diff --git a/ged2dot.py b/ged2dot.py
index 798c3a2..06b4e17 100755
--- a/ged2dot.py
+++ b/ged2dot.py
@@ -149,6 +149,7 @@ def __init__(self) -> None:
self.__note = ""
self.__birth = ""
self.__death = ""
+ self.__occupation = ""
def set_note(self, note: str) -> None:
"""Sets a note."""
@@ -174,6 +175,14 @@ def get_death(self) -> str:
"""Gets the death date."""
return self.__death
+ def set_occupation(self, occupation: str) -> None:
+ """Sets the occupation."""
+ self.__occupation = occupation
+
+ def get_occupation(self) -> str:
+ """Gets the occupation."""
+ return self.__occupation
+
class Individual(Node):
"""An individual is always a child in a family, and is an adult in 0..* families."""
@@ -261,8 +270,8 @@ def get_famc_id(self) -> str:
"""Gets the child family ID."""
return self.__dict["famc_id"]
- def get_label(self, image_dir: str, name_order: str, birth_format: str, basepath: str) -> str:
- """Gets the graphviz label."""
+ def __get_image_path(self, image_dir: str, basepath: str) -> str:
+ """Gets the path to the image."""
image_path = os.path.join(image_dir, self.get_forename() + " " + self.get_surname())
for suffix in [".jpg", ".jpeg", ".png", ".JPG", ".PNG"]:
image_path += " " + self.get_config().get_birth() + suffix
@@ -279,6 +288,11 @@ def get_label(self, image_dir: str, name_order: str, birth_format: str, basepath
image_path = get_abspath(f"placeholder-{sex}.svg")
if basepath:
image_path = os.path.relpath(image_path, basepath)
+ return image_path
+
+ def get_label(self, image_dir: str, name_order: str, birth_format: str, basepath: str) -> str:
+ """Gets the graphviz label."""
+ image_path = self.__get_image_path(image_dir, basepath)
label = "
"
label += " "
# State the font face explicitly to help correct centering.
@@ -297,6 +311,9 @@ def get_label(self, image_dir: str, name_order: str, birth_format: str, basepath
label += "† " + self.get_config().get_death()
else:
label += self.get_config().get_birth() + "-" + self.get_config().get_death()
+ occupation = self.get_config().get_occupation()
+ if occupation:
+ label += " " + occupation
label += " |
"
return label
@@ -473,6 +490,8 @@ def __handle_individual_config(self, line: str) -> None:
self.in_deat = True
elif line_lead_token == "NOTE" and self.individual:
self.individual.get_config().set_note(line[5:])
+ elif line_lead_token == "OCCU" and self.individual:
+ self.individual.get_config().set_occupation(line[5:])
def load(self, config: Dict[str, str]) -> List[Node]:
"""Tokenizes and resolves a gedcom file into a graph."""
diff --git a/guide/src/news.md b/guide/src/news.md
index 1edd8cd..33add65 100644
--- a/guide/src/news.md
+++ b/guide/src/news.md
@@ -1,5 +1,9 @@
# Version descriptions
+## master
+
+- If provided, occupation is listed after the birth and dead year
+
## 25.8
- For people whose names have a suffix (like Richard III, or Sam Jr) extract that and keep it as part of the name (Gregory Dudek)
diff --git a/guide/src/usage.md b/guide/src/usage.md
index 86deba9..3840220 100644
--- a/guide/src/usage.md
+++ b/guide/src/usage.md
@@ -57,15 +57,6 @@ C:/Users/John/Application Data/LibreOffice/4/user/Scripts/python/log.txt
- For Linux, start LibreOffice from a terminal, the log is printed to the
standard error.
-- For Mac, start LibreOffice from Terminal:
-
-```
-cd /Applications/LibreOffice.app/Contents/program
-./soffice --nologo /path/to/test.ged
-```
-
-then the log is printed to the standard error as well.
-
## Icons
Icons are from
diff --git a/tests/occupation.ged b/tests/occupation.ged
new file mode 100644
index 0000000..ed7ca8a
--- /dev/null
+++ b/tests/occupation.ged
@@ -0,0 +1,14 @@
+0 HEAD
+0 @P1@ INDI
+1 NAME Alice /A/
+1 SEX F
+1 FAMS @F1@
+1 OCCU myoccupation
+0 @P2@ INDI
+1 NAME Bob /B/
+1 SEX M
+1 FAMS @F1@
+0 @F1@ FAM
+1 HUSB @P2@
+1 WIFE @P1@
+0 TRLR
diff --git a/tests/test_ged2dot.py b/tests/test_ged2dot.py
index cd5e21e..c53b45b 100644
--- a/tests/test_ged2dot.py
+++ b/tests/test_ged2dot.py
@@ -62,6 +62,19 @@ def test_name_suffix(self) -> None:
label = individual.get_label(image_dir="", name_order="little", birth_format="{}-", basepath="")
self.assertIn("Alice
A Suffix", label)
+ def test_occupation(self) -> None:
+ """Tests the case when the occupation is provided."""
+ config = {
+ "input": "tests/occupation.ged",
+ }
+ importer = ged2dot.GedcomImport()
+ graph = importer.tokenize(config)
+ individual = ged2dot.graph_find(graph, "P1")
+ assert individual
+ assert isinstance(individual, ged2dot.Individual)
+ label = individual.get_label(image_dir="", name_order="little", birth_format="{}-", basepath="")
+ self.assertIn("Alice
A
-
myoccupation", label)
+
def test_str(self) -> None:
"""Tests __str()__."""
config = {