Skip to content

Commit

Permalink
Reformat code using black
Browse files Browse the repository at this point in the history
  • Loading branch information
Jing Wang committed May 2, 2020
1 parent 8ded3a2 commit 5667f80
Show file tree
Hide file tree
Showing 6 changed files with 488 additions and 371 deletions.
14 changes: 7 additions & 7 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

import datetime

project = 'PyHDFS'
author = 'Jing Wang'
copyright = '{}, {}'.format(datetime.datetime.now().year, author)
project = "PyHDFS"
author = "Jing Wang"
copyright = "{}, {}".format(datetime.datetime.now().year, author)

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
]

master_doc = 'index'
master_doc = "index"

exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
28 changes: 14 additions & 14 deletions generate_class_from_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@
import simplejson as json

TYPE_MAPPING = {
'integer': 'int',
'string': 'str',
"integer": "int",
"string": "str",
}


def to_py_type(v: Dict[str, Any]) -> str:
if 'type' in v:
t = TYPE_MAPPING.get(v['type'], v['type'])
if "type" in v:
t = TYPE_MAPPING.get(v["type"], v["type"])
return t
if 'enum' in v:
return 'str'
if "enum" in v:
return "str"
raise AssertionError(v)


def main() -> None:
js = json.loads(sys.stdin.read())
name = js['name']
print('class {}(_BoilerplateClass):'.format(js['name']))
name = js["name"]
print("class {}(_BoilerplateClass):".format(js["name"]))
print(' """')
for k, v in js['properties'][name]['properties'].items():
print(' :param {}: {}'.format(k, v.get('description', '')))
print(' :type {}: {}'.format(k, to_py_type(v)))
for k, v in js["properties"][name]["properties"].items():
print(" :param {}: {}".format(k, v.get("description", "")))
print(" :type {}: {}".format(k, to_py_type(v)))
print(' """')
print()
for k, v in js['properties'][name]['properties'].items():
print(' {}: {}'.format(k, to_py_type(v)))
for k, v in js["properties"][name]["properties"].items():
print(" {}: {}".format(k, to_py_type(v)))


if __name__ == '__main__':
if __name__ == "__main__":
main()
Loading

0 comments on commit 5667f80

Please sign in to comment.