Skip to content

Commit

Permalink
New disivisions and new country (#21)
Browse files Browse the repository at this point in the history
* typo

* reorganize tests

* united states minor outlying islands are seen as a country

* treat Saint Barthélémy as its own department

* add alternative fr name for antigua and barbuda

* german subdivision

* iso format return

* brazilian subdivisions

* reorganize test_subdivisions and keep a 100% coverage

* add a CHANGELOG !

* update readme and ci

Co-authored-by: Roxane <[email protected]>
  • Loading branch information
roxanebellot and Roxane authored Oct 11, 2021
1 parent 71672aa commit 8e68eca
Show file tree
Hide file tree
Showing 23 changed files with 1,709 additions and 1,112 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ install:
- pip install codecov

script:
- make styles_check
- pytest
- make test

after_success:
- codecov
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## Unreleased

### Changed
- test organisation : single file split into multiple files in folders
- US Minor Outlying Islands (UM) is considered as a country and not a US state
- Saint Barthélémy (FR-977) is considered a French departement on its own and not Guadeloupe

### Added
- Changelog !
- Detection for AG written "Antigue et Barbude" in French
- Detection of any Brazilian state code from the post code, state name or if the state code is present.
- Detection of any German land code from the state name, state capital or if the state code is present.
- `address_to_country_and_subdivision_codes` can return iso format


## [4.4.1] - 2021-09-23

### Changed
- minor refacto in special_countries and tests

## [4.4.0] - 2021-09-22

### Fixed
- Make sure we never mistake Guinea (GN) and Papua New Guinea (PG)

## [4.3.0] - 2021-08-09

### Fixed
- Make sure we never mistake Jersey (JE) and New Jersey (US-NJ)


## [4.2.0] - 2021-07-20

### Fixed
- Make sure we never mistake Sudan (SD) and South Sudan (SS)


## [4.1.0] - 2021-01-17

### Added
- Detection of country names in Spanish

## [4.0.0] - 2021-01-11

### Added
- Detection of any American state code from the post code, state name or if the state code is present.
- Detection of any Canadian province or territory code from the post code, state name or if the state code is present.
- Wrapper functions to allow finding the subdivision code (department for France, state for US, ...) and/or the country code from a text input.
- Update README (show the new functions usage in an extensive fashion - more details on how to run the tests and prepare your local dev env - more details for the dev when adding a new language or subdivisions to a new country)

### Changed
- Refactorization of the current code (mainly for France departments and regions) to make the functions more uniform.
- Move data from a single file to multiple files in a specific folder.
- Update CI (test the README, style check)

### Fixed
- Make base functions as language or country-agnostic as possible

### Removed
- Anything related to python 2
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests:
test:
make styles_check
pytest -s
python -m doctest README.md
Expand Down
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,34 @@ There should be no confusion between French and US postcodes:

```

### Brazil

You can find the state code associated with an address, via the postcode,
state name (in Portuguese) or code:
```python
>>> from geoconvert.convert import br_address_to_state_code
>>> br_address_to_state_code("Luz, 01120-010")
'SP'
>>> br_address_to_state_code("Piauí")
'PI'
>>> br_address_to_state_code("Dourados, MS")
'MS'

```

You may use more specific functions, depending on your needs:
```python
>>> from geoconvert.convert import (
... br_postcode_to_state_code, br_state_name_to_state_code
... )
>>> br_postcode_to_state_code("Mariana, 04094-050")
'SP'
>>> br_state_name_to_state_code("a capital do estado do maranhao.")
'MA'

```


### Canada

You can find the province or territory code associated with an address, via the postcode,
Expand Down Expand Up @@ -296,6 +324,19 @@ You can derive both country and subdivision codes at the same time:

```

Result format can be choosen between a tuple and an iso code
```python
>>> address_to_country_and_subdivision_codes("14467 Potsdam")
('DE', 'BB')
>>> address_to_country_and_subdivision_codes("14467 Potsdam", iso_format=True)
'DE-BB'
>>> address_to_country_and_subdivision_codes("14467 Germany")
('DE', None)
>>> address_to_country_and_subdivision_codes("14467 Germany", iso_format=True)
'DE'

```

There should be no confusion between French and US postcodes:
```python
>>> address_to_country_and_subdivision_codes("2 pl. Saint-Pierre, 44000 Nantes", country="US")
Expand All @@ -311,14 +352,14 @@ There should be no confusion between French and US postcodes:

Just run pytest:
```bash
pytest
make test
```

Do not forget to install the dependencies first, preferably in a vitrual environment:
```bash
python3 -m venv .venv
source .venv/bin/activate
python -m pip install requirements_test.txt
python -m pip install -r requirements_test.txt
```

## Releases
Expand Down
Loading

0 comments on commit 8e68eca

Please sign in to comment.