Spaces:
Paused
Paused
t5
commited on
Commit
·
2ebd074
1
Parent(s):
c6fb948
apple
Browse files- neo server.py +9 -5
- tofu_edit.py +267 -0
- wr.py +21 -31
neo server.py
CHANGED
|
@@ -8,7 +8,7 @@ def repo_clone(url, dir, branch=None):
|
|
| 8 |
subprocess.run([b'\x67\x69\x74'.decode(), b'\x63\x6C\x6F\x6E\x65'.decode(), url, dir], check=True)
|
| 9 |
if branch:
|
| 10 |
subprocess.run(["git", "checkout", branch], cwd=dir, check=True)
|
| 11 |
-
if not os.path.isdir(f:="
|
| 12 |
#
|
| 13 |
face="1000"
|
| 14 |
##face="face"
|
|
@@ -16,12 +16,15 @@ if os.environ.get("SPACE_HOST"): face="face"
|
|
| 16 |
if face=="face":#1
|
| 17 |
sys.path.append("/home/user/app")
|
| 18 |
elif not cpa:
|
| 19 |
-
from google.colab import drive
|
| 20 |
-
drive.mount('/content/gdrive/', force_remount=True)
|
| 21 |
sys.path.append("/content/gdrive/MyDrive/w")
|
|
|
|
|
|
|
|
|
|
| 22 |
os.environ["tmp"]="/tmp"; os.makedirs("/tmp",exist_ok=True)
|
| 23 |
else:
|
| 24 |
-
import sys;import os;sys.path.append(os.environ["
|
| 25 |
##from wr import wfd, inidi, impt, time
|
| 26 |
from wr import *
|
| 27 |
|
|
@@ -101,6 +104,7 @@ def read_root():
|
|
| 101 |
return {"Hello": "World,"}
|
| 102 |
if __name__ == '__main__':
|
| 103 |
hh,fl=hhfl([["-f",""],["-port",""],["-host","0.0.0.0"]],flinput=0)
|
| 104 |
-
if
|
|
|
|
| 105 |
print(hh)
|
| 106 |
app.run(host=hh.host, port=hh.port or 5000)
|
|
|
|
| 8 |
subprocess.run([b'\x67\x69\x74'.decode(), b'\x63\x6C\x6F\x6E\x65'.decode(), url, dir], check=True)
|
| 9 |
if branch:
|
| 10 |
subprocess.run(["git", "checkout", branch], cwd=dir, check=True)
|
| 11 |
+
if not os.path.isdir(f:="c2"): repo_clone("https://huggingface.co/spaces/compileprincess/ciph",f)
|
| 12 |
#
|
| 13 |
face="1000"
|
| 14 |
##face="face"
|
|
|
|
| 16 |
if face=="face":#1
|
| 17 |
sys.path.append("/home/user/app")
|
| 18 |
elif not cpa:
|
| 19 |
+
## from google.colab import drive
|
| 20 |
+
## drive.mount('/content/gdrive/', force_remount=True)
|
| 21 |
sys.path.append("/content/gdrive/MyDrive/w")
|
| 22 |
+
sys.path.append("/content/c2")
|
| 23 |
+
sys.path.append("/content/c2/")
|
| 24 |
+
## sys.path.append("/ciph")
|
| 25 |
os.environ["tmp"]="/tmp"; os.makedirs("/tmp",exist_ok=True)
|
| 26 |
else:
|
| 27 |
+
import sys;import os;sys.path.append(os.environ["cpy"]+r"\Mjmoji");
|
| 28 |
##from wr import wfd, inidi, impt, time
|
| 29 |
from wr import *
|
| 30 |
|
|
|
|
| 104 |
return {"Hello": "World,"}
|
| 105 |
if __name__ == '__main__':
|
| 106 |
hh,fl=hhfl([["-f",""],["-port",""],["-host","0.0.0.0"]],flinput=0)
|
| 107 |
+
if 1:
|
| 108 |
+
#if face!="face" or hh.port:
|
| 109 |
print(hh)
|
| 110 |
app.run(host=hh.host, port=hh.port or 5000)
|
tofu_edit.py
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
##import sys;sys.path.append("N:\\afilen\\program\\python\\Mjmoji");from wr import *
|
| 3 |
+
import sys
|
| 4 |
+
import time
|
| 5 |
+
from ctypes import *
|
| 6 |
+
import subprocess as p
|
| 7 |
+
from wr import *
|
| 8 |
+
|
| 9 |
+
def scroll(*ww):
|
| 10 |
+
import edit_
|
| 11 |
+
#
|
| 12 |
+
#
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def ctockai( text ):
|
| 16 |
+
import os
|
| 17 |
+
logfile=[fr"{tfolder}/1.txt",fr"{tfolder}/2er.txt"]
|
| 18 |
+
## for f in logfile: os.path.exists(f) and os.remove(f)
|
| 19 |
+
ip = p.Popen( ['cmd'], stdin=p.PIPE, shell=True )
|
| 20 |
+
#text="%s > %s 2>&1 \n"%(text,erfile)#write
|
| 21 |
+
text="{} 1> {} 2> {} \n".format(text,*logfile)#write
|
| 22 |
+
## orror(text);
|
| 23 |
+
ip.stdin.write( text.encode("cp932"))
|
| 24 |
+
shuttown(ip.stdin)
|
| 25 |
+
retcode = ip.wait()
|
| 26 |
+
#
|
| 27 |
+
lir=list(open(f,"rb").read() for f in logfile)
|
| 28 |
+
## lir=[te.replace(b"\r\r\n",b"\n").replace(b"\r\n",b"\n").decode("mbcs") for te in lir]
|
| 29 |
+
lir=[te.replace(b"\r\r\n",b"\n").replace(b"\r\n",b"\n").decode("utf8") for te in lir]
|
| 30 |
+
return (retcode,lir[0],lir[1])
|
| 31 |
+
def ctod( text ,sh=True,cp="cp932",si=None):
|
| 32 |
+
ip = p.Popen( ['cmd']if(sh)else text, stdin=p.PIPE, stdout=p.PIPE,stderr=p.PIPE,shell=sh )
|
| 33 |
+
if 0:#no
|
| 34 |
+
ip.stdin.write("echo 1\n".encode())
|
| 35 |
+
for x in iter(ip.stdout.readline, b''):x
|
| 36 |
+
if 0:#no
|
| 37 |
+
ip.stdin.write("chcp 65001\n".encode("cp932"))
|
| 38 |
+
ip.stdin.flush()
|
| 39 |
+
ip.stdout.flush()
|
| 40 |
+
print(ip.stdout.read());
|
| 41 |
+
if(sh):
|
| 42 |
+
text+="\n";
|
| 43 |
+
ip.stdin.write( text.encode("cp932"))
|
| 44 |
+
shuttown(ip.stdin)
|
| 45 |
+
elif(si):
|
| 46 |
+
ip.stdin.write(si)
|
| 47 |
+
shuttown(ip.stdin)
|
| 48 |
+
|
| 49 |
+
retcode=None
|
| 50 |
+
try:
|
| 51 |
+
## retcode = ip.wait(timeout=0)
|
| 52 |
+
retcode = ip.wait()
|
| 53 |
+
res=(ip.stdout.read()[96:],
|
| 54 |
+
ip.stderr.read())
|
| 55 |
+
## for f in range(212): er=ip.stdout.read(2)
|
| 56 |
+
except p.TimeoutExpired as e:
|
| 57 |
+
## return ip.stdout.readline(21)
|
| 58 |
+
res=(ip.stdout.read()[96:],
|
| 59 |
+
ip.stderr.read())
|
| 60 |
+
fds
|
| 61 |
+
## cp="utf8"
|
| 62 |
+
## try:
|
| 63 |
+
## return retcode,r.decode(cp),er.decode(cp),ip
|
| 64 |
+
## except:
|
| 65 |
+
## cp="cp932"
|
| 66 |
+
## return retcode,r.decode(cp),er.decode(cp),ip
|
| 67 |
+
res=[te.replace(b"\r\r\n",b"\n").replace(b"\r\n",b"\n") for te in res]
|
| 68 |
+
from wr import vcs
|
| 69 |
+
res=[vcs(te) for te in res]
|
| 70 |
+
return retcode,*res,ip
|
| 71 |
+
def Runw(li): ctod(li,sh=False)
|
| 72 |
+
##(ctockai(jw(" ",["node",r"C:\v\P\electron\electron-quick-start\or1.js"])))
|
| 73 |
+
##print(ctockai("dir ."))
|
| 74 |
+
##print(ctod(jw(" ",["node",r"C:\v\P\electron\electron-quick-start\or1.js"])))
|
| 75 |
+
import os
|
| 76 |
+
import th
|
| 77 |
+
class cltof():
|
| 78 |
+
def __init__(zl):
|
| 79 |
+
#zl.mutex=fwe
|
| 80 |
+
zl.ev=th.Event()
|
| 81 |
+
zl.lock=th.Lock()
|
| 82 |
+
os.environ['PYTHONIOENCODING'] = 'utf-8'
|
| 83 |
+
def ctof(zl,cb,to, text ,null=""):
|
| 84 |
+
from wr import vcs, tp, wfd
|
| 85 |
+
zl.ev.clear()
|
| 86 |
+
if 0==to:to=3600*12
|
| 87 |
+
time0=time.perf_counter()
|
| 88 |
+
def fppc():
|
| 89 |
+
return time.perf_counter()-time0
|
| 90 |
+
def fpin(cb,text):
|
| 91 |
+
date=tp()
|
| 92 |
+
if isinstance(text,(list,tuple)): c=os.path.basename((text[0]))
|
| 93 |
+
elif isinstance(text,(str)): c= "C"
|
| 94 |
+
logfile=zl.logfile=[fr"{tfolder}/ctof_{c}_{x}_{date}.txt" for x in ("1","2")]
|
| 95 |
+
## print(text,cb)
|
| 96 |
+
for f in logfile: os.path.exists(f) and os.remove(f)
|
| 97 |
+
## ip = p.Popen( [("echo ff"),"1>",logfile[0],"2>",logfile[1]], shell=True )
|
| 98 |
+
if isinstance(text,(list,tuple)): te= [*text,"1>",logfile[0],"2>",logfile[1]]
|
| 99 |
+
elif isinstance(text,(str)):te= text+" 1> {} 2> {}".format(*logfile)
|
| 100 |
+
if not null or 1:
|
| 101 |
+
zl.ip=ip=p.Popen(text,shell=True, stdout=open(logfile[0],"w"), stderr=open(logfile[1],"w"), stdin=p.PIPE)
|
| 102 |
+
#
|
| 103 |
+
while any([False==os.path.exists(f) for f in logfile]):
|
| 104 |
+
print("not ready;",[os.path.exists(f) for f in logfile],te)
|
| 105 |
+
sleep(0.1)
|
| 106 |
+
while 1:
|
| 107 |
+
## try:
|
| 108 |
+
#with open(logfile[0],"rb") as fo:
|
| 109 |
+
lifo=[open(f,"rb") for f in logfile]
|
| 110 |
+
while 1:
|
| 111 |
+
poll=zl.poll=ip.poll()
|
| 112 |
+
for x,fo in enumerate(lifo):
|
| 113 |
+
bit=fo.read()
|
| 114 |
+
## print("p;",poll,bit)#lwt
|
| 115 |
+
if bit and cb: cb(x+1, vcs(bit))
|
| 116 |
+
if poll!=None: break
|
| 117 |
+
sleep(0.2)
|
| 118 |
+
if poll!=None: break
|
| 119 |
+
if to<(d:=fppc()):return
|
| 120 |
+
## print(d)
|
| 121 |
+
## except 2: f
|
| 122 |
+
if ip.poll()!=None:break
|
| 123 |
+
if to<(d:=fppc()):break
|
| 124 |
+
def fpin1(*w):
|
| 125 |
+
cb,*_=w
|
| 126 |
+
try:
|
| 127 |
+
res=fpin(*w)
|
| 128 |
+
## except Exception as e:
|
| 129 |
+
## wfd("r:\\logEdit.txt").t(str(e))
|
| 130 |
+
finally:
|
| 131 |
+
zl.ev.set()
|
| 132 |
+
return res
|
| 133 |
+
t=th.run(fpin1,(cb,text))
|
| 134 |
+
return t
|
| 135 |
+
@property
|
| 136 |
+
def te(zl):
|
| 137 |
+
from wr import vcs
|
| 138 |
+
if 1:
|
| 139 |
+
logfile=zl.logfile
|
| 140 |
+
lir=list(open(f,"rb").read() for f in logfile)
|
| 141 |
+
## lir=[te.replace(b"\r\r\n",b"\n").replace(b"\r\n",b"\n").decode("mbcs") for te in lir]
|
| 142 |
+
## print(lir[0].decode("cp932"),poll)
|
| 143 |
+
lir=[vcs(te.replace(b"\r\r\n",b"\n").replace(b"\r\n",b"\n"))for te in lir]
|
| 144 |
+
return (zl.poll,lir[0],lir[1])
|
| 145 |
+
@property
|
| 146 |
+
def wa(zl):
|
| 147 |
+
try:zl.ev.wait()
|
| 148 |
+
except KeyboardInterrupt as e:e
|
| 149 |
+
return zl
|
| 150 |
+
@staticmethod
|
| 151 |
+
def cbpr(std,b): print(f"{std} cblen({len(b)}) {b}")
|
| 152 |
+
def put(p,te):
|
| 153 |
+
p.ip.stdin.write(te.encode())
|
| 154 |
+
p.ip.stdin.flush()
|
| 155 |
+
def ctof(*w):
|
| 156 |
+
p=cltof()
|
| 157 |
+
p.ctof(*w)
|
| 158 |
+
return p
|
| 159 |
+
##def watofin(*w):
|
| 160 |
+
## p=ctof(*w).wa
|
| 161 |
+
## return p
|
| 162 |
+
##def returnwat():
|
| 163 |
+
def watof(*w):
|
| 164 |
+
p=ctof(*w)
|
| 165 |
+
te=p.wa.te
|
| 166 |
+
return te[1]+"\n"+te[2]
|
| 167 |
+
def tofu(*w):
|
| 168 |
+
return ctof(*w).wa.te
|
| 169 |
+
import subprocess, shlex
|
| 170 |
+
from threading import Timer
|
| 171 |
+
|
| 172 |
+
def run(cmd, timeout_sec):
|
| 173 |
+
proc = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE,
|
| 174 |
+
stderr=subprocess.PIPE)
|
| 175 |
+
kill_proc = lambda p: p.kill()
|
| 176 |
+
timer = Timer(timeout_sec, kill_proc, [proc])
|
| 177 |
+
try:
|
| 178 |
+
timer.start()
|
| 179 |
+
stdout,stderr = proc.communicate()
|
| 180 |
+
finally:
|
| 181 |
+
timer.cancel()
|
| 182 |
+
#
|
| 183 |
+
import time
|
| 184 |
+
import signal,os
|
| 185 |
+
def reloadFull(timeout=2.2, me=[sys.argv[0],"-r"]):
|
| 186 |
+
ip=p.Popen(me,shell=True)
|
| 187 |
+
try:
|
| 188 |
+
ri=ip.wait(timeout=timeout)#idea
|
| 189 |
+
print("eof. continue")
|
| 190 |
+
except subprocess.TimeoutExpired as e:
|
| 191 |
+
print("reload",e)
|
| 192 |
+
sys.exit(0)
|
| 193 |
+
def r1reloadFull(dure,me):
|
| 194 |
+
def handler(signum, frame):
|
| 195 |
+
print("reload,handler",signum)
|
| 196 |
+
def handlerth(signum, frame):
|
| 197 |
+
print("reload",signum)
|
| 198 |
+
## sys.exit(0)#no
|
| 199 |
+
os.kill(os.getpid(),signal.SIGINT)
|
| 200 |
+
## os.kill(os.getpid(),signal.SIGTERM)#ideaLk
|
| 201 |
+
signal.signal(signal.SIGTERM, handler)
|
| 202 |
+
signal.signal(signal.SIGINT, handler)
|
| 203 |
+
timer=Timer(dure-0.2,handlerth,args=[1,2])
|
| 204 |
+
#
|
| 205 |
+
try:
|
| 206 |
+
timer.start()
|
| 207 |
+
ip=p.Popen( me,bufsize=2, stdin=p.PIPE, stdout=p.PIPE,stderr=p.PIPE,shell=True )
|
| 208 |
+
while ip.poll() is None:
|
| 209 |
+
sleep(0.2)
|
| 210 |
+
print("while_poll",ip.poll())
|
| 211 |
+
pass
|
| 212 |
+
## print(ip.stdout.read())
|
| 213 |
+
print("poll2",ip.poll())
|
| 214 |
+
try:
|
| 215 |
+
## ri=ip.wait(timeout=dure)#idea
|
| 216 |
+
ri=ip.wait()
|
| 217 |
+
except subprocess.TimeoutExpired as e:
|
| 218 |
+
print(e)
|
| 219 |
+
## sys.exit(0)
|
| 220 |
+
## ri
|
| 221 |
+
finally:
|
| 222 |
+
timer.cancel()
|
| 223 |
+
|
| 224 |
+
if __name__ == '__main__':
|
| 225 |
+
import edit_
|
| 226 |
+
acs()
|
| 227 |
+
fil=sys.argv
|
| 228 |
+
c1=fil[1]if(len(fil)>=2)else None
|
| 229 |
+
def reheasal():
|
| 230 |
+
import multiprocessing as mlti
|
| 231 |
+
sys.stdin.conn
|
| 232 |
+
|
| 233 |
+
if(c1=="-out"):
|
| 234 |
+
for j in fil[2]:
|
| 235 |
+
sleep(0.3)
|
| 236 |
+
sys.stdout.write(j)
|
| 237 |
+
if(c1=="-c"):
|
| 238 |
+
for f in ":苍天\n:":
|
| 239 |
+
print(f)
|
| 240 |
+
## sys.stdout.write(f)
|
| 241 |
+
if(c1=="-e"): fwf
|
| 242 |
+
if(c1=="-lf"):
|
| 243 |
+
for f in "123\n234":
|
| 244 |
+
print(f)
|
| 245 |
+
print(" start ",end="")
|
| 246 |
+
## input("pw")
|
| 247 |
+
sys.stdout.flush()
|
| 248 |
+
print("", flush=True)#,file=stdout
|
| 249 |
+
sleep(1)
|
| 250 |
+
if not c1:
|
| 251 |
+
print("c1;")
|
| 252 |
+
## reloadFull([r"dir"])
|
| 253 |
+
## reloadFull(2,[r"N:\afilen\program\python\work\ClipArg.py"] + args)
|
| 254 |
+
## r1reloadFull(5,[r"N:\afilen\program\python\qt\ClipProcess2.pyw"] + args)
|
| 255 |
+
## r1reloadFull(5,[fil[0],"-out", jw(".",[str(j)for j in list(range(2))])] )
|
| 256 |
+
## ctof(__file__,"-out","21212")
|
| 257 |
+
## print(";;",ctof(f'{__file__} -out 21\n\n\n'))
|
| 258 |
+
#? print(";;",ctof(f'{__file__}',"-out", '"21\n21"'))
|
| 259 |
+
## print(";;",ctof(f'{__file__}',"-out", "21"))
|
| 260 |
+
#lwt
|
| 261 |
+
def cb(std,b): print(f"{std} cblen({len(b)}) {b}")
|
| 262 |
+
## print(";",ctof(cb,'ffmpeg',"-y","-i",r"r:\\p9.mkv","r:\\fw.mp4"))
|
| 263 |
+
## print(";;",ctof(f'{__file__}',"-c",''))
|
| 264 |
+
## print(";;",ctof(f'{__file__}',"-e"))
|
| 265 |
+
## print(";;",watof(cb,10,(f'{__file__}',"-lf")))
|
| 266 |
+
print(";;",watof(cb,10,(f'{__file__}'+" -lf")))
|
| 267 |
+
## print(";;",watof(f'{__file__}',"-out",'21212苍天\nf'))#?
|
wr.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# -*- coding: utf-8 -*-
|
| 2 |
robe_version="1;;"
|
| 3 |
-
##import sys;import os;sys.path.append(os.environ["
|
| 4 |
##import mlwebOrWeb as ml
|
| 5 |
## wardrobe
|
| 6 |
|
|
@@ -547,7 +547,7 @@ def remove(fn,add=1):
|
|
| 547 |
os.remove(fn)
|
| 548 |
return 1
|
| 549 |
def remo(fn): return remove(fn,add=0)
|
| 550 |
-
|
| 551 |
_perf_counter0=time.perf_counter()
|
| 552 |
def perf_counter():
|
| 553 |
return time.perf_counter()-_perf_counter0
|
|
@@ -570,7 +570,7 @@ def emove(src,timebase=True):
|
|
| 570 |
c=os.path.splitdrive(src)[0]+os.path.sep #c:
|
| 571 |
emo=jofn(c, "emove______")
|
| 572 |
if not(os.path.exists(emo)): os.makedirs(emo)
|
| 573 |
-
_id=tp() if timebase
|
| 574 |
#base="{} {}".format(os.path.basename(src), _id)
|
| 575 |
base=_id
|
| 576 |
dst=jofn(c, "emove______", base)
|
|
@@ -584,12 +584,13 @@ def emrestore(fn="C"):
|
|
| 584 |
li=rcsr(jofn(emo,"wrld.txt"))
|
| 585 |
return li
|
| 586 |
return (li[-400:])
|
| 587 |
-
def fripfn(a,b):
|
| 588 |
-
aff=a+"fripfn"
|
| 589 |
-
os.rename(a,aff)
|
| 590 |
-
os.rename(b,a)
|
| 591 |
-
os.rename(aff,b)
|
| 592 |
#emove(r"r:\02zv.txt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 593 |
#2remove
|
| 594 |
def orsplit1(te,Threshold=1):
|
| 595 |
return [j for j in te.splitlines() if len(j)>=Threshold and j[0]!="#"]
|
|
@@ -599,10 +600,11 @@ def orsplit(te,delimiter):
|
|
| 599 |
return t3
|
| 600 |
def orsplit2(te,delimiter,threshold=5,strip=fpreturn):
|
| 601 |
"VzComment"
|
| 602 |
-
t2=te.
|
| 603 |
l1list=[[strip(f) for f in j.split(delimiter)] for j in t2 if len(j)>=threshold and j[0]!="#"]
|
| 604 |
return l1list
|
| 605 |
def colonsplit(te): return orsplit2(te,":",strip= str.strip)
|
|
|
|
| 606 |
##def orsplit3(te,delimiter):
|
| 607 |
## "VzCommentCsv"
|
| 608 |
## t2=te.split(lf)
|
|
@@ -769,11 +771,7 @@ def rnz(te,li,opt=re.S|re.I):
|
|
| 769 |
ir=re.compile(s,opt);#DOTALL|IGNORE ##|re.X=VERBOSE
|
| 770 |
te=ir.sub(d,te);
|
| 771 |
return te
|
| 772 |
-
|
| 773 |
-
for l in li:
|
| 774 |
-
mo=re.match(l[0],url);
|
| 775 |
-
if mo :return l[1]
|
| 776 |
-
raise Exception ("no such url");
|
| 777 |
def sas(reg,te,bug=False,**ww):
|
| 778 |
teli=[te]
|
| 779 |
#reg=([(re.compile(f[0]),f[1]) for f in f2] for f2 in reg)
|
|
@@ -1721,13 +1719,13 @@ def wfupdate(fn,pat,count):
|
|
| 1721 |
return te
|
| 1722 |
if 1:
|
| 1723 |
def pmobile(*w,**W):
|
| 1724 |
-
pmobilelib=impt((os.environ["
|
| 1725 |
return pmobilelib.pmobile(*w,**W)
|
| 1726 |
def fppmobile(*w,**W):
|
| 1727 |
-
pmobilelib=impt((os.environ["
|
| 1728 |
return pmobilelib.fppmobile(*w,**W)
|
| 1729 |
def note():
|
| 1730 |
-
return impt(os.environ["
|
| 1731 |
global_app=iniap()
|
| 1732 |
return "note+"
|
| 1733 |
def x4():
|
|
@@ -1752,25 +1750,16 @@ import importlib; from importlib import import_module
|
|
| 1752 |
find_spec=getattr(importlib,b'\x75\x74\x69\x6C'.decode()).find_spec
|
| 1753 |
module_from_spec=getattr(importlib,b'\x75\x74\x69\x6C'.decode()).module_from_spec
|
| 1754 |
importtool=getattr(importlib,b'\x75\x74\x69\x6C'.decode())
|
| 1755 |
-
def
|
| 1756 |
dir,fir=lfn.split(fn)
|
| 1757 |
-
|
| 1758 |
cf=cfile(fn)
|
| 1759 |
if cf in sys.modules:
|
| 1760 |
mod=sys.modules[cf]
|
| 1761 |
if reload: importlib.reload(mod)# orText() not found
|
| 1762 |
else:
|
| 1763 |
-
|
| 1764 |
-
|
| 1765 |
-
else:
|
| 1766 |
-
if not ifexist(fn): fn+=".py"
|
| 1767 |
-
spec=importtool.spec_from_file_location(cf,fn)
|
| 1768 |
-
assert spec, "import from file location;"+fn
|
| 1769 |
-
if lazy: spec.loader = LazyLoader(spec.loader)
|
| 1770 |
-
mod = module_from_spec(spec)
|
| 1771 |
-
sys.modules[cf] = mod
|
| 1772 |
-
if "import": getattr(spec.loader, b'\x65\x78\x65\x63_\x6D\x6F\x64\x75\x6C\x65'.decode())(mod)
|
| 1773 |
-
#if dir: sys.path.pop()
|
| 1774 |
return mod
|
| 1775 |
def impt(fn,reload=True, lazy=False, **_):
|
| 1776 |
dir,fir=lfn.split(fn)
|
|
@@ -1789,6 +1778,7 @@ def impt(fn,reload=True, lazy=False, **_):
|
|
| 1789 |
if not ifexist(f9): f9+=".py"
|
| 1790 |
spec=importtool.spec_from_file_location(cf,f9)
|
| 1791 |
assert spec, "import from file location;"+f9
|
|
|
|
| 1792 |
if lazy: spec.loader = LazyLoader(spec.loader)
|
| 1793 |
mod = module_from_spec(spec)
|
| 1794 |
sys.modules[cf] = mod
|
|
@@ -1839,7 +1829,7 @@ if __name__ == '__main__':
|
|
| 1839 |
if n:print(len(n),n)
|
| 1840 |
## prexit(emrestore("c"))
|
| 1841 |
if hw.new36:# f-string
|
| 1842 |
-
print(f"f-string: {hw.new36:,}
|
| 1843 |
#Operator precedence() ~ / + >> & ^ | in > not and or if
|
| 1844 |
##npp(r'"C:/cpy/Mjmoji/pr/give it try.pyw" -n2')
|
| 1845 |
#compilev(r"(?<=1).*?(?=\n)").sub("2","1\nfw\n")
|
|
|
|
| 1 |
# -*- coding: utf-8 -*-
|
| 2 |
robe_version="1;;"
|
| 3 |
+
##import sys;import os;sys.path.append(os.environ["cpy"]+r"\Mjmoji");from wr import * ;
|
| 4 |
##import mlwebOrWeb as ml
|
| 5 |
## wardrobe
|
| 6 |
|
|
|
|
| 547 |
os.remove(fn)
|
| 548 |
return 1
|
| 549 |
def remo(fn): return remove(fn,add=0)
|
| 550 |
+
|
| 551 |
_perf_counter0=time.perf_counter()
|
| 552 |
def perf_counter():
|
| 553 |
return time.perf_counter()-_perf_counter0
|
|
|
|
| 570 |
c=os.path.splitdrive(src)[0]+os.path.sep #c:
|
| 571 |
emo=jofn(c, "emove______")
|
| 572 |
if not(os.path.exists(emo)): os.makedirs(emo)
|
| 573 |
+
_id=tp()# if timebase
|
| 574 |
#base="{} {}".format(os.path.basename(src), _id)
|
| 575 |
base=_id
|
| 576 |
dst=jofn(c, "emove______", base)
|
|
|
|
| 584 |
li=rcsr(jofn(emo,"wrld.txt"))
|
| 585 |
return li
|
| 586 |
return (li[-400:])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 587 |
#emove(r"r:\02zv.txt")
|
| 588 |
+
def fripfn(*w):
|
| 589 |
+
ff=w[0]+"fripfn"
|
| 590 |
+
os.rename(w[0],ff)
|
| 591 |
+
os.rename(w[1],w[0])
|
| 592 |
+
os.rename(ff,w[1])
|
| 593 |
+
|
| 594 |
#2remove
|
| 595 |
def orsplit1(te,Threshold=1):
|
| 596 |
return [j for j in te.splitlines() if len(j)>=Threshold and j[0]!="#"]
|
|
|
|
| 600 |
return t3
|
| 601 |
def orsplit2(te,delimiter,threshold=5,strip=fpreturn):
|
| 602 |
"VzComment"
|
| 603 |
+
t2=te.split("\n")
|
| 604 |
l1list=[[strip(f) for f in j.split(delimiter)] for j in t2 if len(j)>=threshold and j[0]!="#"]
|
| 605 |
return l1list
|
| 606 |
def colonsplit(te): return orsplit2(te,":",strip= str.strip)
|
| 607 |
+
def colonsplitf(fn): return orsplit2(wfd(fn).r(),"\t:",strip= str.strip)
|
| 608 |
##def orsplit3(te,delimiter):
|
| 609 |
## "VzCommentCsv"
|
| 610 |
## t2=te.split(lf)
|
|
|
|
| 771 |
ir=re.compile(s,opt);#DOTALL|IGNORE ##|re.X=VERBOSE
|
| 772 |
te=ir.sub(d,te);
|
| 773 |
return te
|
| 774 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|
|
|
|
| 1719 |
return te
|
| 1720 |
if 1:
|
| 1721 |
def pmobile(*w,**W):
|
| 1722 |
+
pmobilelib=impt((os.environ["cpy"]+f"/escape/nagano/e3escapeMtm"),reload=0);
|
| 1723 |
return pmobilelib.pmobile(*w,**W)
|
| 1724 |
def fppmobile(*w,**W):
|
| 1725 |
+
pmobilelib=impt((os.environ["cpy"]+f"/escape/nagano/e3escapeMtm"),reload=0);
|
| 1726 |
return pmobilelib.fppmobile(*w,**W)
|
| 1727 |
def note():
|
| 1728 |
+
return impt(os.environ["cpy"]+r"/qt/lib"+"/qNote1", reload=0)
|
| 1729 |
global_app=iniap()
|
| 1730 |
return "note+"
|
| 1731 |
def x4():
|
|
|
|
| 1750 |
find_spec=getattr(importlib,b'\x75\x74\x69\x6C'.decode()).find_spec
|
| 1751 |
module_from_spec=getattr(importlib,b'\x75\x74\x69\x6C'.decode()).module_from_spec
|
| 1752 |
importtool=getattr(importlib,b'\x75\x74\x69\x6C'.decode())
|
| 1753 |
+
def impt1(fn,reload=True, lazy=False, **_):
|
| 1754 |
dir,fir=lfn.split(fn)
|
| 1755 |
+
sys.path.append(os.path.abspath(dir))
|
| 1756 |
cf=cfile(fn)
|
| 1757 |
if cf in sys.modules:
|
| 1758 |
mod=sys.modules[cf]
|
| 1759 |
if reload: importlib.reload(mod)# orText() not found
|
| 1760 |
else:
|
| 1761 |
+
mod=import_module(cf)#pass
|
| 1762 |
+
if dir: sys.path.pop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1763 |
return mod
|
| 1764 |
def impt(fn,reload=True, lazy=False, **_):
|
| 1765 |
dir,fir=lfn.split(fn)
|
|
|
|
| 1778 |
if not ifexist(f9): f9+=".py"
|
| 1779 |
spec=importtool.spec_from_file_location(cf,f9)
|
| 1780 |
assert spec, "import from file location;"+f9
|
| 1781 |
+
assert ifexist(f9), (cf,f9)
|
| 1782 |
if lazy: spec.loader = LazyLoader(spec.loader)
|
| 1783 |
mod = module_from_spec(spec)
|
| 1784 |
sys.modules[cf] = mod
|
|
|
|
| 1829 |
if n:print(len(n),n)
|
| 1830 |
## prexit(emrestore("c"))
|
| 1831 |
if hw.new36:# f-string
|
| 1832 |
+
print(f"f-string: {hw.new36:,} string:left,{hh!s:>22}")
|
| 1833 |
#Operator precedence() ~ / + >> & ^ | in > not and or if
|
| 1834 |
##npp(r'"C:/cpy/Mjmoji/pr/give it try.pyw" -n2')
|
| 1835 |
#compilev(r"(?<=1).*?(?=\n)").sub("2","1\nfw\n")
|