# Path: APITaxi_models2/zupc.py
# class Town(db.Model):
# class ZUPC(db.Model):
#     def __repr__(self):
#     def __repr__(self):


import json
import pathlib
import sys
import yaml
import click
from flask import Blueprint, current_app
from sqlalchemy import func
from APITaxi_models2 import db, Town, ZUPC
from APITaxi_models2.zupc import town_zupc
    """Import the ZUPC repo into the database"""
    # Ensure zupc_repo has been cloned
    if not zupc_repo.exists():
        raise ValueError('Please clone https://github.com/openmaraude/ZUPC to %s or set --zupc-dir option to the '
                         'cloned directory' % zupc_repo)

    # Delete existing zones beforehand?
    fill_zupc_table_from_arretes(zupc_repo)


@blueprint.cli.command('export_zupc')
def export_zupc():
    """Export the list of ZUPC as a GeoJSON map to share."""

    output = {
        'type': "FeatureCollection",
        'features': []
    }

    query = db.session.query(
        ZUPC,
        func.ST_AsGeoJSON(
            func.ST_Union(  # Aggregate function
                func.Geometry(  # Geometry type needed
                    Town.shape
                )
            )
        ),
        func.json_agg(Town.insee),
    ).join(

# Path: APITaxi_models2/zupc.py
# class Town(db.Model):
# class ZUPC(db.Model):
#     def __repr__(self):
#     def __repr__(self):


# Path: APITaxi2/commands/zupc.py
import json
import pathlib
import sys
import yaml
import click
from flask import Blueprint, current_app
from sqlalchemy import func
from APITaxi_models2 import db, Town, ZUPC
from APITaxi_models2.zupc import town_zupc

    """Import the ZUPC repo into the database"""
    # Ensure zupc_repo has been cloned
    if not zupc_repo.exists():
        raise ValueError('Please clone https://github.com/openmaraude/ZUPC to %s or set --zupc-dir option to the '
                         'cloned directory' % zupc_repo)

    # Delete existing zones beforehand?
    fill_zupc_table_from_arretes(zupc_repo)


@blueprint.cli.command('export_zupc')
def export_zupc():
    """Export the list of ZUPC as a GeoJSON map to share."""

    output = {
        'type': "FeatureCollection",
        'features': []
    }

    query = db.session.query(
        ZUPC,
        func.ST_AsGeoJSON(
            func.ST_Union(  # Aggregate function
                func.Geometry(  # Geometry type needed
                    Town.shape
                )
            )
        ),
        func.json_agg(Town.insee),
    ).join(

        town_zupc, town_zupc.c.zupc_id == ZUPC.id