Add a set of useful filters for pipen templates.
These filters can be used for both liquid and jinja2 templating in pipen.
Installation
pip install -U pipen-filters
Enabling/Disabling the plugin
The plugin is registered via entrypoints. It's by default enabled. To disable it:
plugins=[..., "no:filters"], or uninstall this plugin.
Usage
from pipen import Proc
class MyProc(Proc):
input = "infile:file"
output = "outfile:file:{{in.infile | stem}}.txt"
...
Filters
-
Parse the symbolic links
realpath:os.path.realpathreadlink:os.readlinkabspath:os.path.abspath
-
Find common prefix of given paths
-
commonprefix:>>> commonprefix("/a/b/abc.txt", "/a/b/abc.png") >>> # "abc." >>> commonprefix("/a/b/abc.txt", "/a/b/abc.png", basename_only=False) >>> # "/a/b/abc."
-
-
Get parts of the path
dirname:path.dirnamebasename:path.basenameext,suffix: get the extension (/a/b/c.txt -> .txt)ext0,suffix0: get the extension without dot (/a/b/c.txt -> txt)prefix: get the prefix of a path (/a/b/c.d.txt -> /a/b/c.d)prefix0: get the prefix of a path without dot in basename (/a/b/c.d.txt -> /a/b/c)filename,fn,stem: get the stem of a path (/a/b.c.txt -> b.c)filename0,fn0,stem0: get the stem of a path without dot (/a/b.c.txt -> b)joinpaths,joinpath: join path parts (os.path.join)as_path: convert a string into apathlib.Pathobject
-
Path stat
isdir:os.path.isdirisfile:os.path.isfileislink:os.path.islinkexists:os.path.existsgetsize:os.path.getsize, return -1 if the path doesn't existgetmtime:os.path.getmtime, return -1 if the path doesn't existgetctime:os.path.getctime, return -1 if the path doesn't existgetatime:os.path.getatime, return -1 if the path doesn't existisempty: check if a file is empty
-
Quote data
quote: put double quotes around data (1 -> "1")squote: put single quotes around data (1 -> '1')
-
Configurations
json,json_dumps:json.dumpsjson_load: Load json from a filejson_loads:json.loadstoml:toml.dumpstoml_dump: Load toml from a filetoml_dumps: Alias oftomltoml_loads:toml.loadsconfig: Load configuration from an object, a string or a file
-
Globs
glob: Likeglob.glob, but allows passing multiple parts of a pathglob0: Likeglob, but only returns the first matched path
-
Read file contents
read: Read file content. You can also pass arguments toopenreadlines: Read file content as a list of lines. Additional arguments will be passed toopen
-
Other
regex_replace: Replace a string using regexslugify: Slugify a string
Metadata
Release files for pipen-filters 1.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pipen_filters-1.1.3.tar.gz | 165.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pipen_filters-1.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 172.5 kB
Release files / pipen_filters-1.1.3.tar.gz
| Download URL | pipen_filters-1.1.3.tar.gz |
|---|---|
| Size | 165.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
530ceab2b2e4fda914fdd23705f0721067cdc5f6bda4c65cc29241743e285d28
|
|
BLAKE2b-256 checksum How to use checksums |
e30847eb4b1e00707111dea1b64a8de03cd8d36f03d4428bf449ba6392e0ba10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pipen_filters-1.1.3-py3-none-any.whl
| Download URL | pipen_filters-1.1.3-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a1414354154381af023f7bc451a7fb405ae1aa3c466fdf9616c65e65134e8c32
|
|
BLAKE2b-256 checksum How to use checksums |
7ee4d6f2a721cb7d9c6c2651c2d021ca580b5523ba8bb18af31dd66dd112f480
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|