Ejemplo n.º 1
0
Archivo: core.py Proyecto: vicgc/Uforia
    def get_localized_text(self, schema_ns, alt_text_name, generic_lang,
                           specific_lang, **kwargs):
        """
		get_localized_text() returns information about a selected item in an alt-text array.

		:param schema_ns	The namespace URI for the alt-text array. Has the same usage as in GetProperty.
		:param alt_text_name	The name of the alt-text array. May be a general path expression, must not be null or the empty string. Has the same namespace prefix usage as propName in GetProperty.
		:param generic_lang	The name of the generic language as an RFC 3066 primary subtag. May be null or the empty string if no generic language is wanted.
		:param specific_lang	The name of the specific language as an RFC 3066 tag. Must not be null or the empty string.

		:return: The property's value if the property exists, None otherwise.
		"""
        value = None
        value_lang = None
        the_prop = _exempi.xmp_string_new()
        actual_lang = _exempi.xmp_string_new()
        options = c_int32()

        if _exempi.xmp_get_localized_text(self.xmpptr, schema_ns,
                                          alt_text_name, generic_lang,
                                          specific_lang, actual_lang, the_prop,
                                          byref(options)):
            value = _exempi.xmp_string_cstr(the_prop)
            value_lang = _exempi.xmp_string_cstr(actual_lang)

        _exempi.xmp_string_free(the_prop)
        _exempi.xmp_string_free(actual_lang)

        return value
Ejemplo n.º 2
0
	def get_localized_text(self, schema_ns, alt_text_name, generic_lang, specific_lang, **kwargs ):
		""" 
		get_localized_text() returns information about a selected item in an alt-text array.

		:param schema_ns	The namespace URI for the alt-text array. Has the same usage as in GetProperty.
		:param alt_text_name	The name of the alt-text array. May be a general path expression, must not be null or the empty string. Has the same namespace prefix usage as propName in GetProperty.
		:param generic_lang	The name of the generic language as an RFC 3066 primary subtag. May be null or the empty string if no generic language is wanted.
		:param specific_lang	The name of the specific language as an RFC 3066 tag. Must not be null or the empty string.
		
		:return: The property's value if the property exists, None otherwise.
		"""
		value = None
		value_lang = None
		the_prop = _exempi.xmp_string_new()
		actual_lang = _exempi.xmp_string_new()
		options = c_int32()
		
		if _exempi.xmp_get_localized_text( self.xmpptr, schema_ns, alt_text_name, generic_lang, specific_lang, actual_lang, the_prop, byref(options) ):
			value = _exempi.xmp_string_cstr(the_prop)
			value_lang = _exempi.xmp_string_cstr(actual_lang)

		_exempi.xmp_string_free(the_prop)
		_exempi.xmp_string_free(actual_lang)
			
		return value	
Ejemplo n.º 3
0
	def get_namespace_for_prefix(prefix):
		"""
		Checks if a prefix is registered.
		Parameters:
		prefix: the prefix to check.

 		Returns the associated namespace if registered, None if the prefix is not registered
		"""
		associated_namespace = _exempi.xmp_string_new()
		if _exempi.xmp_prefix_namespace_uri(prefix, associated_namespace):
			return _exempi.xmp_string_cstr(associated_namespace)
		else:
			return None
Ejemplo n.º 4
0
Archivo: core.py Proyecto: vicgc/Uforia
    def get_namespace_for_prefix(prefix):
        """
		Checks if a prefix is registered.
		Parameters:
		prefix: the prefix to check.

		Returns the associated namespace if registered, None if the prefix is not registered
		"""
        associated_namespace = _exempi.xmp_string_new()
        if _exempi.xmp_prefix_namespace_uri(prefix, associated_namespace):
            return _exempi.xmp_string_cstr(associated_namespace)
        else:
            return None
Ejemplo n.º 5
0
Archivo: core.py Proyecto: vicgc/Uforia
    def get_prefix_for_namespace(namespace):
        """
		Check if a namespace is registered.

		Parameters:
		namespace: the namespace to check.

		Returns the associated prefix if registered, None if the namespace is not registered
		"""
        associated_prefix = _exempi.xmp_string_new()
        if _exempi.xmp_namespace_prefix(namespace, associated_prefix):
            return _exempi.xmp_string_cstr(associated_prefix)
        else:
            return None
Ejemplo n.º 6
0
	def get_prefix_for_namespace(namespace):
		"""		
		Check if a namespace is registered.
		
		Parameters:
		namespace: the namespace to check.

 		Returns the associated prefix if registered, None if the namespace is not registered
		"""
		associated_prefix = _exempi.xmp_string_new()
		if _exempi.xmp_namespace_prefix(namespace, associated_prefix):
			return _exempi.xmp_string_cstr(associated_prefix)
		else:
			return None
Ejemplo n.º 7
0
	def count_array_items( self, schema_ns, array_name ):
		""" 
		count_array_items returns the number of a given array's items
		"""
		index = 0
		
		the_prop = _exempi.xmp_string_new()
		
		while( True ):
			if _exempi.xmp_get_array_item( self.xmpptr, str(schema_ns), str(array_name), index+1, the_prop, None):
				index += 1
			else:
				break
		
		return index
Ejemplo n.º 8
0
	def get_array_item( self, schema_ns, array_name, item_index ):
		"""
		get_array_item() provides access to items within an array.
		

		Reports whether the item exists; if it does, and if it has a value, the function retrieves the value.; if it doesn't it raises Exception.
		Items are accessed by an integer index, where the first item has index 1.
		
		.. todo:: Make get_array_item optionally return keywords describing array item's options
		"""	
		the_prop = _exempi.xmp_string_new()
		options = c_int32()
		
		if _exempi.xmp_get_array_item( self.xmpptr, schema_ns, array_name, item_index, the_prop, byref(options)): #we're never returning options
			return {_exempi.xmp_string_cstr(the_prop):options.value}
		else:
			raise Exception, "Array's over"
Ejemplo n.º 9
0
	def register_namespace( namespace_uri, suggested_prefix ):
		"""
		Register a new namespace to save properties to.
		
		Parameters:
		namespace_uri: the new namespace's URI
		suggested prefix: the suggested prefix: note that is NOT guaranteed it'll be the actual namespace's prefix
		
		Returns the actual registered prefix for the namespace of None if the namespace wasn't created.
		"""


		registered_prefix = _exempi.xmp_string_new()
		if _exempi.xmp_register_namespace(namespace_uri, suggested_prefix, registered_prefix):
			return _exempi.xmp_string_cstr(registered_prefix)
		else:
			return None
Ejemplo n.º 10
0
Archivo: core.py Proyecto: vicgc/Uforia
    def count_array_items(self, schema_ns, array_name):
        """
		count_array_items returns the number of a given array's items
		"""
        index = 0

        the_prop = _exempi.xmp_string_new()

        while (True):
            if _exempi.xmp_get_array_item(self.xmpptr, str(schema_ns),
                                          str(array_name), index + 1, the_prop,
                                          None):
                index += 1
            else:
                break

        return index
Ejemplo n.º 11
0
Archivo: core.py Proyecto: vicgc/Uforia
    def register_namespace(namespace_uri, suggested_prefix):
        """
		Register a new namespace to save properties to.

		Parameters:
		namespace_uri: the new namespace's URI
		suggested prefix: the suggested prefix: note that is NOT guaranteed it'll be the actual namespace's prefix

		Returns the actual registered prefix for the namespace of None if the namespace wasn't created.
		"""

        registered_prefix = _exempi.xmp_string_new()
        if _exempi.xmp_register_namespace(namespace_uri, suggested_prefix,
                                          registered_prefix):
            return _exempi.xmp_string_cstr(registered_prefix)
        else:
            return None
Ejemplo n.º 12
0
	def does_array_item_exist(self, schema_ns, array_name, item ):
		""" 
		does_array_item_exist() reports whether an array's item currently exists.

		:return: True if item is in array, False otherwise
		:rtype: bool
		"""
		index = 0
		
		the_prop = _exempi.xmp_string_new()
		
		while( True ):
			if _exempi.xmp_get_array_item( self.xmpptr, str(schema_ns), str(array_name), index+1, the_prop, None):
				index += 1
			else:
				break
		
		return index
Ejemplo n.º 13
0
Archivo: core.py Proyecto: vicgc/Uforia
    def get_array_item(self, schema_ns, array_name, item_index):
        """
		get_array_item() provides access to items within an array.


		Reports whether the item exists; if it does, and if it has a value, the function retrieves the value.; if it doesn't it raises Exception.
		Items are accessed by an integer index, where the first item has index 1.

		.. todo:: Make get_array_item optionally return keywords describing array item's options
		"""
        the_prop = _exempi.xmp_string_new()
        options = c_int32()

        if _exempi.xmp_get_array_item(
                self.xmpptr, schema_ns, array_name, item_index, the_prop,
                byref(options)):  # we're never returning options
            return {_exempi.xmp_string_cstr(the_prop): options.value}
        else:
            raise Exception, "Array's over"
Ejemplo n.º 14
0
Archivo: core.py Proyecto: vicgc/Uforia
    def does_array_item_exist(self, schema_ns, array_name, item):
        """
		does_array_item_exist() reports whether an array's item currently exists.

		:return: True if item is in array, False otherwise
		:rtype: bool
		"""
        index = 0

        the_prop = _exempi.xmp_string_new()

        while (True):
            if _exempi.xmp_get_array_item(self.xmpptr, str(schema_ns),
                                          str(array_name), index + 1, the_prop,
                                          None):
                index += 1
            else:
                break

        return index
Ejemplo n.º 15
0
	def get_property(self, schema_ns, prop_name):
		"""
		get_property() reports whether a property exists, and retrieves its value.

		This is the simplest property accessor: use this to retrieve the values of top-level simple properties.

		:param schema_ns 	The namespace URI for the property; can be null or the empty string if the first component of the prop_name path contains a namespace prefix.
		:param prop_name 	The name of the property. Can be a general path expression, must not be null or the empty string. The first component can be a namespace prefix; if present without a schema_ns value, the prefix specifies the namespace. 

		:return: The property's value if the property exists, None otherwise.
		
		.. todo:: Make get_property optionally return keywords describing property's options
		"""
		value = None
		the_prop = _exempi.xmp_string_new()

		if _exempi.xmp_get_property( self.xmpptr, schema_ns, prop_name, the_prop, 0 ): #we're never returning options
			value = _exempi.xmp_string_cstr(the_prop)

		_exempi.xmp_string_free(the_prop)
		return value
Ejemplo n.º 16
0
Archivo: core.py Proyecto: vicgc/Uforia
    def get_property(self, schema_ns, prop_name):
        """
		get_property() reports whether a property exists, and retrieves its value.

		This is the simplest property accessor: use this to retrieve the values of top-level simple properties.

		:param schema_ns 	The namespace URI for the property; can be null or the empty string if the first component of the prop_name path contains a namespace prefix.
		:param prop_name 	The name of the property. Can be a general path expression, must not be null or the empty string. The first component can be a namespace prefix; if present without a schema_ns value, the prefix specifies the namespace.

		:return: The property's value if the property exists, None otherwise.

		.. todo:: Make get_property optionally return keywords describing property's options
		"""
        value = None
        the_prop = _exempi.xmp_string_new()

        if _exempi.xmp_get_property(self.xmpptr, schema_ns, prop_name,
                                    the_prop,
                                    0):  # we're never returning options
            value = _exempi.xmp_string_cstr(the_prop)

        _exempi.xmp_string_free(the_prop)
        return value
Ejemplo n.º 17
0
	def __init__(self):
		self._ptr  = _exempi.xmp_string_new()
Ejemplo n.º 18
0
Archivo: core.py Proyecto: vicgc/Uforia
 def __init__(self):
     self._ptr = _exempi.xmp_string_new()