pypipr 1.0.84__py3-none-any.whl → 1.0.86__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.
pypipr/__init__.py CHANGED
@@ -62,6 +62,7 @@ from .ifunctions.irange import irange
62
62
  from .ifunctions.ireplace import ireplace
63
63
  from .ifunctions.iscandir import iscandir
64
64
  from .ifunctions.isplit import isplit
65
+ import asyncio
65
66
  import colorama
66
67
  import datetime
67
68
  import functools
@@ -70,6 +71,7 @@ import io
70
71
  import json
71
72
  import lxml
72
73
  import math
74
+ import multiprocessing
73
75
  import operator
74
76
  import os
75
77
  import pathlib
@@ -83,6 +85,7 @@ import string
83
85
  import subprocess
84
86
  import sys
85
87
  import textwrap
88
+ import threading
86
89
  import time
87
90
  import tzdata
88
91
  import uuid
@@ -47,7 +47,7 @@ class RunParallel:
47
47
  Akses resource menggunakan parameter yang sudah disediakan yaitu
48
48
  `result: dict` dan `q: queue.Queue`.
49
49
 
50
- ```python
50
+ ```py
51
51
  class ExampleRunParallel(RunParallel):
52
52
  z = "ini"
53
53
 
@@ -165,3 +165,60 @@ class RunParallel:
165
165
  for i in r:
166
166
  i.join()
167
167
  return (i.copy() for i in a)
168
+
169
+
170
+ class ExampleRunParallel(RunParallel):
171
+ z = "ini"
172
+
173
+ def __init__(self) -> None:
174
+ self.pop = random.randint(0, 100)
175
+
176
+ def _set_property_here(self, v):
177
+ self.prop = v
178
+
179
+ def a(self, result: dict, q: queue.Queue):
180
+ result["z"] = self.z
181
+ result["pop"] = self.pop
182
+ result["a"] = "a"
183
+ q.put("from a 1")
184
+ q.put("from a 2")
185
+
186
+ def b(self, result: dict, q: queue.Queue):
187
+ result["z"] = self.z
188
+ result["pop"] = self.pop
189
+ result["b"] = "b"
190
+ result["q_get"] = q.get()
191
+
192
+ def c(self, result: dict, q: queue.Queue):
193
+ result["z"] = self.z
194
+ result["pop"] = self.pop
195
+ result["c"] = "c"
196
+ result["q_get"] = q.get()
197
+
198
+ async def d(self):
199
+ print("hello")
200
+ await asyncio.sleep(0)
201
+ print("hello")
202
+
203
+ result = {}
204
+ result["z"] = self.z
205
+ result["pop"] = self.pop
206
+ result["d"] = "d"
207
+ return result
208
+
209
+ async def e(self):
210
+ print("world")
211
+ await asyncio.sleep(0)
212
+ print("world")
213
+
214
+ result = {}
215
+ result["z"] = self.z
216
+ result["pop"] = self.pop
217
+ result["e"] = "e"
218
+ return result
219
+
220
+
221
+ if __name__ == "__main__":
222
+ print(ExampleRunParallel().run_asyncio())
223
+ print(ExampleRunParallel().run_multi_threading())
224
+ print(ExampleRunParallel().run_multi_processing())
@@ -1,8 +1,9 @@
1
- import subprocess
1
+ # import subprocess
2
2
  import time
3
3
 
4
4
  from ..ibuiltins.get_filemtime import get_filemtime
5
5
  from ..iconsole.print_log import print_log
6
+ from ..iconsole.console_run import console_run
6
7
 
7
8
 
8
9
  def auto_reload(filename):
@@ -13,7 +14,8 @@ def auto_reload(filename):
13
14
  Jalankan kode ini di terminal console.
14
15
 
15
16
  ```py
16
- python -m pypipr.iflow.auto_reload file_name.py
17
+ if __name__ == "__main__":
18
+ auto_reload("file_name.py")
17
19
  ```
18
20
  """
19
21
  mtime = get_filemtime(filename)
@@ -24,17 +26,11 @@ def auto_reload(filename):
24
26
  print_log("Start")
25
27
  while True:
26
28
  last_mtime = mtime
27
- subprocess.run(cmd, shell=True)
29
+ console_run(cmd, print_info=False)
30
+ # subprocess.run(cmd, shell=True)
28
31
  while mtime == last_mtime:
29
32
  time.sleep(1)
30
33
  mtime = get_filemtime(filename)
31
34
  print_log("Reload")
32
35
  except KeyboardInterrupt:
33
36
  print_log("Stop")
34
-
35
-
36
- if __name__ == "__main__":
37
- from pypipr.ifunctions.iargv import iargv
38
-
39
- if f := iargv(1):
40
- auto_reload(f)
@@ -2,6 +2,16 @@ import sys
2
2
 
3
3
 
4
4
  def iargv(key: int, cast=None, on_error=None):
5
+ """
6
+ Mengambil parameter input dari terminal tanpa menimbulkan error
7
+ apabila parameter kosong.
8
+ Parameter yg berupa string juga dapat diubah menggunakan cast.
9
+
10
+ ```python
11
+ if __name__ == "__main__":
12
+ print(iargv(1, cast=int, on_error=100))
13
+ ```
14
+ """
5
15
  try:
6
16
  v = sys.argv[key]
7
17
  if cast:
pypipr/ifunctions/ienv.py CHANGED
@@ -9,6 +9,11 @@ def ienv(on_windows=None, on_linux=None):
9
9
  ```py
10
10
  getch = __import__(ienv(on_windows="msvcrt", on_linux="getch"))
11
11
 
12
+
13
+ f = ienv(on_windows=fwin, on_linux=flin)
14
+ f()
15
+
16
+
12
17
  inherit = ienv(
13
18
  on_windows=[BaseForWindows, BaseEnv, object],
14
19
  on_linux=[SpecialForLinux, BaseForLinux, BaseEnv, object]
@@ -30,7 +30,5 @@ def iscandir(
30
30
 
31
31
 
32
32
  if __name__ == "__main__":
33
- from .iargv import iargv
34
- from .iprint import iprint
35
-
36
- iprint(iscandir(iargv(1, on_error=".")))
33
+ print(iscandir())
34
+ print(list(iscandir("./", recursive=False, scan_file=False)))