1+ """A hermes harvest plugin that harvests the .toml file of the project"""
2+
13import os
24import pathlib
35import toml
@@ -30,6 +32,8 @@ class TomlHarvestPlugin(HermesHarvestPlugin):
3032 allowed_keys_for_person = ["givenName" , "lastName" , "email" , "@id" , "@type" ]
3133
3234 def __call__ (self , command : HermesHarvestCommand ):
35+ """start of the process of harvesting the .toml file"""
36+
3337 #set the working directory to the correct location
3438 path = command .args .path
3539 old_path = pathlib .Path .cwd ()
@@ -48,6 +52,8 @@ def __call__(self, command: HermesHarvestCommand):
4852
4953 @classmethod
5054 def read_from_toml (cls , file ):
55+ """Read and process the data inside the .toml file"""
56+
5157 #load the toml file as a dictionary
5258 data = toml .load (file )
5359
@@ -70,6 +76,8 @@ def read_from_toml(cls, file):
7076
7177 @classmethod
7278 def read_from_one_table (cls , table , mapping ):
79+ """Read and process the data of one table inside the .toml file"""
80+
7381 ret_data = {}
7482
7583 #iterate over each mapping
@@ -86,7 +94,7 @@ def read_from_one_table(cls, table, mapping):
8694 persons = cls .handle_person_in_unknown_format (table [field2 ])
8795
8896 #store the (corrected) format of the person(s) data
89- persons = cls .handle_differnt_possibilities_for_persons (persons )
97+ persons = cls .handle_different_possibilities_for_persons (persons )
9098 if not persons is None :
9199 ret_data [field1 ] = persons
92100
@@ -102,7 +110,9 @@ def read_from_one_table(cls, table, mapping):
102110 return ret_data
103111
104112 @classmethod
105- def handle_differnt_possibilities_for_persons (cls , persons ):
113+ def handle_different_possibilities_for_persons (cls , persons ):
114+ """Simplify the data structure of the persons"""
115+
106116 #check if it is one person in the right format or none
107117 if isinstance (persons , dict ):
108118 if len (persons .keys ()) > 0 :
@@ -136,6 +146,8 @@ def handle_differnt_possibilities_for_persons(cls, persons):
136146
137147 @classmethod
138148 def handle_person_in_unknown_format (cls , persons ):
149+ """Process the persons in the unkown format"""
150+
139151 #check wheter it is one or are more persons
140152 if isinstance (persons , list ):
141153 #in case of potentially at least two persons
@@ -170,6 +182,8 @@ def handle_person_in_unknown_format(cls, persons):
170182
171183 @classmethod
172184 def remove_forbidden_keys (cls , person ):
185+ """Remove forbidden keys from the person-data-dictionary"""
186+
173187 #the keys are extracted as the dictionary may be resized
174188 keys = list (person .keys ())
175189
0 commit comments