Skip to content

Commit

Permalink
development
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfiex committed Nov 19, 2024
1 parent 828ca4f commit 8474f2c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 33 deletions.
65 changes: 37 additions & 28 deletions cmipld/browse/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,45 @@ def main():
print(args.url)
print('-'*50)

try:
if args.deps:

# Extract dependencies
deps = processor.extract_dependencies(args.url, args.relative)
result = sorted(list(deps))
else:
# Process document
result = processor.get(
args.url,
compact=not args.no_compact,
expand_ctx=not args.expand_ctx,
expand_links=not args.no_expand_links
)

# Output results

if args.output:
output = json.dumps(result, indent=2)
with open(args.output, 'w') as f:
f.write(output)
passes=2
while passes:
try:
if args.deps:

if args.no_interactive:
open_jless_with_memory(result)
else:
print(output)
# Extract dependencies
deps = processor.extract_dependencies(args.url, args.relative)
result = sorted(list(deps))
else:
# Process document
result = processor.get(
args.url,
compact=not args.no_compact,
expand_ctx=not args.expand_ctx,
expand_links=not args.no_expand_links
)

# Output results

except Exception as e:
print(f"Error processing document: {str(e)}", file=sys.stderr)
sys.exit(1)
if args.output:
output = json.dumps(result, indent=2)
with open(args.output, 'w') as f:
f.write(output)

if args.no_interactive:
open_jless_with_memory(result)
else:
print(output)

passes=0
sys.exit(0)

except Exception as e:
if 'Could not retrieve a JSON-LD document from the URL.' in str(e):
passes-=1
args.url+= '/graph'
if not passes:
print(f"Error processing document: {str(e)}\n\n", file=sys.stderr)
sys.exit(1)


main()
10 changes: 5 additions & 5 deletions cmipld/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
# locations mandatory for graphing script to run
# added to contexts
mapping = {
'wcrp-universe': 'https://WCRP-CMIP.github.io/WCRP-UNIVERSE/',
'mip-variables': 'https://WCRP-CMIP/github.io/MIPvariables/',
'cmip6plus': 'https://WCRP-CMIP.github.io/CMIP6Plus_CVs/',
'cmip7': 'https://WCRP-CMIP.github.io/CMIP7_CVs/',
'wcrp-universe': 'https:/wcrp-cmip.github.io/WCRP-UNIVERSE/',
'mip-variables': 'https://wcrp-cmip.github.io/MIPvariables/',
'cmip6plus': 'https:/wcrp-cmip.github.io/CMIP6Plus_CVs/',
'cmip7': 'https:/wcrp-cmip.github.io/CMIP7_CVs/',
# 'mip-cmor-tables': 'https://PCMDI.github.io/mip-cmor-tables/',
'cf': 'https://WCRP-CMIP.github.io/WCRP-CMIP/CF/',
'cf': 'https:/wcrp-cmip.github.io/WCRP-CMIP/CF/',
}

historic = ['mip-variables','cmip6plus','cmip7','cf','wcrp-universe','mip-cmor-tables','mip-variables:', 'cmip6plus:', 'cmip7:', 'cf:', 'wcrp-universe:', 'mip-cmor-tables:']
Expand Down

0 comments on commit 8474f2c

Please sign in to comment.