diff --git a/nr_vocabularies/fixtures/accessRights.xlsx b/nr_vocabularies/fixtures/access-rights.xlsx similarity index 100% rename from nr_vocabularies/fixtures/accessRights.xlsx rename to nr_vocabularies/fixtures/access-rights.xlsx diff --git a/nr_vocabularies/fixtures/catalogue.yaml b/nr_vocabularies/fixtures/catalogue.yaml index ab45340..565d495 100644 --- a/nr_vocabularies/fixtures/catalogue.yaml +++ b/nr_vocabularies/fixtures/catalogue.yaml @@ -5,16 +5,16 @@ vocabulary-access-rights: title: cs: Přístupová práva en: Access rights - - source: accessRights.xlsx + - source: access-rights.xlsx -vocabulary-contributor-types: +vocabulary-contributor-roles: - writer: vocabulary - vocabulary: contributor-types + vocabulary: contributor-roles pid_type: v-ct title: cs: Role přispěvatele en: Contributor Type - - source: contributorType.xlsx + - source: contributor-roles.xlsx vocabulary-countries: - writer: vocabulary @@ -50,7 +50,7 @@ vocabulary-item-relation-types: title: cs: Typ vztahu popisovaného dokumentu k propojené jednotce en: The type of relationship of the described document to the interconnected item (unit) - - source: itemRelationType.xlsx + - source: item-relation-types.xlsx vocabulary-languages: - writer: vocabulary @@ -77,16 +77,7 @@ vocabulary-resource-types: title: cs: Typ zdroje en: Resource type - - source: resourceType.xlsx - -vocabulary-related-resource-types: - - writer: vocabulary - vocabulary: related-resource-types - pid_type: v-rel - title: - cs: Typ přidruženého zdroje - en: Related resource type - - source: resourceType_relatedItem.xlsx + - source: resource-types.xlsx vocabulary-subject-categories: - writer: vocabulary @@ -95,4 +86,14 @@ vocabulary-subject-categories: title: cs: Oborové třídění en: Subject categories - - source: subjectCategories.xlsx + - source: subject-categories.xlsx + +# not ok +# vocabulary-related-resource-types: +# - writer: vocabulary +# vocabulary: related-resource-types +# pid_type: v-rel +# title: +# cs: Typ přidruženého zdroje +# en: Related resource type +# - source: resourceType_relatedItem.xlsx diff --git a/nr_vocabularies/fixtures/contributorType.xlsx b/nr_vocabularies/fixtures/contributor-roles.xlsx similarity index 100% rename from nr_vocabularies/fixtures/contributorType.xlsx rename to nr_vocabularies/fixtures/contributor-roles.xlsx diff --git a/nr_vocabularies/fixtures/institutions_old.xlsx b/nr_vocabularies/fixtures/institutions_old.xlsx deleted file mode 100644 index 232a877..0000000 Binary files a/nr_vocabularies/fixtures/institutions_old.xlsx and /dev/null differ diff --git a/nr_vocabularies/fixtures/itemRelationType.xlsx b/nr_vocabularies/fixtures/item-relation-types.xlsx similarity index 100% rename from nr_vocabularies/fixtures/itemRelationType.xlsx rename to nr_vocabularies/fixtures/item-relation-types.xlsx diff --git a/nr_vocabularies/fixtures/onetime_transform_institutions.py b/nr_vocabularies/fixtures/onetime_transform_institutions.py deleted file mode 100644 index ecb3e4e..0000000 --- a/nr_vocabularies/fixtures/onetime_transform_institutions.py +++ /dev/null @@ -1,107 +0,0 @@ -import re - -import openpyxl -from unidecode import unidecode - -# nasty -rowidx = 0 - - -def next_row(it): - global rowidx - rowidx += 1 - return [x.value for x in next(it)] - - -def empty(r): - for val in r: - if val: - return False - return True - - -wb_obj = openpyxl.load_workbook("tests/complex-data/institutions_old.xlsx") -sheet_obj = wb_obj.active - - -it = sheet_obj.iter_rows() - -stack = [] -ids = set() - -shortcuts = { - "fakulta-jaderna-a-fyzikalne-inzenyrska": "FJFI", - "prirodovedecka": "Pr", - "pedagogicka": "Ped", - "filozoficka": "F", - "strojni": "St", -} - -try: - row = next_row(it) - while empty(row): - row = next_row(it) - while not empty(row): - row = next_row(it) - while empty(row): - row = next_row(it) - header = True - while True: - if not empty(row): - if header: - assert row[0] == "level" - assert row[1] == "slug" - assert row[7] == "props.acronym" - - sheet_obj.cell(row=rowidx, column=1).value = "hierarchy.parent" - sheet_obj.cell(row=rowidx, column=2).value = "id" - header = False - row = next_row(it) - continue - - level = int(row[0]) - slug = re.sub(r"\W+", "-", row[2].lower().strip()) - while level <= len(stack): - stack.pop() - if stack: - parent, base = stack[-1] - else: - parent, base = ("", "") - id = str(row[7] or slug) - split_id = [] - if id.endswith("-cas"): - split_id = [id] - else: - for word in id.split("-"): - if word in shortcuts: - split_id.append(shortcuts[word]) - continue - for ci, c in enumerate(word): - if ci == 0 or c == c.upper(): - split_id.append(c.upper()) - short_id = "".join(split_id) - - if base: - id = f"{base}-{id}" - short_id = f"{base}-{short_id}" - - if short_id not in ids and len(short_id) > 2: - base = short_id - else: - base = id - id = unidecode(id.lower()) - assert id not in ids - - print(id, str(row[7] or slug)) - - ids.add(id) - stack.append((id, base)) - sheet_obj.cell(row=rowidx, column=1).value = parent - sheet_obj.cell(row=rowidx, column=2).value = id - - row = next_row(it) -except StopIteration: - pass - - -wb_obj.save("tests/complex-data/institutions.xlsx") diff --git a/nr_vocabularies/fixtures/resourceType.xlsx b/nr_vocabularies/fixtures/resource-types.xlsx similarity index 100% rename from nr_vocabularies/fixtures/resourceType.xlsx rename to nr_vocabularies/fixtures/resource-types.xlsx diff --git a/nr_vocabularies/fixtures/subjectCategories.xlsx b/nr_vocabularies/fixtures/subject-categories.xlsx similarity index 100% rename from nr_vocabularies/fixtures/subjectCategories.xlsx rename to nr_vocabularies/fixtures/subject-categories.xlsx diff --git a/setup.cfg b/setup.cfg index ae774a0..aeeee53 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,7 @@ [metadata] name = nr-vocabularies -version = 2.0.0 +version = 2.0.1 description = A sample application for nr_vocabularies long_description = Model builder plugin containing model definition of nr-vocabularies authors = Alzbeta Pokorna diff --git a/tests/test_import_export.py b/tests/test_import_export.py index 83fe8a5..481a0af 100644 --- a/tests/test_import_export.py +++ b/tests/test_import_export.py @@ -1,4 +1,3 @@ - import tempfile from invenio_vocabularies.records.api import Vocabulary @@ -9,7 +8,7 @@ def test_complex_import_export(app, db, cache, search_clear, vocab_cf): result = load_fixtures() assert result.failed_count == 0 assert result.skipped_count == 0 - assert len(result.results) == 11 + assert len(result.results) == 10 Vocabulary.index.refresh() with tempfile.TemporaryDirectory() as d: dump_result = dump_fixtures(d)