Skip to content

Commit aee1906

Browse files
author
gdj0nes
committed
yapf
1 parent 1f0300f commit aee1906

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

examples/scripts/upload_documentation.py

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616

1717
def upload_doc(path, section):
18-
title = path.split('/')[-1].replace(".ipynb", '').capitalize().replace('_', ' ')
18+
title = path.split('/')[-1].replace(".ipynb",
19+
'').capitalize().replace('_', ' ')
1920

2021
with open(path) as fb:
2122
nb = nbformat.reads(json.dumps(json.load(fb)), as_version=4)
@@ -27,11 +28,16 @@ def upload_doc(path, section):
2728
body, resources = exporter.from_notebook_node(nb)
2829

2930
payload = {
30-
"hidden": True,
31-
"title": f'{section["slug"]}-' + title.replace(' ', '-').replace("(", ''),
32-
"category": CATEGORY_ID,
33-
"parentDoc": section['id'],
34-
"body": body
31+
"hidden":
32+
True,
33+
"title":
34+
f'{section["slug"]}-' + title.replace(' ', '-').replace("(", ''),
35+
"category":
36+
CATEGORY_ID,
37+
"parentDoc":
38+
section['id'],
39+
"body":
40+
body
3541
}
3642

3743
headers = {
@@ -73,29 +79,29 @@ def make_sections(sections):
7379

7480

7581
def change_name(slug, title, headers):
76-
resp = requests.put(
77-
f'{README_DOC_ENDPOINT}/{slug}',
78-
json={
79-
"title": title,
80-
"category": CATEGORY_ID
81-
},
82-
headers=headers
83-
)
82+
resp = requests.put(f'{README_DOC_ENDPOINT}/{slug}',
83+
json={
84+
"title": title,
85+
"category": CATEGORY_ID
86+
},
87+
headers=headers)
8488
resp.raise_for_status()
8589

8690

8791
def erase_category_docs(cat_slug):
88-
headers = {
89-
"Accept": "application/json",
90-
"Authorization": README_AUTH
91-
}
92+
headers = {"Accept": "application/json", "Authorization": README_AUTH}
9293

93-
response = requests.request("GET", f'https://dash.readme.com/api/v1/categories/{cat_slug}/docs', headers=headers)
94+
response = requests.request(
95+
"GET",
96+
f'https://dash.readme.com/api/v1/categories/{cat_slug}/docs',
97+
headers=headers)
9498
docs = response.json()
9599
for doc in docs:
96100
for child in doc["children"]:
97-
resp = requests.delete(f'{README_DOC_ENDPOINT}/{child["slug"]}', headers=headers)
98-
resp = requests.delete(f'{README_DOC_ENDPOINT}/{doc["slug"]}', headers=headers)
101+
resp = requests.delete(f'{README_DOC_ENDPOINT}/{child["slug"]}',
102+
headers=headers)
103+
resp = requests.delete(f'{README_DOC_ENDPOINT}/{doc["slug"]}',
104+
headers=headers)
99105

100106

101107
@click.command()

0 commit comments

Comments
 (0)