Skip to main content

Tinyscaf

Tinyscaf is a micro scaffolder for simple files you produce all the time. It is an easy way to standardize the basic structure of files you use all the time in projects.

Installation

pip install tinyscaf

Configuration

  • Create a directory called templates
  • Create a configuration file called tinyscaf.json inside the templates directory
  • Create a jinja2 template file using tinyscaf.<variable_name> for the items you want replaced
  • In tinyscaf.json, create a list of objects, one per jinja template
  • Populate the json object with the variable_name as the key and the value is the question you want to prompt the user with.
  • Any matching tinyscaf.<variable_name> will be replaced the in output file

Example

templates/tinyscaf.json

[
    {
    "template_name": "view.jinja",
    "file_name": "{view_name}.sql",
    "view_name": "What is the name of this view?"
    }
]

templates/view.jinja

CREATE VIEW { tinyscaf.view_name } AS
SELECT order_id, customer_name, total_amount
FROM orders limit 100;

The template_name key in each json object is required to identify the associated template. If you want to have a file naming standard based on the answer of one of your questions, you can use the key file_name and the value pointing to the variable_name of the question you want to use in jinja templating formatting.

[
    {
        "template_name": "function.jinja",
        "function_name": "What is the name of the function?",
        "file_name": "{function_name}.sql"
    }
]

Useage:

From the parent folder of templates run tinyscaf Tinyscaf will automatically search the templates directorys for the tinyscaf.json file and any jinja files in the template directory

$> tinyscaf
Choices: 
 
0 - function.jinja 
1 - view.jinja
Choose a template file:  1
What is the name of this view? test_view
File name will be: test_view.sql - Specify the directory to save to. Leave blank for working dir. 
$> 2024-02-02 00:32:42,918 [INFO] [tinyscaf:188] - Finished

If you are not in the parent folder of templates, you can override the auto search for tinyscaf.json and specify the path to the config file manually. Tinyscaf will then search the directory where the config file lives for any jinja template files.

$> tinyscaf --config_file ../../templates/tinyscaf.json
Choices: 
 
0 - function.jinja 
1 - view.jinja
Choose a template file:  1
What is the name of this view? test_view
File name will be: test_view.sql - Specify the directory to save to. Leave blank for working dir. 
$> 2024-02-02 00:32:42,918 [INFO] [tinyscaf:188] - Finished

Metadata

Release files for tinyscaf 0.0.2

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

Source distribution (sdist)

Source distribution for tinyscaf 0.0.2
File Size Uploaded
tinyscaf-0.0.2.tar.gz 9.0 kB Details

Built distribution (wheel)

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

Total release size: 19.2 kB

Release files / tinyscaf-0.0.2.tar.gz

Download URL tinyscaf-0.0.2.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9d54bba511984c6d0223238d61992c18a88f5940a1b019fb49e22f7bbd5cfbfa
BLAKE2b-256 checksum
How to use checksums
a0f43630595a14aec182564eb66ebf100b7d8d025df067cd0b7166701b602a3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0

Release files / tinyscaf-0.0.2-py3-none-any.whl

Download URL tinyscaf-0.0.2-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
561d9403f2bf65980dc059193ff583907a9cd095d62c557d6f88ba12ac2ecc7f
BLAKE2b-256 checksum
How to use checksums
d0aa5f0ffeca741137f95dda9b50849617bb880e83491e1e08916aa1ebd272a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

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