Skip to content

Commit 18f8bd3

Browse files
author
Vladimir Kotal
committed
allow regular expression matching for project names
1 parent eb000c4 commit 18f8bd3

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tools/sync/mirror.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
from readconfig import read_config
5353
from opengrok import get_repos, get_config_value, get_repo_type
5454
from shutil import which
55+
import re
5556

5657

5758
major_version = sys.version_info[0]
@@ -122,9 +123,22 @@
122123

123124
project_config = None
124125
try:
125-
if config['projects']:
126-
if config['projects'][args.project]:
127-
project_config = config['projects'][args.project]
126+
projects = config['projects']
127+
if projects:
128+
if projects.get(args.project):
129+
project_config = projects.get(args.project)
130+
else:
131+
for proj in projects.keys():
132+
try:
133+
pattern = re.compile(proj)
134+
except re.error:
135+
logger.error("Not a valid regular exception: {}".
136+
format(proj))
137+
continue
138+
139+
if pattern.match(args.project):
140+
project_config = projects.get(proj)
141+
break
128142
except KeyError:
129143
# The project has no config, that's fine - defaults will be used.
130144
pass

0 commit comments

Comments
 (0)