# Path: flatisfy/data.py
# LOGGER = logging.getLogger(__name__)
#         def lru_cache(maxsize=None):  # pylint: disable=unused-argument
# def preprocess_data(config, force=False):
# def load_data(model, constraint, config):
# 
# Path: flatisfy/tools.py
# LOGGER = logging.getLogger(__name__)
# NAVITIA_ENDPOINT = "https://api.navitia.io/v1/coverage/fr-idf/journeys"
#         MAPBOX_MODES = {
#             TimeToModes.WALK: "mapbox/walking",
#             TimeToModes.BIKE: "mapbox/cycling",
#             TimeToModes.CAR: "mapbox/driving",
#         }
# def next_weekday(d, weekday):
# def convert_arabic_to_roman(arabic):
# def convert_arabic_to_roman_in_text(text):
# def hash_dict(func):
#         def __hash__(self):
#     def wrapped(*args, **kwargs):
#     def default(self, o):  # pylint: disable=locally-disabled,E0202
# def pretty_json(data):
# def batch(iterable, size):
# def is_within_interval(value, min_value=None, max_value=None):
# def normalize_string(string, lowercase=True, convert_arabic_numerals=True):
# def uniqify(some_list):
# def distance(gps1, gps2):
# def sort_list_of_dicts_by(flats_list, key):
# def merge_dicts(*args):
# def get_travel_time_between(latlng_from, latlng_to, mode, config):
# def timeit(func):
#     def wrapped(*args, **kwargs):
#     class HDict(dict):
# class DateAwareJSONEncoder(json.JSONEncoder):
# 
# Path: flatisfy/constants.py
# class TimeToModes(Enum):
#     PUBLIC_TRANSPORT = -1
#     WALK = 1
#     BIKE = 2
#     CAR = 3
# 
# 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("_")}


from builtins import str
from woob.capabilities.housing import POSTS_TYPES, HOUSE_TYPES
from flatisfy import data
from flatisfy import tools
from flatisfy.constants import TimeToModes
from flatisfy.models.postal_code import PostalCode
import json
import logging
import os
import sys
import traceback
import appdirs
            if constraint["description_should_contain"]:
                for term in constraint["description_should_contain"]:
                    try:
                        assert isinstance(term, str)
                    except AssertionError:
                        assert isinstance(term, list)
                        assert all(isinstance(x, str) for x in term)

            assert "description_should_not_contain" in constraint
            assert isinstance(constraint["description_should_not_contain"], list)
            if constraint["description_should_not_contain"]:
                for term in constraint["description_should_not_contain"]:
                    assert isinstance(term, str)

            assert "house_types" in constraint
            assert constraint["house_types"]
            for house_type in constraint["house_types"]:
                assert house_type.upper() in HOUSE_TYPES.__members__

            assert "postal_codes" in constraint
            assert constraint["postal_codes"]
            assert all(isinstance(x, str) for x in constraint["postal_codes"])
            if "insee_codes" in constraint:
                assert constraint["insee_codes"]
                assert all(isinstance(x, str) for x in constraint["insee_codes"])

            if check_with_data:
                # Ensure data is built into db
                data.preprocess_data(config, force=False)
                # Check postal codes

# Path: flatisfy/data.py
# LOGGER = logging.getLogger(__name__)
#         def lru_cache(maxsize=None):  # pylint: disable=unused-argument
# def preprocess_data(config, force=False):
# def load_data(model, constraint, config):
# 
# Path: flatisfy/tools.py
# LOGGER = logging.getLogger(__name__)
# NAVITIA_ENDPOINT = "https://api.navitia.io/v1/coverage/fr-idf/journeys"
#         MAPBOX_MODES = {
#             TimeToModes.WALK: "mapbox/walking",
#             TimeToModes.BIKE: "mapbox/cycling",
#             TimeToModes.CAR: "mapbox/driving",
#         }
# def next_weekday(d, weekday):
# def convert_arabic_to_roman(arabic):
# def convert_arabic_to_roman_in_text(text):
# def hash_dict(func):
#         def __hash__(self):
#     def wrapped(*args, **kwargs):
#     def default(self, o):  # pylint: disable=locally-disabled,E0202
# def pretty_json(data):
# def batch(iterable, size):
# def is_within_interval(value, min_value=None, max_value=None):
# def normalize_string(string, lowercase=True, convert_arabic_numerals=True):
# def uniqify(some_list):
# def distance(gps1, gps2):
# def sort_list_of_dicts_by(flats_list, key):
# def merge_dicts(*args):
# def get_travel_time_between(latlng_from, latlng_to, mode, config):
# def timeit(func):
#     def wrapped(*args, **kwargs):
#     class HDict(dict):
# class DateAwareJSONEncoder(json.JSONEncoder):
# 
# Path: flatisfy/constants.py
# class TimeToModes(Enum):
#     PUBLIC_TRANSPORT = -1
#     WALK = 1
#     BIKE = 2
#     CAR = 3
# 
# 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/config.py
from builtins import str
from woob.capabilities.housing import POSTS_TYPES, HOUSE_TYPES
from flatisfy import data
from flatisfy import tools
from flatisfy.constants import TimeToModes
from flatisfy.models.postal_code import PostalCode
import json
import logging
import os
import sys
import traceback
import appdirs

            if constraint["description_should_contain"]:
                for term in constraint["description_should_contain"]:
                    try:
                        assert isinstance(term, str)
                    except AssertionError:
                        assert isinstance(term, list)
                        assert all(isinstance(x, str) for x in term)

            assert "description_should_not_contain" in constraint
            assert isinstance(constraint["description_should_not_contain"], list)
            if constraint["description_should_not_contain"]:
                for term in constraint["description_should_not_contain"]:
                    assert isinstance(term, str)

            assert "house_types" in constraint
            assert constraint["house_types"]
            for house_type in constraint["house_types"]:
                assert house_type.upper() in HOUSE_TYPES.__members__

            assert "postal_codes" in constraint
            assert constraint["postal_codes"]
            assert all(isinstance(x, str) for x in constraint["postal_codes"])
            if "insee_codes" in constraint:
                assert constraint["insee_codes"]
                assert all(isinstance(x, str) for x in constraint["insee_codes"])

            if check_with_data:
                # Ensure data is built into db
                data.preprocess_data(config, force=False)
                # Check postal codes

                opendata = data.load_data(PostalCode, constraint, config)