Add a set of useful filters for pipen templates
Project description
pipen-filters
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.readlink
-
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: get the extension (/a/b/c.txt -> .txt)ext0: 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: join path parts (os.path.join)
-
Quote data
quote: put double quotes around data (1 -> "1")squote: put single quotes around data (1 -> '1')json:json.dumps
-
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pipen-filters-0.0.3.tar.gz.
File metadata
- Download URL: pipen-filters-0.0.3.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.8.0-1042-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89c8f55c48bbeba05ccb76dffe4ba1385bcd867c67c58ca655318db47c2b342c
|
|
| MD5 |
eed169fedfa313e7d635cf7240c4d639
|
|
| BLAKE2b-256 |
d294fa79a43e12415584fbbe5af0918d119788296a0d9ffcbba517deda52def5
|
File details
Details for the file pipen_filters-0.0.3-py3-none-any.whl.
File metadata
- Download URL: pipen_filters-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.8.0-1042-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2a13f4c0c42cfa9b98a44f93d081baa51df26315cf486575eeb9412b08516e8
|
|
| MD5 |
8c0fcc823a7d1b3c24758d9ec27d8c2d
|
|
| BLAKE2b-256 |
f9f3020a04240dfe78ef6363443334c075ab8dd42b95d4ae820e81181181c3d6
|