Skip to content

Commit

Permalink
remove sdsections (system, methodology, dataset) if no data present (…
Browse files Browse the repository at this point in the history
…issue #65)
  • Loading branch information
JohnsonDylan committed Aug 4, 2021
1 parent 30acc9b commit 08f09a9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
env:
TEST_PYPI_TOKEN_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
run: |
poetry update
poetry build
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry publish -r testpypi --username "__token__" --password $TEST_PYPI_TOKEN_PASSWORD
Expand Down
2 changes: 1 addition & 1 deletion example2.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,4 @@
lic = 'https://creativecommons.org/licenses/by-nc-nd/4.0/'
example.rights(holder, lic)

print(json.dumps(example.output, ensure_ascii=False))
print(json.dumps(example.output, indent=4, ensure_ascii=False))
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "SciDataLib"
version = "0.2.3"
version = "0.2.3.1"
description = "Python library for development of SciData JSON-LD files"
authors = [
"Stuart Chalk <schalk@unf.edu>",
Expand Down
13 changes: 11 additions & 2 deletions scidatalib/scidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,14 +813,15 @@ def output(self) -> dict:
"""
Generates Scidata JSON-LD File
"""
self.__addtoc()
# self.__addtoc()
today = datetime.today()
self.meta['generatedAt'] = today.strftime("%m-%d-%y %H:%M:%S")

# clean top level
for key in list(self.meta['@graph']):
if not self.meta['@graph'][key]:
del self.meta['@graph'][key]
if key != 'toc':
del self.meta['@graph'][key]
for key in list(self.meta['@graph']['scidata']):
if not self.meta['@graph']['scidata'][key]:
del self.meta['@graph']['scidata'][key]
Expand All @@ -829,5 +830,13 @@ def output(self) -> dict:
for key in list(self.meta['@graph']['scidata'][sect]):
if not self.meta['@graph']['scidata'][sect][key]:
del self.meta['@graph']['scidata'][sect][key]
if not self.meta['@graph']['scidata'].get('methodology', {}).get('aspects', False):
del self.meta['@graph']['scidata']['methodology']
if not self.meta['@graph']['scidata'].get('system', {}).get('facets', False):
del self.meta['@graph']['scidata']['system']
if not self.meta['@graph']['scidata'].get('dataset', {}).get('datapoint', False):
if not self.meta['@graph']['scidata'].get('dataset', {}).get('dataseries', False):
del self.meta['@graph']['scidata']['dataset']
self.__addtoc()

return self.meta

0 comments on commit 08f09a9

Please sign in to comment.