Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
TOPetit committed Jun 21, 2024
1 parent 9ae8c67 commit 404f246
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 40 deletions.
9 changes: 1 addition & 8 deletions src/pygedcom/elements/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,7 @@ def __str__(self) -> str:
:return: The string representation of the Gedcom element.
:rtype: str
"""
return (
"Level: "
+ str(self.__level)
+ ", Tag: "
+ str(self.__tag)
+ ", Value: "
+ str(self.__value)
)
return "Level: " + str(self.__level) + ", Tag: " + str(self.__tag) + ", Value: " + str(self.__value)

def __repr__(self) -> str:
"""Get the string representation of the Gedcom element.
Expand Down
8 changes: 2 additions & 6 deletions src/pygedcom/elements/rootElements/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ def __find_are_married(self) -> str:
:rtype: bool
"""
return self.find_sub_element("MARR") != [] or (
self.find_sub_element("_UST")[0].get_value() == "MARRIED"
if self.find_sub_element("_UST") != []
else False
self.find_sub_element("_UST")[0].get_value() == "MARRIED" if self.find_sub_element("_UST") != [] else False
)

def __find_media(self) -> list:
Expand Down Expand Up @@ -207,9 +205,7 @@ def remove_child(self, child_xref: str):
for child in self.find_sub_element("CHIL"):
if child.get_value() == child_xref:
self.remove_sub_element(child)
self.__export_children.remove(
child_xref
) if child_xref in self.__export_children else None
self.__export_children.remove(child_xref) if child_xref in self.__export_children else None

def remove_parent(self, parent_xref: str):
"""Remove a parent from the family. If parent does not exist, do nothing.
Expand Down
6 changes: 1 addition & 5 deletions src/pygedcom/elements/rootElements/individual.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ def __find_sex(self):
:return: The sex of the individual.
:rtype: str
"""
return (
self.find_sub_element("SEX")[0].get_value()
if self.find_sub_element("SEX") != []
else ""
)
return self.find_sub_element("SEX")[0].get_value() if self.find_sub_element("SEX") != [] else ""

def __find_media(self) -> list:
"""Find media of the individual.
Expand Down
4 changes: 1 addition & 3 deletions src/pygedcom/elements/rootElements/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ def __find_note(self):
content = note[0].find_sub_element("CONT")
if content != []:
# TODO: notes are still ugly.
return re.sub(
rtf_pattern, "", " ".join([cont.get_value() for cont in content])
)
return re.sub(rtf_pattern, "", " ".join([cont.get_value() for cont in content]))
return ""

def get_quality(self) -> str:
Expand Down
6 changes: 1 addition & 5 deletions src/pygedcom/elements/subElements/date.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,7 @@ def __str__(self):
if self.__export_year:
results.append(self.__export_year)

if (
hasattr(self, "__export_day1")
or hasattr(self, "__export_month1")
or hasattr(self, "__export_year1")
):
if hasattr(self, "__export_day1") or hasattr(self, "__export_month1") or hasattr(self, "__export_year1"):
results.append("AND")
if hasattr(self, "__export_day1"):
results.append(self.__export_day1)
Expand Down
17 changes: 4 additions & 13 deletions src/pygedcom/gedcom_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ def verify(self) -> dict:
if parsed_line["level"] > current_level + 1:
return {
"status": "error",
"message": "Invalid level on line "
+ str(current_line)
+ ": "
+ line,
"message": "Invalid level on line " + str(current_line) + ": " + line,
}
current_level = parsed_line["level"]
return {"status": "ok", "message": ""}
Expand Down Expand Up @@ -435,9 +432,7 @@ def __add_root_element(self, collection: list, element: GedcomRootElement):
except KeyError:
collection.append(element)
else:
raise KeyError(
"Element with xref " + element.get_xref() + " already exists."
)
raise KeyError("Element with xref " + element.get_xref() + " already exists.")

def add_individual(self, individual: GedcomIndividual):
"""Add an individual to the collection.
Expand All @@ -452,9 +447,7 @@ def add_individual(self, individual: GedcomIndividual):
try:
self.__add_root_element(self.individuals, individual)
except KeyError:
raise KeyError(
"Individual with xref " + individual.get_xref() + " already exists."
)
raise KeyError("Individual with xref " + individual.get_xref() + " already exists.")

def add_family(self, family: GedcomFamily):
"""Add a family to the collection.
Expand Down Expand Up @@ -529,9 +522,7 @@ def add_repository(self, repository: GedcomRepository):
try:
self.__add_root_element(self.repositories, repository)
except KeyError:
raise KeyError(
"Repository with xref " + repository.get_xref() + " already exists."
)
raise KeyError("Repository with xref " + repository.get_xref() + " already exists.")
self.repositories.append(repository)

def __remove_root_element(self, collection: list, xref: str):
Expand Down

0 comments on commit 404f246

Please sign in to comment.