Skip to content

Commit a375a98

Browse files
committed
allow for multiple version attributes
1 parent a9cc8ab commit a375a98

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

pythesint/cf_vocabulary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class CFVocabulary(JSONVocabulary):
1111

12-
version_attribute = 'omvm:origVocVersionId'
12+
version_attributes = ('omvm:origVocVersionId',)
1313

1414
def _fetch_online_data(self, version=None):
1515
if version:

pythesint/gcmd_vocabulary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class GCMDVocabulary(JSONVocabulary):
1212

13-
version_attribute = 'Keyword Version'
13+
version_attributes = ('Keyword Version', 'Revision')
1414

1515
def _check_categories(self, categories):
1616
'''Print a warning if the categories are not the expected ones

pythesint/json_vocabulary.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class JSONVocabulary(Vocabulary):
1010

11-
version_attribute = None
11+
version_attributes = None
1212

1313
def _fetch_online_data(self, version=None):
1414
raise NotImplementedError
@@ -47,8 +47,8 @@ def get_filepath(self):
4747
return os.path.join(DATA_HOME, self.get_relative_path())
4848

4949
def get_version(self):
50-
if self.version_attribute:
50+
if self.version_attributes:
5151
for kw in self._get_raw_list():
52-
if self.version_attribute in kw:
53-
return kw[self.version_attribute]
52+
if set(self.version_attributes).issubset(set(kw)):
53+
return '-'.join(kw[v] for v in self.version_attributes)
5454
return None

pythesint/mmd_vocabulary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class MMDVocabulary(JSONVocabulary):
1818
base_url = 'https://raw.githubusercontent.com/metno/mmd/master/thesauri/mmd-vocabulary.xml'
1919
base_file = os.path.join(DATA_HOME, 'pythesint', 'mmd-vocabulary.xml')
20-
version_attribute = 'version'
20+
version_attributes = ('version',)
2121

2222
@staticmethod
2323
def get_subnode_data(node, subnode_name):

0 commit comments

Comments
 (0)