Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to black 24 #95

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions backend/gn_modulator/imports/mixins/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ def pretty_errors_txt(self):
key_txt = (
f"'{relation_key}.{key}' : "
if key and relation_key
else f"'{key}' : "
if key
else ""
else f"'{key}' : " if key else ""
)
txt = f"- {key_txt}{error['error_msg']}\n"
for info in error.get("error_infos", []):
Expand Down
44 changes: 23 additions & 21 deletions backend/gn_modulator/imports/mixins/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,27 @@ def sql_process_import_view(self, from_table, dest_table, relation_key=None):
columns = (
[relation_key]
if relation_key and self.Model().is_relation_n_n(relation_key)
else list(
filter(
lambda x: (
self.Model().is_column(x)
and x.startswith(f"{relation_key}.")
and not x == self.Model().pk_field_name()
),
from_table_columns,
else (
list(
filter(
lambda x: (
self.Model().is_column(x)
and x.startswith(f"{relation_key}.")
and not x == self.Model().pk_field_name()
),
from_table_columns,
)
)
)
if relation_key and self.Model().is_relation_1_n(relation_key)
else list(
filter(
lambda x: (
self.Model().is_column(x)
and "." not in x
and not x == self.Model().pk_field_name()
),
from_table_columns,
if relation_key and self.Model().is_relation_1_n(relation_key)
else list(
filter(
lambda x: (
self.Model().is_column(x)
and "." not in x
and not x == self.Model().pk_field_name()
),
from_table_columns,
)
)
)
)
Expand Down Expand Up @@ -271,9 +273,9 @@ def resolve_key(
v_join += v_join_inter

# clarifier link oin
link_joins[
k_unique
] = f"{alias_join}_{index_unique}.{SchemaMethods(rel_schema_code).Model().pk_field_name()}"
link_joins[k_unique] = (
f"{alias_join}_{index_unique}.{SchemaMethods(rel_schema_code).Model().pk_field_name()}"
)

# conditions de jointures
v_join_on = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-03-03 14:31:35.339631

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-12-15 14:20:55.639520

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-10-09 15:55:41.769219

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-06-20 15:19:21.097194

"""

from alembic import op
import sqlalchemy as sa
from gn_modulator import MODULE_CODE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Revises:
Create Date: 2021-09-15 11:49:24.512562
"""

from alembic import op
from sqlalchemy.sql import text
import pkg_resources
Expand Down
1 change: 1 addition & 0 deletions backend/gn_modulator/query/filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
repositories - filters
"""

import unidecode
import sqlalchemy as sa
from geonature.utils.env import db
Expand Down
8 changes: 5 additions & 3 deletions backend/gn_modulator/query/getattr.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ def getModelAttr(Model, query, field_name, only_fields="", index=0, condition=No
current_Model = (
get_query_cache(query, current_relation_cache_key)["relation_alias"]
if query is not None and current_relation_cache_key
else Model.relation_Model(current_relation_cache_key)
if current_relation_cache_key
else Model
else (
Model.relation_Model(current_relation_cache_key)
if current_relation_cache_key
else Model
)
)

res = {"val": getattr(current_Model, current_field)}
Expand Down
5 changes: 2 additions & 3 deletions backend/gn_modulator/schema/auto.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
AutoSchemas
"""

from sqlalchemy.inspection import inspect
from sqlalchemy.orm.properties import ColumnProperty
from geonature.utils.env import db
Expand Down Expand Up @@ -148,9 +149,7 @@ def process_relation_auto(self, relation_key, relation, Model, properties):
"relation_type": (
"n-1"
if relation.direction.name == "MANYTOONE"
else "1-n"
if relation.direction.name == "ONETOMANY"
else "n-n"
else "1-n" if relation.direction.name == "ONETOMANY" else "n-n"
),
"schema_code": schema_code,
# "title": relation_key,
Expand Down
22 changes: 14 additions & 8 deletions backend/gn_modulator/schema/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,15 @@ def relation_type(self, relation_def):
relation_type = (
"n-1"
if relation_def.get("local_key") and not relation_def.get("foreign_key")
else "1-n"
if relation_def.get("foreign_key") and not relation_def.get("local_key")
else "n-n"
if relation_def.get("foreign_key") and relation_def.get("local_key")
else None
else (
"1-n"
if relation_def.get("foreign_key") and not relation_def.get("local_key")
else (
"n-n"
if relation_def.get("foreign_key") and relation_def.get("local_key")
else None
)
)
)

if relation_type is None:
Expand Down Expand Up @@ -290,9 +294,11 @@ def remove_field(self, field_name, schema):

def process_csv_keys(self, keys):
return [
self.property(key.split(".")[0]).get("title", key)
if self.has_property(key.split(".")[0])
else key
(
self.property(key.split(".")[0]).get("title", key)
if self.has_property(key.split(".")[0])
else key
)
for key in keys
]

Expand Down
16 changes: 7 additions & 9 deletions backend/gn_modulator/schema/config/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ def new(self, object_definition={}):
return (
"nouvelle"
if self.genre(object_definition) == "F"
else "nouvel"
if self.is_first_letter_vowel(self.label(object_definition))
else "nouveau"
else (
"nouvel"
if self.is_first_letter_vowel(self.label(object_definition))
else "nouveau"
)
)

def news(self, object_definition={}):
Expand Down Expand Up @@ -90,9 +92,7 @@ def article_def(self, object_definition={}):
return (
"l'"
if self.is_first_letter_vowel(self.label(object_definition))
else "la "
if self.genre(object_definition) == "F"
else "le "
else "la " if self.genre(object_definition) == "F" else "le "
)

def article_undef(self, object_definition={}):
Expand All @@ -111,9 +111,7 @@ def preposition(self, object_definition={}, check_voyel=True):
return (
"de l'"
if self.is_first_letter_vowel(self.label(object_definition)) and check_voyel
else "de la "
if self.genre(object_definition) == "F"
else "du "
else "de la " if self.genre(object_definition) == "F" else "du "
)

def le_label(self, object_definition={}):
Expand Down
8 changes: 5 additions & 3 deletions backend/gn_modulator/schema/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ def doc_import_key(self, key, unique=False, relation_key=None):
type = (
"clé simple"
if property_def.get("schema_code")
else "liste de clés séparées par une virgule"
if property_def.get("relation_type") == "n-n"
else property_def["type"]
else (
"liste de clés séparées par une virgule"
if property_def.get("relation_type") == "n-n"
else property_def["type"]
)
)

column_default = self.property(key).get("default") or (
Expand Down
8 changes: 5 additions & 3 deletions backend/gn_modulator/schema/features/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ def get_data_item(cls, data_item, file_path=None):
items = (
data_item["items"]
if "items" in data_item
else cls.get_data_items_from_file(Path(file_path).parent / data_item["file"])
if "file" in data_item
else []
else (
cls.get_data_items_from_file(Path(file_path).parent / data_item["file"])
if "file" in data_item
else []
)
)

if data_item.get("keys"):
Expand Down
10 changes: 5 additions & 5 deletions backend/gn_modulator/schema/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ def opposite_relation_def(self, relation_def):
"relation_type": (
"n-1"
if relation_def["relation_type"] == "1-n"
else "1-n"
if relation_def["relation_type"] == "n-1"
else "1-1"
if relation_def["relation_type"] == "1-1"
else "n-n"
else (
"1-n"
if relation_def["relation_type"] == "n-1"
else "1-1" if relation_def["relation_type"] == "1-1" else "n-n"
)
),
"schema_code": self.schema_code(),
"title": self.attr("meta.label"),
Expand Down
1 change: 1 addition & 0 deletions backend/gn_modulator/schema/validation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
"""

import jsonschema
import copy
from gn_modulator.utils.cache import get_global_cache, set_global_cache
Expand Down
2 changes: 1 addition & 1 deletion backend/gn_modulator/tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_repo_pf_rel(self, passages_faune_with_diagnostic, users):
# "date_requalification_ouvrage",
# "digitiser.nom_complet",
"actors.organisme.nom_organisme",
"linears.additional_data.largeur"
"linears.additional_data.largeur",
# "actors.nomenclature_type_actor.label_fr",
# "label_infrastructures",
# "linears.additional_data.largeur",
Expand Down
1 change: 0 additions & 1 deletion backend/gn_modulator/utils/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
utils, patch, etc...
"""


import unicodedata
import sys
from importlib import import_module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-08-04 16:05:35.209204

"""

from alembic import op
import sqlalchemy as sa
import pkg_resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-10-19 14:02:45.162974

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2024-01-09 18:22:22.097781

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-03-21 22:36:24.415201

"""

from alembic import op
import sqlalchemy as sa
import pkg_resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-11-14 16:50:11.560175

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2024-01-09 20:29:26.613697

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-10-12 11:38:15.137738

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-06-27 16:18:12.462599

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-03-08 18:21:26.724733

"""

from alembic import op

import sqlalchemy as sa
Expand Down
Loading