Skip to content

Commit

Permalink
Merge pull request #85 from NatLibFi/issue84-post-update-query
Browse files Browse the repository at this point in the history
add post_update_query option
  • Loading branch information
osma committed Aug 30, 2021
2 parents 6dca4ae + d482cf5 commit 0bcb8d7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions skosify/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,18 @@ def get_option_parser(defaults):
group.add_option('--construct-query', type='string',
help='SPARQL CONSTRUCT query. '
'This query is executed against the input '
'data and the result graph is used as the '
'actual input. '
'data (after possible --update-query) and '
'the result graph is used as the actual input. '
'The value can be either the actual query, '
'or "@filename".')
group.add_option('--post-update-query', type='string',
help='SPARQL update query. '
'This convenience query is executed against '
'the output data before writing it. '
'The value can be either the actual query, '
'or "@filename". '
'Use at your own risk - output may not be '
'SKOS at all.')
group.add_option('-I', '--infer', action="store_true",
help='Perform RDFS subclass/subproperty inference '
'before transforming input.')
Expand Down
1 change: 1 addition & 0 deletions skosify/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __init__(self, file=None):
self.infer = False
self.update_query = None
self.construct_query = None
self.post_update_query = None

# mappings
self.types = {}
Expand Down
6 changes: 5 additions & 1 deletion skosify/skosify.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,13 +823,17 @@ def skosify(*sources, **config):
# check for duplicate labels
check_labels(voc, config.preflabel_policy)

logging.debug("Phase 10: Performing post update query")
if config.post_update_query is not None:
transform_sparql_update(voc, config.post_update_query)

processtime = time.time()

logging.debug("reading input file took %d seconds",
(inputtime - starttime))
logging.debug("processing took %d seconds",
(processtime - inputtime))

logging.debug("Phase 10: Writing output")
logging.debug("Phase 11: Writing output")

return voc

0 comments on commit 0bcb8d7

Please sign in to comment.