Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MO-P
Odevzdávací Systém MO
Commits
94ed4478
Project 'mj/mo-submit' was moved to 'mo-p/osmo'. Please update any links and bookmarks that may still have the old path.
Commit
94ed4478
authored
Jan 4, 2021
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Školy: init-schools umí dry run a vypisuje lepší statistiky
parent
ab50103c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/init-schools
+14
-4
14 additions, 4 deletions
bin/init-schools
with
14 additions
and
4 deletions
bin/init-schools
+
14
−
4
View file @
94ed4478
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
# nemusí odpovídat skutečnému sídlu školy. Proto si poněkud magicky pomáháme
# nemusí odpovídat skutečnému sídlu školy. Proto si poněkud magicky pomáháme
# číselníkem obcí z RUIANu.
# číselníkem obcí z RUIANu.
import
argparse
from
typing
import
List
,
Dict
,
DefaultDict
from
typing
import
List
,
Dict
,
DefaultDict
import
sys
import
sys
from
pathlib
import
Path
from
pathlib
import
Path
...
@@ -17,6 +18,7 @@ from collections import defaultdict
...
@@ -17,6 +18,7 @@ from collections import defaultdict
session
=
db
.
get_session
()
session
=
db
.
get_session
()
new_town_cnt
=
0
new_town_cnt
=
0
processed_school_cnt
=
0
new_school_cnt
=
0
new_school_cnt
=
0
...
@@ -91,10 +93,12 @@ def import_schools(path: Path, nuts: str):
...
@@ -91,10 +93,12 @@ def import_schools(path: Path, nuts: str):
is_zs
=
is_zs
,
is_zs
=
is_zs
,
is_ss
=
not
is_zs
)
is_ss
=
not
is_zs
)
session
.
add
(
school
)
session
.
add
(
school
)
global
new_school_cnt
global
new_school_cnt
new_school_cnt
+=
1
new_school_cnt
+=
1
global
processed_school_cnt
processed_school_cnt
+=
1
def
parse_header
(
header
:
str
)
->
Dict
[
str
,
int
]:
def
parse_header
(
header
:
str
)
->
Dict
[
str
,
int
]:
columns
=
{}
columns
=
{}
...
@@ -190,6 +194,10 @@ def load_ruian():
...
@@ -190,6 +194,10 @@ def load_ruian():
# print(f"{jmeno} -> {okres}")
# print(f"{jmeno} -> {okres}")
ruian_obec_to_okres_nuts
[
jmeno
].
append
(
okres
[
ocols
[
'
NUTS_LAU
'
]])
ruian_obec_to_okres_nuts
[
jmeno
].
append
(
okres
[
ocols
[
'
NUTS_LAU
'
]])
parser
=
argparse
.
ArgumentParser
(
description
=
'
Importuje školy z naparsovaného Rejstříku škol
'
)
parser
.
add_argument
(
'
-n
'
,
'
--dry-run
'
,
default
=
False
,
action
=
'
store_true
'
,
help
=
'
pouze ukáže, co by bylo provedeno
'
)
args
=
parser
.
parse_args
()
load_ruian
()
load_ruian
()
...
@@ -199,5 +207,7 @@ for path in Path('db/skoly/parsed').glob('*.tsv'):
...
@@ -199,5 +207,7 @@ for path in Path('db/skoly/parsed').glob('*.tsv'):
nuts
=
m
[
1
]
nuts
=
m
[
1
]
import_schools
(
path
,
nuts
)
import_schools
(
path
,
nuts
)
if
not
args
.
dry_run
:
session
.
commit
()
session
.
commit
()
print
(
f
"
Importováno
{
new_school_cnt
}
škol, založeno
{
new_town_cnt
}
nových obcí.
"
)
print
(
f
"
Importováno
{
processed_school_cnt
}
škol.
"
)
print
(
f
"
Založeno
{
new_school_cnt
}
nových škol a
{
new_town_cnt
}
nových obcí.
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment