Skip to content
This repository has been archived by the owner on Apr 9, 2019. It is now read-only.

Commit

Permalink
Merge pull request #60 from etalab/59-mauvezin-sur-gupie
Browse files Browse the repository at this point in the history
Handle special case of Mauvezin-sur-Gupie, fix #59
  • Loading branch information
davidbgk authored Dec 1, 2017
2 parents 5f8e05c + 9228379 commit a5eba52
Show file tree
Hide file tree
Showing 7 changed files with 78,984 additions and 78,965 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 10.0.2 - 2017-12-01

* Handle special case of Mauvezin-sur-Gupie, fix #59

## 10.0.1 - 2017-10-30

* Deal with Centre region renaming in 2015, fix #57
Expand Down
6 changes: 3 additions & 3 deletions exports/communes/communes.csv
Original file line number Diff line number Diff line change
Expand Up @@ -20355,14 +20355,14 @@ fr:commune:47153@1942-01-01,47153,1942-01-01 00:00:00,1970-12-31 23:59:59,Lusign
fr:commune:47154@1942-01-01,47154,1942-01-01 00:00:00,9999-12-31 23:59:59,Lusignan-Petit,,,fr:departement:47@1860-07-01,354,0
fr:commune:47155@1942-01-01,47155,1942-01-01 00:00:00,9999-12-31 23:59:59,Madaillan,,,fr:departement:47@1860-07-01,638,0
fr:commune:47156@1942-01-01,47156,1942-01-01 00:00:00,9999-12-31 23:59:59,Marcellus,,,fr:departement:47@1860-07-01,828,0
fr:commune:47157@1942-01-01,47157,1942-01-01 00:00:00,9999-12-31 23:59:59,Marmande,,fr:commune:47163@1942-01-01,fr:departement:47@1860-07-01,18028,230
fr:commune:47157@1942-01-01,47157,1942-01-01 00:00:00,9999-12-31 23:59:59,Marmande,fr:commune:47163@2003-02-03,fr:commune:47163@1942-01-01,fr:departement:47@1860-07-01,18028,230
fr:commune:47158@1942-01-01,47158,1942-01-01 00:00:00,9999-12-31 23:59:59,Marmont-Pachas,,,fr:departement:47@1860-07-01,129,0
fr:commune:47159@1942-01-01,47159,1942-01-01 00:00:00,9999-12-31 23:59:59,Le Mas-d'Agenais,,,fr:departement:47@1860-07-01,1470,0
fr:commune:47160@1942-01-01,47160,1942-01-01 00:00:00,9999-12-31 23:59:59,Masquières,,,fr:departement:47@1860-07-01,191,0
fr:commune:47161@1942-01-01,47161,1942-01-01 00:00:00,9999-12-31 23:59:59,Massels,,,fr:departement:47@1860-07-01,109,0
fr:commune:47162@1942-01-01,47162,1942-01-01 00:00:00,9999-12-31 23:59:59,Massoulès,,,fr:departement:47@1860-07-01,198,0
fr:commune:47163@1942-01-01,47163,1942-01-01 00:00:00,1972-10-31 23:59:59,Mauvezin-sur-Gupie,fr:commune:47157@1942-01-01,,fr:departement:47@1860-07-01,567,210
fr:commune:47163@2003-02-03,47163,2003-02-03 00:00:00,9999-12-31 23:59:59,Mauvezin-sur-Gupie,,,fr:departement:47@1860-07-01,567,0
fr:commune:47163@1942-01-01,47163,1942-01-01 00:00:00,1972-10-31 23:59:59,Mauvezin-sur-Gupie,fr:commune:47157@1942-01-01,,fr:departement:47@1860-07-01,567,330
fr:commune:47163@2003-02-03,47163,2003-02-03 00:00:00,9999-12-31 23:59:59,Mauvezin-sur-Gupie,,fr:commune:47157@1942-01-01,fr:departement:47@1860-07-01,567,210
fr:commune:47164@1942-01-01,47164,1942-01-01 00:00:00,9999-12-31 23:59:59,Mazières-Naresse,,,fr:departement:47@1860-07-01,129,0
fr:commune:47165@1942-01-01,47165,1942-01-01 00:00:00,9999-12-31 23:59:59,Meilhan-sur-Garonne,,,fr:departement:47@1860-07-01,1347,0
fr:commune:47166@1942-01-01,47166,1942-01-01 00:00:00,1972-08-31 23:59:59,Meylan,fr:commune:47302@1942-01-01,,fr:departement:47@1860-07-01,NULL,330
Expand Down
60,366 changes: 30,183 additions & 30,183 deletions exports/communes/communes_1962-03-07.csv

Large diffs are not rendered by default.

5,038 changes: 2,519 additions & 2,519 deletions exports/communes/communes_2000-01-01.csv

Large diffs are not rendered by default.

46,660 changes: 23,330 additions & 23,330 deletions exports/communes/communes_2016-01-01.csv

Large diffs are not rendered by default.

45,844 changes: 22,922 additions & 22,922 deletions exports/communes/communes_2017-01-01.csv

Large diffs are not rendered by default.

31 changes: 23 additions & 8 deletions geohisto/specials.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
"""Special cases handled manually."""
import inspect
import logging
from datetime import date, datetime

from datetime import datetime, date

from geohisto import specials

from .constants import (
CREATION_DELEGATED_POLE, DELTA, FUSION_ASSOCIATION_ASSOCIATED
)
from .constants import (CREATION_DELEGATED_POLE, DELTA,
FUSION_ASSOCIATION_ASSOCIATED, REINSTATEMENT)
from .utils import compute_id, only_if_depcom


log = logging.getLogger(__name__)


Expand Down Expand Up @@ -503,9 +498,29 @@ def _special_case_avanchers(towns):
towns.upsert(aigueblanche_new)


@only_if_depcom('47163')
def _special_case_mauvezin_sur_gupie(towns):
"""Special case: change name during split.
https://www.insee.fr/fr/metadonnees/cog/commune/COM47157-Marmande
https://www.insee.fr/fr/metadonnees/cog/commune/COM47163-Mauvezin-sur-Gupie
"""
mauvezin_old, mauvezin_new = towns.filter(depcom='47163')
marmande = next(towns.filter(depcom='47157'))
mauvezin = mauvezin_new.generate(modification=REINSTATEMENT)
towns.upsert(mauvezin)
mauvezin2 = mauvezin_old.generate(
modification=FUSION_ASSOCIATION_ASSOCIATED
)
towns.upsert(mauvezin2)
marmande_new = marmande.add_successor(mauvezin.id)
towns.upsert(marmande_new)


def compute_specials(towns):
"""Apply all special case functions from that file."""
log.info('Applying special cases')
from geohisto import specials # NOQA
for name, func in inspect.getmembers(specials, inspect.isfunction):
if name.startswith('_special_case_'):
func(towns)

0 comments on commit a5eba52

Please sign in to comment.