def test_namespace_unregistered(self): TEST_NS_2 = u"http://test.com/xmp/test/2" PREFIX_2 = "test2" metadata = XMPMetadata() test_metadata = metadata[TEST_NS_2] with self.assertRaises(NameError): test_metadata["test_key"]=0 registerNamespace(TEST_NS_2, "test2") assert(test_metadata.prefix == PREFIX_2) try: test_metadata["test_key"]=0 except Exception, e: assert(False) pass
import errno import os import unittest import shutil # libXMP import libxmp.consts # Xmp from xmp.xmp import (XMPFile, XMPMetadata, XMPElement, XMPVirtualElement, XMPNamespace, XMPStructure, XMPArray, XMPSet, XMPValue, registerNamespace) import fixtures TEST_NS = u"http://test.com/xmp/test/1" PREFIX = "test" registerNamespace(TEST_NS, PREFIX) def sha1(file_path): import hashlib hasher = hashlib.sha1() with open(file_path,'rb') as file: file_data = file.read() hasher.update(file_data) return hasher.hexdigest() class XMPFileTests(unittest.TestCase): def setUp(self): self.jpg_path = fixtures.sandboxedData(fixtures.JPG_PHOTO) fixtures.createSandbox() self.xmp_extension_path = os.path.join(fixtures.SANDBOX_FOLDER, "test.xmp")
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Standard libraries from collections import OrderedDict # Third-party libraries from qidata import makeMetadataObject, MetadataType from xmp.xmp import registerNamespace # Namespace reserved for annotation QIDATA_NS = u"http://softbank-robotics.com/qidata/1" registerNamespace(QIDATA_NS, "qidata") def _unicodeListToBuiltInList(list_to_convert): """ Convert a list containing unicode values into a list of built-in types. The conversion is in-place. :param list_to_convert: list of unicode elements to convert (can be nested) :Example: >>> data = ["1"] >>> _unicodeListToBuiltInList(data) >>> data [1]
QiDataObject's interface. """ from xmp.xmp import XMPFile, registerNamespace from qidata import DataType import glob from qidata.qidatafile import QiDataFile from collections import OrderedDict import copy import re import os import uuid import _mixin as xmp_tools QIDATA_FRAME_NS=u"http://softbank-robotics.com/qidataframe/1" registerNamespace(QIDATA_FRAME_NS, "qidataframe") class FrameIsInvalid(Exception):pass def throwIfInvalid(f): def wraps(*args, **kwargs): self = args[0] if self._is_valid: return f(*args, **kwargs) raise FrameIsInvalid return wraps class QiDataFrame(QiDataFile): # ─────────── # Constructor
import glob import os # Third-party libraries from xmp.xmp import XMPFile, registerNamespace from strong_typing._textualize import textualize_sequence, textualize_mapping # Local modules import qidata from qidata import qidataframe, DataType, _BaseEnum from qidata.metadata_objects import Context from qidata.qidataobject import QiDataObject, throwIfReadOnly import _mixin as xmp_tools QIDATA_CONTENT_NS = u"http://softbank-robotics.com/qidataset/1" registerNamespace(QIDATA_CONTENT_NS, "qidataset") METADATA_FILENAME = "metadata.xmp" # Place-holder def isDataset(path): return os.path.isdir(path)\ and os.path.isfile(os.path.join(path, METADATA_FILENAME)) class QiDataSet(object): class AnnotationStatus(_BaseEnum): """ AnnotationStatus represents the completeness of an annotation. For instance, if the "Face" metadata of "jdoe" is TOTAL, it means that all files have been annotated. This is a very valuable information.
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Third-party libraries from xmp.xmp import XMPFile, registerNamespace # Local modules from qidata import DataType from qidata.metadata_objects import Transform, TimeStamp from qidata.qidatafile import QiDataFile, throwIfClosed from qidata.qidataobject import QiDataObject from qidata.qidatasensorobject import QiDataSensorObject import _mixin as xmp_tools QIDATA_SENSOR_NS = u"http://softbank-robotics.com/qidatasensor/1" registerNamespace(QIDATA_SENSOR_NS, "qidatasensor") class QiDataSensorFile(QiDataSensorObject, QiDataFile): # ────────── # Public API def close(self): """ Closes the file after writing the metadata """ if self.mode != "r": _raw_metadata = self._xmp_file.metadata[QIDATA_SENSOR_NS] setattr(_raw_metadata, "data_type", self.type) setattr(_raw_metadata, "transform", self.transform)