Skip to main content

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.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')
  • Data conversion

    • json: json.dumps
    • json_dumps: Alias of json
    • json_loads: json.loads
  • Globs

    • glob: Like glob.glob, but allows passing multiple parts of a path
    • glob0: Like glob, but only returns the first matched path
  • Read file contents

    • read: Read file content. You can also pass arguments to open
    • readlines: Read file content as a list of lines. Additional arguments will be passed to open

Project details


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.4.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

pipen_filters-0.0.4-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file pipen-filters-0.0.4.tar.gz.

File metadata

  • Download URL: pipen-filters-0.0.4.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.10.0 Linux/5.11.0-1020-azure

File hashes

Hashes for pipen-filters-0.0.4.tar.gz
Algorithm Hash digest
SHA256 b8bcb192087591773a5f07d21a1870694cf8b839eebdb06c7bfec025493ac109
MD5 2dcf2818f66f1b222939c4f69b6f6f8d
BLAKE2b-256 0922ba030c83305e5e6c4a69adcc0cfc605ced17f7be2caca365fe038307fe83

See more details on using hashes here.

File details

Details for the file pipen_filters-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: pipen_filters-0.0.4-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.10.0 Linux/5.11.0-1020-azure

File hashes

Hashes for pipen_filters-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3522cae6e78d649610344764dd534e12b241d9cac6de8d756ebf70d3c99e0f5b
MD5 e0c6a78161ffc7bd5eb48852f0766f45
BLAKE2b-256 feabc2eec7f82cadfae5779a2a1119ffff7e3a5741b8707efc17ad76702be90a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page