MainShortcuts2 2.0.2__tar.gz → 2.0.4__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.
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/PKG-INFO +1 -1
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/pyproject.toml +1 -1
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/src/MainShortcuts2/__init__.py +2 -3
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/src/MainShortcuts2/_module_info.py +1 -1
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/src/MainShortcuts2/core.py +3 -0
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/src/MainShortcuts2/json.py +1 -0
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/src/MainShortcuts2/path.py +59 -30
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/README.md +0 -0
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/src/MainShortcuts2/cfg.py +0 -0
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/src/MainShortcuts2/dict.py +0 -0
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/src/MainShortcuts2/dir.py +0 -0
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/src/MainShortcuts2/file.py +0 -0
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/src/MainShortcuts2/list.py +0 -0
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/src/MainShortcuts2/proc.py +0 -0
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/src/MainShortcuts2/str.py +0 -0
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/src/MainShortcuts2/term.py +0 -0
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/src/MainShortcuts2/utils.py +0 -0
- {mainshortcuts2-2.0.2 → mainshortcuts2-2.0.4}/src/MainShortcuts2/win.py +0 -0
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"""Упрощение и сокращение вашего кода благодаря этой библиотеке
|
|
2
2
|
Разработчик: MainPlay TG
|
|
3
3
|
https://t.me/MainPlayCh"""
|
|
4
|
-
__all__ = ["ms"
|
|
4
|
+
__all__ = ["ms"]
|
|
5
5
|
__scripts__ = ["ms2-import_example"]
|
|
6
6
|
from ._module_info import version as __version__
|
|
7
7
|
# 2.0.0
|
|
8
|
-
from .core import
|
|
9
|
-
ms = MS2()
|
|
8
|
+
from .core import ms
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
name = "MainShortcuts2"
|
|
2
|
-
version = "2.0.
|
|
2
|
+
version = "2.0.4"
|
|
@@ -47,21 +47,21 @@ def cwd(v):
|
|
|
47
47
|
class Path:
|
|
48
48
|
# 2.0.0
|
|
49
49
|
def __init__(self, path: PATH_TYPES):
|
|
50
|
-
self._base_name = None
|
|
51
|
-
self._ext = None
|
|
52
|
-
self._full_name = None
|
|
53
|
-
self._parent_dir = None
|
|
54
|
-
self._path = path2str(path, True)
|
|
55
|
-
self._split = None
|
|
56
50
|
self.cp = self.copy
|
|
57
51
|
self.ln = self.link
|
|
58
52
|
self.mv = self.move
|
|
59
53
|
self.rm = self.delete
|
|
60
54
|
self.rn = self.rename
|
|
61
|
-
self.
|
|
55
|
+
self.path = path
|
|
62
56
|
|
|
63
|
-
def reload(self):
|
|
57
|
+
def reload(self, full: bool = False):
|
|
64
58
|
"""Обнуление кешированной информации"""
|
|
59
|
+
if full:
|
|
60
|
+
self._base_name = None
|
|
61
|
+
self._ext = None
|
|
62
|
+
self._full_name = None
|
|
63
|
+
self._parent_dir = None
|
|
64
|
+
self._split = None
|
|
65
65
|
self._created_at = None
|
|
66
66
|
self._exists = None
|
|
67
67
|
self._is_dir = None
|
|
@@ -78,6 +78,12 @@ class Path:
|
|
|
78
78
|
"""Абсолютный путь к объекту"""
|
|
79
79
|
return self._path
|
|
80
80
|
|
|
81
|
+
@path.setter
|
|
82
|
+
def path(self, v):
|
|
83
|
+
"""Абсолютный путь к объекту"""
|
|
84
|
+
self._path = path2str(v, to_abs=True)
|
|
85
|
+
self.reload(True)
|
|
86
|
+
|
|
81
87
|
@property
|
|
82
88
|
def base_name(self) -> str:
|
|
83
89
|
"""Имя объекта без расширения"""
|
|
@@ -194,56 +200,77 @@ class Path:
|
|
|
194
200
|
self._used_at = os.path.getatime(self.path)
|
|
195
201
|
return self._used_at
|
|
196
202
|
|
|
197
|
-
def copy(self, dest: PATH_TYPES, **kw):
|
|
203
|
+
def copy(self, dest: PATH_TYPES, follow: bool = False, **kw) -> str:
|
|
204
|
+
"""Копирование объекта"""
|
|
198
205
|
kw["dest"] = dest
|
|
199
206
|
kw["path"] = self.path
|
|
200
|
-
|
|
207
|
+
r = copy(**kw)
|
|
208
|
+
if follow:
|
|
209
|
+
self.path = r
|
|
210
|
+
return r
|
|
201
211
|
|
|
202
212
|
def delete(self, **kw):
|
|
213
|
+
"""Безвозвратное удаление объекта"""
|
|
203
214
|
kw["path"] = self.path
|
|
204
|
-
|
|
215
|
+
delete(**kw)
|
|
216
|
+
self.reload()
|
|
205
217
|
|
|
206
218
|
def in_dir(self, dir: PATH_TYPES, **kw) -> bool:
|
|
207
|
-
|
|
219
|
+
"""Находится ли объект в папке"""
|
|
220
|
+
kw["dir"] = dir
|
|
208
221
|
kw["path"] = self.path
|
|
209
222
|
return in_dir(**kw)
|
|
210
223
|
|
|
211
|
-
def link(self, dest: PATH_TYPES, **kw):
|
|
224
|
+
def link(self, dest: PATH_TYPES, follow: bool = False, **kw) -> str:
|
|
225
|
+
"""Создать символическую ссылку на объект"""
|
|
212
226
|
kw["dest"] = dest
|
|
213
227
|
kw["path"] = self.path
|
|
214
|
-
|
|
228
|
+
r = link(**kw)
|
|
229
|
+
if follow:
|
|
230
|
+
self.path = r
|
|
231
|
+
return r
|
|
215
232
|
|
|
216
|
-
def move(self, dest: PATH_TYPES, **kw):
|
|
233
|
+
def move(self, dest: PATH_TYPES, follow: bool = True, **kw) -> str:
|
|
234
|
+
"""Переместить объект"""
|
|
217
235
|
kw["dest"] = dest
|
|
218
236
|
kw["path"] = self.path
|
|
219
|
-
|
|
237
|
+
r = move(**kw)
|
|
238
|
+
if follow:
|
|
239
|
+
self.path = r
|
|
240
|
+
return r
|
|
220
241
|
|
|
221
|
-
def rename(self, name: str, **kw):
|
|
242
|
+
def rename(self, name: str, follow: bool = True, **kw) -> str:
|
|
243
|
+
"""Переименовать объект"""
|
|
222
244
|
kw["name"] = name
|
|
223
245
|
kw["path"] = self.path
|
|
224
|
-
|
|
246
|
+
r = rename(**kw)
|
|
247
|
+
if follow:
|
|
248
|
+
self.path = r
|
|
249
|
+
return r
|
|
225
250
|
|
|
226
251
|
|
|
227
|
-
def copy(path: PATH_TYPES, dest: PATH_TYPES, **kw):
|
|
252
|
+
def copy(path: PATH_TYPES, dest: PATH_TYPES, **kw) -> str:
|
|
228
253
|
kw["src"] = path2str(path)
|
|
229
254
|
kw["dst"] = path2str(dest)
|
|
230
255
|
if os.path.isfile(kw["src"]):
|
|
231
|
-
|
|
256
|
+
shutil.copy(**kw)
|
|
257
|
+
return kw["dst"]
|
|
232
258
|
if os.path.isdir(kw["src"]):
|
|
233
|
-
|
|
259
|
+
shutil.copytree(**kw)
|
|
260
|
+
return kw["dst"]
|
|
234
261
|
|
|
235
262
|
|
|
236
263
|
def delete(path: PATH_TYPES, **kw):
|
|
237
264
|
kw["path"] = path2str(path)
|
|
238
265
|
if os.path.islink(kw["path"]):
|
|
239
|
-
os.unlink(**kw)
|
|
266
|
+
return os.unlink(**kw)
|
|
240
267
|
if os.path.isdir(kw["path"]):
|
|
241
|
-
shutil.rmtree(**kw)
|
|
268
|
+
return shutil.rmtree(**kw)
|
|
242
269
|
if os.path.isfile(kw["path"]):
|
|
243
|
-
os.remove(**kw)
|
|
270
|
+
return os.remove(**kw)
|
|
244
271
|
|
|
245
272
|
|
|
246
|
-
def exists(path: PATH_TYPES):
|
|
273
|
+
def exists(path: PATH_TYPES) -> bool:
|
|
247
274
|
return os.path.exists(path2str(path))
|
|
248
275
|
|
|
249
276
|
|
|
@@ -274,25 +301,27 @@ def is_link(path: PATH_TYPES) -> bool:
|
|
|
274
301
|
return os.path.islink(path2str(path))
|
|
275
302
|
|
|
276
303
|
|
|
277
|
-
def link(path: PATH_TYPES, dest: PATH_TYPES, force: bool = False, **kw):
|
|
304
|
+
def link(path: PATH_TYPES, dest: PATH_TYPES, force: bool = False, **kw) -> str:
|
|
278
305
|
kw["dst"] = path2str(dest, True)
|
|
279
306
|
kw["src"] = path2str(path, True)
|
|
280
307
|
if force:
|
|
281
308
|
if exists(kw["dst"]):
|
|
282
309
|
delete(kw["dst"])
|
|
283
|
-
|
|
310
|
+
os.symlink(**kw)
|
|
311
|
+
return kw["dst"]
|
|
284
312
|
|
|
285
313
|
|
|
286
|
-
def move(path: PATH_TYPES, dest: PATH_TYPES, force: bool = False, **kw):
|
|
314
|
+
def move(path: PATH_TYPES, dest: PATH_TYPES, force: bool = False, **kw) -> str:
|
|
287
315
|
kw["dst"] = path2str(dest, True)
|
|
288
316
|
kw["src"] = path2str(path, True)
|
|
289
317
|
if force:
|
|
290
318
|
if exists(kw["dst"]):
|
|
291
319
|
delete(kw["dst"])
|
|
292
|
-
|
|
320
|
+
shutil.move(**kw)
|
|
321
|
+
return kw["dst"]
|
|
293
322
|
|
|
294
323
|
|
|
295
|
-
def rename(path: PATH_TYPES, name: PATH_TYPES, **kw):
|
|
324
|
+
def rename(path: PATH_TYPES, name: PATH_TYPES, **kw) -> str:
|
|
296
325
|
kw["path"] = path
|
|
297
326
|
kw["dest"] = os.path.dirname(path2str(path)) + "/" + name
|
|
298
327
|
return move(**kw)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|