pypipr 1.0.106__tar.gz → 1.0.108__tar.gz
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-1.0.106 → pypipr-1.0.108}/PKG-INFO +870 -855
- pypipr-1.0.108/pypipr/__init__.py +98 -0
- {pypipr-1.0.106/pypipr/iflow → pypipr-1.0.108/pypipr}/auto_reload.py +3 -3
- {pypipr-1.0.106/pypipr/iengineering → pypipr-1.0.108/pypipr}/batchmaker.py +2 -2
- {pypipr-1.0.106/pypipr/iconsole → pypipr-1.0.108/pypipr}/choices.py +2 -2
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/create_folder.py +0 -6
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/datetime_now.py +0 -5
- {pypipr-1.0.106/pypipr/iflow → pypipr-1.0.108/pypipr}/github_pull.py +1 -5
- {pypipr-1.0.106/pypipr/iflow → pypipr-1.0.108/pypipr}/github_push.py +3 -3
- {pypipr-1.0.106/pypipr/iflow → pypipr-1.0.108/pypipr}/github_user.py +1 -1
- {pypipr-1.0.106/pypipr/ifunctions → pypipr-1.0.108/pypipr}/ienv.py +2 -2
- {pypipr-1.0.106/pypipr/ifunctions → pypipr-1.0.108/pypipr}/ijoin.py +3 -3
- {pypipr-1.0.106/pypipr/iconsole → pypipr-1.0.108/pypipr}/input_char.py +2 -2
- {pypipr-1.0.106/pypipr/ifunctions → pypipr-1.0.108/pypipr}/iopen.py +2 -2
- {pypipr-1.0.106/pypipr/ifunctions → pypipr-1.0.108/pypipr}/iprint.py +1 -1
- {pypipr-1.0.106/pypipr/ifunctions → pypipr-1.0.108/pypipr}/irange.py +3 -3
- {pypipr-1.0.106/pypipr/iflow → pypipr-1.0.108/pypipr}/pip_freeze_without_version.py +4 -4
- {pypipr-1.0.106/pypipr/iflow → pypipr-1.0.108/pypipr}/poetry_publish.py +1 -1
- {pypipr-1.0.106/pypipr/iflow → pypipr-1.0.108/pypipr}/poetry_update_version.py +1 -1
- {pypipr-1.0.106/pypipr/iconsole → pypipr-1.0.108/pypipr}/print_dir.py +1 -1
- {pypipr-1.0.106 → pypipr-1.0.108}/pyproject.toml +1 -1
- {pypipr-1.0.106 → pypipr-1.0.108}/readme.md +869 -854
- pypipr-1.0.106/pypipr/__init__.py +0 -98
- pypipr-1.0.106/pypipr/ibuiltins/__init__.py +0 -0
- pypipr-1.0.106/pypipr/iconsole/__init__.py +0 -0
- pypipr-1.0.106/pypipr/idjango/__init__.py +0 -0
- pypipr-1.0.106/pypipr/iengineering/__init__.py +0 -0
- pypipr-1.0.106/pypipr/ifunctions/__init__.py +0 -0
- pypipr-1.0.106/pypipr/ifunctions/irange.py.bak +0 -81
- pypipr-1.0.106/pypipr/pypipr.py.bak +0 -37
- {pypipr-1.0.106/pypipr/idjango → pypipr-1.0.108/pypipr}/APIMixinView.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/ComparePerformance.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/LINUX.py +0 -0
- {pypipr-1.0.106/pypipr/iengineering → pypipr-1.0.108/pypipr}/PintUreg.py +0 -0
- {pypipr-1.0.106/pypipr/iengineering → pypipr-1.0.108/pypipr}/PintUregQuantity.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/RunParallel.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/WINDOWS.py +0 -0
- /pypipr-1.0.106/pypipr/terminal.py → /pypipr-1.0.108/pypipr/__terminal__.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/avg.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/basename.py +0 -0
- {pypipr-1.0.106/pypipr/iengineering → pypipr-1.0.108/pypipr}/batch_calculate.py +0 -0
- {pypipr-1.0.106/pypipr/iengineering → pypipr-1.0.108/pypipr}/calculate.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/chr_to_int.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/chunk_array.py +0 -0
- {pypipr-1.0.106/pypipr/iconsole → pypipr-1.0.108/pypipr}/console_run.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/datetime_from_string.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/dict_first.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/dirname.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/exit_if_empty.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/filter_empty.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/get_by_index.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/get_class_method.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/get_filemtime.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/get_filesize.py +0 -0
- {pypipr-1.0.106/pypipr/ifunctions → pypipr-1.0.108/pypipr}/iargv.py +0 -0
- {pypipr-1.0.106/pypipr/ifunctions → pypipr-1.0.108/pypipr}/idumps.py +0 -0
- {pypipr-1.0.106/pypipr/ifunctions → pypipr-1.0.108/pypipr}/idumps_html.py +0 -0
- {pypipr-1.0.106/pypipr/ifunctions → pypipr-1.0.108/pypipr}/iexec.py +0 -0
- {pypipr-1.0.106/pypipr/ifunctions → pypipr-1.0.108/pypipr}/iloads.py +0 -0
- {pypipr-1.0.106/pypipr/ifunctions → pypipr-1.0.108/pypipr}/iloads_html.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/int_to_chr.py +0 -0
- {pypipr-1.0.106/pypipr/ifunctions → pypipr-1.0.108/pypipr}/ireplace.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/is_empty.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/is_iterable.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/is_valid_url.py +0 -0
- {pypipr-1.0.106/pypipr/ifunctions → pypipr-1.0.108/pypipr}/iscandir.py +0 -0
- {pypipr-1.0.106/pypipr/ifunctions → pypipr-1.0.108/pypipr}/isplit.py +0 -0
- {pypipr-1.0.106/pypipr/ifunctions → pypipr-1.0.108/pypipr}/ivars.py +0 -0
- {pypipr-1.0.106/pypipr/iconsole → pypipr-1.0.108/pypipr}/log.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/password_generator.py +0 -0
- {pypipr-1.0.106/pypipr/iconsole → pypipr-1.0.108/pypipr}/print_colorize.py +0 -0
- {pypipr-1.0.106/pypipr/iconsole → pypipr-1.0.108/pypipr}/print_log.py +0 -0
- {pypipr-1.0.106/pypipr/iconsole → pypipr-1.0.108/pypipr}/print_to_last_line.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/random_bool.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/restart.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/set_timeout.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/sets_ordered.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/str_cmp.py +0 -0
- {pypipr-1.0.106/pypipr/iconsole → pypipr-1.0.108/pypipr}/text_colorize.py +0 -0
- {pypipr-1.0.106/pypipr/ibuiltins → pypipr-1.0.108/pypipr}/to_str.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pypipr
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.108
|
4
4
|
Summary: The Python Package Index Project
|
5
5
|
Author: ufiapjj
|
6
6
|
Author-email: ufiapjj@gmail.com
|
@@ -50,10 +50,10 @@ pypipr
|
|
50
50
|
|
51
51
|
`LINUX`
|
52
52
|
|
53
|
-
`WINDOWS`
|
54
|
-
|
55
53
|
`PintUreg`
|
56
54
|
|
55
|
+
`WINDOWS`
|
56
|
+
|
57
57
|
# FUNCTION
|
58
58
|
|
59
59
|
## avg
|
@@ -72,252 +72,105 @@ Output:
|
|
72
72
|
16.285714285714285
|
73
73
|
```
|
74
74
|
|
75
|
-
##
|
76
|
-
|
77
|
-
`basename(path)`
|
78
|
-
|
79
|
-
Mengembalikan nama file dari path
|
80
|
-
|
81
|
-
```python
|
82
|
-
print(basename("/ini/nama/folder/ke/file.py"))
|
83
|
-
```
|
84
|
-
|
85
|
-
Output:
|
86
|
-
```py
|
87
|
-
file.py
|
88
|
-
```
|
89
|
-
|
90
|
-
## chr_to_int
|
91
|
-
|
92
|
-
`chr_to_int(s, start=1, numbers='abcdefghijklmnopqrstuvwxyz')`
|
93
|
-
|
94
|
-
Fungsi ini berguna untuk mengubah urutan huruf menjadi angka.
|
95
|
-
|
96
|
-
```python
|
97
|
-
print(chr_to_int('z')) # Output: 26
|
98
|
-
print(chr_to_int('aa')) # Output: 27
|
99
|
-
print(chr_to_int('abc', numbers="abc")) # Output: 10
|
100
|
-
```
|
101
|
-
|
102
|
-
Output:
|
103
|
-
```py
|
104
|
-
26
|
105
|
-
27
|
106
|
-
18
|
107
|
-
```
|
108
|
-
|
109
|
-
## chunk_array
|
75
|
+
## get_filemtime
|
110
76
|
|
111
|
-
`
|
77
|
+
`get_filemtime(filename)`
|
112
78
|
|
113
|
-
|
79
|
+
Mengambil informasi last modification time file dalam nano seconds
|
114
80
|
|
115
81
|
```python
|
116
|
-
|
117
|
-
print(chunk_array(arr, 5))
|
118
|
-
print(list(chunk_array(arr, 5)))
|
82
|
+
print(get_filemtime(__file__))
|
119
83
|
```
|
120
84
|
|
121
85
|
Output:
|
122
86
|
```py
|
123
|
-
|
124
|
-
[[2, 3, 12, 3, 3], [42, 42, 1, 43, 2], [42, 41, 4, 24, 32], [42, 3, 12, 32, 42], [42]]
|
87
|
+
1714399678112897487
|
125
88
|
```
|
126
89
|
|
127
|
-
##
|
90
|
+
## print_colorize
|
128
91
|
|
129
|
-
`
|
92
|
+
`print_colorize(text, color='\x1b[32m', bright='\x1b[1m', color_end='\x1b[0m', text_start='', text_end='\n', delay=0.05)`
|
130
93
|
|
131
|
-
|
132
|
-
Membuat folder secara recursive dengan permission.
|
94
|
+
Print text dengan warna untuk menunjukan text penting
|
133
95
|
|
134
96
|
```py
|
135
|
-
|
136
|
-
|
137
|
-
create_folder("./contoh_membuat_folder/secara/recursive")
|
138
|
-
```
|
139
|
-
|
140
|
-
## datetime_from_string
|
141
|
-
|
142
|
-
`datetime_from_string(iso_string, timezone='UTC')`
|
143
|
-
|
144
|
-
Parse iso_string menjadi datetime object
|
145
|
-
|
146
|
-
```python
|
147
|
-
print(datetime_from_string("2022-12-12 15:40:13").isoformat())
|
148
|
-
print(datetime_from_string(
|
149
|
-
"2022-12-12 15:40:13",
|
150
|
-
timezone="Asia/Jakarta"
|
151
|
-
).isoformat())
|
152
|
-
```
|
153
|
-
|
154
|
-
Output:
|
155
|
-
```py
|
156
|
-
2022-12-12T15:40:13+00:00
|
157
|
-
2022-12-12T15:40:13+07:00
|
158
|
-
```
|
159
|
-
|
160
|
-
## datetime_now
|
161
|
-
|
162
|
-
`datetime_now(timezone=None)`
|
163
|
-
|
164
|
-
Memudahkan dalam membuat Datetime untuk suatu timezone tertentu
|
165
|
-
|
166
|
-
```python
|
167
|
-
print(datetime_now("Asia/Jakarta"))
|
168
|
-
print(datetime_now("GMT"))
|
169
|
-
print(datetime_now("Etc/GMT+7"))
|
170
|
-
```
|
171
|
-
|
172
|
-
Output:
|
173
|
-
```py
|
174
|
-
2024-04-29 20:34:31.857030+07:00
|
175
|
-
2024-04-29 13:34:31.857799+00:00
|
176
|
-
2024-04-29 06:34:31.859165-07:00
|
177
|
-
```
|
178
|
-
|
179
|
-
## dict_first
|
180
|
-
|
181
|
-
`dict_first(d: dict, remove=False)`
|
182
|
-
|
183
|
-
Mengambil nilai (key, value) pertama dari dictionary dalam bentuk tuple.
|
184
|
-
|
185
|
-
```python
|
186
|
-
d = {
|
187
|
-
"key2": "value2",
|
188
|
-
"key3": "value3",
|
189
|
-
"key1": "value1",
|
190
|
-
}
|
191
|
-
print(dict_first(d, remove=True))
|
192
|
-
print(dict_first(d))
|
193
|
-
```
|
194
|
-
|
195
|
-
Output:
|
196
|
-
```py
|
197
|
-
('key2', 'value2')
|
198
|
-
('key3', 'value3')
|
97
|
+
print_colorize("Print some text")
|
98
|
+
print_colorize("Print some text", color=colorama.Fore.RED)
|
199
99
|
```
|
200
100
|
|
201
|
-
##
|
101
|
+
## print_log
|
202
102
|
|
203
|
-
`
|
103
|
+
`print_log(text)`
|
204
104
|
|
205
|
-
|
206
|
-
|
105
|
+
Akan melakukan print ke console.
|
106
|
+
Berguna untuk memberikan informasi proses program yg sedang berjalan.
|
207
107
|
|
208
108
|
```python
|
209
|
-
|
109
|
+
print_log("Standalone Log")
|
210
110
|
```
|
211
111
|
|
212
112
|
Output:
|
213
113
|
```py
|
214
|
-
|
114
|
+
[32m[1m>>> Standalone Log[0m
|
215
115
|
```
|
216
116
|
|
217
|
-
##
|
117
|
+
## console_run
|
218
118
|
|
219
|
-
`
|
119
|
+
`console_run(info, command=None, print_info=True, capture_output=False)`
|
220
120
|
|
221
|
-
|
222
|
-
setara dengan empty
|
121
|
+
Menjalankan command seperti menjalankan command di Command Terminal
|
223
122
|
|
224
123
|
```py
|
225
|
-
|
226
|
-
|
227
|
-
exit_if_empty(var1, var2)
|
228
|
-
```
|
229
|
-
|
230
|
-
## filter_empty
|
231
|
-
|
232
|
-
`filter_empty(iterable, zero_is_empty=True, str_strip=True)`
|
233
|
-
|
234
|
-
Mengembalikan iterabel yang hanya memiliki nilai
|
235
|
-
|
236
|
-
```python
|
237
|
-
var = [1, None, False, 0, "0", True, {}, ['eee']]
|
238
|
-
print(filter_empty(var))
|
239
|
-
```
|
240
|
-
|
241
|
-
Output:
|
242
|
-
```py
|
243
|
-
<generator object filter_empty at 0x78073d2d40>
|
244
|
-
```
|
245
|
-
|
246
|
-
## get_by_index
|
247
|
-
|
248
|
-
`get_by_index(obj, index, on_error=None)`
|
249
|
-
|
250
|
-
Mendapatkan value dari object berdasarkan indexnya.
|
251
|
-
Jika error out of range maka akan mengembalikan on_error.
|
252
|
-
|
253
|
-
```python
|
254
|
-
l = [1, 3, 5]
|
255
|
-
print(get_by_index(l, 7))
|
256
|
-
```
|
257
|
-
|
258
|
-
Output:
|
259
|
-
```py
|
260
|
-
None
|
124
|
+
console_run('dir')
|
125
|
+
console_run('ls')
|
261
126
|
```
|
262
127
|
|
263
|
-
##
|
128
|
+
## auto_reload
|
264
129
|
|
265
|
-
`
|
130
|
+
`auto_reload(filename)`
|
266
131
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
def a():
|
272
|
-
return [x for x in range(10)]
|
273
|
-
|
274
|
-
def b():
|
275
|
-
return [x for x in range(10)]
|
276
|
-
|
277
|
-
def c():
|
278
|
-
return [x for x in range(10)]
|
279
|
-
|
280
|
-
def d():
|
281
|
-
return [x for x in range(10)]
|
132
|
+
Menjalankan file python secara berulang.
|
133
|
+
Dengan tujuan untuk melihat perubahan secara langsung.
|
134
|
+
Pastikan kode aman untuk dijalankan.
|
135
|
+
Jalankan kode ini di terminal console.
|
282
136
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
Output:
|
288
|
-
```py
|
289
|
-
<generator object get_class_method at 0x78073d3010>
|
290
|
-
[<function ExampleGetClassMethod.a at 0x7807449800>, <function ExampleGetClassMethod.b at 0x78074496c0>, <function ExampleGetClassMethod.c at 0x78074498a0>, <function ExampleGetClassMethod.d at 0x7807449940>]
|
137
|
+
```py
|
138
|
+
if __name__ == "__main__":
|
139
|
+
auto_reload("file_name.py")
|
291
140
|
```
|
292
141
|
|
293
|
-
##
|
142
|
+
## basename
|
294
143
|
|
295
|
-
`
|
144
|
+
`basename(path)`
|
296
145
|
|
297
|
-
|
146
|
+
Mengembalikan nama file dari path
|
298
147
|
|
299
148
|
```python
|
300
|
-
print(
|
149
|
+
print(basename("/ini/nama/folder/ke/file.py"))
|
301
150
|
```
|
302
151
|
|
303
152
|
Output:
|
304
153
|
```py
|
305
|
-
|
154
|
+
file.py
|
306
155
|
```
|
307
156
|
|
308
|
-
##
|
157
|
+
## chr_to_int
|
309
158
|
|
310
|
-
`
|
159
|
+
`chr_to_int(s, start=1, numbers='abcdefghijklmnopqrstuvwxyz')`
|
311
160
|
|
312
|
-
|
161
|
+
Fungsi ini berguna untuk mengubah urutan huruf menjadi angka.
|
313
162
|
|
314
163
|
```python
|
315
|
-
print(
|
164
|
+
print(chr_to_int('z')) # Output: 26
|
165
|
+
print(chr_to_int('aa')) # Output: 27
|
166
|
+
print(chr_to_int('abc', numbers="abc")) # Output: 10
|
316
167
|
```
|
317
168
|
|
318
169
|
Output:
|
319
170
|
```py
|
320
|
-
|
171
|
+
26
|
172
|
+
27
|
173
|
+
18
|
321
174
|
```
|
322
175
|
|
323
176
|
## int_to_chr
|
@@ -369,197 +222,157 @@ Output:
|
|
369
222
|
kmc
|
370
223
|
```
|
371
224
|
|
372
|
-
##
|
225
|
+
## irange
|
373
226
|
|
374
|
-
`
|
227
|
+
`irange(start, stop=None, step=1, index=0, numbers='abcdefghijklmnopqrstuvwxyz')`
|
375
228
|
|
376
|
-
|
377
|
-
|
378
|
-
Pengecekan nilai yang setara menggunakan simbol '==', sedangkan untuk
|
379
|
-
pengecekan lokasi memory yang sama menggunakan keyword 'is'
|
229
|
+
Meningkatkan fungsi range() dari python untuk pengulangan menggunakan huruf
|
380
230
|
|
381
231
|
```python
|
382
|
-
print(
|
383
|
-
print(
|
384
|
-
print(
|
385
|
-
print(
|
386
|
-
print(
|
387
|
-
print(is_empty([]))
|
232
|
+
print(irange('a', 'c'))
|
233
|
+
print(irange('z', 'a', 10))
|
234
|
+
print(list(irange('a', 'z', 10)))
|
235
|
+
print(list(irange(1, '7')))
|
236
|
+
print(list(irange(10, 5)))
|
388
237
|
```
|
389
238
|
|
390
239
|
Output:
|
391
240
|
```py
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
True
|
241
|
+
<generator object char_range at 0x7384c3fcd0>
|
242
|
+
<generator object char_range at 0x7384c3fcd0>
|
243
|
+
['a', 'k', 'u']
|
244
|
+
[1, 2, 3, 4, 5, 6]
|
245
|
+
[]
|
398
246
|
```
|
399
247
|
|
400
|
-
##
|
248
|
+
## batchmaker
|
401
249
|
|
402
|
-
`
|
250
|
+
`batchmaker(pattern: str)`
|
403
251
|
|
404
|
-
|
252
|
+
Alat Bantu untuk membuat teks yang berulang.
|
253
|
+
Gunakan `{[start][separator][finish]([separator][step])}`.
|
254
|
+
```
|
255
|
+
[start] dan [finish] -> bisa berupa huruf maupun angka
|
256
|
+
([separator][step]) -> bersifat optional
|
257
|
+
[separator] -> selain huruf dan angka
|
258
|
+
[step] -> berupa angka positif
|
259
|
+
```
|
405
260
|
|
406
261
|
```python
|
407
|
-
s =
|
408
|
-
print(
|
409
|
-
|
410
|
-
l = [12,21,2,1]
|
411
|
-
print(is_iterable(l))
|
412
|
-
|
413
|
-
r = range(100)
|
414
|
-
print(is_iterable(r))
|
415
|
-
|
416
|
-
d = {'a':1, 'b':2}
|
417
|
-
print(is_iterable(d.values()))
|
262
|
+
s = "Urutan {1/6/3} dan {10:9} dan {j k} dan {Z - A - 15} saja."
|
263
|
+
print(batchmaker(s))
|
264
|
+
print(list(batchmaker(s)))
|
418
265
|
```
|
419
266
|
|
420
267
|
Output:
|
421
268
|
```py
|
422
|
-
|
423
|
-
|
424
|
-
True
|
425
|
-
True
|
269
|
+
<generator object batchmaker at 0x7384b4c160>
|
270
|
+
[]
|
426
271
|
```
|
427
272
|
|
428
|
-
##
|
273
|
+
## calculate
|
429
274
|
|
430
|
-
`
|
275
|
+
`calculate(teks)`
|
431
276
|
|
432
|
-
|
433
|
-
|
277
|
+
Mengembalikan hasil dari perhitungan teks menggunakan modul pint.
|
278
|
+
Mendukung perhitungan matematika dasar dengan satuan.
|
434
279
|
|
435
|
-
|
436
|
-
|
437
|
-
print(is_valid_url("https://chat.openai.com/?model/=text-dav/inci-002-render-sha"))
|
438
|
-
```
|
439
|
-
|
440
|
-
Output:
|
441
|
-
```py
|
442
|
-
True
|
443
|
-
True
|
444
|
-
```
|
445
|
-
|
446
|
-
## password_generator
|
447
|
-
|
448
|
-
`password_generator(length=8, characters='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~')`
|
449
|
-
|
450
|
-
Membuat pssword secara acak
|
280
|
+
Return value:
|
281
|
+
- Berupa class Quantity dari modul pint
|
451
282
|
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
```py
|
458
|
-
et[>#k65
|
459
|
-
```
|
460
|
-
|
461
|
-
## random_bool
|
462
|
-
|
463
|
-
`random_bool()`
|
464
|
-
|
465
|
-
Menghasilkan nilai random True atau False.
|
466
|
-
Fungsi ini merupakan fungsi tercepat untuk mendapatkan random bool.
|
467
|
-
Fungsi ini sangat cepat, tetapi pemanggilan fungsi ini membutuhkan
|
468
|
-
overhead yg besar.
|
283
|
+
Format:
|
284
|
+
- f"{result:~P}" -> pretty
|
285
|
+
- f"{result:~H}" -> html
|
286
|
+
- result.to_base_units() -> SI
|
287
|
+
- result.to_compact() -> human readable
|
469
288
|
|
470
289
|
```python
|
471
|
-
|
290
|
+
fx = "3 meter * 10 cm * 3 km"
|
291
|
+
res = calculate(fx)
|
292
|
+
print(res)
|
293
|
+
print(res.to_base_units())
|
294
|
+
print(res.to_compact())
|
295
|
+
print(f"{res:~P}")
|
296
|
+
print(f"{res:~H}")
|
472
297
|
```
|
473
298
|
|
474
299
|
Output:
|
475
300
|
```py
|
476
|
-
|
301
|
+
90 centimeter * kilometer * meter
|
302
|
+
900.0 meter ** 3
|
303
|
+
900.0 meter ** 3
|
304
|
+
90 cm·km·m
|
305
|
+
90 cm km m
|
477
306
|
```
|
478
307
|
|
479
|
-
##
|
480
|
-
|
481
|
-
`restart(*argv)`
|
482
|
-
|
483
|
-
## set_timeout
|
308
|
+
## batch_calculate
|
484
309
|
|
485
|
-
`
|
310
|
+
`batch_calculate(pattern)`
|
486
311
|
|
487
|
-
|
488
|
-
|
489
|
-
program tidak akan berhenti sampai timeout selesai, kemudian fungsi dijalankan,
|
490
|
-
kemudian program dihentikan.
|
312
|
+
Analisa perhitungan massal.
|
313
|
+
Bisa digunakan untuk mencari alternatif terendah/tertinggi/dsb.
|
491
314
|
|
492
|
-
```python
|
493
|
-
set_timeout(3, lambda: print("Timeout 3"))
|
494
|
-
x = set_timeout(7, print, args=["Timeout 7"])
|
495
|
-
print(x)
|
496
|
-
print("menghentikan timeout 7")
|
497
|
-
x.cancel()
|
498
|
-
```
|
499
|
-
|
500
|
-
Output:
|
501
|
-
```py
|
502
|
-
<Timer(Thread-2, started 515494214896)>
|
503
|
-
menghentikan timeout 7
|
504
|
-
```
|
505
|
-
|
506
|
-
## sets_ordered
|
507
|
-
|
508
|
-
`sets_ordered(iterator)`
|
509
|
-
|
510
|
-
Hanya mengambil nilai unik dari suatu list
|
511
315
|
|
512
316
|
```python
|
513
|
-
|
514
|
-
print(
|
515
|
-
print(list(sets_ordered(array)))
|
317
|
+
print(batch_calculate("{1 10} m ** {1 3}"))
|
318
|
+
print(list(batch_calculate("{1 10} m ** {1 3}")))
|
516
319
|
```
|
517
320
|
|
518
321
|
Output:
|
519
322
|
```py
|
520
|
-
<generator object
|
521
|
-
[2, 3,
|
323
|
+
<generator object batch_calculate at 0x7384ac2e30>
|
324
|
+
[('1 m ** 1', <Quantity(1, 'meter')>), ('1 m ** 2', <Quantity(1, 'meter ** 2')>), ('2 m ** 1', <Quantity(2, 'meter')>), ('2 m ** 2', <Quantity(2, 'meter ** 2')>), ('3 m ** 1', <Quantity(3, 'meter')>), ('3 m ** 2', <Quantity(3, 'meter ** 2')>), ('4 m ** 1', <Quantity(4, 'meter')>), ('4 m ** 2', <Quantity(4, 'meter ** 2')>), ('5 m ** 1', <Quantity(5, 'meter')>), ('5 m ** 2', <Quantity(5, 'meter ** 2')>), ('6 m ** 1', <Quantity(6, 'meter')>), ('6 m ** 2', <Quantity(6, 'meter ** 2')>), ('7 m ** 1', <Quantity(7, 'meter')>), ('7 m ** 2', <Quantity(7, 'meter ** 2')>), ('8 m ** 1', <Quantity(8, 'meter')>), ('8 m ** 2', <Quantity(8, 'meter ** 2')>), ('9 m ** 1', <Quantity(9, 'meter')>), ('9 m ** 2', <Quantity(9, 'meter ** 2')>)]
|
522
325
|
```
|
523
326
|
|
524
|
-
##
|
327
|
+
## is_iterable
|
525
328
|
|
526
|
-
`
|
329
|
+
`is_iterable(var, str_is_iterable=False)`
|
527
330
|
|
528
|
-
|
529
|
-
Lebih cepat dibandingkan upper(), casefold(), re.fullmatch(), len().
|
530
|
-
perbandingan ini sangat cepat, tetapi pemanggilan fungsi ini membutuhkan
|
531
|
-
overhead yg besar.
|
331
|
+
Mengecek apakah suatu variabel bisa dilakukan forloop atau tidak
|
532
332
|
|
533
333
|
```python
|
534
|
-
|
334
|
+
s = 'ini string'
|
335
|
+
print(is_iterable(s))
|
336
|
+
|
337
|
+
l = [12,21,2,1]
|
338
|
+
print(is_iterable(l))
|
339
|
+
|
340
|
+
r = range(100)
|
341
|
+
print(is_iterable(r))
|
342
|
+
|
343
|
+
d = {'a':1, 'b':2}
|
344
|
+
print(is_iterable(d.values()))
|
535
345
|
```
|
536
346
|
|
537
347
|
Output:
|
538
348
|
```py
|
349
|
+
False
|
350
|
+
True
|
351
|
+
True
|
539
352
|
True
|
540
353
|
```
|
541
354
|
|
542
|
-
##
|
355
|
+
## print_to_last_line
|
543
356
|
|
544
|
-
`
|
357
|
+
`print_to_last_line(text: str, latest=1, clear=True)`
|
545
358
|
|
546
|
-
|
359
|
+
Melakukan print ke konsol tetapi akan menimpa baris terakhir.
|
360
|
+
Berguna untuk memberikan progress secara interaktif.
|
547
361
|
|
548
|
-
```
|
549
|
-
|
550
|
-
|
551
|
-
print(to_str(False))
|
552
|
-
print(to_str(True))
|
553
|
-
print(to_str(None))
|
362
|
+
```py
|
363
|
+
c = input("masukkan apa saja : ")
|
364
|
+
print_to_last_line(f"masukkan apa saja : {c} [ok]")
|
554
365
|
```
|
555
366
|
|
556
|
-
|
557
|
-
```py
|
558
|
-
5
|
367
|
+
## text_colorize
|
559
368
|
|
560
|
-
|
561
|
-
True
|
369
|
+
`text_colorize(text, color='\x1b[32m', bright='\x1b[1m', color_end='\x1b[0m')`
|
562
370
|
|
371
|
+
return text dengan warna untuk menunjukan text penting
|
372
|
+
|
373
|
+
```py
|
374
|
+
text_colorize("Print some text")
|
375
|
+
text_colorize("Print some text", color=colorama.Fore.RED)
|
563
376
|
```
|
564
377
|
|
565
378
|
## choices
|
@@ -586,258 +399,254 @@ c = choices(
|
|
586
399
|
)
|
587
400
|
```
|
588
401
|
|
589
|
-
##
|
402
|
+
## chunk_array
|
590
403
|
|
591
|
-
`
|
404
|
+
`chunk_array(array, size, start=0)`
|
592
405
|
|
593
|
-
|
406
|
+
Membagi array menjadi potongan-potongan dengan besaran yg diinginkan
|
594
407
|
|
595
|
-
```
|
596
|
-
|
597
|
-
|
408
|
+
```python
|
409
|
+
arr = [2, 3, 12, 3, 3, 42, 42, 1, 43, 2, 42, 41, 4, 24, 32, 42, 3, 12, 32, 42, 42]
|
410
|
+
print(chunk_array(arr, 5))
|
411
|
+
print(list(chunk_array(arr, 5)))
|
598
412
|
```
|
599
413
|
|
600
|
-
|
414
|
+
Output:
|
415
|
+
```py
|
416
|
+
<generator object chunk_array at 0x7384b48240>
|
417
|
+
[[2, 3, 12, 3, 3], [42, 42, 1, 43, 2], [42, 41, 4, 24, 32], [42, 3, 12, 32, 42], [42]]
|
418
|
+
```
|
601
419
|
|
602
|
-
|
420
|
+
## create_folder
|
603
421
|
|
604
|
-
|
422
|
+
`create_folder(folder_name)`
|
423
|
+
|
424
|
+
Membuat folder.
|
425
|
+
Membuat folder secara recursive dengan permission.
|
605
426
|
|
606
427
|
```py
|
607
|
-
|
608
|
-
|
609
|
-
|
428
|
+
create_folder("contoh_membuat_folder")
|
429
|
+
create_folder("contoh/membuat/folder/recursive")
|
430
|
+
create_folder("./contoh_membuat_folder/secara/recursive")
|
610
431
|
```
|
611
432
|
|
612
|
-
##
|
433
|
+
## datetime_from_string
|
613
434
|
|
614
|
-
`
|
435
|
+
`datetime_from_string(iso_string, timezone='UTC')`
|
615
436
|
|
616
|
-
|
617
|
-
fungsi yg sudah ada.
|
618
|
-
Melakukan print ke console untuk menginformasikan proses yg sedang
|
619
|
-
berjalan didalam program.
|
620
|
-
|
621
|
-
```py
|
622
|
-
@log
|
623
|
-
def some_function():
|
624
|
-
pass
|
625
|
-
|
626
|
-
@log()
|
627
|
-
def some_function_again():
|
628
|
-
pass
|
629
|
-
|
630
|
-
@log("Calling some function")
|
631
|
-
def some_function_more():
|
632
|
-
pass
|
437
|
+
Parse iso_string menjadi datetime object
|
633
438
|
|
634
|
-
|
635
|
-
|
636
|
-
|
439
|
+
```python
|
440
|
+
print(datetime_from_string("2022-12-12 15:40:13").isoformat())
|
441
|
+
print(datetime_from_string(
|
442
|
+
"2022-12-12 15:40:13",
|
443
|
+
timezone="Asia/Jakarta"
|
444
|
+
).isoformat())
|
637
445
|
```
|
638
446
|
|
639
|
-
|
447
|
+
Output:
|
448
|
+
```py
|
449
|
+
2022-12-12T15:40:13+00:00
|
450
|
+
2022-12-12T15:40:13+07:00
|
451
|
+
```
|
640
452
|
|
641
|
-
|
453
|
+
## datetime_now
|
642
454
|
|
643
|
-
|
455
|
+
`datetime_now(timezone=None)`
|
456
|
+
|
457
|
+
Memudahkan dalam membuat Datetime untuk suatu timezone tertentu
|
644
458
|
|
645
|
-
```
|
646
|
-
|
647
|
-
|
459
|
+
```python
|
460
|
+
print(datetime_now("Asia/Jakarta"))
|
461
|
+
print(datetime_now("GMT"))
|
462
|
+
print(datetime_now("Etc/GMT+7"))
|
648
463
|
```
|
649
464
|
|
650
|
-
|
465
|
+
Output:
|
466
|
+
```py
|
467
|
+
2024-04-29 21:55:16.569628+07:00
|
468
|
+
2024-04-29 14:55:16.570325+00:00
|
469
|
+
2024-04-29 07:55:16.571597-07:00
|
470
|
+
```
|
651
471
|
|
652
|
-
|
472
|
+
## dict_first
|
653
473
|
|
654
|
-
|
474
|
+
`dict_first(d: dict, remove=False)`
|
475
|
+
|
476
|
+
Mengambil nilai (key, value) pertama dari dictionary dalam bentuk tuple.
|
655
477
|
|
656
478
|
```python
|
657
|
-
|
658
|
-
|
659
|
-
|
479
|
+
d = {
|
480
|
+
"key2": "value2",
|
481
|
+
"key3": "value3",
|
482
|
+
"key1": "value1",
|
483
|
+
}
|
484
|
+
print(dict_first(d, remove=True))
|
485
|
+
print(dict_first(d))
|
660
486
|
```
|
661
487
|
|
662
488
|
Output:
|
663
489
|
```py
|
664
|
-
|
665
|
-
|
666
|
-
__dir__ : ['__module__', '__doc__', '__slots__', '__new__', '_make_child_relpath', '__enter__', '__exit__', 'cwd', 'home', 'samefile', 'iterdir', '_scandir', 'glob', 'rglob', 'absolute', 'resolve', 'stat', 'owner', 'group', 'open', 'read_bytes', 'read_text', 'write_bytes', 'write_text', 'readlink', 'touch', 'mkdir', 'chmod', 'lchmod', 'unlink', 'rmdir', 'lstat', 'rename', 'replace', 'symlink_to', 'hardlink_to', 'link_to', 'exists', 'is_dir', 'is_file', 'is_mount', 'is_symlink', 'is_block_device', 'is_char_device', 'is_fifo', 'is_socket', 'expanduser', '__reduce__', '_parse_args', '_from_parts', '_from_parsed_parts', '_format_parsed_parts', '_make_child', '__str__', '__fspath__', 'as_posix', '__bytes__', '__repr__', 'as_uri', '_cparts', '__eq__', '__hash__', '__lt__', '__le__', '__gt__', '__ge__', 'drive', 'root', 'anchor', 'name', 'suffix', 'suffixes', 'stem', 'with_name', 'with_stem', 'with_suffix', 'relative_to', 'is_relative_to', 'parts', 'joinpath', '__truediv__', '__rtruediv__', 'parent', 'parents', 'is_absolute', 'is_reserved', 'match', '_cached_cparts', '_drv', '_hash', '_parts', '_pparts', '_root', '_str', '__getattribute__', '__setattr__', '__delattr__', '__ne__', '__init__', '__reduce_ex__', '__getstate__', '__subclasshook__', '__init_subclass__', '__format__', '__sizeof__', '__dir__', '__class__', '_flavour']
|
667
|
-
__doc__ : Path subclass for non-Windows systems.
|
668
|
-
|
669
|
-
On a POSIX system, instantiating a Path should return this object.
|
670
|
-
|
671
|
-
__enter__ : https:/www.google.com
|
672
|
-
__fspath__ : https:/www.google.com
|
673
|
-
__getstate__ : (None, {'_drv': '', '_root': '', '_parts': ['https:', 'www.google.com'], '_str': 'https:/www.google.com'})
|
674
|
-
__hash__ : 2310926016887611737
|
675
|
-
__init__ : None
|
676
|
-
__init_subclass__ : None
|
677
|
-
__module__ : pathlib
|
678
|
-
__reduce__ : (<class 'pathlib.PosixPath'>, ('https:', 'www.google.com'))
|
679
|
-
__repr__ : PosixPath('https:/www.google.com')
|
680
|
-
__sizeof__ : 72
|
681
|
-
__slots__ : ()
|
682
|
-
__str__ : https:/www.google.com
|
683
|
-
__subclasshook__ : NotImplemented
|
684
|
-
_cached_cparts : ['https:', 'www.google.com']
|
685
|
-
_cparts : ['https:', 'www.google.com']
|
686
|
-
_drv :
|
687
|
-
_flavour : <pathlib._PosixFlavour object at 0x781687cad0>
|
688
|
-
_hash : 2310926016887611737
|
689
|
-
_parts : ['https:', 'www.google.com']
|
690
|
-
_root :
|
691
|
-
_str : https:/www.google.com
|
692
|
-
absolute : /data/data/com.termux/files/home/pypipr/https:/www.google.com
|
693
|
-
anchor :
|
694
|
-
as_posix : https:/www.google.com
|
695
|
-
cwd : /data/data/com.termux/files/home/pypipr
|
696
|
-
drive :
|
697
|
-
exists : False
|
698
|
-
expanduser : https:/www.google.com
|
699
|
-
home : /data/data/com.termux/files/home
|
700
|
-
is_absolute : False
|
701
|
-
is_block_device : False
|
702
|
-
is_char_device : False
|
703
|
-
is_dir : False
|
704
|
-
is_fifo : False
|
705
|
-
is_file : False
|
706
|
-
is_mount : False
|
707
|
-
is_reserved : False
|
708
|
-
is_socket : False
|
709
|
-
is_symlink : False
|
710
|
-
iterdir : <generator object Path.iterdir at 0x780742d380>
|
711
|
-
joinpath : https:/www.google.com
|
712
|
-
name : www.google.com
|
713
|
-
parent : https:
|
714
|
-
parents : <PosixPath.parents>
|
715
|
-
parts : ('https:', 'www.google.com')
|
716
|
-
resolve : /data/data/com.termux/files/home/pypipr/https:/www.google.com
|
717
|
-
root :
|
718
|
-
stem : www.google
|
719
|
-
suffix : .com
|
720
|
-
suffixes : ['.google', '.com']
|
490
|
+
('key2', 'value2')
|
491
|
+
('key3', 'value3')
|
721
492
|
```
|
722
493
|
|
723
|
-
##
|
494
|
+
## dirname
|
724
495
|
|
725
|
-
`
|
496
|
+
`dirname(path)`
|
726
497
|
|
727
|
-
|
728
|
-
|
498
|
+
Mengembalikan nama folder dari path.
|
499
|
+
Tanpa trailing slash di akhir.
|
729
500
|
|
730
501
|
```python
|
731
|
-
|
502
|
+
print(dirname("/ini/nama/folder/ke/file.py"))
|
732
503
|
```
|
733
504
|
|
734
505
|
Output:
|
735
506
|
```py
|
736
|
-
|
507
|
+
/ini/nama/folder/ke
|
737
508
|
```
|
738
509
|
|
739
|
-
##
|
510
|
+
## is_empty
|
740
511
|
|
741
|
-
`
|
512
|
+
`is_empty(variable, empty=[None, False, 0, 0, '0', '', '-0', '\n', '\t', set(), {}, [], ()])`
|
742
513
|
|
743
|
-
|
744
|
-
Berguna untuk memberikan progress secara interaktif.
|
514
|
+
Mengecek apakah variable setara dengan nilai kosong pada empty.
|
745
515
|
|
746
|
-
|
747
|
-
|
748
|
-
|
516
|
+
Pengecekan nilai yang setara menggunakan simbol '==', sedangkan untuk
|
517
|
+
pengecekan lokasi memory yang sama menggunakan keyword 'is'
|
518
|
+
|
519
|
+
```python
|
520
|
+
print(is_empty("teks"))
|
521
|
+
print(is_empty(True))
|
522
|
+
print(is_empty(False))
|
523
|
+
print(is_empty(None))
|
524
|
+
print(is_empty(0))
|
525
|
+
print(is_empty([]))
|
749
526
|
```
|
750
527
|
|
751
|
-
|
528
|
+
Output:
|
529
|
+
```py
|
530
|
+
False
|
531
|
+
False
|
532
|
+
True
|
533
|
+
True
|
534
|
+
True
|
535
|
+
True
|
536
|
+
```
|
752
537
|
|
753
|
-
|
538
|
+
## exit_if_empty
|
754
539
|
|
755
|
-
|
540
|
+
`exit_if_empty(*args)`
|
541
|
+
|
542
|
+
Keluar dari program apabila seluruh variabel
|
543
|
+
setara dengan empty
|
756
544
|
|
757
545
|
```py
|
758
|
-
|
759
|
-
|
546
|
+
var1 = None
|
547
|
+
var2 = '0'
|
548
|
+
exit_if_empty(var1, var2)
|
760
549
|
```
|
761
550
|
|
762
|
-
##
|
551
|
+
## to_str
|
763
552
|
|
764
|
-
`
|
553
|
+
`to_str(value)`
|
765
554
|
|
766
|
-
|
767
|
-
Bisa digunakan untuk mencari alternatif terendah/tertinggi/dsb.
|
555
|
+
Mengubah value menjadi string literal
|
768
556
|
|
557
|
+
```python
|
558
|
+
print(to_str(5))
|
559
|
+
print(to_str([]))
|
560
|
+
print(to_str(False))
|
561
|
+
print(to_str(True))
|
562
|
+
print(to_str(None))
|
563
|
+
```
|
564
|
+
|
565
|
+
Output:
|
566
|
+
```py
|
567
|
+
5
|
568
|
+
|
569
|
+
False
|
570
|
+
True
|
571
|
+
|
572
|
+
```
|
573
|
+
|
574
|
+
## filter_empty
|
575
|
+
|
576
|
+
`filter_empty(iterable, zero_is_empty=True, str_strip=True)`
|
577
|
+
|
578
|
+
Mengembalikan iterabel yang hanya memiliki nilai
|
769
579
|
|
770
580
|
```python
|
771
|
-
|
772
|
-
print(
|
581
|
+
var = [1, None, False, 0, "0", True, {}, ['eee']]
|
582
|
+
print(filter_empty(var))
|
773
583
|
```
|
774
584
|
|
775
|
-
|
585
|
+
Output:
|
586
|
+
```py
|
587
|
+
<generator object filter_empty at 0x7384ac13f0>
|
588
|
+
```
|
776
589
|
|
777
|
-
|
590
|
+
## get_by_index
|
778
591
|
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
([separator][step]) -> bersifat optional
|
784
|
-
[separator] -> selain huruf dan angka
|
785
|
-
[step] -> berupa angka positif
|
786
|
-
```
|
592
|
+
`get_by_index(obj, index, on_error=None)`
|
593
|
+
|
594
|
+
Mendapatkan value dari object berdasarkan indexnya.
|
595
|
+
Jika error out of range maka akan mengembalikan on_error.
|
787
596
|
|
788
597
|
```python
|
789
|
-
|
790
|
-
print(
|
791
|
-
print(list(batchmaker(s)))
|
598
|
+
l = [1, 3, 5]
|
599
|
+
print(get_by_index(l, 7))
|
792
600
|
```
|
793
601
|
|
794
|
-
|
602
|
+
Output:
|
603
|
+
```py
|
604
|
+
None
|
605
|
+
```
|
795
606
|
|
796
|
-
|
607
|
+
## get_class_method
|
797
608
|
|
798
|
-
|
799
|
-
|
609
|
+
`get_class_method(cls)`
|
610
|
+
|
611
|
+
Mengembalikan berupa tuple yg berisi list dari method dalam class
|
800
612
|
|
801
|
-
|
802
|
-
|
613
|
+
```python
|
614
|
+
class ExampleGetClassMethod:
|
615
|
+
def a():
|
616
|
+
return [x for x in range(10)]
|
803
617
|
|
804
|
-
|
805
|
-
|
806
|
-
- f"{result:~H}" -> html
|
807
|
-
- result.to_base_units() -> SI
|
808
|
-
- result.to_compact() -> human readable
|
618
|
+
def b():
|
619
|
+
return [x for x in range(10)]
|
809
620
|
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
print(
|
817
|
-
print(
|
621
|
+
def c():
|
622
|
+
return [x for x in range(10)]
|
623
|
+
|
624
|
+
def d():
|
625
|
+
return [x for x in range(10)]
|
626
|
+
|
627
|
+
print(get_class_method(ExampleGetClassMethod))
|
628
|
+
print(list(get_class_method(ExampleGetClassMethod)))
|
818
629
|
```
|
819
630
|
|
820
631
|
Output:
|
821
632
|
```py
|
822
|
-
|
823
|
-
|
824
|
-
900.0 meter ** 3
|
825
|
-
90 cm·km·m
|
826
|
-
90 cm km m
|
633
|
+
<generator object get_class_method at 0x7384ac3100>
|
634
|
+
[<function ExampleGetClassMethod.a at 0x7384b544a0>, <function ExampleGetClassMethod.b at 0x7384b54720>, <function ExampleGetClassMethod.c at 0x7384b547c0>, <function ExampleGetClassMethod.d at 0x7384b54860>]
|
827
635
|
```
|
828
636
|
|
829
|
-
##
|
637
|
+
## get_filesize
|
830
638
|
|
831
|
-
`
|
639
|
+
`get_filesize(filename)`
|
832
640
|
|
833
|
-
|
834
|
-
Dengan tujuan untuk melihat perubahan secara langsung.
|
835
|
-
Pastikan kode aman untuk dijalankan.
|
836
|
-
Jalankan kode ini di terminal console.
|
641
|
+
Mengambil informasi file size dalam bytes
|
837
642
|
|
838
|
-
```
|
839
|
-
|
840
|
-
|
643
|
+
```python
|
644
|
+
print(get_filesize(__file__))
|
645
|
+
```
|
646
|
+
|
647
|
+
Output:
|
648
|
+
```py
|
649
|
+
465
|
841
650
|
```
|
842
651
|
|
843
652
|
## github_pull
|
@@ -871,37 +680,6 @@ menginput nya setiap saat.
|
|
871
680
|
github_user('my@emil.com', 'MyName')
|
872
681
|
```
|
873
682
|
|
874
|
-
## pip_freeze_without_version
|
875
|
-
|
876
|
-
`pip_freeze_without_version(filename=None)`
|
877
|
-
|
878
|
-
Memberikan list dari dependencies yang terinstall tanpa version.
|
879
|
-
Bertujuan untuk menggunakan Batteries Included Python.
|
880
|
-
|
881
|
-
```py
|
882
|
-
print(pip_freeze_without_version())
|
883
|
-
```
|
884
|
-
|
885
|
-
## poetry_publish
|
886
|
-
|
887
|
-
`poetry_publish(token=None)`
|
888
|
-
|
889
|
-
Publish project to pypi,org
|
890
|
-
|
891
|
-
```py
|
892
|
-
poetry_publish()
|
893
|
-
```
|
894
|
-
|
895
|
-
## poetry_update_version
|
896
|
-
|
897
|
-
`poetry_update_version(mayor=False, minor=False, patch=False)`
|
898
|
-
|
899
|
-
Update versi pada pyproject.toml menggunakan poetry
|
900
|
-
|
901
|
-
```py
|
902
|
-
poetry_update_version()
|
903
|
-
```
|
904
|
-
|
905
683
|
## iargv
|
906
684
|
|
907
685
|
`iargv(key: int, cast=None, on_error=None)`
|
@@ -919,92 +697,6 @@ Output:
|
|
919
697
|
```py
|
920
698
|
```
|
921
699
|
|
922
|
-
## idumps
|
923
|
-
|
924
|
-
`idumps(data, syntax='yaml', indent=4)`
|
925
|
-
|
926
|
-
Mengubah variabel data menjadi string untuk yang dapat dibaca untuk disimpan.
|
927
|
-
String yang dihasilkan berbentuk syntax YAML/JSON/HTML.
|
928
|
-
|
929
|
-
```python
|
930
|
-
data = {
|
931
|
-
'a': 123,
|
932
|
-
't': ['disini', 'senang', 'disana', 'senang'],
|
933
|
-
'l': (12, 23, [12, 42]),
|
934
|
-
}
|
935
|
-
print(idumps(data))
|
936
|
-
print(idumps(data, syntax='html'))
|
937
|
-
```
|
938
|
-
|
939
|
-
Output:
|
940
|
-
```py
|
941
|
-
a: 123
|
942
|
-
l: !!python/tuple
|
943
|
-
- 12
|
944
|
-
- 23
|
945
|
-
- - 12
|
946
|
-
- 42
|
947
|
-
t:
|
948
|
-
- disini
|
949
|
-
- senang
|
950
|
-
- disana
|
951
|
-
- senang
|
952
|
-
|
953
|
-
<table>
|
954
|
-
<tbody>
|
955
|
-
<tr>
|
956
|
-
<th>a</th>
|
957
|
-
<td>
|
958
|
-
<span>123</span>
|
959
|
-
</td>
|
960
|
-
</tr>
|
961
|
-
<tr>
|
962
|
-
<th>t</th>
|
963
|
-
<td>
|
964
|
-
<ul>
|
965
|
-
<li>
|
966
|
-
<span>disini</span>
|
967
|
-
</li>
|
968
|
-
<li>
|
969
|
-
<span>senang</span>
|
970
|
-
</li>
|
971
|
-
<li>
|
972
|
-
<span>disana</span>
|
973
|
-
</li>
|
974
|
-
<li>
|
975
|
-
<span>senang</span>
|
976
|
-
</li>
|
977
|
-
</ul>
|
978
|
-
</td>
|
979
|
-
</tr>
|
980
|
-
<tr>
|
981
|
-
<th>l</th>
|
982
|
-
<td>
|
983
|
-
<ul>
|
984
|
-
<li>
|
985
|
-
<span>12</span>
|
986
|
-
</li>
|
987
|
-
<li>
|
988
|
-
<span>23</span>
|
989
|
-
</li>
|
990
|
-
<li>
|
991
|
-
<ul>
|
992
|
-
<li>
|
993
|
-
<span>12</span>
|
994
|
-
</li>
|
995
|
-
<li>
|
996
|
-
<span>42</span>
|
997
|
-
</li>
|
998
|
-
</ul>
|
999
|
-
</li>
|
1000
|
-
</ul>
|
1001
|
-
</td>
|
1002
|
-
</tr>
|
1003
|
-
</tbody>
|
1004
|
-
</table>
|
1005
|
-
|
1006
|
-
```
|
1007
|
-
|
1008
700
|
## idumps_html
|
1009
701
|
|
1010
702
|
`idumps_html(data, indent=None)`
|
@@ -1088,6 +780,92 @@ Output:
|
|
1088
780
|
|
1089
781
|
```
|
1090
782
|
|
783
|
+
## idumps
|
784
|
+
|
785
|
+
`idumps(data, syntax='yaml', indent=4)`
|
786
|
+
|
787
|
+
Mengubah variabel data menjadi string untuk yang dapat dibaca untuk disimpan.
|
788
|
+
String yang dihasilkan berbentuk syntax YAML/JSON/HTML.
|
789
|
+
|
790
|
+
```python
|
791
|
+
data = {
|
792
|
+
'a': 123,
|
793
|
+
't': ['disini', 'senang', 'disana', 'senang'],
|
794
|
+
'l': (12, 23, [12, 42]),
|
795
|
+
}
|
796
|
+
print(idumps(data))
|
797
|
+
print(idumps(data, syntax='html'))
|
798
|
+
```
|
799
|
+
|
800
|
+
Output:
|
801
|
+
```py
|
802
|
+
a: 123
|
803
|
+
l: !!python/tuple
|
804
|
+
- 12
|
805
|
+
- 23
|
806
|
+
- - 12
|
807
|
+
- 42
|
808
|
+
t:
|
809
|
+
- disini
|
810
|
+
- senang
|
811
|
+
- disana
|
812
|
+
- senang
|
813
|
+
|
814
|
+
<table>
|
815
|
+
<tbody>
|
816
|
+
<tr>
|
817
|
+
<th>a</th>
|
818
|
+
<td>
|
819
|
+
<span>123</span>
|
820
|
+
</td>
|
821
|
+
</tr>
|
822
|
+
<tr>
|
823
|
+
<th>t</th>
|
824
|
+
<td>
|
825
|
+
<ul>
|
826
|
+
<li>
|
827
|
+
<span>disini</span>
|
828
|
+
</li>
|
829
|
+
<li>
|
830
|
+
<span>senang</span>
|
831
|
+
</li>
|
832
|
+
<li>
|
833
|
+
<span>disana</span>
|
834
|
+
</li>
|
835
|
+
<li>
|
836
|
+
<span>senang</span>
|
837
|
+
</li>
|
838
|
+
</ul>
|
839
|
+
</td>
|
840
|
+
</tr>
|
841
|
+
<tr>
|
842
|
+
<th>l</th>
|
843
|
+
<td>
|
844
|
+
<ul>
|
845
|
+
<li>
|
846
|
+
<span>12</span>
|
847
|
+
</li>
|
848
|
+
<li>
|
849
|
+
<span>23</span>
|
850
|
+
</li>
|
851
|
+
<li>
|
852
|
+
<ul>
|
853
|
+
<li>
|
854
|
+
<span>12</span>
|
855
|
+
</li>
|
856
|
+
<li>
|
857
|
+
<span>42</span>
|
858
|
+
</li>
|
859
|
+
</ul>
|
860
|
+
</li>
|
861
|
+
</ul>
|
862
|
+
</td>
|
863
|
+
</tr>
|
864
|
+
</tbody>
|
865
|
+
</table>
|
866
|
+
|
867
|
+
```
|
868
|
+
|
1091
869
|
## ienv
|
1092
870
|
|
1093
871
|
`ienv(on_windows=None, on_linux=None)`
|
@@ -1151,7 +929,7 @@ print(ijoin(10, ' '))
|
|
1151
929
|
|
1152
930
|
Output:
|
1153
931
|
```py
|
1154
|
-
weq,
|
932
|
+
qweqw, weq, dfs, asd
|
1155
933
|
,ini,path,seperti,url,
|
1156
934
|
ini,path,seperti,url
|
1157
935
|
<li>satu</li>
|
@@ -1169,28 +947,6 @@ ini,path,seperti,url
|
|
1169
947
|
10
|
1170
948
|
```
|
1171
949
|
|
1172
|
-
## iloads
|
1173
|
-
|
1174
|
-
`iloads(data, syntax='yaml')`
|
1175
|
-
|
1176
|
-
Mengubah string data hasil dari idumps menjadi variabel.
|
1177
|
-
String data adalah berupa syntax YAML.
|
1178
|
-
|
1179
|
-
```python
|
1180
|
-
data = {
|
1181
|
-
'a': 123,
|
1182
|
-
't': ['disini', 'senang', 'disana', 'senang'],
|
1183
|
-
'l': (12, 23, [12, 42]),
|
1184
|
-
}
|
1185
|
-
s = idumps(data)
|
1186
|
-
print(iloads(s))
|
1187
|
-
```
|
1188
|
-
|
1189
|
-
Output:
|
1190
|
-
```py
|
1191
|
-
{'a': 123, 'l': (12, 23, [12, 42]), 't': ['disini', 'senang', 'disana', 'senang']}
|
1192
|
-
```
|
1193
|
-
|
1194
950
|
## iloads_html
|
1195
951
|
|
1196
952
|
`iloads_html(html)`
|
@@ -1217,9 +973,9 @@ Output:
|
|
1217
973
|
```py
|
1218
974
|
(['Home', 'Emas 1 Gram', 'History', 'Trend', 'Perak 1 Gram', 'Pluang'],
|
1219
975
|
[['Harga Emas Hari Ini - Senin, 29 April 2024'],
|
1220
|
-
['Spot Emas USD↓2.
|
976
|
+
['Spot Emas USD↓2.336,06 (-1,88) / oz',
|
1221
977
|
'Kurs IDR↑16.222,00 (+14,00) / USD',
|
1222
|
-
'Emas IDR
|
978
|
+
'Emas IDR↑1.218.371 (+72) / gr'],
|
1223
979
|
['LM Antam (Jual)↓1.325.000 (-1.000) / gr',
|
1224
980
|
'LM Antam (Beli)↓1.221.000 (-1.000) / gr']],
|
1225
981
|
[['Harga Emas Hari Ini'],
|
@@ -1290,10 +1046,10 @@ Output:
|
|
1290
1046
|
'Update harga LM Pegadaian :31 Agustus 2023']],
|
1291
1047
|
[['Spot Harga Emas Hari Ini (Market Open)'],
|
1292
1048
|
['Satuan', 'USD', 'Kurs\xa0Dollar', 'IDR'],
|
1293
|
-
['Ounce\xa0(oz)', '2.
|
1294
|
-
['Gram\xa0(gr)', '75,
|
1295
|
-
['Kilogram\xa0(kg)', '75.
|
1296
|
-
['Update harga emas :29 April 2024, pukul
|
1049
|
+
['Ounce\xa0(oz)', '2.336,06 (-1,88)', '16.222,00 (+14,00)', '37.895.565'],
|
1050
|
+
['Gram\xa0(gr)', '75,11', '16.222,00', '1.218.371 (+72)'],
|
1051
|
+
['Kilogram\xa0(kg)', '75.106,07', '16.222,00', '1.218.370.718'],
|
1052
|
+
['Update harga emas :29 April 2024, pukul 21:54Update kurs :29 April 2024, '
|
1297
1053
|
'pukul 13:10']],
|
1298
1054
|
[['Gram', 'UBS Gold 99.99%'],
|
1299
1055
|
['Jual', 'Beli'],
|
@@ -1339,36 +1095,36 @@ Output:
|
|
1339
1095
|
['Unit', 'USD', 'IDR'],
|
1340
1096
|
['Angka', '+/-', 'Angka', '+/-'],
|
1341
1097
|
['Hari Ini', 'Kurs', '', '', '16.208', '+14+0,09%'],
|
1342
|
-
['oz', '2.337,94', '-
|
1343
|
-
['gr', '75,17', '-0,
|
1098
|
+
['oz', '2.337,94', '-1,88-0,08%', '37.893.332', '+2.234+0,01%'],
|
1099
|
+
['gr', '75,17', '-0,06-0,08%', '1.218.299', '+72+0,01%'],
|
1344
1100
|
['30 Hari', 'Kurs', '', '', '15.853', '+369+2,33%'],
|
1345
|
-
['oz', '2.232,75', '+
|
1346
|
-
['gr', '71,78', '+3,
|
1101
|
+
['oz', '2.232,75', '+103,31+4,63%', '35.395.786', '+2.499.780+7,06%'],
|
1102
|
+
['gr', '71,78', '+3,32+4,63%', '1.138.001', '+80.370+7,06%'],
|
1347
1103
|
['2 Bulan', 'Kurs', '', '', '15.673', '+549+3,50%'],
|
1348
|
-
['oz', '2.045,83', '+
|
1349
|
-
['gr', '65,77', '+9,
|
1104
|
+
['oz', '2.045,83', '+290,23+14,19%', '32.064.294', '+5.831.272+18,19%'],
|
1105
|
+
['gr', '65,77', '+9,33+14,19', '1.030.891', '+187.480+18,19%'],
|
1350
1106
|
['6 Bulan', 'Kurs', '', '', '15.897', '+325+2,04%'],
|
1351
|
-
['oz', '1.977,80', '+
|
1352
|
-
['gr', '63,59', '+11,
|
1107
|
+
['oz', '1.977,80', '+358,26+18,11%', '31.441.087', '+6.454.479+20,53%'],
|
1108
|
+
['gr', '63,59', '+11,52+18,11%', '1.010.854', '+207.516+20,53%'],
|
1353
1109
|
['1 Tahun', 'Kurs', '', '', '15.731', '+491+3,12%'],
|
1354
|
-
['oz', '1.823,86', '+
|
1355
|
-
['gr', '58,64', '+16,
|
1110
|
+
['oz', '1.823,86', '+512,20+28,08%', '28.691.142', '+9.204.424+32,08%'],
|
1111
|
+
['gr', '58,64', '+16,47+28,08%', '922.442', '+295.929+32,08%'],
|
1356
1112
|
['2 Tahun', 'Kurs', '', '', '14.418', '+1.804+12,51%'],
|
1357
|
-
['oz', '1.896,95', '+
|
1358
|
-
['gr', '60,99', '+14,
|
1113
|
+
['oz', '1.896,95', '+439,11+23,15%', '27.350.225', '+10.545.340+38,56%'],
|
1114
|
+
['gr', '60,99', '+14,12+23,15%', '879.330', '+339.041+38,56%'],
|
1359
1115
|
['3 Tahun', 'Kurs', '', '', '14.468', '+1.754+12,12%'],
|
1360
|
-
['oz', '1.767,08', '+
|
1361
|
-
['gr', '56,81', '+18,
|
1116
|
+
['oz', '1.767,08', '+568,98+32,20%', '25.566.113', '+12.329.452+48,23%'],
|
1117
|
+
['gr', '56,81', '+18,29+32,20%', '821.970', '+396.401+48,23%'],
|
1362
1118
|
['5 Tahun', 'Kurs', '', '', '14.215', '+2.007+14,12%'],
|
1363
|
-
['oz', '1.280,61', '+1.
|
1364
|
-
['gr', '41,17', '+33,
|
1119
|
+
['oz', '1.280,61', '+1.055,45+82,42%', '18.203.871', '+19.691.694+108,17%'],
|
1120
|
+
['gr', '41,17', '+33,93+82,42%', '585.268', '+633.103+108,17%']])
|
1365
1121
|
(['Home', 'Emas 1 Gram', 'History', 'Trend', 'Perak 1 Gram', 'Pluang'],
|
1366
1122
|
[[''],
|
1367
1123
|
['Emas 24 KaratHarga Emas 1 Gram', ''],
|
1368
|
-
['USD', '75,
|
1369
|
-
['KURS', '16.
|
1370
|
-
['IDR', '1.
|
1371
|
-
['Senin, 29 April 2024
|
1124
|
+
['USD', '75,11↓', '-0,06-0,08%'],
|
1125
|
+
['KURS', '16.230,40↓', '-10,90-0,07%'],
|
1126
|
+
['IDR', '1.219.048,57↓', '-1.753,37-0,14%'],
|
1127
|
+
['Senin, 29 April 2024 21:55']],
|
1372
1128
|
[[''],
|
1373
1129
|
['Emas 1 Gram (IDR)Emas 1 Gram (USD)Kurs USD-IDR',
|
1374
1130
|
'Hari Ini',
|
@@ -1379,19 +1135,71 @@ Output:
|
|
1379
1135
|
'']],
|
1380
1136
|
[['Pergerakkan Harga Emas 1 Gram'],
|
1381
1137
|
['', 'Penutupan Kemarin', 'Pergerakkan Hari Ini', 'Rata-rata'],
|
1382
|
-
['USD', '75,17', '75,
|
1383
|
-
['KURS', '16.241,30', '16.
|
1384
|
-
['IDR', '1.220.801,94', '1.
|
1138
|
+
['USD', '75,17', '75,11 - 75,17', '75,14'],
|
1139
|
+
['KURS', '16.241,30', '16.230,40 - 16.241,30', '16.235,85'],
|
1140
|
+
['IDR', '1.220.801,94', '1.219.048,57 - 1.220.801,94', '1.219.925,26'],
|
1385
1141
|
[''],
|
1386
1142
|
['', 'Awal Tahun', 'Pergerakkan YTD', '+/- YTD'],
|
1387
|
-
['USD', '66,32', '64,07 - 77,14', '+8,
|
1388
|
-
['KURS', '15.390,10', '15.390,00 - 16.307,80', '+
|
1389
|
-
['IDR', '1.020.729,53', '997.660,12 - 1.256.829,06', '+
|
1143
|
+
['USD', '66,32', '64,07 - 77,14', '+8,79 (13,25%)'],
|
1144
|
+
['KURS', '15.390,10', '15.390,00 - 16.307,80', '+840,30 (5,46%)'],
|
1145
|
+
['IDR', '1.020.729,53', '997.660,12 - 1.256.829,06', '+198.319,04 (19,43%)'],
|
1390
1146
|
[''],
|
1391
1147
|
['', 'Tahun Lalu / 52 Minggu', 'Pergerakkan 52 Minggu', '+/- 52 Minggu'],
|
1392
|
-
['USD', '64,04', '58,43 - 77,14', '+11,
|
1393
|
-
['KURS', '14.671,35', '14.669,40 - 16.307,80', '+1.
|
1394
|
-
['IDR', '939.568,98', '912.925,68 - 1.256.829,06', '+
|
1148
|
+
['USD', '64,04', '58,43 - 77,14', '+11,07 (17,29%)'],
|
1149
|
+
['KURS', '14.671,35', '14.669,40 - 16.307,80', '+1.559,05 (10,63%)'],
|
1150
|
+
['IDR', '939.568,98', '912.925,68 - 1.256.829,06', '+279.479,59 (29,75%)']])
|
1151
|
+
```
|
1152
|
+
|
1153
|
+
## iloads
|
1154
|
+
|
1155
|
+
`iloads(data, syntax='yaml')`
|
1156
|
+
|
1157
|
+
Mengubah string data hasil dari idumps menjadi variabel.
|
1158
|
+
String data adalah berupa syntax YAML.
|
1159
|
+
|
1160
|
+
```python
|
1161
|
+
data = {
|
1162
|
+
'a': 123,
|
1163
|
+
't': ['disini', 'senang', 'disana', 'senang'],
|
1164
|
+
'l': (12, 23, [12, 42]),
|
1165
|
+
}
|
1166
|
+
s = idumps(data)
|
1167
|
+
print(iloads(s))
|
1168
|
+
```
|
1169
|
+
|
1170
|
+
Output:
|
1171
|
+
```py
|
1172
|
+
{'a': 123, 'l': (12, 23, [12, 42]), 't': ['disini', 'senang', 'disana', 'senang']}
|
1173
|
+
```
|
1174
|
+
|
1175
|
+
## input_char
|
1176
|
+
|
1177
|
+
`input_char(prompt=None, prompt_ending='', newline_after_input=True, echo_char=True, default=None)`
|
1178
|
+
|
1179
|
+
Meminta masukan satu huruf tanpa menekan Enter.
|
1180
|
+
|
1181
|
+
```py
|
1182
|
+
input_char("Input char : ")
|
1183
|
+
input_char("Input char : ", default='Y')
|
1184
|
+
input_char("Input Char without print : ", echo_char=False)
|
1185
|
+
```
|
1186
|
+
|
1187
|
+
## is_valid_url
|
1188
|
+
|
1189
|
+
`is_valid_url(path)`
|
1190
|
+
|
1191
|
+
Mengecek apakah path merupakan URL yang valid atau tidak.
|
1192
|
+
Cara ini merupakan cara yang paling efektif.
|
1193
|
+
|
1194
|
+
```python
|
1195
|
+
print(is_valid_url("https://chat.openai.com/?model=text-davinci-002-render-sha"))
|
1196
|
+
print(is_valid_url("https://chat.openai.com/?model/=text-dav/inci-002-render-sha"))
|
1197
|
+
```
|
1198
|
+
|
1199
|
+
Output:
|
1200
|
+
```py
|
1201
|
+
True
|
1202
|
+
True
|
1395
1203
|
```
|
1396
1204
|
|
1397
1205
|
## iopen
|
@@ -1431,225 +1239,448 @@ print(iopen("https://www.google.com/", dict(coba="dulu"), xpath="//a"))
|
|
1431
1239
|
|
1432
1240
|
Output:
|
1433
1241
|
```py
|
1434
|
-
8
|
1435
|
-
['mana', 'aja']
|
1436
|
-
[<Element a at
|
1437
|
-
False
|
1242
|
+
8
|
1243
|
+
['mana', 'aja']
|
1244
|
+
[<Element a at 0x7384b59090>, <Element a at 0x7384b94910>, <Element a at 0x7384b949b0>, <Element a at 0x7384b94a00>, <Element a at 0x7384b94a50>, <Element a at 0x7384b94aa0>, <Element a at 0x7384b94af0>, <Element a at 0x7384b94b40>, <Element a at 0x7384b94b90>, <Element a at 0x7384b94be0>, <Element a at 0x7384b94c30>, <Element a at 0x7384b94c80>, <Element a at 0x7384b94cd0>, <Element a at 0x7384b94d20>, <Element a at 0x7384b94d70>, <Element a at 0x7384b94dc0>, <Element a at 0x7384b94e10>, <Element a at 0x7384b94e60>, <Element a at 0x7384b94eb0>, <Element a at 0x7384b94f00>]
|
1245
|
+
False
|
1246
|
+
```
|
1247
|
+
|
1248
|
+
## iprint
|
1249
|
+
|
1250
|
+
`iprint(*args, color=None, sort_dicts=False, **kwargs)`
|
1251
|
+
|
1252
|
+
Improve print function dengan menambahkan color dan pretty print
|
1253
|
+
Color menggunakan colorama Fore + Back + Style
|
1254
|
+
|
1255
|
+
```python
|
1256
|
+
import colorama
|
1257
|
+
iprint(
|
1258
|
+
'yang ini',
|
1259
|
+
{'12':12,'sdsd':{'12':21,'as':[88]}},
|
1260
|
+
color=colorama.Fore.BLUE + colorama.Style.BRIGHT
|
1261
|
+
)
|
1262
|
+
```
|
1263
|
+
|
1264
|
+
Output:
|
1265
|
+
```py
|
1266
|
+
[34m[1myang ini[0m [34m[1m{'12': 12, 'sdsd': {'12': 21, 'as': [88]}}[0m
|
1267
|
+
```
|
1268
|
+
|
1269
|
+
## ireplace
|
1270
|
+
|
1271
|
+
`ireplace(string: str, replacements: dict, flags=re.IGNORECASE|re.MULTILINE|re.DOTALL)`
|
1272
|
+
|
1273
|
+
STRing TRanslate mengubah string menggunakan kamus dari dict.
|
1274
|
+
Replacement dapat berupa text biasa ataupun regex pattern.
|
1275
|
+
Apabila replacement berupa regex, gunakan raw string `r"..."`
|
1276
|
+
Untuk regex capturing gunakan `(...)`, dan untuk mengaksesnya
|
1277
|
+
gunakan `\1`, `\2`, .., dst.
|
1278
|
+
|
1279
|
+
```python
|
1280
|
+
text = 'aku ini mau ke sini'
|
1281
|
+
replacements = {
|
1282
|
+
"sini": "situ",
|
1283
|
+
r"(ini)": r"itu dan \1",
|
1284
|
+
}
|
1285
|
+
print(ireplace(text, replacements))
|
1286
|
+
```
|
1287
|
+
|
1288
|
+
Output:
|
1289
|
+
```py
|
1290
|
+
aku itu dan ini mau ke situ
|
1291
|
+
```
|
1292
|
+
|
1293
|
+
## iscandir
|
1294
|
+
|
1295
|
+
`iscandir(folder_name='.', glob_pattern='*', recursive=True, scan_file=True, scan_folder=True)`
|
1296
|
+
|
1297
|
+
Mempermudah scandir untuk mengumpulkan folder dan file.
|
1298
|
+
|
1299
|
+
```python
|
1300
|
+
print(iscandir())
|
1301
|
+
print(list(iscandir("./", recursive=False, scan_file=False)))
|
1302
|
+
```
|
1303
|
+
|
1304
|
+
Output:
|
1305
|
+
```py
|
1306
|
+
<generator object iscandir at 0x7384b48540>
|
1307
|
+
[PosixPath('.git'), PosixPath('.vscode'), PosixPath('pypipr'), PosixPath('__pycache__'), PosixPath('dist')]
|
1308
|
+
```
|
1309
|
+
|
1310
|
+
## isplit
|
1311
|
+
|
1312
|
+
`isplit(text, separator='', include_separator=False)`
|
1313
|
+
|
1314
|
+
Memecah text menjadi list berdasarkan separator.
|
1315
|
+
|
1316
|
+
```python
|
1317
|
+
t = '/ini/contoh/path/'
|
1318
|
+
print(isplit(t, separator='/'))
|
1319
|
+
```
|
1320
|
+
|
1321
|
+
Output:
|
1322
|
+
```py
|
1323
|
+
['', 'ini', 'contoh', 'path', '']
|
1324
|
+
```
|
1325
|
+
|
1326
|
+
## ivars
|
1327
|
+
|
1328
|
+
`ivars(obj, skip_underscore=True)`
|
1329
|
+
|
1330
|
+
Membuat dictionary berdasarkan kategori untuk setiap
|
1331
|
+
member dari object.
|
1332
|
+
|
1333
|
+
```python
|
1334
|
+
iprint(ivars(__import__('pypipr')))
|
1335
|
+
```
|
1336
|
+
|
1337
|
+
Output:
|
1338
|
+
```py
|
1339
|
+
{'class': {'APIMixinView': <class 'pypipr.APIMixinView.APIMixinView'>,
|
1340
|
+
'ComparePerformance': <class 'pypipr.ComparePerformance.ComparePerformance'>,
|
1341
|
+
'PintUregQuantity': <class 'pint.Quantity'>,
|
1342
|
+
'RunParallel': <class 'pypipr.RunParallel.RunParallel'>},
|
1343
|
+
'function': {'avg': <function avg at 0x7393816700>,
|
1344
|
+
'get_filemtime': <function get_filemtime at 0x738aecf2e0>,
|
1345
|
+
'print_colorize': <function print_colorize at 0x738aecf4c0>,
|
1346
|
+
'print_log': <function print_log at 0x738af92b60>,
|
1347
|
+
'console_run': <function console_run at 0x738aecf380>,
|
1348
|
+
'auto_reload': <function auto_reload at 0x738aebbec0>,
|
1349
|
+
'basename': <function basename at 0x738aecf240>,
|
1350
|
+
'chr_to_int': <function chr_to_int at 0x738aecfa60>,
|
1351
|
+
'int_to_chr': <function int_to_chr at 0x738aecfb00>,
|
1352
|
+
'irange': <function irange at 0x738aecf920>,
|
1353
|
+
'batchmaker': <function batchmaker at 0x738aecf740>,
|
1354
|
+
'calculate': <function calculate at 0x738aecfba0>,
|
1355
|
+
'batch_calculate': <function batch_calculate at 0x738aecf600>,
|
1356
|
+
'is_iterable': <function is_iterable at 0x738aecfc40>,
|
1357
|
+
'print_to_last_line': <function print_to_last_line at 0x738aecfce0>,
|
1358
|
+
'text_colorize': <function text_colorize at 0x738aecfd80>,
|
1359
|
+
'choices': <function choices at 0x738aecf6a0>,
|
1360
|
+
'chunk_array': <function chunk_array at 0x738aecf7e0>,
|
1361
|
+
'create_folder': <function create_folder at 0x738aecfe20>,
|
1362
|
+
'datetime_from_string': <function datetime_from_string at 0x738aecfec0>,
|
1363
|
+
'datetime_now': <function datetime_now at 0x738aecff60>,
|
1364
|
+
'dict_first': <function dict_first at 0x738acf8040>,
|
1365
|
+
'dirname': <function dirname at 0x738acf80e0>,
|
1366
|
+
'is_empty': <function is_empty at 0x738acf82c0>,
|
1367
|
+
'exit_if_empty': <function exit_if_empty at 0x738aecf560>,
|
1368
|
+
'to_str': <function to_str at 0x738acf8400>,
|
1369
|
+
'filter_empty': <function filter_empty at 0x738acf8180>,
|
1370
|
+
'get_by_index': <function get_by_index at 0x738acf8360>,
|
1371
|
+
'get_class_method': <function get_class_method at 0x738acf84a0>,
|
1372
|
+
'get_filesize': <function get_filesize at 0x738acf85e0>,
|
1373
|
+
'github_pull': <function github_pull at 0x738acf8680>,
|
1374
|
+
'github_push': <function github_push at 0x738acf8860>,
|
1375
|
+
'github_user': <function github_user at 0x738acf8900>,
|
1376
|
+
'iargv': <function iargv at 0x738acf8720>,
|
1377
|
+
'idumps_html': <function idumps_html at 0x738acf8b80>,
|
1378
|
+
'idumps': <function idumps at 0x738acf8a40>,
|
1379
|
+
'ienv': <function ienv at 0x738acf9080>,
|
1380
|
+
'iexec': <function iexec at 0x738add13a0>,
|
1381
|
+
'ijoin': <function ijoin at 0x738add1580>,
|
1382
|
+
'iloads_html': <function iloads_html at 0x738add1760>,
|
1383
|
+
'iloads': <function iloads at 0x738add14e0>,
|
1384
|
+
'input_char': <function input_char at 0x738add16c0>,
|
1385
|
+
'is_valid_url': <function is_valid_url at 0x738add1940>,
|
1386
|
+
'iopen': <function iopen at 0x738abd9da0>,
|
1387
|
+
'iprint': <function iprint at 0x738add18a0>,
|
1388
|
+
'ireplace': <function ireplace at 0x738add1c60>,
|
1389
|
+
'iscandir': <function iscandir at 0x738ac9d4e0>,
|
1390
|
+
'isplit': <function isplit at 0x738ac9d580>,
|
1391
|
+
'ivars': <function ivars at 0x738ac9d620>,
|
1392
|
+
'log': <function log at 0x738ac9d6c0>,
|
1393
|
+
'password_generator': <function password_generator at 0x738ac9d760>,
|
1394
|
+
'pip_freeze_without_version': <function pip_freeze_without_version at 0x738ac9d8a0>,
|
1395
|
+
'poetry_publish': <function poetry_publish at 0x738ac9d940>,
|
1396
|
+
'poetry_update_version': <function poetry_update_version at 0x738ac9da80>,
|
1397
|
+
'print_dir': <function print_dir at 0x738ac9dc60>,
|
1398
|
+
'random_bool': <function random_bool at 0x738ac9dd00>,
|
1399
|
+
'restart': <function restart at 0x738ac9dda0>,
|
1400
|
+
'set_timeout': <function set_timeout at 0x738ac9de40>,
|
1401
|
+
'sets_ordered': <function sets_ordered at 0x738ac9dee0>,
|
1402
|
+
'str_cmp': <function str_cmp at 0x738ac9df80>},
|
1403
|
+
'variable': {'LINUX': True,
|
1404
|
+
'PintUreg': <pint.registry.UnitRegistry object at 0x73939fbf50>,
|
1405
|
+
'WINDOWS': False},
|
1406
|
+
'module': {'asyncio': <module 'asyncio' from '/data/data/com.termux/files/usr/lib/python3.11/asyncio/__init__.py'>,
|
1407
|
+
'colorama': <module 'colorama' from '/data/data/com.termux/files/usr/lib/python3.11/site-packages/colorama/__init__.py'>,
|
1408
|
+
'csv': <module 'csv' from '/data/data/com.termux/files/usr/lib/python3.11/csv.py'>,
|
1409
|
+
'datetime': <module 'datetime' from '/data/data/com.termux/files/usr/lib/python3.11/datetime.py'>,
|
1410
|
+
'functools': <module 'functools' from '/data/data/com.termux/files/usr/lib/python3.11/functools.py'>,
|
1411
|
+
'inspect': <module 'inspect' from '/data/data/com.termux/files/usr/lib/python3.11/inspect.py'>,
|
1412
|
+
'io': <module 'io' (frozen)>,
|
1413
|
+
'json': <module 'json' from '/data/data/com.termux/files/usr/lib/python3.11/json/__init__.py'>,
|
1414
|
+
'lxml': <module 'lxml' from '/data/data/com.termux/files/usr/lib/python3.11/site-packages/lxml/__init__.py'>,
|
1415
|
+
'math': <module 'math' from '/data/data/com.termux/files/usr/lib/python3.11/lib-dynload/math.cpython-311.so'>,
|
1416
|
+
'multiprocessing': <module 'multiprocessing' from '/data/data/com.termux/files/usr/lib/python3.11/multiprocessing/__init__.py'>,
|
1417
|
+
'operator': <module 'operator' from '/data/data/com.termux/files/usr/lib/python3.11/operator.py'>,
|
1418
|
+
'os': <module 'os' (frozen)>,
|
1419
|
+
'pathlib': <module 'pathlib' from '/data/data/com.termux/files/usr/lib/python3.11/pathlib.py'>,
|
1420
|
+
'pint': <module 'pint' from '/data/data/com.termux/files/usr/lib/python3.11/site-packages/pint/__init__.py'>,
|
1421
|
+
'pprint': <module 'pprint' from '/data/data/com.termux/files/usr/lib/python3.11/pprint.py'>,
|
1422
|
+
'queue': <module 'queue' from '/data/data/com.termux/files/usr/lib/python3.11/queue.py'>,
|
1423
|
+
'random': <module 'random' from '/data/data/com.termux/files/usr/lib/python3.11/random.py'>,
|
1424
|
+
're': <module 're' from '/data/data/com.termux/files/usr/lib/python3.11/re/__init__.py'>,
|
1425
|
+
'requests': <module 'requests' from '/data/data/com.termux/files/usr/lib/python3.11/site-packages/requests/__init__.py'>,
|
1426
|
+
'string': <module 'string' from '/data/data/com.termux/files/usr/lib/python3.11/string.py'>,
|
1427
|
+
'subprocess': <module 'subprocess' from '/data/data/com.termux/files/usr/lib/python3.11/subprocess.py'>,
|
1428
|
+
'sys': <module 'sys' (built-in)>,
|
1429
|
+
'textwrap': <module 'textwrap' from '/data/data/com.termux/files/usr/lib/python3.11/textwrap.py'>,
|
1430
|
+
'threading': <module 'threading' from '/data/data/com.termux/files/usr/lib/python3.11/threading.py'>,
|
1431
|
+
'time': <module 'time' (built-in)>,
|
1432
|
+
'tzdata': <module 'tzdata' from '/data/data/com.termux/files/usr/lib/python3.11/site-packages/tzdata/__init__.py'>,
|
1433
|
+
'uuid': <module 'uuid' from '/data/data/com.termux/files/usr/lib/python3.11/uuid.py'>,
|
1434
|
+
'webbrowser': <module 'webbrowser' from '/data/data/com.termux/files/usr/lib/python3.11/webbrowser.py'>,
|
1435
|
+
'yaml': <module 'yaml' from '/data/data/com.termux/files/usr/lib/python3.11/site-packages/yaml/__init__.py'>,
|
1436
|
+
'zoneinfo': <module 'zoneinfo' from '/data/data/com.termux/files/usr/lib/python3.11/zoneinfo/__init__.py'>}}
|
1437
|
+
```
|
1438
|
+
|
1439
|
+
## log
|
1440
|
+
|
1441
|
+
`log(text=None)`
|
1442
|
+
|
1443
|
+
Decorator untuk mempermudah pembuatan log karena tidak perlu mengubah
|
1444
|
+
fungsi yg sudah ada.
|
1445
|
+
Melakukan print ke console untuk menginformasikan proses yg sedang
|
1446
|
+
berjalan didalam program.
|
1447
|
+
|
1448
|
+
```py
|
1449
|
+
@log
|
1450
|
+
def some_function():
|
1451
|
+
pass
|
1452
|
+
|
1453
|
+
@log()
|
1454
|
+
def some_function_again():
|
1455
|
+
pass
|
1456
|
+
|
1457
|
+
@log("Calling some function")
|
1458
|
+
def some_function_more():
|
1459
|
+
pass
|
1460
|
+
|
1461
|
+
some_function()
|
1462
|
+
some_function_again()
|
1463
|
+
some_function_more()
|
1464
|
+
```
|
1465
|
+
|
1466
|
+
## password_generator
|
1467
|
+
|
1468
|
+
`password_generator(length=8, characters='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~')`
|
1469
|
+
|
1470
|
+
Membuat pssword secara acak
|
1471
|
+
|
1472
|
+
```python
|
1473
|
+
print(password_generator())
|
1474
|
+
```
|
1475
|
+
|
1476
|
+
Output:
|
1477
|
+
```py
|
1478
|
+
br3+8mbt
|
1438
1479
|
```
|
1439
1480
|
|
1440
|
-
##
|
1481
|
+
## pip_freeze_without_version
|
1441
1482
|
|
1442
|
-
`
|
1483
|
+
`pip_freeze_without_version(filename=None)`
|
1443
1484
|
|
1444
|
-
|
1445
|
-
|
1485
|
+
Memberikan list dari dependencies yang terinstall tanpa version.
|
1486
|
+
Bertujuan untuk menggunakan Batteries Included Python.
|
1446
1487
|
|
1447
|
-
```
|
1448
|
-
|
1449
|
-
iprint(
|
1450
|
-
'yang ini',
|
1451
|
-
{'12':12,'sdsd':{'12':21,'as':[88]}},
|
1452
|
-
color=colorama.Fore.BLUE + colorama.Style.BRIGHT
|
1453
|
-
)
|
1488
|
+
```py
|
1489
|
+
print(pip_freeze_without_version())
|
1454
1490
|
```
|
1455
1491
|
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1492
|
+
## poetry_publish
|
1493
|
+
|
1494
|
+
`poetry_publish(token=None)`
|
1495
|
+
|
1496
|
+
Publish project to pypi,org
|
1497
|
+
|
1498
|
+
```py
|
1499
|
+
poetry_publish()
|
1459
1500
|
```
|
1460
1501
|
|
1461
|
-
##
|
1502
|
+
## poetry_update_version
|
1462
1503
|
|
1463
|
-
`
|
1504
|
+
`poetry_update_version(mayor=False, minor=False, patch=False)`
|
1464
1505
|
|
1465
|
-
|
1506
|
+
Update versi pada pyproject.toml menggunakan poetry
|
1507
|
+
|
1508
|
+
```py
|
1509
|
+
poetry_update_version()
|
1510
|
+
```
|
1511
|
+
|
1512
|
+
## print_dir
|
1513
|
+
|
1514
|
+
`print_dir(var, colorize=True)`
|
1515
|
+
|
1516
|
+
Print property dan method yang tersedia pada variabel
|
1466
1517
|
|
1467
1518
|
```python
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
print(list(irange(1, '7')))
|
1472
|
-
print(list(irange(10, 5)))
|
1519
|
+
import pathlib
|
1520
|
+
p = pathlib.Path("https://www.google.com/")
|
1521
|
+
print_dir(p, colorize=False)
|
1473
1522
|
```
|
1474
1523
|
|
1475
|
-
|
1524
|
+
Output:
|
1525
|
+
```py
|
1526
|
+
__bytes__ : b'https:/www.google.com'
|
1527
|
+
__class__ : .
|
1528
|
+
__dir__ : ['__module__', '__doc__', '__slots__', '__new__', '_make_child_relpath', '__enter__', '__exit__', 'cwd', 'home', 'samefile', 'iterdir', '_scandir', 'glob', 'rglob', 'absolute', 'resolve', 'stat', 'owner', 'group', 'open', 'read_bytes', 'read_text', 'write_bytes', 'write_text', 'readlink', 'touch', 'mkdir', 'chmod', 'lchmod', 'unlink', 'rmdir', 'lstat', 'rename', 'replace', 'symlink_to', 'hardlink_to', 'link_to', 'exists', 'is_dir', 'is_file', 'is_mount', 'is_symlink', 'is_block_device', 'is_char_device', 'is_fifo', 'is_socket', 'expanduser', '__reduce__', '_parse_args', '_from_parts', '_from_parsed_parts', '_format_parsed_parts', '_make_child', '__str__', '__fspath__', 'as_posix', '__bytes__', '__repr__', 'as_uri', '_cparts', '__eq__', '__hash__', '__lt__', '__le__', '__gt__', '__ge__', 'drive', 'root', 'anchor', 'name', 'suffix', 'suffixes', 'stem', 'with_name', 'with_stem', 'with_suffix', 'relative_to', 'is_relative_to', 'parts', 'joinpath', '__truediv__', '__rtruediv__', 'parent', 'parents', 'is_absolute', 'is_reserved', 'match', '_cached_cparts', '_drv', '_hash', '_parts', '_pparts', '_root', '_str', '__getattribute__', '__setattr__', '__delattr__', '__ne__', '__init__', '__reduce_ex__', '__getstate__', '__subclasshook__', '__init_subclass__', '__format__', '__sizeof__', '__dir__', '__class__', '_flavour']
|
1529
|
+
__doc__ : Path subclass for non-Windows systems.
|
1476
1530
|
|
1477
|
-
|
1531
|
+
On a POSIX system, instantiating a Path should return this object.
|
1532
|
+
|
1533
|
+
__enter__ : https:/www.google.com
|
1534
|
+
__fspath__ : https:/www.google.com
|
1535
|
+
__getstate__ : (None, {'_drv': '', '_root': '', '_parts': ['https:', 'www.google.com'], '_str': 'https:/www.google.com'})
|
1536
|
+
__hash__ : 9538007634898831
|
1537
|
+
__init__ : None
|
1538
|
+
__init_subclass__ : None
|
1539
|
+
__module__ : pathlib
|
1540
|
+
__reduce__ : (<class 'pathlib.PosixPath'>, ('https:', 'www.google.com'))
|
1541
|
+
__repr__ : PosixPath('https:/www.google.com')
|
1542
|
+
__sizeof__ : 72
|
1543
|
+
__slots__ : ()
|
1544
|
+
__str__ : https:/www.google.com
|
1545
|
+
__subclasshook__ : NotImplemented
|
1546
|
+
_cached_cparts : ['https:', 'www.google.com']
|
1547
|
+
_cparts : ['https:', 'www.google.com']
|
1548
|
+
_drv :
|
1549
|
+
_flavour : <pathlib._PosixFlavour object at 0x73966307d0>
|
1550
|
+
_hash : 9538007634898831
|
1551
|
+
_parts : ['https:', 'www.google.com']
|
1552
|
+
_root :
|
1553
|
+
_str : https:/www.google.com
|
1554
|
+
absolute : /data/data/com.termux/files/home/pypipr/https:/www.google.com
|
1555
|
+
anchor :
|
1556
|
+
as_posix : https:/www.google.com
|
1557
|
+
cwd : /data/data/com.termux/files/home/pypipr
|
1558
|
+
drive :
|
1559
|
+
exists : False
|
1560
|
+
expanduser : https:/www.google.com
|
1561
|
+
home : /data/data/com.termux/files/home
|
1562
|
+
is_absolute : False
|
1563
|
+
is_block_device : False
|
1564
|
+
is_char_device : False
|
1565
|
+
is_dir : False
|
1566
|
+
is_fifo : False
|
1567
|
+
is_file : False
|
1568
|
+
is_mount : False
|
1569
|
+
is_reserved : False
|
1570
|
+
is_socket : False
|
1571
|
+
is_symlink : False
|
1572
|
+
iterdir : <generator object Path.iterdir at 0x7384b51fc0>
|
1573
|
+
joinpath : https:/www.google.com
|
1574
|
+
name : www.google.com
|
1575
|
+
parent : https:
|
1576
|
+
parents : <PosixPath.parents>
|
1577
|
+
parts : ('https:', 'www.google.com')
|
1578
|
+
resolve : /data/data/com.termux/files/home/pypipr/https:/www.google.com
|
1579
|
+
root :
|
1580
|
+
stem : www.google
|
1581
|
+
suffix : .com
|
1582
|
+
suffixes : ['.google', '.com']
|
1583
|
+
```
|
1478
1584
|
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1585
|
+
## random_bool
|
1586
|
+
|
1587
|
+
`random_bool()`
|
1588
|
+
|
1589
|
+
Menghasilkan nilai random True atau False.
|
1590
|
+
Fungsi ini merupakan fungsi tercepat untuk mendapatkan random bool.
|
1591
|
+
Fungsi ini sangat cepat, tetapi pemanggilan fungsi ini membutuhkan
|
1592
|
+
overhead yg besar.
|
1484
1593
|
|
1485
1594
|
```python
|
1486
|
-
|
1487
|
-
replacements = {
|
1488
|
-
"sini": "situ",
|
1489
|
-
r"(ini)": r"itu dan \1",
|
1490
|
-
}
|
1491
|
-
print(ireplace(text, replacements))
|
1595
|
+
print(random_bool())
|
1492
1596
|
```
|
1493
1597
|
|
1494
1598
|
Output:
|
1495
1599
|
```py
|
1496
|
-
|
1600
|
+
False
|
1497
1601
|
```
|
1498
1602
|
|
1499
|
-
##
|
1603
|
+
## restart
|
1500
1604
|
|
1501
|
-
`
|
1605
|
+
`restart(*argv)`
|
1502
1606
|
|
1503
|
-
|
1607
|
+
## set_timeout
|
1608
|
+
|
1609
|
+
`set_timeout(interval, func, args=None, kwargs=None)`
|
1610
|
+
|
1611
|
+
Menjalankan fungsi ketika sudah sekian detik.
|
1612
|
+
Apabila timeout masih berjalan tapi kode sudah selesai dieksekusi semua, maka
|
1613
|
+
program tidak akan berhenti sampai timeout selesai, kemudian fungsi dijalankan,
|
1614
|
+
kemudian program dihentikan.
|
1504
1615
|
|
1505
1616
|
```python
|
1506
|
-
print(
|
1507
|
-
|
1617
|
+
set_timeout(3, lambda: print("Timeout 3"))
|
1618
|
+
x = set_timeout(7, print, args=["Timeout 7"])
|
1619
|
+
print(x)
|
1620
|
+
print("menghentikan timeout 7")
|
1621
|
+
x.cancel()
|
1508
1622
|
```
|
1509
1623
|
|
1510
1624
|
Output:
|
1511
1625
|
```py
|
1512
|
-
<
|
1513
|
-
|
1626
|
+
<Timer(Thread-2, started 496119037168)>
|
1627
|
+
menghentikan timeout 7
|
1514
1628
|
```
|
1515
1629
|
|
1516
|
-
##
|
1630
|
+
## sets_ordered
|
1517
1631
|
|
1518
|
-
`
|
1632
|
+
`sets_ordered(iterator)`
|
1519
1633
|
|
1520
|
-
|
1634
|
+
Hanya mengambil nilai unik dari suatu list
|
1521
1635
|
|
1522
1636
|
```python
|
1523
|
-
|
1524
|
-
print(
|
1637
|
+
array = [2, 3, 12, 3, 3, 42, 42, 1, 43, 2, 42, 41, 4, 24, 32, 42, 3, 12, 32, 42, 42]
|
1638
|
+
print(sets_ordered(array))
|
1639
|
+
print(list(sets_ordered(array)))
|
1525
1640
|
```
|
1526
1641
|
|
1527
1642
|
Output:
|
1528
1643
|
```py
|
1529
|
-
|
1644
|
+
<generator object sets_ordered at 0x7384b70a00>
|
1645
|
+
[2, 3, 12, 42, 1, 43, 41, 4, 24, 32]
|
1530
1646
|
```
|
1531
1647
|
|
1532
|
-
##
|
1648
|
+
## str_cmp
|
1533
1649
|
|
1534
|
-
`
|
1650
|
+
`str_cmp(t1, t2)`
|
1535
1651
|
|
1536
|
-
|
1537
|
-
|
1652
|
+
Membandingakan string secara incase-sensitive menggunakan lower().
|
1653
|
+
Lebih cepat dibandingkan upper(), casefold(), re.fullmatch(), len().
|
1654
|
+
perbandingan ini sangat cepat, tetapi pemanggilan fungsi ini membutuhkan
|
1655
|
+
overhead yg besar.
|
1538
1656
|
|
1539
1657
|
```python
|
1540
|
-
|
1658
|
+
print(str_cmp('teks1', 'Teks1'))
|
1541
1659
|
```
|
1542
1660
|
|
1543
1661
|
Output:
|
1544
1662
|
```py
|
1545
|
-
|
1546
|
-
'iconsole': <module 'pypipr.iconsole' from '/data/data/com.termux/files/home/pypipr/pypipr/iconsole/__init__.py'>,
|
1547
|
-
'idjango': <module 'pypipr.idjango' from '/data/data/com.termux/files/home/pypipr/pypipr/idjango/__init__.py'>,
|
1548
|
-
'iengineering': <module 'pypipr.iengineering' from '/data/data/com.termux/files/home/pypipr/pypipr/iengineering/__init__.py'>,
|
1549
|
-
'ifunctions': <module 'pypipr.ifunctions' from '/data/data/com.termux/files/home/pypipr/pypipr/ifunctions/__init__.py'>,
|
1550
|
-
'iflow': <module 'pypipr.iflow' (<_frozen_importlib_external.NamespaceLoader object at 0x7815c8f5d0>)>,
|
1551
|
-
'asyncio': <module 'asyncio' from '/data/data/com.termux/files/usr/lib/python3.11/asyncio/__init__.py'>,
|
1552
|
-
'colorama': <module 'colorama' from '/data/data/com.termux/files/usr/lib/python3.11/site-packages/colorama/__init__.py'>,
|
1553
|
-
'csv': <module 'csv' from '/data/data/com.termux/files/usr/lib/python3.11/csv.py'>,
|
1554
|
-
'datetime': <module 'datetime' from '/data/data/com.termux/files/usr/lib/python3.11/datetime.py'>,
|
1555
|
-
'functools': <module 'functools' from '/data/data/com.termux/files/usr/lib/python3.11/functools.py'>,
|
1556
|
-
'inspect': <module 'inspect' from '/data/data/com.termux/files/usr/lib/python3.11/inspect.py'>,
|
1557
|
-
'io': <module 'io' (frozen)>,
|
1558
|
-
'json': <module 'json' from '/data/data/com.termux/files/usr/lib/python3.11/json/__init__.py'>,
|
1559
|
-
'lxml': <module 'lxml' from '/data/data/com.termux/files/usr/lib/python3.11/site-packages/lxml/__init__.py'>,
|
1560
|
-
'math': <module 'math' from '/data/data/com.termux/files/usr/lib/python3.11/lib-dynload/math.cpython-311.so'>,
|
1561
|
-
'multiprocessing': <module 'multiprocessing' from '/data/data/com.termux/files/usr/lib/python3.11/multiprocessing/__init__.py'>,
|
1562
|
-
'operator': <module 'operator' from '/data/data/com.termux/files/usr/lib/python3.11/operator.py'>,
|
1563
|
-
'os': <module 'os' (frozen)>,
|
1564
|
-
'pathlib': <module 'pathlib' from '/data/data/com.termux/files/usr/lib/python3.11/pathlib.py'>,
|
1565
|
-
'pint': <module 'pint' from '/data/data/com.termux/files/usr/lib/python3.11/site-packages/pint/__init__.py'>,
|
1566
|
-
'pprint': <module 'pprint' from '/data/data/com.termux/files/usr/lib/python3.11/pprint.py'>,
|
1567
|
-
'queue': <module 'queue' from '/data/data/com.termux/files/usr/lib/python3.11/queue.py'>,
|
1568
|
-
'random': <module 'random' from '/data/data/com.termux/files/usr/lib/python3.11/random.py'>,
|
1569
|
-
're': <module 're' from '/data/data/com.termux/files/usr/lib/python3.11/re/__init__.py'>,
|
1570
|
-
'requests': <module 'requests' from '/data/data/com.termux/files/usr/lib/python3.11/site-packages/requests/__init__.py'>,
|
1571
|
-
'string': <module 'string' from '/data/data/com.termux/files/usr/lib/python3.11/string.py'>,
|
1572
|
-
'subprocess': <module 'subprocess' from '/data/data/com.termux/files/usr/lib/python3.11/subprocess.py'>,
|
1573
|
-
'sys': <module 'sys' (built-in)>,
|
1574
|
-
'textwrap': <module 'textwrap' from '/data/data/com.termux/files/usr/lib/python3.11/textwrap.py'>,
|
1575
|
-
'threading': <module 'threading' from '/data/data/com.termux/files/usr/lib/python3.11/threading.py'>,
|
1576
|
-
'time': <module 'time' (built-in)>,
|
1577
|
-
'tzdata': <module 'tzdata' from '/data/data/com.termux/files/usr/lib/python3.11/site-packages/tzdata/__init__.py'>,
|
1578
|
-
'uuid': <module 'uuid' from '/data/data/com.termux/files/usr/lib/python3.11/uuid.py'>,
|
1579
|
-
'webbrowser': <module 'webbrowser' from '/data/data/com.termux/files/usr/lib/python3.11/webbrowser.py'>,
|
1580
|
-
'yaml': <module 'yaml' from '/data/data/com.termux/files/usr/lib/python3.11/site-packages/yaml/__init__.py'>,
|
1581
|
-
'zoneinfo': <module 'zoneinfo' from '/data/data/com.termux/files/usr/lib/python3.11/zoneinfo/__init__.py'>},
|
1582
|
-
'class': {'ComparePerformance': <class 'pypipr.ibuiltins.ComparePerformance.ComparePerformance'>,
|
1583
|
-
'RunParallel': <class 'pypipr.ibuiltins.RunParallel.RunParallel'>,
|
1584
|
-
'APIMixinView': <class 'pypipr.idjango.APIMixinView.APIMixinView'>,
|
1585
|
-
'PintUregQuantity': <class 'pint.Quantity'>},
|
1586
|
-
'variable': {'LINUX': True,
|
1587
|
-
'WINDOWS': False,
|
1588
|
-
'PintUreg': <pint.registry.UnitRegistry object at 0x780e334750>},
|
1589
|
-
'function': {'avg': <function avg at 0x7818bb6d40>,
|
1590
|
-
'basename': <function basename at 0x7818b868e0>,
|
1591
|
-
'chr_to_int': <function chr_to_int at 0x7816805080>,
|
1592
|
-
'chunk_array': <function chunk_array at 0x78168051c0>,
|
1593
|
-
'create_folder': <function create_folder at 0x78168053a0>,
|
1594
|
-
'datetime_from_string': <function datetime_from_string at 0x7816805580>,
|
1595
|
-
'datetime_now': <function datetime_now at 0x78168ad620>,
|
1596
|
-
'dict_first': <function dict_first at 0x78168ad580>,
|
1597
|
-
'dirname': <function dirname at 0x78168ad4e0>,
|
1598
|
-
'exit_if_empty': <function exit_if_empty at 0x78168ad3a0>,
|
1599
|
-
'filter_empty': <function filter_empty at 0x78168ad1c0>,
|
1600
|
-
'get_by_index': <function get_by_index at 0x78168ace00>,
|
1601
|
-
'get_class_method': <function get_class_method at 0x78168accc0>,
|
1602
|
-
'get_filemtime': <function get_filemtime at 0x78168acb80>,
|
1603
|
-
'get_filesize': <function get_filesize at 0x78168ac9a0>,
|
1604
|
-
'int_to_chr': <function int_to_chr at 0x78168ac900>,
|
1605
|
-
'is_empty': <function is_empty at 0x78168ad260>,
|
1606
|
-
'is_iterable': <function is_iterable at 0x78168acfe0>,
|
1607
|
-
'is_valid_url': <function is_valid_url at 0x78168ac7c0>,
|
1608
|
-
'password_generator': <function password_generator at 0x78168ac680>,
|
1609
|
-
'random_bool': <function random_bool at 0x78168ac4a0>,
|
1610
|
-
'restart': <function restart at 0x78168af7e0>,
|
1611
|
-
'set_timeout': <function set_timeout at 0x78168af920>,
|
1612
|
-
'sets_ordered': <function sets_ordered at 0x78168afa60>,
|
1613
|
-
'str_cmp': <function str_cmp at 0x78168afb00>,
|
1614
|
-
'to_str': <function to_str at 0x78168acf40>,
|
1615
|
-
'choices': <function choices at 0x78168afba0>,
|
1616
|
-
'console_run': <function console_run at 0x78168afe20>,
|
1617
|
-
'input_char': <function input_char at 0x78168aff60>,
|
1618
|
-
'log': <function log at 0x78168d0180>,
|
1619
|
-
'print_colorize': <function print_colorize at 0x78168d0220>,
|
1620
|
-
'print_dir': <function print_dir at 0x78168d0360>,
|
1621
|
-
'print_log': <function print_log at 0x78168d0040>,
|
1622
|
-
'print_to_last_line': <function print_to_last_line at 0x78168afd80>,
|
1623
|
-
'text_colorize': <function text_colorize at 0x78168afec0>,
|
1624
|
-
'batch_calculate': <function batch_calculate at 0x780d9316c0>,
|
1625
|
-
'batchmaker': <function batchmaker at 0x780d932340>,
|
1626
|
-
'calculate': <function calculate at 0x780d932700>,
|
1627
|
-
'auto_reload': <function auto_reload at 0x780d9323e0>,
|
1628
|
-
'github_pull': <function github_pull at 0x780d9325c0>,
|
1629
|
-
'github_push': <function github_push at 0x780d932b60>,
|
1630
|
-
'github_user': <function github_user at 0x780d65a0c0>,
|
1631
|
-
'pip_freeze_without_version': <function pip_freeze_without_version at 0x780d65a160>,
|
1632
|
-
'poetry_publish': <function poetry_publish at 0x780d65a020>,
|
1633
|
-
'poetry_update_version': <function poetry_update_version at 0x780d67eb60>,
|
1634
|
-
'iargv': <function iargv at 0x780763c2c0>,
|
1635
|
-
'idumps': <function idumps at 0x780763c400>,
|
1636
|
-
'idumps_html': <function idumps_html at 0x78076a8e00>,
|
1637
|
-
'ienv': <function ienv at 0x780763c540>,
|
1638
|
-
'iexec': <function iexec at 0x78076a9080>,
|
1639
|
-
'ijoin': <function ijoin at 0x780d65a340>,
|
1640
|
-
'iloads': <function iloads at 0x78076a9120>,
|
1641
|
-
'iloads_html': <function iloads_html at 0x78076a93a0>,
|
1642
|
-
'iopen': <function iopen at 0x780d65a3e0>,
|
1643
|
-
'iprint': <function iprint at 0x78076a9260>,
|
1644
|
-
'irange': <function irange at 0x780d932520>,
|
1645
|
-
'ireplace': <function ireplace at 0x78076a9440>,
|
1646
|
-
'iscandir': <function iscandir at 0x78076ab060>,
|
1647
|
-
'isplit': <function isplit at 0x78076ab100>,
|
1648
|
-
'ivars': <function ivars at 0x78076ab1a0>}}
|
1663
|
+
True
|
1649
1664
|
```
|
1650
1665
|
|
1651
1666
|
# CLASS
|
1652
1667
|
|
1668
|
+
## APIMixinView
|
1669
|
+
|
1670
|
+
`APIMixinView()`
|
1671
|
+
|
1672
|
+
APIView adalah class view untuk membuat Website API
|
1673
|
+
Cara kerjanya adalah dengan menggunakan variabel GET untuk menerima data.
|
1674
|
+
|
1675
|
+
Class ini tidak bisa digunakan sendiri.
|
1676
|
+
Class ini harus menjadi mixin Class View karena perlu trigger untuk
|
1677
|
+
memanggil method get().
|
1678
|
+
|
1679
|
+
```py
|
1680
|
+
class ExampleAPIView(APIMixinView, View):
|
1681
|
+
pass
|
1682
|
+
```
|
1683
|
+
|
1653
1684
|
## ComparePerformance
|
1654
1685
|
|
1655
1686
|
`ComparePerformance()`
|
@@ -1685,7 +1716,7 @@ print(ExampleComparePerformance().compare_performance())
|
|
1685
1716
|
|
1686
1717
|
Output:
|
1687
1718
|
```py
|
1688
|
-
{'a': <generator object ExampleComparePerformance.a.<locals>.<genexpr> at
|
1719
|
+
{'a': <generator object ExampleComparePerformance.a.<locals>.<genexpr> at 0x7384b70450>,
|
1689
1720
|
'b': (0, 1, 2, 3, 4, 5, 6, 7, 8, 9),
|
1690
1721
|
'c': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
1691
1722
|
'd': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}
|
@@ -1696,6 +1727,10 @@ Output:
|
|
1696
1727
|
{'a': 0, 'b': 0, 'c': 0, 'd': 0}
|
1697
1728
|
```
|
1698
1729
|
|
1730
|
+
## PintUregQuantity
|
1731
|
+
|
1732
|
+
`PintUregQuantity(value, units=None)`
|
1733
|
+
|
1699
1734
|
## RunParallel
|
1700
1735
|
|
1701
1736
|
`RunParallel()`
|
@@ -1798,23 +1833,3 @@ if __name__ == "__main__":
|
|
1798
1833
|
print(ExampleRunParallel().run_multi_processing())
|
1799
1834
|
```
|
1800
1835
|
|
1801
|
-
## APIMixinView
|
1802
|
-
|
1803
|
-
`APIMixinView()`
|
1804
|
-
|
1805
|
-
APIView adalah class view untuk membuat Website API
|
1806
|
-
Cara kerjanya adalah dengan menggunakan variabel GET untuk menerima data.
|
1807
|
-
|
1808
|
-
Class ini tidak bisa digunakan sendiri.
|
1809
|
-
Class ini harus menjadi mixin Class View karena perlu trigger untuk
|
1810
|
-
memanggil method get().
|
1811
|
-
|
1812
|
-
```py
|
1813
|
-
class ExampleAPIView(APIMixinView, View):
|
1814
|
-
pass
|
1815
|
-
```
|
1816
|
-
|
1817
|
-
## PintUregQuantity
|
1818
|
-
|
1819
|
-
`PintUregQuantity(value, units=None)`
|
1820
|
-
|