Skip to content

Commit 4d575e4

Browse files
authored
[wizard] 允许使用-(横线)命名软件包 (#170)
1 parent 99f69f2 commit 4d575e4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cmds/cmd_package/cmd_package_wizard.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ def package_wizard():
4747
print('\033[5;33;40m\n1.Please input a new package name :\033[0m')
4848

4949
name = user_input()
50-
regular_obj = re.compile('\W')
51-
while name == '' or name.isspace() == True or regular_obj.search(name.strip()):
50+
regular_obj = re.compile('^[\w\d_-]*$')
51+
while name == '' or name.isspace() == True or regular_obj.search(name.strip()) == None:
5252
if name == '' or name.isspace():
5353
print('\033[1;31;40mError: you must input a package name. Try again.\033[0m')
5454
name = user_input()
5555
else:
56-
print('\033[1;31;40mError: package name is made of alphabet, number and underline. Try again.\033[0m')
56+
print('\033[1;31;40mError: package name is made of alphabet, number, underline and dash. Try again.\033[0m')
5757
name = user_input()
5858

5959
default_description = 'Please add description of ' + name + ' in English.'
@@ -155,6 +155,7 @@ def package_wizard():
155155

156156
s = Template(Kconfig_file)
157157
upper_name = str.upper(name)
158+
upper_name = upper_name.replace('-', '_')
158159
kconfig = s.substitute(name=upper_name, description=description, version=ver,
159160
pkgs_class=package_class, lowercase_name=name, version_standard=ver_standard)
160161
f = open(os.path.join(pkg_path, 'Kconfig'), 'w')

0 commit comments

Comments
 (0)