From f660e5dbef775d17579eff8293431591bf5a9ae9 Mon Sep 17 00:00:00 2001 From: chendelin1982 Date: Wed, 29 Sep 2021 18:24:23 +0800 Subject: [PATCH] model --- cli/__pycache__/model.cpython-36.pyc | Bin 4304 -> 4628 bytes cli/model.py | 30 ++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/cli/__pycache__/model.cpython-36.pyc b/cli/__pycache__/model.cpython-36.pyc index 94ae1bef786cb888ea819a0dab5906161bd48d39..07db2f36b78899c18f5f49b602e2c20c0dcbe448 100644 GIT binary patch delta 1128 zcmaJgU2oBh)uOIbwb=6n>X87MV*0y}! z8d@@09q9STdP@hNzk9D`8R>pZz2>DnEs+kTB%%!#Q}v1eZ!nn$f_kDqwRD*50}BtR zVLmdP7rMv@eHrPZn|-9YmYch)PnmAdIpWyrp7GcG*Z3M7%z_=n0P6uF5>uDD>^^(2 zq|G84vj*#=w_hNxc7~iK7h!}ryw&H=MZsKDo~}1Vx#oM3@S=n`G|714cC+q@2}et~ z9|%vDAhH|;aI|jXGnvY~X46*j2pm2Yj0UpqMaM(mTcE2K=@{b?(xcc}@1i zQtOa*#$_>&GvnlDKmHfU_gZ7U!8-)Ck2wZdtbGs*z9r;h^^sr3>cj77j!@1nfl`4bM4n}IDy@!dFC^|&xFP{56~2%8WL zgdOTkZmGI#_ESRz<_mg4t;>GylUvb;?Og1n+@&g(LnqWFD_-^+?lU?5jnjRm!1-vc zpcj>u+i#@K-59)txgP@yv6&|2%+zd4?o@YjFKJEf>3Nmw3q@20)qL-|V);Ay8D!(z z<)pP<{aqMP&+?Ni55q=6Yd@(ZF?3V4?Smt8K_Da~hD3QB;YUGJ>MT%C4E>VgsSoz~ zO$YEgGpL5)ZC|=+D2K|U7`EFTS@m3h_B0Tt)%C(Qx?epkEHCauLMrVZoSjDrHtvP# zHLwsJT?r)awR%S@4d0(_Rx6{zyLGkNY^sIAirzoKm+%HOUgFD_C)G&tN-qkT9!q#6 UKrZZEN&QzG%B-@N+I5Lp6o&6fG9O8kbjBGvGg=A-zoKN!WZ9RbRl!CzuYy*IW(3ZLke=5&p;DgvOa`-xN59^@fD|H+n zC)b=ma}tfKRMS+!ev*)NnGLpdSGvDr4MONr)<&G#WHxKCId+-Oi_DVi5wjpldCtm` z>p7MjDSpTCc!5HAABiR5qf{jaCah-8x=YT5PPxNfFRTT)nLG&l#9qV3HQ&4C@NnL* z1->^bwh${ZSj}(G`~%djG=5K%biRieJ|yH2uIoj-qvk=ur|JthflcjKK2ol`o*ge^ z$=ncN1s8iPn8e#X-O^!dSQ0-X`eI@7+f2jArvoRP^?5jhRsB>lW=6$J3S}azR6&{~ z4T_YOO^uiFx&8*`aoKpQ=roFB<~m%#m*!2Fz)EjlVv6Vmto5E7m>|bb3(^0IDclsv zA|cazZTE&7(mMY|uVR1Z($H}liqf4{5Ulvzjw3DLlOj)qMjCHMmHz&-SWB>pF diff --git a/cli/model.py b/cli/model.py index 1063373d..4d5dd679 100644 --- a/cli/model.py +++ b/cli/model.py @@ -31,7 +31,7 @@ class GitOp: def __init__(self): pass - def gitClone(cmd: str): + def gitClone(self, cmd: str): '''git clone''' try: print("Command is: "+cmd) @@ -46,12 +46,28 @@ class FileOp: def __init__(self): pass - def printJson(path: str): + def printJson(self, path: str): + '''output file content''' + with open(path,newline='') as file: print(file.read()) - def convertToJson(path: str): - pass + def fileToJson(self, path: str, remark: Optional[str] = "#", separate: Optional[str] = "="): + ''' convert file to Json ''' + + dict = {} + with open(path) as fh: + for line in fh: + + print(line.find(remark)) + if line.find(remark) != 0: + item, value = line.strip().split(separate, -1) + item = line.strip() + dict[item] = value + else: + continue + fh.close() + print (dict) class NetOp: @@ -85,7 +101,7 @@ class SecurityOp: pass def randomPass(self, length: Optional[int] = 16): - '''set password''' + '''set strong password''' alphabet = string.ascii_letters + string.digits while True: @@ -97,6 +113,6 @@ class SecurityOp: print(password) -test=SecurityOp() +test=FileOp() #test.setPort(9001) -test.randomPass(25) \ No newline at end of file +test.fileToJson('./joomla/.env_all') \ No newline at end of file