py2ls 0.2.4.27__py3-none-any.whl → 0.2.4.28__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
py2ls/.git/index
CHANGED
Binary file
|
py2ls/ips.py
CHANGED
@@ -3657,35 +3657,21 @@ def get_os(full=False, verbose=False):
|
|
3657
3657
|
pnrint(e)
|
3658
3658
|
return res
|
3659
3659
|
|
3660
|
-
|
3660
|
+
import re
|
3661
|
+
import stat
|
3662
|
+
import platform
|
3661
3663
|
def listdir(
|
3662
3664
|
rootdir,
|
3663
3665
|
kind=None,
|
3664
3666
|
sort_by="name",
|
3665
3667
|
ascending=True,
|
3666
|
-
contains=None
|
3668
|
+
contains=None,# filter filenames using re
|
3669
|
+
booster=False,# walk in subfolders
|
3670
|
+
hidden=False, # Include hidden files/folders
|
3667
3671
|
orient="list",
|
3668
|
-
output="df", # 'list','dict','records','index','series'
|
3672
|
+
output="df", # "df", 'list','dict','records','index','series'
|
3669
3673
|
verbose=True,
|
3670
|
-
):
|
3671
|
-
if kind is None:
|
3672
|
-
ls = os.listdir(rootdir)
|
3673
|
-
ls = [f for f in ls if not f.startswith(".") and not f.startswith("~")]
|
3674
|
-
if verbose:
|
3675
|
-
if len(ls)>20:
|
3676
|
-
print(ls[:20])
|
3677
|
-
else:
|
3678
|
-
print(ls)
|
3679
|
-
df_all = pd.DataFrame(
|
3680
|
-
{
|
3681
|
-
"name": ls,
|
3682
|
-
"path": [os.path.join(rootdir, i) for i in ls],
|
3683
|
-
"kind":[os.path.splitext(i)[1] for i in ls]
|
3684
|
-
}
|
3685
|
-
)
|
3686
|
-
if verbose:
|
3687
|
-
display(df_all.head())
|
3688
|
-
return df_all
|
3674
|
+
):
|
3689
3675
|
if isinstance(kind, list):
|
3690
3676
|
f_ = []
|
3691
3677
|
for kind_ in kind:
|
@@ -3695,56 +3681,106 @@ def listdir(
|
|
3695
3681
|
sort_by=sort_by,
|
3696
3682
|
ascending=ascending,
|
3697
3683
|
contains=contains,
|
3684
|
+
booster=booster,# walk in subfolders
|
3685
|
+
hidden=hidden,
|
3698
3686
|
orient=orient,
|
3699
3687
|
output=output,
|
3688
|
+
verbose=verbose,
|
3700
3689
|
)
|
3701
3690
|
f_.append(f_tmp)
|
3702
3691
|
if f_:
|
3703
3692
|
return pd.concat(f_, ignore_index=True)
|
3704
|
-
|
3705
|
-
|
3706
|
-
|
3707
|
-
|
3708
|
-
|
3709
|
-
|
3710
|
-
|
3711
|
-
|
3712
|
-
|
3713
|
-
|
3714
|
-
|
3715
|
-
|
3716
|
-
|
3717
|
-
|
3718
|
-
|
3719
|
-
|
3720
|
-
|
3721
|
-
|
3722
|
-
|
3723
|
-
|
3724
|
-
|
3725
|
-
|
3726
|
-
|
3727
|
-
if
|
3693
|
+
if kind is not None:
|
3694
|
+
if not kind.startswith("."):
|
3695
|
+
kind = "." + kind
|
3696
|
+
fd = [".fd", ".fld", ".fol", ".fd", ".folder"]
|
3697
|
+
i = 0
|
3698
|
+
f = {
|
3699
|
+
"name": [],
|
3700
|
+
'kind':[],
|
3701
|
+
"length": [],
|
3702
|
+
"basename":[],
|
3703
|
+
"path": [],
|
3704
|
+
"created_time": [],
|
3705
|
+
"modified_time": [],
|
3706
|
+
"last_open_time": [],
|
3707
|
+
"size": [],
|
3708
|
+
"permission":[],
|
3709
|
+
"owner":[],
|
3710
|
+
"rootdir":[],
|
3711
|
+
"fname": [],
|
3712
|
+
"fpath": [],
|
3713
|
+
}
|
3714
|
+
for dirpath, dirnames, ls in os.walk(rootdir):
|
3715
|
+
if not hidden:
|
3716
|
+
dirnames[:] = [d for d in dirnames if not d.startswith(".")]
|
3717
|
+
ls = [i for i in ls if not i.startswith(".")]
|
3718
|
+
for dirname in dirnames:
|
3719
|
+
if contains and not re.search(contains, dirname):
|
3728
3720
|
continue
|
3729
|
-
|
3730
|
-
|
3731
|
-
|
3732
|
-
os.
|
3733
|
-
|
3734
|
-
|
3735
|
-
|
3736
|
-
|
3737
|
-
|
3738
|
-
return flist(fpath, contains=contains)
|
3739
|
-
else: # 精确到文件的后缀
|
3740
|
-
if not is_folder and not is_file:
|
3741
|
-
continue
|
3721
|
+
dirname_path = os.path.join(dirpath, dirname)
|
3722
|
+
fpath = os.path.join(os.path.dirname(dirname_path), dirname)
|
3723
|
+
try:
|
3724
|
+
stats_file = os.stat(fpath)
|
3725
|
+
except Exception as e:
|
3726
|
+
print(e)
|
3727
|
+
continue
|
3728
|
+
filename, file_extension = os.path.splitext(dirname)
|
3729
|
+
file_extension = file_extension if file_extension!='' else None
|
3742
3730
|
f["name"].append(filename)
|
3731
|
+
f['kind'].append(file_extension)
|
3743
3732
|
f["length"].append(len(filename))
|
3744
|
-
f["
|
3733
|
+
f["size"].append(round(os.path.getsize(fpath) / 1024 / 1024, 3))
|
3734
|
+
f['basename'].append(os.path.basename(dirname_path))
|
3735
|
+
f["path"].append(os.path.join(os.path.dirname(dirname_path), dirname))
|
3736
|
+
f["created_time"].append(
|
3737
|
+
pd.to_datetime(os.path.getctime(dirname_path), unit="s")
|
3738
|
+
)
|
3739
|
+
f["modified_time"].append(
|
3740
|
+
pd.to_datetime(os.path.getmtime(dirname_path), unit="s")
|
3741
|
+
)
|
3742
|
+
f["last_open_time"].append(
|
3743
|
+
pd.to_datetime(os.path.getatime(dirname_path), unit="s")
|
3744
|
+
)
|
3745
|
+
f["permission"].append(stat.filemode(stats_file.st_mode)),
|
3746
|
+
f["owner"].append(os.getlogin() if platform.system() != "Windows" else "N/A"),
|
3747
|
+
f["rootdir"].append(dirpath)
|
3748
|
+
f["fname"].append(filename) # will be removed
|
3749
|
+
f["fpath"].append(fpath) # will be removed
|
3750
|
+
i += 1
|
3751
|
+
for item in ls:
|
3752
|
+
if contains and not re.search(contains, item):
|
3753
|
+
continue
|
3754
|
+
item_path = os.path.join(dirpath, item)
|
3745
3755
|
fpath = os.path.join(os.path.dirname(item_path), item)
|
3746
|
-
|
3756
|
+
try:
|
3757
|
+
stats_file = os.stat(fpath)
|
3758
|
+
except Exception as e:
|
3759
|
+
print(e)
|
3760
|
+
continue
|
3761
|
+
filename, file_extension = os.path.splitext(item)
|
3762
|
+
if kind is not None:
|
3763
|
+
if not kind.startswith("."):
|
3764
|
+
kind = "." + kind
|
3765
|
+
is_folder = kind.lower() in fd and os.path.isdir(item_path)
|
3766
|
+
is_file = kind.lower() in file_extension.lower() and (
|
3767
|
+
os.path.isfile(item_path)
|
3768
|
+
)
|
3769
|
+
if kind in [".doc", ".img", ".zip"]: # 选择大的类别
|
3770
|
+
if kind != ".folder" and not isa(item_path, kind):
|
3771
|
+
continue
|
3772
|
+
elif kind in [".all"]:
|
3773
|
+
return flist(fpath, contains=contains)
|
3774
|
+
else: # 精确到文件的后缀
|
3775
|
+
if not is_folder and not is_file:
|
3776
|
+
continue
|
3777
|
+
file_extension = file_extension if file_extension!='' else None
|
3778
|
+
f["name"].append(filename)
|
3779
|
+
f['kind'].append(file_extension)
|
3780
|
+
f["length"].append(len(filename))
|
3747
3781
|
f["size"].append(round(os.path.getsize(fpath) / 1024 / 1024, 3))
|
3782
|
+
f['basename'].append(os.path.basename(item_path))
|
3783
|
+
f["path"].append(os.path.join(os.path.dirname(item_path), item))
|
3748
3784
|
f["created_time"].append(
|
3749
3785
|
pd.to_datetime(os.path.getctime(item_path), unit="s")
|
3750
3786
|
)
|
@@ -3754,26 +3790,22 @@ def listdir(
|
|
3754
3790
|
f["last_open_time"].append(
|
3755
3791
|
pd.to_datetime(os.path.getatime(item_path), unit="s")
|
3756
3792
|
)
|
3793
|
+
f["permission"].append(stat.filemode(stats_file.st_mode)),
|
3794
|
+
f["owner"].append(os.getlogin() if platform.system() != "Windows" else "N/A"),
|
3757
3795
|
f["fname"].append(filename) # will be removed
|
3758
3796
|
f["fpath"].append(fpath) # will be removed
|
3759
|
-
f[
|
3797
|
+
f["rootdir"].append(dirpath)
|
3760
3798
|
i += 1
|
3761
3799
|
|
3762
3800
|
f["num"] = i
|
3763
|
-
f["rootdir"] = rootdir
|
3764
3801
|
f["os"] = get_os() # os.uname().machine
|
3765
|
-
|
3766
|
-
|
3767
|
-
|
3768
|
-
rootdir
|
3769
|
-
)
|
3770
|
-
)
|
3771
|
-
|
3802
|
+
if not booster: # go deeper subfolders
|
3803
|
+
break
|
3804
|
+
#* convert to pd.DataFrame
|
3772
3805
|
f = pd.DataFrame(f)
|
3773
|
-
|
3774
|
-
|
3775
|
-
|
3776
|
-
|
3806
|
+
f=f[["basename","name","kind","length","size","num","path","created_time",
|
3807
|
+
"modified_time","last_open_time","rootdir",
|
3808
|
+
"fname","fpath","permission","owner","os",]]
|
3777
3809
|
if "nam" in sort_by.lower():
|
3778
3810
|
f = sort_kind(f, by="name", ascending=ascending)
|
3779
3811
|
elif "crea" in sort_by.lower():
|
@@ -3786,10 +3818,10 @@ def listdir(
|
|
3786
3818
|
if "df" in output:
|
3787
3819
|
if verbose:
|
3788
3820
|
display(f.head())
|
3821
|
+
print(f"shape: {f.shape}")
|
3789
3822
|
return f
|
3790
3823
|
else:
|
3791
3824
|
from box import Box
|
3792
|
-
|
3793
3825
|
if "l" in orient.lower(): # list # default
|
3794
3826
|
res_output = Box(f.to_dict(orient="list"))
|
3795
3827
|
return res_output
|
@@ -3802,12 +3834,6 @@ def listdir(
|
|
3802
3834
|
if "se" in orient.lower(): # records
|
3803
3835
|
return Box(f.to_dict(orient="series"))
|
3804
3836
|
|
3805
|
-
|
3806
|
-
# Example usage:
|
3807
|
-
# result = listdir('your_root_directory')
|
3808
|
-
# print(result)
|
3809
|
-
# df=listdir("/", contains='sss',sort_by='name',ascending=False)
|
3810
|
-
# print(df.fname.to_list(),"\n",df.fpath.to_list())
|
3811
3837
|
def listfunc(lib_name, opt="call"):
|
3812
3838
|
if opt == "call":
|
3813
3839
|
funcs = [func for func in dir(lib_name) if callable(getattr(lib_name, func))]
|
@@ -3822,6 +3848,10 @@ def func_list(lib_name, opt="call"):
|
|
3822
3848
|
def copy(src, dst, overwrite=False):
|
3823
3849
|
"""Copy a file from src to dst."""
|
3824
3850
|
try:
|
3851
|
+
dir_par_dst = os.path.dirname(dst)
|
3852
|
+
if not os.path.isdir(dir_par_dst):
|
3853
|
+
mkdir(dir_par_dst)
|
3854
|
+
print(dir_par_dst)
|
3825
3855
|
src = Path(src)
|
3826
3856
|
dst = Path(dst)
|
3827
3857
|
if not src.is_dir():
|
@@ -3848,11 +3878,14 @@ def copy(src, dst, overwrite=False):
|
|
3848
3878
|
except Exception as e:
|
3849
3879
|
logging.error(f"Failed {e}")
|
3850
3880
|
|
3851
|
-
def move(src, dst, overwrite=False):
|
3852
|
-
return cut(src=src, dst=dst, overwrite=overwrite)
|
3853
|
-
|
3854
3881
|
def cut(src, dst, overwrite=False):
|
3882
|
+
return move(src=src, dst=dst, overwrite=overwrite)
|
3883
|
+
|
3884
|
+
def move(src, dst, overwrite=False):
|
3855
3885
|
try:
|
3886
|
+
dir_par_dst = os.path.dirname(dst)
|
3887
|
+
if not os.path.isdir(dir_par_dst):
|
3888
|
+
mkdir(dir_par_dst)
|
3856
3889
|
src = Path(src)
|
3857
3890
|
dst = Path(dst)
|
3858
3891
|
if dst.is_dir():
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: py2ls
|
3
|
-
Version: 0.2.4.
|
3
|
+
Version: 0.2.4.28
|
4
4
|
Summary: py(thon)2(too)ls
|
5
5
|
Author: Jianfeng
|
6
6
|
Author-email: Jianfeng.Liu0413@gmail.com
|
@@ -26,7 +26,7 @@ Requires-Dist: PyMatting (>=1.1.12)
|
|
26
26
|
Requires-Dist: PyOpenGL (>=3.1.6)
|
27
27
|
Requires-Dist: PyPDF2 (>=3.0.1)
|
28
28
|
Requires-Dist: PyQt5 (>=5.15.11)
|
29
|
-
Requires-Dist: PyQt5-Qt5 (>=5.15.
|
29
|
+
Requires-Dist: PyQt5-Qt5 (>=5.15.0)
|
30
30
|
Requires-Dist: PyQt5_sip (>=12.15.0)
|
31
31
|
Requires-Dist: PyQtWebEngine (>=5.15.7)
|
32
32
|
Requires-Dist: PyQtWebEngine-Qt5 (>=5.15.14)
|
@@ -38,7 +38,6 @@ Requires-Dist: SciencePlots (>=2.1.1)
|
|
38
38
|
Requires-Dist: XlsxWriter (>=3.2.0)
|
39
39
|
Requires-Dist: asciitree (>=0.3.3)
|
40
40
|
Requires-Dist: asttokens (>=2.4.1)
|
41
|
-
Requires-Dist: attrs (>=23.2.0)
|
42
41
|
Requires-Dist: autogluon (>=1.2)
|
43
42
|
Requires-Dist: beautifulsoup4 (>=4.12.3)
|
44
43
|
Requires-Dist: bleach (>=6.1.0)
|
@@ -18,7 +18,7 @@ py2ls/.git/hooks/pre-receive.sample,sha256=pMPSuce7P9jRRBwxvU7nGlldZrRPz0ndsxAlI
|
|
18
18
|
py2ls/.git/hooks/prepare-commit-msg.sample,sha256=6d3KpBif3dJe2X_Ix4nsp7bKFjkLI5KuMnbwyOGqRhk,1492
|
19
19
|
py2ls/.git/hooks/push-to-checkout.sample,sha256=pT0HQXmLKHxt16-mSu5HPzBeZdP0lGO7nXQI7DsSv18,2783
|
20
20
|
py2ls/.git/hooks/update.sample,sha256=jV8vqD4QPPCLV-qmdSHfkZT0XL28s32lKtWGCXoU0QY,3650
|
21
|
-
py2ls/.git/index,sha256=
|
21
|
+
py2ls/.git/index,sha256=1-0l4HpWQFAVRMijggz6CNt4WGBxyGaAzgKzr57Td2I,4232
|
22
22
|
py2ls/.git/info/exclude,sha256=ZnH-g7egfIky7okWTR8nk7IxgFjri5jcXAbuClo7DsE,240
|
23
23
|
py2ls/.git/logs/HEAD,sha256=8ID7WuAe_TlO9g-ARxhIJYdgdL3u3m7-1qrOanaIUlA,3535
|
24
24
|
py2ls/.git/logs/refs/heads/main,sha256=8ID7WuAe_TlO9g-ARxhIJYdgdL3u3m7-1qrOanaIUlA,3535
|
@@ -240,7 +240,7 @@ py2ls/export_requirements.py,sha256=x2WgUF0jYKz9GfA1MVKN-MdsM-oQ8yUeC6Ua8oCymio,
|
|
240
240
|
py2ls/fetch_update.py,sha256=9LXj661GpCEFII2wx_99aINYctDiHni6DOruDs_fdt8,4752
|
241
241
|
py2ls/freqanalysis.py,sha256=F4218VSPbgL5tnngh6xNCYuNnfR-F_QjECUUxrPYZss,32594
|
242
242
|
py2ls/ich2ls.py,sha256=3E9R8oVpyYZXH5PiIQgT3CN5NxLe4Dwtm2LwaeacE6I,21381
|
243
|
-
py2ls/ips.py,sha256=
|
243
|
+
py2ls/ips.py,sha256=ZAwkOilTrfQ3zkUiMQbidrcFs-hZoWmXH60KGHkh530,342899
|
244
244
|
py2ls/ml2ls.py,sha256=kIk-ZnDdJGd-fw9GPIFf1r4jtrw5hgvBpRnYNoL1U8I,209494
|
245
245
|
py2ls/mol.py,sha256=AZnHzarIk_MjueKdChqn1V6e4tUle3X1NnHSFA6n3Nw,10645
|
246
246
|
py2ls/netfinder.py,sha256=UfsruqlFwUOZQx4mO7P7-UiRJqcxcT0WN3QRLv22o74,64059
|
@@ -252,6 +252,6 @@ py2ls/sleep_events_detectors.py,sha256=bQA3HJqv5qnYKJJEIhCyhlDtkXQfIzqksnD0YRXso
|
|
252
252
|
py2ls/stats.py,sha256=qBn2rJmNa_QLLUqjwYqXUlGzqmW94sgA1bxJU2FC3r0,39175
|
253
253
|
py2ls/translator.py,sha256=77Tp_GjmiiwFbEIJD_q3VYpQ43XL9ZeJo6Mhl44mvh8,34284
|
254
254
|
py2ls/wb_detector.py,sha256=7y6TmBUj9exCZeIgBAJ_9hwuhkDh1x_-yg4dvNY1_GQ,6284
|
255
|
-
py2ls-0.2.4.
|
256
|
-
py2ls-0.2.4.
|
257
|
-
py2ls-0.2.4.
|
255
|
+
py2ls-0.2.4.28.dist-info/METADATA,sha256=DmVK7j9FD4wjYNSx3WoUaGlhwf0VSFNIu6Vlewfy5R0,20215
|
256
|
+
py2ls-0.2.4.28.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
257
|
+
py2ls-0.2.4.28.dist-info/RECORD,,
|
File without changes
|