This commit is contained in:
chendelin1982 2021-10-11 20:23:46 +08:00
parent 08cd4d33cf
commit be8dbf112a
3 changed files with 12 additions and 19 deletions

1
cli/c2 Submodule

@ -0,0 +1 @@
Subproject commit 324c5bc05dd27826e863d31f2e3b0caf84878b2c

View file

@ -54,9 +54,6 @@ class FileOp:
def fileToJson(self, path: str, remark: Optional[str] = "#", separate: Optional[str] = "="): def fileToJson(self, path: str, remark: Optional[str] = "#", separate: Optional[str] = "="):
''' convert file to Json ''' ''' convert file to Json '''
print(path)
dict = {} dict = {}
with open(path) as fh: with open(path) as fh:
for line in fh: for line in fh:
@ -65,7 +62,8 @@ class FileOp:
if line.find(remark) != 0: if line.find(remark) != 0:
item, value = line.strip().split(separate, -1) item, value = line.strip().split(separate, -1)
dict[item] = value if value != "":
dict[item] = value
else: else:
continue continue
fh.close() fh.close()
@ -81,7 +79,7 @@ class NetOp:
def checkPort(self, port: int): def checkPort(self, port: int):
'''check the target port's status''' '''check the target port's status'''
search_key = "port="+str(port) search_key = "port="+str(port)
if str(psutil.net_connections()).find(search_key) != -1: if str(+psutil.net_connections()).find(search_key) != -1:
print(str(port)+" is used") print(str(port)+" is used")
return False return False
else: else:

View file

@ -1,16 +1,10 @@
class Card: import model,re
def __init__(self, rank, suit):
self.suit = suit
self.rank = rank
self.hard, self.soft = self._points()
class NumberCard( Card ): env = {}
def _points(self): fileop=model.FileOp()
return int(self.rank), int(self.rank) env = fileop.fileToJson('c2/.env')
class AceCard( Card ): for key,value in env.items():
def _points(self): if re.match(pattern,key,re.I) != None:
return 1, 11 print(value)
nc=NumberCard(11,12)
print(nc)