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