Add a set of useful filters for pipen templates
Project description
pipen-filters
Add a set of useful filters for 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.realpath
readlink
: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.dirname
basename
:path.basename
ext
: 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 toopen
readlines
: 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
pipen-filters-0.0.1.tar.gz
(3.4 kB
view details)
Built Distribution
File details
Details for the file pipen-filters-0.0.1.tar.gz
.
File metadata
- Download URL: pipen-filters-0.0.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.9.6 Linux/5.8.0-1040-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d149bbe01c91e3602b37e1eddf0d9aa5d70040d83f203ab868023cc509f8d2ce |
|
MD5 | 3522b28472a1ca5931e7d698e84f5aff |
|
BLAKE2b-256 | b1d059f4d8327c473c1c810f69d5ec59ec01b29c5aceab4dfaade095aadb5b94 |
File details
Details for the file pipen_filters-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: pipen_filters-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.9.6 Linux/5.8.0-1040-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2aa6bebf8429d1b5cb9d81a26b7d7226f499f6d814e36bfe3827ce1ec69a57d0 |
|
MD5 | a1235be30c0dbe711388d8c76b6e37f2 |
|
BLAKE2b-256 | 54d69709fea715216e8270196d35eeb509047d8124237cd7898424e8dc93f72d |