Skip to content

Commit 362eac5

Browse files
committed
[2.0] Rename to ExceptionCrue10
1 parent 6bab639 commit 362eac5

28 files changed

+154
-154
lines changed

cli/crue10_merge_models.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
import sys
2323

2424
from crue10.etude import Etude
25-
from crue10.utils import CrueError, logger
25+
from crue10.utils import ExceptionCrue10, logger
2626
from crue10.utils.cli_parser import MyArgParse
2727

2828

2929
def crue10_merge_models(args):
3030
if len(args.etu_path_list) != len(args.mo_name_list) != len(args.suffix_list):
31-
raise CrueError("Les arguments `--etu_path_list`, `--suffix_list` et `--mo_name_list`"
31+
raise ExceptionCrue10("Les arguments `--etu_path_list`, `--suffix_list` et `--mo_name_list`"
3232
" n'ont pas la même longueur !")
3333

3434
# Parse argument `--nodes_to_share`
@@ -39,16 +39,16 @@ def crue10_merge_models(args):
3939
for nodes_str in args.nodes_to_share:
4040
nodes = nodes_str.split(',')
4141
if len(nodes) != nb_models:
42-
raise CrueError("L'argument `--nodes_to_share` doit être composé de groupe(s) de %i noeuds"
43-
% nb_models)
42+
raise ExceptionCrue10("L'argument `--nodes_to_share` doit être composé de groupe(s) de %i noeuds"
43+
% nb_models)
4444
reference_found = False
4545
for i, node_id in enumerate(nodes):
4646
noeud_id_list[i].append(node_id)
4747
if not reference_found and node_id != '':
4848
noeud_id_references.append(node_id)
4949
reference_found = True
5050
if not reference_found:
51-
raise CrueError("Le noeud de référence n'a pas pu être trouvé pour : `%s`" % nodes_str)
51+
raise ExceptionCrue10("Le noeud de référence n'a pas pu être trouvé pour : `%s`" % nodes_str)
5252

5353
study_out = Etude(args.etu_path_out, access='w')
5454
study_out.create_empty_scenario('Sc_%s' % args.out_name, 'Mo_%s' % args.out_name, nom_sous_modele=None)
@@ -64,7 +64,7 @@ def crue10_merge_models(args):
6464
for j, noeud_id in enumerate(noeud_id_list[i]):
6565
if noeud_id != '':
6666
if noeud_id not in [nd.id for nd in model_in.get_liste_noeuds()]:
67-
raise CrueError("Le noeud %s n'est pas dans le modèle %s" % (noeud_id, model_in.id))
67+
raise ExceptionCrue10("Le noeud %s n'est pas dans le modèle %s" % (noeud_id, model_in.id))
6868
model_in.rename_noeud(noeud_id, noeud_id_references[j])
6969

7070
model_out.ajouter_depuis_modele(model_in)
@@ -101,6 +101,6 @@ def crue10_merge_models(args):
101101
args = parser.parse_args()
102102
try:
103103
crue10_merge_models(args)
104-
except CrueError as e:
104+
except ExceptionCrue10 as e:
105105
logger.critical(e)
106106
sys.exit(1)

cli/crue10_merge_submodels.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
from crue10.etude import Etude
1010
from crue10.sous_modele import SousModele
11-
from crue10.utils import CrueError, logger
11+
from crue10.utils import ExceptionCrue10, logger
1212
from crue10.utils.cli_parser import MyArgParse
1313

1414

1515
def crue10_merge_sous_modeles(args):
1616
if len(args.etu_path_list) != len(args.sm_name_list) != len(args.suffix_list):
17-
raise CrueError("Les arguments `etu_path_list`, `suffix_list` et `sm_name_list` n'ont pas la même longueur !")
17+
raise ExceptionCrue10("Les arguments `etu_path_list`, `suffix_list` et `sm_name_list` n'ont pas la même longueur !")
1818

1919
first = True
2020
merged_sous_modele = None
@@ -45,6 +45,6 @@ def crue10_merge_sous_modeles(args):
4545
args = parser.parse_args()
4646
try:
4747
crue10_merge_sous_modeles(args)
48-
except CrueError as e:
48+
except ExceptionCrue10 as e:
4949
logger.critical(e)
5050
sys.exit(1)

cli/crue10_model_extract_shp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77

88
from crue10.etude import Etude
9-
from crue10.utils import CrueError, logger
9+
from crue10.utils import ExceptionCrue10, logger
1010
from crue10.utils.cli_parser import MyArgParse
1111

1212

@@ -38,6 +38,6 @@ def crue10_model_extract_shp(args):
3838
args = parser.parse_args()
3939
try:
4040
crue10_model_extract_shp(args)
41-
except CrueError as e:
41+
except ExceptionCrue10 as e:
4242
logger.critical(e)
4343
sys.exit(1)

cli/crue10_model_for_maps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from crue10.emh.section import SectionProfil
2525
from crue10.etude import Etude
2626
from crue10.utils.cli_parser import MyArgParse
27-
from crue10.utils import CrueError, logger
27+
from crue10.utils import ExceptionCrue10, logger
2828

2929

3030
def crue10_model_for_maps(args):
@@ -218,6 +218,6 @@ def crue10_model_for_maps(args):
218218
args = parser.parse_args()
219219
try:
220220
crue10_model_for_maps(args)
221-
except CrueError as e:
221+
except ExceptionCrue10 as e:
222222
logger.critical(e)
223223
sys.exit(1)

cli/crue10_model_geom_to_mascaret.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from crue10.etude import Etude
1313
from crue10.utils.cli_parser import MyArgParse
14-
from crue10.utils import CrueError, logger
14+
from crue10.utils import ExceptionCrue10, logger
1515

1616

1717
def crue10_model_geom_to_mascaret(args):
@@ -34,6 +34,6 @@ def crue10_model_geom_to_mascaret(args):
3434
args = parser.parse_args()
3535
try:
3636
crue10_model_geom_to_mascaret(args)
37-
except CrueError as e:
37+
except ExceptionCrue10 as e:
3838
logger.critical(e)
3939
sys.exit(1)

cli/crue10_model_topographical_graph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import sys
2424

2525
from crue10.utils.cli_parser import MyArgParse
26-
from crue10.utils import CrueError, logger
26+
from crue10.utils import ExceptionCrue10, logger
2727
from crue10.etude import Etude
2828

2929

@@ -48,6 +48,6 @@ def crue10_model_topographical_graph(args):
4848
args = parser.parse_args()
4949
try:
5050
crue10_model_topographical_graph(args)
51-
except CrueError as e:
51+
except ExceptionCrue10 as e:
5252
logger.critical(e)
5353
sys.exit(1)

cli/crue10_xsd_validator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import sys
88

99
from crue10.etude import Etude
10-
from crue10.utils import CrueError, logger
10+
from crue10.utils import ExceptionCrue10, logger
1111
from crue10.utils.cli_parser import MyArgParse
1212

1313

@@ -39,6 +39,6 @@ def crue10_xsd_validator(args):
3939
args = parser.parse_args()
4040
try:
4141
crue10_xsd_validator(args)
42-
except CrueError as e:
42+
except ExceptionCrue10 as e:
4343
logger.critical(e)
4444
sys.exit(1)

cli/crue9_dc_topographical_graph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from io import open # Python2 fix
2929
import sys
3030

31-
from crue10.utils import CrueError, logger
31+
from crue10.utils import ExceptionCrue10, logger
3232
from crue10.utils.cli_parser import MyArgParse
3333
from crue10.utils.graph_1d_model import *
3434

@@ -125,7 +125,7 @@ def crue9_dc_topographical_graph(args):
125125
elif out_file.endswith('.dot'):
126126
graph.write_dot(out_file)
127127
else:
128-
raise CrueError("Le format de fichier de `%s` n'est pas supporté" % out_file)
128+
raise ExceptionCrue10("Le format de fichier de `%s` n'est pas supporté" % out_file)
129129

130130

131131
parser = MyArgParse(description=__doc__)
@@ -139,6 +139,6 @@ def crue9_dc_topographical_graph(args):
139139
args = parser.parse_args()
140140
try:
141141
crue9_dc_topographical_graph(args)
142-
except CrueError as e:
142+
except ExceptionCrue10 as e:
143143
logger.critical(e)
144144
sys.exit(1)

crue10/emh/branche.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from .noeud import Noeud
2222
from .section import Section, SectionIdem, SectionInterpolee, SectionProfil, SectionSansGeometrie
23-
from crue10.utils import check_isinstance, check_preffix, CrueError, CrueErrorGeometryNotFound, logger
23+
from crue10.utils import check_isinstance, check_preffix, ExceptionCrue10, ExceptionCrue10GeometryNotFound, logger
2424

2525

2626
# ABC below is compatible with Python 2 and 3
@@ -123,13 +123,13 @@ def ajouter_section_dans_branche(self, section, xp):
123123
check_isinstance(section, Section)
124124
if isinstance(section, SectionInterpolee):
125125
if self.type != 20:
126-
raise CrueError("La %s ne peut être affectée qu'à une branche Saint-Venant" % section)
126+
raise ExceptionCrue10("La %s ne peut être affectée qu'à une branche Saint-Venant" % section)
127127
elif self.type in Branche.TYPES_WITH_GEOM:
128128
if not isinstance(section, SectionProfil) and not isinstance(section, SectionIdem):
129-
raise CrueError("La %s ne peut porter que des SectionProfil ou SectionIdem" % self)
129+
raise ExceptionCrue10("La %s ne peut porter que des SectionProfil ou SectionIdem" % self)
130130
else:
131131
if not isinstance(section, SectionSansGeometrie):
132-
raise CrueError("La %s ne peut porter que des SectionSansGeometrie" % self)
132+
raise ExceptionCrue10("La %s ne peut porter que des SectionSansGeometrie" % self)
133133
section.xp = xp
134134
self.liste_sections_dans_branche.append(section)
135135

@@ -143,7 +143,7 @@ def shift_sectionprofil_to_extremity(self):
143143
(a constant biais is introduced by Fudaa-Crue for the graphical representation)
144144
"""
145145
if self.geom is None:
146-
raise CrueErrorGeometryNotFound(self)
146+
raise ExceptionCrue10GeometryNotFound(self)
147147
for pos in (0, -1):
148148
section = self.liste_sections_dans_branche[pos]
149149
if isinstance(section, SectionProfil):
@@ -152,7 +152,7 @@ def shift_sectionprofil_to_extremity(self):
152152
else:
153153
node = self.noeud_aval.geom
154154
if section.geom_trace is None:
155-
raise CrueErrorGeometryNotFound(section)
155+
raise ExceptionCrue10GeometryNotFound(section)
156156
section_point = section.geom_trace.intersection(self.geom)
157157
if isinstance(section_point, Point):
158158
dx = node.x - section_point.x

crue10/emh/casier.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from shapely.geometry import LinearRing
1212

1313
from crue10.emh.noeud import Noeud
14-
from crue10.utils import check_isinstance, check_preffix, CrueError, logger
14+
from crue10.utils import check_isinstance, check_preffix, ExceptionCrue10, logger
1515

1616

1717
DX = 0.1
@@ -69,14 +69,14 @@ def __init__(self, nom_profil_casier):
6969
def set_xz(self, array):
7070
check_isinstance(array, np.ndarray)
7171
if any(x > y for x, y in zip(array[:, 0], array[1:, 0])):
72-
raise CrueError("Les valeurs de xt ne sont pas strictement croissantes %s" % array[:, 0])
72+
raise ExceptionCrue10("Les valeurs de xt ne sont pas strictement croissantes %s" % array[:, 0])
7373
self.xz = array
7474
self.xt_min = self.xz[0, 0]
7575
self.xt_max = self.xz[-1, 0]
7676

7777
def interp_z(self, xt):
7878
if xt < self.xt_min or xt > self.xt_max:
79-
raise CrueError("xt=%f en dehors de la plage [%f, %f] pour %s" % (xt, self.xt_min, self.xt_max, self))
79+
raise ExceptionCrue10("xt=%f en dehors de la plage [%f, %f] pour %s" % (xt, self.xt_min, self.xt_max, self))
8080
return np.interp(xt, self.xz[:, 0], self.xz[:, 1])
8181

8282
def compute_surface(self, z):
@@ -116,7 +116,7 @@ def __init__(self, nom_casier, noeud, is_active=True):
116116
def set_geom(self, geom):
117117
check_isinstance(geom, LinearRing)
118118
if geom.has_z:
119-
raise CrueError("La trace du %s ne doit pas avoir de Z !" % self)
119+
raise ExceptionCrue10("La trace du %s ne doit pas avoir de Z !" % self)
120120
self.geom = geom
121121

122122
def ajouter_profil_casier(self, profil_casier):

crue10/emh/section.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import numpy as np
1717
from shapely.geometry import LineString
1818

19-
from crue10.utils import check_isinstance, check_preffix, CrueError, logger
19+
from crue10.utils import check_isinstance, check_preffix, ExceptionCrue10, logger
2020

2121

2222
# ABC below is compatible with Python 2 and 3
@@ -175,7 +175,7 @@ def xt_axe(self):
175175
for limite in self.limites_geom:
176176
if limite.id == 'Et_AxeHyd':
177177
return limite.xt
178-
raise CrueError("Limite 'Et_AxeHyd' could not be found for %s" % self)
178+
raise ExceptionCrue10("Limite 'Et_AxeHyd' could not be found for %s" % self)
179179

180180
@property
181181
def is_avec_fente(self):
@@ -193,9 +193,9 @@ def set_xz(self, array):
193193
def set_trace(self, trace):
194194
check_isinstance(trace, LineString)
195195
if trace.has_z:
196-
raise CrueError("La trace de la %s ne doit pas avoir de Z !" % self)
196+
raise ExceptionCrue10("La trace de la %s ne doit pas avoir de Z !" % self)
197197
if not self.lits_numerotes:
198-
raise CrueError('xz has to be set before (to check consistency)')
198+
raise ExceptionCrue10('xz has to be set before (to check consistency)')
199199
self.geom_trace = trace
200200

201201
# Display a warning if geometry is not consistent with self.xz array
@@ -214,9 +214,9 @@ def ajouter_fente(self, largeur, profondeur):
214214
def set_lits_numerotes(self, xt_list):
215215
"""Add directly the 5 beds from a list of 6 ordered xt values"""
216216
if len(xt_list) != 6:
217-
raise CrueError("Il faut exactement 5 lits numérotés pour les affecter")
217+
raise ExceptionCrue10("Il faut exactement 5 lits numérotés pour les affecter")
218218
if any(x > y for x, y in zip(xt_list, xt_list[1:])):
219-
raise CrueError("Les valeurs de xt ne sont pas croissantes")
219+
raise ExceptionCrue10("Les valeurs de xt ne sont pas croissantes")
220220
self.lits_numerotes = []
221221
for bed_name, xt_min, xt_max in zip(LitNumerote.BED_NAMES, xt_list, xt_list[1:]):
222222
lit_numerote = LitNumerote(bed_name, xt_min, xt_max)
@@ -225,21 +225,21 @@ def set_lits_numerotes(self, xt_list):
225225
def ajouter_lit(self, lit_numerote):
226226
check_isinstance(lit_numerote, LitNumerote)
227227
if lit_numerote.id in self.lits_numerotes:
228-
raise CrueError("Le lit numéroté `%s` est déjà présent" % lit_numerote.id)
228+
raise ExceptionCrue10("Le lit numéroté `%s` est déjà présent" % lit_numerote.id)
229229
self.lits_numerotes.append(lit_numerote)
230230

231231
def add_limite_geom(self, limite_geom):
232232
check_isinstance(limite_geom, LimiteGeom)
233233
if limite_geom.id in self.limites_geom:
234-
raise CrueError("La limite géométrique `%s` est déjà présente" % limite_geom.id)
234+
raise ExceptionCrue10("La limite géométrique `%s` est déjà présente" % limite_geom.id)
235235
self.limites_geom.append(limite_geom)
236236

237237
def interp_z(self, xt):
238238
return np.interp(xt, self.xz[:, 0], self.xz[:, 1])
239239

240240
def interp_point(self, xt):
241241
if not self.lits_numerotes:
242-
raise CrueError('lits_numerotes has to be set before')
242+
raise ExceptionCrue10('lits_numerotes has to be set before')
243243
xt_line = xt - self.lits_numerotes[0].xt_min
244244
diff = xt_line - self.geom_trace.length
245245
if diff > DISTANCE_TOL:
@@ -250,9 +250,9 @@ def interp_point(self, xt):
250250

251251
def get_coord(self, add_z=False):
252252
if self.xz is None:
253-
raise CrueError("`%s`: 3D trace could not be computed (xz is missing)!" % self)
253+
raise ExceptionCrue10("`%s`: 3D trace could not be computed (xz is missing)!" % self)
254254
if self.geom_trace is None:
255-
raise CrueError("`%s`: 3D trace could not be computed (trace is missing)!" % self)
255+
raise ExceptionCrue10("`%s`: 3D trace could not be computed (trace is missing)!" % self)
256256
coords = []
257257
for xt, z in self.xz_filtered:
258258
point = self.interp_point(xt)

0 commit comments

Comments
 (0)