Skip to content

Commit dae927b

Browse files
committed
added maintainer
1 parent f5b51b5 commit dae927b

3 files changed

Lines changed: 80 additions & 3 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/output/*
22
output.csv
33
/cache/*
4-
*.pyc
4+
*.pyc
5+
/*/*.pyc
6+
/*/*/*.pyc

build_web_pages/build_packages_long_page.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,16 @@ def main(package_file_path, functions_file_path, html_file_path):
120120
html_content += f"""
121121
<tr><td class="label">GitHub license</td><td class="left">{this_package_info.get('github_license', 'No GitHub license available.')}</td></tr>
122122
<tr><td class="label">GitHub owner</td><td class="left">{this_package_info.get('github_owner', 'No GitHub owner available.')}</td></tr>
123-
<tr><td class="label">Status</td><td class="left">{this_package_info.get('status', 'Unknown')}</td></tr>
123+
<tr><td class="label">Status</td><td class="left">{this_package_info.get('status', 'Unknown')}</td></tr>
124+
"""
125+
126+
if this_package_info.get('DESCRIPTION'):
127+
if this_package_info.get('DESCRIPTION').get('maintainer_string'):
128+
html_content += f"""<tr><td class="label">Maintainer</td><td class="left">{this_package_info.get('DESCRIPTION').get('maintainer_string')}</td></tr>"""
129+
else:
130+
html_content += '<tr><td class="label">Maintainer</td><td class="left"></td></tr>'
131+
132+
html_content += f"""
124133
<tr><td class="label">Functions</td><td class="left">{', '.join(this_package_info.get('functions', [])) if 'functions' in this_package_info else 'No functions listed.'}</td></tr>
125134
</table>
126135
"""

build_web_pages/parse_DESCRIPTION_file.py

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import re
23

34
def parse_description_file(file_path):
45
"""Parses a DESCRIPTION file and returns a dictionary of key-value pairs."""
@@ -33,19 +34,84 @@ def parse_description_file(file_path):
3334
# Save the last key-value pair
3435
if current_key:
3536
parsed_data[current_key] = "\n".join(current_value).strip()
37+
print(parsed_data)
38+
39+
# Parse the Authors@R part if it is present
40+
if 'Authors@R' in parsed_data:
41+
print("Parsing Authors@R REGEX")
42+
authors_string = parsed_data['Authors@R']
43+
authors_string = authors_string.replace('\n', "")
44+
authors_string = authors_string.replace(" ", "")
45+
authors_string = authors_string.replace("c(person(", "")
46+
authors_string = authors_string[:-2]
47+
temp = authors_string.split("),person(")
48+
49+
parsed_data["Authors"] = []
50+
51+
for this_author in temp:
52+
print(this_author)
53+
# Email
54+
email = re.findall("email=\"([\w\-\.]+@[\w\-\.]+\.+[\w\-]{2,4})\"", this_author)
55+
if len(email):
56+
this_author = re.sub("email=\"([\w\-\.]+@[\w\-\.]+\.+[\w\-]{2,4})\"","", this_author)
57+
email = email[0]
58+
print(email)
59+
else:
60+
email = ""
61+
62+
#ORCID
63+
orcid = re.findall("comment=c\(ORCID=\"([0-9]+-[0-9]+-[0-9]+-[0-9]+)\"\)", this_author)
64+
if len(orcid):
65+
this_author = re.sub("comment=c\(ORCID=\"([0-9]+-[0-9]+-[0-9]+-[0-9]+)\"\)","", this_author)
66+
orcid = orcid[0]
67+
print(orcid)
68+
else:
69+
orcid = ""
70+
71+
#Role
72+
role = re.findall("role=c?\(?([\"\w+\",?]+)\)?", this_author)
73+
this_author = re.sub("role=c?\(?([\"\w+\",?]+)\)?","", this_author)
74+
print(role)
75+
76+
# The only thing left should be the name, either with or without given/family
77+
this_author = this_author.replace(",,",",")
78+
temp = this_author.split(",")
79+
given = temp[0]
80+
given = given.replace("given=","").replace('"',"")
81+
print(given)
82+
family = temp[1]
83+
family = family.replace("family=","").replace('"',"")
84+
print(family)
85+
86+
parsed_data["Authors"].append({"given":given, "family":family, "orcid":orcid, "role":role, "email":email})
87+
88+
# Create a maintainer_string out of the relevant author
89+
if "cre" in str(role):
90+
print("MAINTAINER")
91+
parsed_data["maintainer_string"] = f"""{given} {family} ({email})"""
92+
93+
elif 'Maintainer' in parsed_data:
94+
# The old way was to have an explicit Maintainer item.
95+
parsed_data['maintainer_string'] = parsed_data['Maintainer'].replace("<","").replace(">","")
3696

3797
return parsed_data
3898

3999

40100
def main():
41-
input_file = "DESCRIPTION.txt" # Path to the DESCRIPTION file
101+
input_file = "./DESCRIPTION" # Path to the DESCRIPTION file
42102

43103
# Parse the DESCRIPTION file
44104
parsed_data = parse_description_file(input_file)
45105

106+
print(parsed_data)
107+
46108
print(parsed_data['Title'])
47109
print(parsed_data['Description'])
110+
print(parsed_data['Authors@R'])
111+
print("############")
48112

113+
print(parsed_data)
114+
49115

50116
if __name__ == "__main__":
51117
main()

0 commit comments

Comments
 (0)