Skip to content

Commit

Permalink
fixing code issue
Browse files Browse the repository at this point in the history
  • Loading branch information
wjo1212 committed Nov 22, 2017
1 parent acce67a commit bf1ebca
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 45 deletions.
42 changes: 2 additions & 40 deletions aliyunlogcli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from docopt import docopt
from config import load_config, LOG_CONFIG_SECTION
from six import StringIO
from parser import parse_method_types_optdoc_from_class


def configure_confidential(secure_id, secure_key, endpoint, client_name=LOG_CONFIG_SECTION):
Expand Down Expand Up @@ -46,6 +47,7 @@ def _get_str(obj, enclosed=True):
return repr(obj)
return str(obj)


def _sort_str_dict(obj, enclosed=False):
buf = StringIO()
if isinstance(obj, dict):
Expand Down Expand Up @@ -114,43 +116,3 @@ def main():

if __name__ == '__main__':
main()


# def test_convert():
# d1 = {1:'\n'}
# print(_sort_str_dict(d1))
# assert r"{1: '\n'}" == _sort_str_dict(d1)
#
# d1 = {1:'\t'}
# print(_sort_str_dict(d1))
# assert r"{1: '\t'}" == _sort_str_dict(d1)
#
# d1 = "123"
# print(_sort_str_dict(d1))
# assert """123""" == _sort_str_dict(d1)
#
# d1 = ""
# print(_sort_str_dict(d1))
# assert """""" == _sort_str_dict(d1)
#
# d1 = 123
# print(_sort_str_dict(d1))
# assert """123""" == _sort_str_dict(d1)
#
# d1 = [1,'2', 3]
# print(_sort_str_dict(d1))
# assert """[1, '2', 3]""" == _sort_str_dict(d1)
#
# d1 = {1:1, '3':3, 2:'2'}
# print(_sort_str_dict(d1))
# assert """{1: 1, 2: '2', '3': 3}""" == _sort_str_dict(d1)
#
# d1 = [1,'2', {1:1, '3':3, 2:'2'}]
# print(_sort_str_dict(d1))
# assert """[1, '2', {1: 1, 2: '2', '3': 3}]""" == _sort_str_dict(d1)
#
# d1 = {1:{1:1, '3':3, 2:'2'}, '3':{1:1, '3':{1:1, '3':3, 2:'2'}, 2:'2'}, 2:'2'}
# print(_sort_str_dict(d1))
# assert """{1: {1: 1, 2: '2', '3': 3}, 2: '2', '3': {1: 1, 2: '2', '3': {1: 1, 2: '2', '3': 3}}}""" == _sort_str_dict(d1)
#
# exit(10)
2 changes: 1 addition & 1 deletion aliyunlogcli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def _parse_method_params_from_doc(doc):
params = dict((k, types_maps.get(t.lower().strip(), None)) for k, t, d in m)

unsupported_types = [(k, t, d) for k, t, d in m if params.get(k, None) is None]
if unsupported_types :
if unsupported_types:
for k, t, d in unsupported_types:
handler = _find_multiple_cls(t)
if handler is not None:
Expand Down
6 changes: 3 additions & 3 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import os
import sys
import six
import re
import pypandoc

sys.path.insert(0, os.path.abspath('../..'))


Expand Down Expand Up @@ -66,8 +69,6 @@
# built documents.
#
# The short X.Y version.
from aliyun.log import __version__
import re
version = '0.6'
with open(os.path.abspath('../../aliyunlogcli/__init__.py'), 'r') as fd:
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
Expand Down Expand Up @@ -184,7 +185,6 @@
'Miscellaneous'),
]

import pypandoc
if six.PY3:
open("README.rst", "w").write(pypandoc.convert('../../README.md', 'rst'))
open("README_CN.rst", "w").write(pypandoc.convert('../../README_CN.md', 'rst'))
Expand Down
3 changes: 2 additions & 1 deletion tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def run_test(cmd_file):

output, return_code = run_cmd(cmd)
for check_item in check_items:
assert check_item in output, ValueError('check item "{0}" is not in output "{1}"'.format(check_item, output))
assert check_item in output, ValueError('check item "{0}" is not in output "{1}"'
.format(check_item, output))

if not check_items:
# no check, need to ensure return code is 0
Expand Down

0 comments on commit bf1ebca

Please sign in to comment.