-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dobj - implement latest version fetching for data objects
- Loading branch information
Showing
2 changed files
with
19 additions
and
24 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,19 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Created on Fri Aug 9 10:40:27 2019 | ||
Use an ICOS digital object id (persistent identification url) | ||
to load a binary representation of the data object. | ||
""" | ||
|
||
__author__ = ['Claudio D\'Onofrio'] | ||
__credits__ = 'ICOS Carbon Portal' | ||
__license__ = 'GPL-3.0' | ||
__version__ = '0.1.8' | ||
__maintainer__ = 'ICOS Carbon Portal, elaborated products team' | ||
__email__ = ['[email protected]', '[email protected]'] | ||
__status__ = 'stable' | ||
__date__ = '2023-02-27' | ||
|
||
import os | ||
# Standard library imports. | ||
from typing import Optional | ||
from warnings import warn | ||
import requests | ||
import os | ||
import struct | ||
|
||
# Related third party imports. | ||
import pandas as pd | ||
import requests | ||
|
||
# Local application/library specific imports. | ||
from icoscp import __version__ as release_version | ||
from icoscp import cpauth | ||
from icoscp.cpb import dtype | ||
from icoscp.cpb import metadata | ||
import icoscp.const as CPC | ||
from json.decoder import JSONDecodeError | ||
|
||
|
||
class Dobj(): | ||
|
@@ -39,7 +27,7 @@ def __init__(self, digitalObject=None): | |
self._dobj = None # contains the pid | ||
self._colSelected = None # 'none' -> ALL columns are returned | ||
self._endian = 'big' # default "big endian conversion | ||
self._dtconvert = True # convert Unixtimstamp to datetime object | ||
self._dtconvert = True # convert Unix timestamp to datetime object | ||
self._meta = None # contains metadata about dobj | ||
self._variables = None # contains a list of variables, former info2 | ||
self._colSchema = None # format of columns (read struct bin data) | ||
|
@@ -95,7 +83,12 @@ def next(self): | |
if self.valid and 'nextVersion' in self.meta.keys(): | ||
nextversion = self.meta['nextVersion'] | ||
return nextversion | ||
#----------- | ||
@property | ||
def latest(self) -> Optional[str]: | ||
latest_version = self.meta['latestVersion'] \ | ||
if self.valid and 'latestVersion' in self.meta.keys() else None | ||
return latest_version | ||
|
||
@property | ||
def valid(self): | ||
return self._dobjValid | ||
|
@@ -273,11 +266,9 @@ def __set_meta(self): | |
self.meta | ||
self.variables | ||
''' | ||
|
||
# get all the meta data and check.. | ||
self._meta = metadata.get(self.dobj) | ||
|
||
if not self._meta: | ||
if not self._meta: | ||
return False | ||
else: | ||
# set conveniance excerpts from meta | ||
|
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