ialdev-core 0.1.0__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.
- iad/core/__init__.py +9 -0
- iad/core/array.py +1961 -0
- iad/core/binary.py +377 -0
- iad/core/cache.py +903 -0
- iad/core/codetools.py +203 -0
- iad/core/datatools.py +671 -0
- iad/core/docs/locators.ipynb +754 -0
- iad/core/dotstyle.py +99 -0
- iad/core/env.py +271 -0
- iad/core/events.py +650 -0
- iad/core/filesproc.py +1046 -0
- iad/core/fnctools.py +390 -0
- iad/core/label.py +240 -0
- iad/core/logs.py +182 -0
- iad/core/nptools.py +449 -0
- iad/core/one_dark.puml +881 -0
- iad/core/param/__init__.py +17 -0
- iad/core/param/confargparse.py +55 -0
- iad/core/param/paramaze.py +339 -0
- iad/core/param/tbox.py +277 -0
- iad/core/paths.py +563 -0
- iad/core/pdtools.py +2570 -0
- iad/core/pydantools/__init__.py +5 -0
- iad/core/pydantools/fixed_pydantic_yaml/__init__.py +32 -0
- iad/core/pydantools/fixed_pydantic_yaml/compat/__init__.py +0 -0
- iad/core/pydantools/fixed_pydantic_yaml/compat/hacks.py +76 -0
- iad/core/pydantools/fixed_pydantic_yaml/compat/old_enums.py +37 -0
- iad/core/pydantools/fixed_pydantic_yaml/compat/representers.py +92 -0
- iad/core/pydantools/fixed_pydantic_yaml/compat/types.py +122 -0
- iad/core/pydantools/fixed_pydantic_yaml/compat/yaml_lib.py +104 -0
- iad/core/pydantools/fixed_pydantic_yaml/ext/__init__.py +1 -0
- iad/core/pydantools/fixed_pydantic_yaml/ext/semver.py +152 -0
- iad/core/pydantools/fixed_pydantic_yaml/ext/versioned_model.py +113 -0
- iad/core/pydantools/fixed_pydantic_yaml/main.py +30 -0
- iad/core/pydantools/fixed_pydantic_yaml/mixin.py +281 -0
- iad/core/pydantools/fixed_pydantic_yaml/model.py +20 -0
- iad/core/pydantools/fixed_pydantic_yaml/py.typed +1 -0
- iad/core/pydantools/fixed_pydantic_yaml/version.py +1 -0
- iad/core/pydantools/models.py +560 -0
- iad/core/regexp.py +348 -0
- iad/core/short.py +308 -0
- iad/core/strings.py +635 -0
- iad/core/unc_panda.py +270 -0
- iad/core/units.py +58 -0
- iad/core/wrap.py +420 -0
- ialdev_core-0.1.0.dist-info/METADATA +73 -0
- ialdev_core-0.1.0.dist-info/RECORD +48 -0
- ialdev_core-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,754 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "code",
|
|
5
|
+
"execution_count": 1,
|
|
6
|
+
"id": "e363337a-c122-407a-9a38-adc2ea03e95c",
|
|
7
|
+
"metadata": {},
|
|
8
|
+
"outputs": [],
|
|
9
|
+
"source": [
|
|
10
|
+
"from inu.utils.filesproc import Locator\n",
|
|
11
|
+
"from pathlib import Path\n",
|
|
12
|
+
"import os\n",
|
|
13
|
+
"\n",
|
|
14
|
+
"root = Path().cwd()\n",
|
|
15
|
+
"os.environ['CUSTOM_OS_ROOT'] = str(Path().home())"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"cell_type": "markdown",
|
|
20
|
+
"id": "13eb1e54-9a67-4652-9a8a-f293abe131d3",
|
|
21
|
+
"metadata": {},
|
|
22
|
+
"source": [
|
|
23
|
+
"# Locator"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"cell_type": "code",
|
|
28
|
+
"execution_count": 2,
|
|
29
|
+
"id": "5011ce13-8115-4fee-99c7-6c90894ac61e",
|
|
30
|
+
"metadata": {},
|
|
31
|
+
"outputs": [
|
|
32
|
+
{
|
|
33
|
+
"data": {
|
|
34
|
+
"text/plain": [
|
|
35
|
+
"\u001B[0;31mInit signature:\u001B[0m\n",
|
|
36
|
+
"\u001B[0mLocator\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m\u001B[0m\n",
|
|
37
|
+
"\u001B[0;34m\u001B[0m \u001B[0;34m*\u001B[0m\u001B[0mfolders\u001B[0m\u001B[0;34m:\u001B[0m \u001B[0;34m'PathT | Locator'\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0;34m\u001B[0m\n",
|
|
38
|
+
"\u001B[0;34m\u001B[0m \u001B[0menvar\u001B[0m\u001B[0;34m:\u001B[0m \u001B[0;34m'str'\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0;32mNone\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0;34m\u001B[0m\n",
|
|
39
|
+
"\u001B[0;34m\u001B[0m \u001B[0msub\u001B[0m\u001B[0;34m:\u001B[0m \u001B[0;34m'PathT'\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0;32mNone\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0;34m\u001B[0m\n",
|
|
40
|
+
"\u001B[0;34m\u001B[0m \u001B[0morder\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0;34m'EIA'\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0;34m\u001B[0m\n",
|
|
41
|
+
"\u001B[0;34m\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
|
|
42
|
+
"\u001B[0;31mDocstring:\u001B[0m \n",
|
|
43
|
+
"Manages multiple locations in the file system and provides methods to find and valudate them.\n",
|
|
44
|
+
"\n",
|
|
45
|
+
"Each of the locations can be defined:\n",
|
|
46
|
+
" - explicitely as a path,\n",
|
|
47
|
+
" - as environment variable\n",
|
|
48
|
+
" - as another Locator\n",
|
|
49
|
+
"\n",
|
|
50
|
+
"Main functionality resides in ``Locator.existing_folders()`` method.\n",
|
|
51
|
+
"By default it returns iterator over actually existing folders at the time of the call.\n",
|
|
52
|
+
"\u001B[0;31mInit docstring:\u001B[0m\n",
|
|
53
|
+
"Define locations to check for usually known before the run-time.\n",
|
|
54
|
+
"\n",
|
|
55
|
+
"Locations are searched in order is defined by the string of following letters denoting:\n",
|
|
56
|
+
" - *E*: folder from the Env variable\n",
|
|
57
|
+
" - *I*: Internal fallback folders\n",
|
|
58
|
+
" - *A*: Additional folders\n",
|
|
59
|
+
"\n",
|
|
60
|
+
"Every letter must be used no more than once.\n",
|
|
61
|
+
"Valid orders: '*IA*', '*E*', '*AIE*'.\n",
|
|
62
|
+
"\n",
|
|
63
|
+
":param envar: environment variable with search folder\n",
|
|
64
|
+
":param default: default search folder\n",
|
|
65
|
+
":param sub: sub-path relative to those defined in envar and defaults\n",
|
|
66
|
+
":param order: order of searching locations\n",
|
|
67
|
+
"\u001B[0;31mFile:\u001B[0m ~/code/algodev/inu/utils/filesproc.py\n",
|
|
68
|
+
"\u001B[0;31mType:\u001B[0m type\n",
|
|
69
|
+
"\u001B[0;31mSubclasses:\u001B[0m "
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
"metadata": {},
|
|
73
|
+
"output_type": "display_data"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"source": [
|
|
77
|
+
"Locator?"
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"cell_type": "markdown",
|
|
82
|
+
"id": "b521886f-3619-4885-89cd-ebd986d4be2e",
|
|
83
|
+
"metadata": {},
|
|
84
|
+
"source": [
|
|
85
|
+
"# Creation"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"cell_type": "markdown",
|
|
90
|
+
"id": "94cd821b-fe50-470e-ade9-de5330d9e78e",
|
|
91
|
+
"metadata": {},
|
|
92
|
+
"source": [
|
|
93
|
+
"## Single Argument"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"cell_type": "code",
|
|
98
|
+
"execution_count": 60,
|
|
99
|
+
"id": "ad29c933-6fd7-460d-90d7-3f1e0a011bee",
|
|
100
|
+
"metadata": {},
|
|
101
|
+
"outputs": [
|
|
102
|
+
{
|
|
103
|
+
"data": {
|
|
104
|
+
"text/plain": [
|
|
105
|
+
"Locator<EIA>$CUSTOM_OS_ROOT=/home/itayo [/tmp\n",
|
|
106
|
+
"\t/home/itayo/tmp]"
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
"execution_count": 60,
|
|
110
|
+
"metadata": {},
|
|
111
|
+
"output_type": "execute_result"
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"source": [
|
|
115
|
+
"loc1 = Locator('/tmp', '~/tmp', envar='CUSTOM_OS_ROOT') # using environment variable\n",
|
|
116
|
+
"loc1"
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"cell_type": "code",
|
|
121
|
+
"execution_count": 65,
|
|
122
|
+
"id": "52cbb7ae-7b77-4c1b-be99-b2f4d34c065c",
|
|
123
|
+
"metadata": {},
|
|
124
|
+
"outputs": [],
|
|
125
|
+
"source": [
|
|
126
|
+
"loc2 = Locator(loc1, '/more/tmp') # using other Locator"
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"attachments": {},
|
|
131
|
+
"cell_type": "markdown",
|
|
132
|
+
"id": "27a32476-aba3-40c1-a916-d367169d361c",
|
|
133
|
+
"metadata": {},
|
|
134
|
+
"source": [
|
|
135
|
+
"## Search Order\n",
|
|
136
|
+
"Main functionality of the `Locator` class is iterate over provided locations:\n",
|
|
137
|
+
" - **E**nvironment Variable based folder\n",
|
|
138
|
+
" - **I**nternally defined list of folders\n",
|
|
139
|
+
" - **A**dditionally provided to a specific method\n",
|
|
140
|
+
"\n",
|
|
141
|
+
"Default: 'EIA'\n",
|
|
142
|
+
"\n",
|
|
143
|
+
"*order* argument exists for almost all of the methods, and allows not only change the search order, but also filter it. \n",
|
|
144
|
+
"\n",
|
|
145
|
+
"### Iterators \n",
|
|
146
|
+
"There are two family of iterators over the locations:\n",
|
|
147
|
+
" - defined: does not checks if defined folders exist\n",
|
|
148
|
+
" - existing: yields only existing "
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"cell_type": "code",
|
|
153
|
+
"execution_count": 66,
|
|
154
|
+
"id": "8e25ff6d-dbe8-4ed2-8148-9384d0afd114",
|
|
155
|
+
"metadata": {},
|
|
156
|
+
"outputs": [
|
|
157
|
+
{
|
|
158
|
+
"data": {
|
|
159
|
+
"text/plain": [
|
|
160
|
+
"[PosixPath('/home/itayo'), PosixPath('/tmp'), PosixPath('/home/itayo/tmp')]"
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
"execution_count": 66,
|
|
164
|
+
"metadata": {},
|
|
165
|
+
"output_type": "execute_result"
|
|
166
|
+
}
|
|
167
|
+
],
|
|
168
|
+
"source": [
|
|
169
|
+
"[*loc1.defined()]"
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"cell_type": "code",
|
|
174
|
+
"execution_count": 74,
|
|
175
|
+
"id": "e826e5ee-7b67-42a1-a404-0bdf16976119",
|
|
176
|
+
"metadata": {},
|
|
177
|
+
"outputs": [
|
|
178
|
+
{
|
|
179
|
+
"data": {
|
|
180
|
+
"text/plain": [
|
|
181
|
+
"[PosixPath('/home/itayo'), PosixPath('/tmp')]"
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
"execution_count": 74,
|
|
185
|
+
"metadata": {},
|
|
186
|
+
"output_type": "execute_result"
|
|
187
|
+
}
|
|
188
|
+
],
|
|
189
|
+
"source": [
|
|
190
|
+
"[*loc1.existing()]"
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"cell_type": "code",
|
|
195
|
+
"execution_count": 75,
|
|
196
|
+
"id": "834ac9d8-d176-4ac8-bc01-3ff41e964163",
|
|
197
|
+
"metadata": {},
|
|
198
|
+
"outputs": [
|
|
199
|
+
{
|
|
200
|
+
"data": {
|
|
201
|
+
"text/plain": [
|
|
202
|
+
"[PosixPath('/tmp'), PosixPath('/home/itayo')]"
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
"execution_count": 75,
|
|
206
|
+
"metadata": {},
|
|
207
|
+
"output_type": "execute_result"
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
"source": [
|
|
211
|
+
"[*loc1.existing(order='IE')]"
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"cell_type": "markdown",
|
|
216
|
+
"id": "d11e3cef-3c52-4237-955a-778b37c24aa2",
|
|
217
|
+
"metadata": {},
|
|
218
|
+
"source": [
|
|
219
|
+
"Shortcuts for `first_` elements:"
|
|
220
|
+
]
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"cell_type": "code",
|
|
224
|
+
"execution_count": 77,
|
|
225
|
+
"id": "0d74674b-0519-49e6-a638-ac8fc2ba1e3c",
|
|
226
|
+
"metadata": {},
|
|
227
|
+
"outputs": [
|
|
228
|
+
{
|
|
229
|
+
"data": {
|
|
230
|
+
"text/plain": [
|
|
231
|
+
"(PosixPath('/home/itayo'), PosixPath('/tmp'))"
|
|
232
|
+
]
|
|
233
|
+
},
|
|
234
|
+
"execution_count": 77,
|
|
235
|
+
"metadata": {},
|
|
236
|
+
"output_type": "execute_result"
|
|
237
|
+
}
|
|
238
|
+
],
|
|
239
|
+
"source": [
|
|
240
|
+
"loc1.first_existing(), loc1.first_existing(order='AIE')"
|
|
241
|
+
]
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"cell_type": "markdown",
|
|
245
|
+
"id": "e3d1e568-0356-43c9-adc1-9894b1a1af49",
|
|
246
|
+
"metadata": {},
|
|
247
|
+
"source": [
|
|
248
|
+
"### Internal folders first, then environment variable"
|
|
249
|
+
]
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"cell_type": "markdown",
|
|
253
|
+
"id": "ab4f4522-fe83-4e97-b2f9-c3176a1d208b",
|
|
254
|
+
"metadata": {},
|
|
255
|
+
"source": [
|
|
256
|
+
"### Internal, then environment, then explicit"
|
|
257
|
+
]
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"cell_type": "code",
|
|
261
|
+
"execution_count": 78,
|
|
262
|
+
"id": "68b249f2-7946-4c20-b6ef-5aacfcfe447b",
|
|
263
|
+
"metadata": {},
|
|
264
|
+
"outputs": [],
|
|
265
|
+
"source": [
|
|
266
|
+
"loc6 = Locator(root, envar='CUSTOM_OS_ROOT', order='IEA')"
|
|
267
|
+
]
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"cell_type": "code",
|
|
271
|
+
"execution_count": 79,
|
|
272
|
+
"id": "4b1cb909-a230-4906-920b-0468188c3df7",
|
|
273
|
+
"metadata": {},
|
|
274
|
+
"outputs": [
|
|
275
|
+
{
|
|
276
|
+
"name": "stdout",
|
|
277
|
+
"output_type": "stream",
|
|
278
|
+
"text": [
|
|
279
|
+
"1./home/itayo/code/algodev/inu/utils\n",
|
|
280
|
+
"2./home/itayo\n",
|
|
281
|
+
"3./home/itayo/code\n"
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
],
|
|
285
|
+
"source": [
|
|
286
|
+
"cnt = 1\n",
|
|
287
|
+
"for folder in loc6.existing(Path().home() / 'code'):\n",
|
|
288
|
+
" print(f'{cnt}.{folder}')\n",
|
|
289
|
+
" cnt += 1"
|
|
290
|
+
]
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"cell_type": "markdown",
|
|
294
|
+
"id": "46057bb0-aa49-4ea6-84ba-50f0b0821f94",
|
|
295
|
+
"metadata": {},
|
|
296
|
+
"source": [
|
|
297
|
+
"# Finding Files"
|
|
298
|
+
]
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
"cell_type": "markdown",
|
|
302
|
+
"id": "40071cff-f18c-46e0-b26b-af225ed7d057",
|
|
303
|
+
"metadata": {},
|
|
304
|
+
"source": [
|
|
305
|
+
"## Using Iterator"
|
|
306
|
+
]
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
"cell_type": "code",
|
|
310
|
+
"execution_count": 80,
|
|
311
|
+
"id": "68c7e93c-86fa-4b43-ab31-e2dd0306539e",
|
|
312
|
+
"metadata": {},
|
|
313
|
+
"outputs": [
|
|
314
|
+
{
|
|
315
|
+
"data": {
|
|
316
|
+
"text/plain": [
|
|
317
|
+
"PosixPath('/home/itayo/code/algodev/inu/utils/filesproc.py')"
|
|
318
|
+
]
|
|
319
|
+
},
|
|
320
|
+
"execution_count": 80,
|
|
321
|
+
"metadata": {},
|
|
322
|
+
"output_type": "execute_result"
|
|
323
|
+
}
|
|
324
|
+
],
|
|
325
|
+
"source": [
|
|
326
|
+
"itr = loc5.find_file_iter('filesproc.py')\n",
|
|
327
|
+
"next(itr)"
|
|
328
|
+
]
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"cell_type": "markdown",
|
|
332
|
+
"id": "15fa60ae-4207-4edf-86cc-384463641242",
|
|
333
|
+
"metadata": {},
|
|
334
|
+
"source": [
|
|
335
|
+
"## Using First Found"
|
|
336
|
+
]
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
"cell_type": "code",
|
|
340
|
+
"execution_count": 81,
|
|
341
|
+
"id": "662b9f0e-7606-4f90-9cf5-03dcf2521003",
|
|
342
|
+
"metadata": {},
|
|
343
|
+
"outputs": [
|
|
344
|
+
{
|
|
345
|
+
"data": {
|
|
346
|
+
"text/plain": [
|
|
347
|
+
"PosixPath('/home/itayo/code/algodev/inu/utils/filesproc.py')"
|
|
348
|
+
]
|
|
349
|
+
},
|
|
350
|
+
"execution_count": 81,
|
|
351
|
+
"metadata": {},
|
|
352
|
+
"output_type": "execute_result"
|
|
353
|
+
}
|
|
354
|
+
],
|
|
355
|
+
"source": [
|
|
356
|
+
"loc5.first_file('filesproc.py')"
|
|
357
|
+
]
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
"cell_type": "markdown",
|
|
361
|
+
"id": "b3698533-6dd6-4a5e-8337-28d355f12cc5",
|
|
362
|
+
"metadata": {},
|
|
363
|
+
"source": [
|
|
364
|
+
"# Defined and Existing"
|
|
365
|
+
]
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"cell_type": "markdown",
|
|
369
|
+
"id": "654a40a5-e51f-4a89-9a18-c8a35b023d7c",
|
|
370
|
+
"metadata": {},
|
|
371
|
+
"source": [
|
|
372
|
+
"Defined locations inside the locator are not necessarily exists. \n",
|
|
373
|
+
"So we distinguish between *defined* and *existing* iterators."
|
|
374
|
+
]
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"cell_type": "code",
|
|
378
|
+
"execution_count": 82,
|
|
379
|
+
"id": "be0991d4-44aa-4aa6-b62d-76d42139ac3a",
|
|
380
|
+
"metadata": {},
|
|
381
|
+
"outputs": [
|
|
382
|
+
{
|
|
383
|
+
"data": {
|
|
384
|
+
"text/plain": [
|
|
385
|
+
"Locator<IE>$FAKE_CUSTOM_OS_ROOT=/home/itayo/notreallyexists [/home/itayo/code/algodev/inu/utils]"
|
|
386
|
+
]
|
|
387
|
+
},
|
|
388
|
+
"execution_count": 82,
|
|
389
|
+
"metadata": {},
|
|
390
|
+
"output_type": "execute_result"
|
|
391
|
+
}
|
|
392
|
+
],
|
|
393
|
+
"source": [
|
|
394
|
+
"os.environ['FAKE_CUSTOM_OS_ROOT'] = str(Path().home() / 'notreallyexists')\n",
|
|
395
|
+
"loc7 = Locator(root, envar='FAKE_CUSTOM_OS_ROOT', order='IE')\n",
|
|
396
|
+
"loc7"
|
|
397
|
+
]
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
"cell_type": "code",
|
|
401
|
+
"execution_count": 83,
|
|
402
|
+
"id": "eba8be5c-3706-4f72-9494-cf15f81ef11f",
|
|
403
|
+
"metadata": {},
|
|
404
|
+
"outputs": [
|
|
405
|
+
{
|
|
406
|
+
"data": {
|
|
407
|
+
"text/plain": [
|
|
408
|
+
"[PosixPath('/home/itayo/code/algodev/inu/utils'),\n",
|
|
409
|
+
" PosixPath('/home/itayo/notreallyexists')]"
|
|
410
|
+
]
|
|
411
|
+
},
|
|
412
|
+
"execution_count": 83,
|
|
413
|
+
"metadata": {},
|
|
414
|
+
"output_type": "execute_result"
|
|
415
|
+
}
|
|
416
|
+
],
|
|
417
|
+
"source": [
|
|
418
|
+
"[*loc7.defined()]"
|
|
419
|
+
]
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
"cell_type": "code",
|
|
423
|
+
"execution_count": 84,
|
|
424
|
+
"id": "51444a00-3261-4961-9abd-8aab6ab4c900",
|
|
425
|
+
"metadata": {},
|
|
426
|
+
"outputs": [
|
|
427
|
+
{
|
|
428
|
+
"data": {
|
|
429
|
+
"text/plain": [
|
|
430
|
+
"[PosixPath('/home/itayo/code/algodev/inu/utils')]"
|
|
431
|
+
]
|
|
432
|
+
},
|
|
433
|
+
"execution_count": 84,
|
|
434
|
+
"metadata": {},
|
|
435
|
+
"output_type": "execute_result"
|
|
436
|
+
}
|
|
437
|
+
],
|
|
438
|
+
"source": [
|
|
439
|
+
"[*loc7.existing()]"
|
|
440
|
+
]
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
"cell_type": "markdown",
|
|
444
|
+
"id": "4a9205dc-c8c1-4735-832b-1aa51301c759",
|
|
445
|
+
"metadata": {},
|
|
446
|
+
"source": [
|
|
447
|
+
"# Reconfigure existing Locator\n",
|
|
448
|
+
"For special cases, it is possible to reconfigure the Locator after it's creation."
|
|
449
|
+
]
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
"cell_type": "code",
|
|
453
|
+
"execution_count": 85,
|
|
454
|
+
"id": "ad1cde07-8593-4f3f-9601-20f80b4aa53b",
|
|
455
|
+
"metadata": {},
|
|
456
|
+
"outputs": [],
|
|
457
|
+
"source": [
|
|
458
|
+
"loc7.reconfigure(root.parent, '/tmp', '/another/one', envar='CUSTOM_OS_ROOT')"
|
|
459
|
+
]
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
"cell_type": "code",
|
|
463
|
+
"execution_count": 86,
|
|
464
|
+
"id": "6521b187-4c1f-4826-8258-f88734974008",
|
|
465
|
+
"metadata": {},
|
|
466
|
+
"outputs": [
|
|
467
|
+
{
|
|
468
|
+
"data": {
|
|
469
|
+
"text/plain": [
|
|
470
|
+
"Locator<IE>$CUSTOM_OS_ROOT=/home/itayo [/home/itayo/code/algodev/inu\n",
|
|
471
|
+
"\t/tmp\n",
|
|
472
|
+
"\t/another/one]"
|
|
473
|
+
]
|
|
474
|
+
},
|
|
475
|
+
"execution_count": 86,
|
|
476
|
+
"metadata": {},
|
|
477
|
+
"output_type": "execute_result"
|
|
478
|
+
}
|
|
479
|
+
],
|
|
480
|
+
"source": [
|
|
481
|
+
"loc7"
|
|
482
|
+
]
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
"cell_type": "markdown",
|
|
486
|
+
"id": "0234e9b8-665a-4f43-bd45-5e2a0af33b34",
|
|
487
|
+
"metadata": {},
|
|
488
|
+
"source": [
|
|
489
|
+
"# Sub-foldering"
|
|
490
|
+
]
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
"cell_type": "code",
|
|
494
|
+
"execution_count": 87,
|
|
495
|
+
"id": "9453b3bd-68fb-4151-be77-0735260f74d0",
|
|
496
|
+
"metadata": {},
|
|
497
|
+
"outputs": [],
|
|
498
|
+
"source": [
|
|
499
|
+
"loc4 = Locator(root, envar='CUSTOM_OS_ROOT')"
|
|
500
|
+
]
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
"cell_type": "code",
|
|
504
|
+
"execution_count": 88,
|
|
505
|
+
"id": "ebd5320b-e5c9-48ab-9ef7-16ad64743477",
|
|
506
|
+
"metadata": {},
|
|
507
|
+
"outputs": [],
|
|
508
|
+
"source": [
|
|
509
|
+
"loc8 = loc4 / 'code/algodev'"
|
|
510
|
+
]
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
"cell_type": "code",
|
|
514
|
+
"execution_count": 89,
|
|
515
|
+
"id": "2882c9b7-7573-4518-92a1-9a4af758158b",
|
|
516
|
+
"metadata": {},
|
|
517
|
+
"outputs": [
|
|
518
|
+
{
|
|
519
|
+
"data": {
|
|
520
|
+
"text/plain": [
|
|
521
|
+
"Locator<EIA|'/code/algodev'>$CUSTOM_OS_ROOT=/home/itayo [/home/itayo/code/algodev/inu/utils]"
|
|
522
|
+
]
|
|
523
|
+
},
|
|
524
|
+
"execution_count": 89,
|
|
525
|
+
"metadata": {},
|
|
526
|
+
"output_type": "execute_result"
|
|
527
|
+
}
|
|
528
|
+
],
|
|
529
|
+
"source": [
|
|
530
|
+
"loc8"
|
|
531
|
+
]
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
"cell_type": "code",
|
|
535
|
+
"execution_count": 91,
|
|
536
|
+
"id": "3cbedb30-1a8f-4f4b-a2d2-2f585dd40668",
|
|
537
|
+
"metadata": {},
|
|
538
|
+
"outputs": [],
|
|
539
|
+
"source": [
|
|
540
|
+
"loc9 = loc8 / 'aviv'"
|
|
541
|
+
]
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
"cell_type": "code",
|
|
545
|
+
"execution_count": 92,
|
|
546
|
+
"id": "9926ad6a-72a9-4b04-9f66-6a9cca7f9bc6",
|
|
547
|
+
"metadata": {},
|
|
548
|
+
"outputs": [
|
|
549
|
+
{
|
|
550
|
+
"data": {
|
|
551
|
+
"text/plain": [
|
|
552
|
+
"Locator<EIA|'/code/algodev/aviv'>$CUSTOM_OS_ROOT=/home/itayo [/home/itayo/code/algodev/inu/utils]"
|
|
553
|
+
]
|
|
554
|
+
},
|
|
555
|
+
"execution_count": 92,
|
|
556
|
+
"metadata": {},
|
|
557
|
+
"output_type": "execute_result"
|
|
558
|
+
}
|
|
559
|
+
],
|
|
560
|
+
"source": [
|
|
561
|
+
"loc9"
|
|
562
|
+
]
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
"cell_type": "code",
|
|
566
|
+
"execution_count": 90,
|
|
567
|
+
"id": "f9618c95-9f14-410f-a6dc-d7296ced1ead",
|
|
568
|
+
"metadata": {},
|
|
569
|
+
"outputs": [
|
|
570
|
+
{
|
|
571
|
+
"data": {
|
|
572
|
+
"text/plain": [
|
|
573
|
+
"PosixPath('code/algodev')"
|
|
574
|
+
]
|
|
575
|
+
},
|
|
576
|
+
"execution_count": 90,
|
|
577
|
+
"metadata": {},
|
|
578
|
+
"output_type": "execute_result"
|
|
579
|
+
}
|
|
580
|
+
],
|
|
581
|
+
"source": [
|
|
582
|
+
"loc8.sub"
|
|
583
|
+
]
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
"cell_type": "markdown",
|
|
587
|
+
"id": "21062e37-306d-45aa-a20c-3831d1d7a172",
|
|
588
|
+
"metadata": {},
|
|
589
|
+
"source": [
|
|
590
|
+
"# Operator overloading and dunder methods"
|
|
591
|
+
]
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
"cell_type": "markdown",
|
|
595
|
+
"id": "b8644c18-f5e6-4ddb-a02a-c1daeab048e7",
|
|
596
|
+
"metadata": {},
|
|
597
|
+
"source": [
|
|
598
|
+
"## +"
|
|
599
|
+
]
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
"cell_type": "code",
|
|
603
|
+
"execution_count": 94,
|
|
604
|
+
"id": "1ef45ffc-0f4f-4233-a280-c5537e1ba7cd",
|
|
605
|
+
"metadata": {},
|
|
606
|
+
"outputs": [
|
|
607
|
+
{
|
|
608
|
+
"data": {
|
|
609
|
+
"text/plain": [
|
|
610
|
+
"[PosixPath('/home/itayo/code/algodev/inu/utils'),\n",
|
|
611
|
+
" PosixPath('/dev'),\n",
|
|
612
|
+
" PosixPath('/aviv')]"
|
|
613
|
+
]
|
|
614
|
+
},
|
|
615
|
+
"execution_count": 94,
|
|
616
|
+
"metadata": {},
|
|
617
|
+
"output_type": "execute_result"
|
|
618
|
+
}
|
|
619
|
+
],
|
|
620
|
+
"source": [
|
|
621
|
+
"[dfnd for dfnd in (Locator(root) + ['/dev', '/aviv/']).defined()]"
|
|
622
|
+
]
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
"cell_type": "markdown",
|
|
626
|
+
"id": "2396e072-f0cf-4919-b883-5670dad603d3",
|
|
627
|
+
"metadata": {},
|
|
628
|
+
"source": [
|
|
629
|
+
"## -"
|
|
630
|
+
]
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
"cell_type": "code",
|
|
634
|
+
"execution_count": 22,
|
|
635
|
+
"id": "339f7fbd-d096-43b5-8b5a-00edb0482b28",
|
|
636
|
+
"metadata": {},
|
|
637
|
+
"outputs": [
|
|
638
|
+
{
|
|
639
|
+
"data": {
|
|
640
|
+
"text/plain": [
|
|
641
|
+
"[]"
|
|
642
|
+
]
|
|
643
|
+
},
|
|
644
|
+
"execution_count": 22,
|
|
645
|
+
"metadata": {},
|
|
646
|
+
"output_type": "execute_result"
|
|
647
|
+
}
|
|
648
|
+
],
|
|
649
|
+
"source": [
|
|
650
|
+
"[dfnd for dfnd in (Locator(root) - root).defined()]"
|
|
651
|
+
]
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
"cell_type": "markdown",
|
|
655
|
+
"id": "6eb6a1c5-b876-4c39-86dc-07e27718b59b",
|
|
656
|
+
"metadata": {},
|
|
657
|
+
"source": [
|
|
658
|
+
"## /"
|
|
659
|
+
]
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
"cell_type": "code",
|
|
663
|
+
"execution_count": 23,
|
|
664
|
+
"id": "74936891-a3bc-4dc9-8165-d2ffc546756d",
|
|
665
|
+
"metadata": {},
|
|
666
|
+
"outputs": [
|
|
667
|
+
{
|
|
668
|
+
"data": {
|
|
669
|
+
"text/plain": [
|
|
670
|
+
"True"
|
|
671
|
+
]
|
|
672
|
+
},
|
|
673
|
+
"execution_count": 23,
|
|
674
|
+
"metadata": {},
|
|
675
|
+
"output_type": "execute_result"
|
|
676
|
+
}
|
|
677
|
+
],
|
|
678
|
+
"source": [
|
|
679
|
+
"(Locator(\"/tmp\", sub=\"one\") / \"two\").sub == (Locator(\"/tmp\", sub=\"one/two\")).sub"
|
|
680
|
+
]
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
"cell_type": "markdown",
|
|
684
|
+
"id": "6ed29e8a-12fb-4e02-baa3-59b96d16bec9",
|
|
685
|
+
"metadata": {},
|
|
686
|
+
"source": [
|
|
687
|
+
"## bool"
|
|
688
|
+
]
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
"cell_type": "code",
|
|
692
|
+
"execution_count": 24,
|
|
693
|
+
"id": "3749a41a-8d45-4d6b-9dc6-708ec2d98d67",
|
|
694
|
+
"metadata": {},
|
|
695
|
+
"outputs": [
|
|
696
|
+
{
|
|
697
|
+
"data": {
|
|
698
|
+
"text/plain": [
|
|
699
|
+
"True"
|
|
700
|
+
]
|
|
701
|
+
},
|
|
702
|
+
"execution_count": 24,
|
|
703
|
+
"metadata": {},
|
|
704
|
+
"output_type": "execute_result"
|
|
705
|
+
}
|
|
706
|
+
],
|
|
707
|
+
"source": [
|
|
708
|
+
"bool(loc8)"
|
|
709
|
+
]
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
"cell_type": "code",
|
|
713
|
+
"execution_count": 25,
|
|
714
|
+
"id": "3b083f11-04dd-4b7e-9092-5875d4f059e4",
|
|
715
|
+
"metadata": {},
|
|
716
|
+
"outputs": [
|
|
717
|
+
{
|
|
718
|
+
"data": {
|
|
719
|
+
"text/plain": [
|
|
720
|
+
"False"
|
|
721
|
+
]
|
|
722
|
+
},
|
|
723
|
+
"execution_count": 25,
|
|
724
|
+
"metadata": {},
|
|
725
|
+
"output_type": "execute_result"
|
|
726
|
+
}
|
|
727
|
+
],
|
|
728
|
+
"source": [
|
|
729
|
+
"bool(Locator())"
|
|
730
|
+
]
|
|
731
|
+
}
|
|
732
|
+
],
|
|
733
|
+
"metadata": {
|
|
734
|
+
"kernelspec": {
|
|
735
|
+
"display_name": "algodev",
|
|
736
|
+
"language": "python",
|
|
737
|
+
"name": "algodev"
|
|
738
|
+
},
|
|
739
|
+
"language_info": {
|
|
740
|
+
"codemirror_mode": {
|
|
741
|
+
"name": "ipython",
|
|
742
|
+
"version": 3
|
|
743
|
+
},
|
|
744
|
+
"file_extension": ".py",
|
|
745
|
+
"mimetype": "text/x-python",
|
|
746
|
+
"name": "python",
|
|
747
|
+
"nbconvert_exporter": "python",
|
|
748
|
+
"pygments_lexer": "ipython3",
|
|
749
|
+
"version": "3.10.9"
|
|
750
|
+
}
|
|
751
|
+
},
|
|
752
|
+
"nbformat": 4,
|
|
753
|
+
"nbformat_minor": 5
|
|
754
|
+
}
|