PyPaf 1.0.1__tar.gz → 1.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. {pypaf-1.0.1/src/PyPaf.egg-info → pypaf-1.0.2}/PKG-INFO +1 -1
  2. {pypaf-1.0.1 → pypaf-1.0.2/src/PyPaf.egg-info}/PKG-INFO +1 -1
  3. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/__init__.py +5 -0
  4. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/exception.py +4 -0
  5. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/split.py +13 -0
  6. pypaf-1.0.2/src/paf/version.py +3 -0
  7. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_3.py +80 -0
  8. pypaf-1.0.1/src/paf/version.py +0 -3
  9. {pypaf-1.0.1 → pypaf-1.0.2}/LICENSE.txt +0 -0
  10. {pypaf-1.0.1 → pypaf-1.0.2}/README.md +0 -0
  11. {pypaf-1.0.1 → pypaf-1.0.2}/pyproject.toml +0 -0
  12. {pypaf-1.0.1 → pypaf-1.0.2}/setup.cfg +0 -0
  13. {pypaf-1.0.1 → pypaf-1.0.2}/src/PyPaf.egg-info/SOURCES.txt +0 -0
  14. {pypaf-1.0.1 → pypaf-1.0.2}/src/PyPaf.egg-info/dependency_links.txt +0 -0
  15. {pypaf-1.0.1 → pypaf-1.0.2}/src/PyPaf.egg-info/top_level.txt +0 -0
  16. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/__init__.py +0 -0
  17. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/address.py +0 -0
  18. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/attribute.py +0 -0
  19. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/immutable.py +0 -0
  20. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/initiator.py +0 -0
  21. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/lineable.py +0 -0
  22. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/attribute.py +0 -0
  23. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/building_type.py +0 -0
  24. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/dependent_premisable.py +0 -0
  25. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/extender.py +0 -0
  26. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/lineable.py +0 -0
  27. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/premisable.py +0 -0
  28. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule000.py +0 -0
  29. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule001.py +0 -0
  30. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule010.py +0 -0
  31. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule011.py +0 -0
  32. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule100.py +0 -0
  33. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule101.py +0 -0
  34. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule110.py +0 -0
  35. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule111.py +0 -0
  36. {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/thoroughfare_locality.py +0 -0
  37. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_empty.py +0 -0
  38. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_exception_i.py +0 -0
  39. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_exception_ii.py +0 -0
  40. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_exception_iii.py +0 -0
  41. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_exception_iv.py +0 -0
  42. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_immutability.py +0 -0
  43. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_kwargs.py +0 -0
  44. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_mainfile.py +0 -0
  45. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_po_box.py +0 -0
  46. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_premises.py +0 -0
  47. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_1.py +0 -0
  48. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_2.py +0 -0
  49. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_4.py +0 -0
  50. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_5.py +0 -0
  51. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_6.py +0 -0
  52. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_7.py +0 -0
  53. {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_x.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: PyPaf
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: Formats the elements of a Royal Mail Postcode Address File entry
5
5
  Author-email: John Bard <johnbard@globalnet.co.uk>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: PyPaf
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: Formats the elements of a Royal Mail Postcode Address File entry
5
5
  Author-email: John Bard <johnbard@globalnet.co.uk>
6
6
  License: MIT
@@ -94,6 +94,11 @@ class Premises(
94
94
  """Returns last word of the building name"""
95
95
  return self.last_word('building_name')
96
96
 
97
+ @property
98
+ def building_name_last_two_words(self):
99
+ """Returns last two words of the building name"""
100
+ return self.last_two_words('building_name')
101
+
97
102
  @property
98
103
  def sub_building_name_but_last_word(self):
99
104
  """Returns all but last word of the sub-building name"""
@@ -50,4 +50,8 @@ class ExceptionMixin(BuildingTypeMixin, SplitMixin):
50
50
  or self.__is_exception_ii(self.last_word(attr)))
51
51
  and not self.last_word(attr).isdigit()
52
52
  and not self.__is_exception_iv(attr)
53
+ and (
54
+ attr != 'building_name'
55
+ or not self.is_known_building_type('building_name_last_two_words')
56
+ )
53
57
  )
@@ -24,6 +24,15 @@ class SplitMixin():
24
24
  except ValueError:
25
25
  return string
26
26
 
27
+ @classmethod
28
+ def __last_two_words(cls, string):
29
+ """Returns last two words of the string"""
30
+ try:
31
+ *_, penultimate, last = string.split()
32
+ return ' '.join([penultimate, last])
33
+ except ValueError:
34
+ return cls.__last_word(string)
35
+
27
36
  @classmethod
28
37
  def __leading_digits(cls, string):
29
38
  """Returns the leading digits from the string"""
@@ -49,6 +58,10 @@ class SplitMixin():
49
58
  """Returns last word of the attribute"""
50
59
  return self.__last_word(str(getattr(self, attr, '')))
51
60
 
61
+ def last_two_words(self, attr):
62
+ """Returns last two word of the attribute"""
63
+ return self.__last_two_words(str(getattr(self, attr, '')))
64
+
52
65
  def leading_digits(self, attr):
53
66
  """Returns the leading digits from the attribute"""
54
67
  return self.__leading_digits(str(getattr(self, attr, '')))
@@ -0,0 +1,3 @@
1
+ """Version"""
2
+
3
+ __version__ = '1.0.2'
@@ -349,5 +349,85 @@ class TestRule3WithoutCharSplit(unittest.TestCase):
349
349
  )
350
350
 
351
351
 
352
+ class TestRule3WithoutTypeSplit(unittest.TestCase):
353
+ """Test Address Rule 3 without Building Type Split Exception"""
354
+
355
+ @classmethod
356
+ def setUpClass(cls):
357
+ """Set up Address instance"""
358
+ cls.address = paf.Address({
359
+ 'organisation_name': "P S G MARINE & LOGISTICS LTD",
360
+ 'building_name': "PORT SERVICES HOUSE UNIT 14A",
361
+ 'thoroughfare_name': "PETERSEAT",
362
+ 'thoroughfare_descriptor': "DRIVE",
363
+ 'dependent_locality': "ALTENS INDUSTRIAL ESTATE",
364
+ 'post_town': "ABERDEEN",
365
+ 'postcode': "AB12 3HT"
366
+ })
367
+
368
+ def test_list(self):
369
+ """Test conversion to an list"""
370
+ address = [
371
+ "P S G MARINE & LOGISTICS LTD",
372
+ "PORT SERVICES HOUSE UNIT 14A",
373
+ "PETERSEAT DRIVE",
374
+ "ALTENS INDUSTRIAL ESTATE",
375
+ "ABERDEEN",
376
+ "AB12 3HT"
377
+ ]
378
+ self.assertEqual(
379
+ self.address.as_list(), address, "Incorrect Rule 3 w/o type split list format"
380
+ )
381
+
382
+ def test_string(self):
383
+ """Test conversion to a string"""
384
+ address = (
385
+ "P S G MARINE & LOGISTICS LTD, "
386
+ "PORT SERVICES HOUSE UNIT 14A, "
387
+ "PETERSEAT DRIVE, "
388
+ "ALTENS INDUSTRIAL ESTATE, "
389
+ "ABERDEEN. "
390
+ "AB12 3HT"
391
+ )
392
+ self.assertEqual(
393
+ self.address.as_str(), address, "Incorrect Rule 3 w/o type split string format"
394
+ )
395
+
396
+ def test_tuple(self):
397
+ """Test conversion to a tuple"""
398
+ address = (
399
+ "P S G MARINE & LOGISTICS LTD",
400
+ "PORT SERVICES HOUSE UNIT 14A",
401
+ "PETERSEAT DRIVE",
402
+ "ALTENS INDUSTRIAL ESTATE",
403
+ "ABERDEEN",
404
+ "AB12 3HT"
405
+ )
406
+ self.assertEqual(
407
+ self.address.as_tuple(), address, "Incorrect Rule 3 w/o type split tuple format"
408
+ )
409
+
410
+ def test_dict(self):
411
+ """Test conversion to a dict"""
412
+ address = {
413
+ 'line_1': "P S G MARINE & LOGISTICS LTD",
414
+ 'line_2': "PORT SERVICES HOUSE UNIT 14A",
415
+ 'line_3': "PETERSEAT DRIVE",
416
+ 'line_4': "ALTENS INDUSTRIAL ESTATE",
417
+ 'post_town': "ABERDEEN",
418
+ 'postcode': "AB12 3HT"
419
+ }
420
+ self.assertEqual(
421
+ self.address.as_dict(), address, "Incorrect Rule 3 w/o type split dict format"
422
+ )
423
+
424
+ def test_premises(self):
425
+ """Test premises"""
426
+ premises = {'premises_name': 'PORT SERVICES HOUSE UNIT 14A'}
427
+ self.assertEqual(
428
+ self.address.premises(), premises, "Incorrect Rule 3 w/o type split premises"
429
+ )
430
+
431
+
352
432
  if __name__ == '__main__':
353
433
  unittest.main()
@@ -1,3 +0,0 @@
1
- """Version"""
2
-
3
- __version__ = '1.0.1'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes