py2ls 0.1.10.12__py3-none-any.whl → 0.2.7.10__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.

Potentially problematic release.


This version of py2ls might be problematic. Click here for more details.

Files changed (72) hide show
  1. py2ls/.DS_Store +0 -0
  2. py2ls/.git/.DS_Store +0 -0
  3. py2ls/.git/index +0 -0
  4. py2ls/.git/logs/refs/remotes/origin/HEAD +1 -0
  5. py2ls/.git/objects/.DS_Store +0 -0
  6. py2ls/.git/refs/.DS_Store +0 -0
  7. py2ls/ImageLoader.py +621 -0
  8. py2ls/__init__.py +7 -5
  9. py2ls/apptainer2ls.py +3940 -0
  10. py2ls/batman.py +164 -42
  11. py2ls/bio.py +2595 -0
  12. py2ls/cell_image_clf.py +1632 -0
  13. py2ls/container2ls.py +4635 -0
  14. py2ls/corr.py +475 -0
  15. py2ls/data/.DS_Store +0 -0
  16. py2ls/data/email/email_html_template.html +88 -0
  17. py2ls/data/hyper_param_autogluon_zeroshot2024.json +2383 -0
  18. py2ls/data/hyper_param_tabrepo_2024.py +1753 -0
  19. py2ls/data/mygenes_fields_241022.txt +355 -0
  20. py2ls/data/re_common_pattern.json +173 -0
  21. py2ls/data/sns_info.json +74 -0
  22. py2ls/data/styles/.DS_Store +0 -0
  23. py2ls/data/styles/example/.DS_Store +0 -0
  24. py2ls/data/styles/stylelib/.DS_Store +0 -0
  25. py2ls/data/styles/stylelib/grid.mplstyle +15 -0
  26. py2ls/data/styles/stylelib/high-contrast.mplstyle +6 -0
  27. py2ls/data/styles/stylelib/high-vis.mplstyle +4 -0
  28. py2ls/data/styles/stylelib/ieee.mplstyle +15 -0
  29. py2ls/data/styles/stylelib/light.mplstyl +6 -0
  30. py2ls/data/styles/stylelib/muted.mplstyle +6 -0
  31. py2ls/data/styles/stylelib/nature-reviews-latex.mplstyle +616 -0
  32. py2ls/data/styles/stylelib/nature-reviews.mplstyle +616 -0
  33. py2ls/data/styles/stylelib/nature.mplstyle +31 -0
  34. py2ls/data/styles/stylelib/no-latex.mplstyle +10 -0
  35. py2ls/data/styles/stylelib/notebook.mplstyle +36 -0
  36. py2ls/data/styles/stylelib/paper.mplstyle +290 -0
  37. py2ls/data/styles/stylelib/paper2.mplstyle +305 -0
  38. py2ls/data/styles/stylelib/retro.mplstyle +4 -0
  39. py2ls/data/styles/stylelib/sans.mplstyle +10 -0
  40. py2ls/data/styles/stylelib/scatter.mplstyle +7 -0
  41. py2ls/data/styles/stylelib/science.mplstyle +48 -0
  42. py2ls/data/styles/stylelib/std-colors.mplstyle +4 -0
  43. py2ls/data/styles/stylelib/vibrant.mplstyle +6 -0
  44. py2ls/data/tiles.csv +146 -0
  45. py2ls/data/usages_pd.json +1417 -0
  46. py2ls/data/usages_sns.json +31 -0
  47. py2ls/docker2ls.py +5446 -0
  48. py2ls/ec2ls.py +61 -0
  49. py2ls/fetch_update.py +145 -0
  50. py2ls/ich2ls.py +1955 -296
  51. py2ls/im2.py +8242 -0
  52. py2ls/image_ml2ls.py +2100 -0
  53. py2ls/ips.py +33909 -3418
  54. py2ls/ml2ls.py +7700 -0
  55. py2ls/mol.py +289 -0
  56. py2ls/mount2ls.py +1307 -0
  57. py2ls/netfinder.py +873 -351
  58. py2ls/nl2ls.py +283 -0
  59. py2ls/ocr.py +1581 -458
  60. py2ls/plot.py +10394 -314
  61. py2ls/rna2ls.py +311 -0
  62. py2ls/ssh2ls.md +456 -0
  63. py2ls/ssh2ls.py +5933 -0
  64. py2ls/ssh2ls_v01.py +2204 -0
  65. py2ls/stats.py +66 -172
  66. py2ls/temp20251124.py +509 -0
  67. py2ls/translator.py +2 -0
  68. py2ls/utils/decorators.py +3564 -0
  69. py2ls/utils_bio.py +3453 -0
  70. {py2ls-0.1.10.12.dist-info → py2ls-0.2.7.10.dist-info}/METADATA +113 -224
  71. {py2ls-0.1.10.12.dist-info → py2ls-0.2.7.10.dist-info}/RECORD +72 -16
  72. {py2ls-0.1.10.12.dist-info → py2ls-0.2.7.10.dist-info}/WHEEL +0 -0
py2ls/ec2ls.py ADDED
@@ -0,0 +1,61 @@
1
+ def get_trend(
2
+ keywords: list = None, # ["AI", "Python", "Data Science"]
3
+ timezone: str = "Europe/Berlin", # minutes differ from UTC
4
+ cat=0,
5
+ timeframe="today 12-m",
6
+ geo="DE",
7
+ gprop="",
8
+ **kwargs
9
+ ):
10
+ from pytrends.request import TrendReq
11
+ from pytrends.exceptions import TooManyRequestsError
12
+ import pytz
13
+ from datetime import datetime
14
+ import time
15
+ import requests
16
+ from urllib3.util.retry import Retry
17
+
18
+ if isinstance(timezone, str):
19
+ stadt = pytz.timezone(timezone)
20
+ current_time = datetime.now(stadt) # This will be timezone-aware
21
+ # Convert the timezone-aware datetime to naive UTC datetime
22
+ naive_time = current_time.astimezone(pytz.utc).replace(tzinfo=None)
23
+ tz_offset = stadt.utcoffset(naive_time).seconds // 60 # in minutes
24
+ elif isinstance(timezone, int):
25
+ tz_offset = timezone
26
+
27
+ # Initialize TrendReq with correct timezone offset
28
+ pytrends = TrendReq(hl="en-US", tz=tz_offset )
29
+
30
+ # Ensure that keywords are in list form
31
+ if isinstance(keywords, str):
32
+ keywords = [keywords]
33
+
34
+ pytrends.build_payload(keywords, cat=cat, timeframe=timeframe, geo=geo, gprop=gprop)
35
+
36
+ res = {}
37
+ # Try fetching data with error handling
38
+ for func_name, fetch_func in [
39
+ ("interest_over_time", pytrends.interest_over_time),
40
+ ("related_topics", pytrends.related_topics),
41
+ ("related_queries", pytrends.related_queries),
42
+ ("categories", pytrends.categories)
43
+ ]:
44
+ try:
45
+ print(f"Fetching {func_name}...")
46
+ res[func_name] = fetch_func()
47
+ print(f"done: {func_name}")
48
+ except TooManyRequestsError:
49
+ print(f"Too many requests error for {func_name}. Retrying...")
50
+ time.sleep(5) # Delay to avoid spamming the server
51
+ if retries > 0:
52
+ return get_trend(keywords, timezone, cat, timeframe, geo, gprop, retries=retries-1)
53
+ res[func_name] = None
54
+ except requests.exceptions.RequestException as e:
55
+ print(f"Request error for {func_name}: {e}")
56
+ res[func_name] = None
57
+ except Exception as e:
58
+ print(f"Error fetching {func_name}: {e}")
59
+ res[func_name] = None
60
+
61
+ return res
py2ls/fetch_update.py ADDED
@@ -0,0 +1,145 @@
1
+ from .ips import *
2
+ from .netfinder import fetch, get_soup
3
+
4
+
5
+ def usage_pd(
6
+ url="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_clipboard.html",
7
+ dir_save=None,
8
+ ):
9
+ # extract each usage from its url
10
+ def get_usage(url):
11
+ # extract each usage from its url
12
+ print(f"trying: {url}")
13
+ sp = get_soup(url, driver="se")
14
+ return fetch(sp, where="dt")[0]
15
+
16
+
17
+ if dir_save is None:
18
+ if "mac" in get_os():
19
+ dir_save = "/Users/macjianfeng/Dropbox/github/python/py2ls/py2ls/data/"
20
+ else:
21
+ dir_save = "Z:\\Jianfeng\\temp\\"
22
+ sp = get_soup(url, driver="se")
23
+ links_all4lev1 = fetch(sp, where="a", get="href", class_="reference internal")
24
+ links_level_1 = [
25
+ strcmp(link, links_all4lev1)[0].replace(
26
+ "../", "https://pandas.pydata.org/docs/reference/"
27
+ )
28
+ for link in links_all4lev1
29
+ if not link.startswith("pandas")
30
+ ]
31
+ dict_usage = {}
32
+ for link_level_1 in links_level_1:
33
+ sp = get_soup(link_level_1, driver="se")
34
+ links_all = fetch(sp, where="a", get="href", class_="reference internal")
35
+
36
+ filtered_links = unique(
37
+ [
38
+ i
39
+ for i in links_all
40
+ if any([i.startswith(cond) for cond in ["pandas", "api"]])
41
+ ]
42
+ )
43
+ links = [
44
+ (
45
+ "https://pandas.pydata.org/docs/reference/api/" + i
46
+ if not i.startswith("api")
47
+ else "https://pandas.pydata.org/docs/reference/" + i
48
+ )
49
+ for i in filtered_links
50
+ ]
51
+ usages = [get_usage(i) for i in links]
52
+ for usage, link in zip(usages, links):
53
+ if usage.startswith("DataFrame"):
54
+ usage = usage.replace("DataFrame", "df")
55
+ if usage.startswith("pandas"):
56
+ usage = usage.replace("pandas", "pd")
57
+ if usage.endswith("[source]#"):
58
+ usage = usage.replace("[source]#", "")
59
+ if usage.endswith("#"):
60
+ usage = usage.replace("#", "")
61
+ str2rm = ["class", "property"]
62
+ for str2rm_ in str2rm:
63
+ if usage.startswith(str2rm_):
64
+ usage = usage.replace(str2rm_, "")
65
+ funcname = ssplit(usage, by="(")[0]
66
+ dict_usage.update({funcname: usage + f"\n{link}"})
67
+ # save to local
68
+ dir_save += "/" if not dir_save.endswith("/") else ""
69
+ fsave(
70
+ dir_save + "usages_pd.json",
71
+ dict_usage,
72
+ )
73
+ def usage_sns(
74
+ url="https://seaborn.pydata.org/generated/seaborn.swarmplot.html",
75
+ dir_save=None,
76
+ ):
77
+ """
78
+ Fetches usage examples of various Seaborn plotting functions from the Seaborn documentation website.
79
+ It filters the relevant plot-related links, extracts usage examples, and saves them in a JSON file.
80
+
81
+ Parameters:
82
+ - url (str): URL of the Seaborn page to start extracting plot usages (default is swarmplot page).
83
+ - dir_save (str): Directory where the JSON file containing usages will be saved (default is a local path).
84
+
85
+ Saves:
86
+ - A JSON file named 'usages_sns.json' containing plotting function names and their usage descriptions.
87
+
88
+ Returns:
89
+ - None
90
+ """
91
+
92
+ # extract each usage from its url
93
+ def get_usage(url):
94
+ print(f"trying: {url}")
95
+ sp = get_soup(url, driver="se")
96
+ return fetch(sp, where="dt")[0]
97
+
98
+ if dir_save is None:
99
+ if "mac" in get_os():
100
+ dir_save = "/Users/macjianfeng/Dropbox/github/python/py2ls/py2ls/data/"
101
+ else:
102
+ dir_save = "Z:\\Jianfeng\\temp\\"
103
+ sp = get_soup(url, driver="se")
104
+ links_all = fetch(sp, where="a", get="href", class_="reference internal")
105
+ filtered_links = unique(
106
+ [
107
+ i
108
+ for i in links_all
109
+ if not any(
110
+ [
111
+ i.startswith(cond)
112
+ for cond in [
113
+ "seaborn.JointGrid",
114
+ "seaborn.PairGrid",
115
+ "seaborn.objects",
116
+ ]
117
+ ]
118
+ + ["plot" not in i]
119
+ )
120
+ ]
121
+ )
122
+ links = ["https://seaborn.pydata.org/generated/" + i for i in filtered_links]
123
+
124
+ usages = [get_usage(i) for i in links]
125
+ dict_usage = {}
126
+ for usage, link in zip(usages, links):
127
+ dict_usage.update(
128
+ {ssplit(usage, by="(")[0].replace("seaborn.", ""): usage[:-1] + f"\n{link}"}
129
+ )
130
+ # save to local
131
+ dir_save += "/" if not dir_save.endswith("/") else ""
132
+ fsave(
133
+ dir_save + "usages_sns.json",
134
+ dict_usage,
135
+ )
136
+
137
+
138
+ def main():
139
+ # update pandas usage to local
140
+ usage_pd()
141
+ # usage_sns()
142
+
143
+
144
+ if __name__ == "__main__":
145
+ main()