Example #1
0
    def _generator(self):
        ''' A generator returning a dictionary created from the parsed page data. '''

        for name, coordinates, description in zip(self._names, self._coordinates, self._descriptions):
            yield {
                'name': name.strip(),
                'coordinates': StaticCoordinate.match(coordinates),
                'description': description.strip()
            }
Example #2
0
    def extract_formulae(self, description):
        '''
        Parses the given description and returns an iterable list of dynamic coordinates with resolved descriptions.
        '''

        assert 'x' not in self._variable_addresses, "'x' as variable name is currently not supported"

        description = StaticCoordinate.filter(description)
        description = self._mask_orientation(description)

        for match in re.finditer(self._dynamic_dimension_re, string=description):
            normalized_coordinates = self._normalize(match.group())
            yield normalized_coordinates
Example #3
0
 def test_coordinates_in_wgs84_with_floating_point_minutes(self):
     self.assertEquals(StaticCoordinate.match('\n                N 47° 03.204 E 008° 18.557\xa0\n\n            '),
                       'N 47° 03.204 E 008° 18.557')
Example #4
0
 def test_filter_static_coordinates_from_input_with_single_static_dimension(self):
     given = 'Lorem E 008° 12.345 ipsum'
     expected = 'Lorem  ipsum'
     actual = StaticCoordinate.filter(given)
     self.assertEqual(actual, expected)
Example #5
0
 def test_filter_static_coordinates_from_input_with_static_coordinate(self):
     given = 'Lorem N 47° 03.204 E 008° 12.345 ipsum'
     expected = 'Lorem   ipsum'
     actual = StaticCoordinate.filter(given)
     self.assertEqual(actual, expected)
Example #6
0
 def test_filter_static_coordinates_from_input_without_static_coordinate(self):
     given = expected = 'Lorem ipsum'
     actual = StaticCoordinate.filter(given)
     self.assertEqual(actual, expected)
Example #7
0
 def test_fullcoordinates_do_match_partially_returns_longitude(self):
     self.assertEquals(StaticCoordinate.match_partially('N 47° 03.204 E 008° 18.557'), 'N 47° 03.204')
Example #8
0
 def test_partial_coordinates_do_match_partially(self):
     self.assertTrue(StaticCoordinate.match_partially('N 47° 03.204'))
     self.assertTrue(StaticCoordinate.match_partially('E 008° 18.557'))
Example #9
0
 def test_partial_coordinates_dont_match(self):
     self.assertIsNone(StaticCoordinate.match('N 47° 03.204'))
     self.assertIsNone(StaticCoordinate.match('E 008° 18.557'))
Example #10
0
 def test_non_coordinates_yield_empty(self):
     self.assertIsNone(StaticCoordinate.match('\n                ???\xa0\n\n            '))