{"id":18714171,"url":"https://github.com/pfultz2/pino","last_synced_at":"2025-10-23T23:46:34.426Z","repository":{"id":2194308,"uuid":"3142458","full_name":"pfultz2/Pino","owner":"pfultz2","description":"Python template preprocessor","archived":false,"fork":false,"pushed_at":"2014-02-08T19:17:55.000Z","size":750,"stargazers_count":16,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-26T07:11:19.055Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"CheckiO-Missions/checkio-task-number-guess","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pfultz2.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-01-10T03:44:55.000Z","updated_at":"2018-02-26T09:06:38.000Z","dependencies_parsed_at":"2022-08-20T09:50:50.726Z","dependency_job_id":null,"html_url":"https://github.com/pfultz2/Pino","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfultz2%2FPino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfultz2%2FPino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfultz2%2FPino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfultz2%2FPino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pfultz2","download_url":"https://codeload.github.com/pfultz2/Pino/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248566538,"owners_count":21125681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T12:51:37.900Z","updated_at":"2025-10-23T23:46:29.394Z","avatar_url":"https://github.com/pfultz2.png","language":"Python","readme":"# Pino\n\n## Python template preprocessor\n\nPino is a template preprocessor that is designed to integrate easily with C-like languages(such as C, C++, C#, and Java). To process a file called \"myfile.template.c\" and output it to \"myfile.c\" just call:\n```\npino.py myfile.template.c myfile.c\n```\nIf your file is called \"myfile.pino.c\" then you can just call it like this:\n```\npino.py myfile.pino.c\n```\nAnd pino will remove the \".pino\" extension, and output a to a file called \"myfile.c\".\n\n## Getting Started\n\nThe dollar sign($) is used to signal the preprocessor. There are two types of syntaxes, expressions and blocks. A python expression is evaluated by calling:\n```Javascript\n$(\"hello\")\n```\nBlocks allow flow control, such as:\n```Javascript\n$if i is 5\n{\n    hello\n}\n```\nHere is an example that creates a class that has 5 variables:\n```Javascript\nclass foo\n{\n    $for i in range(5)\n    {\n        int x$(i);\n    }\n};\n```\nThis will output:\n```Javascript\nclass foo\n{\n        int x0;\n        int x1;\n        int x2;\n        int x3;\n        int x4;\n};\n```\n\n# How it works\n\n## Overview\n\nPino evaluates python expressions in your source code. Thus, when it finds `$()`, it will evaluate whats inside of the parenthesis, and output that to the file. For example, if you type `$(\"hello\")` it will output `hello` without the quotes to the file. If you want to output `\"hello\"` with quotes you can type `$(quote(\"hello\"))`. Now to process the file just add \".pino\" extension to your file. Pino will process the file, and output to the same file name with the extension removed. So a file named \"foo.cpp.pino\" will be processed and outputted to \"foo.cpp\".\n\n## Flow control\n\nFlow control can be done using `if` and `for` statements\". Here is the syntax for an `if` statement:\n```Javascript\n$if conditional { output }\n```\nIf the conditional is true then whatever is in the curly braces will be outputted. If it is not true, then nothing will be outputted. The conditional is a python expression. Right now, `else` clauses are not supported. Here is the syntax for the `for` statement:\n```Javascript\n$for var in sequence { output }\n```\nEvery time the `for` loop is run, it will output what's in the curly braces. The `for` loop is evaluated from a python `for` loop.\n\n## Python config file\n\nIf you want to define python variables and functions to be used in the python file, you can create a python file and pass it into pino like this:\n```\npino.py --config=myconfig.py myfile.template.c myfile.c\n```\nAny variables or functions define in \"myconfig.py\" will be accessible during processing of the \"myfile.template.c\" file. For example, if we defined a \"template.py\" file like this:\n```Python\nclass_name = \"foo\"\nnumber_of_vars = 5\n```\nThen if the \"MyTemplate.pino.h\" file was defined like this:\n```Javascript\nclass $(class_name)\n{\n    $for i in range(number_of_vars)\n    {\n        int x$(i);\n    }\n};\n```\nYou can process the template using pino by calling this:\n```\npino.py --config=template.py MyTemplate.pino.h\n```\nThen pino will generate a file called \"MyTemplate.h\" with this output:\n```Javascript\nclass foo\n{\n        int x0;\n        int x1;\n        int x2;\n        int x3;\n        int x4;\n};\n```\n\n## Multiple Files\n\nInstead of specifying input and output files on the command line, the files to be processed can be specified in the python config file instead. This lets you specify multiple files at once. To specify multiple files, just define an list called `templates` that contains a tuple with the template file to be processed and the name of the output file, like this:\n```Python\ntemplates = [(\"MyTemplateHeader.h\", \"MyHeader.h\"), (\"MyTemplateSrc.cpp\", \"MySrc.cpp\")]\n```\nThis will process each file in the `templates` list, and any variables defined in this file will be accessible during processing.  So, for example, if you wrote a \"template.py\" file define like this:\n```Python\ntemplates = [(\"MyTemplate.h\", \"MyHeader.h\")]\nclass_name = \"foo\"\nnumber_of_vars = 5\n```\nThen if the \"MyTemplate.h\" file was defined like this:\n```Javascript\nclass $(class_name)\n{\n    $for i in range(number_of_vars)\n    {\n        int x$(i);\n    }\n};\n```\nTo process the files specified by the `templates` list, you must pass in just the config file without any input or output files, like this:\n```\npino.py --config=template.py\n```\nThen pino will generate a file called \"MyHeader.h\" with this output:\n```Javascript\nclass foo\n{\n        int x0;\n        int x1;\n        int x2;\n        int x3;\n        int x4;\n};\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfultz2%2Fpino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpfultz2%2Fpino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfultz2%2Fpino/lists"}