Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option --add-table-numbers #71

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions mc2skos/mc2skos.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from rdflib import URIRef, Literal, Graph, BNode
from otsrdflib import OrderedTurtleSerializer
import json
import rdflib_jsonld.serializer as json_ld
from rdflib.plugins.serializers import jsonld
import pkg_resources
import skosify

Expand Down Expand Up @@ -173,7 +173,7 @@ def process_record(graph, rec, **kwargs):
raise InvalidRecordError('Record is not a Marc21 Classification or Authority record',
control_number=el.text('mx:controlfield[@tag="001"]'))

if rec.is_public():
if rec.is_public(add_table_numbers=kwargs.get('add_table_numbers')):
add_record_to_graph(graph, rec, kwargs)


Expand Down Expand Up @@ -235,6 +235,8 @@ def main():
help='Include component information from 765.')
parser.add_argument('--webdewey', dest='webdewey', action='store_true',
help='Include non-standard WebDewey notes from 680.')
parser.add_argument('--add-table-numbers', dest='add_table_numbers', action='store_true',
help='Include add table numbers (notations with a colon)')
parser.add_argument('--skip-classification', dest='skip_classification', action='store_true',
help='Skip classification records')
parser.add_argument('--skip-authority', dest='skip_authority', action='store_true',
Expand Down Expand Up @@ -307,6 +309,7 @@ def main():
'exclude_notes': args.exclude_notes,
'include_components': args.components,
'include_webdewey': args.webdewey,
'add_table_numbers': args.add_table_numbers,
'skip_classification': args.skip_classification,
'skip_authority': args.skip_authority,
'expand': args.expand,
Expand Down Expand Up @@ -348,7 +351,7 @@ def main():
elif args.outformat in ['jskos', 'ndjson']:
s = pkg_resources.resource_string(__name__, 'jskos-context.json').decode('utf-8')
context = json.loads(s)
jskos = json_ld.from_rdf(graph, context)
jskos = jsonld.from_rdf(graph, context)
if args.outformat == 'jskos':
jskos['@context'] = u'https://gbv.github.io/jskos/context.json'
out_file.write(json.dumps(jskos, sort_keys=True, indent=2).encode('utf-8'))
Expand Down
5 changes: 2 additions & 3 deletions mc2skos/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ def parse_153(element):

return table, notation, is_top_concept, parent_notation, caption

def is_public(self):
def is_public(self, add_table_numbers=False):
if not self.display:
# This is a record not displayed in standard schedules or tables
# or in extended display. It could be a deleted (not deprecated)
Expand All @@ -583,8 +583,7 @@ def is_public(self):
logger.debug('%s is a type %s', self.notation, self.record_type)
return False

include_add_table_numbers = False # @TODO: Make argparse option
if self.notation.find(':') != -1 and not include_add_table_numbers:
if self.notation.find(':') != -1 and not add_table_numbers:
logger.debug('%s is an add table number', self.notation)
return False

Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
author_email='[email protected]',
url='https://github.com/scriptotek/mc2skos',
license='MIT',
install_requires=['rdflib[sparql]',
'rdflib-jsonld',
'lxml',
install_requires=['lxml',
'otsrdflib>=0.5.0,<0.6.0',
'iso-639',
'pyyaml',
Expand Down