immlib 1.0.0.dev2__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.
- immlib/__init__.py +131 -0
- immlib/_init.py +108 -0
- immlib/_version.py +235 -0
- immlib/doc/__init__.py +38 -0
- immlib/doc/_core.py +311 -0
- immlib/iolib/__init__.py +29 -0
- immlib/iolib/_core.py +720 -0
- immlib/pathlib/__init__.py +69 -0
- immlib/pathlib/_cache.py +152 -0
- immlib/pathlib/_core.py +869 -0
- immlib/pathlib/_osf.py +538 -0
- immlib/test/__init__.py +16 -0
- immlib/test/__main__.py +10 -0
- immlib/test/doc/__init__.py +6 -0
- immlib/test/doc/test_core.py +91 -0
- immlib/test/iolib/__init__.py +7 -0
- immlib/test/iolib/test_core.py +81 -0
- immlib/test/pathlib/__init__.py +11 -0
- immlib/test/pathlib/test_core.py +146 -0
- immlib/test/pathlib/test_osf.py +54 -0
- immlib/test/types/__init__.py +5 -0
- immlib/test/types/test_core.py +110 -0
- immlib/test/util/__init__.py +11 -0
- immlib/test/util/test_core.py +681 -0
- immlib/test/util/test_numeric.py +1374 -0
- immlib/test/util/test_quantity.py +218 -0
- immlib/test/util/test_url.py +51 -0
- immlib/test/workflow/__init__.py +9 -0
- immlib/test/workflow/test_core.py +418 -0
- immlib/test/workflow/test_plantype.py +248 -0
- immlib/types/__init__.py +29 -0
- immlib/types/_core.py +333 -0
- immlib/util/__init__.py +283 -0
- immlib/util/_core.py +2524 -0
- immlib/util/_numeric.py +2651 -0
- immlib/util/_quantity.py +523 -0
- immlib/util/_url.py +114 -0
- immlib/workflow/__init__.py +48 -0
- immlib/workflow/_core.py +1635 -0
- immlib/workflow/_plantype.py +334 -0
- immlib-1.0.0.dev2.dist-info/METADATA +76 -0
- immlib-1.0.0.dev2.dist-info/RECORD +45 -0
- immlib-1.0.0.dev2.dist-info/WHEEL +5 -0
- immlib-1.0.0.dev2.dist-info/licenses/LICENSE +21 -0
- immlib-1.0.0.dev2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
###############################################################################
|
|
3
|
+
# immlib/pathlib/__init__.py
|
|
4
|
+
|
|
5
|
+
"""Core implementation of the classes for exploring and managing cached paths.
|
|
6
|
+
|
|
7
|
+
These tools work both for exploring files and directories on the local
|
|
8
|
+
filesystem as well as for examining remote paths such as Amazon S3 or OSF
|
|
9
|
+
repositories. The `immlib` library builds on the `pathlib` library along with
|
|
10
|
+
the `cloudpath` library to provide straightforward interface using the `path`
|
|
11
|
+
function.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from ._osf import (
|
|
15
|
+
OSFClient,
|
|
16
|
+
OSFPath)
|
|
17
|
+
from ._core import (
|
|
18
|
+
pathstr,
|
|
19
|
+
filepath,
|
|
20
|
+
s3path,
|
|
21
|
+
gspath,
|
|
22
|
+
azpath,
|
|
23
|
+
osfpath,
|
|
24
|
+
path,
|
|
25
|
+
is_filepath,
|
|
26
|
+
is_s3path,
|
|
27
|
+
is_azpath,
|
|
28
|
+
is_gspath,
|
|
29
|
+
is_osfpath,
|
|
30
|
+
is_path,
|
|
31
|
+
like_filepath,
|
|
32
|
+
like_s3path,
|
|
33
|
+
like_azpath,
|
|
34
|
+
like_gspath,
|
|
35
|
+
like_osfpath,
|
|
36
|
+
like_path,
|
|
37
|
+
pathdict,
|
|
38
|
+
# Symbols that aren't exported via __all__:
|
|
39
|
+
PathTypeRecord,
|
|
40
|
+
pathtypes,
|
|
41
|
+
pathtype)
|
|
42
|
+
__all__ = (
|
|
43
|
+
"OSFClient",
|
|
44
|
+
"OSFPath",
|
|
45
|
+
"pathstr",
|
|
46
|
+
"filepath",
|
|
47
|
+
"s3path",
|
|
48
|
+
"gspath",
|
|
49
|
+
"azpath",
|
|
50
|
+
"osfpath",
|
|
51
|
+
"path",
|
|
52
|
+
"is_filepath",
|
|
53
|
+
"is_s3path",
|
|
54
|
+
"is_azpath",
|
|
55
|
+
"is_gspath",
|
|
56
|
+
"is_osfpath",
|
|
57
|
+
"is_path",
|
|
58
|
+
"like_filepath",
|
|
59
|
+
"like_s3path",
|
|
60
|
+
"like_azpath",
|
|
61
|
+
"like_gspath",
|
|
62
|
+
"like_osfpath",
|
|
63
|
+
"like_path",
|
|
64
|
+
"pathdict")
|
|
65
|
+
|
|
66
|
+
# Mark all the imported functions as belonging to this module instead of the
|
|
67
|
+
# hidden submodules:
|
|
68
|
+
from .._init import reclaim
|
|
69
|
+
reclaim(__name__, del_reclaim=True)
|
immlib/pathlib/_cache.py
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
###############################################################################
|
|
3
|
+
# immlib/pathlib/_cache.py
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# Dependencies ################################################################
|
|
7
|
+
|
|
8
|
+
import os, sys
|
|
9
|
+
from pathlib import (Path, PurePath)
|
|
10
|
+
|
|
11
|
+
from pcollections import (pdict, ldict, lazy)
|
|
12
|
+
from cloudpathlib import CloudPath
|
|
13
|
+
|
|
14
|
+
from ..doc import docwrap
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# CloudCachePath ##############################################################
|
|
18
|
+
|
|
19
|
+
_pymajor = int(sys.version.split('.')[0])
|
|
20
|
+
_pyminor = int(sys.version.split('.')[1])
|
|
21
|
+
_pyv3_12 = (_pymajor > 3 or (_pymajor == 3 and _pyminor > 11))
|
|
22
|
+
_pathbase = Path if _pyv3_12 else type(Path())
|
|
23
|
+
|
|
24
|
+
class CloudCachePath(_pathbase):
|
|
25
|
+
"""A filesystem path wrapper for the CloudPath type.
|
|
26
|
+
|
|
27
|
+
A `CloudCachePath` object is a simple wrapper around a `CloudPath` object.
|
|
28
|
+
However, unlike a `CloudPath` object, a `CloudCachePath` object is also a
|
|
29
|
+
`Path` object. `CloudCachePath` objects represent the cache directories of
|
|
30
|
+
`CloudPath` objects, presenting the directories as fully fleshed out
|
|
31
|
+
instances of their associated cloud paths. Interacting with files forces
|
|
32
|
+
them to be downloaded.
|
|
33
|
+
"""
|
|
34
|
+
def __new__(cls, cloud_path):
|
|
35
|
+
if not isinstance(cloud_path, CloudPath):
|
|
36
|
+
raise TypeError(
|
|
37
|
+
f"CloudCachePath requiers a CloudPath object, not"
|
|
38
|
+
f" {type(cloud_path)}")
|
|
39
|
+
pre = cloud_path.cloud_prefix
|
|
40
|
+
lcd = cloud_path.client._local_cache_dir
|
|
41
|
+
fspath = Path(lcd).absolute() / str(cloud_path)[len(pre):]
|
|
42
|
+
p = super().__new__(cls, fspath)
|
|
43
|
+
p.cloud_path = cloud_path
|
|
44
|
+
return p
|
|
45
|
+
def __init__(self, cloud_path):
|
|
46
|
+
if _pyv3_12:
|
|
47
|
+
pre = cloud_path.cloud_prefix
|
|
48
|
+
lcd = cloud_path.client._local_cache_dir
|
|
49
|
+
fspath = Path(lcd).absolute() / str(cloud_path)[len(pre):]
|
|
50
|
+
super().__init__(fspath)
|
|
51
|
+
def __truediv__(self, other):
|
|
52
|
+
return CloudCachePath(self.cloud_path / other)
|
|
53
|
+
def iterdir(self):
|
|
54
|
+
return map(CloudCachePath, self.cloud_path.iterdir())
|
|
55
|
+
@property
|
|
56
|
+
def parents(self):
|
|
57
|
+
return tuple(map(CloudCachePath, self.cloud_path.parents))
|
|
58
|
+
@property
|
|
59
|
+
def parts(self):
|
|
60
|
+
return self.cloud_path.parts[1:]
|
|
61
|
+
def stat(self, *args, **kw):
|
|
62
|
+
return Path(self.cloud_path.fspath).stat(*args, **kw)
|
|
63
|
+
def chmod(self, *args, **kw):
|
|
64
|
+
#return Path(self.cloud_path.fspath).chmod(*args, **kw)
|
|
65
|
+
raise TypeError(f"{type(self)} filesystem access is read-only")
|
|
66
|
+
def exists(self):
|
|
67
|
+
return Path(self.cloud_path.fspath).exists()
|
|
68
|
+
def expanduser(self):
|
|
69
|
+
return Path(self.cloud_path.fspath).expanduser()
|
|
70
|
+
def glob(self, patt):
|
|
71
|
+
return map(CloudCachePath, self.cloud_path.glob(patt))
|
|
72
|
+
def group(self):
|
|
73
|
+
return Path(self.cloud_path.fspath).group()
|
|
74
|
+
def is_dir(self):
|
|
75
|
+
if os.path.exists(self):
|
|
76
|
+
return os.path.is_dir(self)
|
|
77
|
+
else:
|
|
78
|
+
return self.cloud_path.is_dir()
|
|
79
|
+
def is_file(self):
|
|
80
|
+
if os.path.exists(self):
|
|
81
|
+
return os.path.is_file(self)
|
|
82
|
+
else:
|
|
83
|
+
return self.cloud_path.is_file()
|
|
84
|
+
def is_mount(self):
|
|
85
|
+
return self.cloud_path.is_mount()
|
|
86
|
+
def is_symlink(self):
|
|
87
|
+
return self.cloud_path.is_symlink()
|
|
88
|
+
def is_socket(self):
|
|
89
|
+
return self.cloud_path.is_socket()
|
|
90
|
+
def is_fifo(self):
|
|
91
|
+
return self.cloud_path.is_fifo()
|
|
92
|
+
def is_block_device(self):
|
|
93
|
+
return self.cloud_path.is_block_device()
|
|
94
|
+
def is_char_device(self):
|
|
95
|
+
return self.cloud_path.is_char_device()
|
|
96
|
+
def iterdir(self):
|
|
97
|
+
return map(CloudCachePath, self.cloud_path.iterdir())
|
|
98
|
+
def lchmod(self, mode):
|
|
99
|
+
return Path(self.cloud_path.fspath).lchmod(mode)
|
|
100
|
+
def lstat(self):
|
|
101
|
+
return Path(self.cloud_path.fspath).lstat()
|
|
102
|
+
def mkdir(self, *args, **kw):
|
|
103
|
+
#return Path(self.cloud_path.fspath).mkdir(*args, **kw)
|
|
104
|
+
raise TypeError(f"{type(self)} filesystem access is read-only")
|
|
105
|
+
def open(self, *args, **kw):
|
|
106
|
+
return Path(self.cloud_path.fspath).open(*args, **kw)
|
|
107
|
+
def owner(self):
|
|
108
|
+
return Path(self.cloud_path.fspath).owner()
|
|
109
|
+
def read_bytes(self):
|
|
110
|
+
return Path(self.cloud_path.fspath).read_bytes()
|
|
111
|
+
def read_text(self, *args, **kw):
|
|
112
|
+
return Path(self.cloud_path.fspath).read_text(*args, **kw)
|
|
113
|
+
def readlink(self):
|
|
114
|
+
return Path(self.cloud_path.fspath).readlink()
|
|
115
|
+
def rename(self, target):
|
|
116
|
+
#return Path(self.cloud_path.fspath).rename(target)
|
|
117
|
+
raise TypeError(f"{type(self)} filesystem access is read-only")
|
|
118
|
+
def replace(self, target):
|
|
119
|
+
#return Path(self.cloud_path.fspath).replace(target)
|
|
120
|
+
raise TypeError(f"{type(self)} filesystem access is read-only")
|
|
121
|
+
def absolute(self):
|
|
122
|
+
return CloudCachePath(self.cloud_path)
|
|
123
|
+
def resolve(self, *args, **kw):
|
|
124
|
+
return Path(self.cloud_path.fspath).resolve(*args, **kw)
|
|
125
|
+
def rglob(self, patt):
|
|
126
|
+
return Path(self.cloud_path.fspath).rglob(patt)
|
|
127
|
+
def rmdir(self):
|
|
128
|
+
#return Path(self.cloud_path.fspath).rmdir()
|
|
129
|
+
raise TypeError(f"{type(self)} filesystem access is read-only")
|
|
130
|
+
def samefile(self, other):
|
|
131
|
+
return Path(self.cloud_path.fspath).samefile(other)
|
|
132
|
+
def symlink_to(self, *args, **kw):
|
|
133
|
+
#return Path(self.cloud_path.fspath).symlink_to(target, *args, **kw)
|
|
134
|
+
raise TypeError(f"{type(self)} filesystem access is read-only")
|
|
135
|
+
def hardlink_to(self, target):
|
|
136
|
+
#return Path(self.cloud_path.fspath).hardlink_to(target)
|
|
137
|
+
raise TypeError(f"{type(self)} filesystem access is read-only")
|
|
138
|
+
def link_to(self, target):
|
|
139
|
+
#return Path(self.cloud_path.fspath).link_to(target)
|
|
140
|
+
raise TypeError(f"{type(self)} filesystem access is read-only")
|
|
141
|
+
def touch(self, *args, **kw):
|
|
142
|
+
#return Path(self.cloud_path.fspath).touch(*args, **kw)
|
|
143
|
+
raise TypeError(f"{type(self)} filesystem access is read-only")
|
|
144
|
+
def unlink(self, *args, **kw):
|
|
145
|
+
#return Path(self.cloud_path.fspath).unlink(*args, **kw)
|
|
146
|
+
raise TypeError(f"{type(self)} filesystem access is read-only")
|
|
147
|
+
def write_bytes(self, data):
|
|
148
|
+
#return Path(self.cloud_path.fspath).write_bytes(data)
|
|
149
|
+
raise TypeError(f"{type(self)} filesystem access is read-only")
|
|
150
|
+
def write_text(self, *args, **kw):
|
|
151
|
+
#return Path(self.cloud_path.fspath).write_text(*args, **kw)
|
|
152
|
+
raise TypeError(f"{type(self)} filesystem access is read-only")
|