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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2ebd074
7743d5a
 
0e6f104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1eb4c1c
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
# -*- coding: utf-8 -*-
robe_version="1;;"
##import sys;import os;sys.path.append(os.environ["cpy"]+r"\Mjmoji");from mw import * ;
##import mlwebOrWeb as ml
## wardrobe

import sys,os,re
import shutil
import inspect
import time
import traceback
import pprint
import functools
if "Byte":
                                                                                    from                io import StringIO, BytesIO


lf= "\n";lff=lf*2;sp="  ";lf2="\n";tab="\t";
def fpreturn(*_): return _[0]
def fpre(*_): return _
pr=print
tfolder="r:/temp"
if not os.path.exists(tfolder): tfolder=os.environ["tmp"]
if "cpa" in os.environ:
    cpy=os.path.abspath(__file__+"\\..\\..")
    cpw=os.path.abspath(__file__+"\\..")
    T45=os.environ["USERNAME"]
    cpa=os.environ["cpa"]
    ZVCherryPicker=cpy+"\\qt\\ZVCherryPicker.pyw"
    HeartNote=cpy+"\\qt\\HeartNote.pyw"
else:
    cpa=None

class p310:# require version
    def __getstate__(zl):return #pickle

membile={}
def membile(fp,membile=membile):
    membilefp=membile.setdefault(fp,{})
    @functools.wraps(fp)
    def f(*w,**W):
        if(p:=membilefp.get((w,str(W)))):return p
        p=fp(*w,**W)
        membilefp[(w,str(W))]=p
        return p
    f.membile=membilefp
    return f






def rint(w):
    if not typeint(w):
        assert 0,"not rint"
    return int(w)
def typeint(w):
    try:
        int(w)
        return True
    except:False
def typefn(fn,remove=0):
    if (re.search(r'["*/:<>?\\|]',(fn))):return
    if (".." in fn):return
    if len(fn)>255:return
    try:
        open(fn,"ab")
##        if remove: os.remove(fn)
        return 1
    except:False
def fpf(fn,fb="",tail=""):
    if not typefn(fn):
        if not fb:
            f,e=lfn.splitext(fn)
            fb=f[:200]+e
        fn=fb
    if tail: wfdb(fn+"_", putp(1,tail))
    return fn
def putp(fl,te):#,*w,**W):
    import pickle
    put=pickle.dumps
##    print(te)
    if fl==1: te= put(te)
    if fl==2: te= pickle.loads(te)
    return te
def exrange(li,step=2):
    if len(li)/step < 0: return
    for x in range(0,len(li)//step):
        yield li[x*step:x*step+step]
def pr2(*a,**k): pass;
oriAB=lambda x: (print(x[:122],lf*2,x[-122:]))
ppf=pprint.pformat
def orib(lii, ix=-1,bound=4):
    "print(li[:4],li[-4:])"
    if(ix==-1):
        lambda x: (print(x[:4],lf*2,x[-4:]))
    else:
        lio=[lii[ix+n]  for n in list(range(-bound,bound)) if(ix+n>0 and ix+n<len(lii)) ]
        for v in lio:
            if(v==lii[ix]):lio[lio.index(v)]="__"+v
##        lio[ix]="__"+lio[ix]
        #lio[ix]+=lf
        print(lfjw(lio))
def printline(*a,**k):#X/ref
    f=inspect.currentframe()
    if(sys.version=='3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)]'):
        no=inspect.currentframe(1)
    elif(sys.hexversion>=0x030401F0):#'3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)]'):
        "c7 3.7.7 64bit -> 3.8.6"
        fb=f
        for _ in range(4):
            print(fb.f_lineno,fb.f_code.co_filename, fb.f_code.co_name)
            fb=fb.f_back
            if not fb:
                break
##    print(" L-"+str(no),*a,**k)
def prfl(li):#prFirstLast
    print(li[0],lf,li[-1]);
def pren(v):
    print(list(enumerate(v)))










#mrk1------------file
def wfdb(filename,te):#writeFileDirectInBinaryMode
    f = open(filename,"wb")
    f.write(te)
def wfdt(filename,te):#text
    return wfd(filename).t(te)
def wfdt8L(filename,te):#textUni NewLine Unix Format
    f = open(filename,"wU",encoding="utf-8")
    f.write(te)
def wfd8(fn,te):
    wfd(fn).w(te,code="utf8",copy=0)
def afdt(filename,te):#textUni
    f = open(filename,"a+",encoding="utf-8")
    f.write(te)
write8dd=afdt
afdtu=afdt
def rfdb(fn):
    f = open(fn,"rb")
    te = f.read()
    return te
def rfdt(fn):return wfd(fn).r()
def rfdl(fn):
    f = open(fn,"r")
    te = f.readlines()
    return te
def rfdv0(fn,codeList=("cp932","utf-16","utf-8","eucjp"),lines=True):
    for c in codeList:
        f = open(fn,"r",encoding=c)
        try:
            te = f.readlines() if(lines)else f.read()
            break
        except UnicodeDecodeError as XP:
            continue;
        except UnicodeError as XP:
            continue;
    return te
def rfdlv(fn): return rfdv0(fn)
def rfdtv(fn): return rfdv0(fn,lines=False)
def rfdtu(fn):
    f = open(fn,"r",encoding="utf-8")
    te = f.read()
    return te
def vcs(bte,cs=("utf8","cp932","utf16","eucjp")):
    for c in cs:
        try:        return bte.decode(c)
        except: continue
class wfd():#clWfd
    tab="\t"
    def __init__(zl,fn,region=(),ir=None,lf="\n"):
        zl.fn=fn
        zl.code="utf8"
        zl.lf=lf
        zl.ir=ir#
        zl.by=None
    def readtime(zl,mod=0):
        zl.ts=(lfn.getatime(zl.fn)+mod, mtime(zl.fn)+mod)
        return zl
##    def restoretime(zl):
    def rfdv(zl):return zl.r(cs=("cp932","utf-16","utf-8","eucjp","mbcs"))#noMbcs)
##    def mem(zl): zl.by=zl.rb(); return zl;
    def rb(zl): return open(zl.fn,"rb").read()
    def r(zl,cs=("utf8","cp932","utf16","eucjp"),lines=False,m=0,te=""):
        if te: e1=te
        else:
          with open(zl.fn,"rb") as f:
            e1 = f.read()
        for c in cs:
            try:
                t1=e1.decode(c)
                if("\r\n" in t1):
                    #if(t1.count("\r")!=t1.count("\n")):return 0
                    zl.lf="\r\n"
                elif("\n" in t1):zl.lf="\n"
                elif("\r" in t1):zl.lf="\r"
                else:#oneline
                    pass
                if lines: te=t1.splitlines()
                else: te=t1
                #te=te.replace(zl.lf, "\n")
                zl.code=c
                break
            except (UnicodeDecodeError, UnicodeError) as e:
                zl.lastException=e
                continue;
        else:
            return 0
        if(zl.ir) and 0:
            te=zl.lte=findall(zl.ir,te)
        if m: #chk modified
            import hashlib
            zl.mtime=mtime(zl.fn)
            zl.sha=hashlib.sha256(te.encode()).digest()
        return te
    def csvr(zl,*aw,lf=None,tab=None,**kw):
        return list(csv.reader(StringIO(zl.r()), delimiter=tab or zl.tab))
    def w8(zl,te): return zl.w(te,code="utf8")
    def w16(zl,te): return zl.w(te,code="utf_16_LE")
    def wjis(zl,te): return zl.write8re(zl.fn,te,"cp932")
    def write8re(zl,fn,te,code="",lines=False,copy=True,lf=1,nbase=0,ts=0):
        if not code: code=zl.code
        dir = lfnd(fn)
        if dir: inidi(dir)
        if(ifexist(fn) and copy):
            dnRestore=f"{tfolder}/restore"
            inidi(dnRestore)
            zl.fnRestore=nxNumFull(dnRestore,"%s"+lfn.split(fn)[1],nZfill=2) if nbase else jofn(dnRestore,cfile(fn)+" "+tp())
            shutil.copy2(fn,zl.fnRestore)
##            emove__
            rmbat(zl.fnRestore)
##        if(type(te)!=str):return 0
        if 1:
            Lf=(zl.lf if lf==1 else lf)
            t1=jw(Lf,te) if lines else te
            #no t1=zl.CallBackCaller() if zl.ir else t1
            e1=t1
            if isinstance(e1, str): e1=e1.encode(code)
        try:
            with open(fn, 'wb') as fo:
                fo.write(e1)
        except Exception as e:
            #restore()
##            zl.LastError=e
            open(r"r:\fail reason.txt","w").write(str(e))
            open(r"r:\fail "+tp()+".txt", "wb").write(e1)
            #with open(nxNumFull(r"r:","%s"+os.path.split(fn)[1],nZfill=2), 'wb') as fo:
            return 0
        if ts==1: os.utime(zl.fn, zl.ts)
##        finally:
        if 0:
##            t2=rfdtv(fn)
            fo=wfd(fn)
            t2=fo.r(cs=("utf8","utf16","eucjp","cp932"))
            print(fo.code,t2)
##            print(fnRestore,t2)
            #diff()
        return 1
##    def write8re(zl,fn,te,*aw,**kw):print("w;",fn,len(te), lf, dif32(zl.r(),te))
    def w(zl,te,*a,**k):return zl.write8re(zl.fn, te, *a, **k)
    def t(zl,te,*a,**k):
        rmbat(zl.fn,rembat="wf t.bat")
        return zl.write8re(zl.fn, te,copy=False *a, **k)
    def CallBackCaller(zl):
        te=zl.r((zl.code,))
        rnte=""
        l=0
        for n,ran in enumerate(zl.lte):#range list.appended(ire.search)
            rnte+=te[l:ran[0]]
            rnte+=zl.cb(n)
            l=ran[1]
        rnte+=te[l:]
        return rnte
def ornkf(byte,cs=("utf8","cp932","utf16","eucjp"),lines=False):
        return
        for c in csf:
            try:
                t1=e1.decode(c)
                if("\r\n" in t1):
                    if(t1.count("\r")!=t1.count("\n")):return 0
                    zl.lf="\r\n"
                elif("\n" in t1):zl.lf="\n"
                elif("\r" in t1):zl.lf="\r"
                else:#oneline
                    pass
                if lines: te=t1.splitlines()
                else: te=t1.replace(zl.lf, "\n")
                zl.code=c
                break
            except UnicodeDecodeError as XP:
                continue;
            except UnicodeError as XP:
                continue;
        else:
            return 0
##        with open(zl.fn, "rb", encoding=zl.code):
        return te








#----mrk1-----------
def line():
    return inspect.currentframe().f_back.f_lineno
def cmpd(te,tf):#cmpDokomade.Use for comic rename
    for n in range(999):
        if te[n] != tf[n]:
            return n
def cmpfs(li):
    "os.path.commonprefix(list)"
    ip=min(compd(li[0],f) for f in li)
    return ip
def wfy(li,ws=5):# windowfy function, window size
    for n,f in enumerate(li):
        yield li[n:n+5]
##def orin(te=" input"):
##    print(te)
##    input()
def owari():
    print("\nowari:");
    input("owari:")


from argparse import ArgumentParser
def arx(a=None):#Exe
    parser = ArgumentParser(description="command_error")
    parser.add_argument("-f",type=str)
    parser.add_argument("-re",type=str)
    parser.add_argument("fil",nargs="*")
    arps=parser.parse_args(a)
    return arps
def a2a(li):
    return jw(" ",('"{}"'.format(f) for f in li))
def chdir(x=0):
    os.chdir(lfnd(sys.argv[x]))
class pushd:
    def __init__(sl,dir):
        if 1: inidi(dir)
        sl.dL=os.getcwd()
        os.chdir(dir)
    def __enter__(sl):
        return 1
    def __exit__(sl, _type, value, traceback):
        os.chdir(sl.dL)
"contextmanager"
##@contextmanager
##def __pushd(dir):
##    try: yield chdir(pop:=dir)
##    finally: chdir(pop)
def chdirc(fil=0,idx=1):# mv to z droped file
    if not fil:fil=sys.argv[1:]
    if isinstance(fil,(hhww)): fil=fil.fil
    if not fil:
        pr("please drop off the file");input("chdirc()");
    else:
        os.chdir(lfnd(fil[0]))
        return fil

def chdirm():# mv to z file own is in
    chdirc(args=sys.argv,idx=0)

def cdn(args = sys.argv):#ChDirNakereba 引数があればそのディレクトリに。なければスクリプトの
    if(len(args) == 1):
        lena=0;
    else:
        lena=1;
    argf= args[lena]
    d=re.match(r"(.+(?:\\|/))",argf).group(1)
    os.chdir(d)
#    a=input(argf)
    return args[1:];
#r:\p\fi.mkv
#r:\p
#r:\p #fi
#fi.
#fi.mkv
#.mkv
#mkv
def cdir(fn):return lfnd(fn)
def cdiy(argf):#+yen
    return argf[:argf.rfind('\\')+1]#fail .-1+1=0 .""
def cfile(fn):return lfnb(lfn.splitext(fn)[0])
def cdotc(fn):return lfnb(fn)
def catsuff(fn,suf):#foo.mkv, mp4 >> foo.mp4
    tail=fn.rfind('.')
    if(tail==-1):tail=None
    fnre=fn[:tail]+"."+suf
    if(fnre==fn):
        return "onaji"
    return fnre
replaceSuffix=catsuff
def catpref(fn,prefix):
    "/foo.mkv, f2 >> /f2foo.mkv"
    yenpos=fn.rfind('\\')
    if(yenpos==-1):
        fnre=prefix+fn
    else:
        fnre=fn[:yenpos]+'\\'+prefix+fn[yenpos+1:]
    return fnre
def CatPS(fn,p,s):
    return catsuff(catpref(fn,p),s)
#
if "jwdir":
    def lgest(lis):
        l=lis[0]
        for l2 in lis:
            if l2>l: l=l2
        return l
    def notanybad(lis):
        for f in lis:
            if not f: return False
        return True
    #from jwdir import *
    jwdir=getattr(os.path,b'\x6A\x6F\x69\x6E'.decode())
    jofn=jwdir
    def jw(te,list):
        assert isinstance(te,(str,bytes))
        #assert 1==len(typ:=set(type(f) for f in [te,*list])), ["type not unique ",typ]
        assert hasattr(list,"__iter__")
        return getattr(te,b'\x6A\x6F\x69\x6E'.decode())(list)
    lfjw=functools.partial(jw, lf)
    _lfn="LibFileName"#="lfn"
    lfn=os.path
    lfnd=lfn.dirname
    lfndir=lfn.dirname
    lfnb=lfn.basename
    mtime=lfn.getmtime
    ctime=lfn.getctime
    n12=__builtins__[b'\x65\x6E\x75\x6D\x65\x72\x61\x74\x65'.decode()]
    def fpn1(lis):
        if isinstance(lis,(dict)): return getattr(lis,b'\x69\x74\x65\x6D\x73'.decode())()
        return n12(lis)
    sleep=getattr(time,b'\x73\x6C\x65\x65\x70'.decode())
    def shuttown(stdin,*w):
        assert hasattr(stdin, b'\x63\x6C\x6F\x73\x65'.decode())
        return getattr(stdin,b'\x63\x6C\x6F\x73\x65'.decode())(*w)














def dq(te):#double quote
    if(te[0] != '"' or te[-1] != '"'):
        return '"'+te+'"';
def prit(*w):
    te=jw(" ", [str(f) for f in w])+lf;
    print("---")
    print(te, end="");
    if w[:1]==(1,):input("*")
    sys.exit();
prexit=prit
def inidi(pdir):
    if os.path.exists(pdir): return 1
    else:os.makedirs(pdir); return 0
def inidir(*dirlist):
  with pushd("."):
    for f in dirlist:
        assert type(f)==str, "inidir;"
        #f=os.path.abspath(f)
        if not f:
            os.chdir("..")
            continue
        p=os.path.split(f)
        if(p[0]):#"c:\dir\"
            if not lfn.exists(p[0]):os.makedirs(p[0])
            assert lfn.isdir(p[0])
            os.chdir(p[0])
        if(p[1]):#"c:\file" > ("c:\", "file")
            if not os.path.exists(f):wfdb(f,b"")
def isdir(fn):
    if os.path.isdir(fn): return fn;
    if os.path.isfile(fn): return 0;
    if os.path.islink(fn): return 0;

def isBound(length,index):
    if(length<0):
        index=abs(index+1)
    return bool(length>index)
def boundary(x,b):
    if b[0]>x:x=b[0];
    if b[1]<=x:x=b[1]-1
    return x
def ifexist(fn):#return True
    return lfn.exists(fn)
def AbImage1(fs,grouping=False):#連番を表示しない。冗長になるのを防ぐ
    lioView=[]
    DiNameTm=puni()
    for fn in fs:
        NameTm=re.sub(r"\d","5",fn)
        DiNameTm.up(NameTm,fn)
    #
    ireTailNm=re.compile(r"(\d+)")
    def fTailNm(fn):#return rearest number
        fn=re.sub(r"(mp4|mp3)","",fn)
        mo=ireTailNm.findall(fn)
        if mo:
            Nm=int(mo[-1])
            return Nm
        return 0
    if grouping:
        d2=list((k,sorted(v,key=lambda e: -fTailNm(e))) for k,v in DiNameTm.items())
        l1=[[" "+f[0]]+f[1:grouping] for k,f in d2]
        lioView=[f1 for f2 in l1 for f1 in f2]
    else:
        lioView=[max(v,key=fTailNm) for k,v in DiNameTm.items()]
    return lioView
def orror(*a,**k):
    te=jw(" ",(str(f)for f in a)) + lf;
    afdt("orror00.txt",te)
def orro2(*a,**k):
    te="";
    for f in a:
        ty=type(f);
        if(ty==int):
            ti=str(f);
            te= te+ti
        else:
            te+=f;
        te+=" ";
    te+=lf;
    afdt("orror00.txt",te)
def orro3(fn,te0=None,sp=" "):
    if(te0!=None):
        wfd(fn).w(te0,copy=False)
    def f(*a,**k):
        te=jw(sp,[str(t) for t in a]);
        afdt(fn,te+lf)
        return te
    return f;

def move2(src,dist, rec=0):
    if dist==src: return
    distdir=lfn.dirname(dist)
    if distdir and not(ifexist(distdir)): os.makedirs(distdir)
    if rec: afdt("r:\\temp\\rename.txt",dist+tab+src+lf);
    os.rename(src,dist);
##def move2(src,dist): move2(dist,src,0)

def rmbat(fns,rembat="rmbat.bat",tmd=tfolder):#jis only
    rembat=tmd+"/"+rembat
    if not ifexist(rembat): afdt(rembat, 'chcp 65001\r\n')
    for fn in fns if type(fns)!=str else [fns]: afdt(rembat,'del "{fn}"\r\n'.format(fn=lfn.abspath(fn)))
orRemove=rmbat
def remove(fn,add=1):
    if not ifexist(fn):return
    if add: afdt(r"r:\temp\rename.txt",":rm"+"\t"+fn+lf);
    os.chmod(fn,0o770)
    if lfn.isdir(fn):
        shutil.rmtree(fn)
    elif lfn.isfile(fn):
        os.remove(fn)
    return 1
def remo(fn): return remove(fn,add=0)

_perf_counter0=time.perf_counter()
def perf_counter():
    return time.perf_counter()-_perf_counter0
def timepref(w=5,n=2):# zero width, after z decimal point
    return time.strftime("%Y%m%d-%H%M%S")+"-{t:0{w}d}".format(w=w,t=time.perf_counter_ns()//(1000000000//10**n))
from datetime import datetime, timedelta, timezone
JST = timezone(timedelta(hours=+9), 'JST')
##def today():
_now=0
def tp(te="%Y%m%d-%H%M%S",n=2, JST=JST ):#%f
    global _now
    while 1:
        ((t:=datetime.now(JST)))
        now=t.strftime(te)
        if n:now+="-{}".format(f"{t.microsecond:06}"[:n])
        if _now!=now:break
    _now=now
    return now

def emove(src,timebase=True):
    src=os.path.abspath(src)
    c=os.path.splitdrive(src)[0]+os.path.sep #c:
    emo=jofn(c, "emove______")
    if not(os.path.exists(emo)): os.makedirs(emo)
    _id=tp()# if timebase
    #base="{} {}".format(os.path.basename(src), _id)
    base=_id
    dst=jofn(c, "emove______", base)
    afdt(jofn(emo,"wrld.txt"),src+"\t"+base+lf);
    os.rename(src,dst)
    return dst
def emrestore(fn="C"):
    if len(fn)==1:
        emo=jofn(fn[0]+":/", "emove______")
    else:emo=fn
    li=rcsr(jofn(emo,"wrld.txt"))
    return li
    return (li[-400:])
#emove(r"r:\02zv.txt")
def fripfn(*w):
    ff=w[0]+"fripfn"
    os.rename(w[0],ff)
    os.rename(w[1],w[0])
    os.rename(ff,w[1])

#2remove
def orsplit1(te,Threshold=1):
    return [j for j in te.splitlines() if len(j)>=Threshold and j[0]!="#"]
def orsplit(te,delimiter):
    t2=te.split(lf)
    t3=[j.split(delimiter) for j in t2 if len(j) > 0]
    return t3
def orsplit2(te,delimiter,threshold=5,strip=fpreturn):
    "VzComment"
    t2=te.split("\n")
    l1list=[[strip(f) for f in j.split(delimiter)] for j in t2 if len(j)>=threshold and j[0]!="#"]
    return l1list
def colonsplit(te): return orsplit2(te,":",strip= str.strip)
def colonsplitf(fn): return orsplit2(wfd(fn).r(),"\t:",strip= str.strip)
##def orsplit3(te,delimiter):
##    "VzCommentCsv"
##    t2=te.split(lf)
##    l2list=[j.split(delimiter) for j in t2 if j[0]!="#"]
##    return l2list
def orsub(map0,te):
    pat=jw("|",map(lambda e:re.escape(e),map0));
##    pr(pat);
    irfinal=re.compile(pat)
    def f6(mo):
        mg= mo.group(0);#[0];
        if (mg in map0):
            mg=map0[mg];
        else:
            assert 0,("orsub");
        return mg;
    t2=irfinal.sub(f6,te);
    return t2;
def orsubne(map0,te):#NonEscape
    pat=jw("|",map0);
##    pr(pat);
    irfinal=re.compile(pat)
##    mapi={orsub({r"\[":"[",r"\]":"]",r"^":"","$":""},k):v for k,v in map0.items()}
    def f6(mo):
        mg= mo.group(0);#[0];
        li=[v for k,v in map0.items() if re.match(k,mg)]
        if li:pass
        else:
            assert 0,("orsub")
        return mg;
    t2=irfinal.sub(f6,te);
    return t2;
#
def findall(ire,te,rebuild=0):
    ire=re.compile(*ire) if not isinstance(ire,re.Pattern) else ire
    ran=(0,0)#range
    while 1:
        mo=ire.search(te,ran[1])
        if(mo):
##            print(mo,mo.groups())
            if rebuild:
                yield (ran[1],mo.span()[0]), 0
                yield mo.span(), mo
            else: yield mo
            ran=mo.span()
        else:break
    if rebuild: yield (ran[1], len(te)), 0
#2regex
##prexit(findall(re.compile(r"(\d*) (?=<d>\d*)a"),"1 2a"))
##prexit(findall(re.compile(r"(\d)(?P<d2>2)?"),"123 1 12"))
##prexit(list(findall((r"('.+?')",),"1'2'3 '1' 12",rebuild=1)))
def dif1(prefix,pat="#mrk1"):
    ir1=compilev(pat)
    mo=ir1.findall(rfdtu(sys.argv[0]))
    for n,v in enumerate(mo):
        write8("r:\\"+prefix+"%d%d"%(n,len(v))+".txt",v)
def dif2(t1,t2):
    from difflib import HtmlDiff
    df = HtmlDiff()
    return df.make_file(t1,t2)
def charjunk(c):
    return c==" \t"
def dif3(t1,t2):
    import difflib as dif
    print=orro3(r"r:\tstDiff.txt")
    print("ndiff\n",lfjw(list(dif.ndiff(t1,t2))))
    dcd=dif.Differ().compare(t1,t2)
    print("compare",list(dcd))
    unif=list(dif.unified_diff(t1,t2))
    print("unified",lfjw(unif))
    #wel print("ndiff",list(dif.ndiff(t1,t2,charjunk=charjunk)))
    con=dif.context_diff(t1,t2)
    print("context",lfjw(con))
    ir1=dif.SequenceMatcher(None,t1,t2)
    print("opcodes ",ir1.ratio(),list(ir1.get_opcodes()))
    return jw(lf,unif)
    #
def dif3tst():
    import difflib as dif
    t1="am..==d"
    t2="pm..i=="
    l1=list(t1); l2=list(t2)
    ir1=dif.SequenceMatcher(None,t1,t2)
    mo=ir1.get_matching_blocks()
    print(ir1.ratio())#equal==1.0
    print(lf,t1,lf,t2,lf,  list(mo))
    print(list(ir1.get_opcodes()))
    sys.exit()
def dif4(*T):
    import difflib as dif
    return lfjw(list(dif.unified_diff(*[t.splitlines() for t in T]))[2:])
def dif32(*T): return dif3(*[t.splitlines() for t in T])
def dif5(t1,t2, splitlines=str.splitlines):
    import difflib as dif
    f=(dif.SequenceMatcher(None,*[splitlines(t) for t in (t1,t2)]))
    return f.get_opcodes()
def difri(T,splitlines=fpreturn):
    import difflib as dif
    return (dif.SequenceMatcher(None,*[splitlines(t) for t in T]))
qfem="""
; ;;
: ;c
\\ ;y
/ ;l
" ;d
? ;q
< ;k
> ;r
| ;s
* ;a
"""#
q_fileEscapeMap={k:v for k,v in [k.split(" ") for k in qfem.split(lf) if k]}
##q_fileEscapeMap={";":";;",":":";c","\\":";y","/":";l",'"':";d","?":";q"}
def esfn(fn):#EscapeFileName;x/2
    return orsub(q_fileEscapeMap,fn );
def exfn(fn):#extract
    return orsub(puni(q_fileEscapeMap).tenchi(),fn);
time.perf_counter()
##def clock
def orbench(p):#BenchMark(Proc)K@milisecond
    t = time.perf_counter()
    tsai = time.perf_counter() - t
    t = time.perf_counter()
    rn=p()
    t = time.perf_counter() -t -tsai;
    return t,rn;

def cbbench(f):
##    @functools.wraps(f)
    def cb(*a,**k):
        timeL=time.perf_counter()
        rn2=f(*a,**k)
        rn1=time.perf_counter()-timeL
        return rn1,rn2
    return cb
def timefor(cb,lis,to,start="start",logfile=""):
    def pr(te): return afdt(logfile or tfolder+"/log for time", te+lf)
    if start: pr(start)
    ti2pre=tia0=ti0=time.perf_counter()
    x9=len(lis)
    for x1,fn in enumerate(lis):
        et=cb(x1, fn, pr)
##    if 1:
        ti2=time.perf_counter()
        eli=(ti2-ti0)
        x1p=x1+1
        ti9=eli/(x1p) * x9
        mean=eli/(x1p)
        one=ti2 - ti2pre
        ti2pre=ti2
        remain=ti9-eli
        if (ti2-tia0) > to[0]:
            te=et+f"({one:.1f}), {x1p}/{x9} ,  {eli:.1f} / {ti9:.1f}, {remain=:.1f}"
            print(te)
            pr(te)
            tia0=ti2
        if to[1] and eli > to[1]:return
        if et=="return": return et

#---------
def rnz(te,li,opt=re.S|re.I):
    for s,d in li:#src dist;
##        pr(s,"__",d);
        ir=re.compile(s,opt);#DOTALL|IGNORE ##|re.X=VERBOSE
        te=ir.sub(d,te);
    return te

def sas(reg,te,bug=False,**ww):
    teli=[te]
    #reg=([(re.compile(f[0]),f[1]) for f in f2] for f2 in reg)
    reg=([re.compile(f,re.S) for f in f2] for f2 in reg)
    for ix,(ri,rx) in enumerate(reg):
        li2=[]
        for ta in teli:
            #li2.extend([f for f in ri[0].sub(lambda e:ri[0].sub(ri[1],e), ta) if f])
            li2.extend([f for f in ri.findall(ta) if f])
        teli=li2
        if bug: afdt(r"r:\fwfw-search.txt","mrk{}\n".format(ix)+ppf(teli))
    return teli
def traverse(reg,te,bug=False,**ww):
    fn=reg; #fn.teli=[te]
    def fp1(fn,pare,F,after):
      if after:return
      fn.teli=[]
      for ta in pare.teli if pare else [te]:
        rin,rx1,rx2=fn.pat
        li=compilex(rin).findall(ta)
        for t1 in li:
            for rex in rx1:
                if rex.search(t1):continue
            fn.teli.append(t1)
      from mlwebOrWeb import webrap
##      print(fn, f"{fn.flget=}")
      if fn.flget: #fn.teli=[ webrap().gtoff(f,"utf-8") for f in fn.teli]
        li=[]
        for n1,f in enumerate(fn.teli):
            print(f"download {n1+1} / {len(fn.teli)}")
            li.append(webrap().gtoff(f,"utf-8"))
        fn.teli=li
    def mimi(fn):return fn.mimi
    lamrec(fp1,fn, mimi,F=0,pare=None)
    return
if 0:
##class reg(re):
  def compile(me,*w):
    try:
        return re.compile(*w)
    except re.error as e:e
  def sub(me,*w):
    try:
        return me.sub(*w)
    except re.error as e:
        e
compilev=lambda e:re.compile(e,re.S|re.I|re.X|re.M)
compilevs=lambda e:re.compile(e.replace(" ","\\s*"),re.S|re.I)
compilex=lambda e:re.compile(e.replace(" ","\\s*"),re.S|re.I|re.X)
compiled=lambda e:re.compile(e,re.S|re.I)
compilefn=lambda e:re.compile(e,re.I)
irealpha=re.compile(r"[_\.a-zA-Z0-9]")
def adcompile(fp):
    if isinstance(fp,str): return compilevs(fp).search
    if isinstance(fp,re.Pattern): return fp.search
    return fp



#       #-----------
def tae(p):#TryAndError例外で終了させずに表示する
    try:
        p()
    except Exception as e:
        orro4(e,lf,e.args,lf,type(e));
        return(e)
def t1t(p): return ttt(p,times=1)
def ttt(p,times=10,interval=4):# try ten times
    for n in range(times):
        try:
            return p()
        except Exception as e:
            if n+1 >= times: return e
            time.sleep(interval)
            continue
import th
cbTryLock=th.Lock()
def cbTry(f,ercb=None,lo=0,ww=(),pr=0):
##    flq=1 if hasattr(f, "__self__") and isinstance(f.__self__, orq) else 0
##    la=lambda e: a[1:]
    counter=0
    @functools.wraps(f)
    def cb(*a,**k):
        try:
            #return f(**k) if a[flq:] is (False,) else f(*a,**k)
##            print("cb;", a,f,cb)
            #return f(**k) if not a[flq:] or a[flq] is False else f(*a,**k)
            if ww:
                wwa=ww[0]
                www=ww[1] if ww[1:] else {}
                if lo==1:lg("cb", f.__qualname__, a,k,ww)
                return f(*wwa,**k,**www) if not a or a[0] is False else f(*wwa, *a,**k,**www)#pass
            if lo==1:lg("cb", f.__qualname__, a,k)
            return f(**k) if not a or a[0] is False else f(*a,**k) #pass
        ##except: except2(0,find="p",edit="npp")
        except Exception as e: # exit is not exception
        #except:
            et=0
            cb.counter+=1
            if cb.counter>10:return
            if ercb: et=cbTry(ercb)(e)
            if et:return
            if pr: print(except2(0,find=""))
            else:
##                with cbTryLock:#?
                    except2(0,find="p",edit="note")
##            e2=except2()
##            Mini(te)
            cb.counter-=1
    cb.counter=0
    return cb

def edipt(te="",find="p",edit=0,fntbl=()):
    if edit:return edipt_edit(te,find,edit,fntbl)
    e2=te or traceback.format_exc()
    e2=e2.replace("Traceback (most recent call last):","-"*9)
    if find:
        if find=="p":
##            mo=compiled((r'(?<= File ")(.*?)", line (\d+), in (.+?)\n(.*?)')).findall(e2)
            mo=compiled((r'(?<= File ")([^\n]+?)", line (\d+)(?:, in )?([^\n]*?)\n((?!  File).*?(?=\n))?')).findall(e2)
            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]) )) ]
            return (fppmobile(omiterror(e2)),mo)
        if find=="node":
            mo=compiled(r'at ([\w\.]* )?\(?(C:.*?):(\d+):(\d+)').findall(e2)
            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]) )) ]
            mo=[[w[f] for f in (1,2,0,3)] for w in mo]
            return (fppmobile(omiterror(e2)),mo)
        if 0:
            mo=re.findall(r'"<string>", line (\d+)(), in <module>\n(.*)',e2)
            return mo
    return fppmobile(omiterror(e2))
except2=edipt
def edipt_edit(te,find,edit=0,fntbl=()):
    e2=edipt(te,find=find)
    t1=e2[0].splitlines().pop()
    if "dialog rejected;" in t1: return
    if "SystemExit" in t1: return
    from qNote1 import  iniap, Mini, clhk
    from dialog_ import orDialog
    app=iniap()
    mono=orDialog()
    if not e2[1]: return Mini(e2)
    if find=="p":
        mo=[clhk(f, teh=(f"({cfile(f[0])}), {f[1]}, {f[2]}, \n{f[3]}")) for f in e2[1]]
    if find=="node":
        mo=[clhk(f, teh=(f"({cfile(f[0])}), {f[1]}, {f[2]}")) for f in e2[1]]
    if (mf:=re.search("AssertionError: (.*)", e2[0])): mo=[clhk("*", teh=mf.group(1))]+mo
    whw=[mo+[e2[0]]]
    mono.xch(whw)
    if not mono.fiFiles:return
    fn,*_=mono.pickupli()
    if type(fn)==str:return e2
    (fn,pos,mod,te)=fn
    if fn in fntbl: fn=fntbl[fn]
##    print(fn,fntbl)
    #npp(fn,f"-n{pos}")
    orPOA([HeartNote, fn, "-pos",pos,"0"])
    return e2
def omiterror(e2):
    return rnz(e2,(
("NameError: name",""),
))
def mpvstring(e2):
            #t1=e2.splitlines().pop()
            e2=re.sub(r'Traceback .+?\n','',e2)
            e2=re.sub(r'  File "C:\\cpy\\qt\\(?:clas\\)?(.+?)(?:\.pyw?)", line (\d+),',r'"\1",\2',e2)
            if "mpv property does not exist" in te:
                if(mo:=re.search(r"'(mpv property does not exist)',.*?b('.*?'),",te)): te=str(mo.groups())
                else: te="mpv not exist"
##                te=rnz(te,(
##                (r"'(mpv property does not exist)',.*?b('.*?'),",r"\1 \2"),
##                (r"\d+",""),
##                ))
def orpopen(mp3):
    import subprocess as p
    return p.Popen([mp3],shell=True);
def orPOA(cmd,shell=True):
    import subprocess as p
    return p.Popen(cmd,shell=shell);
def popen1(cmd,shell=True):
    import subprocess as p
    return p.Popen(cmd,shell=shell).wait()
##orPOA(r'start cmd /c "r:\c f.bat"')
def wiff(w):
    orPOA([mdir("wiff"),*w])
def npp(*w):
    if not w: return mdir("npp")
    orPOA([mdir("npp"),*w])
def nppw(lis,fn=tfolder+"/log"):
    wfd(fn).t(lis)
    npp(fn)
class puni(dict):
##    def update(zl,k,v): dict.update(zl,[(k,v)])
    def ez(zl,k):#di.get()
        return  zl[k] if(k in zl) else 0;
    def ud(zl,k,v):
        zl.update([(k,v)]);
    def up(zl,k,L):#update append
        if(k in zl):
            zl[k].append(L);
        else:
            zl.update([(k,[L])]);
    def uni(zl,k,L):#update append uni
        if(k in zl and L not in zl[k]):
            zl[k].append(L);
        else:
            zl.update([(k,[L])]);
    def setclr(zl,li,la):
        for nc,f in enumerate(li):
            k=la(f)
            zl.up(k,f)
        return zl
    def updateIncliment(zl,k):
        zl.ul(k,1)
    def ul(zl,k,L):#update vz Length
        if(k in zl):
            zl[k]+=L;
        else:
            zl[k]=L
    def us(zl,k):#文字ごとの生起確率
        for c in k:
            zl.ui(c);
        return zl;
##    def counter(zl,w):
    def Clip(zl,count,regexpattern="."):
        "Clip key less than count"
        ire=re.compile(regexpattern)
        return puni([(k,v) for k,v in zl.items() if(v>count)and(ire.match(k))])
    def LetterFrequency(zl,te,llen=2):
        for k in range(len(te)-llen+1):
            zl.ui(te[k:k+llen])
        return zl;
    def sortedlist(zl):#oredered list by value;
        return [[k,v] for k, v in sorted(zl.items(), key=lambda x:x[1])]
    def ok(zl):#oredered list by key;
        return [[k,v] for k, v in sorted(zl.items(), key=lambda x:x[0])]
    def ovk(zl,valuekey):#sort by appended list
        pass
    def tenchi(zl):
        li={v:k for k,v in zl.items()}
##        li=map(lambda x: x,li);
        return li;
        d=puni()
        for k,v in zl.items():
            d[v]=k;
        return d;#X/2
    def rms(zl,la):
        pops={k:v for k,v in zl.items() if la(k,v)}
        _=[zl.pop(k) for k in pops]
        return zl,pops
    #listDict
    def lipop(zl,k,cb):
        for k,v in zl.items():
            for n,v1 in enumerate(v):
                if(cb(v1)):return k,n
    def lipop1(zl,f,te):
        #{f,[[open,],[file,],[copy,],]};findcopy():lipop(f,"copy")
        return zl.lipop(f,lambda e: e[0]==te)
##    def compres(zl,w0,fp=fpreturn,uni=0):
##        for f in w0:
##            zl.compresin(f,fp)
##        return zl
    def compres(zl,f,fp=fpreturn,uni=0,te=""):#配列の長さは同じにする
        z2=zl
        if 1:
            z2=zl
            for w in f[:-1]:
                w=fp(w)
                if w not in z2: z2[w]=puni()
                z2=z2[w]
            assert isinstance(z2,puni), "not list len"#,f
            if te:
                assert f[-1] not in z2, "not list len. 123 12"#,f
                z2[f[-1]]=te
            else:
                z2.ul(f[-1],1)
            return z2[f[-1]]
    def flat(zl):
        li=[((x,),v) for x,v in zl.items()]
        for p,v in li:
            if isinstance(v,puni):
                li.extend(((*p,p2),v2) for p2,v2 in v.items())
            else:
                yield (*p,v)
class pini(puni):
    def __init__(zl,d={},fn="pini00.ini"):
        dict.__init__(zl,d);
        zl.fn=lfn.abspath(fn);
        if lfn.isfile(fn):
            f=rfdv0(fn,["utf-8"])
            for j in f:
                a=j.split("\t");
##                try:
##                    nm=float(a[1])
##                except:
##                    pass;
                if(len(a)== 2):
##                    exete='zl["%s"]=' % a[0]#.replace("\\","\\\\");
                    exete='zl[%s]=' % a[0]#.replace("\\","\\\\");
                    et2= exete+a[1];
                    exec(et2);
                else:
                    notTheFormat
    def save(zl):
        te="";
        #print(os.getcwd())
        for f,v in fpn1(zl):
            ti= repr(f) +"\t" +repr(v)+"\n";
            te+=ti;
        wfd8(zl.fn,te);#Exceptions during cleanup are always ignored; see the object.__del__() documentation:
#
def ordiMdirs():# Dictionary of Directory
    global diMdirs
    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]])
    return diMdirs
def mdir(f): return ordiMdirs()[f]
class _:
    def __init__(zl,fn,unquote=1):
        zl.fn=fn
        zl.unquote=unquote
    w=""
    def split(zl):
            zl.w={f:(v[0]) for f,*v in orsplit(wfd(zl.fn).r(),"\t") if v}
    def __call__(zl,at):
        if not zl.w: zl.split()
        return zl.w[at]
    def __getattr__(zl,at):
        return zl(at)
if cpa: mdir=_(os.environ["cpa"]+r"\data\dirs-{}.txt".format(T45))
class _(_):
    def split(zl):
        from urllib.parse import unquote
        if not zl.unquote: unquote=fpreturn
        zl.w={f:unquote(v[-1]) for f,*v in orsplit2(wfd(zl.fn).r(),"\t")}
abenatsumi=_(lfn.abspath(__file__+"/../"+"abenatsumi.txt"))
#

def fFlat(li,lirn):
    if(type(li)==list):
        for j in li:
            L1=fFlat(j,lirn)
    else:
        L1=li
        lirn.append(L1)
    return lirn
class List(list):
    def rx(zl,te):
        ir1=re.compile(te)
        zl.res=[]
        for i,j in enumerate(zl):
            mo=ir1.search(j)
            if mo:
                zl.res.append(j)
        return zl.res
    def rxenu(zl,te):
        ir1=re.compile(te)
        zl.res=[]
        for i,j in enumerate(zl):
            mo=ir1.search(j)
            if mo:
                zl.res.append((i,j))
        return zl.res
    def __lt__(zl,f): return zl.append(f)
    def __lshift__(zl,li): return zl.extend(li)
    #def __getitem__(zl,f):
    def getx(zl,f,v):
        return zl.index(f) if f in zl else v
    def u(zl,f,v):
        zl[zl.index(f)]=v
##    def up(zl,v):
orList=List
class ListHash(List):#from collections import OrderedDict
    def put(zl,k,v):#up
        1
class orLiset(set):#unique list
    pass
    def cmp(zl,ot):
        zl.cmp[x](zl[y],ot)
##        if(role=="cmp"):split(sel)
    def get(zl,x,y,role="edit"):
        return zl[y][x]
class LastOperation(List):
    def __init__(zl,li=(),threshold=30,wriIni=False,k="",uniq=True):
        zl.threshold=threshold
        zl.see=-1
        zl.uniq=uniq
        if(wriIni):#dict.setdefault()
            if(k in wriIni):
                li=wriIni[k]
            list.__init__(zl,li)
            wriIni[k]=zl
        else:
            list.__init__(zl,li)
    def rm(zl,te):
        if zl.uniq and (te in zl):
            zl.pop(zl.index(te))
    def ap(zl,te):
        if zl.uniq and (te in zl):
            zl._ap(zl.pop(zl.index(te)))
        else:
            if(len(zl)>=zl.threshold):zl.pop()
            zl._ap(te)
        zl.see=0
    def aprx(zl,te):#Word completion
        if zl.uniq and (zl.get(te)):
            zl._ap(zl.pop(zl.res[0][0]))
        else:
            if(len(zl)>=zl.threshold):zl.pop()
            zl._ap(te)
        zl.see=0
##    def _ap(zl,element):
##        zl.insert(0,element)
    _ap=lambda zl,x:zl.insert(0,x)
    def get(zl,te):
        r=zl.rxenu(te)
        return r[0]
    def up(zl):
        if(len(zl)-1>zl.see):
            zl.see+=1
        return zl[zl.see]
    def down(zl):
        if(zl.see>0):
            zl.see-=1
            return zl[zl.see]
clHistry=LastOperation
##class cycle():
class orLog(LastOperation):
    def __call__(zl,*w):
        if(len(zl)>=zl.threshold):zl.pop(0)
        zl.append((w[0],w[1:]))
        return zl
    def __repr__(zl):
        if not zl: return "[]"
        rn=[f[1] for f in zl.find(zl[-1][0])]#findByLastKey
        return str(rn)
    def find(zl,pat):
        ir1=re.compile(str(pat))
        rn= [f for f in zl if ir1.search(str(f[0]))]
        return rn
imorLog=orLog(threshold=32100)
##logi=lambda *x:imorLog.ap(x[0],x[1:])
lg=logi=imorLog
lgf=logifind=lambda x="":imorLog.find(x)
lgfv=lgf2=lambda x="":[f[1] for f in imorLog.find(x)]# value
lglf=lambda x:jw(lf,[jw(" ",[str(f) for f in l]) for l in lgfv(x)])
##jw(lf,[l for l in lgfv(x)])
lgc=lambda: imorLog.clear()
def msri(proc,lp):#mashiroInner
    fil = sys.argv
    if(len(fil) == 1):
        pr("please drop off the file");input();exit()
    for fi in fil[1:]:
        proc(fi,lp);
mashiro=msri;
gif=r"(jpg|jpeg|png|gif|tiff|jfif|webp)$"
ignoreFiles=(r"R:\TEMP",r"R:\Clip1.txt.txt",r"R:\OnClipChange1.txt",r"R:\Recycled",r'R:\System Volume Information')
def listdir(r=None,iref="",walk=False,flat=False,isdir=False):
    "f in listdir() if not(f in ignoreFiles)"
    assert ifexist(r or "."),r
    if type(iref)==str:iref=re.compile(iref,re.I).search
    li=[(jwdir(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)))]
    if isdir: li=[f for f in li if isdir(jwdir(r,f) if r else f)]
    return li
def walky(r):
    for p, ds ,fs in os.walk(r):
        for fn in ds+fs:
            yield jofn(p,fn)
def unfoldfiles(ars,ap=False):
    for fn in ars:
        if os.path.isfile(fn):
            fn
        else:
            lifn=walky(fn)
            for fn in lifn:
                fn
def orWalk(d,proc,lp):#CallBackWalk
    waw = os.walk(ddf[0])
    for r, ds ,fs in waw:
        mod=ddf[2].search(r)
        if mod :#除外子孫のフォルダをさらに(被除外リスト)出力からも除外
            lidex.append(r);
        else:
            ldir=[]
            for fc in fs:
                ldir.append(fc)
            orcb(ldir,r,ddf)
def rnWalk(d,inc,exc):
    irInc=[re.compile(f,re.I) for f in inc]
    irExc=[re.compile(f,re.I) for f in exc]
    lii=[]
    for r, ds ,fs in os.walk(d):
        dsfs=ds+fs
        for fn in dsfs:
            for ire in irInc:
                mod=ire.search(fn)
                if mod :
                    lii.append((r,fn));
                    break
    for k,(r,fn) in enumerate(lii):
            for ire in irExc:
                mod=ire.search(fn)
                if mod :
                    lii.pop(k);
                    break
    return lii
def ywalk(dn=None,dr=0,pop=-1):
    ds=[dn or os.getcwd()]
    while 1:
        cd=ds.pop(pop)
        ag=os.listdir(cd)
        if dr: ag=ag[::dr]
        for f in ag: yield cd,ag,jofn(cd,f)
        else:# not break return
            ds+=[fp for f in ag if os.path.isdir(fp:=jofn(cd,f))]
            if not ds : break
            continue
        break
while 0:
        sn=hhww(dn=listdir(r"c:\v\t",iref=isdir)[0])
        dnd=os.path.dirname(sn.dn)
        if(dnd in [r"c:\v"]): break
        for cd,fs,fp in ywalk(dnd):
            pass
        li=(list(listdir(dnd,iref=isdir)))
        ix=li.index(os.path.basename(sn.dn))
##prexit([f for f in ywalk(r"c:\v\t")])
def nxDir(fn,ceil,fs=0,dr=1):
    for n in range(9):
        dn=lfnd(fn)
        if dn in ceil:
            return
        fs=listdir(dn,flat=1)
        if fn == fs[-dr]:# -1 | 0  # last sister
            fn=dn
        else:
            if not dr: fs.reverse()
            for nxf in fs[fs.index(fn)+1:]:
                fn=jofn(dn, fs[fs.index(fn)+1])
                if os.path.isfile(fn):
                    yield fn
                else:
                    for cd, ag, fnw in ywalk(fn,dr=0 if dr else -1):
                        yield fnw
def nxfortst(*a):
    for n,f in enumerate(nxDir(*a,dr=1)):
        print(n,f)
##prexit("nxfor:",nxfortst(r"C:\v\T\eva7\cover\..jpeg",(r"C:\v",)))
def merge(li,fl="f"):
    l4=orList()
    for f1,f2 in li:
        if not f1.endswith("\\"): f1+="\\"
        li1=[f[len(f1):] for f in listdir(f1,walk=1)][::-1]
        for fe in li1:
            src=jofn(f1,fe)
            dst=jofn(f2,fe)
            assert dst.startswith(f2),(f1,f2,fe,dst)
            inidi(lfnd(dst))
            if isdir(src):
                inidi(dst)
            else:
                copy=1
                if ifexist(dst):
                    copy=0
                    if "f" in fl:# force, modi
                        copy=1
                    elif "m" in fl and (mtime(src)-mtime(dst) > 1):
                        copy=1
                if copy:
                    l4<(fe)
                    shutil.copy2(src, dst)
    return l4
#prexit(merge([[r"C:\v\T\lvlv",r"r:\hono"]],"m"))
def listDrive(ignore="ABD"):
    return [L for L in (chr(c) for c in range(65,90+1)) if os.path.exists(L+':') and (L)not in ignore]
def getFolderSize(folder):
    total_size = 0 #os.path.getsize(folder)#4096
    for item in os.listdir(folder):
        itempath = jofn(folder, item)
        if os.path.isfile(itempath):
            total_size += os.path.getsize(itempath)
        elif os.path.isdir(itempath):
            total_size += getFolderSize(itempath)
    return total_size
def lamrec(fp1,fn, fpEnum,F=0,pare=None):
    fp1(fn,pare,F,0)
    #print(" "*F, fn)
    for f2 in fpEnum(fn):
        lamrec(fp1,f2, fpEnum,F+1,fn)
    fp1(fn,pare,F,1)

def abSize(size,M="",_1024=1024):# 1234 > 1,234
    # return f"{size:,}"
    li=[];mb=""
    for heavy in "KMGTE":
        m= size % _1024
        size= size // _1024
        li.append(m)
        if(heavy==M):
            li=[]
            mb=M
        if(size):mb
        else: break
    return jw(",",("{:03}".format(f) for f in li[::-1])).lstrip("0")+mb
##prexit(_:=(1,2026,3,4) ,abSize(sum([1024**n*f for n,f in enumerate(_[::-1])]),"K"))#
def crbs(li):
 def binarySearchRec(goal,q0,q1,fpSave):
    mid = q0+(q1-q0)/2
    if q0>q1: return
    size=fpSave(mid)
    if goal == size:
       return mid
    elif goal > size:
       return binarySearchRec(goal,mid+1,q1,fpSave)
    else:
       return binarySearchRec(goal,q0,mid-1,fpSave)
 return binarySearchRec
def binarySearch(fpSave,goal,q0,q1,li):
    while q0<=q1:
          mid = int(q0+(q1-q0)/2)
          size=fpSave(mid)
          li.append((mid,size))
          if(goal == size):
             return li#mid
          elif goal > size:
             q0 = mid + 1
          else:
             q1 = mid - 1
    if 0:
          mid = (q0+(q1-q0)/2)
          size=fpSave(mid)
          li.append((mid,size))
    return li
##print(binarySearch(lambda e:e*100,501,0,20,[]))
def mvvideo(src,vfl,suffix):#VideoFolder,拡張子
    ire = re.compile(suffix,re.I)
    files = os.listdir(src)
    count=0
    for f in files:
        mo= ire.match(f)
        if(mo):
            sfi= src+"\\"+f;
            vfi= vfl+"\\"+f;
            #print(vfi,sfi)
            os.rename(sfi,vfi)
            count+=1;
    return count;
def mvdir(src,vfl,suffix):#VideoFolder,拡張子
    ire = re.compile(suffix,re.I)
    files = os.walk(src)
    count=0
    for r,ds,fs in files:
        for f in ds:
            mo= ire.match(f)
            if(mo):
                sfi= r+"\\"+f;
                vfi= vfl+"\\"+f;
                #print(vfi,sfi)
                try:
                    os.rename(sfi,vfi)
                except a as XP:
                    pass
                count+=1;
    return count;
def copyTree(src,dist,pat):
    pass
def nxnum(WorkDir,fn):#Create sequencial number filename 001~99999
    'r=nxnum(".","%sx.jpg")'
    pat=fn%r"(\d{1,3})"
    ire=re.compile(pat);
    xmax=0;
    for n in os.listdir(WorkDir):
        mo=ire.search(n);
        if mo:
            m1=mo.group(1)
            xi = int(m1)
            if(xmax < xi):
                xmax = xi
    xmax+=1
    rr = str(xmax).zfill(3);
    rr=fn%rr;
    return rr;
def nxnu2m(WorkDir,fn,nZfill=3):
    ire=re.compile(re.escape(fn)%r"(\d{1,})");
    xmax=max([0]+[int(mo.group(1)) for mo in [ire.search(f) for f in os.listdir(WorkDir)] if mo])
    rr = str(xmax+1).zfill(nZfill);
    rr=fn%rr;
    return rr;
def nxNumFull(WorkDir,fn,nZfill=3):#return FullPath
    resFn=nxnu2m(WorkDir,fn,nZfill=nZfill)
    return jofn(WorkDir,resFn)
def nxNumFullSplit(fn,nZfill=3):#FullPath
    resFn=nxnu2m(*os.path.split(fn),nZfill=nZfill)
    return jofn(os.path.split(fn)[0],resFn)
#
montail=(0,31,28,31,30,31,30 ,31,31,30,31,30,31)
import csv
class oc:#orcsv
    ordelimiter="\t"
def wcsw(fn,li):
    for code in ("cp932","utf-16"):
        try:
            with open(fn, 'w',encoding=code) as fpw:
                writer = csv.writer(fpw, delimiter=oc.ordelimiter, lineterminator='\n')
                for f in li:#
                    writer.writerow(f);
            break
        except UnicodeEncodeError as XP:
            continue;
def writecs8(fn,li):
    return wcsv(fn,li,("cp932","utf-8"))
def wcsv(fn,li,cs=("utf-8",)):
    for code in cs:
        try:
            with open(fn, 'w',encoding=code) as fpw:
                writer = csv.writer(fpw, delimiter=oc.ordelimiter, lineterminator='\n')
                for f in li:#
                    writer.writerow(f);
            break
        except UnicodeEncodeError as XP:
            continue;
def acsw(fn,li,code="cp932"):
            with open(fn, 'a',encoding=code) as fpw:
                writer = csv.writer(fpw, delimiter=oc.ordelimiter, lineterminator='\n')
                for f in li:#
                    writer.writerow(f);
def acswvp84n534983v(fn,li):
    for code in ("cp932","utf-16"):#No good
        try:
            with open(fn, 'a',encoding=code) as fpw:
                writer = csv.writer(fpw, delimiter=oc.ordelimiter, lineterminator='\n')
                for f in li:#
                    writer.writerow(f);
            break
        except UnicodeEncodeError as XP:
            continue;
def rcsr(fn):
    for code in ("utf-8",):#("cp932","utf-8","utf-8"):
        try:
            lines =[];
            with open(fn, 'r',encoding=code, newline='') as fpr:
                reader = csv.reader(fpr, delimiter=oc.ordelimiter, lineterminator='\n')
                for line in reader:
##                    print(line)
                    lines.append(line);
            return lines;
        except UnicodeDecodeError as XP:
            continue;
#list(csv.reader(['"-f" 2 9'],delimiter=" "))
##X/
def zelp0(lio,fi,irz0=re.compile(r"h/",re.I),irs=0,irx=()):
    "oList, fn, ir, List"
    tel=rfdlv(fi)
    for k,f in enumerate(tel):
        mo=irz0.search(f);
        if mo and not (irx and any(x.search(f) for x in irx)):
            if(irs):
                f=rnz(f,irs)
            lio.append((k,f))
    return lio
def orgrepir(li,fi,ir1):
    tel=rfdlv(fi)
    for k,f in enumerate(tel):
        mo=irz0.search(f);
        if mo:
            lio.append((k,f))
    return lio
def orgrep(li,fi,pat):
    ir1=re.compile(pat);
    li=orgrepir(li,fi,ir1);
    return lio;
def orgrepdir(currentdir,pat):
    filelist=os.listdir(currentdir)
    matchlist=[orgrep(f) for f in filelist]
    return matchlist;
if 1:#time
#time.strptime("1970,1,1, ","%Y,%m,%d, ")
#time.mktime(time.strptime("1976,2,29, 9,3,4.56","%Y,%m,%d, %H,%M,%S.%f"))
#time.gmtime(232.324)
#time.strftime("%Y")
#time.time();time.mktime(time.localtime())
    def timea(te):
        time.mktime((1970,1,1, 9,10,10,  3,1,0))
        time.mktime((1970,2,31, 25,66,66,  1,1,1))
        return
    def hourmin(te): return te.replace("hour","H").replace("min","M").replace("second","S")
letters='abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXY'
def letter_digit(te,ln=2,zfill=0):
    for c in te:1
def i2l(d,letters=letters):
    li2=[]
    while d:
        d,e=divmod(d,len(letters))
        li2.append(letters[e])
    return jw("",li2[::-1]) or letters[0]
#
#graph
def fncore(fn,exist=False,cc=1,fldn=0):
    fn=fn.replace("\\","/")
    fnli=fn.split("/")#.__iter__()
    for nc,f in enumerate(fnli):
        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("@")):
            if fldn: return jw("/",fnli[:nc+1])
            fn=jw("/",fnli[nc:])
            break
    pat=[("#.*?#",""),(r"[:_/]"," "),(r"\bv?(\d+)[sbw]?[e]?",r"\1"),(r" z(\d+)","")]
##    pat+=[("\(.*?\)","")]#(1)
    if not exist: fn=rnz(fn,pat).strip()
    if cc==1:fn=fn.lower()
    if cc==2:pass # camel case
    return fn
def fncx(fn): return fncore(fn,True)
def findzv(fn):
    dir,fn=lfn.split(fn)
    if not dir:dir=os.getcwd()
    for f in range(9):
        #zl+[dir,fn]
        with pushd(dir):
            if ifexist(fn): return lfn.abspath(fn).replace("\\","/")
            if not lfnb(dir): return
            dir,_=lfn.split(dir)
class clfn:
    def __init__(sl,**kw):
        sl.__dict__.update(kw)
    def __call__(sl,fn,dirs=()):
        for dn in dirs or sl.dirs:
            if lfn.exists(f2:=(dn+"/"+fn)):
                return f2
if cpa:
    pmfolder=(#r"c:\v\jext",
r"C:\Users\user\Downloads\dval\n2",
#r"C:\Users\user\Downloads\dval\t1",
r"C:\Users\user\Downloads\dval\t2",
r"C:\Users\user\Downloads\dval\t5",
r"C:\Users\user\Downloads\dval\t9",
)+tuple(jofn(r"c:\v\zv",f) for f in os.listdir(r"c:\v\zv"))
    xcore=clfn(dirs=pmfolder)
#
def _gettps(fnzv,dncore):
    fnzv= fnzv or jofn(mdir("mtm"),"data","zv.txt")
    itemdict=eval(wfd(fnzv).r())
    tps=itemdict.setdefault(dncore,dict())
    return tps
def gettps(fnzv,dncore=None):
    fnzv=jofn(*[fnzv] if fnzv else (mdir("mtm"),"data","zv"),dncore)
    if ifexist(fnzv):
        tps=puni(eval(wfd(fnzv).r()))
    else:tps=puni()
    tps.fn=fnzv
    return tps
#

##class hhwwproto(dict):pass
class hhwwproto(p310, dict):
    def __init__(zl,*aw,**kw):
##        super
        for f in aw: zl.update(f)
        zl.update(kw)
        for f,v in kw.items():
            if v==None: zl.pop(f)
    def str(zl,order=None, sp=" : ", lf=lf, ls=repr):
        return jw(lf,(key +sp+ ls(zl[key]) for key in order or zl if key in zl))
    def __setattr__(zl,at,v):
        zl[at]=v
    def __mod__(zl,li):pass
    def __sub__(zl,li): return zl.__x(li)
    def __truediv__(zl,l): return zl.__x((l,))
    def __x(zl,li):#exclude
        for f in li:
            zl.pop(f,0)
        return zl
    #def copy():
    def hh(zl,li=None):
        zl.parser = ArgumentParser()
        zl.parser.add_argument("fil",nargs="*")#all other
        if li: zl+li
        return zl
    def __add__(zl,li):
        for f in li:
            f1,t=f[:2]
            lenli,default= f[2:] if(len(f)==4) else (None,None)
            if not isinstance(t,type):
                lenli=0
                if isinstance(t, (tuple,list)): lenli=len(t)
                default=t
                t=type(t)
            if t==bool and "store true":                                zl.parser.add_argument(f1,           action="store_true")
            else:
                zl.parser.add_argument(f1, type=t, nargs=lenli or None, default=default)
        return zl
    def ho(zl,te=None):
        w=zl.parser.parse_args(te and csv.reader([te.strip()],delimiter=" ").__next__())
        zl.update(w.__dict__)
        zl.pop("parser")# need vn pickle
        return zl
    def __getattr__(zl,at):
        return zl[at]
##    def __vars__(zl):wefw
class hhww(hhwwproto):
    def __getattr__(zl,at):
        return zl.get(at)
        return None
hhwwproto().str
##prexit((hhww(w=2,f=4) - ("w",)).str())
##prexit((hhww(w=2,f=4,ff=4)/"w"/"f").str())
##w=hhww();w.f=2;pr(w.f)
##print(hhww({"e":1},{"e":4}))
##print("vars;",vars(w))
###print(hhww().hh([("-f",str),("-re",str),("-ns",str)]).ho())
##print(dict(**hhww(w=2)), {"ww":2})
##prexit(hhww(w=2)==hhww(w=3), hhww()==hhww())
cls=hhwwproto()
cls.mp4="mp3|mp4|mkv|flv|ogg|webm"
#
def set2(sl,ob,value):
    for f in value.split(): ob.__dict__[f]=sl.__dict__.get(f)
import json
##def pl(fn,tfn="",pl="p"): return jsonload(fn,tfn=tfn,pl=pl)
##def typejson(te):
##    try: json.loads(te)
def jsontext(li):return json.dumps(li)
def jsonload(fn,tfn="",pl="json",flw=0,fltmp=1):
        if pl=="json":
            fp=(json.loads,json.dumps)
        elif pl=="p":
            import pickle
            fp=(pickle.loads, pickle.dumps)
        else:fp=()
        if not tfn:
            import hashlib
            te=hashlib.sha256(fn.encode()).hexdigest()
            tfn=jofn(tfolder,"wft;"+te)
        tfn=lfn.abspath(tfn)
        #print(tfn)
        if ifexist(tfn) and flw==0:
            if pl=="json": te=wfd(tfn).r()
            if pl=="p": te=wfd(tfn).rb()
            js=fp[0](te or "")
        else:js=hhww()
        def log(te=js):
            if fltmp:wfd(tfn).t(fp[1](te))
            else: wfd(tfn).w(fp[1](te), copy=0)
        if flw!=0: log(flw)
        table=hhww(t=js,l=len(js),fn=fn,tfn=tfn,log=log)
        return table, js, tfn, log
def wfupdate(fn,pat,count,te=""):
        if fn:
            imw=wfd(fn)
            te=imw.r()
        if callable(pat):te=pat(te)
        else: te=rnz(te,pat)
        cs=[te.count(f) for f,c in count]
        assert not any(c!=co for (f,c),co in zip(count,cs)),cs
        if fn:
            imw.w(te,copy=0)
        return te

if 1:
  @membile
  def pmobile(*w,**W):
    pmobilelib=impt((os.environ["cpy"]+f"/escape/nagano/e3escapeMtm"),reload=0);
    return pmobilelib.pmobile(*w,**W)
  def fppmobile(*w,**W):
    pmobilelib=impt((os.environ["cpy"]+f"/escape/nagano/e3escapeMtm"),reload=0);
    p=membile(pmobilelib.pmobile)(2,presort=1)
    return p(*w,**W)
  def note():
    return impt(os.environ["cpy"]+r"/qt/lib"+"/qNote1", reload=0)
    global_app=iniap()
    return "note+"
  def x4():
    return impt(cpy+"/Generator/x4orlexi")
def xfil(ap,flinput=1):
    hh=hhww().hh(ap).ho()
    fl=hh.fil
    if hh.fil:fl= hh.fil
    elif flinput:
        fl=input("w copy:")
        if fl:
            if fl[0]==";": fl=hh.ho(fl)
            else:    fl=fl.split()
        #else:fl=[]
    return hh,fl
hhfl=xfil
##def genefp(li):
##    def fp1(fn,pare,F,after):l
##    def fpEnum(fn):
##    lamrec(fp1,li,fpEnum)
import importlib; from importlib import import_module
find_spec=getattr(importlib,b'\x75\x74\x69\x6C'.decode()).find_spec
module_from_spec=getattr(importlib,b'\x75\x74\x69\x6C'.decode()).module_from_spec
importtool=getattr(importlib,b'\x75\x74\x69\x6C'.decode())
def impt1(fn,reload=True, lazy=False, **_):
    dir,fir=lfn.split(fn)
    sys.path.append(os.path.abspath(dir))
    cf=cfile(fn)
    if cf in sys.modules:
        mod=sys.modules[cf]
        if reload: importlib.reload(mod)# orText() not found
    else:
        mod=import_module(cf)#pass
    if dir: sys.path.pop()
    return mod
def impt(fn,reload=True, lazy=False, **_):
    dir,fir=lfn.split(fn)
    #sys.path.append(os.path.abspath(dir))
    cf=cfile(fn)
    if cf in sys.modules and not reload:
        mod=sys.modules[cf]
        #if reload: importlib.reload(mod)# orText() not found
    else:
        f9=fn
        if not dir:
            for p in [os.getcwd(), *sys.path]:
                if ifexist(f9:=jwdir(p,fn)): break
                if ifexist(f9:=(f9+".py")):break
        if 1:
            if not ifexist(f9): f9+=".py"
            assert ifexist(f9), "module not found: "+fn
            spec=importtool.spec_from_file_location(cf,f9)
            assert spec, "import from file location;"+f9
            #print("spec;",[ spec.name, spec.origin], flush=True)
            if lazy: spec.loader = LazyLoader(spec.loader)
            mod = module_from_spec(spec)
            sys.modules[cf] = mod
            if "import": getattr(spec.loader, b'\x65\x78\x65\x63_\x6D\x6F\x64\x75\x6C\x65'.decode())(mod)
    #if dir: sys.path.pop()
    return mod
def zen(wfn):
    wfn=orsub({":":":", "<":"(",">":")","\\":"/"},wfn)
    return wfn
def newthan(tfn,fn): return mtime(tfn)>mtime(fn)
def memof(fp):
    fp._memof={}
    @functools.wraps(fp)
    def p(zl,*w):
        #print(fp._memof, w)
        if(mf:=fp._memof.get(w)): return mf
        else:
            pm=fp(zl,*w)
            fp._memof[w]=pm
            return pm
    return p
if __name__ == '__main__':
    print(os.getcwd());
    hh={
##        "ast":1,
##        "dif3":5,
    }
    hw,fl=xfil([])
    hw.new36=1200
    if "dif3" in hw:
        t1="am,mm,gf,jpefg".split(",")
        t2="pm,mm,gif,jpg".split(",")
        prexit(dif3(t1,t2))
    if(0):
        eu=esfn(url);
        wfdt(eu,"lkjl");
        e2=exfn(eu);
        pr(bool(url==e2));
        pr(url,lf,e2,lf,eu);
    if "ast" in fl:
        import ast
        @cbTry
        def pcompile(te):1
        print(ast.dump(ast.parse("if 1:1")))
        w=ast.parse("sn.l[2]")
        q=[(f,list(ast.iter_fields(f))) for f in ast.walk(w)]
        for f,n in q:
            if n:print(len(n),n)
##    prexit(emrestore("c"))
    if hw.new36:# f-string
        print(f"f-string: {hw.new36:,} string:left,{hh!s:>22}")
#Operator precedence() ~ / + >> & ^ | in > not and or if
##npp(r'"C:/cpy/Mjmoji/pr/give it try.pyw" -n2')
#compilev(r"(?<=1).*?(?=\n)").sub("2","1\nfw\n")

if 1:
    import socket
    def better_send(feeding, host=(),cb=()):
        socket_port_web = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        socket_port_web.settimeout(1)
        #socket_port_web.connect(("localhost",5010))
        socket_port_web.connect(("127.0.0.1",5010))
        #
        sent    = 0
        while sent < len(feeding):
            sent = sent + socket_port_web.send(feeding[sent:])
        #
        while True:
            long = socket_port_web.recv(4096)
            if len(long) == 0:     # No more data received
                break
            #response = response + long;
            yield long
        #return response
    def transfer(feeding, host):
        tea=b""
        for et in better_send(feeding,host):
            tea+=et
        return tea
if 1:
    finalcb=cbTry
    cbstop=finalcb