Skip to content

Commit 6bab639

Browse files
committed
Additional corrections to improve flake8 report
1 parent 6f95f89 commit 6bab639

File tree

8 files changed

+25
-22
lines changed

8 files changed

+25
-22
lines changed

crue10/etude.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def write_etu(self, folder=None):
226226
etu_path = os.path.join(folder, os.path.basename(self.etu_path))
227227
xml = 'etu'
228228
template_render = JINJA_ENV.get_template(xml + '.xml').render(
229-
folders=[(name, folder) for name, folder in self.folders.items()],
229+
folders=[(name, folder_str) for name, folder_str in self.folders.items()],
230230
metadata=self.metadata,
231231
current_scenario_id=self.nom_scenario_courant,
232232
files=[(os.path.basename(file), file[-8:-4].upper()) for file in sorted(self.filename_list)],

crue10/modele.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def write_all(self, folder, folder_config):
252252
def write_topological_graph(self, out_files, nodesep=0.8, prog='dot'):
253253
try:
254254
import pydot
255-
except ModuleNotFoundError:
255+
except ImportError: # ModuleNotFoundError not available in Python2
256256
raise CrueError("Le module pydot ne fonctionne pas !")
257257

258258
check_isinstance(out_files, list)

crue10/sous_modele.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
from builtins import super # Python2 fix
33
from collections import OrderedDict
44
import fiona
5+
import numpy as np
56
import os.path
67
from shapely.geometry import LinearRing, LineString, mapping, Point
78

89
from crue10.base import FichierXML
9-
from crue10.emh.branche import *
10+
from crue10.emh.branche import BRANCHE_CLASSES, Branche, BranchePdC, BrancheSeuilTransversal, \
11+
BrancheSeuilLateral, BrancheOrifice, BrancheStrickler, BrancheNiveauxAssocies, \
12+
BrancheBarrageGenerique, BrancheBarrageFilEau, BrancheSaintVenant
1013
from crue10.emh.casier import Casier, ProfilCasier
1114
from crue10.emh.noeud import Noeud
12-
from crue10.emh.section import DEFAULT_FK_MAX, DEFAULT_FK_MIN, DEFAULT_FK_STO, LoiFrottement, LimiteGeom, LitNumerote, \
13-
SectionIdem, SectionInterpolee, SectionProfil, SectionSansGeometrie
14-
from crue10.utils import check_preffix, CrueError, CrueErrorGeometryNotFound, PREFIX
15+
from crue10.emh.section import DEFAULT_FK_MAX, DEFAULT_FK_MIN, DEFAULT_FK_STO, LoiFrottement, \
16+
LimiteGeom, LitNumerote, Section, SectionIdem, SectionInterpolee, SectionProfil, SectionSansGeometrie
17+
from crue10.utils import check_isinstance, check_preffix, CrueError, CrueErrorGeometryNotFound, logger, PREFIX
1518

1619

1720
def parse_loi(elt, group='EvolutionFF', line='PointFF'):
@@ -650,12 +653,12 @@ def write_all(self, folder, folder_config=None):
650653

651654
# TO CHECK:
652655
# - Casier has at least one ProfilCasier
653-
# - BrancheSaintVenant has a section_pilote
656+
# - BrancheBarrage* has a section_pilote
654657
# ...
655658

656659
# Create folder if not existing
660+
sm_folder = os.path.join(folder, folder_config, self.id.upper())
657661
if folder_config is not None:
658-
sm_folder = os.path.join(folder, folder_config, self.id.upper())
659662
if not os.path.exists(sm_folder):
660663
os.makedirs(sm_folder)
661664

mascaret/mascaret_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ def _read_binary_header(self):
816816
for i, varname in enumerate(self.varnames):
817817
var_index = abbrs.index(varname)
818818
self.add_variable(names[var_index], units[var_index], varname)
819-
except FileNotFoundError:
819+
except IOError: # FileNotFoundError is not Python2
820820
self.logger.warning('Mascaret dico file is missing !')
821821
for i, varname in enumerate(self.varnames):
822822
self.add_variable('Rub_long_name_unknown_' + str(i), 'Rub_unit_unknown_' + str(i), varname)

snippets/lire_modele_et_run.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@
6969
# Write a shp file to check
7070
schema = {
7171
'geometry': 'Point',
72-
'properties': {'id_section': 'str', **{var: 'float' for var in VARIABLES}}
72+
'properties': {'id_section': 'str'}
7373
}
74+
schema['properties'].update({var: 'float' for var in VARIABLES})
7475
if ADD_BOTTOM:
7576
schema['properties']['Zf'] = 'float'
7677
with fiona.open(os.path.join(out_folder, 'debug.shp'), 'w', 'ESRI Shapefile', schema) as out_shp:
@@ -81,11 +82,9 @@
8182
values[var] = array[section_index, var_index]
8283
layer = {
8384
'geometry': mapping(Point(x, y)),
84-
'properties': {
85-
'id_section': section_name,
86-
**values
87-
}
85+
'properties': {'id_section': section_name}
8886
}
87+
layer['properties'].update(values)
8988
if ADD_BOTTOM:
9089
layer['properties']['Zf'] = z_bottom
9190
out_shp.write(layer)

snippets/lire_sous_modele.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
point = section.interp_point(section.lits_numerotes[i_lit - 1].xt_max)
4343
print((point.x, point.y))
4444

45-
except FileNotFoundError as e:
45+
except IOError as e:
4646
logger.critical(e)
4747
sys.exit(1)
4848
except CrueError as e:

snippets/post_crue_VS.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
variables = ['Zseuil_min', 'Qmax', 'Qmin']
3232
schema = {
3333
'geometry': 'LineString',
34-
'properties': {'id_branche': 'str', **{var: 'str' for var in variables}}
34+
'properties': {'id_branche': 'str'}
3535
}
36+
schema['properties'].update({var: 'float' for var in variables})
3637
with fiona.open(os.path.join(model_folder, 'check_at_branches.shp'), 'w', 'ESRI Shapefile', schema) as out_shp:
3738
for sous_modele in modele.liste_sous_modeles:
3839
sous_modele.convert_sectionidem_to_sectionprofil()
@@ -52,11 +53,9 @@
5253

5354
layer = {
5455
'geometry': mapping(branche.geom),
55-
'properties': {
56-
'id_branche': branche.id,
57-
**values
58-
}
56+
'properties': {'id_branche': branche.id}
5957
}
58+
layer['properties'].update(values)
6059
out_shp.write(layer)
6160

6261
except CrueError as e:

snippets/write_submodel_from_scratch.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
import os.path
55
from shapely.geometry import Point, LinearRing, LineString
66

7-
from crue10.emh.branche import *
7+
from crue10.emh.branche import BranchePdC, BrancheSeuilTransversal, \
8+
BrancheSeuilLateral, BrancheOrifice, BrancheStrickler, BrancheNiveauxAssocies, \
9+
BrancheBarrageGenerique, BrancheBarrageFilEau, BrancheSaintVenant
810
from crue10.emh.casier import Casier, ProfilCasier
911
from crue10.emh.noeud import Noeud
10-
from crue10.emh.section import *
12+
from crue10.emh.section import LimiteGeom, SectionIdem, SectionProfil, SectionSansGeometrie
1113
from crue10.sous_modele import SousModele
1214
from crue10.utils import logger
1315

0 commit comments

Comments
 (0)