@@ -38,7 +38,6 @@ def save_codemeta_output(repo_data, outfile, pretty=False):
38
38
@param outfile: path where to save the codemeta file
39
39
@param pretty: option to show the JSON results in a nice format
40
40
"""
41
-
42
41
def format_date (date_string ):
43
42
date_object = date_parser .parse (date_string )
44
43
return date_object .strftime ("%Y-%m-%d" )
@@ -67,8 +66,12 @@ def format_date(date_string):
67
66
author_name = None
68
67
if constants .CAT_OWNER in repo_data :
69
68
author_name = repo_data [constants .CAT_OWNER ][0 ][constants .PROP_RESULT ][constants .PROP_VALUE ]
69
+
70
+ # add a check for the existence of the 'description' property, similar way to most properties in the method.
71
+ descriptions = None
72
+ if constants .CAT_DESCRIPTION in repo_data :
73
+ descriptions = repo_data [constants .CAT_DESCRIPTION ]
70
74
71
- descriptions = repo_data [constants .CAT_DESCRIPTION ]
72
75
descriptions_text = []
73
76
if descriptions is not None :
74
77
descriptions .sort (key = lambda x : (x [constants .PROP_CONFIDENCE ] + (1 if x [constants .PROP_TECHNIQUE ] == constants .GITHUB_API else 0 )),
@@ -85,12 +88,30 @@ def format_date(date_string):
85
88
for l in repo_data [constants .CAT_LICENSE ]:
86
89
if constants .PROP_NAME in l [constants .PROP_RESULT ].keys ():
87
90
l_result ["name" ] = l [constants .PROP_RESULT ][constants .PROP_NAME ]
91
+ # else:
92
+ # print(f"PROP_NAME key not found in: {l[constants.PROP_RESULT].keys()}")
93
+
94
+ # change this structure because is posible l_result["url"] doesnt exist
95
+ # if "url" not in l_result.keys() and constants.PROP_URL in l[constants.PROP_RESULT].keys():
96
+ # l_result["url"] = l[constants.PROP_RESULT][constants.PROP_URL]
97
+ # # We get the first license we find from the repo
98
+ # elif l[constants.PROP_TECHNIQUE] == constants.TECHNIQUE_FILE_EXPLORATION and constants.PROP_SOURCE in l.keys() and "api.github.com" in l_result["url"]:
99
+ # l_result["url"] = l[constants.PROP_SOURCE]
100
+
101
+ # checking if PROP_URL is in the keys PROP_RESULT and key "url" is not in results
88
102
if "url" not in l_result .keys () and constants .PROP_URL in l [constants .PROP_RESULT ].keys ():
89
- l_result ["url" ] = l [constants .PROP_RESULT ][constants .PROP_URL ]
90
- # We get the first license we find from the repo
91
- elif l [constants .PROP_TECHNIQUE ] == constants .TECHNIQUE_FILE_EXPLORATION \
92
- and constants .PROP_SOURCE in l .keys () and "api.github.com" in l_result ["url" ]:
93
- l_result ["url" ] = l [constants .PROP_SOURCE ]
103
+ l_result ["url" ] = l [constants .PROP_RESULT ][constants .PROP_URL ]
104
+ # else:
105
+ # print(f"PROP_URL key not found in: {l[constants.PROP_RESULT].keys()}")
106
+
107
+ # Thist block run if url is not found in the previous
108
+ if l [constants .PROP_TECHNIQUE ] == constants .TECHNIQUE_FILE_EXPLORATION and constants .PROP_SOURCE in l .keys ():
109
+ if "url" in l_result and "api.github.com" in l_result ["url" ]:
110
+ l_result ["url" ] = l [constants .PROP_SOURCE ]
111
+ else :
112
+ if "url" not in l_result .keys () and constants .PROP_URL in l [constants .PROP_RESULT ].keys ():
113
+ l_result ["url" ] = l [constants .PROP_RESULT ][constants .PROP_URL ]
114
+
94
115
codemeta_output ["license" ] = l_result
95
116
if code_repository is not None :
96
117
codemeta_output ["codeRepository" ] = code_repository
@@ -118,6 +139,7 @@ def format_date(date_string):
118
139
install_links .append (inst [constants .PROP_SOURCE ])
119
140
elif inst [constants .PROP_TECHNIQUE ] == constants .TECHNIQUE_FILE_EXPLORATION :
120
141
install_links .append (inst [constants .PROP_RESULT ][constants .PROP_VALUE ])
142
+
121
143
if constants .CAT_DOCUMENTATION in repo_data :
122
144
for inst in repo_data [constants .CAT_DOCUMENTATION ]:
123
145
if inst [constants .PROP_TECHNIQUE ] == constants .TECHNIQUE_HEADER_ANALYSIS and constants .PROP_SOURCE in inst .keys ():
0 commit comments