cds-dojson 0.14.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cds_dojson/__init__.py +22 -0
- cds_dojson/cli.py +63 -0
- cds_dojson/exceptions.py +18 -0
- cds_dojson/marc21/__init__.py +24 -0
- cds_dojson/marc21/fields/__init__.py +19 -0
- cds_dojson/marc21/fields/base.py +57 -0
- cds_dojson/marc21/fields/books/__init__.py +19 -0
- cds_dojson/marc21/fields/books/base.py +909 -0
- cds_dojson/marc21/fields/books/book.py +118 -0
- cds_dojson/marc21/fields/books/errors.py +52 -0
- cds_dojson/marc21/fields/books/journal.py +161 -0
- cds_dojson/marc21/fields/books/multipart.py +351 -0
- cds_dojson/marc21/fields/books/serial.py +52 -0
- cds_dojson/marc21/fields/books/standard.py +86 -0
- cds_dojson/marc21/fields/books/utils.py +134 -0
- cds_dojson/marc21/fields/books/values_mapping.py +305 -0
- cds_dojson/marc21/fields/rdm/__init__.py +19 -0
- cds_dojson/marc21/fields/rdm/base.py +41 -0
- cds_dojson/marc21/fields/utils.py +546 -0
- cds_dojson/marc21/fields/videos/__init__.py +19 -0
- cds_dojson/marc21/fields/videos/base.py +162 -0
- cds_dojson/marc21/fields/videos/project.py +37 -0
- cds_dojson/marc21/fields/videos/utils.py +50 -0
- cds_dojson/marc21/fields/videos/video.py +329 -0
- cds_dojson/marc21/models/__init__.py +19 -0
- cds_dojson/marc21/models/base.py +28 -0
- cds_dojson/marc21/models/books/__init__.py +19 -0
- cds_dojson/marc21/models/books/base.py +234 -0
- cds_dojson/marc21/models/books/book.py +63 -0
- cds_dojson/marc21/models/books/journal.py +105 -0
- cds_dojson/marc21/models/books/multipart.py +70 -0
- cds_dojson/marc21/models/books/serial.py +222 -0
- cds_dojson/marc21/models/books/standard.py +60 -0
- cds_dojson/marc21/models/videos/__init__.py +19 -0
- cds_dojson/marc21/models/videos/base.py +29 -0
- cds_dojson/marc21/models/videos/project.py +60 -0
- cds_dojson/marc21/models/videos/video.py +99 -0
- cds_dojson/marc21/utils.py +88 -0
- cds_dojson/matcher.py +107 -0
- cds_dojson/overdo.py +114 -0
- cds_dojson/schemas/__init__.py +19 -0
- cds_dojson/schemas/categories/category-v1.0.0.json +39 -0
- cds_dojson/schemas/deposits/deposit-cds-v1.0.0.json +88 -0
- cds_dojson/schemas/deposits/records/base-v1.0.0.json +51 -0
- cds_dojson/schemas/deposits/records/videos/project/project-v1.0.0.json +482 -0
- cds_dojson/schemas/deposits/records/videos/project/project_src-v1.0.0.json +21 -0
- cds_dojson/schemas/deposits/records/videos/video/video-v1.0.0.json +687 -0
- cds_dojson/schemas/deposits/records/videos/video/video_src-v1.0.0.json +34 -0
- cds_dojson/schemas/keywords/keyword-v1.0.0.json +19 -0
- cds_dojson/schemas/records/base-v1.0.0.json +103 -0
- cds_dojson/schemas/records/definitions-v1.0.0.json +428 -0
- cds_dojson/schemas/records/videos/project/project-v1.0.0.json +434 -0
- cds_dojson/schemas/records/videos/project/project_src-v1.0.0.json +129 -0
- cds_dojson/schemas/records/videos/video/video-v1.0.0.json +628 -0
- cds_dojson/schemas/records/videos/video/video_src-v1.0.0.json +171 -0
- cds_dojson/schemas/records-files/records-files-cds-v1.0.0.json +23 -0
- cds_dojson/schemas/transform.py +74 -0
- cds_dojson/translations/.gitkeep +0 -0
- cds_dojson/utils.py +211 -0
- cds_dojson-0.14.0.dist-info/METADATA +26 -0
- cds_dojson-0.14.0.dist-info/RECORD +66 -0
- cds_dojson-0.14.0.dist-info/WHEEL +5 -0
- cds_dojson-0.14.0.dist-info/entry_points.txt +45 -0
- cds_dojson-0.14.0.dist-info/licenses/AUTHORS.rst +8 -0
- cds_dojson-0.14.0.dist-info/licenses/LICENSE +38 -0
- cds_dojson-0.14.0.dist-info/top_level.txt +1 -0
cds_dojson/__init__.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# This file is part of CERN Document Server.
|
|
4
|
+
# Copyright (C) 2015 CERN.
|
|
5
|
+
#
|
|
6
|
+
# Invenio is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the GNU General Public License as
|
|
8
|
+
# published by the Free Software Foundation; either version 2 of the
|
|
9
|
+
# License, or (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# Invenio is distributed in the hope that it will be useful, but
|
|
12
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14
|
+
# General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
|
|
18
|
+
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
|
19
|
+
|
|
20
|
+
"""The CDS DoJson."""
|
|
21
|
+
|
|
22
|
+
__version__ = "0.14.0"
|
cds_dojson/cli.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# This file is part of CERN Document Server.
|
|
4
|
+
# Copyright (C) 2016, 2017 CERN.
|
|
5
|
+
#
|
|
6
|
+
# CERN Document Server is free software; you can redistribute it
|
|
7
|
+
# and/or modify it under the terms of the GNU General Public License as
|
|
8
|
+
# published by the Free Software Foundation; either version 2 of the
|
|
9
|
+
# License, or (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# CERN Document Server is distributed in the hope that it will be
|
|
12
|
+
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14
|
+
# General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with CERN Document Server; if not, write to the
|
|
18
|
+
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
19
|
+
# MA 02111-1307, USA.
|
|
20
|
+
#
|
|
21
|
+
# In applying this license, CERN does not
|
|
22
|
+
# waive the privileges and immunities granted to it by virtue of its status
|
|
23
|
+
# as an Intergovernmental Organization or submit itself to any jurisdiction.
|
|
24
|
+
|
|
25
|
+
"""CLI additions to ``dojson``."""
|
|
26
|
+
|
|
27
|
+
from __future__ import absolute_import, print_function
|
|
28
|
+
|
|
29
|
+
import json
|
|
30
|
+
import os
|
|
31
|
+
import sys
|
|
32
|
+
|
|
33
|
+
import click
|
|
34
|
+
|
|
35
|
+
from .schemas.transform import compile_schema as _compile_schema
|
|
36
|
+
from .utils import yaml2json
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@click.group()
|
|
40
|
+
def cli():
|
|
41
|
+
"""CDS dojson CLI."""
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@cli.command()
|
|
45
|
+
@click.argument("schema", type=click.Path(exists=True))
|
|
46
|
+
def compile_schema(schema):
|
|
47
|
+
"""Compile ``$ref`` and ``allOf`` key from the given JSON schema."""
|
|
48
|
+
with open(schema) as f:
|
|
49
|
+
schema_json = json.load(f)
|
|
50
|
+
|
|
51
|
+
base_uri = "file://{0}/".format(os.path.dirname(os.path.abspath(schema)))
|
|
52
|
+
|
|
53
|
+
click.echo(json.dumps(_compile_schema(schema_json, base_uri), indent=2))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@cli.command()
|
|
57
|
+
@click.argument("source", type=click.Path(exists=True))
|
|
58
|
+
@click.argument("destination", type=click.Path())
|
|
59
|
+
def convert_yaml2json(source, destination):
|
|
60
|
+
"""Convert files from yaml to json."""
|
|
61
|
+
if sys.version_info[0] <= 3 and sys.version_info[1] < 6:
|
|
62
|
+
click.echo("Use Python 3.6+ to deterministically generate the json.")
|
|
63
|
+
yaml2json(source, destination)
|
cds_dojson/exceptions.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2026 CERN.
|
|
4
|
+
#
|
|
5
|
+
# CDS-Doson is free software; you can redistribute it and/or modify it under
|
|
6
|
+
# the terms of the MIT License; see LICENSE file for more details.
|
|
7
|
+
|
|
8
|
+
"""CDS-Dojson exceptions module."""
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ModelMissingException(Exception):
|
|
12
|
+
"""CDSDoJSONException class."""
|
|
13
|
+
|
|
14
|
+
description = "[Record did not match any available model]"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class MultipleModelsException(Exception):
|
|
18
|
+
"""CDSDoJSONException class."""
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# This file is part of CERN Document Server.
|
|
4
|
+
# Copyright (C) 2015 CERN.
|
|
5
|
+
#
|
|
6
|
+
# Invenio is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the GNU General Public License as
|
|
8
|
+
# published by the Free Software Foundation; either version 2 of the
|
|
9
|
+
# License, or (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# Invenio is distributed in the hope that it will be useful, but
|
|
12
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14
|
+
# General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
|
|
18
|
+
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
|
19
|
+
|
|
20
|
+
"""MARC21."""
|
|
21
|
+
|
|
22
|
+
from ..overdo import OverdoBase
|
|
23
|
+
|
|
24
|
+
marc21 = OverdoBase(entry_point_models="cds_dojson.marc21.models")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# This file is part of CERN Document Server.
|
|
4
|
+
# Copyright (C) 2017 CERN.
|
|
5
|
+
#
|
|
6
|
+
# Invenio is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the GNU General Public License as
|
|
8
|
+
# published by the Free Software Foundation; either version 2 of the
|
|
9
|
+
# License, or (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# Invenio is distributed in the hope that it will be useful, but
|
|
12
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14
|
+
# General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
|
|
18
|
+
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
|
19
|
+
"""CDS fields."""
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# This file is part of CERN Document Server.
|
|
4
|
+
# Copyright (C) 2017 CERN.
|
|
5
|
+
#
|
|
6
|
+
# Invenio is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the GNU General Public License as
|
|
8
|
+
# published by the Free Software Foundation; either version 2 of the
|
|
9
|
+
# License, or (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# Invenio is distributed in the hope that it will be useful, but
|
|
12
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14
|
+
# General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
|
|
18
|
+
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
|
19
|
+
"""Common fields."""
|
|
20
|
+
|
|
21
|
+
from __future__ import absolute_import, print_function
|
|
22
|
+
|
|
23
|
+
from dojson.utils import (
|
|
24
|
+
IgnoreKey,
|
|
25
|
+
filter_values,
|
|
26
|
+
for_each_value,
|
|
27
|
+
force_list,
|
|
28
|
+
ignore_value,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
from ..models.base import model
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@model.over("recid", "^001")
|
|
35
|
+
def recid(self, key, value):
|
|
36
|
+
"""Record Identifier."""
|
|
37
|
+
return int(value)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@model.over("agency_code", "^003")
|
|
41
|
+
def agency_code(self, key, value):
|
|
42
|
+
"""Control number identifier."""
|
|
43
|
+
return "SzGeCERN"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@model.over("videos", "^774")
|
|
47
|
+
@for_each_value
|
|
48
|
+
def videos(self, key, value):
|
|
49
|
+
"""Videos."""
|
|
50
|
+
return {"$ref": value.get("u")}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@model.over("modified_by", "^937__")
|
|
54
|
+
@ignore_value
|
|
55
|
+
def modified_by(self, key, value):
|
|
56
|
+
"""Modified by."""
|
|
57
|
+
return value.get("s")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# This file is part of CERN Document Server.
|
|
4
|
+
# Copyright (C) 2017 CERN.
|
|
5
|
+
#
|
|
6
|
+
# Invenio is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the GNU General Public License as
|
|
8
|
+
# published by the Free Software Foundation; either version 2 of the
|
|
9
|
+
# License, or (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# Invenio is distributed in the hope that it will be useful, but
|
|
12
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14
|
+
# General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
|
|
18
|
+
# 59 Temple Place, Suite 330, Boston, MA 02D111-1307, USA.
|
|
19
|
+
"""CDS Books fields."""
|