Skip to main content

A tiny app to scafold individual files.

Project description

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

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

tinyscaf-0.0.2.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

tinyscaf-0.0.2-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file tinyscaf-0.0.2.tar.gz.

File metadata

  • Download URL: tinyscaf-0.0.2.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0

File hashes

Hashes for tinyscaf-0.0.2.tar.gz
Algorithm Hash digest
SHA256 9d54bba511984c6d0223238d61992c18a88f5940a1b019fb49e22f7bbd5cfbfa
MD5 e53a1a748512553506ddf90adec40a36
BLAKE2b-256 a0f43630595a14aec182564eb66ebf100b7d8d025df067cd0b7166701b602a3e

See more details on using hashes here.

File details

Details for the file tinyscaf-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: tinyscaf-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0

File hashes

Hashes for tinyscaf-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 561d9403f2bf65980dc059193ff583907a9cd095d62c557d6f88ba12ac2ecc7f
MD5 f3bd8ed4f8404177906c81ca632bae9c
BLAKE2b-256 d0aa5f0ffeca741137f95dda9b50849617bb880e83491e1e08916aa1ebd272a7

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