pep8: Some modifications to respect pep8 standard code.

This commit is contained in:
Pierre-Antoine Rouby committed 2023-10-11 11:06:45 +02:00
1 parent 8544dd1144
commit fa2454d079
152 files changed
+1626 -1277

No files matched your search

+35 -16
View File
@@ -32,6 +32,7 @@ config_file = "config.sqlite3"
logger = logging.getLogger()
class Config(SQL):
def __init__(self):
self._version = '0.0.3'
@@ -40,15 +41,17 @@ class Config(SQL):
logging.info(f"Configuration file : {self.filename}")
super(Config, self).__init__(filename = self.filename)
super(Config, self).__init__(filename=self.filename)
def _create(self):
# Info (meta data)
self.execute("CREATE TABLE info(key TEXT NOT NULL UNIQUE, value TEXT NOT NULL)")
self.execute(
"CREATE TABLE info(key TEXT NOT NULL UNIQUE, value TEXT NOT NULL)")
self.execute(f"INSERT INTO info VALUES ('version', '{self._version}')")
# Key / Value (data)
self.execute("CREATE TABLE data(key TEXT NOT NULL UNIQUE, value TEXT NOT NULL)")
self.execute(
"CREATE TABLE data(key TEXT NOT NULL UNIQUE, value TEXT NOT NULL)")
# Solver
self.execute("""
@@ -79,12 +82,15 @@ class Config(SQL):
self.commit()
def _update(self):
version = self.execute(f"SELECT value FROM info WHERE key='version'")[0]
version = self.execute(
f"SELECT value FROM info WHERE key='version'")[0]
if version != self._version:
logger.info(f"Configuration file update from {version} to {self._version}...")
logger.info(
"Configuration file update from " +
f"{version} to {self._version}..."
)
major, minor, release = version.strip().split(".")
@@ -92,6 +98,8 @@ class Config(SQL):
if int(release) < 2:
# Add default solver
posix = os.name == 'posix'
ext = "" if posix else ".exe"
self.execute(f"""
INSERT INTO solver VALUES (
'mage8',
@@ -101,13 +109,14 @@ class Config(SQL):
'', '', '',
'',
'@install_dir/mage/mage{"" if posix else ".exe"} @args @input',
'@install_dir/mage/mage{ext} @args @input',
''
)
""")
if int(release) < 3:
self.execute(f"INSERT INTO data VALUES ('last_study', '')")
self.execute(f"INSERT INTO data VALUES ('close_correctly', 'True')")
self.execute(
f"INSERT INTO data VALUES ('close_correctly', 'True')")
self.commit()
@@ -116,7 +125,7 @@ class Config(SQL):
solvers = self.execute(
"SELECT * FROM solver",
fetch_one = False
fetch_one=False
)
for solver in solvers:
solver_type = solver[0]
@@ -139,7 +148,7 @@ class Config(SQL):
id = 0
stricklers = self.execute(
"SELECT * FROM stricklers",
fetch_one = False
fetch_one=False
)
for strickler in stricklers:
new = Stricklers()
@@ -210,7 +219,7 @@ class Config(SQL):
'{self._sql_format(solver._cmd_output)}'
)
""",
commit = True)
commit=True)
def _save_stricklers(self):
self.execute(f"DELETE FROM stricklers")
@@ -263,10 +272,12 @@ class Config(SQL):
self._solvers = []
posix = os.name == 'posix'
ext = "" if posix else ".exe"
ctor = solver_type_list["mage8"]
new = ctor("default-mage")
new._description = "Default Pamhyr2 mage 8 version"
new._cmd_solver = f""""@install_dir/mage/mage{"" if posix else ".exe"}" @args @input"""
new._cmd_solver = f""""@install_dir/mage/mage{ext}" @args @input"""
self._solvers.append(new)
# Meshing tool
@@ -300,14 +311,22 @@ class Config(SQL):
def set_close_correctly(self):
self.close_correctly = True
self.execute(f"UPDATE data SET value='True' WHERE key='close_correctly'")
self.execute(
f"UPDATE data SET value='True' WHERE key='close_correctly'")
self.commit()
def set_last_study(self, filename):
self.last_study = filename
self.close_correctly = False
self.execute(f"UPDATE data SET value='{self._sql_format(self.last_study)}' WHERE key='last_study'")
self.execute(f"UPDATE data SET value='{self.close_correctly}' WHERE key='close_correctly'")
self.execute(
"UPDATE data SET " +
f"value='{self._sql_format(self.last_study)}' " +
"WHERE key='last_study'"
)
self.execute(
f"UPDATE data SET value='{self.close_correctly}' " +
"WHERE key='close_correctly'"
)
self.commit()
@classmethod
@@ -320,7 +339,7 @@ class Config(SQL):
ndir = os.path.expanduser('~') + config_dir
ndir = ndir.replace("/", "\\")
os.makedirs(ndir, exist_ok = True)
os.makedirs(ndir, exist_ok=True)
file = ndir + config_file
return file