blob: f483b1fbf0fa74f7c295aa30bc2927678fe0682c [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001# 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."""
7from __future__ import print_function
8from __future__ import division
9from __future__ import absolute_import
10
11import re
12
13PROJECT_NAME_PATTERN = '[a-z0-9][-a-z0-9]*[a-z0-9]'
14
15MAX_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.
29RE_PROJECT_NAME = re.compile(
30 '^%s$' % _RE_PROJECT_NAME_PATTERN_VERBOSE, re.VERBOSE)