コード例 #1
0
    def test_write_new_date_property(self):
        """
        TODO:  fill in the doc string
        """
        filename = pkg_resources.resource_filename(__name__,
                                                   "samples/test1.xmp")

        with open(filename, 'r') as fptr:
            strbuffer = fptr.read()

        xmp = exempi.new_empty()
        self.assertFalse(exempi.get_error())

        exempi.parse(xmp, strbuffer)
        self.assertFalse(exempi.get_error())

        the_dt = datetime.datetime(2005, 12, 25, 12, 42, 42)

        exempi.set_property_date(xmp, NS_EXIF, "DateTimeOriginal", the_dt, 0)
        the_prop, _ = exempi.get_property(xmp, NS_EXIF, "DateTimeOriginal")
        self.assertEqual("2005-12-25T12:42:42", the_prop)

        the_prop, _ = exempi.get_property_date(xmp, NS_EXIF,
                                               "DateTimeOriginal")
        self.assertEqual(the_prop.year, 2005)
        self.assertEqual(the_prop.minute, 42)
        self.assertEqual(
            the_prop,
            datetime.datetime(2005, 12, 25, 12, 42, 42, tzinfo=pytz.utc))

        exempi.free(xmp)
コード例 #2
0
    def test_write_new_date_property(self):
        """
        TODO:  fill in the doc string
        """
        filename = pkg_resources.resource_filename(__name__,
                                                   "samples/test1.xmp")

        with open(filename, 'r') as fptr:
            strbuffer = fptr.read()

        xmp = exempi.new_empty()
        self.assertFalse(exempi.get_error())

        exempi.parse(xmp, strbuffer)
        self.assertFalse(exempi.get_error())

        the_dt = datetime.datetime(2005, 12, 25, 12, 42, 42)

        exempi.set_property_date(xmp, NS_EXIF, "DateTimeOriginal", the_dt, 0)
        the_prop, _ = exempi.get_property(xmp, NS_EXIF, "DateTimeOriginal")
        self.assertEqual("2005-12-25T12:42:42", the_prop)

        the_prop, _ = exempi.get_property_date(xmp, NS_EXIF, "DateTimeOriginal")
        self.assertEqual(the_prop.year, 2005)
        self.assertEqual(the_prop.minute, 42)
        self.assertEqual(the_prop, datetime.datetime(2005, 12, 25, 12, 42, 42,
                                   tzinfo=pytz.utc))

        exempi.free(xmp)
コード例 #3
0
    def test_serialize(self):
        """Corresponds to test-serialize.cpp"""
        filename = pkg_resources.resource_filename(__name__,
                                                   "samples/test1.xmp")
        with open(filename, 'r') as fptr:
            strbuffer = fptr.read()

        self.assertFalse(exempi.get_error())

        xmp = exempi.new_empty()
        self.assertFalse(exempi.get_error())

        exempi.parse(xmp, strbuffer)
        self.assertFalse(exempi.get_error())

        options = XMP_SERIAL_OPTIONS['omit_packet_wrapper']
        # TODO:  test this somehow.
        output = exempi.serialize_and_format(xmp, options, 0, '\n', ' ', 0)
        self.assertFalse(exempi.get_error())

        exempi.free(xmp)
コード例 #4
0
    def test_serialize(self):
        """Corresponds to test-serialize.cpp"""
        filename = pkg_resources.resource_filename(__name__,
                                                   "samples/test1.xmp")
        with open(filename, 'r') as fptr:
            strbuffer = fptr.read()

        self.assertFalse(exempi.get_error())

        xmp = exempi.new_empty()
        self.assertFalse(exempi.get_error())

        exempi.parse(xmp, strbuffer)
        self.assertFalse(exempi.get_error())

        options = XMP_SERIAL_OPTIONS['omit_packet_wrapper']
        # TODO:  test this somehow.
        output = exempi.serialize_and_format(xmp, options, 0, '\n', ' ', 0)
        self.assertFalse(exempi.get_error())

        exempi.free(xmp)
コード例 #5
0
    def test_write_new_property(self):
        """Corresponds to test-write-new-property.cpp"""
        filename = pkg_resources.resource_filename(__name__,
                                                   "samples/test1.xmp")

        with open(filename, 'r') as fptr:
            strbuffer = fptr.read()

        xmp = exempi.new_empty()
        self.assertFalse(exempi.get_error())

        exempi.parse(xmp, strbuffer)
        self.assertFalse(exempi.get_error())

        reg_prefix = exempi.register_namespace(NS_CC, "cc")
        self.assertEqual("cc:", reg_prefix)

        reg_prefix = exempi.prefix_namespace_uri("cc")
        self.assertEqual(NS_CC, reg_prefix)

        reg_prefix = exempi.namespace_prefix(NS_CC)
        self.assertEqual("cc:", reg_prefix)

        exempi.set_property(xmp, NS_CC, "License", "Foo", 0)
        the_prop, _ = exempi.get_property(xmp, NS_CC, "License")
        self.assertEqual(the_prop, "Foo")

        the_dt = datetime.datetime(2005, 12, 25, 12, 42, 42, tzinfo=pytz.utc)
        exempi.set_property_date(xmp, NS_EXIF, "DateTimeOriginal", the_dt, 0)
        the_prop, _ = exempi.get_property(xmp, NS_EXIF, "DateTimeOriginal")
        self.assertEqual("2005-12-25T12:42:42", the_prop)

        the_prop, _ = exempi.get_property_date(xmp, NS_EXIF,
                                               "DateTimeOriginal")
        self.assertEqual(the_prop.year, 2005)
        self.assertEqual(the_prop.minute, 42)
        self.assertEqual(the_prop.tzinfo, pytz.utc)

        exempi.free(xmp)
コード例 #6
0
    def test_write_new_property(self):
        """Corresponds to test-write-new-property.cpp"""
        filename = pkg_resources.resource_filename(__name__,
                                                   "samples/test1.xmp")

        with open(filename, 'r') as fptr:
            strbuffer = fptr.read()

        xmp = exempi.new_empty()
        self.assertFalse(exempi.get_error())

        exempi.parse(xmp, strbuffer)
        self.assertFalse(exempi.get_error())

        reg_prefix = exempi.register_namespace(NS_CC, "cc")
        self.assertEqual("cc:", reg_prefix)

        reg_prefix = exempi.prefix_namespace_uri("cc")
        self.assertEqual(NS_CC, reg_prefix)

        reg_prefix = exempi.namespace_prefix(NS_CC)
        self.assertEqual("cc:", reg_prefix)

        exempi.set_property(xmp, NS_CC, "License", "Foo", 0)
        the_prop, _ = exempi.get_property(xmp, NS_CC, "License")
        self.assertEqual(the_prop, "Foo")

        the_dt = datetime.datetime(2005, 12, 25, 12, 42, 42, tzinfo=pytz.utc)
        exempi.set_property_date(xmp, NS_EXIF, "DateTimeOriginal", the_dt, 0)
        the_prop, _ = exempi.get_property(xmp, NS_EXIF, "DateTimeOriginal")
        self.assertEqual("2005-12-25T12:42:42", the_prop)

        the_prop, _ = exempi.get_property_date(xmp, NS_EXIF, "DateTimeOriginal")
        self.assertEqual(the_prop.year, 2005)
        self.assertEqual(the_prop.minute, 42)
        self.assertEqual(the_prop.tzinfo, pytz.utc)

        exempi.free(xmp)