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