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.
- {pypaf-1.0.1/src/PyPaf.egg-info → pypaf-1.0.2}/PKG-INFO +1 -1
- {pypaf-1.0.1 → pypaf-1.0.2/src/PyPaf.egg-info}/PKG-INFO +1 -1
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/__init__.py +5 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/exception.py +4 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/split.py +13 -0
- pypaf-1.0.2/src/paf/version.py +3 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_3.py +80 -0
- pypaf-1.0.1/src/paf/version.py +0 -3
- {pypaf-1.0.1 → pypaf-1.0.2}/LICENSE.txt +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/README.md +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/pyproject.toml +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/setup.cfg +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/PyPaf.egg-info/SOURCES.txt +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/PyPaf.egg-info/dependency_links.txt +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/PyPaf.egg-info/top_level.txt +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/__init__.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/address.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/attribute.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/immutable.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/initiator.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/lineable.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/attribute.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/building_type.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/dependent_premisable.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/extender.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/lineable.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/premisable.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule000.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule001.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule010.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule011.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule100.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule101.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule110.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/premises/rule111.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/src/paf/thoroughfare_locality.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_empty.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_exception_i.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_exception_ii.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_exception_iii.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_exception_iv.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_immutability.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_kwargs.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_mainfile.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_po_box.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_premises.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_1.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_2.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_4.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_5.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_6.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_7.py +0 -0
- {pypaf-1.0.1 → pypaf-1.0.2}/tests/test_rule_x.py +0 -0
|
@@ -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, '')))
|
|
@@ -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()
|
pypaf-1.0.1/src/paf/version.py
DELETED
|
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
|
|
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
|