Commit 4352b6d3 authored by Dimitri Podborski's avatar Dimitri Podborski
Browse files

improve search by namespace a bit

parent 12eff491
......@@ -52,7 +52,7 @@ The CSV file must have a header row with the folowing entries:
- `Number` - MPEG document number e.g. m12345
- To determine which GitLab project needs to be used make sure that your CSV file has either:
- `Project URL` - a full URL to your GitLab project
- `Project URL` - a full URL to your GitLab project (**recommended**)
- or `Sub Group` and `Project Name` - two last elements of the Project URL. (non-case-sensitive)
e.g.: http://mpegx.int-evry.fr/software/MPEG/Systems/PCC-SYS/V-PCC → `Sub Group = PCC-SYS` and `Project Name = V-PCC`.
e.g.: http://mpegx.int-evry.fr/software/MPEG/Systems/FileFormat/isobmff → `Sub Group = FileFormat` and `Project Name = ISOBMFF`
......
......@@ -157,7 +157,7 @@ def find_document(documents, document_number):
return doc
return None
def find_project(projects, url_or_path):
def find_project(projects, url_or_path, path_root = 'MPEG/'):
'''
Search for gitlab project based on URL or path_with_namespace.
'''
......@@ -167,7 +167,8 @@ def find_project(projects, url_or_path):
for project in projects:
if striped_url_or_path == project['url']:
return project
if striped_url_or_path.lower() in project['path_with_namespace'].lower():
path_ns = project['path_with_namespace'].lower()
if striped_url_or_path.lower() in path_ns and path_ns.startswith(path_root.lower()):
return project
return None
......
......@@ -61,7 +61,7 @@ def print_infos(docs, project_url_or_path, gitlab_projects, input_docs):
print(' Last version: version', last_doc['version'], 'from', last_doc['timestamp'])
if project_url_or_path:
print('GitLab metadata')
project = helpers.find_project(gitlab_projects, project_url_or_path)
project = helpers.find_project(gitlab_projects, project_url_or_path, 'MPEG/Systems')
if not project:
print(' Could not find a GitLab project with', project_url_or_path)
else:
......@@ -234,7 +234,7 @@ def parse_csv(csv_file, projects, docs):
if project_url_or_path is None and subgroup_idx is not None and project_name_idx is not None:
if len(row[subgroup_idx]) > 0 and len(row[project_name_idx]) > 0:
project_url_or_path = row[subgroup_idx] + '/' + row[project_name_idx]
project = helpers.find_project(projects, project_url_or_path)
project = helpers.find_project(projects, project_url_or_path, 'MPEG/Systems')
doc = helpers.find_document(docs, row[doc_number_idx])
if not project:
print('WARNING: No project on GitLab for:', row)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment