Skip to content

Commit d13a93f

Browse files
author
zhanglei3
committed
Merge branch 'develop' into 'master'
修复因 python3.7 中要求必须在 argparse 模块的 add_subparsers 增加 required 参数的问题 See merge request bge/bge-python-sdk!8
2 parents 35047fb + 369d69e commit d13a93f

53 files changed

Lines changed: 62 additions & 9750 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ test_env.sh
1414
.eggs/
1515
.pytest_cache/
1616
.python-version
17+
htmlcov/

bgesdk/__main__.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,19 @@ def init_parser():
2727
help='显示当前 BGE 开放平台 Python SDK 版本号。',
2828
version='version {}'.format(version.__version__)
2929
)
30-
subparsers = parser.add_subparsers(
31-
dest='command',
32-
help='SDK 命令行工具可选子命令。'
33-
)
30+
try:
31+
subparsers = parser.add_subparsers(
32+
dest='command',
33+
help='SDK 命令行工具可选子命令。'
34+
)
35+
except TypeError:
36+
# required: Whether or not a subcommand must be provided,
37+
# by default False (added in 3.7)
38+
subparsers = parser.add_subparsers(
39+
dest='command',
40+
help='SDK 命令行工具可选子命令。',
41+
required=False
42+
)
3443
command_names = get_commands()
3544
sort_items = []
3645
for sub_command_name in command_names:

bgesdk/management/commands/api/__init__.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,19 @@ class Command(BaseCommand):
2121
help='BGE 开放平台接口测试工具,可调用部分平台接口。'
2222

2323
def add_arguments(self, parser):
24-
api_subparsers = parser.add_subparsers(
25-
dest='subcommand',
26-
help='可选子命令。'
27-
)
24+
try:
25+
api_subparsers = parser.add_subparsers(
26+
dest='subcommand',
27+
help='可选子命令。'
28+
)
29+
except TypeError:
30+
# required: Whether or not a subcommand must be provided,
31+
# by default False (added in 3.7)
32+
api_subparsers = parser.add_subparsers(
33+
dest='subcommand',
34+
help='可选子命令。',
35+
required=False
36+
)
2837
commands_dir = posixpath.join(__path__[0], 'commands')
2938
command_names = find_commands(commands_dir)
3039
sort_items = []

bgesdk/management/commands/config.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,17 @@ class Command(BaseCommand):
2929
project_help = '全局配置项目名。'
3030

3131
def add_arguments(self, parser):
32-
sub_ps = parser.add_subparsers(
33-
help='新增、删除、显示 OAuth2 配置',
34-
required=False
35-
)
32+
try:
33+
sub_ps = parser.add_subparsers(
34+
help='新增、删除、显示 OAuth2 配置'
35+
)
36+
except TypeError:
37+
# required: Whether or not a subcommand must be provided,
38+
# by default False (added in 3.7)
39+
sub_ps = parser.add_subparsers(
40+
help='新增、删除、显示 OAuth2 配置',
41+
required=False
42+
)
3643
add_p = sub_ps.add_parser(
3744
'add',
3845
formatter_class=argparse.ArgumentDefaultsHelpFormatter,

bgesdk/management/commands/model.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,19 @@ class Command(BaseCommand):
173173

174174
def add_arguments(self, parser):
175175
home = get_home()
176-
model_subparsers = parser.add_subparsers(
177-
dest='subcommand',
178-
help='可选子命令。'
179-
)
180-
176+
try:
177+
model_subparsers = parser.add_subparsers(
178+
dest='subcommand',
179+
help='可选子命令。'
180+
)
181+
except TypeError:
182+
# required: Whether or not a subcommand must be provided,
183+
# by default False (added in 3.7)
184+
model_subparsers = parser.add_subparsers(
185+
dest='subcommand',
186+
help='可选子命令。',
187+
required=False
188+
)
181189
# 初始化脚手架命令
182190
init_p = model_subparsers.add_parser(
183191
'init',

bgesdk/management/commands/model_doc.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,17 @@ class Command(BaseCommand):
4141

4242
def add_arguments(self, parser):
4343
home = get_home()
44-
doc_ps = parser.add_subparsers(
45-
help='对模型文档进行预览和发布',
46-
required=False
47-
)
48-
44+
try:
45+
doc_ps = parser.add_subparsers(
46+
help='对模型文档进行预览和发布'
47+
)
48+
except TypeError:
49+
# required: Whether or not a subcommand must be provided,
50+
# by default False (added in 3.7)
51+
doc_ps = parser.add_subparsers(
52+
help='对模型文档进行预览和发布',
53+
required=False
54+
)
4955
init_p = doc_ps.add_parser(
5056
'init',
5157
formatter_class=argparse.ArgumentDefaultsHelpFormatter,

htmlcov/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)