metapath 0.1.0__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.
- metapath-0.1.0/LICENSE +21 -0
- metapath-0.1.0/PKG-INFO +20 -0
- metapath-0.1.0/README.md +4 -0
- metapath-0.1.0/pyproject.toml +27 -0
- metapath-0.1.0/scripts/pypi.sh +3 -0
- metapath-0.1.0/setup.cfg +4 -0
- metapath-0.1.0/src/metapath/__init__.py +8 -0
- metapath-0.1.0/src/metapath/_version.py +24 -0
- metapath-0.1.0/src/metapath/path.py +74 -0
- metapath-0.1.0/src/metapath.egg-info/PKG-INFO +20 -0
- metapath-0.1.0/src/metapath.egg-info/SOURCES.txt +12 -0
- metapath-0.1.0/src/metapath.egg-info/dependency_links.txt +1 -0
- metapath-0.1.0/src/metapath.egg-info/requires.txt +7 -0
- metapath-0.1.0/src/metapath.egg-info/top_level.txt +1 -0
metapath-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lockhart Lab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
metapath-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: metapath
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A package to combine paths with metadata
|
|
5
|
+
Author-email: "C. Lockhart" <clockha2@gmu.edu>
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: numpy
|
|
10
|
+
Requires-Dist: parse
|
|
11
|
+
Requires-Dist: polars
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest; extra == "dev"
|
|
14
|
+
Requires-Dist: black; extra == "dev"
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
metapath
|
|
18
|
+
========
|
|
19
|
+
|
|
20
|
+
A Python package for adding metadata to file paths.
|
metapath-0.1.0/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel", "setuptools_scm"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[tool.setuptools_scm]
|
|
6
|
+
write_to = "src/metapath/_version.py"
|
|
7
|
+
version_scheme = "post-release"
|
|
8
|
+
local_scheme = "no-local-version"
|
|
9
|
+
|
|
10
|
+
[project]
|
|
11
|
+
name = "metapath"
|
|
12
|
+
dynamic = ["version"]
|
|
13
|
+
description = "A package to combine paths with metadata"
|
|
14
|
+
authors = [{ name="C. Lockhart", email="clockha2@gmu.edu" }]
|
|
15
|
+
readme = "README.md"
|
|
16
|
+
requires-python = ">=3.9"
|
|
17
|
+
dependencies = [
|
|
18
|
+
"numpy",
|
|
19
|
+
"parse",
|
|
20
|
+
"polars",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
dev = ["pytest", "black"]
|
|
25
|
+
|
|
26
|
+
[tool.setuptools.packages.find]
|
|
27
|
+
where = ["src"]
|
metapath-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '0.1.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 1, 0)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = 'g9be45d043'
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
from collections.abc import Sequence
|
|
2
|
+
from glob import glob
|
|
3
|
+
import numpy as np
|
|
4
|
+
import parse
|
|
5
|
+
import pathlib
|
|
6
|
+
import polars as pl
|
|
7
|
+
import re
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Path(pathlib.Path):
|
|
11
|
+
def __init__(self, path, metadata=None):
|
|
12
|
+
super().__init__(path)
|
|
13
|
+
self.metadata = metadata
|
|
14
|
+
|
|
15
|
+
def match(self, path_pattern):
|
|
16
|
+
for path_pattern in np.hstack([path_pattern]):
|
|
17
|
+
if super().match(path_pattern):
|
|
18
|
+
return True
|
|
19
|
+
return False
|
|
20
|
+
|
|
21
|
+
# TODO does scan_csv belong here?
|
|
22
|
+
class Paths(Sequence):
|
|
23
|
+
def __init__(self, paths):
|
|
24
|
+
if len(paths) != len(set(paths)):
|
|
25
|
+
raise AttributeError("paths are not unique")
|
|
26
|
+
self.paths = paths
|
|
27
|
+
|
|
28
|
+
def __getitem__(self, item):
|
|
29
|
+
return self.paths[item]
|
|
30
|
+
|
|
31
|
+
def __len__(self):
|
|
32
|
+
return len(self.paths)
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def metadata(self):
|
|
36
|
+
metadata = {path: path.metadata for path in self.paths}
|
|
37
|
+
return metadata
|
|
38
|
+
|
|
39
|
+
def to_frame(self):
|
|
40
|
+
data = [{"fname": str(key), **value} for key, value in self.metadata.items()]
|
|
41
|
+
return pl.DataFrame(data)
|
|
42
|
+
|
|
43
|
+
def to_polars(self, lazy=False):
|
|
44
|
+
df = self.to_frame()
|
|
45
|
+
if lazy:
|
|
46
|
+
df = df.lazy()
|
|
47
|
+
return df
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def var_paths(fstring, exclude=None, require_metadata=True):
|
|
51
|
+
"""
|
|
52
|
+
Use an f-string to extract out a collection of paths, where the f-string variables are captured and stored along the path name.
|
|
53
|
+
|
|
54
|
+
Parameters
|
|
55
|
+
----------
|
|
56
|
+
fstring : :obj:`str`
|
|
57
|
+
exclude : :obj:`bool`
|
|
58
|
+
require_metadata : :obj:`bool`
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
parser = parse.compile(fstring)
|
|
62
|
+
|
|
63
|
+
paths = []
|
|
64
|
+
for fname in glob(re.sub(r"\{.*?\}", "*", fstring)):
|
|
65
|
+
path = Path(fname)
|
|
66
|
+
if exclude and path.match(exclude):
|
|
67
|
+
continue
|
|
68
|
+
path.metadata = getattr(parser.parse(fname), "named", None)
|
|
69
|
+
if require_metadata and path.metadata is None:
|
|
70
|
+
msg = f"metadata not found for '{fname}' with fstring '{fstring}'"
|
|
71
|
+
raise AttributeError(msg)
|
|
72
|
+
paths.append(path)
|
|
73
|
+
|
|
74
|
+
return Paths(paths)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: metapath
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A package to combine paths with metadata
|
|
5
|
+
Author-email: "C. Lockhart" <clockha2@gmu.edu>
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: numpy
|
|
10
|
+
Requires-Dist: parse
|
|
11
|
+
Requires-Dist: polars
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest; extra == "dev"
|
|
14
|
+
Requires-Dist: black; extra == "dev"
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
metapath
|
|
18
|
+
========
|
|
19
|
+
|
|
20
|
+
A Python package for adding metadata to file paths.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
scripts/pypi.sh
|
|
5
|
+
src/metapath/__init__.py
|
|
6
|
+
src/metapath/_version.py
|
|
7
|
+
src/metapath/path.py
|
|
8
|
+
src/metapath.egg-info/PKG-INFO
|
|
9
|
+
src/metapath.egg-info/SOURCES.txt
|
|
10
|
+
src/metapath.egg-info/dependency_links.txt
|
|
11
|
+
src/metapath.egg-info/requires.txt
|
|
12
|
+
src/metapath.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
metapath
|