Spaces:
Sleeping
Sleeping
t5
commited on
Commit
·
54efa00
1
Parent(s):
565f928
apple
Browse files- neo server.py +4 -2
- requirements.txt +15 -1
- wr.py +0 -1808
neo server.py
CHANGED
|
@@ -70,6 +70,8 @@ def run1(data):
|
|
| 70 |
impt(("c2/"+fn2),reload=fn['reload'])
|
| 71 |
@app.post(handle_post)
|
| 72 |
def handle_post():
|
|
|
|
|
|
|
| 73 |
try:
|
| 74 |
#print(request.get_data())
|
| 75 |
if request.is_json and (data:=request.get_json()):
|
|
@@ -92,7 +94,7 @@ def handle_post():
|
|
| 92 |
def read_root():
|
| 93 |
return {"Hello": "World,"}
|
| 94 |
if __name__ == '__main__':
|
| 95 |
-
hh,fl=hhfl([["-port","
|
| 96 |
if face!="face" or hh.port:
|
| 97 |
print(hh)
|
| 98 |
-
app.run(host=
|
|
|
|
| 70 |
impt(("c2/"+fn2),reload=fn['reload'])
|
| 71 |
@app.post(handle_post)
|
| 72 |
def handle_post():
|
| 73 |
+
header=(dict(req.headers));
|
| 74 |
+
if header.get("saty")!=(os.environ.get("saty") or saty):return '{"e2":"set header"}'
|
| 75 |
try:
|
| 76 |
#print(request.get_data())
|
| 77 |
if request.is_json and (data:=request.get_json()):
|
|
|
|
| 94 |
def read_root():
|
| 95 |
return {"Hello": "World,"}
|
| 96 |
if __name__ == '__main__':
|
| 97 |
+
hh,fl=hhfl([["-port",""],["-host","0.0.0.0"]],flinput=0)
|
| 98 |
if face!="face" or hh.port:
|
| 99 |
print(hh)
|
| 100 |
+
app.run(host=hh.host, port=hh.port or 5000)
|
requirements.txt
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
|
|
| 1 |
requests
|
| 2 |
pyngrok
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
flask
|
| 2 |
requests
|
| 3 |
pyngrok
|
| 4 |
+
cryptography
|
| 5 |
+
psutil
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
flask
|
| 9 |
+
opencv-python
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
torch
|
| 13 |
+
diffusers
|
| 14 |
+
transformers
|
| 15 |
+
accelerate
|
| 16 |
+
ftfy
|
| 17 |
+
xformers
|
wr.py
DELETED
|
@@ -1,1808 +0,0 @@
|
|
| 1 |
-
# -*- coding: utf-8 -*-
|
| 2 |
-
##import sys;import os;sys.path.append(os.environ["AlfiPython"]+r"\Mjmoji");from wr import * ;
|
| 3 |
-
##import mlwebOrWeb as ml
|
| 4 |
-
## wardrobe
|
| 5 |
-
|
| 6 |
-
import sys,os,re
|
| 7 |
-
import shutil
|
| 8 |
-
import inspect
|
| 9 |
-
import time
|
| 10 |
-
import traceback
|
| 11 |
-
import pprint
|
| 12 |
-
import functools
|
| 13 |
-
if "Byte":
|
| 14 |
-
from io import StringIO, BytesIO
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
lf= "\n";lff=lf*2;sp=" ";lf2="\n";tab="\t";
|
| 18 |
-
def fpreturn(*_): return _[0]
|
| 19 |
-
def fpre(*_): return _
|
| 20 |
-
pr=print
|
| 21 |
-
tfolder="r:/temp"
|
| 22 |
-
if not os.path.exists(tfolder): tfolder=os.environ["tmp"]
|
| 23 |
-
if "cpa" in os.environ:
|
| 24 |
-
cpy=os.path.abspath(__file__+"\\..\\..")
|
| 25 |
-
cpw=os.path.abspath(__file__+"\\..")
|
| 26 |
-
T45=os.environ["USERNAME"]
|
| 27 |
-
cpa=os.environ["cpa"]
|
| 28 |
-
ZVCherryPicker=cpy+"\\qt\\ZVCherryPicker.pyw"
|
| 29 |
-
HeartNote=cpy+"\\qt\\HeartNote.pyw"
|
| 30 |
-
else:
|
| 31 |
-
cpa=None
|
| 32 |
-
|
| 33 |
-
class p310:# require version
|
| 34 |
-
def __getstate__(zl):return #pickle
|
| 35 |
-
def typeint(w):
|
| 36 |
-
try:
|
| 37 |
-
int(w)
|
| 38 |
-
return True
|
| 39 |
-
except:False
|
| 40 |
-
def typefn(fn,remove=0):
|
| 41 |
-
if (re.search(r'["*/:<>?\\|]',(fn))):return
|
| 42 |
-
if (".." in fn):return
|
| 43 |
-
if len(fn)>255:return
|
| 44 |
-
try:
|
| 45 |
-
open(fn,"ab")
|
| 46 |
-
## if remove: os.remove(fn)
|
| 47 |
-
return 1
|
| 48 |
-
except:False
|
| 49 |
-
def fpf(fn,fb="",tail=""):
|
| 50 |
-
if not typefn(fn):
|
| 51 |
-
if not fb:
|
| 52 |
-
f,e=lfn.splitext(fn)
|
| 53 |
-
fb=f[:200]+e
|
| 54 |
-
fn=fb
|
| 55 |
-
if tail: wfdb(fn+"_", putp(1,tail))
|
| 56 |
-
return fn
|
| 57 |
-
def putp(fl,te):#,*w,**W):
|
| 58 |
-
import pickle
|
| 59 |
-
put=pickle.dumps
|
| 60 |
-
## print(te)
|
| 61 |
-
if fl==1: te= put(te)
|
| 62 |
-
if fl==2: te= pickle.loads(te)
|
| 63 |
-
return te
|
| 64 |
-
def exrange(li,step=2):
|
| 65 |
-
if len(li)/step < 0: return
|
| 66 |
-
for x in range(0,len(li)//step):
|
| 67 |
-
yield li[x*step:x*step+step]
|
| 68 |
-
def pr2(*a,**k): pass;
|
| 69 |
-
oriAB=lambda x: (print(x[:122],lf*2,x[-122:]))
|
| 70 |
-
ppf=pprint.pformat
|
| 71 |
-
def orib(lii, ix=-1,bound=4):
|
| 72 |
-
"print(li[:4],li[-4:])"
|
| 73 |
-
if(ix==-1):
|
| 74 |
-
lambda x: (print(x[:4],lf*2,x[-4:]))
|
| 75 |
-
else:
|
| 76 |
-
lio=[lii[ix+n] for n in list(range(-bound,bound)) if(ix+n>0 and ix+n<len(lii)) ]
|
| 77 |
-
for v in lio:
|
| 78 |
-
if(v==lii[ix]):lio[lio.index(v)]="__"+v
|
| 79 |
-
## lio[ix]="__"+lio[ix]
|
| 80 |
-
#lio[ix]+=lf
|
| 81 |
-
print(lfjw(lio))
|
| 82 |
-
def printline(*a,**k):#X/ref
|
| 83 |
-
f=inspect.currentframe()
|
| 84 |
-
if(sys.version=='3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)]'):
|
| 85 |
-
no=inspect.currentframe(1)
|
| 86 |
-
elif(sys.hexversion>=0x030401F0):#'3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)]'):
|
| 87 |
-
"c7 3.7.7 64bit -> 3.8.6"
|
| 88 |
-
fb=f
|
| 89 |
-
for _ in range(4):
|
| 90 |
-
print(fb.f_lineno,fb.f_code.co_filename, fb.f_code.co_name)
|
| 91 |
-
fb=fb.f_back
|
| 92 |
-
if not fb:
|
| 93 |
-
break
|
| 94 |
-
## print(" L-"+str(no),*a,**k)
|
| 95 |
-
def prfl(li):#prFirstLast
|
| 96 |
-
print(li[0],lf,li[-1]);
|
| 97 |
-
def pren(v):
|
| 98 |
-
print(list(enumerate(v)))
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
#mrk1------------file
|
| 110 |
-
def wfdb(filename,te):#writeFileDirectInBinaryMode
|
| 111 |
-
f = open(filename,"wb")
|
| 112 |
-
f.write(te)
|
| 113 |
-
def wfdt(filename,te):#text
|
| 114 |
-
return wfd(filename).t(te)
|
| 115 |
-
def wfdt8L(filename,te):#textUni NewLine Unix Format
|
| 116 |
-
f = open(filename,"wU",encoding="utf-8")
|
| 117 |
-
f.write(te)
|
| 118 |
-
def wfd8(fn,te):
|
| 119 |
-
wfd(fn).w(te,code="utf8",copy=0)
|
| 120 |
-
def afdt(filename,te):#textUni
|
| 121 |
-
f = open(filename,"a+",encoding="utf-8")
|
| 122 |
-
f.write(te)
|
| 123 |
-
write8dd=afdt
|
| 124 |
-
afdtu=afdt
|
| 125 |
-
def rfdb(fn):
|
| 126 |
-
f = open(fn,"rb")
|
| 127 |
-
te = f.read()
|
| 128 |
-
return te
|
| 129 |
-
def rfdt(fn):return wfd(fn).r()
|
| 130 |
-
def rfdl(fn):
|
| 131 |
-
f = open(fn,"r")
|
| 132 |
-
te = f.readlines()
|
| 133 |
-
return te
|
| 134 |
-
def rfdv0(fn,codeList=("cp932","utf-16","utf-8","eucjp"),lines=True):
|
| 135 |
-
for c in codeList:
|
| 136 |
-
f = open(fn,"r",encoding=c)
|
| 137 |
-
try:
|
| 138 |
-
te = f.readlines() if(lines)else f.read()
|
| 139 |
-
break
|
| 140 |
-
except UnicodeDecodeError as XP:
|
| 141 |
-
continue;
|
| 142 |
-
except UnicodeError as XP:
|
| 143 |
-
continue;
|
| 144 |
-
return te
|
| 145 |
-
def rfdlv(fn): return rfdv0(fn)
|
| 146 |
-
def rfdtv(fn): return rfdv0(fn,lines=False)
|
| 147 |
-
def rfdtu(fn):
|
| 148 |
-
f = open(fn,"r",encoding="utf-8")
|
| 149 |
-
te = f.read()
|
| 150 |
-
return te
|
| 151 |
-
def vcs(bte,cs=("utf8","cp932","utf16","eucjp")):
|
| 152 |
-
for c in cs:
|
| 153 |
-
try: return bte.decode(c)
|
| 154 |
-
except: continue
|
| 155 |
-
class wfd():#clWfd
|
| 156 |
-
tab="\t"
|
| 157 |
-
def __init__(zl,fn,region=(),ir=None,lf="\n"):
|
| 158 |
-
zl.fn=fn
|
| 159 |
-
zl.code="utf8"
|
| 160 |
-
zl.lf=lf
|
| 161 |
-
zl.ir=ir#
|
| 162 |
-
zl.by=None
|
| 163 |
-
def readtime(zl,mod=0):
|
| 164 |
-
zl.ts=(lfn.getatime(zl.fn)+mod, mtime(zl.fn)+mod)
|
| 165 |
-
return zl
|
| 166 |
-
## def restoretime(zl):
|
| 167 |
-
def rfdv(zl):return zl.r(cs=("cp932","utf-16","utf-8","eucjp","mbcs"))#noMbcs)
|
| 168 |
-
## def mem(zl): zl.by=zl.rb(); return zl;
|
| 169 |
-
def rb(zl): return open(zl.fn,"rb").read()
|
| 170 |
-
def r(zl,cs=("utf8","cp932","utf16","eucjp"),lines=False,m=0,te=""):
|
| 171 |
-
if te: e1=te
|
| 172 |
-
else:
|
| 173 |
-
with open(zl.fn,"rb") as f:
|
| 174 |
-
e1 = f.read()
|
| 175 |
-
for c in cs:
|
| 176 |
-
try:
|
| 177 |
-
t1=e1.decode(c)
|
| 178 |
-
if("\r\n" in t1):
|
| 179 |
-
#if(t1.count("\r")!=t1.count("\n")):return 0
|
| 180 |
-
zl.lf="\r\n"
|
| 181 |
-
elif("\n" in t1):zl.lf="\n"
|
| 182 |
-
elif("\r" in t1):zl.lf="\r"
|
| 183 |
-
else:#oneline
|
| 184 |
-
pass
|
| 185 |
-
if lines: te=t1.splitlines()
|
| 186 |
-
else: te=t1
|
| 187 |
-
#te=te.replace(zl.lf, "\n")
|
| 188 |
-
zl.code=c
|
| 189 |
-
break
|
| 190 |
-
except (UnicodeDecodeError, UnicodeError) as e:
|
| 191 |
-
zl.lastException=e
|
| 192 |
-
continue;
|
| 193 |
-
else:
|
| 194 |
-
return 0
|
| 195 |
-
if(zl.ir) and 0:
|
| 196 |
-
te=zl.lte=findall(zl.ir,te)
|
| 197 |
-
if m: #chk modified
|
| 198 |
-
import hashlib
|
| 199 |
-
zl.mtime=mtime(zl.fn)
|
| 200 |
-
zl.sha=hashlib.sha256(te.encode()).digest()
|
| 201 |
-
return te
|
| 202 |
-
def csvr(zl,*aw,lf=None,tab=None,**kw):
|
| 203 |
-
return list(csv.reader(StringIO(zl.r()), delimiter=tab or zl.tab))
|
| 204 |
-
def w8(zl,te): return zl.w(te,code="utf8")
|
| 205 |
-
def w16(zl,te): return zl.w(te,code="utf_16_LE")
|
| 206 |
-
def wjis(zl,te): return zl.write8re(zl.fn,te,"cp932")
|
| 207 |
-
def write8re(zl,fn,te,code="",lines=False,copy=True,lf=1,nbase=0,ts=0):
|
| 208 |
-
if not code: code=zl.code
|
| 209 |
-
dir = lfnd(fn)
|
| 210 |
-
if dir: inidi(dir)
|
| 211 |
-
if(ifexist(fn) and copy):
|
| 212 |
-
dnRestore=f"{tfolder}/restore"
|
| 213 |
-
inidi(dnRestore)
|
| 214 |
-
zl.fnRestore=nxNumFull(dnRestore,"%s"+lfn.split(fn)[1],nZfill=2) if nbase else jofn(dnRestore,cfile(fn)+" "+tp())
|
| 215 |
-
shutil.copy2(fn,zl.fnRestore)
|
| 216 |
-
## emove__
|
| 217 |
-
rmbat(zl.fnRestore)
|
| 218 |
-
## if(type(te)!=str):return 0
|
| 219 |
-
if 1:
|
| 220 |
-
Lf=(zl.lf if lf==1 else lf)
|
| 221 |
-
t1=jw(Lf,te) if lines else te
|
| 222 |
-
#no t1=zl.CallBackCaller() if zl.ir else t1
|
| 223 |
-
e1=t1 if type(t1)==bytes else t1.encode(code)#
|
| 224 |
-
try:
|
| 225 |
-
with open(fn, 'wb') as fo:
|
| 226 |
-
fo.write(e1)
|
| 227 |
-
except Exception as e:
|
| 228 |
-
#restore()
|
| 229 |
-
## zl.LastError=e
|
| 230 |
-
open(r"r:\fail reason.txt","w").write(str(e))
|
| 231 |
-
open(r"r:\fail "+tp()+".txt", "wb").write(e1)
|
| 232 |
-
#with open(nxNumFull(r"r:","%s"+os.path.split(fn)[1],nZfill=2), 'wb') as fo:
|
| 233 |
-
return 0
|
| 234 |
-
if ts==1: os.utime(zl.fn, zl.ts)
|
| 235 |
-
## finally:
|
| 236 |
-
if 0:
|
| 237 |
-
## t2=rfdtv(fn)
|
| 238 |
-
fo=wfd(fn)
|
| 239 |
-
t2=fo.r(cs=("utf8","utf16","eucjp","cp932"))
|
| 240 |
-
print(fo.code,t2)
|
| 241 |
-
## print(fnRestore,t2)
|
| 242 |
-
#diff()
|
| 243 |
-
return 1
|
| 244 |
-
## def write8re(zl,fn,te,*aw,**kw):print("w;",fn,len(te), lf, dif32(zl.r(),te))
|
| 245 |
-
def w(zl,te,*a,**k):return zl.write8re(zl.fn, te, *a, **k)
|
| 246 |
-
def t(zl,te,*a,**k):
|
| 247 |
-
rmbat(zl.fn,rembat="wf t.bat")
|
| 248 |
-
return zl.write8re(zl.fn, te,copy=False *a, **k)
|
| 249 |
-
def CallBackCaller(zl):
|
| 250 |
-
te=zl.r((zl.code,))
|
| 251 |
-
rnte=""
|
| 252 |
-
l=0
|
| 253 |
-
for n,ran in enumerate(zl.lte):#range list.appended(ire.search)
|
| 254 |
-
rnte+=te[l:ran[0]]
|
| 255 |
-
rnte+=zl.cb(n)
|
| 256 |
-
l=ran[1]
|
| 257 |
-
rnte+=te[l:]
|
| 258 |
-
return rnte
|
| 259 |
-
def ornkf(byte,cs=("utf8","cp932","utf16","eucjp"),lines=False):
|
| 260 |
-
return
|
| 261 |
-
for c in csf:
|
| 262 |
-
try:
|
| 263 |
-
t1=e1.decode(c)
|
| 264 |
-
if("\r\n" in t1):
|
| 265 |
-
if(t1.count("\r")!=t1.count("\n")):return 0
|
| 266 |
-
zl.lf="\r\n"
|
| 267 |
-
elif("\n" in t1):zl.lf="\n"
|
| 268 |
-
elif("\r" in t1):zl.lf="\r"
|
| 269 |
-
else:#oneline
|
| 270 |
-
pass
|
| 271 |
-
if lines: te=t1.splitlines()
|
| 272 |
-
else: te=t1.replace(zl.lf, "\n")
|
| 273 |
-
zl.code=c
|
| 274 |
-
break
|
| 275 |
-
except UnicodeDecodeError as XP:
|
| 276 |
-
continue;
|
| 277 |
-
except UnicodeError as XP:
|
| 278 |
-
continue;
|
| 279 |
-
else:
|
| 280 |
-
return 0
|
| 281 |
-
## with open(zl.fn, "rb", encoding=zl.code):
|
| 282 |
-
return te
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
#----mrk1-----------
|
| 292 |
-
def line():
|
| 293 |
-
return inspect.currentframe().f_back.f_lineno
|
| 294 |
-
def cmpd(te,tf):#cmpDokomade.Use for comic rename
|
| 295 |
-
for n in range(999):
|
| 296 |
-
if te[n] != tf[n]:
|
| 297 |
-
return n
|
| 298 |
-
def cmpfs(li):
|
| 299 |
-
"os.path.commonprefix(list)"
|
| 300 |
-
ip=min(compd(li[0],f) for f in li)
|
| 301 |
-
return ip
|
| 302 |
-
def wfy(li,ws=5):# windowfy function, window size
|
| 303 |
-
for n,f in enumerate(li):
|
| 304 |
-
yield li[n:n+5]
|
| 305 |
-
##def orin(te=" input"):
|
| 306 |
-
## print(te)
|
| 307 |
-
## input()
|
| 308 |
-
def owari():
|
| 309 |
-
print("\nowari:");
|
| 310 |
-
input("owari:")
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
from argparse import ArgumentParser
|
| 314 |
-
def arx(a=None):#Exe
|
| 315 |
-
parser = ArgumentParser(description="command_error")
|
| 316 |
-
parser.add_argument("-f",type=str)
|
| 317 |
-
parser.add_argument("-re",type=str)
|
| 318 |
-
parser.add_argument("fil",nargs="*")
|
| 319 |
-
arps=parser.parse_args(a)
|
| 320 |
-
return arps
|
| 321 |
-
def a2a(li):
|
| 322 |
-
return jw(" ",('"{}"'.format(f) for f in li))
|
| 323 |
-
def chdir(x=0):
|
| 324 |
-
os.chdir(lfnd(sys.argv[x]))
|
| 325 |
-
class pushd:
|
| 326 |
-
def __init__(sl,dir):
|
| 327 |
-
if 1: inidi(dir)
|
| 328 |
-
sl.dL=os.getcwd()
|
| 329 |
-
os.chdir(dir)
|
| 330 |
-
def __enter__(sl):
|
| 331 |
-
return 1
|
| 332 |
-
def __exit__(sl, _type, value, traceback):
|
| 333 |
-
os.chdir(sl.dL)
|
| 334 |
-
def chdirc(fil=0,idx=1):# mv to z droped file
|
| 335 |
-
if not fil:fil=sys.argv[1:]
|
| 336 |
-
if isinstance(fil,(hhwr)): fil=fil.fil
|
| 337 |
-
if not fil:
|
| 338 |
-
pr("please drop off the file");input("chdirc()");
|
| 339 |
-
else:
|
| 340 |
-
os.chdir(lfnd(fil[0]))
|
| 341 |
-
return fil
|
| 342 |
-
|
| 343 |
-
def chdirm():# mv to z file own is in
|
| 344 |
-
chdirc(args=sys.argv,idx=0)
|
| 345 |
-
|
| 346 |
-
def cdn(args = sys.argv):#ChDirNakereba 引数があればそのディレクトリに。なければスクリプトの
|
| 347 |
-
if(len(args) == 1):
|
| 348 |
-
lena=0;
|
| 349 |
-
else:
|
| 350 |
-
lena=1;
|
| 351 |
-
argf= args[lena]
|
| 352 |
-
d=re.match(r"(.+(?:\\|/))",argf).group(1)
|
| 353 |
-
os.chdir(d)
|
| 354 |
-
# a=input(argf)
|
| 355 |
-
return args[1:];
|
| 356 |
-
#r:\p\fi.mkv
|
| 357 |
-
#r:\p
|
| 358 |
-
#r:\p #fi
|
| 359 |
-
#fi.
|
| 360 |
-
#fi.mkv
|
| 361 |
-
#.mkv
|
| 362 |
-
#mkv
|
| 363 |
-
def cdir(fn):return lfnd(fn)
|
| 364 |
-
def cdiy(argf):#+yen
|
| 365 |
-
return argf[:argf.rfind('\\')+1]#fail .-1+1=0 .""
|
| 366 |
-
def cfile(fn):return lfnb(lfn.splitext(fn)[0])
|
| 367 |
-
def cdotc(fn):return lfnb(fn)
|
| 368 |
-
def catsuff(fn,suf):#foo.mkv, mp4 >> foo.mp4
|
| 369 |
-
tail=fn.rfind('.')
|
| 370 |
-
if(tail==-1):tail=None
|
| 371 |
-
fnre=fn[:tail]+"."+suf
|
| 372 |
-
if(fnre==fn):
|
| 373 |
-
return "onaji"
|
| 374 |
-
return fnre
|
| 375 |
-
replaceSuffix=catsuff
|
| 376 |
-
def catpref(fn,prefix):
|
| 377 |
-
"/foo.mkv, f2 >> /f2foo.mkv"
|
| 378 |
-
yenpos=fn.rfind('\\')
|
| 379 |
-
if(yenpos==-1):
|
| 380 |
-
fnre=prefix+fn
|
| 381 |
-
else:
|
| 382 |
-
fnre=fn[:yenpos]+'\\'+prefix+fn[yenpos+1:]
|
| 383 |
-
return fnre
|
| 384 |
-
def CatPS(fn,p,s):
|
| 385 |
-
return catsuff(catpref(fn,p),s)
|
| 386 |
-
#
|
| 387 |
-
if "jwdir":
|
| 388 |
-
def lgest(lis):
|
| 389 |
-
l=lis[0]
|
| 390 |
-
for l2 in lis:
|
| 391 |
-
if l2>l: l=l2
|
| 392 |
-
return l
|
| 393 |
-
def notanybad(lis):
|
| 394 |
-
for f in lis:
|
| 395 |
-
if not f: return False
|
| 396 |
-
return True
|
| 397 |
-
#from jwdir import *
|
| 398 |
-
jwdir=getattr(os.path,b'\x6A\x6F\x69\x6E'.decode())
|
| 399 |
-
jofn=jwdir
|
| 400 |
-
def jw(te,list):
|
| 401 |
-
assert isinstance(te,(str,bytes))
|
| 402 |
-
#assert 1==len(typ:=set(type(f) for f in [te,*list])), ["type not unique ",typ]
|
| 403 |
-
assert hasattr(list,"__iter__")
|
| 404 |
-
return getattr(te,b'\x6A\x6F\x69\x6E'.decode())(list)
|
| 405 |
-
lfjw=functools.partial(jw, lf)
|
| 406 |
-
_lfn="LibFileName"#="lfn"
|
| 407 |
-
lfn=os.path
|
| 408 |
-
lfnd=lfn.dirname
|
| 409 |
-
lfndir=lfn.dirname
|
| 410 |
-
lfnb=lfn.basename
|
| 411 |
-
mtime=lfn.getmtime
|
| 412 |
-
ctime=lfn.getctime
|
| 413 |
-
n12=__builtins__[b'\x65\x6E\x75\x6D\x65\x72\x61\x74\x65'.decode()]
|
| 414 |
-
def fpn1(lis):
|
| 415 |
-
if isinstance(lis,(dict)): return getattr(lis,b'\x69\x74\x65\x6D\x73'.decode())()
|
| 416 |
-
return n12(lis)
|
| 417 |
-
sleep=getattr(time,b'\x73\x6C\x65\x65\x70'.decode())
|
| 418 |
-
def shuttown(stdin,*w):
|
| 419 |
-
assert hasattr(stdin, b'\x63\x6C\x6F\x73\x65'.decode())
|
| 420 |
-
return getattr(stdin,b'\x63\x6C\x6F\x73\x65'.decode())(*w)
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
def dq(te):#double quote
|
| 436 |
-
if(te[0] != '"' or te[-1] != '"'):
|
| 437 |
-
return '"'+te+'"';
|
| 438 |
-
def prit(*w):
|
| 439 |
-
te=jw(" ", [str(f) for f in w])+lf;
|
| 440 |
-
## print("exit-%d "%inspect.currentframe().f_back.f_lineno, end="");
|
| 441 |
-
print("exit-")
|
| 442 |
-
print(te, end="");
|
| 443 |
-
if w[:1]==(1,):input("*")
|
| 444 |
-
sys.exit();
|
| 445 |
-
prexit=prit
|
| 446 |
-
def inidi(pdir):
|
| 447 |
-
if os.path.exists(pdir): return 1
|
| 448 |
-
else:os.makedirs(pdir); return 0
|
| 449 |
-
def inidir(*dirlist):
|
| 450 |
-
cwd=os.getcwd()
|
| 451 |
-
for f in dirlist:
|
| 452 |
-
assert type(f)==str, "inidir;"
|
| 453 |
-
#f=os.path.abspath(f)
|
| 454 |
-
if not f:
|
| 455 |
-
os.chdir("..")
|
| 456 |
-
continue
|
| 457 |
-
p=os.path.split(f)
|
| 458 |
-
if(p[0]):#"c:\dir\"
|
| 459 |
-
if not lfn.exists(p[0]):os.makedirs(p[0])
|
| 460 |
-
assert lfn.isdir(p[0])
|
| 461 |
-
os.chdir(p[0])
|
| 462 |
-
if(p[1]):#"c:\file" > ("c:\", "file")
|
| 463 |
-
if not os.path.exists(f):wfdb(f,b"")
|
| 464 |
-
os.chdir(cwd)
|
| 465 |
-
def isdir(fn):
|
| 466 |
-
if os.path.isdir(fn): return fn;
|
| 467 |
-
if os.path.isfile(fn): return 0;
|
| 468 |
-
if os.path.islink(fn): return 0;
|
| 469 |
-
|
| 470 |
-
def isBound(length,index):
|
| 471 |
-
if(length<0):
|
| 472 |
-
index=abs(index+1)
|
| 473 |
-
return bool(length>index)
|
| 474 |
-
def boundary(x,b):
|
| 475 |
-
if b[0]>x:x=b[0];
|
| 476 |
-
if b[1]<=x:x=b[1]-1
|
| 477 |
-
return x
|
| 478 |
-
def ifexist(fn):#return True
|
| 479 |
-
return lfn.exists(fn)
|
| 480 |
-
def AbImage1(fs,grouping=False):#連番を表示しない。冗長になるのを防ぐ
|
| 481 |
-
lioView=[]
|
| 482 |
-
DiNameTm=puni()
|
| 483 |
-
for fn in fs:
|
| 484 |
-
NameTm=re.sub(r"\d","5",fn)
|
| 485 |
-
DiNameTm.up(NameTm,fn)
|
| 486 |
-
#
|
| 487 |
-
ireTailNm=re.compile(r"(\d+)")
|
| 488 |
-
def fTailNm(fn):#return rearest number
|
| 489 |
-
fn=re.sub(r"(mp4|mp3)","",fn)
|
| 490 |
-
mo=ireTailNm.findall(fn)
|
| 491 |
-
if mo:
|
| 492 |
-
Nm=int(mo[-1])
|
| 493 |
-
return Nm
|
| 494 |
-
return 0
|
| 495 |
-
if grouping:
|
| 496 |
-
d2=list((k,sorted(v,key=lambda e: -fTailNm(e))) for k,v in DiNameTm.items())
|
| 497 |
-
l1=[[" "+f[0]]+f[1:grouping] for k,f in d2]
|
| 498 |
-
lioView=[f1 for f2 in l1 for f1 in f2]
|
| 499 |
-
else:
|
| 500 |
-
lioView=[max(v,key=fTailNm) for k,v in DiNameTm.items()]
|
| 501 |
-
return lioView
|
| 502 |
-
def orror(*a,**k):
|
| 503 |
-
te=jw(" ",(str(f)for f in a)) + lf;
|
| 504 |
-
afdt("orror00.txt",te)
|
| 505 |
-
def orro2(*a,**k):
|
| 506 |
-
te="";
|
| 507 |
-
for f in a:
|
| 508 |
-
ty=type(f);
|
| 509 |
-
if(ty==int):
|
| 510 |
-
ti=str(f);
|
| 511 |
-
te= te+ti
|
| 512 |
-
else:
|
| 513 |
-
te+=f;
|
| 514 |
-
te+=" ";
|
| 515 |
-
te+=lf;
|
| 516 |
-
afdt("orror00.txt",te)
|
| 517 |
-
def orro3(fn,te0=None,sp=" "):
|
| 518 |
-
if(te0!=None):
|
| 519 |
-
wfd(fn).w(te0,copy=False)
|
| 520 |
-
def f(*a,**k):
|
| 521 |
-
te=jw(sp,[str(t) for t in a]);
|
| 522 |
-
afdt(fn,te+lf)
|
| 523 |
-
return te
|
| 524 |
-
return f;
|
| 525 |
-
|
| 526 |
-
def move2(src,dist, rec=0):
|
| 527 |
-
if dist==src: return
|
| 528 |
-
distdir=lfn.dirname(dist)
|
| 529 |
-
if distdir and not(ifexist(distdir)): os.makedirs(distdir)
|
| 530 |
-
if rec: afdt("r:\\temp\\rename.txt",dist+tab+src+lf);
|
| 531 |
-
os.rename(src,dist);
|
| 532 |
-
##def move2(src,dist): move2(dist,src,0)
|
| 533 |
-
|
| 534 |
-
def rmbat(fns,rembat="rmbat.bat",tmd=tfolder):#jis only
|
| 535 |
-
rembat=tmd+"/"+rembat
|
| 536 |
-
if not ifexist(rembat): afdt(rembat, 'chcp 65001\r\n')
|
| 537 |
-
for fn in fns if type(fns)!=str else [fns]: afdt(rembat,'del "{fn}"\r\n'.format(fn=lfn.abspath(fn)))
|
| 538 |
-
orRemove=rmbat
|
| 539 |
-
def remove(fn,add=1):
|
| 540 |
-
if not ifexist(fn):return
|
| 541 |
-
if add: afdt(r"r:\temp\rename.txt",":rm"+"\t"+fn+lf);
|
| 542 |
-
os.chmod(fn,0o770)
|
| 543 |
-
if lfn.isdir(fn):
|
| 544 |
-
shutil.rmtree(fn)
|
| 545 |
-
elif lfn.isfile(fn):
|
| 546 |
-
os.remove(fn)
|
| 547 |
-
return 1
|
| 548 |
-
def remo(fn): return remove(fn,add=0)
|
| 549 |
-
from uuid import uuid1
|
| 550 |
-
_perf_counter0=time.perf_counter()
|
| 551 |
-
def perf_counter():
|
| 552 |
-
return time.perf_counter()-_perf_counter0
|
| 553 |
-
def timepref(w=5,n=2):# zero width, after z decimal point
|
| 554 |
-
return time.strftime("%Y%m%d-%H%M%S")+"-{t:0{w}d}".format(w=w,t=time.perf_counter_ns()//(1000000000//10**n))
|
| 555 |
-
from datetime import datetime
|
| 556 |
-
_now=0
|
| 557 |
-
def tp(te="%Y%m%d-%H%M%S",n=2):#%f
|
| 558 |
-
global _now
|
| 559 |
-
while 1:
|
| 560 |
-
((now:=datetime.now()))
|
| 561 |
-
now=now.strftime(te)+"-{}".format(f"{now.microsecond:06}"[:n])
|
| 562 |
-
if _now!=now:break
|
| 563 |
-
_now=now
|
| 564 |
-
return now
|
| 565 |
-
|
| 566 |
-
def emove(src,timebase=True):
|
| 567 |
-
src=os.path.abspath(src)
|
| 568 |
-
c=os.path.splitdrive(src)[0]+os.path.sep #c:
|
| 569 |
-
emo=jofn(c, "emove______")
|
| 570 |
-
if not(os.path.exists(emo)): os.makedirs(emo)
|
| 571 |
-
_id=tp() if timebase else str(uuid1(0))# None . getnode()
|
| 572 |
-
#base="{} {}".format(os.path.basename(src), _id)
|
| 573 |
-
base=_id
|
| 574 |
-
dst=jofn(c, "emove______", base)
|
| 575 |
-
afdt(jofn(emo,"wrld.txt"),src+"\t"+base+lf);
|
| 576 |
-
os.rename(src,dst)
|
| 577 |
-
return dst
|
| 578 |
-
def emrestore(fn="C"):
|
| 579 |
-
if len(fn)==1:
|
| 580 |
-
emo=jofn(fn[0]+":/", "emove______")
|
| 581 |
-
else:emo=fn
|
| 582 |
-
li=rcsr(jofn(emo,"wrld.txt"))
|
| 583 |
-
return li
|
| 584 |
-
return (li[-400:])
|
| 585 |
-
def fripfn(a,b):
|
| 586 |
-
aff=a+"fripfn"
|
| 587 |
-
os.rename(a,aff)
|
| 588 |
-
os.rename(b,a)
|
| 589 |
-
os.rename(aff,b)
|
| 590 |
-
#emove(r"r:\02zv.txt")
|
| 591 |
-
#2remove
|
| 592 |
-
def orsplit1(te,Threshold=1):
|
| 593 |
-
return [j for j in te.splitlines() if len(j)>=Threshold and j[0]!="#"]
|
| 594 |
-
def orsplit(te,delimiter):
|
| 595 |
-
t2=te.split(lf)
|
| 596 |
-
t3=[j.split(delimiter) for j in t2 if len(j) > 0]
|
| 597 |
-
return t3
|
| 598 |
-
def orsplit2(te,delimiter,threshold=5,strip=fpreturn):
|
| 599 |
-
"VzComment"
|
| 600 |
-
t2=te.splitlines()
|
| 601 |
-
l1list=[[strip(f) for f in j.split(delimiter)] for j in t2 if len(j)>=threshold and j[0]!="#"]
|
| 602 |
-
return l1list
|
| 603 |
-
def colonsplit(te): return orsplit2(te,":",strip= str.strip)
|
| 604 |
-
##def orsplit3(te,delimiter):
|
| 605 |
-
## "VzCommentCsv"
|
| 606 |
-
## t2=te.split(lf)
|
| 607 |
-
## l2list=[j.split(delimiter) for j in t2 if j[0]!="#"]
|
| 608 |
-
## return l2list
|
| 609 |
-
def orsub(map0,te):
|
| 610 |
-
pat=jw("|",map(lambda e:re.escape(e),map0));
|
| 611 |
-
## pr(pat);
|
| 612 |
-
irfinal=re.compile(pat)
|
| 613 |
-
def f6(mo):
|
| 614 |
-
mg= mo.group(0);#[0];
|
| 615 |
-
if (mg in map0):
|
| 616 |
-
mg=map0[mg];
|
| 617 |
-
else:
|
| 618 |
-
assert 0,("orsub");
|
| 619 |
-
return mg;
|
| 620 |
-
t2=irfinal.sub(f6,te);
|
| 621 |
-
return t2;
|
| 622 |
-
def orsubne(map0,te):#NonEscape
|
| 623 |
-
pat=jw("|",map0);
|
| 624 |
-
## pr(pat);
|
| 625 |
-
irfinal=re.compile(pat)
|
| 626 |
-
## mapi={orsub({r"\[":"[",r"\]":"]",r"^":"","$":""},k):v for k,v in map0.items()}
|
| 627 |
-
def f6(mo):
|
| 628 |
-
mg= mo.group(0);#[0];
|
| 629 |
-
li=[v for k,v in map0.items() if re.match(k,mg)]
|
| 630 |
-
if li:pass
|
| 631 |
-
else:
|
| 632 |
-
assert 0,("orsub")
|
| 633 |
-
return mg;
|
| 634 |
-
t2=irfinal.sub(f6,te);
|
| 635 |
-
return t2;
|
| 636 |
-
#
|
| 637 |
-
def findall(ire,te,rebuild=0):
|
| 638 |
-
ire=re.compile(*ire) if not isinstance(ire,re.Pattern) else ire
|
| 639 |
-
ran=(0,0)#range
|
| 640 |
-
while 1:
|
| 641 |
-
mo=ire.search(te,ran[1])
|
| 642 |
-
if(mo):
|
| 643 |
-
## print(mo,mo.groups())
|
| 644 |
-
if rebuild:
|
| 645 |
-
yield (ran[1],mo.span()[0]), 0
|
| 646 |
-
yield mo.span(), mo
|
| 647 |
-
else: yield mo
|
| 648 |
-
ran=mo.span()
|
| 649 |
-
else:break
|
| 650 |
-
if rebuild: yield (ran[1], len(te)), 0
|
| 651 |
-
#2regex
|
| 652 |
-
##prexit(findall(re.compile(r"(\d*) (?=<d>\d*)a"),"1 2a"))
|
| 653 |
-
##prexit(findall(re.compile(r"(\d)(?P<d2>2)?"),"123 1 12"))
|
| 654 |
-
##prexit(list(findall((r"('.+?')",),"1'2'3 '1' 12",rebuild=1)))
|
| 655 |
-
def dif1(prefix,pat="#mrk1"):
|
| 656 |
-
ir1=compilev(pat)
|
| 657 |
-
mo=ir1.findall(rfdtu(sys.argv[0]))
|
| 658 |
-
for n,v in enumerate(mo):
|
| 659 |
-
write8("r:\\"+prefix+"%d%d"%(n,len(v))+".txt",v)
|
| 660 |
-
def dif2(t1,t2):
|
| 661 |
-
from difflib import HtmlDiff
|
| 662 |
-
df = HtmlDiff()
|
| 663 |
-
return df.make_file(t1,t2)
|
| 664 |
-
def charjunk(c):
|
| 665 |
-
return c==" \t"
|
| 666 |
-
def dif3(t1,t2):
|
| 667 |
-
import difflib as dif
|
| 668 |
-
print=orro3(r"r:\tstDiff.txt")
|
| 669 |
-
print("ndiff\n",lfjw(list(dif.ndiff(t1,t2))))
|
| 670 |
-
dcd=dif.Differ().compare(t1,t2)
|
| 671 |
-
print("compare",list(dcd))
|
| 672 |
-
unif=list(dif.unified_diff(t1,t2))
|
| 673 |
-
print("unified",lfjw(unif))
|
| 674 |
-
#wel print("ndiff",list(dif.ndiff(t1,t2,charjunk=charjunk)))
|
| 675 |
-
con=dif.context_diff(t1,t2)
|
| 676 |
-
print("context",lfjw(con))
|
| 677 |
-
ir1=dif.SequenceMatcher(None,t1,t2)
|
| 678 |
-
print("opcodes ",ir1.ratio(),list(ir1.get_opcodes()))
|
| 679 |
-
return jw(lf,unif)
|
| 680 |
-
#
|
| 681 |
-
def dif3tst():
|
| 682 |
-
import difflib as dif
|
| 683 |
-
t1="am..==d"
|
| 684 |
-
t2="pm..i=="
|
| 685 |
-
l1=list(t1); l2=list(t2)
|
| 686 |
-
ir1=dif.SequenceMatcher(None,t1,t2)
|
| 687 |
-
mo=ir1.get_matching_blocks()
|
| 688 |
-
print(ir1.ratio())#equal==1.0
|
| 689 |
-
print(lf,t1,lf,t2,lf, list(mo))
|
| 690 |
-
print(list(ir1.get_opcodes()))
|
| 691 |
-
sys.exit()
|
| 692 |
-
def dif4(*T):
|
| 693 |
-
import difflib as dif
|
| 694 |
-
return lfjw(list(dif.unified_diff(*[t.splitlines() for t in T]))[2:])
|
| 695 |
-
def dif32(*T): return dif3(*[t.splitlines() for t in T])
|
| 696 |
-
def dif5(t1,t2, splitlines=str.splitlines):
|
| 697 |
-
import difflib as dif
|
| 698 |
-
f=(dif.SequenceMatcher(None,*[splitlines(t) for t in (t1,t2)]))
|
| 699 |
-
return f.get_opcodes()
|
| 700 |
-
def difri(T,splitlines=fpreturn):
|
| 701 |
-
import difflib as dif
|
| 702 |
-
return (dif.SequenceMatcher(None,*[splitlines(t) for t in T]))
|
| 703 |
-
qfem="""
|
| 704 |
-
; ;;
|
| 705 |
-
: ;c
|
| 706 |
-
\\ ;y
|
| 707 |
-
/ ;l
|
| 708 |
-
" ;d
|
| 709 |
-
? ;q
|
| 710 |
-
< ;k
|
| 711 |
-
> ;r
|
| 712 |
-
| ;s
|
| 713 |
-
* ;a
|
| 714 |
-
"""#
|
| 715 |
-
q_fileEscapeMap={k:v for k,v in [k.split(" ") for k in qfem.split(lf) if k]}
|
| 716 |
-
##q_fileEscapeMap={";":";;",":":";c","\\":";y","/":";l",'"':";d","?":";q"}
|
| 717 |
-
def esfn(fn):#EscapeFileName;x/2
|
| 718 |
-
return orsub(q_fileEscapeMap,fn );
|
| 719 |
-
def exfn(fn):#extract
|
| 720 |
-
return orsub(puni(q_fileEscapeMap).tenchi(),fn);
|
| 721 |
-
time.perf_counter()
|
| 722 |
-
##def clock
|
| 723 |
-
def orbench(p):#BenchMark(Proc)K@milisecond
|
| 724 |
-
t = time.perf_counter()
|
| 725 |
-
tsai = time.perf_counter() - t
|
| 726 |
-
t = time.perf_counter()
|
| 727 |
-
rn=p()
|
| 728 |
-
t = time.perf_counter() -t -tsai;
|
| 729 |
-
return t,rn;
|
| 730 |
-
|
| 731 |
-
def cbbench(f):
|
| 732 |
-
## @functools.wraps(f)
|
| 733 |
-
def cb(*a,**k):
|
| 734 |
-
timeL=time.perf_counter()
|
| 735 |
-
rn2=f(*a,**k)
|
| 736 |
-
rn1=time.perf_counter()-timeL
|
| 737 |
-
return rn1,rn2
|
| 738 |
-
return cb
|
| 739 |
-
def timefor(cb,lis,to,start="start",logfile=""):
|
| 740 |
-
def pr(te): return afdt(logfile or tfolder+"/log for time", te+lf)
|
| 741 |
-
if start: pr(start)
|
| 742 |
-
ti2pre=tia0=ti0=time.perf_counter()
|
| 743 |
-
x9=len(lis)
|
| 744 |
-
for x1,fn in enumerate(lis):
|
| 745 |
-
et=cb(x1, fn, pr)
|
| 746 |
-
## if 1:
|
| 747 |
-
ti2=time.perf_counter()
|
| 748 |
-
eli=(ti2-ti0)
|
| 749 |
-
x1p=x1+1
|
| 750 |
-
ti9=eli/(x1p) * x9
|
| 751 |
-
mean=eli/(x1p)
|
| 752 |
-
one=ti2 - ti2pre
|
| 753 |
-
ti2pre=ti2
|
| 754 |
-
remain=ti9-eli
|
| 755 |
-
if (ti2-tia0) > to[0]:
|
| 756 |
-
te=et+f"({one:.1f}), {x1p}/{x9} , {eli:.1f} / {ti9:.1f}, {remain=:.1f}"
|
| 757 |
-
print(te)
|
| 758 |
-
pr(te)
|
| 759 |
-
tia0=ti2
|
| 760 |
-
if to[1] and eli > to[1]:return
|
| 761 |
-
if et=="return": return et
|
| 762 |
-
|
| 763 |
-
#---------
|
| 764 |
-
def rnz(te,li,opt=re.S|re.I):
|
| 765 |
-
for s,d in li:#src dist;
|
| 766 |
-
## pr(s,"__",d);
|
| 767 |
-
ir=re.compile(s,opt);#DOTALL|IGNORE ##|re.X=VERBOSE
|
| 768 |
-
te=ir.sub(d,te);
|
| 769 |
-
return te
|
| 770 |
-
def rfor(url,li):
|
| 771 |
-
for l in li:
|
| 772 |
-
mo=re.match(l[0],url);
|
| 773 |
-
if mo :return l[1]
|
| 774 |
-
raise Exception ("no such url");
|
| 775 |
-
def sas(reg,te,bug=False,**ww):
|
| 776 |
-
teli=[te]
|
| 777 |
-
#reg=([(re.compile(f[0]),f[1]) for f in f2] for f2 in reg)
|
| 778 |
-
reg=([re.compile(f,re.S) for f in f2] for f2 in reg)
|
| 779 |
-
for ix,(ri,rx) in enumerate(reg):
|
| 780 |
-
li2=[]
|
| 781 |
-
for ta in teli:
|
| 782 |
-
#li2.extend([f for f in ri[0].sub(lambda e:ri[0].sub(ri[1],e), ta) if f])
|
| 783 |
-
li2.extend([f for f in ri.findall(ta) if f])
|
| 784 |
-
teli=li2
|
| 785 |
-
if bug: afdt(r"r:\fjpg-sas.txt","mrk{}\n".format(ix)+ppf(teli))
|
| 786 |
-
return teli
|
| 787 |
-
def traverse(reg,te,bug=False,**ww):
|
| 788 |
-
fn=reg; #fn.teli=[te]
|
| 789 |
-
def fp1(fn,pare,F,after):
|
| 790 |
-
if after:return
|
| 791 |
-
fn.teli=[]
|
| 792 |
-
for ta in pare.teli if pare else [te]:
|
| 793 |
-
rin,rx1,rx2=fn.pat
|
| 794 |
-
li=compilex(rin).findall(ta)
|
| 795 |
-
for t1 in li:
|
| 796 |
-
for rex in rx1:
|
| 797 |
-
if rex.search(t1):continue
|
| 798 |
-
fn.teli.append(t1)
|
| 799 |
-
from mlwebOrWeb import webrap
|
| 800 |
-
## print(fn, f"{fn.flget=}")
|
| 801 |
-
if fn.flget: #fn.teli=[ webrap().gtoff(f,"utf-8") for f in fn.teli]
|
| 802 |
-
li=[]
|
| 803 |
-
for n1,f in enumerate(fn.teli):
|
| 804 |
-
print(f"download {n1+1} / {len(fn.teli)}")
|
| 805 |
-
li.append(webrap().gtoff(f,"utf-8"))
|
| 806 |
-
fn.teli=li
|
| 807 |
-
def mimi(fn):return fn.mimi
|
| 808 |
-
lamrec(fp1,fn, mimi,F=0,pare=None)
|
| 809 |
-
return
|
| 810 |
-
if 0:
|
| 811 |
-
##class reg(re):
|
| 812 |
-
def compile(me,*w):
|
| 813 |
-
try:
|
| 814 |
-
return re.compile(*w)
|
| 815 |
-
except re.error as e:e
|
| 816 |
-
def sub(me,*w):
|
| 817 |
-
try:
|
| 818 |
-
return me.sub(*w)
|
| 819 |
-
except re.error as e:
|
| 820 |
-
e
|
| 821 |
-
compilev=lambda e:re.compile(e,re.S|re.I|re.X|re.M)
|
| 822 |
-
compilevs=lambda e:re.compile(e.replace(" ","\\s*"),re.S|re.I)
|
| 823 |
-
compilex=lambda e:re.compile(e.replace(" ","\\s*"),re.S|re.I|re.X)
|
| 824 |
-
compiled=lambda e:re.compile(e,re.S|re.I)
|
| 825 |
-
compilefn=lambda e:re.compile(e,re.I)
|
| 826 |
-
irealpha=re.compile(r"[_\.a-zA-Z0-9]")
|
| 827 |
-
def adcompile(fp):
|
| 828 |
-
if isinstance(fp,str): return compilevs(fp).search
|
| 829 |
-
if isinstance(fp,re.Pattern): return fp.search
|
| 830 |
-
return fp
|
| 831 |
-
|
| 832 |
-
|
| 833 |
-
|
| 834 |
-
# #-----------
|
| 835 |
-
def tae(p):#TryAndError例外で終了させずに表示する
|
| 836 |
-
try:
|
| 837 |
-
p()
|
| 838 |
-
except Exception as e:
|
| 839 |
-
orro4(e,lf,e.args,lf,type(e));
|
| 840 |
-
return(e)
|
| 841 |
-
def t1t(p): return ttt(p,times=1)
|
| 842 |
-
def ttt(p,times=10,interval=4):# try ten times
|
| 843 |
-
for n in range(times):
|
| 844 |
-
try:
|
| 845 |
-
return p()
|
| 846 |
-
except Exception as e:
|
| 847 |
-
if n+1 >= times: return e
|
| 848 |
-
time.sleep(interval)
|
| 849 |
-
continue
|
| 850 |
-
import th
|
| 851 |
-
cbTryLock=th.Lock()
|
| 852 |
-
def cbTry(f,ercb=None,lo=0,ww=(),pr=0):
|
| 853 |
-
## flq=1 if hasattr(f, "__self__") and isinstance(f.__self__, orq) else 0
|
| 854 |
-
## la=lambda e: a[1:]
|
| 855 |
-
counter=0
|
| 856 |
-
@functools.wraps(f)
|
| 857 |
-
def cb(*a,**k):
|
| 858 |
-
try:
|
| 859 |
-
#return f(**k) if a[flq:] is (False,) else f(*a,**k)
|
| 860 |
-
## print("cb;", a,f,cb)
|
| 861 |
-
#return f(**k) if not a[flq:] or a[flq] is False else f(*a,**k)
|
| 862 |
-
if ww:
|
| 863 |
-
wwa=ww[0]
|
| 864 |
-
www=ww[1] if ww[1:] else {}
|
| 865 |
-
if lo==1:lg("cb", f.__qualname__, a,k,ww)
|
| 866 |
-
return f(*wwa,**k,**www) if not a or a[0] is False else f(*wwa, *a,**k,**www)#pass
|
| 867 |
-
if lo==1:lg("cb", f.__qualname__, a,k)
|
| 868 |
-
return f(**k) if not a or a[0] is False else f(*a,**k) #pass
|
| 869 |
-
##except: except2(0,find="p",edit="npp")
|
| 870 |
-
except Exception as e: # exit is not exception
|
| 871 |
-
#except:
|
| 872 |
-
et=0
|
| 873 |
-
cb.counter+=1
|
| 874 |
-
if cb.counter>10:return
|
| 875 |
-
if ercb: et=cbTry(ercb)(e)
|
| 876 |
-
if et:return
|
| 877 |
-
if pr: print(except2(0,find=""))
|
| 878 |
-
else:
|
| 879 |
-
## with cbTryLock:#?
|
| 880 |
-
except2(0,find="p",edit="note")
|
| 881 |
-
## e2=except2()
|
| 882 |
-
## Mini(te)
|
| 883 |
-
cb.counter=0
|
| 884 |
-
return cb
|
| 885 |
-
|
| 886 |
-
def edipt(te="",find="p",edit=0,fntbl=()):
|
| 887 |
-
if edit:return edipt_edit(te,find,edit,fntbl)
|
| 888 |
-
e2=te or traceback.format_exc()
|
| 889 |
-
e2=e2.replace("Traceback (most recent call last):","-"*9)
|
| 890 |
-
if find:
|
| 891 |
-
if find=="p":
|
| 892 |
-
## mo=compiled((r'(?<= File ")(.*?)", line (\d+), in (.+?)\n(.*?)')).findall(e2)
|
| 893 |
-
mo=compiled((r'(?<= File ")([^\n]+?)", line (\d+)(?:, in )?([^\n]*?)\n((?! File).*?(?=\n))?')).findall(e2)
|
| 894 |
-
mo=[[fppmobile(f) for f in f2] for f2 in mo if not any(((compilex(r"/python|\\Python\\|importlib").search(f2[0])), ("#pass" in f2[-1]) )) ]
|
| 895 |
-
return (fppmobile(omiterror(e2)),mo)
|
| 896 |
-
if find=="node":
|
| 897 |
-
mo=compiled(r'at ([\w\.]* )?\(?(C:.*?):(\d+):(\d+)').findall(e2)
|
| 898 |
-
mo=[[fppmobile(f) for f in f2] for f2 in mo if not any(((compilex(r"/python|\\Python\\|importlib").search(f2[0])), ("//pass" in f2[-1]) )) ]
|
| 899 |
-
mo=[[w[f] for f in (1,2,0,3)] for w in mo]
|
| 900 |
-
return (fppmobile(omiterror(e2)),mo)
|
| 901 |
-
if 0:
|
| 902 |
-
mo=re.findall(r'"<string>", line (\d+)(), in <module>\n(.*)',e2)
|
| 903 |
-
return mo
|
| 904 |
-
return fppmobile(omiterror(e2))
|
| 905 |
-
except2=edipt
|
| 906 |
-
def edipt_edit(te,find,edit=0,fntbl=()):
|
| 907 |
-
e2=edipt(te,find=find)
|
| 908 |
-
t1=e2[0].splitlines().pop()
|
| 909 |
-
if "dialog rejected;" in t1: return
|
| 910 |
-
if "SystemExit" in t1: return
|
| 911 |
-
from qNote1 import iniap, Mini, clhk
|
| 912 |
-
from dialog_ import orDialog
|
| 913 |
-
app=iniap()
|
| 914 |
-
mono=orDialog()
|
| 915 |
-
if not e2[1]: return Mini(e2)
|
| 916 |
-
if find=="p":
|
| 917 |
-
mo=[clhk(f, teh=(f"({cfile(f[0])}), {f[1]}, {f[2]}, \n{f[3]}")) for f in e2[1]]
|
| 918 |
-
if find=="node":
|
| 919 |
-
mo=[clhk(f, teh=(f"({cfile(f[0])}), {f[1]}, {f[2]}")) for f in e2[1]]
|
| 920 |
-
if (mf:=re.search("AssertionError: (.*)", e2[0])): mo=[clhk("*", teh=mf.group(1))]+mo
|
| 921 |
-
whw=[mo+[e2[0]]]
|
| 922 |
-
mono.xch(whw)
|
| 923 |
-
if not mono.fiFiles:return
|
| 924 |
-
fn,*_=mono.pickupli()
|
| 925 |
-
if type(fn)==str:return e2
|
| 926 |
-
(fn,pos,mod,te)=fn
|
| 927 |
-
if fn in fntbl: fn=fntbl[fn]
|
| 928 |
-
print(fn,fntbl)
|
| 929 |
-
#npp(fn,f"-n{pos}")
|
| 930 |
-
orPOA([HeartNote, fn, "-pos",pos,"0"])
|
| 931 |
-
return e2
|
| 932 |
-
def omiterror(e2):
|
| 933 |
-
return rnz(e2,(
|
| 934 |
-
("NameError: name",""),
|
| 935 |
-
))
|
| 936 |
-
def mpvstring(e2):
|
| 937 |
-
#t1=e2.splitlines().pop()
|
| 938 |
-
e2=re.sub(r'Traceback .+?\n','',e2)
|
| 939 |
-
e2=re.sub(r' File "C:\\cpy\\qt\\(?:clas\\)?(.+?)(?:\.pyw?)", line (\d+),',r'"\1",\2',e2)
|
| 940 |
-
if "mpv property does not exist" in te:
|
| 941 |
-
if(mo:=re.search(r"'(mpv property does not exist)',.*?b('.*?'),",te)): te=str(mo.groups())
|
| 942 |
-
else: te="mpv not exist"
|
| 943 |
-
## te=rnz(te,(
|
| 944 |
-
## (r"'(mpv property does not exist)',.*?b('.*?'),",r"\1 \2"),
|
| 945 |
-
## (r"\d+",""),
|
| 946 |
-
## ))
|
| 947 |
-
def orpopen(mp3):
|
| 948 |
-
import subprocess as p
|
| 949 |
-
return p.Popen([mp3],shell=True);
|
| 950 |
-
def orPOA(cmd,shell=True):
|
| 951 |
-
import subprocess as p
|
| 952 |
-
return p.Popen(cmd,shell=shell);
|
| 953 |
-
def popen1(cmd,shell=True):
|
| 954 |
-
import subprocess as p
|
| 955 |
-
return p.Popen(cmd,shell=shell).wait()
|
| 956 |
-
##orPOA(r'start cmd /c "r:\c f.bat"')
|
| 957 |
-
def wiff(w):
|
| 958 |
-
orPOA([ordiMdirs()["wiff"],*w])
|
| 959 |
-
def npp(*w):
|
| 960 |
-
if not w: return ordiMdirs()["npp"]
|
| 961 |
-
orPOA([ordiMdirs()["npp"],*w])
|
| 962 |
-
def nppw(lis,fn=tfolder+"/log"):
|
| 963 |
-
wfd(fn).t(lis)
|
| 964 |
-
npp(fn)
|
| 965 |
-
class puni(dict):
|
| 966 |
-
## def update(zl,k,v): dict.update(zl,[(k,v)])
|
| 967 |
-
def ez(zl,k):#di.get()
|
| 968 |
-
return zl[k] if(k in zl) else 0;
|
| 969 |
-
def ud(zl,k,v):
|
| 970 |
-
zl.update([(k,v)]);
|
| 971 |
-
def up(zl,k,L):#update append
|
| 972 |
-
if(k in zl):
|
| 973 |
-
zl[k].append(L);
|
| 974 |
-
else:
|
| 975 |
-
zl.update([(k,[L])]);
|
| 976 |
-
def uni(zl,k,L):#update append uni
|
| 977 |
-
if(k in zl and L not in zl[k]):
|
| 978 |
-
zl[k].append(L);
|
| 979 |
-
else:
|
| 980 |
-
zl.update([(k,[L])]);
|
| 981 |
-
def setclr(zl,li,la):
|
| 982 |
-
for nc,f in enumerate(li):
|
| 983 |
-
k=la(f)
|
| 984 |
-
zl.up(k,f)
|
| 985 |
-
return zl
|
| 986 |
-
def updateIncliment(zl,k):
|
| 987 |
-
zl.ul(k,1)
|
| 988 |
-
def ul(zl,k,L):#update vz Length
|
| 989 |
-
if(k in zl):
|
| 990 |
-
zl[k]+=L;
|
| 991 |
-
else:
|
| 992 |
-
zl[k]=L
|
| 993 |
-
def us(zl,k):#文字ごとの生起確率
|
| 994 |
-
for c in k:
|
| 995 |
-
zl.ui(c);
|
| 996 |
-
return zl;
|
| 997 |
-
## def counter(zl,w):
|
| 998 |
-
def Clip(zl,count,regexpattern="."):
|
| 999 |
-
"Clip key less than count"
|
| 1000 |
-
ire=re.compile(regexpattern)
|
| 1001 |
-
return puni([(k,v) for k,v in zl.items() if(v>count)and(ire.match(k))])
|
| 1002 |
-
def LetterFrequency(zl,te,llen=2):
|
| 1003 |
-
for k in range(len(te)-llen+1):
|
| 1004 |
-
zl.ui(te[k:k+llen])
|
| 1005 |
-
return zl;
|
| 1006 |
-
def sortedlist(zl):#oredered list by value;
|
| 1007 |
-
return [[k,v] for k, v in sorted(zl.items(), key=lambda x:x[1])]
|
| 1008 |
-
def olal(zl):#appended length
|
| 1009 |
-
tl={k:len(v) for k,v in zl.items()}
|
| 1010 |
-
return puni.ol(tl);
|
| 1011 |
-
def ok(zl):#oredered list by key;
|
| 1012 |
-
return [[k,v] for k, v in sorted(zl.items(), key=lambda x:x[0])]
|
| 1013 |
-
def ovk(zl,valuekey):#sort by appended list
|
| 1014 |
-
pass
|
| 1015 |
-
def tenchi(zl):
|
| 1016 |
-
li={v:k for k,v in zl.items()}
|
| 1017 |
-
## li=map(lambda x: x,li);
|
| 1018 |
-
return li;
|
| 1019 |
-
d=puni()
|
| 1020 |
-
for k,v in zl.items():
|
| 1021 |
-
d[v]=k;
|
| 1022 |
-
return d;#X/2
|
| 1023 |
-
def xemj(zl,vn="v"):#moji for exec,Video
|
| 1024 |
-
tef="";
|
| 1025 |
-
for k in zl.keys():
|
| 1026 |
-
tei="%s=%s[%s];"%(k,vn,repr(k));#tei=k+"="++";";
|
| 1027 |
-
tef+=tei;
|
| 1028 |
-
return tef;
|
| 1029 |
-
def rms(zl,la):
|
| 1030 |
-
pops={k:v for k,v in zl.items() if la(k,v)}
|
| 1031 |
-
_=[zl.pop(k) for k in pops]
|
| 1032 |
-
return zl,pops
|
| 1033 |
-
#listDict
|
| 1034 |
-
def lipop(zl,k,cb):
|
| 1035 |
-
for k,v in zl.items():
|
| 1036 |
-
for n,v1 in enumerate(v):
|
| 1037 |
-
if(cb(v1)):return k,n
|
| 1038 |
-
def lipop1(zl,f,te):
|
| 1039 |
-
#{f,[[open,],[file,],[copy,],]};findcopy():lipop(f,"copy")
|
| 1040 |
-
return zl.lipop(f,lambda e: e[0]==te)
|
| 1041 |
-
## def compres(zl,w0,fp=fpreturn,uni=0):
|
| 1042 |
-
## for f in w0:
|
| 1043 |
-
## zl.compresin(f,fp)
|
| 1044 |
-
## return zl
|
| 1045 |
-
def compres(zl,f,fp=fpreturn,uni=0,te=""):#配列の長さは同じにする
|
| 1046 |
-
z2=zl
|
| 1047 |
-
if 1:
|
| 1048 |
-
z2=zl
|
| 1049 |
-
for w in f[:-1]:
|
| 1050 |
-
w=fp(w)
|
| 1051 |
-
if w not in z2: z2[w]=puni()
|
| 1052 |
-
z2=z2[w]
|
| 1053 |
-
assert isinstance(z2,puni), "not list len"#,f
|
| 1054 |
-
if te:
|
| 1055 |
-
assert f[-1] not in z2, "not list len. 123 12"#,f
|
| 1056 |
-
z2[f[-1]]=te
|
| 1057 |
-
else:
|
| 1058 |
-
z2.ul(f[-1],1)
|
| 1059 |
-
return z2[f[-1]]
|
| 1060 |
-
def flat(zl):
|
| 1061 |
-
li=[((x,),v) for x,v in zl.items()]
|
| 1062 |
-
for p,v in li:
|
| 1063 |
-
if isinstance(v,puni):
|
| 1064 |
-
li.extend(((*p,p2),v2) for p2,v2 in v.items())
|
| 1065 |
-
else:
|
| 1066 |
-
yield (*p,v)
|
| 1067 |
-
class pini(puni):
|
| 1068 |
-
def __init__(zl,d={},fn="pini00.ini"):
|
| 1069 |
-
dict.__init__(zl,d);
|
| 1070 |
-
zl.fn=lfn.abspath(fn);
|
| 1071 |
-
if lfn.isfile(fn):
|
| 1072 |
-
f=rfdv0(fn,["utf-8"])
|
| 1073 |
-
for j in f:
|
| 1074 |
-
a=j.split("\t");
|
| 1075 |
-
## try:
|
| 1076 |
-
## nm=float(a[1])
|
| 1077 |
-
## except:
|
| 1078 |
-
## pass;
|
| 1079 |
-
if(len(a)== 2):
|
| 1080 |
-
## exete='zl["%s"]=' % a[0]#.replace("\\","\\\\");
|
| 1081 |
-
exete='zl[%s]=' % a[0]#.replace("\\","\\\\");
|
| 1082 |
-
et2= exete+a[1];
|
| 1083 |
-
exec(et2);
|
| 1084 |
-
else:
|
| 1085 |
-
notTheFormat
|
| 1086 |
-
def save(zl):
|
| 1087 |
-
te="";
|
| 1088 |
-
#print(os.getcwd())
|
| 1089 |
-
for f,v in fpn1(zl):
|
| 1090 |
-
ti= repr(f) +"\t" +repr(v)+"\n";
|
| 1091 |
-
te+=ti;
|
| 1092 |
-
wfd8(zl.fn,te);#Exceptions during cleanup are always ignored; see the object.__del__() documentation:
|
| 1093 |
-
## deli=__del__#for
|
| 1094 |
-
##class lazy:1
|
| 1095 |
-
##diMdirs=None
|
| 1096 |
-
def ordiMdirs():# Dictionary of Directory
|
| 1097 |
-
global diMdirs
|
| 1098 |
-
diMdirs=globals().get("diMdirs") or dict([j.split("\t")[:2] for j in wfd(os.environ["cpa"]+r"\data\dirs-{}.txt".format(T45)).r(lines=True) if j[:2]])
|
| 1099 |
-
return diMdirs
|
| 1100 |
-
def mdir(f): return ordiMdirs()[f]
|
| 1101 |
-
#
|
| 1102 |
-
def fFlat(li,lirn):
|
| 1103 |
-
if(type(li)==list):
|
| 1104 |
-
for j in li:
|
| 1105 |
-
r1=fFlat(j,lirn)
|
| 1106 |
-
## lirn.extend(r1)
|
| 1107 |
-
else:
|
| 1108 |
-
r1=li
|
| 1109 |
-
lirn.append(r1)
|
| 1110 |
-
return lirn
|
| 1111 |
-
class List(list):
|
| 1112 |
-
def rx(zl,te):
|
| 1113 |
-
ir1=re.compile(te)
|
| 1114 |
-
zl.res=[]
|
| 1115 |
-
for i,j in enumerate(zl):
|
| 1116 |
-
mo=ir1.search(j)
|
| 1117 |
-
if mo:
|
| 1118 |
-
zl.res.append(j)
|
| 1119 |
-
return zl.res
|
| 1120 |
-
def rxenu(zl,te):
|
| 1121 |
-
ir1=re.compile(te)
|
| 1122 |
-
zl.res=[]
|
| 1123 |
-
for i,j in enumerate(zl):
|
| 1124 |
-
mo=ir1.search(j)
|
| 1125 |
-
if mo:
|
| 1126 |
-
zl.res.append((i,j))
|
| 1127 |
-
return zl.res
|
| 1128 |
-
def __lt__(zl,f): return zl.append(f)
|
| 1129 |
-
def __lshift__(zl,li): return zl.extend(li)
|
| 1130 |
-
#def __getitem__(zl,f):
|
| 1131 |
-
def getx(zl,f,v):
|
| 1132 |
-
return zl.index(f) if f in zl else v
|
| 1133 |
-
def u(zl,f,v):
|
| 1134 |
-
zl[zl.index(f)]=v
|
| 1135 |
-
## def up(zl,v):
|
| 1136 |
-
orList=List
|
| 1137 |
-
class ListHash(List):#from collections import OrderedDict
|
| 1138 |
-
def put(zl,k,v):#up
|
| 1139 |
-
1
|
| 1140 |
-
class orLiset(set):#unique list
|
| 1141 |
-
pass
|
| 1142 |
-
def cmp(zl,ot):
|
| 1143 |
-
zl.cmp[x](zl[y],ot)
|
| 1144 |
-
## if(role=="cmp"):split(sel)
|
| 1145 |
-
def get(zl,x,y,role="edit"):
|
| 1146 |
-
return zl[y][x]
|
| 1147 |
-
class LastOperation(List):
|
| 1148 |
-
def __init__(zl,li=(),threshold=30,wriIni=False,k="",uniq=True):
|
| 1149 |
-
zl.threshold=threshold
|
| 1150 |
-
zl.see=-1
|
| 1151 |
-
zl.uniq=uniq
|
| 1152 |
-
if(wriIni):#dict.setdefault()
|
| 1153 |
-
if(k in wriIni):
|
| 1154 |
-
li=wriIni[k]
|
| 1155 |
-
list.__init__(zl,li)
|
| 1156 |
-
wriIni[k]=zl
|
| 1157 |
-
else:
|
| 1158 |
-
list.__init__(zl,li)
|
| 1159 |
-
def rm(zl,te):
|
| 1160 |
-
if zl.uniq and (te in zl):
|
| 1161 |
-
zl.pop(zl.index(te))
|
| 1162 |
-
def ap(zl,te):
|
| 1163 |
-
if zl.uniq and (te in zl):
|
| 1164 |
-
zl._ap(zl.pop(zl.index(te)))
|
| 1165 |
-
else:
|
| 1166 |
-
if(len(zl)>=zl.threshold):zl.pop()
|
| 1167 |
-
zl._ap(te)
|
| 1168 |
-
zl.see=0
|
| 1169 |
-
def aprx(zl,te):#Word completion
|
| 1170 |
-
if zl.uniq and (zl.get(te)):
|
| 1171 |
-
zl._ap(zl.pop(zl.res[0][0]))
|
| 1172 |
-
else:
|
| 1173 |
-
if(len(zl)>=zl.threshold):zl.pop()
|
| 1174 |
-
zl._ap(te)
|
| 1175 |
-
zl.see=0
|
| 1176 |
-
## def _ap(zl,element):
|
| 1177 |
-
## zl.insert(0,element)
|
| 1178 |
-
_ap=lambda zl,x:zl.insert(0,x)
|
| 1179 |
-
def get(zl,te):
|
| 1180 |
-
r=zl.rxenu(te)
|
| 1181 |
-
return r[0]
|
| 1182 |
-
def up(zl):
|
| 1183 |
-
if(len(zl)-1>zl.see):
|
| 1184 |
-
zl.see+=1
|
| 1185 |
-
return zl[zl.see]
|
| 1186 |
-
def down(zl):
|
| 1187 |
-
if(zl.see>0):
|
| 1188 |
-
zl.see-=1
|
| 1189 |
-
return zl[zl.see]
|
| 1190 |
-
clHistry=LastOperation
|
| 1191 |
-
##class cycle():
|
| 1192 |
-
class orLog(LastOperation):
|
| 1193 |
-
def __call__(zl,*w):
|
| 1194 |
-
if(len(zl)>=zl.threshold):zl.pop(0)
|
| 1195 |
-
zl.append((w[0],w[1:]))
|
| 1196 |
-
return zl
|
| 1197 |
-
def __repr__(zl):
|
| 1198 |
-
if not zl: return "[]"
|
| 1199 |
-
rn=[f[1] for f in zl.find(zl[-1][0])]#findByLastKey
|
| 1200 |
-
return str(rn)
|
| 1201 |
-
def find(zl,pat):
|
| 1202 |
-
ir1=re.compile(str(pat))
|
| 1203 |
-
rn= [f for f in zl if ir1.search(str(f[0]))]
|
| 1204 |
-
return rn
|
| 1205 |
-
imorLog=orLog(threshold=32100)
|
| 1206 |
-
##logi=lambda *x:imorLog.ap(x[0],x[1:])
|
| 1207 |
-
lg=logi=imorLog
|
| 1208 |
-
lgf=logifind=lambda x="":imorLog.find(x)
|
| 1209 |
-
lgfv=lgf2=lambda x="":[f[1] for f in imorLog.find(x)]# value
|
| 1210 |
-
lglf=lambda x:jw(lf,[jw(" ",[str(f) for f in l]) for l in lgfv(x)])
|
| 1211 |
-
##jw(lf,[l for l in lgfv(x)])
|
| 1212 |
-
lgc=lambda: imorLog.clear()
|
| 1213 |
-
def msri(proc,lp):#mashiroInner
|
| 1214 |
-
fil = sys.argv
|
| 1215 |
-
if(len(fil) == 1):
|
| 1216 |
-
pr("please drop off the file");input();exit()
|
| 1217 |
-
for fi in fil[1:]:
|
| 1218 |
-
proc(fi,lp);
|
| 1219 |
-
mashiro=msri;
|
| 1220 |
-
gif=r"(jpg|jpeg|png|gif|tiff|jfif|webp)$"
|
| 1221 |
-
ignoreFiles=(r"R:\TEMP",r"R:\Clip1.txt.txt",r"R:\OnClipChange1.txt",r"R:\Recycled",r'R:\System Volume Information')
|
| 1222 |
-
def listdir(r=None,iref="",walk=False,flat=False,isdir=False):
|
| 1223 |
-
"f in listdir() if not(f in ignoreFiles)"
|
| 1224 |
-
assert ifexist(r or "."),r
|
| 1225 |
-
if type(iref)==str:iref=re.compile(iref,re.I).search
|
| 1226 |
-
li=[(jofn(r,f) if flat else f) for f in (os.listdir(r) if not walk else walky(r)) if ((os.path.abspath(jofn(r or "",f)) not in ignoreFiles) and (iref(f)))]
|
| 1227 |
-
if isdir: li=[f for f in li if isdir(jofn(r,f) if r else f)]
|
| 1228 |
-
return li
|
| 1229 |
-
def walky(r):
|
| 1230 |
-
for p, ds ,fs in os.walk(r):
|
| 1231 |
-
for fn in ds+fs:
|
| 1232 |
-
yield jofn(p,fn)
|
| 1233 |
-
def unfoldfiles(ars,ap=False):
|
| 1234 |
-
for fn in ars:
|
| 1235 |
-
if os.path.isfile(fn):
|
| 1236 |
-
fn
|
| 1237 |
-
else:
|
| 1238 |
-
lifn=walky(fn)
|
| 1239 |
-
for fn in lifn:
|
| 1240 |
-
fn
|
| 1241 |
-
def orWalk(d,proc,lp):#CallBackWalk
|
| 1242 |
-
waw = os.walk(ddf[0])
|
| 1243 |
-
for r, ds ,fs in waw:
|
| 1244 |
-
mod=ddf[2].search(r)
|
| 1245 |
-
if mod :#除外子孫のフォルダをさらに(被除外リスト)出力からも除外
|
| 1246 |
-
lidex.append(r);
|
| 1247 |
-
else:
|
| 1248 |
-
ldir=[]
|
| 1249 |
-
for fc in fs:
|
| 1250 |
-
ldir.append(fc)
|
| 1251 |
-
orcb(ldir,r,ddf)
|
| 1252 |
-
def rnWalk(d,inc,exc):
|
| 1253 |
-
irInc=[re.compile(f,re.I) for f in inc]
|
| 1254 |
-
irExc=[re.compile(f,re.I) for f in exc]
|
| 1255 |
-
lii=[]
|
| 1256 |
-
for r, ds ,fs in os.walk(d):
|
| 1257 |
-
dsfs=ds+fs
|
| 1258 |
-
for fn in dsfs:
|
| 1259 |
-
for ire in irInc:
|
| 1260 |
-
mod=ire.search(fn)
|
| 1261 |
-
if mod :
|
| 1262 |
-
lii.append((r,fn));
|
| 1263 |
-
break
|
| 1264 |
-
for k,(r,fn) in enumerate(lii):
|
| 1265 |
-
for ire in irExc:
|
| 1266 |
-
mod=ire.search(fn)
|
| 1267 |
-
if mod :
|
| 1268 |
-
lii.pop(k);
|
| 1269 |
-
break
|
| 1270 |
-
return lii
|
| 1271 |
-
def ywalk(dn=None,dr=0,pop=-1):
|
| 1272 |
-
ds=[dn or os.getcwd()]
|
| 1273 |
-
while 1:
|
| 1274 |
-
cd=ds.pop(pop)
|
| 1275 |
-
ag=os.listdir(cd)
|
| 1276 |
-
if dr: ag=ag[::dr]
|
| 1277 |
-
for f in ag: yield cd,ag,jofn(cd,f)
|
| 1278 |
-
else:# not break return
|
| 1279 |
-
ds+=[fp for f in ag if os.path.isdir(fp:=jofn(cd,f))]
|
| 1280 |
-
if not ds : break
|
| 1281 |
-
continue
|
| 1282 |
-
break
|
| 1283 |
-
while 0:
|
| 1284 |
-
sn=hhwr(dn=listdir(r"c:\v\t",iref=isdir)[0])
|
| 1285 |
-
dnd=os.path.dirname(sn.dn)
|
| 1286 |
-
if(dnd in [r"c:\v"]): break
|
| 1287 |
-
for cd,fs,fp in ywalk(dnd):
|
| 1288 |
-
pass
|
| 1289 |
-
li=(list(listdir(dnd,iref=isdir)))
|
| 1290 |
-
ix=li.index(os.path.basename(sn.dn))
|
| 1291 |
-
##prexit([f for f in ywalk(r"c:\v\t")])
|
| 1292 |
-
def nxDir(fn,ceil,fs=0,dr=1):
|
| 1293 |
-
for n in range(9):
|
| 1294 |
-
dn=lfnd(fn)
|
| 1295 |
-
if dn in ceil:
|
| 1296 |
-
return
|
| 1297 |
-
fs=listdir(dn,flat=1)
|
| 1298 |
-
if fn == fs[-dr]:# -1 | 0 # last sister
|
| 1299 |
-
fn=dn
|
| 1300 |
-
else:
|
| 1301 |
-
if not dr: fs.reverse()
|
| 1302 |
-
for nxf in fs[fs.index(fn)+1:]:
|
| 1303 |
-
fn=jofn(dn, fs[fs.index(fn)+1])
|
| 1304 |
-
if os.path.isfile(fn):
|
| 1305 |
-
yield fn
|
| 1306 |
-
else:
|
| 1307 |
-
for cd, ag, fnw in ywalk(fn,dr=0 if dr else -1):
|
| 1308 |
-
yield fnw
|
| 1309 |
-
def nxfortst(*a):
|
| 1310 |
-
for n,f in enumerate(nxDir(*a,dr=1)):
|
| 1311 |
-
print(n,f)
|
| 1312 |
-
##prexit("nxfor:",nxfortst(r"C:\v\T\eva7\cover\..jpeg",(r"C:\v",)))
|
| 1313 |
-
def merge(li,fl="f"):
|
| 1314 |
-
l4=orList()
|
| 1315 |
-
for f1,f2 in li:
|
| 1316 |
-
if not f1.endswith("\\"): f1+="\\"
|
| 1317 |
-
li1=[f[len(f1):] for f in listdir(f1,walk=1)][::-1]
|
| 1318 |
-
for fe in li1:
|
| 1319 |
-
src=jofn(f1,fe)
|
| 1320 |
-
dst=jofn(f2,fe)
|
| 1321 |
-
assert dst.startswith(f2),(f1,f2,fe,dst)
|
| 1322 |
-
inidi(lfnd(dst))
|
| 1323 |
-
if isdir(src):
|
| 1324 |
-
inidi(dst)
|
| 1325 |
-
else:
|
| 1326 |
-
copy=1
|
| 1327 |
-
if ifexist(dst):
|
| 1328 |
-
copy=0
|
| 1329 |
-
if "f" in fl:# force, modi
|
| 1330 |
-
copy=1
|
| 1331 |
-
elif "m" in fl and (mtime(src)-mtime(dst) > 1):
|
| 1332 |
-
copy=1
|
| 1333 |
-
if copy:
|
| 1334 |
-
l4<(fe)
|
| 1335 |
-
shutil.copy2(src, dst)
|
| 1336 |
-
return l4
|
| 1337 |
-
#prexit(merge([[r"C:\v\T\lvlv",r"r:\hono"]],"m"))
|
| 1338 |
-
def listDrive(ignore="ABD"):
|
| 1339 |
-
return [L for L in (chr(c) for c in range(65,90+1)) if os.path.exists(L+':') and (L)not in ignore]
|
| 1340 |
-
def getFolderSize(folder):
|
| 1341 |
-
total_size = 0 #os.path.getsize(folder)#4096
|
| 1342 |
-
for item in os.listdir(folder):
|
| 1343 |
-
itempath = jofn(folder, item)
|
| 1344 |
-
if os.path.isfile(itempath):
|
| 1345 |
-
total_size += os.path.getsize(itempath)
|
| 1346 |
-
elif os.path.isdir(itempath):
|
| 1347 |
-
total_size += getFolderSize(itempath)
|
| 1348 |
-
return total_size
|
| 1349 |
-
def lamrec(fp1,fn, fpEnum,F=0,pare=None):
|
| 1350 |
-
fp1(fn,pare,F,0)
|
| 1351 |
-
#print(" "*F, fn)
|
| 1352 |
-
for f2 in fpEnum(fn):
|
| 1353 |
-
lamrec(fp1,f2, fpEnum,F+1,fn)
|
| 1354 |
-
fp1(fn,pare,F,1)
|
| 1355 |
-
|
| 1356 |
-
def abSize(size,M="",_1024=1024):# 1234 > 1,234
|
| 1357 |
-
# return f"{size:,}"
|
| 1358 |
-
li=[];mb=""
|
| 1359 |
-
for heavy in "KMGTE":
|
| 1360 |
-
m= size % _1024
|
| 1361 |
-
size= size // _1024
|
| 1362 |
-
li.append(m)
|
| 1363 |
-
if(heavy==M):
|
| 1364 |
-
li=[]
|
| 1365 |
-
mb=M
|
| 1366 |
-
if(size):mb
|
| 1367 |
-
else: break
|
| 1368 |
-
return jw(",",("{:03}".format(f) for f in li[::-1])).lstrip("0")+mb
|
| 1369 |
-
##prexit(_:=(1,2026,3,4) ,abSize(sum([1024**n*f for n,f in enumerate(_[::-1])]),"K"))#
|
| 1370 |
-
def crbs(li):
|
| 1371 |
-
def binarySearchRec(goal,q0,q1,fpSave):
|
| 1372 |
-
mid = q0+(q1-q0)/2
|
| 1373 |
-
if q0>q1: return
|
| 1374 |
-
size=fpSave(mid)
|
| 1375 |
-
if goal == size:
|
| 1376 |
-
return mid
|
| 1377 |
-
elif goal > size:
|
| 1378 |
-
return binarySearchRec(goal,mid+1,q1,fpSave)
|
| 1379 |
-
else:
|
| 1380 |
-
return binarySearchRec(goal,q0,mid-1,fpSave)
|
| 1381 |
-
return binarySearchRec
|
| 1382 |
-
def binarySearch(fpSave,goal,q0,q1,li):
|
| 1383 |
-
while q0<=q1:
|
| 1384 |
-
mid = int(q0+(q1-q0)/2)
|
| 1385 |
-
size=fpSave(mid)
|
| 1386 |
-
li.append((mid,size))
|
| 1387 |
-
if(goal == size):
|
| 1388 |
-
return li#mid
|
| 1389 |
-
elif goal > size:
|
| 1390 |
-
q0 = mid + 1
|
| 1391 |
-
else:
|
| 1392 |
-
q1 = mid - 1
|
| 1393 |
-
if 0:
|
| 1394 |
-
mid = (q0+(q1-q0)/2)
|
| 1395 |
-
size=fpSave(mid)
|
| 1396 |
-
li.append((mid,size))
|
| 1397 |
-
return li
|
| 1398 |
-
##print(binarySearch(lambda e:e*100,501,0,20,[]))
|
| 1399 |
-
def mvvideo(src,vfl,suffix):#VideoFolder,拡張子
|
| 1400 |
-
ire = re.compile(suffix,re.I)
|
| 1401 |
-
files = os.listdir(src)
|
| 1402 |
-
count=0
|
| 1403 |
-
for f in files:
|
| 1404 |
-
mo= ire.match(f)
|
| 1405 |
-
if(mo):
|
| 1406 |
-
sfi= src+"\\"+f;
|
| 1407 |
-
vfi= vfl+"\\"+f;
|
| 1408 |
-
#print(vfi,sfi)
|
| 1409 |
-
os.rename(sfi,vfi)
|
| 1410 |
-
count+=1;
|
| 1411 |
-
return count;
|
| 1412 |
-
def mvdir(src,vfl,suffix):#VideoFolder,拡張子
|
| 1413 |
-
ire = re.compile(suffix,re.I)
|
| 1414 |
-
files = os.walk(src)
|
| 1415 |
-
count=0
|
| 1416 |
-
for r,ds,fs in files:
|
| 1417 |
-
for f in ds:
|
| 1418 |
-
mo= ire.match(f)
|
| 1419 |
-
if(mo):
|
| 1420 |
-
sfi= r+"\\"+f;
|
| 1421 |
-
vfi= vfl+"\\"+f;
|
| 1422 |
-
#print(vfi,sfi)
|
| 1423 |
-
try:
|
| 1424 |
-
os.rename(sfi,vfi)
|
| 1425 |
-
except a as XP:
|
| 1426 |
-
pass
|
| 1427 |
-
count+=1;
|
| 1428 |
-
return count;
|
| 1429 |
-
def copyTree(src,dist,pat):
|
| 1430 |
-
pass
|
| 1431 |
-
def nxnum(WorkDir,fn):#Create sequencial number filename 001~99999
|
| 1432 |
-
'r=nxnum(".","%sx.jpg")'
|
| 1433 |
-
pat=fn%r"(\d{1,3})"
|
| 1434 |
-
ire=re.compile(pat);
|
| 1435 |
-
xmax=0;
|
| 1436 |
-
for n in os.listdir(WorkDir):
|
| 1437 |
-
mo=ire.search(n);
|
| 1438 |
-
if mo:
|
| 1439 |
-
m1=mo.group(1)
|
| 1440 |
-
xi = int(m1)
|
| 1441 |
-
if(xmax < xi):
|
| 1442 |
-
xmax = xi
|
| 1443 |
-
xmax+=1
|
| 1444 |
-
rr = str(xmax).zfill(3);
|
| 1445 |
-
rr=fn%rr;
|
| 1446 |
-
return rr;
|
| 1447 |
-
def nxnu2m(WorkDir,fn,nZfill=3):
|
| 1448 |
-
ire=re.compile(re.escape(fn)%r"(\d{1,})");
|
| 1449 |
-
xmax=max([0]+[int(mo.group(1)) for mo in [ire.search(f) for f in os.listdir(WorkDir)] if mo])
|
| 1450 |
-
rr = str(xmax+1).zfill(nZfill);
|
| 1451 |
-
rr=fn%rr;
|
| 1452 |
-
return rr;
|
| 1453 |
-
def nxNumFull(WorkDir,fn,nZfill=3):#return FullPath
|
| 1454 |
-
resFn=nxnu2m(WorkDir,fn,nZfill=nZfill)
|
| 1455 |
-
return jofn(WorkDir,resFn)
|
| 1456 |
-
def nxNumFullSplit(fn,nZfill=3):#FullPath
|
| 1457 |
-
resFn=nxnu2m(*os.path.split(fn),nZfill=nZfill)
|
| 1458 |
-
return jofn(os.path.split(fn)[0],resFn)
|
| 1459 |
-
#
|
| 1460 |
-
montail=(0,31,28,31,30,31,30 ,31,31,30,31,30,31)
|
| 1461 |
-
import csv
|
| 1462 |
-
class oc:#orcsv
|
| 1463 |
-
ordelimiter="\t"
|
| 1464 |
-
def wcsw(fn,li):
|
| 1465 |
-
for code in ("cp932","utf-16"):
|
| 1466 |
-
try:
|
| 1467 |
-
with open(fn, 'w',encoding=code) as fpw:
|
| 1468 |
-
writer = csv.writer(fpw, delimiter=oc.ordelimiter, lineterminator='\n')
|
| 1469 |
-
for f in li:#
|
| 1470 |
-
writer.writerow(f);
|
| 1471 |
-
break
|
| 1472 |
-
except UnicodeEncodeError as XP:
|
| 1473 |
-
continue;
|
| 1474 |
-
def writecs8(fn,li):
|
| 1475 |
-
return wcsv(fn,li,("cp932","utf-8"))
|
| 1476 |
-
def wcsv(fn,li,cs=("utf-8",)):
|
| 1477 |
-
for code in cs:
|
| 1478 |
-
try:
|
| 1479 |
-
with open(fn, 'w',encoding=code) as fpw:
|
| 1480 |
-
writer = csv.writer(fpw, delimiter=oc.ordelimiter, lineterminator='\n')
|
| 1481 |
-
for f in li:#
|
| 1482 |
-
writer.writerow(f);
|
| 1483 |
-
break
|
| 1484 |
-
except UnicodeEncodeError as XP:
|
| 1485 |
-
continue;
|
| 1486 |
-
def acsw(fn,li,code="cp932"):
|
| 1487 |
-
with open(fn, 'a',encoding=code) as fpw:
|
| 1488 |
-
writer = csv.writer(fpw, delimiter=oc.ordelimiter, lineterminator='\n')
|
| 1489 |
-
for f in li:#
|
| 1490 |
-
writer.writerow(f);
|
| 1491 |
-
def acswvp84n534983v(fn,li):
|
| 1492 |
-
for code in ("cp932","utf-16"):#No good
|
| 1493 |
-
try:
|
| 1494 |
-
with open(fn, 'a',encoding=code) as fpw:
|
| 1495 |
-
writer = csv.writer(fpw, delimiter=oc.ordelimiter, lineterminator='\n')
|
| 1496 |
-
for f in li:#
|
| 1497 |
-
writer.writerow(f);
|
| 1498 |
-
break
|
| 1499 |
-
except UnicodeEncodeError as XP:
|
| 1500 |
-
continue;
|
| 1501 |
-
def rcsr(fn):
|
| 1502 |
-
for code in ("utf-8",):#("cp932","utf-8","utf-8"):
|
| 1503 |
-
try:
|
| 1504 |
-
lines =[];
|
| 1505 |
-
with open(fn, 'r',encoding=code, newline='') as fpr:
|
| 1506 |
-
reader = csv.reader(fpr, delimiter=oc.ordelimiter, lineterminator='\n')
|
| 1507 |
-
for line in reader:
|
| 1508 |
-
## print(line)
|
| 1509 |
-
lines.append(line);
|
| 1510 |
-
return lines;
|
| 1511 |
-
except UnicodeDecodeError as XP:
|
| 1512 |
-
continue;
|
| 1513 |
-
#list(csv.reader(['"-f" 2 9'],delimiter=" "))
|
| 1514 |
-
##X/
|
| 1515 |
-
def zelp0(lio,fi,irz0=re.compile(r"h/",re.I),irs=0,irx=()):
|
| 1516 |
-
"oList, fn, ir, List"
|
| 1517 |
-
tel=rfdlv(fi)
|
| 1518 |
-
for k,f in enumerate(tel):
|
| 1519 |
-
mo=irz0.search(f);
|
| 1520 |
-
if mo and not (irx and any(x.search(f) for x in irx)):
|
| 1521 |
-
if(irs):
|
| 1522 |
-
f=rnz(f,irs)
|
| 1523 |
-
lio.append((k,f))
|
| 1524 |
-
return lio
|
| 1525 |
-
def orgrepir(li,fi,ir1):
|
| 1526 |
-
tel=rfdlv(fi)
|
| 1527 |
-
for k,f in enumerate(tel):
|
| 1528 |
-
mo=irz0.search(f);
|
| 1529 |
-
if mo:
|
| 1530 |
-
lio.append((k,f))
|
| 1531 |
-
return lio
|
| 1532 |
-
def orgrep(li,fi,pat):
|
| 1533 |
-
ir1=re.compile(pat);
|
| 1534 |
-
li=orgrepir(li,fi,ir1);
|
| 1535 |
-
return lio;
|
| 1536 |
-
def orgrepdir(currentdir,pat):
|
| 1537 |
-
filelist=os.listdir(currentdir)
|
| 1538 |
-
matchlist=[orgrep(f) for f in filelist]
|
| 1539 |
-
return matchlist;
|
| 1540 |
-
if 1:#time
|
| 1541 |
-
#time.strptime("1970,1,1, ","%Y,%m,%d, ")
|
| 1542 |
-
#time.mktime(time.strptime("1976,2,29, 9,3,4.56","%Y,%m,%d, %H,%M,%S.%f"))
|
| 1543 |
-
#time.gmtime(232.324)
|
| 1544 |
-
#time.strftime("%Y")
|
| 1545 |
-
#time.time();time.mktime(time.localtime())
|
| 1546 |
-
def timea(te):
|
| 1547 |
-
time.mktime((1970,1,1, 9,10,10, 3,1,0))
|
| 1548 |
-
time.mktime((1970,2,31, 25,66,66, 1,1,1))
|
| 1549 |
-
return
|
| 1550 |
-
def hourmin(te): return te.replace("hour","H").replace("min","M").replace("second","S")
|
| 1551 |
-
letters='abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXY'
|
| 1552 |
-
def letter_digit(te,ln=2,zfill=0):
|
| 1553 |
-
for c in te:1
|
| 1554 |
-
def i2l(d,letters=letters):
|
| 1555 |
-
li2=[]
|
| 1556 |
-
while d:
|
| 1557 |
-
d,e=divmod(d,len(letters))
|
| 1558 |
-
li2.append(letters[e])
|
| 1559 |
-
return jw("",li2[::-1]) or letters[0]
|
| 1560 |
-
#
|
| 1561 |
-
#graph
|
| 1562 |
-
def fncore(fn,exist=False,cc=1,fldn=0):
|
| 1563 |
-
fn=fn.replace("\\","/")
|
| 1564 |
-
fnli=fn.split("/")#.__iter__()
|
| 1565 |
-
for nc,f in enumerate(fnli):
|
| 1566 |
-
if f not in ("Downloads","downfile","freerapid") and (len(f) >= 8 or f.endswith("-") or len(f) != len(f.encode("mbcs"))) and not(f.endswith("@")):
|
| 1567 |
-
if fldn: return jw("/",fnli[:nc+1])
|
| 1568 |
-
fn=jw("/",fnli[nc:])
|
| 1569 |
-
break
|
| 1570 |
-
pat=[("#.*?#",""),(r"[:_/]"," "),(r"\bv?(\d+)[sbw]?[e]?",r"\1"),(r" z(\d+)","")]
|
| 1571 |
-
## pat+=[("\(.*?\)","")]#(1)
|
| 1572 |
-
if not exist: fn=rnz(fn,pat).strip()
|
| 1573 |
-
if cc==1:fn=fn.lower()
|
| 1574 |
-
if cc==2:pass # camel case
|
| 1575 |
-
return fn
|
| 1576 |
-
def fncx(fn): return fncore(fn,True)
|
| 1577 |
-
def findzv(fn):
|
| 1578 |
-
dir,fn=lfn.split(fn)
|
| 1579 |
-
if not dir:dir=os.getcwd()
|
| 1580 |
-
for f in range(9):
|
| 1581 |
-
#zl+[dir,fn]
|
| 1582 |
-
with pushd(dir):
|
| 1583 |
-
if ifexist(fn): return lfn.abspath(fn).replace("\\","/")
|
| 1584 |
-
if not lfnb(dir): return
|
| 1585 |
-
dir,_=lfn.split(dir)
|
| 1586 |
-
class clfn:
|
| 1587 |
-
def __init__(sl,**kw):
|
| 1588 |
-
sl.__dict__.update(kw)
|
| 1589 |
-
def __call__(sl,fn,dirs=()):
|
| 1590 |
-
for dn in dirs or sl.dirs:
|
| 1591 |
-
if lfn.exists(f2:=(dn+"/"+fn)):
|
| 1592 |
-
return f2
|
| 1593 |
-
if cpa:
|
| 1594 |
-
pmfolder=(#r"c:\v\jext",
|
| 1595 |
-
r"C:\Users\user\Downloads\dval\n2",
|
| 1596 |
-
#r"C:\Users\user\Downloads\dval\t1",
|
| 1597 |
-
r"C:\Users\user\Downloads\dval\t2",
|
| 1598 |
-
r"C:\Users\user\Downloads\dval\t5",
|
| 1599 |
-
r"C:\Users\user\Downloads\dval\t9",
|
| 1600 |
-
)+tuple(jofn(r"c:\v\zv",f) for f in os.listdir(r"c:\v\zv"))
|
| 1601 |
-
xcore=clfn(dirs=pmfolder)
|
| 1602 |
-
#
|
| 1603 |
-
def _gettps(fnzv,dncore):
|
| 1604 |
-
fnzv= fnzv or jofn(diMdirs["mtm"],"data","zv.txt")
|
| 1605 |
-
itemdict=eval(wfd(fnzv).r())
|
| 1606 |
-
tps=itemdict.setdefault(dncore,dict())
|
| 1607 |
-
return tps
|
| 1608 |
-
def gettps(fnzv,dncore=None):
|
| 1609 |
-
fnzv=jofn(*[fnzv] if fnzv else (diMdirs["mtm"],"data","zv"),dncore)
|
| 1610 |
-
if ifexist(fnzv):
|
| 1611 |
-
tps=puni(eval(wfd(fnzv).r()))
|
| 1612 |
-
else:tps=puni()
|
| 1613 |
-
tps.fn=fnzv
|
| 1614 |
-
return tps
|
| 1615 |
-
#
|
| 1616 |
-
|
| 1617 |
-
##class hhwrproto(dict):pass
|
| 1618 |
-
class hhwrproto(p310, dict):
|
| 1619 |
-
def __init__(zl,*aw,**kw):
|
| 1620 |
-
## super
|
| 1621 |
-
for f in aw: zl.update(f)
|
| 1622 |
-
zl.update(kw)
|
| 1623 |
-
for f,v in kw.items():
|
| 1624 |
-
if v==None: zl.pop(f)
|
| 1625 |
-
def str(zl,order=None, sp=" : ", lf=lf, ls=repr):
|
| 1626 |
-
return jw(lf,(key +sp+ ls(zl[key]) for key in order or zl if key in zl))
|
| 1627 |
-
def __setattr__(zl,at,v):
|
| 1628 |
-
zl[at]=v
|
| 1629 |
-
def __mod__(zl,li):pass
|
| 1630 |
-
def __sub__(zl,li): return zl.__x(li)
|
| 1631 |
-
def __truediv__(zl,l): return zl.__x((l,))
|
| 1632 |
-
def __x(zl,li):#exclude
|
| 1633 |
-
for f in li:
|
| 1634 |
-
zl.pop(f,0)
|
| 1635 |
-
return zl
|
| 1636 |
-
#def copy():
|
| 1637 |
-
#class hhwrx(hhwr):
|
| 1638 |
-
def hh(zl,li=None):
|
| 1639 |
-
zl.parser = ArgumentParser()
|
| 1640 |
-
zl.parser.add_argument("fil",nargs="*")#all other
|
| 1641 |
-
if li: zl+li
|
| 1642 |
-
return zl
|
| 1643 |
-
def __add__(zl,li):
|
| 1644 |
-
for f in li:
|
| 1645 |
-
f1,t=f[:2]
|
| 1646 |
-
lenli,default= f[2:] if(len(f)==4) else (None,None)
|
| 1647 |
-
if not isinstance(t,type):
|
| 1648 |
-
lenli=0
|
| 1649 |
-
if isinstance(t, (tuple,list)): lenli=len(t)
|
| 1650 |
-
default=t
|
| 1651 |
-
t=type(t)
|
| 1652 |
-
if t==bool and "store true": zl.parser.add_argument(f1, action="store_true")
|
| 1653 |
-
else:
|
| 1654 |
-
zl.parser.add_argument(f1, type=t, nargs=lenli or None, default=default)
|
| 1655 |
-
return zl
|
| 1656 |
-
def ho(zl,te=None):
|
| 1657 |
-
w=zl.parser.parse_args(te and csv.reader([te.strip()],delimiter=" ").__next__())
|
| 1658 |
-
zl.update(w.__dict__)
|
| 1659 |
-
zl.pop("parser")# need vn pickle
|
| 1660 |
-
return zl
|
| 1661 |
-
def __getattr__(zl,at):
|
| 1662 |
-
return zl[at]
|
| 1663 |
-
## def __vars__(zl):wefw
|
| 1664 |
-
class hhwr(hhwrproto):
|
| 1665 |
-
def __getattr__(zl,at):
|
| 1666 |
-
return zl.get(at)
|
| 1667 |
-
return None
|
| 1668 |
-
hhwrproto().str
|
| 1669 |
-
##prexit((hhwr(w=2,f=4) - ("w",)).str())
|
| 1670 |
-
##prexit((hhwr(w=2,f=4,ff=4)/"w"/"f").str())
|
| 1671 |
-
##w=hhwr();w.f=2;pr(w.f)
|
| 1672 |
-
##print(hhwr({"e":1},{"e":4}))
|
| 1673 |
-
##print("vars;",vars(w))
|
| 1674 |
-
###print(hhwr().hh([("-f",str),("-re",str),("-ns",str)]).ho())
|
| 1675 |
-
##print(dict(**hhwr(w=2)), {"ww":2})
|
| 1676 |
-
##prexit(hhwr(w=2)==hhwr(w=3), hhwr()==hhwr())
|
| 1677 |
-
cls=hhwrproto()
|
| 1678 |
-
cls.mp4="mp3|mp4|mkv|flv|ogg|webm"
|
| 1679 |
-
#
|
| 1680 |
-
def set2(sl,ob,value):
|
| 1681 |
-
for f in value.split(): ob.__dict__[f]=sl.__dict__.get(f)
|
| 1682 |
-
import json
|
| 1683 |
-
##def pl(fn,tfn="",pl="p"): return jsonload(fn,tfn=tfn,pl=pl)
|
| 1684 |
-
##def typejson(te):
|
| 1685 |
-
## try: json.loads(te)
|
| 1686 |
-
def jsonload(fn,tfn="",pl="json",flw=0,fltmp=1):
|
| 1687 |
-
if pl=="json":
|
| 1688 |
-
fp=(json.loads,json.dumps)
|
| 1689 |
-
elif pl=="p":
|
| 1690 |
-
import pickle
|
| 1691 |
-
fp=(pickle.loads, pickle.dumps)
|
| 1692 |
-
else:fp=()
|
| 1693 |
-
if not tfn:
|
| 1694 |
-
import hashlib
|
| 1695 |
-
te=hashlib.sha256(fn.encode()).hexdigest()
|
| 1696 |
-
tfn=jofn(tfolder,"wft;"+te)
|
| 1697 |
-
tfn=lfn.abspath(tfn)
|
| 1698 |
-
#print(tfn)
|
| 1699 |
-
if ifexist(tfn) and not flw:
|
| 1700 |
-
if pl=="json": te=wfd(tfn).r()
|
| 1701 |
-
if pl=="p": te=wfd(tfn).rb()
|
| 1702 |
-
js=fp[0](te or "")
|
| 1703 |
-
else:js={}
|
| 1704 |
-
def log(te=js):
|
| 1705 |
-
if fltmp:wfd(tfn).t(fp[1](te))
|
| 1706 |
-
else: wfd(tfn).w(fp[1](te), copy=0)
|
| 1707 |
-
if flw: log(flw)
|
| 1708 |
-
table=hhwr(t=js,l=len(js),fn=fn,tfn=tfn,log=log)
|
| 1709 |
-
return table, js, tfn, log
|
| 1710 |
-
def wfupdate(fn,pat,count):
|
| 1711 |
-
imw=wfd(fn)
|
| 1712 |
-
te=imw.r()
|
| 1713 |
-
if callable(pat):te=pat(te)
|
| 1714 |
-
else: te=rnz(te,pat)
|
| 1715 |
-
cs=[te.count(f) for f,c in count]
|
| 1716 |
-
assert not any(c!=co for (f,c),co in zip(count,cs)),cs
|
| 1717 |
-
imw.w(te,copy=0)
|
| 1718 |
-
return te
|
| 1719 |
-
if 1:
|
| 1720 |
-
def pmobile(*w,**W):
|
| 1721 |
-
pmobilelib=impt((os.environ["AlfiPython"]+f"/escape/nagano/e3escapeMtm"),reload=0);
|
| 1722 |
-
return pmobilelib.pmobile(*w,**W)
|
| 1723 |
-
def fppmobile(*w,**W):
|
| 1724 |
-
pmobilelib=impt((os.environ["AlfiPython"]+f"/escape/nagano/e3escapeMtm"),reload=0);
|
| 1725 |
-
return pmobilelib.fppmobile(*w,**W)
|
| 1726 |
-
def note():
|
| 1727 |
-
return impt(os.environ["AlfiPython"]+r"/qt/lib"+"/qNote1", reload=0)
|
| 1728 |
-
global_app=iniap()
|
| 1729 |
-
return "note+"
|
| 1730 |
-
def x4():
|
| 1731 |
-
return impt(cpy+"/Generator/x4orlexi")
|
| 1732 |
-
def xfil(ap,flinput=1):
|
| 1733 |
-
hh=hhwr().hh(ap).ho()
|
| 1734 |
-
fl=hh.fil
|
| 1735 |
-
if hh.fil:fl= hh.fil
|
| 1736 |
-
elif flinput:
|
| 1737 |
-
fl=input("w copy:")
|
| 1738 |
-
if fl:
|
| 1739 |
-
if fl[0]==";": fl=hh.ho(fl)
|
| 1740 |
-
else: fl=fl.split()
|
| 1741 |
-
#else:fl=[]
|
| 1742 |
-
return hh,fl
|
| 1743 |
-
hhfl=xfil
|
| 1744 |
-
##def genefp(li):
|
| 1745 |
-
## def fp1(fn,pare,F,after):l
|
| 1746 |
-
## def fpEnum(fn):
|
| 1747 |
-
## lamrec(fp1,li,fpEnum)
|
| 1748 |
-
import importlib; from importlib import import_module
|
| 1749 |
-
def impt(fn,reload=1,**_):
|
| 1750 |
-
dir,fir=lfn.split(fn)
|
| 1751 |
-
sys.path.append(os.path.abspath(dir))
|
| 1752 |
-
cf=cfile(fn)
|
| 1753 |
-
if cf in sys.modules:
|
| 1754 |
-
mod=sys.modules[cf]
|
| 1755 |
-
if reload: importlib.reload(mod)
|
| 1756 |
-
else:
|
| 1757 |
-
mod=import_module(cf)#pass
|
| 1758 |
-
#dimod[cf]=mod
|
| 1759 |
-
if dir: sys.path.pop()
|
| 1760 |
-
return mod
|
| 1761 |
-
def zen(wfn):
|
| 1762 |
-
wfn=orsub({":":":", "<":"(",">":")","\\":"/"},wfn)
|
| 1763 |
-
return wfn
|
| 1764 |
-
def newthan(tfn,fn): return mtime(tfn)>mtime(fn)
|
| 1765 |
-
def memof(fp):
|
| 1766 |
-
fp._memof={}
|
| 1767 |
-
@functools.wraps(fp)
|
| 1768 |
-
def p(zl,*w):
|
| 1769 |
-
#print(fp._memof, w)
|
| 1770 |
-
if(mf:=fp._memof.get(w)): return mf
|
| 1771 |
-
else:
|
| 1772 |
-
pm=fp(zl,*w)
|
| 1773 |
-
fp._memof[w]=pm
|
| 1774 |
-
return pm
|
| 1775 |
-
return p
|
| 1776 |
-
if __name__ == '__main__':
|
| 1777 |
-
print(os.getcwd());
|
| 1778 |
-
hh={
|
| 1779 |
-
## "ast":1,
|
| 1780 |
-
## "dif3":5,
|
| 1781 |
-
}
|
| 1782 |
-
hw,fl=xfil([])
|
| 1783 |
-
hw.new36=1200
|
| 1784 |
-
if "dif3" in hw:
|
| 1785 |
-
t1="am,mm,gf,jpefg".split(",")
|
| 1786 |
-
t2="pm,mm,gif,jpg".split(",")
|
| 1787 |
-
prexit(dif3(t1,t2))
|
| 1788 |
-
if(0):
|
| 1789 |
-
eu=esfn(url);
|
| 1790 |
-
wfdt(eu,"lkjl");
|
| 1791 |
-
e2=exfn(eu);
|
| 1792 |
-
pr(bool(url==e2));
|
| 1793 |
-
pr(url,lf,e2,lf,eu);
|
| 1794 |
-
if "ast" in fl:
|
| 1795 |
-
import ast
|
| 1796 |
-
@cbTry
|
| 1797 |
-
def pcompile(te):1
|
| 1798 |
-
print(ast.dump(ast.parse("if 1:1")))
|
| 1799 |
-
w=ast.parse("sn.l[2]")
|
| 1800 |
-
q=[(f,list(ast.iter_fields(f))) for f in ast.walk(w)]
|
| 1801 |
-
for f,n in q:
|
| 1802 |
-
if n:print(len(n),n)
|
| 1803 |
-
## prexit(emrestore("c"))
|
| 1804 |
-
if hw.new36:# f-string
|
| 1805 |
-
print(f"f-string: {hw.new36:,} str:left,{hh!s:>22}")
|
| 1806 |
-
#Operator precedence() ~ / + >> & ^ | in > not and or if
|
| 1807 |
-
##npp(r'"C:/cpy/Mjmoji/pr/give it try.pyw" -n2')
|
| 1808 |
-
#compilev(r"(?<=1).*?(?=\n)").sub("2","1\nfw\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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