Exemple #1
0
	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")
		if os.path.exists(self.xmp_extension_path):
			os.remove(self.xmp_extension_path)
Exemple #2
0
	def test_setattr_existing(self):
		jpg_filepath = fixtures.sandboxedData(fixtures.JPG_PHOTO)

		with XMPFile(jpg_filepath, rw=True) as xmp_file:
			xmp_file.metadata[libxmp.consts.XMP_NS_EXIF].FNumber = "314/141"
			self.assertEqual(xmp_file.metadata[libxmp.consts.XMP_NS_EXIF].FNumber.value, "314/141")

		with XMPFile(jpg_filepath) as xmp_file:
			# libxmp doesn't allow persistence of standard namespaces such as EXIF
			self.assertEqual(xmp_file.metadata[libxmp.consts.XMP_NS_EXIF].FNumber.value, "32/10")
Exemple #3
0
	def test_xmp_file_open(self):
		with XMPFile(fixtures.sandboxedData("foo.xmp")) as file:
			namespaces = file.metadata.namespaces
			self.assertIsInstance(namespaces, collections.Sequence)
			self.assertEqual(len(namespaces), 1)

			namespace = namespaces[0]
			self.assertIsInstance(namespace, XMPNamespace)
			self.assertEqual(namespace.uid, "http://test.com/xmp/test/1")
			self.assertIsInstance(namespace.structure, XMPValue)
			self.assertEqual(namespace.structure.value, "value")
Exemple #4
0
	def test_setattr_inexistent(self):
		sandboxed_photo = fixtures.sandboxedData(fixtures.JPG_PHOTO)
		with XMPFile(sandboxed_photo, rw=True) as xmp_file:
			xmp_file.metadata[TEST_NS].inexistent_element = 12
			self.assertIsInstance(xmp_file.metadata[TEST_NS].inexistent_element,
			                      XMPValue)
			self.assertEqual(xmp_file.metadata[TEST_NS].inexistent_element.value, "12")
		# Close and write file then reopen it
		with XMPFile(sandboxed_photo) as xmp_file:
			self.assertIsInstance(xmp_file.metadata[TEST_NS].inexistent_element,
			                      XMPValue)
			self.assertEqual(xmp_file.metadata[TEST_NS].inexistent_element.value, "12")
Exemple #5
0
	def setUp(self):
		self.sidecar_only_path = fixtures.sandboxedData("foobar.txt")
		self.sidecar_path = self.sidecar_only_path + ".xmp"
		if os.path.exists(self.sidecar_path):
			os.remove(self.sidecar_path)
Exemple #6
0
	def test_virtual_element_descriptor_set(self):
		with XMPFile(fixtures.sandboxedData(fixtures.JPG_PHOTO), rw = True) as xmpitem:
			xmpitem.metadata[TEST_NS].inexistent_attribute = 12
			self.assertIsInstance(xmpitem.metadata[TEST_NS].inexistent_attribute, XMPValue)
			self.assertEqual(xmpitem.metadata[TEST_NS].inexistent_attribute.value, "12")
Exemple #7
0
	def setUp(self):
		self.xmp_file = XMPFile(fixtures.sandboxedData(fixtures.JPG_PHOTO))
		self.xmp_file.open()
		self.xmp_metadata = self.xmp_file.metadata[TEST_NS]
Exemple #8
0
	def setUp(self):
		self.EXPECTED_NS_UIDS = fixtures.JPG_PHOTO_NS_UIDS

		self.xmp_file = XMPFile(fixtures.sandboxedData(fixtures.JPG_PHOTO))
		self.xmp_file.__enter__()
		self.example_xmp = self.xmp_file.metadata