Format all the python files in the project

This commit is contained in:
Fabrice Reix 2022-02-05 11:13:49 +01:00 committed by Fabrice Reix
parent 5e9a94a430
commit 745fb1d193
3 changed files with 33 additions and 32 deletions

View File

@ -58,7 +58,7 @@ jobs:
- name: Check Python Scripts
run: |
pip3 install black
black --check integration
black --check .
benchsuite:

View File

@ -3,10 +3,10 @@ from flask import request
app = Flask(__name__)
@app.route('/hello')
@app.route("/hello")
def hello():
return 'Hello World!'
app.run(host='0.0.0.0', port=8000)
return "Hello World!"
app.run(host="0.0.0.0", port=8000)

View File

@ -5,12 +5,15 @@ from datetime import date
def header(version, date):
return '.TH hurl 1 "%s" "hurl %s" " Hurl Manual"' % (date.strftime("%d %b %Y"), version)
return '.TH hurl 1 "%s" "hurl %s" " Hurl Manual"' % (
date.strftime("%d %b %Y"),
version,
)
def version():
p = re.compile('version = "(.*)"')
for line in open('packages/hurl/Cargo.toml', 'r').readlines():
for line in open("packages/hurl/Cargo.toml", "r").readlines():
m = p.match(line)
if m:
return m.group(1)
@ -18,45 +21,43 @@ def version():
def process_code_block(s):
output = ''
output = ""
indent = False
for line in s.split('\n'):
if indent and line.startswith('```'):
for line in s.split("\n"):
if indent and line.startswith("```"):
indent = False
elif not indent and line.startswith('```'):
elif not indent and line.startswith("```"):
indent = True
else:
if line != '':
if line != "":
if indent:
output += ' '
output += " "
output += line
output += '\n'
output += "\n"
return output
#p.sub('\\\\f[C]\\1\\\\f[R]', s)
# p.sub('\\\\f[C]\\1\\\\f[R]', s)
def convert_md(s):
p = re.compile('^###\s+(.*)')
s = p.sub('.IP "\\1"', s)
p = re.compile("^###\s+(.*)")
s = p.sub('.IP "\\1"', s)
p = re.compile('^##')
s = p.sub('.SH', s)
p = re.compile("^##")
s = p.sub(".SH", s)
p = re.compile("\*\*(.*)\*\*\s+")
s = p.sub(".B \\1\n", s)
p = re.compile('\*\*(.*)\*\*\s+')
s = p.sub('.B \\1\n', s)
# Remove link Text
p = re.compile("\[(.*)\]\(.*\)")
s = p.sub("\\\\fI\\1\\\\fP", s)
# Remove link Text
p = re.compile('\[(.*)\]\(.*\)')
s = p.sub('\\\\fI\\1\\\\fP', s)
# Remove local anchor
p = re.compile('{#.*}')
s = p.sub('', s)
return s
# Remove local anchor
p = re.compile("{#.*}")
s = p.sub("", s)
return s
def main():
@ -64,11 +65,11 @@ def main():
data = open(input_file).readlines()
print(header(version(), date.today()))
s = ''.join([convert_md(line) for line in data])
s = "".join([convert_md(line) for line in data])
s = process_code_block(s)
print(s)
if __name__ == '__main__':
if __name__ == "__main__":
main()