Skip to content

Commit 745bd51

Browse files
committed
Black formatting
1 parent 39ede38 commit 745bd51

File tree

5 files changed

+19
-22
lines changed

5 files changed

+19
-22
lines changed

caltechdata_api/caltechdata_edit.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def caltechdata_accept(ids, token=None, production=False):
3333
}
3434

3535
for idv in ids:
36-
3736
result = requests.get(
3837
url + "/api/records/" + idv + "/draft/review", headers=headers
3938
)

caltechdata_api/caltechdata_write.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def add_file_links(
6969
):
7070
# Currently configured for S3 links, assuming all are at same endpoint
7171
link_string = ""
72-
endpoint = "https://"+file_links[0].split("/")[2]
72+
endpoint = "https://" + file_links[0].split("/")[2]
7373
s3 = s3fs.S3FileSystem(anon=True, client_kwargs={"endpoint_url": endpoint})
7474
index = 0
7575
for link in file_links:
@@ -102,7 +102,6 @@ def add_file_links(
102102

103103

104104
def send_to_community(review_link, data, headers, publish, community, message=None):
105-
106105
if not message:
107106
message = "This record is submitted automatically with the CaltechDATA API"
108107

caltechdata_api/customize_schema.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def get_vocabularies():
5757

5858

5959
def customize_schema(json_record, schema="43"):
60-
6160
if schema == "43":
6261
return customize_schema_rdm(json_record)
6362
else:
@@ -134,7 +133,6 @@ def rdm_creators_contributors(person_list, peopleroles):
134133

135134

136135
def customize_schema_rdm(json_record):
137-
138136
# Get vocabularies used in InvenioRDM
139137
vocabularies = get_vocabularies()
140138

caltechdata_api/md_to_json.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,46 @@
11
import re
22
import json
33

4+
45
class ReadmeFormatException(Exception):
56
"""Custom exception for errors in the README format."""
67

8+
79
def camel_case(s):
810
"""Converts a string to camelCase."""
911
s = re.sub(r"(\s|_|-)+", " ", s).title().replace(" ", "")
1012
return s[0].lower() + s[1:] if s else ""
1113

14+
1215
def expand_special_keys(key, value):
1316
"""Expand special keys into their structured format (affiliation, nameIdentifiers)."""
1417
if key == "affiliation":
15-
return [
16-
{
17-
"affiliationIdentifier": value,
18-
"affiliationIdentifierScheme": "ROR"
19-
}
20-
]
18+
return [{"affiliationIdentifier": value, "affiliationIdentifierScheme": "ROR"}]
2119
elif key == "nameIdentifiers":
2220
return [
2321
{
2422
"nameIdentifier": value,
2523
"nameIdentifierScheme": "ORCID",
26-
"schemeUri": f"https://orcid.org/{value}"
24+
"schemeUri": f"https://orcid.org/{value}",
2725
}
2826
]
2927
return value
3028

29+
3130
def parse_readme_to_json(readme_path):
3231
try:
33-
with open(readme_path, 'r') as file:
34-
lines = file.read().split('\n')
32+
with open(readme_path, "r") as file:
33+
lines = file.read().split("\n")
3534
except IOError as e:
3635
raise ReadmeFormatException(f"Failed to open or read the file: {e}")
3736

3837
json_data = {}
3938
current_section = None
4039
current_object = {}
4140

42-
section_pattern = re.compile(r'^##\s+(.*)$')
43-
key_value_pattern = re.compile(r'^-\s+(.*?):\s+(.*)$')
44-
link_pattern = re.compile(r'\[.*?\]\((.*?)\)')
41+
section_pattern = re.compile(r"^##\s+(.*)$")
42+
key_value_pattern = re.compile(r"^-\s+(.*?):\s+(.*)$")
43+
link_pattern = re.compile(r"\[.*?\]\((.*?)\)")
4544

4645
for line_number, line in enumerate(lines, 1):
4746
if not line.strip():
@@ -93,7 +92,9 @@ def parse_readme_to_json(readme_path):
9392
current_object[key] = value
9493

9594
elif line.strip() and not section_match:
96-
raise ReadmeFormatException(f"Incorrect format detected at line {line_number}: {line}")
95+
raise ReadmeFormatException(
96+
f"Incorrect format detected at line {line_number}: {line}"
97+
)
9798

9899
if current_section and current_object:
99100
if current_section == "types":
@@ -109,11 +110,12 @@ def parse_readme_to_json(readme_path):
109110

110111
return json_data
111112

112-
readme_path = '/Users/elizabethwon/downloads/exampleREADME.md'
113+
114+
readme_path = "/Users/elizabethwon/downloads/exampleREADME.md"
113115
try:
114116
json_data = parse_readme_to_json(readme_path)
115-
output_json_path = 'output1.json'
116-
with open(output_json_path, 'w') as json_file:
117+
output_json_path = "output1.json"
118+
with open(output_json_path, "w") as json_file:
117119
json.dump(json_data, json_file, indent=4)
118120
print(f"Converted JSON saved to {output_json_path}")
119121
except ReadmeFormatException as e:

caltechdata_api/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ def humanbytes(num: Union[int, float], metric: bool = True, precision: int = 1)
5454

5555

5656
if __name__ == "__main__":
57-
5857
print(humanbytes(2251799813685247)) # 2 pebibytes
5958
print(humanbytes(2000000000000000, True)) # 2 petabytes
6059
print(humanbytes(1099511627776)) # 1 tebibyte

0 commit comments

Comments
 (0)