-
Notifications
You must be signed in to change notification settings - Fork 5
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
Feature/ted 1219 packages #447
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d7d03a6
METS generation updates + tests
kaleanych cb5aff7
METS package updates + tests
kaleanych 24c91e2
Updated features test
kaleanych ecb4b4b
Merge remote-tracking branch 'origin/main' into feature/TED-1219-pack…
kaleanych 52e2a55
renamed local param v to fit actual meaning
kaleanych File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,25 @@ | |
|
||
from ted_sws.core.model.metadata import Metadata | ||
|
||
WORK_AGENT = "PUBL" | ||
METS_PROFILE = "http://publications.europa.eu/resource/mets/op-sip-profile_002" | ||
METS_TYPE_CREATE = "create" | ||
METS_TYPE_UPDATE = "update" | ||
METS_TYPE_DELETE = "delete" | ||
METS_ACCEPTED_TYPES = [METS_TYPE_CREATE, METS_TYPE_UPDATE, METS_TYPE_DELETE] | ||
METS_DMD_MDTYPE = "OTHER" | ||
METS_DMD_OTHERMDTYPE = "INSTANCE" | ||
METS_DMD_HREF = "{work_identifier}_{revision}.mets.xml.dmd.rdf" | ||
METS_DMD_ID = "dmd_{work_identifier}_{revision}_{dmd_idx}" | ||
METS_TMD_ID = "tmd_{work_identifier}_{revision}_{tmd_idx}" | ||
METS_TMD_HREF = "{work_identifier}_{revision}.tmd.rdf" | ||
METS_TMD_MDTYPE = "OTHER" | ||
METS_TMD_OTHERMDTYPE = "INSTANCE" | ||
METS_FILE_ID = "file_{work_identifier}_{revision}_{file_idx}" | ||
METS_NOTICE_FILE_HREF = "{work_identifier}_{revision}.notice.rdf" | ||
METS_NOTICE_FILE_MIMETYPE = "application/rdf+xml" | ||
METS_NOTICE_FILE_CHECKSUM_TYPE = "SHA-256" | ||
|
||
WORK_AGENT = "EURUN" | ||
PUBLICATION_FREQUENCY = "OTHER" | ||
CONCEPT_TYPE_DATASET = "TEST_DATA" | ||
DATASET_KEYWORD = [ | ||
|
@@ -35,38 +53,52 @@ | |
LANGUAGE = LANGUAGES[0] | ||
USES_LANGUAGE = "MUL" | ||
|
||
ACTION_CREATE = "create" | ||
ACTION_UPDATE = "update" | ||
ACCEPTED_ACTIONS = [ACTION_CREATE, ACTION_UPDATE] | ||
|
||
REVISION = "0" | ||
|
||
|
||
def validate_notice_action_type(v): | ||
if v not in ACCEPTED_ACTIONS: | ||
raise ValueError('No such action: %s' % v) | ||
def validate_mets_type(v): | ||
if v not in METS_ACCEPTED_TYPES: | ||
raise ValueError('No such METS type: %s' % v) | ||
|
||
|
||
class NoticeActionMetadata(Metadata): | ||
class NoticeMetadata(Metadata): | ||
""" | ||
Notice action metadata | ||
General notice metadata | ||
""" | ||
type: str = ACTION_CREATE | ||
date: str = datetime.datetime.now().isoformat() | ||
|
||
@validator('type') | ||
def validate_notice_action_type(cls, v): | ||
validate_notice_action_type(v) | ||
return v | ||
id: Optional[str] | ||
public_number_document: Optional[str] | ||
public_number_edition: Optional[str] | ||
|
||
|
||
class NoticeMetadata(Metadata): | ||
class MetsMetadata(Metadata): | ||
""" | ||
General notice metadata | ||
""" | ||
id: Optional[str] = None | ||
languages: List[str] = LANGUAGES | ||
action: NoticeActionMetadata = NoticeActionMetadata() | ||
revision: str = REVISION | ||
|
||
type: str = METS_TYPE_CREATE | ||
profile: str = METS_PROFILE | ||
createdate: str = datetime.datetime.now().isoformat() | ||
document_id: Optional[str] | ||
dmd_id: Optional[str] | ||
dmd_mdtype: str = METS_DMD_MDTYPE | ||
dmd_othermdtype: str = METS_DMD_OTHERMDTYPE | ||
dmd_href: Optional[str] | ||
tmd_id: Optional[str] | ||
tmd_href: Optional[str] | ||
tmd_mdtype: str = METS_TMD_MDTYPE | ||
tmd_othermdtype: str = METS_TMD_OTHERMDTYPE | ||
file_id: Optional[str] | ||
notice_file_href: Optional[str] | ||
notice_file_mimetype: Optional[str] = METS_NOTICE_FILE_MIMETYPE | ||
notice_file_checksum: Optional[str] | ||
notice_file_checksum_type: Optional[str] = METS_NOTICE_FILE_CHECKSUM_TYPE | ||
|
||
@validator('type') | ||
def validate_notice_action_type(cls, v): | ||
validate_mets_type(v) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is v ? vicar? |
||
return v | ||
|
||
|
||
class WorkMetadata(Metadata): | ||
|
@@ -95,11 +127,13 @@ class WorkMetadata(Metadata): | |
|
||
|
||
class ExpressionMetadata(Metadata): | ||
identifier: Optional[str] | ||
title: Optional[Dict[str, str]] = None | ||
uses_language: str = USES_LANGUAGE | ||
|
||
|
||
class ManifestationMetadata(Metadata): | ||
identifier: Optional[str] | ||
type: str = MANIFESTATION_TYPE | ||
date_publication: str = datetime.datetime.now().strftime('%Y-%m-%d') | ||
distribution_has_status_distribution_status: str = DISTRIBUTION_STATUS | ||
|
@@ -108,6 +142,7 @@ class ManifestationMetadata(Metadata): | |
|
||
class PackagerMetadata(Metadata): | ||
notice: NoticeMetadata = NoticeMetadata() | ||
mets: MetsMetadata = MetsMetadata() | ||
work: WorkMetadata = WorkMetadata() | ||
expression: ExpressionMetadata = ExpressionMetadata() | ||
manifestation: ManifestationMetadata = ManifestationMetadata() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is v ? victory ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it’s a short name for value when used in a very small context (likke: k => v: key => value)