From 77a0900d65794c841c5851d4bac03f7fe598fab9 Mon Sep 17 00:00:00 2001 From: Phil Hopper Date: Tue, 8 Nov 2016 07:38:21 -0500 Subject: [PATCH] Update the OBS manifest structure --- obs/obs_classes.py | 66 ++++++++++++++++++++++++++++------------------ setup.py | 2 +- test-setup.py | 2 +- 3 files changed, 42 insertions(+), 28 deletions(-) diff --git a/obs/obs_classes.py b/obs/obs_classes.py index d15dcbf..a3800d6 100644 --- a/obs/obs_classes.py +++ b/obs/obs_classes.py @@ -39,16 +39,17 @@ def __contains__(self, item): def from_manifest(manifest): status = OBSStatus() - manifest_status = manifest['status'] - - status.checking_entity = ', '.join(manifest_status['checking_entity']) - status.checking_level = manifest_status['checking_level'] - status.comments = manifest_status['comments'] - status.contributors = ', '.join(manifest_status['contributors']) - status.publish_date = manifest_status['pub_date'] - status.source_text = manifest_status['source_translations'][0]['language_slug'] - status.source_text_version = manifest_status['source_translations'][0]['version'] - status.version = manifest_status['version'] + resource = manifest['resource'] + resource_status = resource['status'] + + status.checking_entity = ', '.join(resource_status['checking_entity']) + status.checking_level = resource_status['checking_level'] + status.comments = resource_status['comments'] + status.contributors = ', '.join(resource_status['contributors']) + status.publish_date = resource_status['pub_date'] + status.source_text = resource_status['source_translations'][0]['language_slug'] + status.source_text_version = resource_status['source_translations'][0]['version'] + status.version = resource_status['version'] return status @@ -324,33 +325,46 @@ def __init__(self, file_name=None): else: raise IOError('The file {0} was not found.'.format(file_name)) else: - self.syntax_version = '1.0' - self.type = 'book' + self.package_version = 1 + self.modified_at = datetime.today().strftime('%Y%m%d000000') self.content_mime_type = 'text/markdown' - self.slug = 'obs' - self.name = 'Open Bible Stories' self.versification_slug = 'ufw' - self.finished_chunks = [] + self.language = {'slug': 'en', 'name': 'English', 'dir': 'ltr'} - self.status = {'translate_mode': 'all', 'checking_entity': [], 'checking_level': '1', 'version': '4', - 'comments': '', 'contributors': [], 'pub_date': datetime.today().strftime('%Y-%m-%d'), - 'license': 'CC BY-SA', 'checks_performed': [], - 'source_translations': []} + + self.resource = { + 'slug': 'obs', + 'name': 'Open Bible Stories', + 'type': 'book', + + 'status': { + 'translate_mode': 'all', + 'checking_entity': [], + 'checking_level': '1', + 'version': '4', + 'comments': '', + 'contributors': [], + 'pub_date': datetime.today().strftime('%Y-%m-%d'), + 'license': 'CC BY-SA', + 'checks_performed': [], + 'source_translations': [] + } + } + + self.chunk_status = [] def __contains__(self, item): return item in self.__dict__ def to_serializable(self): return_val = OrderedDict([ - ('syntax_version', self.syntax_version), - ('type', self.type), + ('package_version', self.package_version), + ('modified_at', self.modified_at), ('content_mime_type', self.content_mime_type), - ('language', self.language), - ('slug', self.slug), - ('name', self.name), ('versification_slug', self.versification_slug), - ('status', self.status), - ('finished_chunks', self.finished_chunks) + ('language', self.language), + ('resource', self.resource), + ('chunk_status', self.chunk_status) ]) return return_val diff --git a/setup.py b/setup.py index baa4bd9..720322f 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="obs_tools", - version="0.0.3", + version="0.0.4", author="unfoldingWord", author_email="phillip_hopper@wycliffeassociates.org", description="A collection of useful scripts", diff --git a/test-setup.py b/test-setup.py index b5ea60e..5596040 100644 --- a/test-setup.py +++ b/test-setup.py @@ -2,7 +2,7 @@ setup( name="obs_tools", - version="0.0.1", + version="0.0.4", author="unfoldingWord", author_email="unfoldingword.org", description="Unit test setup file.",