Commit fabb3978 authored by Dimitri Podborski's avatar Dimitri Podborski
Browse files

cosmetics

parent da557580
...@@ -41,16 +41,18 @@ deactivate ...@@ -41,16 +41,18 @@ deactivate
`systems.py` is a script which is intended to be used in the Systems group. Use the `-h` option to see all available parameters. This script allows you to: `systems.py` is a script which is intended to be used in the Systems group. Use the `-h` option to see all available parameters. This script allows you to:
1. Print information about input documents on MDMS and GitLab (`-p` is optional): 1. Open issues based on the information provided in a CSV file:
e.g.: `python systems.py -m m55958,m55959,m56121 -p FileFormat/CENC --meeting 133` e.g.: `python systems.py -o --csv Contribs.csv`
2. Open issues based on the information provided in a CSV file: 2. Open issues based on CLI options:
e.g.: `python systems.py --csv Contribs.csv -o` e.g.: `python3 systems.py -o -m 55958,55959,56121 -p FileFormat/CENC --meeting 133`
3. Open issues based on the CLI options:
e.g.: `python systems.py -m m56345,m56346 -p http://mpegx.int-evry.fr/software/podborski/test`
3. Generate an output document based on the information provided in a CSV file. Use a template as a basis (`--template` is optional): 3. Generate an output document based on the information provided in a CSV file. Use a template as a basis (`--template` is optional):
e.g.: `python systems.py --csv Contribs.csv -d --template templates/WG03_input_template_dimitri.docx` e.g.: `python systems.py -d --csv Contribs.csv --template template.docx`
4. Close issues basd on the information provided in a CSV file: 4. Close issues based on the information provided in a CSV file:
e.g.: `python systems.py --csv Contribs.csv -c` e.g.: `python systems.py -c --csv Contribs.csv`
5. Close issues based on CLI options:
e.g.: `python systems.py -c -m m55958,m55959,m56121 -p FileFormat/CENC --meeting 133`
6. Print information about input documents on MDMS and GitLab:
e.g.: `python systems.py -l -m m55958,m55959,m56121 -p FileFormat/CENC --meeting 133`
The CSV file must have a header row with the folowing entries: The CSV file must have a header row with the folowing entries:
...@@ -58,8 +60,8 @@ The CSV file must have a header row with the folowing entries: ...@@ -58,8 +60,8 @@ The CSV file must have a header row with the folowing entries:
- To determine which GitLab project needs to be used make sure that your CSV file has either: - 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 (*recommended*) - **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) - 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/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` e.g.: `http://mpegx.int-evry.fr/software/MPEG/Systems/FileFormat/isobmff` → `Sub Group = FileFormat` and `Project Name = ISOBMFF`
- **Close issue** - is required if you want to close multiple issues at once. Supported values are `0`, `1`, `TRUE`, `FALSE`, `true` and `false`. - **Close issue** - is required if you want to close multiple issues at once. Supported values are `0`, `1`, `TRUE`, `FALSE`, `true` and `false`.
The example CSV below has both `Project URL` and (`Sub Group` with `Project Name`) but you can also have one of these in your CSV. The CSV delimiter is determined automatically. The example CSV below has both `Project URL` and (`Sub Group` with `Project Name`) but you can also have one of these in your CSV. The CSV delimiter is determined automatically.
......
...@@ -94,12 +94,11 @@ def open_new_issue(project_id, document, test, meeting_start, gitlab_members): ...@@ -94,12 +94,11 @@ def open_new_issue(project_id, document, test, meeting_start, gitlab_members):
issue_title = helpers.create_issue_title(document) issue_title = helpers.create_issue_title(document)
document_details = mdms.get_document_details(document['mdms_id']) document_details = mdms.get_document_details(document['mdms_id'])
if document_details is None: if document_details is None:
print(' Skip', document['document']) print(' No document details found. Skip', document['document'])
return return False
issue_description = helpers.create_issue_description(document, document_details) issue_description = helpers.create_issue_description(document, document_details)
if len(usernames) > 0: if len(usernames) > 0:
issue_description += '\n_for:_ ' + ''.join('@'+str(u)+', ' for u in usernames) issue_description += '\n_for:_ ' + ''.join('@'+str(u)+', ' for u in usernames)
print(issue_description)
issue_lables = [] issue_lables = []
timestamp = datetime.now() timestamp = datetime.now()
if len(document_details['documents']) > 0: if len(document_details['documents']) > 0:
...@@ -112,15 +111,19 @@ def open_new_issue(project_id, document, test, meeting_start, gitlab_members): ...@@ -112,15 +111,19 @@ def open_new_issue(project_id, document, test, meeting_start, gitlab_members):
if not test: if not test:
print(' * {}: Open issue with title "{}" | Lables={}'.format(document['document'], issue_title, issue_lables)) print(' * {}: Open issue with title "{}" | Lables={}'.format(document['document'], issue_title, issue_lables))
gitlab.open_issue(project_id, issue_title, issue_description, issue_lables) gitlab.open_issue(project_id, issue_title, issue_description, issue_lables)
return True
else: else:
print(' * {}: Test open issue with title "{}" | Lables={}'.format(document['document'], issue_title, issue_lables)) print(' * {}: Test open issue with title "{}" | Lables={}'.format(document['document'], issue_title, issue_lables))
return False
def close_issue(issue, test): def close_issue(issue, test, document):
if not test: if not test:
print(' * Close issue:', issue.web_url) print(' * {}: Close issue: {}'.format(document['document'], issue.web_url))
gitlab.close_issue(issue) gitlab.close_issue(issue)
return True
else: else:
print(' * Test close issue:', issue.web_url) print(' * {}: Test close issue: {}'.format(document['document'], issue.web_url))
return False
def open_issues(table_entries, test, gitlab_members, meeting_start): def open_issues(table_entries, test, gitlab_members, meeting_start):
print('\nOpen {} issues. TestMode={}'.format(len(table_entries), test)) print('\nOpen {} issues. TestMode={}'.format(len(table_entries), test))
...@@ -133,8 +136,9 @@ def open_issues(table_entries, test, gitlab_members, meeting_start): ...@@ -133,8 +136,9 @@ def open_issues(table_entries, test, gitlab_members, meeting_start):
issue_with_title, issue_with_meta, meta_last_doc_version = helpers.find_issue(issues, document) issue_with_title, issue_with_meta, meta_last_doc_version = helpers.find_issue(issues, document)
if issue_with_title is None and issue_with_meta is None: if issue_with_title is None and issue_with_meta is None:
open_new_issue(project_id, document, test, meeting_start, gitlab_members) was_opened = open_new_issue(project_id, document, test, meeting_start, gitlab_members)
counter += 1 if was_opened:
counter += 1
elif issue_with_title is not None and issue_with_meta is None: elif issue_with_title is not None and issue_with_meta is None:
print(' * {}: ATTENTION Another issue with the same document number in the title was found on GitLab.'.format(document['document'])) print(' * {}: ATTENTION Another issue with the same document number in the title was found on GitLab.'.format(document['document']))
print(' - Issue URL:', issue_with_title.web_url) print(' - Issue URL:', issue_with_title.web_url)
...@@ -142,8 +146,9 @@ def open_issues(table_entries, test, gitlab_members, meeting_start): ...@@ -142,8 +146,9 @@ def open_issues(table_entries, test, gitlab_members, meeting_start):
print(' - Should we still open a new one?') print(' - Should we still open a new one?')
user_input = input(' Type y or n: ') user_input = input(' Type y or n: ')
if 'y' in user_input: if 'y' in user_input:
open_new_issue(project_id, document, test, meeting_start, gitlab_members) was_opened = open_new_issue(project_id, document, test, meeting_start, gitlab_members)
counter += 1 if was_opened:
counter += 1
else: else:
print(' * {} Skip "{}"'.format(document['document'], document['title'])) print(' * {} Skip "{}"'.format(document['document'], document['title']))
else: else:
...@@ -179,7 +184,7 @@ def open_issues(table_entries, test, gitlab_members, meeting_start): ...@@ -179,7 +184,7 @@ def open_issues(table_entries, test, gitlab_members, meeting_start):
print('Opened issues:', counter) print('Opened issues:', counter)
def close_issues(table_entries, test): def close_issues(table_entries, test):
print('\nClose issues. TestMode =', test) print('\nClose {} issues. TestMode={}'.format(len(table_entries), test))
counter = 0 counter = 0
for entry in table_entries: for entry in table_entries:
document = entry['document'] document = entry['document']
...@@ -192,21 +197,24 @@ def close_issues(table_entries, test): ...@@ -192,21 +197,24 @@ def close_issues(table_entries, test):
issues = gitlab.get_issues(project_id) issues = gitlab.get_issues(project_id)
issue_with_title, issue_with_meta, _meta_last_doc_version = helpers.find_issue(issues, document) issue_with_title, issue_with_meta, _meta_last_doc_version = helpers.find_issue(issues, document)
if issue_with_meta is None and issue_with_title is None: if issue_with_meta is None and issue_with_title is None:
print(' * No issue to close for:', document['document'], 'in', entry['project']['url']) print(' * {}: No issue to close in: {}'.format(document['document'], entry['project']['url']))
if issue_with_meta is not None: if issue_with_meta is not None:
close_issue(issue_with_meta, test) was_closed = close_issue(issue_with_meta, test, document)
counter += 1 if was_closed:
counter += 1
if issue_with_title is not None: if issue_with_title is not None:
print(' * *** ATTENTION *** User created issue with the same document number in the title was found on GitLab.') print(' * {}: ATTENTION User created issue with the same document number in the title was found on GitLab.'.format(document['document']))
print(' - Issue:', issue_with_title.web_url) print(' - Issue URL:', issue_with_title.web_url)
print(' - Issue Title:', issue_with_title.title)
print(' - Should we also close it?') print(' - Should we also close it?')
user_input = input('Type y or n: ') user_input = input(' Type y or n: ')
if 'y' in user_input: if 'y' in user_input:
close_issue(issue_with_title, test) was_closed = close_issue(issue_with_title, test, document)
counter += 1 if was_closed:
counter += 1
else: else:
print(' * Skip', document['document'], document['title']) print(' * Skip "{}"'.format(issue_with_title.title))
print(' * Closed issues:', counter) print('Closed issues:', counter)
def create_output_doc(table_entries, output_path, template_path): def create_output_doc(table_entries, output_path, template_path):
print('\nCreate Output Document') print('\nCreate Output Document')
......
Markdown is supported
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