# Path: park_api/env.py
# API_VERSION = '1.0'
# SERVER_VERSION = '0.3.0'
# SOURCE_REPOSITORY = 'https://github.com/offenesdresden/ParkAPI'
# APP_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
# SERVER_CONF = None
# ENV = None
# SUPPORTED_CITIES = None
# DATABASE = {}
# DEFAULT_CONFIGURATION = {
#     "port": 5000,
#     "host": "::1",
#     "debug": False,
#     "live_scrape": True,
#     "database_uri": "postgres:///park_api",
# }
#         SUPPORTED_CITIES = load_cities()
#     ENV = os.getenv("env", "development")
#     SERVER_CONF = structs.ServerConf(host=raw_config.get('host'),
#                                      port=raw_config.getint("port"),
#                                      debug=raw_config.getboolean("debug"))
#     LIVE_SCRAPE = raw_config.getboolean("live_scrape")
#     DATABASE_URI = raw_config.get("database_uri")
#         SERVER_VERSION = '0.3.{0}'.format(rev)
# def is_production():
# def is_development():
# def is_testing():
# def is_staging():
# def load_cities():
# def supported_cities():
# def load_config():
# def determine_server_version():
# 
# Path: park_api/util.py
# def remove_special_chars(string):
#     """
#     Remove any umlauts, spaces and punctuation from a string.
# 
#     :param string:
#     :return:
#     """
#     replacements = {
#         "ä": "ae",
#         "ö": "oe",
#         "ü": "ue",
#         "ß": "ss",
#         "-": "",
#         " ": "",
#         ".": "",
#         ",": "",
#         "'": "",
#         "\"": "",
#         "/": "",
#         "\\": "",
#         "\n": "",
#         "\t": ""
#     }
#     for repl in replacements.keys():
#         string = string.replace(repl, replacements[repl])
#     return string


import os
import calendar
import json
from datetime import date
from collections import namedtuple
from park_api import env
from park_api.util import remove_special_chars

lot_fields = ['name', 'id', 'type', 'lng', 'lat', 'address', 'total', 'aux']


class Lot(namedtuple('Lot', lot_fields)):
    @property
    def coords(self):
        if self.lng is not None and self.lat is not None:
            return {'lng': self.lng, 'lat': self.lat}
        return None

city_fields = ['name', 'id', 'lng', 'lat', 'url', 'source', 'headers', 'public_source', 'active_support', 'attribution']


class City(namedtuple('City', city_fields)):
    @property
    def coords(self):
        if self.lng is not None and self.lat is not None:
            return {'lng': self.lng, 'lat': self.lat}
        return None


def generate_id(s):
    return remove_special_chars(s.lower())


class GeoData:
    def __init__(self, city):
        json_file = city[:-3] + ".geojson"
        self.city_name = os.path.basename(city[:-3])

# Path: park_api/env.py
# API_VERSION = '1.0'
# SERVER_VERSION = '0.3.0'
# SOURCE_REPOSITORY = 'https://github.com/offenesdresden/ParkAPI'
# APP_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
# SERVER_CONF = None
# ENV = None
# SUPPORTED_CITIES = None
# DATABASE = {}
# DEFAULT_CONFIGURATION = {
#     "port": 5000,
#     "host": "::1",
#     "debug": False,
#     "live_scrape": True,
#     "database_uri": "postgres:///park_api",
# }
#         SUPPORTED_CITIES = load_cities()
#     ENV = os.getenv("env", "development")
#     SERVER_CONF = structs.ServerConf(host=raw_config.get('host'),
#                                      port=raw_config.getint("port"),
#                                      debug=raw_config.getboolean("debug"))
#     LIVE_SCRAPE = raw_config.getboolean("live_scrape")
#     DATABASE_URI = raw_config.get("database_uri")
#         SERVER_VERSION = '0.3.{0}'.format(rev)
# def is_production():
# def is_development():
# def is_testing():
# def is_staging():
# def load_cities():
# def supported_cities():
# def load_config():
# def determine_server_version():
# 
# Path: park_api/util.py
# def remove_special_chars(string):
#     """
#     Remove any umlauts, spaces and punctuation from a string.
# 
#     :param string:
#     :return:
#     """
#     replacements = {
#         "ä": "ae",
#         "ö": "oe",
#         "ü": "ue",
#         "ß": "ss",
#         "-": "",
#         " ": "",
#         ".": "",
#         ",": "",
#         "'": "",
#         "\"": "",
#         "/": "",
#         "\\": "",
#         "\n": "",
#         "\t": ""
#     }
#     for repl in replacements.keys():
#         string = string.replace(repl, replacements[repl])
#     return string


# Path: park_api/geodata.py
import os
import calendar
import json
from datetime import date
from collections import namedtuple
from park_api import env
from park_api.util import remove_special_chars


lot_fields = ['name', 'id', 'type', 'lng', 'lat', 'address', 'total', 'aux']


class Lot(namedtuple('Lot', lot_fields)):
    @property
    def coords(self):
        if self.lng is not None and self.lat is not None:
            return {'lng': self.lng, 'lat': self.lat}
        return None

city_fields = ['name', 'id', 'lng', 'lat', 'url', 'source', 'headers', 'public_source', 'active_support', 'attribution']


class City(namedtuple('City', city_fields)):
    @property
    def coords(self):
        if self.lng is not None and self.lat is not None:
            return {'lng': self.lng, 'lat': self.lat}
        return None


def generate_id(s):
    return remove_special_chars(s.lower())


class GeoData:
    def __init__(self, city):
        json_file = city[:-3] + ".geojson"
        self.city_name = os.path.basename(city[:-3])

        json_path = os.path.join(env.APP_ROOT, "park_api", "cities", json_file)