Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 1 | # Copyright 2020 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style |
| 3 | # license that can be found in the LICENSE file or at |
| 4 | # https://developers.google.com/open-source/licenses/bsd |
| 5 | |
| 6 | """Some constants used for managing Monorail Projects.""" |
| 7 | from __future__ import print_function |
| 8 | from __future__ import division |
| 9 | from __future__ import absolute_import |
| 10 | |
| 11 | import re |
| 12 | |
| 13 | PROJECT_NAME_PATTERN = '[a-z0-9][-a-z0-9]*[a-z0-9]' |
| 14 | |
| 15 | MAX_PROJECT_NAME_LENGTH = 63 |
| 16 | |
| 17 | # Pattern to match a valid project name. Users of this pattern MUST use |
| 18 | # the re.VERBOSE flag or the whitespace and comments we be considered |
| 19 | # significant and the pattern will not work. See "re" module documentation. |
| 20 | _RE_PROJECT_NAME_PATTERN_VERBOSE = r""" |
| 21 | (?=[-a-z0-9]*[a-z][-a-z0-9]*) # Lookahead to make sure there is at least |
| 22 | # one letter in the whole name. |
| 23 | [a-z0-9] # Start with a letter or digit. |
| 24 | [-a-z0-9]* # Follow with any number of valid characters. |
| 25 | [a-z0-9] # End with a letter or digit. |
| 26 | """ |
| 27 | |
| 28 | # Compiled regexp to match the project name and nothing more before or after. |
| 29 | RE_PROJECT_NAME = re.compile( |
| 30 | '^%s$' % _RE_PROJECT_NAME_PATTERN_VERBOSE, re.VERBOSE) |