Skip to content

Commit a78e3a9

Browse files
author
jvaleroach
committedJul 17, 2024·
black formatting
1 parent a8ce6ad commit a78e3a9

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed
 

‎pykobo/form.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -442,29 +442,29 @@ def _rename_columns_labels_duplicates(self, structure: list) -> None:
442442
q.label = f"{q.label} ({duplicates_count[q.label]})"
443443

444444
def _obtain_url(self, row, column):
445-
"""Aux Function to obtain url of an attached file.
446-
Replaces the ' ' (spaces) by '_' from the attached files"""
445+
"""Aux Function to obtain url of an attached file.
446+
Replaces the ' ' (spaces) by '_' from the attached files"""
447447

448-
df = pd.json_normalize(row["_attachments"])
449-
if "filename" in df.columns:
450-
df["filename_ok"] = df["filename"].apply(
451-
lambda x: x.split("/")[-1].replace(" ", "_")
452-
)
448+
df = pd.json_normalize(row["_attachments"])
449+
if "filename" in df.columns:
450+
df["filename_ok"] = df["filename"].apply(
451+
lambda x: x.split("/")[-1].replace(" ", "_")
452+
)
453453

454-
if pd.isna(row[column]):
455-
name = None
456-
else:
457-
name = row[column].replace(" ", "_")
454+
if pd.isna(row[column]):
455+
name = None
456+
else:
457+
name = row[column].replace(" ", "_")
458458

459-
if name is not None:
460-
matching_rows = df.loc[df["filename_ok"] == name]
461-
if not matching_rows.empty:
462-
url = matching_rows["download_url"].iloc[0]
463-
else:
464-
url = np.nan
459+
if name is not None:
460+
matching_rows = df.loc[df["filename_ok"] == name]
461+
if not matching_rows.empty:
462+
url = matching_rows["download_url"].iloc[0]
465463
else:
466464
url = np.nan
467-
return url
465+
else:
466+
url = np.nan
467+
return url
468468

469469
def _split_gps_coords(self) -> None:
470470
"""Split the columns of type 'geopoint' into 4 new columns

‎pykobo/manager.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ def fetch_users_with_access(self, uid: str):
206206
"""
207207
Fetch the list of users who have access to a specific form, extracting usernames from URLs.
208208
"""
209-
url_permissions = f"{self.url}/api/v{self.api_version}/assets/{uid}/permission-assignments/"
209+
url_permissions = (
210+
f"{self.url}/api/v{self.api_version}/assets/{uid}/permission-assignments/"
211+
)
210212
res = requests.get(url=url_permissions, headers=self.headers)
211213

212214
if res.status_code != 200:
@@ -216,9 +218,11 @@ def fetch_users_with_access(self, uid: str):
216218
users_with_access = set()
217219

218220
for permission in permissions:
219-
user_url = permission.get('user')
221+
user_url = permission.get("user")
220222
if user_url:
221-
username = user_url.rstrip('/').split('/')[-1] # Split to get the username from the url
223+
username = user_url.rstrip("/").split("/")[
224+
-1
225+
] # Split to get the username from the url
222226
users_with_access.add(username)
223227

224-
return list(users_with_access)
228+
return list(users_with_access)

0 commit comments

Comments
 (0)
Please sign in to comment.