Skip to content

Commit

Permalink
Reformatting according to Black
Browse files Browse the repository at this point in the history
Changed from Autopep to Black :-)
  • Loading branch information
JR-1991 committed Mar 3, 2022
1 parent 1965b70 commit ae2c946
Show file tree
Hide file tree
Showing 28 changed files with 912 additions and 1,265 deletions.
4 changes: 2 additions & 2 deletions pyenzyme/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''
"""
File: __init__.py
Project: pyenzyme
Author: Jan Range
Expand All @@ -8,7 +8,7 @@
Modified By: Jan Range (<jan.range@simtech.uni-stuttgart.de>)
-----
Copyright (c) 2021 Institute of Biochemistry and Technical Biochemistry Stuttgart
'''
"""

from pyenzyme.enzymeml.core import EnzymeMLDocument
from pyenzyme.enzymeml.core import Vessel
Expand Down
4 changes: 2 additions & 2 deletions pyenzyme/enzymeml/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''
"""
File: __init__.py
Project: core
Author: Jan Range
Expand All @@ -8,7 +8,7 @@
Modified By: Jan Range (<jan.range@simtech.uni-stuttgart.de>)
-----
Copyright (c) 2021 Institute of Biochemistry and Technical Biochemistry Stuttgart
'''
"""

from pyenzyme.enzymeml.core.creator import Creator
from pyenzyme.enzymeml.core.enzymemldocument import EnzymeMLDocument
Expand Down
8 changes: 3 additions & 5 deletions pyenzyme/enzymeml/core/abstract_classes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''
"""
File: creator.py
Project: core
Author: Jan Range
Expand All @@ -8,7 +8,7 @@
Modified By: Jan Range (<jan.range@simtech.uni-stuttgart.de>)
-----
Copyright (c) 2021 Institute of Biochemistry and Technical Biochemistry Stuttgart
'''
"""

from pydantic import BaseModel, PrivateAttr, validator
from typing import Optional
Expand Down Expand Up @@ -58,7 +58,5 @@ class AbstractSpeciesFactory(ABC):
enzymeml_part: str

@abstractmethod
def get_species(
self, **kwargs
) -> AbstractSpecies:
def get_species(self, **kwargs) -> AbstractSpecies:
"""Return a new species object"""
14 changes: 5 additions & 9 deletions pyenzyme/enzymeml/core/complex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''
"""
File: complex.py
Project: core
Author: Jan Range
Expand All @@ -8,7 +8,7 @@
Modified By: Jan Range (<jan.range@simtech.uni-stuttgart.de>)
-----
Copyright (c) 2021 Institute of Biochemistry and Technical Biochemistry Stuttgart
'''
"""

import re

Expand Down Expand Up @@ -46,13 +46,11 @@ class Complex(EnzymeMLBase, AbstractSpecies):
vessel_id: str = Field(
...,
description="Identifier of the vessel in which the protein was stored.",
regex=r"v[\d]+"
regex=r"v[\d]+",
)

init_conc: Optional[float] = Field(
None,
description="Initial concentration of the protein.",
inclusiveMinimum=0.0
None, description="Initial concentration of the protein.", inclusiveMinimum=0.0
)

unit: Optional[str] = Field(
Expand All @@ -71,9 +69,7 @@ class Complex(EnzymeMLBase, AbstractSpecies):
)

id: Optional[str] = Field(
None,
description="Unique identifier of the protein.",
regex=r"c[\d]+"
None, description="Unique identifier of the protein.", regex=r"c[\d]+"
)

boundary: bool = Field(
Expand Down
23 changes: 8 additions & 15 deletions pyenzyme/enzymeml/core/creator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''
"""
File: creator.py
Project: core
Author: Jan Range
Expand All @@ -8,17 +8,14 @@
Modified By: Jan Range (<jan.range@simtech.uni-stuttgart.de>)
-----
Copyright (c) 2021 Institute of Biochemistry and Technical Biochemistry Stuttgart
'''
"""

from pydantic import Field, validator, ValidationError
from typing import TYPE_CHECKING, Optional
from dataclasses import dataclass

from pyenzyme.enzymeml.core.enzymemlbase import EnzymeMLBase
from pyenzyme.enzymeml.core.utils import (
type_checking,
deprecated_getter
)
from pyenzyme.enzymeml.core.utils import type_checking, deprecated_getter

if TYPE_CHECKING: # pragma: no cover
static_check_init_args = dataclass
Expand All @@ -31,23 +28,21 @@ class Creator(EnzymeMLBase):

given_name: str = Field(
...,
description='Given name of the author or contributor.',
description="Given name of the author or contributor.",
)

family_name: str = Field(
...,
description='Family name of the author or contributor.',
description="Family name of the author or contributor.",
)

mail: str = Field(
...,
description='Email address of the author or contributor.',
description="Email address of the author or contributor.",
)

id: Optional[str] = Field(
None,
description="Unique identifier of the protein.",
regex=r"a[\d]+"
None, description="Unique identifier of the protein.", regex=r"a[\d]+"
)

@validator("given_name", "family_name", "mail", pre=True)
Expand All @@ -62,9 +57,7 @@ def check_empty_strings(cls, value):
@validator("mail")
def check_mail_consistency(cls, mail):
if len(mail.split("@")) != 2:
raise ValueError(
f"{mail} is not a valid mail adress."
)
raise ValueError(f"{mail} is not a valid mail adress.")

return mail

Expand Down
36 changes: 22 additions & 14 deletions pyenzyme/enzymeml/core/enzymemlbase.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''
"""
File: baseclass.py
Project: core
Author: Jan Range
Expand All @@ -8,7 +8,7 @@
Modified By: Jan Range (<jan.range@simtech.uni-stuttgart.de>)
-----
Copyright (c) 2021 Institute of Biochemistry and Technical Biochemistry Stuttgart
'''
"""

import json
import logging
Expand All @@ -32,39 +32,47 @@ def json(self, indent: int = 2, **kwargs):
"log": ...,
"unit_dict": ...,
"file_dict": ...,
"protein_dict":
{
"Protein": {"__all__": {"_unit_id"}}
}
"protein_dict": {"Protein": {"__all__": {"_unit_id"}}},
},
by_alias=True,
**kwargs
)

@classmethod
def fromJSON(cls, json_string):
return cls.parse_obj(
json.loads(json_string)
)
return cls.parse_obj(json.loads(json_string))

def __setattr__(self, name, value):
"""Modified attribute setter to document changes in the EnzymeML document"""
old_value = getattr(self, name)

if isinstance(old_value, list) is False and name.startswith("_") is False and name != "id" and old_value:
if (
isinstance(old_value, list) is False
and name.startswith("_") is False
and name != "id"
and old_value
):

if type(self).__name__ != "EnzymeMLDocument":

try:
log_change(
logger, type(self).__name__, getattr(self, 'id'),
name, old_value, value
logger,
type(self).__name__,
getattr(self, "id"),
name,
old_value,
value,
)

except AttributeError:
log_change(
logger, type(self).__name__, self.get_id(),
name, old_value, value
logger,
type(self).__name__,
self.get_id(),
name,
old_value,
value,
)

super().__setattr__(name, value)

0 comments on commit ae2c946

Please sign in to comment.