Repository: mirumee/google-i18n-address

Issue:
`load_validation_data` throws TypeErrors if site-packages path includes `%` characters
https://github.com/mirumee/google-i18n-address/blob/aaa90ee859a5ff445b9cb39a67e12db047db0027/i18naddress/__init__.py#L31

The above line throws TypeError exceptions if `VALIDATION_DATA_PATH` contains any `%` characters. 
```
10:38:05  proj/common/validators.py:28: in validate_postal_code_with_country_code
10:38:05      rules = i18naddress.get_validation_rules({"country_code": country_code})
10:38:05  python-test-env/jira%2FTACO-1947/lib/python3.6/site-packages/i18naddress/__init__.py:206: in get_validation_rules
10:38:05      country_data, database = _load_country_data(country_code)
10:38:05  python-test-env/jira%2FTACO-1947/lib/python3.6/site-packages/i18naddress/__init__.py:193: in _load_country_data
10:38:05      database = load_validation_data("zz")
10:38:05  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
10:38:05  
10:38:05  country_code = 'zz'
10:38:05  
10:38:05      def load_validation_data(country_code="all"):
10:38:05          if not VALID_COUNTRY_CODE.match(country_code):
10:38:05              raise ValueError("%r is not a valid country code" % (country_code,))
10:38:05          country_code = country_code.lower()
10:38:05  >       path = VALIDATION_DATA_PATH % (country_code,)
10:38:05  E       TypeError: must be real number, not str
10:38:05  
10:38:05  python-test-env/jira%2FTACO-1947/lib/python3.6/site-packages/i18naddress/__init__.py:31: TypeError
```

A common example of this would be a Jenkins pipeline that uses branch name to create the workspace directory. A branch named `bug/exampe123` would result in 
```
VALIDATION_DATA_PATH='/home/jenkins/workspace/bug%2Fexample123/lib/python3.6/site-packages/i18naddress/data/%s.json'
```

Comments:

Patch:
diff --git a/i18naddress/__init__.py b/i18naddress/__init__.py
index 4ea2bd5..c53c8fc 100644
--- a/i18naddress/__init__.py
+++ b/i18naddress/__init__.py
@@ -28,7 +28,14 @@ def load_validation_data(country_code="all"):
     if not VALID_COUNTRY_CODE.match(country_code):
         raise ValueError("%r is not a valid country code" % (country_code,))
     country_code = country_code.lower()
-    path = VALIDATION_DATA_PATH % (country_code,)
+    try:
+        # VALIDATION_DATA_PATH may have '%' symbols
+        # for backwards compatability if VALIDATION_DATA_PATH is imported
+        # by consumers of this package.
+        path = VALIDATION_DATA_PATH % (country_code,)
+    except TypeError:
+        path = os.path.join(VALIDATION_DATA_DIR, "%s.json" % country_code)
+
     if not os.path.exists(path):
         raise ValueError("%r is not a valid country code" % (country_code,))
     with io.open(path, encoding="utf-8") as data:


Test patch:
diff --git a/tests/test_i18naddress.py b/tests/test_i18naddress.py
index 1179bbf..eceaf08 100644
--- a/tests/test_i18naddress.py
+++ b/tests/test_i18naddress.py
@@ -1,5 +1,6 @@
 # coding: utf-8
 from __future__ import unicode_literals
+from unittest.mock import patch
 
 import pytest
 
@@ -158,3 +159,9 @@ def test_locality_types(country, levels):
     assert validation_data.country_area_type == levels[0]
     assert validation_data.city_type == levels[1]
     assert validation_data.city_area_type == levels[2]
+
+@patch('i18naddress.VALIDATION_DATA_PATH', '/home/bug%2Fexample/%s.json')
+def test_validation_path_with_percent_symbol():
+    data = load_validation_data('US')
+    state = data['US/NV']
+    assert state['name'] == 'Nevada'