Skip to content

Commit 593e844

Browse files
authored
Merge pull request #109 from ErnestChen1/master
[add] a regular format check
2 parents 46cabcc + de9ef9d commit 593e844

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cmds/cmd_package.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import logging
3737
import archive
3838
import sys
39+
import re
3940

4041
try:
4142
import requests
@@ -891,9 +892,14 @@ def package_wizard():
891892
#first step
892893
print ('\033[5;33;40m\n1.Please input a new package name :\033[0m')
893894
name = raw_input()
894-
while name == '' or name.isspace() == True :
895-
print ('\033[1;31;40mError: you must input a package name. Try again.\033[0m')
896-
name = raw_input()
895+
regular_obj = re.compile('\W')
896+
while name == '' or name.isspace() == True or regular_obj.search(name.strip()):
897+
if name == '' or name.isspace():
898+
print ('\033[1;31;40mError: you must input a package name. Try again.\033[0m')
899+
name = raw_input()
900+
else:
901+
print ('\033[1;31;40mError: package name is made of alphabet, number and underline. Try again.\033[0m')
902+
name = raw_input()
897903

898904
default_description = 'Please add description of ' + name + ' in English.'
899905
#description = user_input('menuconfig option name,default:\n',default_description)

0 commit comments

Comments
 (0)