Skip to content

Commit

Permalink
Fix codelists2ttl.py and upload_changes.py #6
Browse files Browse the repository at this point in the history
The codelists2ttl.py no longer generates wis.ttl - we are not going to change this top-level register once the WIS specification is published, so it can remain a manual process.
Fixed checking of sub-register existence and a few other minor issues in upload_changes.py.
  • Loading branch information
josusky committed Feb 12, 2024
1 parent 06b36d4 commit 4841668
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
5 changes: 0 additions & 5 deletions scripts/codelists2ttl.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,4 @@ def gen_skos_concept(name: str, description: str, source: str = None) -> str:

fh3.write(ttl)

register_ttl_file = ttl_files_path / 'wis.ttl'
print(f'Generating {register_ttl_file}')
with register_ttl_file.open('w') as fh:
fh.write(gen_skos_register(subregisters))

print('Done')
16 changes: 9 additions & 7 deletions scripts/upload_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,10 @@ def put(session: requests.Session, url: str, payload: str,
"""

params = {
'status': status
'status': status,
'non-member-properties': 'true'
}

# for register update adjust the URL
if 'reg:Register' in payload:
url += '?non-member-properties'
if not dry_run:
if verbose:
print(f' HTTP PUT to: {url}')
Expand Down Expand Up @@ -159,10 +157,12 @@ def upload(session: requests.Session, url: str, payload: str,
:returns: `None`
"""

# to check existence adjust the URL
url_to_check = url + '/'
if verbose:
print(f' Checking {url} - ', end=" ")
print(f' Checking {url_to_check} - ', end=" ")

response = session.get(url, headers=HEADERS)
response = session.get(url_to_check, headers=HEADERS)

if response.status_code == 200:
if verbose:
Expand Down Expand Up @@ -236,7 +236,9 @@ def upload_file(session: requests.Session, url: str, filepath: Path,
if not Path(args.directory).is_dir():
raise ValueError(f'Directory {args.directory} does not exists.')
if args.mode not in ['test', 'prod']:
raise ValueError('Mode must be either test or prod')
raise ValueError('Mode must be either "test" or "prod"')
if args.status not in ['stable', 'experimental']:
raise ValueError('Mode must be either "stable" or "experimental"')
if args.mode == 'prod':
REGISTRY = PROD_REGISTRY

Expand Down

0 comments on commit 4841668

Please sign in to comment.