Example #1
0
    def build_schema_map(schema):
        schema_index_items = OrderedDict()

        if isinstance(schema, basestring):
            if schema == 'Stations':
                schema = Schema().station
            elif schema == 'Results':
                schema = Schema().result

        for item in schema:
            schema_index_items.update({item['destination']: Field(item)})

        return OrderedDict(schema_index_items)
Example #2
0
    def __init__(self, row, normalizer):
        super(UgsStation, self).__init__(normalizer)

        self.schema = Schema().station

        self.schema_map = Table.build_schema_map(self.schema)
        self.row = self._etl_row(row, self.schema_map, 'Station')
Example #3
0
    def __init__(self, row, normalizer):
        super(UgsResult, self).__init__(normalizer)

        self.schema = Schema().result

        self.schema_map = Table.build_schema_map(self.schema)
        self.row = self._etl_row(row, self.schema_map, 'Result')
Example #4
0
    def __init__(self, row, normalizer):
        super(WqpStation, self).__init__(normalizer)

        schema = Schema().station
        self.fields = range(0, len(schema))

        schema_map = WqpTable.build_schema_map(schema)
        self.row = self._etl_row(row, schema_map, 'Station')
Example #5
0
def __sync(fname):
    stream = file(fname, 'r')
    print "syncing "+fname
    dic = yaml.safe_load(stream=stream)

    s = Schema.from_dic(dic)

    s.sync_description()
Example #6
0
    def __init__(self, row, normalizer):
        super(WqpResult, self).__init__(normalizer)

        schema = Schema().result
        self.fields = range(0, len(schema))

        schema_map = WqpTable.build_schema_map(schema)
        self.row = self._etl_row(row, schema_map, 'Result')
Example #7
0
def schema_yaml(path, schema):

    """ Cria o yaml para um schema de nome 'schema' na pasta 'path' """

    s = Schema.with_name(schema)

    if not s:
        print "Schema com nome '%s' não encontrado." % (schema,)
    else:
        __create_yaml(path, s)
Example #8
0
    def dbd_to_ram(self):
        conn = sqlite3.connect(self.file_path)
        cur = conn.cursor()

        db_schema = cur.execute("SELECT * from dbd$schemas").fetchall()
        schema_metadata = self._getMetadata(cur, "dbd$schemas")

        for item in db_schema:
            schema_dictionary = dict(zip(schema_metadata, list(item)))
            schema = Schema(schema_dictionary)
            schema.domains = self._getDbDomains(cur)

            if schema_dictionary.get("id") is not None:
                schema.tables = self._getDbTables(cur, schema_dictionary["id"])

        conn.commit()
        conn.close()

        return schema
Example #9
0
    def __init__(self, row, normalizer):
        super(DwrResult, self).__init__(normalizer)

        #: add paramgroup in ctor so `Type.fields` works for reads
        #: since paragroup does not exist in source data
        self.fields = self.fields + ['ParamGroup']

        self.schema = Schema().result

        self.schema_map = Table.build_schema_map(self.schema)
        self.row = self._etl_row(row, self.schema_map, 'Result')
Example #10
0
def all_yamls(path):

    """ Cria na pasta 'path' os yamls
        para todos os schemas do banco de dados
    """

    schemas = Schema.all()

    if not schemas:
        print "Nenhum schema encontrado."

    for s in schemas:
        __create_yaml(path, s)
Example #11
0
    def xml_to_ram(self):
        schema = Schema()
        for attributeName, attributeValue in self.xml.documentElement.attributes.items(
        ):
            if attributeName.lower() == "fulltext_engine":
                schema.fulltext_engine = attributeValue
            elif attributeName.lower() == "version":
                schema.version = attributeValue
            elif attributeName.lower() == "name":
                schema.name = attributeValue
            elif attributeName.lower() == "description":
                schema.description = attributeValue
            else:
                raise ValueError(
                    "Incorrect attribute name \"{}\" in tag \"{}\"".format(
                        attributeName, schema.nodeName))

            schema.domains = self._getDomains()
            schema.tables = self._getTables(self.xml)

        return schema
Example #12
0
    def _create_feature_classes(self, types):
        """creates feature classes for the given types"""

        results_table = TableInfo(self.location, 'Results')
        station_points = TableInfo(self.location, 'Stations')
        schema = Schema()

        if 'Results' in types:
            arcpy.CreateTable_management(self.location, results_table.name)

            self._add_fields(results_table, schema.result)

        if 'Stations' in types:
            sr = arcpy.SpatialReference(26912)
            arcpy.CreateFeatureclass_management(self.location,
                                                station_points.name,
                                                'POINT',
                                                spatial_reference=sr)

            self._add_fields(station_points, schema.station)
Example #13
0
#On hitting http://localhost:5000/Gowri You can see Hello Gowri
@app.route("/<name>")
def hello_name(name):
    return "Hello " + name


@app.route("/todo", methods=["GET"])
def list_todo():
    return jsonify(ToDoService().list())


@app.route("/todo", methods=["POST"])
def create_todo():
    return jsonify(ToDoService().create(request.get_json()))


@app.route("/todo/<item_id>", methods=["PUT"])
def update_item(item_id):
    return jsonify(ToDoService().update(item_id, request.get_json()))


@app.route("/todo/<item_id>", methods=["DELETE"])
def delete_item(item_id):
    return jsonify(ToDoService().delete(item_id))


if __name__ == "__main__":
    Schema()
    app.run(debug=True, port=8888)
Example #14
0
def hello_world():
    Schema()
    return 'Hello World!'
Example #15
0
 def __init__(self):
     self.conn = sqlite3.connect('chatbot.db')
     Schema()
     self.main()