py2ls 0.1.4.2__py3-none-any.whl → 0.1.4.5__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/.DS_Store +0 -0
- py2ls/.git/COMMIT_EDITMSG +1 -3
- py2ls/.git/FETCH_HEAD +1 -1
- py2ls/.git/index +0 -0
- py2ls/.git/logs/HEAD +6 -0
- py2ls/.git/logs/refs/heads/main +6 -0
- py2ls/.git/logs/refs/remotes/origin/HEAD +26 -0
- py2ls/.git/logs/refs/remotes/origin/main +5 -0
- py2ls/.git/objects/1a/b4585881a6a42889f01aa0cfe25fd5acfaf46f +0 -0
- py2ls/.git/objects/36/e56a361f526eafa59c5235a5c990bf288b5f9c +0 -0
- py2ls/.git/objects/43/dbd49b2ee367c5434dd545e3b5795434f2ef0b +0 -0
- py2ls/.git/objects/50/08ddfcf53c02e82d7eee2e57c38e5672ef89f6 +0 -0
- py2ls/.git/objects/53/e0deb1cb4c2c606bced6e7f9a66b0fda60980d +0 -0
- py2ls/.git/objects/56/e4e8b2d5545e0256090f45aa8fc42c5fe067d0 +0 -0
- py2ls/.git/objects/62/7c81b23b4e56e87b042b650b0103653cc9e34a +0 -0
- py2ls/.git/objects/62/d90ccf8cbefdc2e4fd475e7c6f4f76e9fdf801 +3 -0
- py2ls/.git/objects/64/27a4edff08f93d98f511418423f09f2ab90bcd +0 -0
- py2ls/.git/objects/6c/cebb29b7f3f5b0c889f6dadbf9ff066554587d +0 -0
- py2ls/.git/objects/81/8f26b7bf042269729020cf944fc362d66ba27e +0 -0
- py2ls/.git/objects/84/59071b722a255b774a80b27746033f8141ab39 +0 -0
- py2ls/.git/objects/8b/84f56978e1de8f2ae82abce5f8b3e182d365cd +0 -0
- py2ls/.git/objects/b5/61831c7dce8ea51e7ee6b6fa35745f14d8242d +0 -0
- py2ls/.git/objects/bb/934eb33bc1a8b85630bf680caffd99560c1b8f +0 -0
- py2ls/.git/objects/c6/7f17e5707313600efcb85e9a3fedea35dba591 +0 -0
- py2ls/.git/objects/cf/0c0d9c6fb09473aaeb7f7e2edbd770c3f2ef3d +1 -0
- py2ls/.git/objects/d6/9ab1c4aadf279936dd778e8346ba60f74705b6 +0 -0
- py2ls/.git/objects/d9/dfa5aee51e92a541b707e8e7baea6f06deff98 +0 -0
- py2ls/.git/objects/e3/1356f90ea6dd0577b5e0b40b206319adcbf085 +0 -0
- py2ls/.git/objects/fa/147e6bb78a2e8db241d231295fd7f1ed061af8 +0 -0
- py2ls/.git/refs/heads/main +1 -1
- py2ls/.git/refs/remotes/origin/main +1 -1
- py2ls/__init__.py +1 -2
- py2ls/ips.py +159 -24
- py2ls/netfinder.py +166 -128
- py2ls/setuptools-70.1.0-py3-none-any.whl +0 -0
- {py2ls-0.1.4.2.dist-info → py2ls-0.1.4.5.dist-info}/METADATA +139 -2
- {py2ls-0.1.4.2.dist-info → py2ls-0.1.4.5.dist-info}/RECORD +38 -17
- py2ls/internet_finder.py +0 -405
- py2ls/version.py +0 -1
- {py2ls-0.1.4.2.dist-info → py2ls-0.1.4.5.dist-info}/WHEEL +0 -0
py2ls/.DS_Store
ADDED
Binary file
|
py2ls/.git/COMMIT_EDITMSG
CHANGED
py2ls/.git/FETCH_HEAD
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
1ab4585881a6a42889f01aa0cfe25fd5acfaf46f branch 'main' of https://github.com/Jianfengliu0413/py2ls
|
py2ls/.git/index
CHANGED
Binary file
|
py2ls/.git/logs/HEAD
CHANGED
@@ -6,3 +6,9 @@ d9c2403fd166ce791b4e9d0c6792ed8342c71fcd 14449a0e6ba4ea2f1a73acf63ef91c9c6193f9e
|
|
6
6
|
0b409e1bc918277010f5679b402d1d1dda53e15c 6b7fde264d93a7a0986d394c46c7650d0ce2ab92 Jianfeng <Jianfeng.Liu0413@gmail.com> 1718393734 +0200 commit: Update ips.py
|
7
7
|
6b7fde264d93a7a0986d394c46c7650d0ce2ab92 3bbd972aa7ad680858f8dfbd0f7fcd97756f0d6f Jianfeng <Jianfeng.Liu0413@gmail.com> 1718491087 +0200 commit: Update netfinder.py
|
8
8
|
3bbd972aa7ad680858f8dfbd0f7fcd97756f0d6f 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng <Jianfeng.Liu0413@gmail.com> 1718526957 +0200 commit: Update netfinder.py
|
9
|
+
48a88fc5806305d0bb0755ee6801161b79696972 cf0c0d9c6fb09473aaeb7f7e2edbd770c3f2ef3d Jianfeng <Jianfeng.Liu0413@gmail.com> 1718553462 +0200 commit: new feature: display_thumbnail_figure
|
10
|
+
cf0c0d9c6fb09473aaeb7f7e2edbd770c3f2ef3d 6427a4edff08f93d98f511418423f09f2ab90bcd Jianfeng <Jianfeng.Liu0413@gmail.com> 1718555179 +0200 commit: listdir type
|
11
|
+
6427a4edff08f93d98f511418423f09f2ab90bcd d9dfa5aee51e92a541b707e8e7baea6f06deff98 Jianfeng <Jianfeng.Liu0413@gmail.com> 1718570098 +0200 commit: imgsets update
|
12
|
+
d9dfa5aee51e92a541b707e8e7baea6f06deff98 e31356f90ea6dd0577b5e0b40b206319adcbf085 Jianfeng <Jianfeng.Liu0413@gmail.com> 1718618413 +0200 commit: add thumbnail
|
13
|
+
e31356f90ea6dd0577b5e0b40b206319adcbf085 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng <Jianfeng.Liu0413@gmail.com> 1718619568 +0200 commit: Update ips.py
|
14
|
+
1ab4585881a6a42889f01aa0cfe25fd5acfaf46f 627c81b23b4e56e87b042b650b0103653cc9e34a Jianfeng <Jianfeng.Liu0413@gmail.com> 1718698925 +0200 commit: update xample_imgsets
|
py2ls/.git/logs/refs/heads/main
CHANGED
@@ -6,3 +6,9 @@ d9c2403fd166ce791b4e9d0c6792ed8342c71fcd 14449a0e6ba4ea2f1a73acf63ef91c9c6193f9e
|
|
6
6
|
0b409e1bc918277010f5679b402d1d1dda53e15c 6b7fde264d93a7a0986d394c46c7650d0ce2ab92 Jianfeng <Jianfeng.Liu0413@gmail.com> 1718393734 +0200 commit: Update ips.py
|
7
7
|
6b7fde264d93a7a0986d394c46c7650d0ce2ab92 3bbd972aa7ad680858f8dfbd0f7fcd97756f0d6f Jianfeng <Jianfeng.Liu0413@gmail.com> 1718491087 +0200 commit: Update netfinder.py
|
8
8
|
3bbd972aa7ad680858f8dfbd0f7fcd97756f0d6f 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng <Jianfeng.Liu0413@gmail.com> 1718526957 +0200 commit: Update netfinder.py
|
9
|
+
48a88fc5806305d0bb0755ee6801161b79696972 cf0c0d9c6fb09473aaeb7f7e2edbd770c3f2ef3d Jianfeng <Jianfeng.Liu0413@gmail.com> 1718553462 +0200 commit: new feature: display_thumbnail_figure
|
10
|
+
cf0c0d9c6fb09473aaeb7f7e2edbd770c3f2ef3d 6427a4edff08f93d98f511418423f09f2ab90bcd Jianfeng <Jianfeng.Liu0413@gmail.com> 1718555179 +0200 commit: listdir type
|
11
|
+
6427a4edff08f93d98f511418423f09f2ab90bcd d9dfa5aee51e92a541b707e8e7baea6f06deff98 Jianfeng <Jianfeng.Liu0413@gmail.com> 1718570098 +0200 commit: imgsets update
|
12
|
+
d9dfa5aee51e92a541b707e8e7baea6f06deff98 e31356f90ea6dd0577b5e0b40b206319adcbf085 Jianfeng <Jianfeng.Liu0413@gmail.com> 1718618413 +0200 commit: add thumbnail
|
13
|
+
e31356f90ea6dd0577b5e0b40b206319adcbf085 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng <Jianfeng.Liu0413@gmail.com> 1718619568 +0200 commit: Update ips.py
|
14
|
+
1ab4585881a6a42889f01aa0cfe25fd5acfaf46f 627c81b23b4e56e87b042b650b0103653cc9e34a Jianfeng <Jianfeng.Liu0413@gmail.com> 1718698925 +0200 commit: update xample_imgsets
|
@@ -9,3 +9,29 @@ d9c2403fd166ce791b4e9d0c6792ed8342c71fcd d9c2403fd166ce791b4e9d0c6792ed8342c71fc
|
|
9
9
|
6b7fde264d93a7a0986d394c46c7650d0ce2ab92 6b7fde264d93a7a0986d394c46c7650d0ce2ab92 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718393737 +0200 remote set-head
|
10
10
|
3bbd972aa7ad680858f8dfbd0f7fcd97756f0d6f 3bbd972aa7ad680858f8dfbd0f7fcd97756f0d6f Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718491090 +0200 remote set-head
|
11
11
|
48a88fc5806305d0bb0755ee6801161b79696972 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718526960 +0200 remote set-head
|
12
|
+
48a88fc5806305d0bb0755ee6801161b79696972 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718529062 +0200 remote set-head
|
13
|
+
48a88fc5806305d0bb0755ee6801161b79696972 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718531693 +0200 remote set-head
|
14
|
+
48a88fc5806305d0bb0755ee6801161b79696972 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718533521 +0200 remote set-head
|
15
|
+
48a88fc5806305d0bb0755ee6801161b79696972 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718535485 +0200 remote set-head
|
16
|
+
48a88fc5806305d0bb0755ee6801161b79696972 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718537443 +0200 remote set-head
|
17
|
+
48a88fc5806305d0bb0755ee6801161b79696972 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718539464 +0200 remote set-head
|
18
|
+
48a88fc5806305d0bb0755ee6801161b79696972 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718541421 +0200 remote set-head
|
19
|
+
48a88fc5806305d0bb0755ee6801161b79696972 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718543586 +0200 remote set-head
|
20
|
+
48a88fc5806305d0bb0755ee6801161b79696972 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718545544 +0200 remote set-head
|
21
|
+
48a88fc5806305d0bb0755ee6801161b79696972 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718547501 +0200 remote set-head
|
22
|
+
48a88fc5806305d0bb0755ee6801161b79696972 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718549457 +0200 remote set-head
|
23
|
+
48a88fc5806305d0bb0755ee6801161b79696972 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718551415 +0200 remote set-head
|
24
|
+
48a88fc5806305d0bb0755ee6801161b79696972 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718553371 +0200 remote set-head
|
25
|
+
cf0c0d9c6fb09473aaeb7f7e2edbd770c3f2ef3d cf0c0d9c6fb09473aaeb7f7e2edbd770c3f2ef3d Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718553465 +0200 remote set-head
|
26
|
+
6427a4edff08f93d98f511418423f09f2ab90bcd 6427a4edff08f93d98f511418423f09f2ab90bcd Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718555183 +0200 remote set-head
|
27
|
+
6427a4edff08f93d98f511418423f09f2ab90bcd 6427a4edff08f93d98f511418423f09f2ab90bcd Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718570095 +0200 remote set-head
|
28
|
+
d9dfa5aee51e92a541b707e8e7baea6f06deff98 d9dfa5aee51e92a541b707e8e7baea6f06deff98 Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1718570102 +0200 remote set-head
|
29
|
+
e31356f90ea6dd0577b5e0b40b206319adcbf085 e31356f90ea6dd0577b5e0b40b206319adcbf085 Jianfeng Liu <macjianfeng@JFLMBP.local> 1718618416 +0200 remote set-head
|
30
|
+
1ab4585881a6a42889f01aa0cfe25fd5acfaf46f 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng Liu <macjianfeng@JFLMBP.local> 1718619571 +0200 remote set-head
|
31
|
+
1ab4585881a6a42889f01aa0cfe25fd5acfaf46f 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng Liu <macjianfeng@JFLMBP.local> 1718698084 +0200 remote set-head
|
32
|
+
1ab4585881a6a42889f01aa0cfe25fd5acfaf46f 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng Liu <macjianfeng@JFLMBP.local> 1718699917 +0200 remote set-head
|
33
|
+
1ab4585881a6a42889f01aa0cfe25fd5acfaf46f 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng Liu <macjianfeng@JFLMBP.local> 1718701729 +0200 remote set-head
|
34
|
+
1ab4585881a6a42889f01aa0cfe25fd5acfaf46f 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng Liu <macjianfeng@JFLMBP.local> 1718703544 +0200 remote set-head
|
35
|
+
1ab4585881a6a42889f01aa0cfe25fd5acfaf46f 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng Liu <macjianfeng@JFLMBP.local> 1718705358 +0200 remote set-head
|
36
|
+
1ab4585881a6a42889f01aa0cfe25fd5acfaf46f 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng Liu <macjianfeng@JFLMBP.local> 1718707170 +0200 remote set-head
|
37
|
+
1ab4585881a6a42889f01aa0cfe25fd5acfaf46f 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng Liu <macjianfeng@JFLMBP.local> 1718708982 +0200 remote set-head
|
@@ -6,3 +6,8 @@ d9c2403fd166ce791b4e9d0c6792ed8342c71fcd 14449a0e6ba4ea2f1a73acf63ef91c9c6193f9e
|
|
6
6
|
0b409e1bc918277010f5679b402d1d1dda53e15c 6b7fde264d93a7a0986d394c46c7650d0ce2ab92 Jianfeng <Jianfeng.Liu0413@gmail.com> 1718393736 +0200 update by push
|
7
7
|
6b7fde264d93a7a0986d394c46c7650d0ce2ab92 3bbd972aa7ad680858f8dfbd0f7fcd97756f0d6f Jianfeng <Jianfeng.Liu0413@gmail.com> 1718491090 +0200 update by push
|
8
8
|
3bbd972aa7ad680858f8dfbd0f7fcd97756f0d6f 48a88fc5806305d0bb0755ee6801161b79696972 Jianfeng <Jianfeng.Liu0413@gmail.com> 1718526959 +0200 update by push
|
9
|
+
48a88fc5806305d0bb0755ee6801161b79696972 cf0c0d9c6fb09473aaeb7f7e2edbd770c3f2ef3d Jianfeng <Jianfeng.Liu0413@gmail.com> 1718553464 +0200 update by push
|
10
|
+
cf0c0d9c6fb09473aaeb7f7e2edbd770c3f2ef3d 6427a4edff08f93d98f511418423f09f2ab90bcd Jianfeng <Jianfeng.Liu0413@gmail.com> 1718555183 +0200 update by push
|
11
|
+
6427a4edff08f93d98f511418423f09f2ab90bcd d9dfa5aee51e92a541b707e8e7baea6f06deff98 Jianfeng <Jianfeng.Liu0413@gmail.com> 1718570102 +0200 update by push
|
12
|
+
d9dfa5aee51e92a541b707e8e7baea6f06deff98 e31356f90ea6dd0577b5e0b40b206319adcbf085 Jianfeng <Jianfeng.Liu0413@gmail.com> 1718618415 +0200 update by push
|
13
|
+
e31356f90ea6dd0577b5e0b40b206319adcbf085 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng <Jianfeng.Liu0413@gmail.com> 1718619570 +0200 update by push
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
x�NIj1�Y��{����4&�C�`�Qk,�4f�!������K-PU�Zk�,��F�����n&�MJd�u$7=eV�1�{ظu0>x�g�h5R��1[�RZ�d�a��u��Z���ʎF��RC��~�t�ic|�B�7;�] �B����O���~�~�klc���2�!^Q�
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
py2ls/.git/refs/heads/main
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
627c81b23b4e56e87b042b650b0103653cc9e34a
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
1ab4585881a6a42889f01aa0cfe25fd5acfaf46f
|
py2ls/__init__.py
CHANGED
py2ls/ips.py
CHANGED
@@ -3,7 +3,6 @@ import numpy as np
|
|
3
3
|
import pandas as pd
|
4
4
|
import json
|
5
5
|
import matplotlib.pyplot as plt
|
6
|
-
# from functools import partial
|
7
6
|
import seaborn as sns
|
8
7
|
import scienceplots
|
9
8
|
import matplotlib
|
@@ -15,7 +14,7 @@ from scipy import stats
|
|
15
14
|
import matplotlib.ticker as tck
|
16
15
|
from cycler import cycler
|
17
16
|
import re
|
18
|
-
from PIL import ImageEnhance, ImageOps,ImageFilter
|
17
|
+
from PIL import Image,ImageEnhance, ImageOps,ImageFilter
|
19
18
|
from rembg import remove,new_session
|
20
19
|
from mpl_toolkits.mplot3d import Axes3D
|
21
20
|
import docx
|
@@ -36,6 +35,8 @@ import time
|
|
36
35
|
from box import Box, BoxList
|
37
36
|
from numerizer import numerize
|
38
37
|
from tqdm import tqdm
|
38
|
+
import mimetypes
|
39
|
+
from pprint import pp
|
39
40
|
|
40
41
|
def str2num(s, *args):
|
41
42
|
delimiter = None
|
@@ -778,14 +779,15 @@ def dir_name(fpath):
|
|
778
779
|
return dirname(fpath)
|
779
780
|
def basename(fpath):
|
780
781
|
return os.path.basename(fpath)
|
782
|
+
|
781
783
|
def listdir(
|
782
784
|
rootdir,
|
783
785
|
kind="folder",
|
784
786
|
sort_by="name",
|
785
787
|
ascending=True,
|
786
788
|
contains=None,
|
787
|
-
orient
|
788
|
-
output=
|
789
|
+
orient="list",
|
790
|
+
output="df"
|
789
791
|
):
|
790
792
|
def sort_kind(df, by="name", ascending=True):
|
791
793
|
if df[by].dtype == 'object': # Check if the column contains string values
|
@@ -801,6 +803,69 @@ def listdir(
|
|
801
803
|
sorted_df = df.iloc[sorted_index].reset_index(drop=True)
|
802
804
|
return sorted_df
|
803
805
|
|
806
|
+
def flist(fpath, filter="all"):
|
807
|
+
all_files = [os.path.join(fpath, f) for f in os.listdir(fpath) if os.path.isfile(os.path.join(fpath, f))]
|
808
|
+
if isinstance(filter, list):
|
809
|
+
filt_files = []
|
810
|
+
for filter_ in filter:
|
811
|
+
filt_files.extend(flist(fpath, filter_))
|
812
|
+
return filt_files
|
813
|
+
else:
|
814
|
+
if 'all' in filter.lower():
|
815
|
+
return all_files
|
816
|
+
else:
|
817
|
+
filt_files = [f for f in all_files if istype(f, filter)]
|
818
|
+
return filt_files
|
819
|
+
|
820
|
+
def istype(fpath, filter='img'):
|
821
|
+
"""
|
822
|
+
Filters file paths based on the specified filter.
|
823
|
+
Args:
|
824
|
+
fpath (str): Path to the file.
|
825
|
+
filter (str): Filter of file to filter. Default is 'img' for images. Other options include 'doc' for documents,
|
826
|
+
'zip' for ZIP archives, and 'other' for other types of files.
|
827
|
+
Returns:
|
828
|
+
bool: True if the file matches the filter, False otherwise.
|
829
|
+
"""
|
830
|
+
if 'img' in filter.lower():
|
831
|
+
return is_image(fpath)
|
832
|
+
elif 'doc' in filter.lower():
|
833
|
+
return is_document(fpath)
|
834
|
+
elif 'zip' in filter.lower():
|
835
|
+
return is_zip(fpath)
|
836
|
+
else:
|
837
|
+
return False
|
838
|
+
|
839
|
+
def is_image(fpath):
|
840
|
+
mime_type, _ = mimetypes.guess_type(fpath)
|
841
|
+
if mime_type and mime_type.startswith('image'):
|
842
|
+
return True
|
843
|
+
else:
|
844
|
+
return False
|
845
|
+
|
846
|
+
def is_document(fpath):
|
847
|
+
mime_type, _ = mimetypes.guess_type(fpath)
|
848
|
+
if mime_type and (
|
849
|
+
mime_type.startswith('text/') or
|
850
|
+
mime_type == 'application/pdf' or
|
851
|
+
mime_type == 'application/msword' or
|
852
|
+
mime_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' or
|
853
|
+
mime_type == 'application/vnd.ms-excel' or
|
854
|
+
mime_type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' or
|
855
|
+
mime_type == 'application/vnd.ms-powerpoint' or
|
856
|
+
mime_type == 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
|
857
|
+
):
|
858
|
+
return True
|
859
|
+
else:
|
860
|
+
return False
|
861
|
+
|
862
|
+
def is_zip(fpath):
|
863
|
+
mime_type, _ = mimetypes.guess_type(fpath)
|
864
|
+
if mime_type == 'application/zip':
|
865
|
+
return True
|
866
|
+
else:
|
867
|
+
return False
|
868
|
+
|
804
869
|
if not kind.startswith("."):
|
805
870
|
kind = "." + kind
|
806
871
|
|
@@ -814,7 +879,7 @@ def listdir(
|
|
814
879
|
"path": [],
|
815
880
|
"created_time": [],
|
816
881
|
"modified_time": [],
|
817
|
-
"last_open_time":[],
|
882
|
+
"last_open_time": [],
|
818
883
|
"size": [],
|
819
884
|
"fname": [],
|
820
885
|
"fpath": [],
|
@@ -828,16 +893,20 @@ def listdir(
|
|
828
893
|
is_file = kind.lower() in file_extension.lower() and (
|
829
894
|
os.path.isfile(item_path)
|
830
895
|
)
|
831
|
-
if
|
832
|
-
|
896
|
+
if kind in ['.doc','.img','.zip']: #选择大的类别
|
897
|
+
if kind != ".folder" and not istype(item_path, kind):
|
898
|
+
continue
|
899
|
+
else: #精确到文件的后缀
|
900
|
+
if not is_folder and not is_file:
|
901
|
+
continue
|
833
902
|
f["name"].append(filename)
|
834
903
|
f["length"].append(len(filename))
|
835
904
|
f["path"].append(os.path.join(os.path.dirname(item_path), item))
|
836
|
-
fpath=os.path.join(os.path.dirname(item_path), item)
|
905
|
+
fpath = os.path.join(os.path.dirname(item_path), item)
|
837
906
|
f["size"].append(round(os.path.getsize(fpath) / 1024 / 1024, 3))
|
838
|
-
f["created_time"].append(pd.to_datetime(os.path.getctime(item_path),unit='s'))
|
839
|
-
f["modified_time"].append(pd.to_datetime(os.path.getmtime(item_path),unit='s'))
|
840
|
-
f['last_open_time'].append(pd.to_datetime(os.path.getatime(item_path),unit='s'))
|
907
|
+
f["created_time"].append(pd.to_datetime(os.path.getctime(item_path), unit='s'))
|
908
|
+
f["modified_time"].append(pd.to_datetime(os.path.getmtime(item_path), unit='s'))
|
909
|
+
f['last_open_time'].append(pd.to_datetime(os.path.getatime(item_path), unit='s'))
|
841
910
|
f["fname"].append(filename) # will be removed
|
842
911
|
f["fpath"].append(fpath) # will be removed
|
843
912
|
i += 1
|
@@ -850,32 +919,35 @@ def listdir(
|
|
850
919
|
'The directory "{}" does NOT exist. Please check the directory "rootdir".'.format(
|
851
920
|
rootdir
|
852
921
|
)
|
853
|
-
)
|
922
|
+
)
|
923
|
+
|
854
924
|
f = pd.DataFrame(f)
|
925
|
+
|
855
926
|
if contains is not None:
|
856
|
-
f = f[f["name"].str.contains(contains,case=False)]
|
927
|
+
f = f[f["name"].str.contains(contains, case=False)]
|
928
|
+
|
857
929
|
if "nam" in sort_by.lower():
|
858
|
-
|
859
|
-
f=sort_kind(f, by="name", ascending=ascending)
|
930
|
+
f = sort_kind(f, by="name", ascending=ascending)
|
860
931
|
elif "crea" in sort_by.lower():
|
861
|
-
f=sort_kind(f, by="created_time", ascending=ascending)
|
932
|
+
f = sort_kind(f, by="created_time", ascending=ascending)
|
862
933
|
elif "modi" in sort_by.lower():
|
863
|
-
f=sort_kind(f, by="modified_time", ascending=ascending)
|
934
|
+
f = sort_kind(f, by="modified_time", ascending=ascending)
|
864
935
|
elif "s" in sort_by.lower() and "z" in sort_by.lower():
|
865
|
-
f=sort_kind(f, by="size", ascending=ascending)
|
936
|
+
f = sort_kind(f, by="size", ascending=ascending)
|
937
|
+
|
866
938
|
if 'df' in output:
|
867
939
|
return f
|
868
940
|
else:
|
869
|
-
if 'l' in orient.lower():
|
941
|
+
if 'l' in orient.lower(): # list # default
|
870
942
|
res_output = Box(f.to_dict(orient="list"))
|
871
943
|
return res_output
|
872
|
-
if 'd' in orient.lower():
|
944
|
+
if 'd' in orient.lower(): # dict
|
873
945
|
return Box(f.to_dict(orient="dict"))
|
874
|
-
if 'r' in orient.lower():
|
946
|
+
if 'r' in orient.lower(): # records
|
875
947
|
return Box(f.to_dict(orient="records"))
|
876
|
-
if 'in' in orient.lower():
|
948
|
+
if 'in' in orient.lower(): # records
|
877
949
|
return Box(f.to_dict(orient="index"))
|
878
|
-
if 'se' in orient.lower():
|
950
|
+
if 'se' in orient.lower(): # records
|
879
951
|
return Box(f.to_dict(orient="series"))
|
880
952
|
|
881
953
|
# Example usage:
|
@@ -2035,7 +2107,6 @@ def load_img(fpath):
|
|
2035
2107
|
FileNotFoundError: If the specified file is not found.
|
2036
2108
|
OSError: If the specified file cannot be opened or is not a valid image file.
|
2037
2109
|
"""
|
2038
|
-
from PIL import Image
|
2039
2110
|
|
2040
2111
|
try:
|
2041
2112
|
img = Image.open(fpath)
|
@@ -2116,6 +2187,7 @@ def apply_filter(img, *args):
|
|
2116
2187
|
raise ValueError(
|
2117
2188
|
f"Unsupported filter: {filter_name}, should be one of: {supported_filters}"
|
2118
2189
|
)
|
2190
|
+
|
2119
2191
|
for arg in args:
|
2120
2192
|
if isinstance(arg, str):
|
2121
2193
|
filter_name = arg
|
@@ -2214,6 +2286,29 @@ def imgsets(
|
|
2214
2286
|
Note:
|
2215
2287
|
The "color" and "enhance" enhancements are not implemented in this function.
|
2216
2288
|
"""
|
2289
|
+
supported_filters = [
|
2290
|
+
"BLUR",
|
2291
|
+
"CONTOUR",
|
2292
|
+
"DETAIL",
|
2293
|
+
"EDGE_ENHANCE",
|
2294
|
+
"EDGE_ENHANCE_MORE",
|
2295
|
+
"EMBOSS",
|
2296
|
+
"FIND_EDGES",
|
2297
|
+
"SHARPEN",
|
2298
|
+
"SMOOTH",
|
2299
|
+
"SMOOTH_MORE",
|
2300
|
+
"MIN_FILTER",
|
2301
|
+
"MAX_FILTER",
|
2302
|
+
"MODE_FILTER",
|
2303
|
+
"MULTIBAND_FILTER",
|
2304
|
+
"GAUSSIAN_BLUR",
|
2305
|
+
"BOX_BLUR",
|
2306
|
+
"MEDIAN_FILTER",
|
2307
|
+
]
|
2308
|
+
print("sets: a dict,'sharp:1.2','color','contrast:'auto' or 1.2','bright', 'crop: x_upperleft,y_upperleft, x_lowerright, y_lowerright','rotation','resize','rem or background'")
|
2309
|
+
print(f"usage: filter_kws 'dict' below:")
|
2310
|
+
pp([str(i).lower() for i in supported_filters])
|
2311
|
+
print("\nlog:\n")
|
2217
2312
|
def confirm_rembg_models(model_name):
|
2218
2313
|
models_support = [
|
2219
2314
|
"u2net",
|
@@ -2662,6 +2757,46 @@ def figsets(*args):
|
|
2662
2757
|
plt.tight_layout()
|
2663
2758
|
plt.gcf().align_labels()
|
2664
2759
|
|
2760
|
+
def thumbnail(dir_img_list,figsize=(10,10),dpi=100, dir_save=None, kind='.png'):
|
2761
|
+
"""
|
2762
|
+
Display a thumbnail figure of all images in the specified directory.
|
2763
|
+
Args:
|
2764
|
+
dir_img_list (list): List of the Directory containing the images.
|
2765
|
+
"""
|
2766
|
+
num_images = len(dir_img_list)
|
2767
|
+
if not kind.startswith('.'):
|
2768
|
+
kind='.'+kind
|
2769
|
+
|
2770
|
+
if num_images == 0:
|
2771
|
+
print("No images found to display.")
|
2772
|
+
return
|
2773
|
+
grid_size = int(num_images ** 0.5) + 1 # Determine grid size
|
2774
|
+
fig, axs = plt.subplots(grid_size, grid_size, figsize=figsize,dpi=dpi)
|
2775
|
+
for ax, image_file in zip(axs.flatten(), dir_img_list):
|
2776
|
+
try:
|
2777
|
+
img = Image.open(image_file)
|
2778
|
+
ax.imshow(img)
|
2779
|
+
ax.axis('off')
|
2780
|
+
except:
|
2781
|
+
continue
|
2782
|
+
# for ax in axs.flatten():
|
2783
|
+
# ax.axis('off')
|
2784
|
+
[ax.axis("off") for ax in axs.flatten()]
|
2785
|
+
plt.tight_layout()
|
2786
|
+
if dir_save is None:
|
2787
|
+
plt.show()
|
2788
|
+
else:
|
2789
|
+
if basename(dir_save):
|
2790
|
+
fname= basename(dir_save) +kind
|
2791
|
+
else:
|
2792
|
+
fname= "_thumbnail_"+basename(dirname(dir_save)[:-1])+'.png'
|
2793
|
+
if dirname(dir_img_list[0]) == dirname(dir_save):
|
2794
|
+
figsave(dirname(dir_save[:-1]),fname)
|
2795
|
+
else:
|
2796
|
+
figsave(dirname(dir_save),fname)
|
2797
|
+
# usage:
|
2798
|
+
# fpath = "/Users/macjianfeng/Dropbox/github/python/py2ls/tests/xample_netfinder/images/"
|
2799
|
+
# thumbnail(listdir(fpath,'png').fpath.to_list(),dir_save=dirname(fpath))
|
2665
2800
|
def read_mplstyle(style_file):
|
2666
2801
|
# Load the style file
|
2667
2802
|
plt.style.use(style_file)
|