# Path: flatisfy/models/flat.py
# LOGGER = logging.getLogger(__name__)
# AUTOMATED_STATUSES = [FlatStatus.new, FlatStatus.duplicate, FlatStatus.ignored]
# class FlatUtilities(enum.Enum):
# class FlatStatus(enum.Enum):
# class Flat(BASE):
#     def validate_utilities(self, _, utilities):
#     def validate_status(self, _, status):
#     def validate_notation(self, _, notation):
#     def validate_date(self, _, date):
#     def validate_visit_date(self, _, visit_date):
#     def validate_photos(self, _, photos):
#     def from_dict(flat_dict):
#     def __repr__(self):
#     def json_api_repr(self):
# 
# Path: flatisfy/models/postal_code.py
# LOGGER = logging.getLogger(__name__)
# class PostalCode(BASE):
#     def __repr__(self):
#     def json_api_repr(self):
# 
# Path: flatisfy/models/postal_code.py
# class PostalCode(BASE):
#     """
#     SQLAlchemy ORM model to store a postal code opendata.
#     """
# 
#     __tablename__ = "postal_codes"
# 
#     id = Column(Integer, primary_key=True)
#     # Area is an identifier to prevent loading unnecessary stops. For now it is
#     # following ISO 3166-2.
#     area = Column(String, index=True)
#     postal_code = Column(String, index=True)
#     insee_code = Column(String, index=True)
#     name = Column(String, index=True)
#     lat = Column(Float)
#     lng = Column(Float)
#     UniqueConstraint("postal_code", "name")
# 
#     def __repr__(self):
#         return "<PostalCode(id=%s)>" % self.id
# 
#     def json_api_repr(self):
#         """
#         Return a dict representation of this postal code object that is JSON
#         serializable.
#         """
#         return {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
# 
# Path: flatisfy/cmds.py
# LOGGER = logging.getLogger(__name__)
# def filter_flats_list(config, constraint_name, flats_list, fetch_details=True, past_flats=None):
# def filter_fetched_flats(config, fetched_flats, fetch_details=True, past_flats={}):
# def import_and_filter(config, load_from_db=False, new_only=False):
# def purge_db(config):
# def serve(config):


import datetime
import itertools
import json
import logging
import re
import os
import bottle
import vobject
import flatisfy.data
from flatisfy.models import flat as flat_model
from flatisfy.models import postal_code
from flatisfy.models.postal_code import PostalCode
from flatisfy import cmds

        GET /api/v1/opendata/postal_codes

    .. note::

        Filtering can be done through the ``filter`` GET param, according
        to JSON API spec (http://jsonapi.org/recommendations/#filtering).

    .. note::

        By default no pagination is done. Pagination can be forced using
        ``page[size]`` to specify a number of items per page and
        ``page[number]`` to specify which page to return. Pages are numbered
        starting from 0.

    .. note::

        Sorting can be handled through the ``sort`` GET param, according to
        JSON API spec (http://jsonapi.org/format/#fetching-sorting).


    :return: The postal codes data from opendata.
    """
    if bottle.request.method == "OPTIONS":
        # CORS
        return {}

    try:
        try:
            filters, page_number, page_size, sorting = _JSONApiSpec(

# Path: flatisfy/models/flat.py
# LOGGER = logging.getLogger(__name__)
# AUTOMATED_STATUSES = [FlatStatus.new, FlatStatus.duplicate, FlatStatus.ignored]
# class FlatUtilities(enum.Enum):
# class FlatStatus(enum.Enum):
# class Flat(BASE):
#     def validate_utilities(self, _, utilities):
#     def validate_status(self, _, status):
#     def validate_notation(self, _, notation):
#     def validate_date(self, _, date):
#     def validate_visit_date(self, _, visit_date):
#     def validate_photos(self, _, photos):
#     def from_dict(flat_dict):
#     def __repr__(self):
#     def json_api_repr(self):
# 
# Path: flatisfy/models/postal_code.py
# LOGGER = logging.getLogger(__name__)
# class PostalCode(BASE):
#     def __repr__(self):
#     def json_api_repr(self):
# 
# Path: flatisfy/models/postal_code.py
# class PostalCode(BASE):
#     """
#     SQLAlchemy ORM model to store a postal code opendata.
#     """
# 
#     __tablename__ = "postal_codes"
# 
#     id = Column(Integer, primary_key=True)
#     # Area is an identifier to prevent loading unnecessary stops. For now it is
#     # following ISO 3166-2.
#     area = Column(String, index=True)
#     postal_code = Column(String, index=True)
#     insee_code = Column(String, index=True)
#     name = Column(String, index=True)
#     lat = Column(Float)
#     lng = Column(Float)
#     UniqueConstraint("postal_code", "name")
# 
#     def __repr__(self):
#         return "<PostalCode(id=%s)>" % self.id
# 
#     def json_api_repr(self):
#         """
#         Return a dict representation of this postal code object that is JSON
#         serializable.
#         """
#         return {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
# 
# Path: flatisfy/cmds.py
# LOGGER = logging.getLogger(__name__)
# def filter_flats_list(config, constraint_name, flats_list, fetch_details=True, past_flats=None):
# def filter_fetched_flats(config, fetched_flats, fetch_details=True, past_flats={}):
# def import_and_filter(config, load_from_db=False, new_only=False):
# def purge_db(config):
# def serve(config):


# Path: flatisfy/web/routes/api.py
import datetime
import itertools
import json
import logging
import re
import os
import bottle
import vobject
import flatisfy.data
from flatisfy.models import flat as flat_model
from flatisfy.models import postal_code
from flatisfy.models.postal_code import PostalCode
from flatisfy import cmds


        GET /api/v1/opendata/postal_codes

    .. note::

        Filtering can be done through the ``filter`` GET param, according
        to JSON API spec (http://jsonapi.org/recommendations/#filtering).

    .. note::

        By default no pagination is done. Pagination can be forced using
        ``page[size]`` to specify a number of items per page and
        ``page[number]`` to specify which page to return. Pages are numbered
        starting from 0.

    .. note::

        Sorting can be handled through the ``sort`` GET param, according to
        JSON API spec (http://jsonapi.org/format/#fetching-sorting).


    :return: The postal codes data from opendata.
    """
    if bottle.request.method == "OPTIONS":
        # CORS
        return {}

    try:
        try:
            filters, page_number, page_size, sorting = _JSONApiSpec(

                bottle.request.query, PostalCode, default_sorting="postal_code"