Skip to content

Commit

Permalink
[ares] statutar nemusi mit nazev (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
kokes authored Jul 29, 2024
1 parent 98553e3 commit d652e80
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 8 additions & 6 deletions data/ares/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def obj(root):


def organi(root, ico, nsmap):
nazev = root.find("./are:Nazev", namespaces=nsmap).text
# ICO 1112 ma prazdny nazev statutaru
nazev_el = root.find("./are:Nazev", namespaces=nsmap)
nazev = nazev_el.text if nazev_el is not None else None

fosoby, posoby = [], []
for cl in root.findall("./are:Clen", namespaces=nsmap):
Expand Down Expand Up @@ -71,12 +73,16 @@ def remote_data(partial):
# pri castecnym loadu stahni jen megabyte
if partial:
with urlopen(BASE_URL) as r, open(tfn, "wb") as fw:
# v ARES je ted bug, kdy to obcas vraci naprostej garbage
# print(r.headers.__dict__["_headers"])
fw.write(r.read(1000_000))
else:
urlretrieve(BASE_URL, tfn)
with tarfile.open(tfn, "r:gz") as tf:
try:
for el in tf:
for j, el in enumerate(tf):
if partial and j > 100:
break
yield (el, tf.extractfile(el).read())
except EOFError:
if partial:
Expand All @@ -95,8 +101,6 @@ def main(outdir: str, partial: bool = False):
cols = [
"zdroj",
"aktualizace_db",
"datum_vypisu",
"cas_vypisu",
"typ_vypisu",
"rejstrik",
"ico",
Expand Down Expand Up @@ -158,8 +162,6 @@ def main(outdir: str, partial: bool = False):
uvod = vypis.find("./are:Uvod", namespaces=et.nsmap)
uvod_cols = [
"Aktualizace_DB",
"Datum_vypisu",
"Cas_vypisu",
"Typ_vypisu",
]

Expand Down
8 changes: 3 additions & 5 deletions data/ares/schema.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from sqlalchemy import Column, MetaData, Table
from sqlalchemy.sql.sqltypes import JSON, Date, Integer, Text, Time
from sqlalchemy.sql.sqltypes import JSON, Date, Integer, Text

meta = MetaData()

Expand All @@ -9,8 +9,6 @@
meta,
Column("zdroj", Text, nullable=False),
Column("aktualizace_db", Date, nullable=False),
Column("datum_vypisu", Date, nullable=False),
Column("cas_vypisu", Time, nullable=False),
Column("typ_vypisu", Text, nullable=False),
Column("rejstrik", Text, nullable=True),
Column("ico", Integer, nullable=False, primary_key=True, autoincrement=False),
Expand All @@ -23,7 +21,7 @@
"fosoby",
meta,
Column("ico", Integer, nullable=False, index=True),
Column("nazev_organu", Text, nullable=False),
Column("nazev_organu", Text, nullable=True),
Column("datum_zapisu", Date, nullable=False),
Column("datum_vymazu", Date, nullable=True),
Column("nazev_funkce", Text, nullable=True),
Expand All @@ -38,7 +36,7 @@
"posoby",
meta,
Column("ico", Integer, nullable=False, index=True),
Column("nazev_organu", Text, nullable=False),
Column("nazev_organu", Text, nullable=True),
Column("datum_zapisu", Date, nullable=False),
Column("datum_vymazu", Date, nullable=True),
Column("nazev_funkce", Text, nullable=True),
Expand Down

0 comments on commit d652e80

Please sign in to comment.