blob: 4be334888eb850fe755fb2c2f5ebb7a9bcc223a7 [file] [log] [blame]
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +01001# 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.
Copybara854996b2021-09-07 19:36:02 +00004
5"""Some constants used for managing Monorail Projects."""
6from __future__ import print_function
7from __future__ import division
8from __future__ import absolute_import
9
10import re
11
12PROJECT_NAME_PATTERN = '[a-z0-9][-a-z0-9]*[a-z0-9]'
13
14MAX_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.
28RE_PROJECT_NAME = re.compile(
29 '^%s$' % _RE_PROJECT_NAME_PATTERN_VERBOSE, re.VERBOSE)