Пример #1
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	
Пример #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
Пример #3
0
    def __unicode__(self):
        """
		Note string cannot be used to be written to file, as it the special encoding character
		is not included.
		"""
        s = _exempi.xmp_string_cstr(self._ptr)
        return s.decode('utf-8')  # ,errors='ignore')
Пример #4
0
	def __unicode__(self):
		"""
		Note string cannot be used to be written to file, as it the special encoding character
		is not included.
		"""
		s = _exempi.xmp_string_cstr(self._ptr)
		return s.decode('utf-8') #,errors='ignore')
Пример #5
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
Пример #6
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
Пример #7
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
Пример #8
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
Пример #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
Пример #10
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
Пример #11
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"
Пример #12
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"
Пример #13
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
Пример #14
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
Пример #15
0
 def __str__(self):
     # Returns a UTF-8 encode 8-bit string. With a encoding specified so it cannot be
     # decoded into a unicode string. This is needed when writing it to a file e.g.
     return _exempi.xmp_string_cstr(self._ptr)
Пример #16
0
	def __str__(self):
		# Returns a UTF-8 encode 8-bit string. With a encoding specified so it cannot be
		# decoded into a unicode string. This is needed when writing it to a file e.g. 
		return _exempi.xmp_string_cstr(self._ptr)