fix flake8 errors in the script file (#6528)

* fix flake8 errors

* fix E126 error

* fix E123 error
This commit is contained in:
Adi Shankara 2023-08-07 21:45:44 +05:30 committed by GitHub
parent 54bcb10227
commit 98c805e267
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,61 +14,63 @@ def checkIfDocIsPresent(title, headers):
check_url = URL + "/" + title check_url = URL + "/" + title
response = requests.get(check_url, headers=headers) response = requests.get(check_url, headers=headers)
if (response.status_code == 200): if response.status_code == 200:
return True return True
else: else:
return False return False
def publishDoc(title, body, order): def publishDoc(title, body, order):
key = os.environ.get('README_API_KEY') key = os.environ.get("README_API_KEY")
payload = { payload = {
"title": title, "title": title,
"type": "basic", "type": "basic",
"body": body, "body": body,
"category": CATEGORY_ID, "category": CATEGORY_ID,
"hidden": False, "hidden": False,
"order": order "order": order,
} }
headers = { headers = {
"accept": "application/json", "accept": "application/json",
"content-type": "application/json", "content-type": "application/json",
"authorization": "Basic " + key "authorization": "Basic " + key,
} }
isDocPresent = checkIfDocIsPresent(title, headers) isDocPresent = checkIfDocIsPresent(title, headers)
if (isDocPresent): if isDocPresent:
# update doc # update doc
update_url = URL + "/" + title # title == slug update_url = URL + "/" + title # title == slug
response = requests.put(update_url, json=payload, headers=headers) response = requests.put(update_url, json=payload, headers=headers)
if (response.status_code != 200): if response.status_code != 200:
print(response.text) print(response.text)
else: else:
print("Updated ", title) print("Updated ", title)
else: else:
# create doc # create doc
response = requests.post(URL, json=payload, headers=headers) response = requests.post(URL, json=payload, headers=headers)
if (response.status_code != 201): if response.status_code != 201:
print(response.text) print(response.text)
else: else:
print("Created ", title) print("Created ", title)
def extract_rpc_commands(rst_content): def extract_rpc_commands(rst_content):
manpages_block = re.search manpages_block = re.search(
(r"\.\. block_start manpages(.*?)\.\. block_end manpages", r"\.\. block_start manpages(.*?)" r"\.\. block_end manpages",
rst_content, re.DOTALL) rst_content,
re.DOTALL,
)
if manpages_block: if manpages_block:
commands = re.findall commands = re.findall(
(r'\b([a-zA-Z0-9_-]+)\s+<([^>]+)>\n', r"\b([a-zA-Z0-9_-]+)" r"\s+<([^>]+)>\n", manpages_block.group(1)
manpages_block.group(1)) )
return commands return commands
return [] return []
def main(): def main():
# path to the rst file from where we fetch all the RPC commands # path to the rst file from where we fetch all the RPC commands
path_to_rst = 'doc/index.rst' path_to_rst = "doc/index.rst"
with open(path_to_rst, "r") as file: with open(path_to_rst, "r") as file:
rst_content = file.read() rst_content = file.read()