Commit 2c592b25 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

pep8: Fix code format.

Showing with 32 additions and 18 deletions
+32 -18
...@@ -25,7 +25,7 @@ try: ...@@ -25,7 +25,7 @@ try:
# Installation allow Unix-like signal # Installation allow Unix-like signal
from signal import SIGTERM, SIGSTOP, SIGCONT from signal import SIGTERM, SIGSTOP, SIGCONT
_signal = True _signal = True
except: except Exception:
_signal = False _signal = False
from enum import Enum from enum import Enum
...@@ -220,7 +220,7 @@ class AbstractSolver(object): ...@@ -220,7 +220,7 @@ class AbstractSolver(object):
""" """
# HACK: Works in most case... Trust me i'm an engineer # HACK: Works in most case... Trust me i'm an engineer
cmd = cmd.replace("@install_dir", self._install_dir()) cmd = cmd.replace("@install_dir", self._install_dir())
cmd = cmd.replace("@path", path.replace(" ", "\ ")) cmd = cmd.replace("@path", path.replace(" ", "%20"))
cmd = cmd.replace("@input", self.input_param()) cmd = cmd.replace("@input", self.input_param())
cmd = cmd.replace("@dir", self._process.workingDirectory()) cmd = cmd.replace("@dir", self._process.workingDirectory())
cmd = cmd.replace("@args", " ".join(self.cmd_args(study))) cmd = cmd.replace("@args", " ".join(self.cmd_args(study)))
...@@ -230,7 +230,7 @@ class AbstractSolver(object): ...@@ -230,7 +230,7 @@ class AbstractSolver(object):
if cmd[0] == "\"": if cmd[0] == "\"":
# Command line executable path is between " char # Command line executable path is between " char
cmd = cmd.split("\"") cmd = cmd.split("\"")
exe = cmd[1].replace("\ ", " ") exe = cmd[1].replace("%20", " ")
args = list( args = list(
filter( filter(
lambda s: s != "", lambda s: s != "",
...@@ -239,12 +239,12 @@ class AbstractSolver(object): ...@@ -239,12 +239,12 @@ class AbstractSolver(object):
) )
else: else:
# We suppose the command line executable path as no space char # We suppose the command line executable path as no space char
cmd = cmd.replace("\ ", "&_&").split(" ") cmd = cmd.replace("\\ ", "&_&").split(" ")
exe = cmd[0].replace("&_&", " ") exe = cmd[0].replace("&_&", " ")
args = list( args = list(
filter( filter(
lambda s: s != "", lambda s: s != "",
map(lambda s: s.replace("&_&", "\ "), cmd[1:]) map(lambda s: s.replace("&_&", " "), cmd[1:])
) )
) )
......
...@@ -99,11 +99,11 @@ class Mage(AbstractSolver): ...@@ -99,11 +99,11 @@ class Mage(AbstractSolver):
########## ##########
def cmd_args(self, study): def cmd_args(self, study):
l = super(Mage, self).cmd_args(study) lst = super(Mage, self).cmd_args(study)
l.append("-r") lst.append("-r")
return l return lst
def input_param(self): def input_param(self):
name = self._study.name name = self._study.name
...@@ -137,7 +137,10 @@ class Mage(AbstractSolver): ...@@ -137,7 +137,10 @@ class Mage(AbstractSolver):
if edge._name == "": if edge._name == "":
name = f"Reach_{edge.id}" name = f"Reach_{edge.id}"
with mage_file_open(os.path.join(repertory, "net", f"{name}.ST"), "w+") as f: with mage_file_open(
os.path.join(repertory, "net", f"{name}.ST"),
"w+"
) as f:
files.append(str(os.path.join("net", f"{name}.ST"))) files.append(str(os.path.join("net", f"{name}.ST")))
cnt_num = 1 cnt_num = 1
...@@ -159,8 +162,12 @@ class Mage(AbstractSolver): ...@@ -159,8 +162,12 @@ class Mage(AbstractSolver):
nl = len(profile.sl) nl = len(profile.sl)
sediment = f" {nl:>3}" sediment = f" {nl:>3}"
for l in profile.sl.layers: for layer in profile.sl.layers:
sediment += f" {l.height:>10} {l.d50:>10} {l.sigma:>10} {l.critical_constraint:>10}" sediment += (
f" {layer.height:>10} {layer.d50:>10} " +
f"{layer.sigma:>10} " +
f"{layer.critical_constraint:>10}"
)
f.write(f"{num}{c1}{c2}{t}{kp} {name} {sediment}\n") f.write(f"{num}{c1}{c2}{t}{kp} {name} {sediment}\n")
cnt_num += 1 cnt_num += 1
...@@ -176,9 +183,13 @@ class Mage(AbstractSolver): ...@@ -176,9 +183,13 @@ class Mage(AbstractSolver):
if point.sl is not None: if point.sl is not None:
nl = len(point.sl) nl = len(point.sl)
sediment = f"{nl:>3}" sediment = f"{nl:>3}"
for l in point.sl.layers: for layer in point.sl.layers:
prev = round(prev - l.height, 5) prev = round(prev - layer.height, 5)
sediment += f" {prev:>10} {l.d50:>10} {l.sigma:>10} {l.critical_constraint:>10}" sediment += (
f" {prev:>10} {layer.d50:>10} " +
f"{layer.sigma:>10} " +
f"{layer.critical_constraint:>10}"
)
f.write(f"{x}{y}{z} {n} {sediment}\n") f.write(f"{x}{y}{z} {n} {sediment}\n")
...@@ -252,7 +263,10 @@ class Mage(AbstractSolver): ...@@ -252,7 +263,10 @@ class Mage(AbstractSolver):
# if qlog is not None: # if qlog is not None:
# qlog.put(f"Export LAT file") # qlog.put(f"Export LAT file")
# with mage_file_open(os.path.join(repertory, f"{name}.LAT"), "w+") as f: # with mage_file_open(
# os.path.join(repertory, f"{name}.LAT"),
# "w+"
# ) as f:
# files.append(f"{name}.LAT") # files.append(f"{name}.LAT")
# name = f"{lateral.node.id:3}".replace(" ", "x") # name = f"{lateral.node.id:3}".replace(" ", "x")
...@@ -478,12 +492,12 @@ class Mage8(Mage): ...@@ -478,12 +492,12 @@ class Mage8(Mage):
########## ##########
def cmd_args(self, study): def cmd_args(self, study):
l = super(Mage8, self).cmd_args(study) lst = super(Mage8, self).cmd_args(study)
if study.river.has_sediment(): if study.river.has_sediment():
l.append("-c=3") lst.append("-c=3")
return l return lst
@timer @timer
def _export_PAR(self, study, repertory, qlog=None, name="0"): def _export_PAR(self, study, repertory, qlog=None, name="0"):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment