Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions ocldev/checksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from uuid import UUID


LOCALE_STATUS_CHECKSUM_FIELDS = ('retired', 'retire_reason')


def getvalue(obj, key, default=None):
if obj is None:
return default
Expand Down Expand Up @@ -77,12 +80,15 @@ def _get_data_by_resource(self):

@staticmethod
def get_concept_name_fields(data):
fields = ['locale', 'locale_preferred', 'name', 'name_type', 'external_id', 'retired']
fields = ['locale', 'locale_preferred', 'name', 'name_type', 'external_id', 'retired', 'retire_reason']
return {field: getvalue(data, field, None) for field in fields}

@staticmethod
def get_concept_description_fields(data):
fields = ['locale', 'locale_preferred', 'description', 'description_type', 'external_id', 'retired']
fields = [
'locale', 'locale_preferred', 'description', 'description_type', 'external_id', 'retired',
'retire_reason'
]
return {field: getvalue(data, field, None) for field in fields}

def get_concept_fields(self, data):
Expand Down Expand Up @@ -331,7 +337,12 @@ def _cleanup(fields):
def _locales_for_checksums(self, data, relation, predicate_func):
locales = getvalue(data, relation, [])
locale_func = self.get_concept_name_fields if relation == 'names' else self.get_concept_description_fields
return [locale_func(locale) for locale in locales if predicate_func(locale)]
checksum_locales = [locale_func(locale) for locale in locales if predicate_func(locale)]
if self.checksum_type != 'standard':
for locale in checksum_locales:
for field in LOCALE_STATUS_CHECKSUM_FIELDS:
locale.pop(field, None)
return checksum_locales

def _generate(self, obj, hash_algorithm='MD5'):
# hex encoding is used to make the hash more readable
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='ocldev',
version='0.2.3',
version='0.2.4',
author='Open Concept Lab',
author_email='info@openconceptlab.org',
description='Python development library for working with OCL resources and APIs',
Expand Down
Loading