Giter VIP home page Giter VIP logo

postal-address's Introduction

Postal Address

Python module to parse, normalize and render postal addresses.

Stable release: Last release Python versions Software license

Development: Documentation Status Coverage Status Code Quality

Motivation

« What ties us to territory is tax. » -- Kevin Deldycke, 2014-11-07

The reason above is why we need fine-grained and meticulous territory management and normalization. This project aims to solve this problem once for all.

Don't get me wrong, this work is a huge undertaking. Postal address parsing, normalization and rendering is hard. See the collection of falsehoods programmers believe about postal addresses.

This library is still in its early stages, but is good enough to implement the new European Directives on VAT, which requires all e-commerce shops to guess the locality of their EU customers depending on their billing address.

postal-address's People

Contributors

aveuiller avatar bchatelard avatar evasdk avatar kdeldycke avatar sweenu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

postal-address's Issues

Add support for zones.

We might be able to add support for territorial zones that are not countries or subdivisions per-se, like the European Union, or an

This requires #6.

Use case: implement territory matching for business rules.

Better yet: let the user creates its own zones. Think of arbitrary availability zones for datacenters, business regions, supranational European bodies, ...

Fix hard-requirement of Faker

We have been forced to avoid version 0.8.4 of Faker in this commit : 3c9cedf

But we should try to make postal-address works with the latest faker package.

Territory class

Package up all territory utilities into a proper Territory class.

The goal of this class will be to reconcile and normalize territory taxonomies (ISO countries, subdivisions and european legacy country codes).

Document stability policy

0.3.0 release moved some code around and thus breaks components using the symbols where they were located resulting in this sample backtrace:

[...]
   from postal_address.address import supported_territory_codes
ImportError: cannot import name supported_territory_codes

This specific break occurs when upgrading from 0.2.1 to 0.3.0 and the CHANGES.rst did not make any mention of that.

There is no such thing as private symbols in python, except for well documented _ or __ class or module members so please write a little something about the stability or lack thereof of the module.

Django integration?

Hi @kdeldycke and @scaleway,

Do you think we could use this library to create a Django PostalAddressField?
Could you write some documentation, snippet or maybe a library for this?

Use a DAG for territory aliases

Territory code aliases implementation is quite a mess, and to make it easier to maintain, use a directed acyclic graph to store the subdivision / country relationship as well as aliases.

With such a structure, we can easily solve #5 and check for stupid cycles in unit tests.

I think I'll leverage the NetworkX package to do so.

Docs on how to use the library?

Hi, the lib intro sounds great, but I couldn't find any doc examples on how to actually use it.

There's the API documentation at https://postal-address.readthedocs.io/en/develop/ , which is quite detailed and contains a myriad of classes and methods, but not helpful in figuring out what to do.

Is there a quick start example or something? How do I detect addresses in text using postal-address?

Apologies if I missed something obvious.

Return invalid fields on validation error

When validating an address using address.validate(), on error the method always raises a ValueError.
We can also use the address.valid() method, but we do not have the information about what field is invalid.

It would be great if you could expose a new property like address.errors that returns a dict with something like {'field': 'error'}.

And maybe also embed in the exception body this dict.

Country aliases not resolved on normalization

Non standard, addresses' country code are not normalized to their good values, even if defined as alias in territory.py:

>>> import postal_address
>>> postal_address.__version__
'0.7.1'
>>> from postal_address import Address
>>> Address(country_code='EL')
  File "(...)/postal_address-0.7.1-py2.7.egg/postal_address/address.py", line 152, in __repr__
  File "(...)/postal_address-0.7.1-py2.7.egg/postal_address/address.py", line 456, in country_name
  File "(...)/postal_address-0.7.1-py2.7.egg/postal_address/address.py", line 445, in country
  File "(...)/pycountry-1.10-py2.7.egg/pycountry/db.py", line 114, in get
    return self.indices[field][value]
KeyError: 'EL'

Change license to LGPL or more liberal ?

Do you have any particular reason to use the GPL ? We'd like to use your library in a LGPL projet, it would be great if you could change to something more liberal.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.