Skip to content

Commit fadeedb

Browse files
authored
Merge pull request #50 from OSLL/developers-google-com-badges-updates
fix for skipping ids with errors
2 parents 0158200 + ec70e96 commit fadeedb

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

google_export/main.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def get_id_by_name(user_id: str, curl_args):
6464
user_id = json.loads(
6565
output
6666
)
67+
print(user_id)
6768
user_id = user_id[1][31]
6869
return user_id
6970

@@ -115,7 +116,14 @@ def get_awards_by_id(user_id: str | int, key: str, curl_args, timeout, rec_limit
115116

116117

117118
def get_awards(ids: [str | int], key: str, curl_args, timeout, rec_limit=10) -> dict[set]:
118-
awards = {user_id: get_awards_by_id(user_id, key, curl_args, timeout, rec_limit) for user_id in ids}
119+
awards = {}
120+
for user_id in ids:
121+
try:
122+
user_awards = get_awards_by_id(user_id, key, curl_args, timeout, rec_limit)
123+
awards[user_id] = user_awards
124+
except Exception as e:
125+
print(f'Error during processing id = {user_id}, it will be skipped')
126+
print(e)
119127
return awards
120128

121129

@@ -124,7 +132,7 @@ def write_to_local_csv(awards: dict[set], curl_args, fname: str = 'result.csv',
124132
default_columns = [
125133
'id',
126134
'name',
127-
'link',
135+
'url_id',
128136
'public_profile',
129137
'profile created',
130138
]
@@ -142,7 +150,7 @@ def write_to_local_csv(awards: dict[set], curl_args, fname: str = 'result.csv',
142150
row = [
143151
get_id_by_name(user_awards[0], curl_args),
144152
get_name(user_awards[0], curl_args, rec_limit),
145-
get_link(user_awards[0], curl_args, rec_limit),
153+
user_awards[0],
146154
1 if len(user_awards[1]) else 0,
147155
user_awards[1].get('Joined the Google Developer Program'),
148156
]

0 commit comments

Comments
 (0)