Skip to main content

PyPI Package Documentation Status Git tag Test status Code coverage

Fyoo is a simple argument templatizer that wraps around a command. CLIs exist for pretty much everything, isn’t it about time we started using them in our pipelines as they are? The best data flow code is code you don’t have to write.

Installation

pip install fyoo

Basic Usage

Fyoo can provide context to a subcommand’s arguments after --. All arguments to that subcommand become pre-rendered jinja2 templates.

Fyoo allows you to inject context into shell arguments in a few ways, --fyoo-set being the simplest and easiest to get started with.

fyoo \
  --set table=Employee \
  -- \
sqlite3 \
  'examples/Chinook_Sqlite.sqlite' \
  'select * from {{ table }} where date(HireDate) < "{{ date() }}"' \
  -csv -header
# ... csv results

This goes further than simple bash replacement, because you have the full template power of jinja2 between when arguments are processed and before the process is started.

Let’s use this sql template file now.

{%- if not table %}
  {{ throw("'table' required") }}
{%- endif %}

select count(*)
from {{ table }}
{%- if condition %}
  where ({{ condition }})
{%- endif %}

The template file contents are passed as a bash argument, but then fyoo renders the template before passing it to sqllite3 subcommand.

The -v/--verbose flag will show the executable before running it.

fyoo \
  --verbose \
  --jinja-template-folder ./tests/sql \
  --set table=Employee \
  --set condition='lower(Title) like "%sales%"' \
  -- \
sqlite3 \
  'examples/Chinook_Sqlite.sqlite' \
  '{% include "count.sql.jinja" %}' \
  -csv
# ["sqlite3", "examples/Chinook_Sqlite.sqlite", "\nselect count(*) as c\nfrom Employee\nwhere (lower(Title) like \"%sales%\")", "-csv"]
# 4

Release files for fyoo 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fyoo 1.1.0
File Size Uploaded
fyoo-1.1.0.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fyoo 1.1.0
File Interpreter ABI Platform
fyoo-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.8 kB

Release files / fyoo-1.1.0.tar.gz

Download URL fyoo-1.1.0.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
52d60f3df4e8a3040562657357cc7896198a0c0d5097048e6127af8a78efb44f
BLAKE2b-256 checksum
How to use checksums
b00b881e491b47fb271512a4520cf52461ca6af617229b3307dce22ce302a460
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.1

Release files / fyoo-1.1.0-py3-none-any.whl

Download URL fyoo-1.1.0-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa97e6f8d00f06641971d79a3bb59cd331e00fec8fee09054db777c5ab8d22e4
BLAKE2b-256 checksum
How to use checksums
56a0249c8e075172118f9ccc565e7c53c1301225e112ed3ff4fa22d601d35d60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.1
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page