Exemple #1
0
 def test_parse_dimension_text(self):
     line = six.b(
         'Metadata:\r\nDimensions: T(443) x \xce\xbb(1)\r\nCamera Name: Andor Zyla VSC-01537'
     )
     self.assertEqual(parse_dimension_text_line(line),
                      six.b('Dimensions: T(443) x \xce\xbb(1)'))
     self.assertIsNone(parse_dimension_text_line(six.b('Dim: nothing')))
Exemple #2
0
    def _parse_dimension_text(self):
        """While there are metadata values that represent a lot of what we want to capture, they seem to be unreliable.
        Sometimes certain elements don't exist, or change their data type randomly. However, the human-readable text
        is always there and in the same exact format, so we just parse that instead.

        """
        dimension_text = six.b("")
        if self.image_text_info is None:
            return dimension_text

        try:
            textinfo = self.image_text_info[six.b('SLxImageTextInfo')].values()
        except KeyError:
            return dimension_text

        for line in textinfo:
            entry = parse_dimension_text_line(line)
            if entry is not None:
                return entry

        return dimension_text