From 0e53a802ef3a1f4c457134295eff414e0cfe45d8 Mon Sep 17 00:00:00 2001 From: Jakob Voss Date: Tue, 9 Mar 2021 11:36:55 +0100 Subject: [PATCH 1/3] Add option --add-table-numbers --- mc2skos/mc2skos.py | 5 ++++- mc2skos/record.py | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mc2skos/mc2skos.py b/mc2skos/mc2skos.py index 6c05a73..a1d1761 100755 --- a/mc2skos/mc2skos.py +++ b/mc2skos/mc2skos.py @@ -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) @@ -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', @@ -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, diff --git a/mc2skos/record.py b/mc2skos/record.py index fbf6ccc..1f894bb 100644 --- a/mc2skos/record.py +++ b/mc2skos/record.py @@ -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) @@ -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 From abe755b1281851a333a5e262ecbeafc831aa4ee7 Mon Sep 17 00:00:00 2001 From: Jakob Voss Date: Mon, 26 Feb 2024 13:25:03 +0100 Subject: [PATCH 2/3] Replace rdflib-jsonld (#72) --- mc2skos/mc2skos.py | 4 ++-- setup.py | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mc2skos/mc2skos.py b/mc2skos/mc2skos.py index a1d1761..6d30943 100755 --- a/mc2skos/mc2skos.py +++ b/mc2skos/mc2skos.py @@ -16,7 +16,7 @@ from rdflib import URIRef, Literal, Graph, BNode from otsrdflib import OrderedTurtleSerializer import json -import rdflib_jsonld.serializer as json_ld +import jsonld from rdflib.plugins.serializers import pkg_resources import skosify @@ -351,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')) diff --git a/setup.py b/setup.py index 108a0c7..378623a 100644 --- a/setup.py +++ b/setup.py @@ -29,9 +29,7 @@ author_email='danmichaelo@gmail.com', 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', From d2f647fed187cf0430a15d4b4e2ada9c7443aa01 Mon Sep 17 00:00:00 2001 From: Jakob Voss Date: Mon, 26 Feb 2024 14:34:01 +0100 Subject: [PATCH 3/3] Fix import --- mc2skos/mc2skos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mc2skos/mc2skos.py b/mc2skos/mc2skos.py index 6d30943..0c085ab 100755 --- a/mc2skos/mc2skos.py +++ b/mc2skos/mc2skos.py @@ -16,7 +16,7 @@ from rdflib import URIRef, Literal, Graph, BNode from otsrdflib import OrderedTurtleSerializer import json -import jsonld from rdflib.plugins.serializers +from rdflib.plugins.serializers import jsonld import pkg_resources import skosify