Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions autogenfiles/autogenfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
from .files_helper import prepare_output_path_dir, read_template


def run(variables: dict, output_path: str):
def run(templates_path: str, variables: dict, output_path: str):
"""Runs the logic for generating rendered templates outcome

Params:
:dir_name: str, Required
:templates_path: str, Optional
Path to the templates directory
:variables: str, Optional
Dictionary with all the variables to be injected on the templates
:output_path: str, Required
Name of output directory
"""
# avoids problem with concats without trailling slash
Expand All @@ -26,7 +30,7 @@ def run(variables: dict, output_path: str):
# makes sure output dir exists to avoid FileNotFound error
prepare_output_path_dir(output_path)

file_list, subfolders, dir_size = prepare_files_and_subfolders()
file_list, subfolders, dir_size = prepare_files_and_subfolders(templates_path)

if subfolders:
create_subfolder_structure(subfolders, output_path)
Expand All @@ -35,9 +39,9 @@ def run(variables: dict, output_path: str):
# makes sure I have correct file names for subfolder structure
if dir_size == 1:
file_name = f
f = f'templates/{f}'
f = f'{templates_path}/{f}'
else:
file_name = f.split('templates/')[1]
file_name = f.split(f'{templates_path}')[1]
template = read_template(f)

# create templates
Expand All @@ -55,11 +59,13 @@ def run(variables: dict, output_path: str):


@click.command()
@click.option('-t', '--templates-path', default='templates/',
help='A custom templates path. Default is `./templates`')
@click.option('-v', '--variable-list', default='variables.yaml',
help='Name of the yaml files containing variables')
@click.option('-o', '--output-path', default='./',
help='Output path, by default writes to root')
def AutoGenFiles(variable_list, output_path):
def AutoGenFiles(templates_path, variable_list, output_path):
"""CLI"""
print(f'Output path: {output_path}')
# read variables to substitute
Expand All @@ -72,5 +78,5 @@ def AutoGenFiles(variable_list, output_path):
return
click.echo(f'Variables found: {list(variables.keys())}')

run(variables, output_path)
run(templates_path, variables, output_path)
click.echo('Output fully written')
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ build==0.5.1
ipython==7.31.1
pycodestyle==2.7.0
pytest==6.2.4
Sphinx==4.1.1
Sphinx==7.2.6
Binary file modified docs/build/doctrees/API.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/build/doctrees/index.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/usage.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 7ddcc93c3d9f4799a2b495f01affb8e4
config: fd285bc0b62a59d3d225e89af3060393
tags: 645f666f9bcd5a90fca523b33c5a78b7
72 changes: 39 additions & 33 deletions docs/build/html/API.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/build/html/_sources/usage.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ And add the following content:
project_number = 42
project_description = Generate files from templates

Now run autogenfiles:
AutoGenFiles needs a variables section to work. Now run autogenfiles:

.. code-block:: console

Expand Down
4 changes: 3 additions & 1 deletion docs/build/html/_static/alabaster.css
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@ table.footnote td {
}

dl {
margin: 0;
margin-left: 0;
margin-right: 0;
margin-top: 0;
padding: 0;
}

Expand Down
77 changes: 49 additions & 28 deletions docs/build/html/_static/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Sphinx stylesheet -- basic theme.
*
* :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
* :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
Expand Down Expand Up @@ -222,7 +222,7 @@ table.modindextable td {
/* -- general body styles --------------------------------------------------- */

div.body {
min-width: 450px;
min-width: 360px;
max-width: 800px;
}

Expand All @@ -237,14 +237,8 @@ a.headerlink {
visibility: hidden;
}

a.brackets:before,
span.brackets > a:before{
content: "[";
}

a.brackets:after,
span.brackets > a:after {
content: "]";
a:visited {
color: #551A8B;
}

h1:hover > a.headerlink,
Expand Down Expand Up @@ -335,12 +329,16 @@ p.sidebar-title {
font-weight: bold;
}

nav.contents,
aside.topic,
div.admonition, div.topic, blockquote {
clear: left;
}

/* -- topics ---------------------------------------------------------------- */

nav.contents,
aside.topic,
div.topic {
border: 1px solid #ccc;
padding: 7px;
Expand Down Expand Up @@ -379,13 +377,17 @@ div.body p.centered {

div.sidebar > :last-child,
aside.sidebar > :last-child,
nav.contents > :last-child,
aside.topic > :last-child,
div.topic > :last-child,
div.admonition > :last-child {
margin-bottom: 0;
}

div.sidebar::after,
aside.sidebar::after,
nav.contents::after,
aside.topic::after,
div.topic::after,
div.admonition::after,
blockquote::after {
Expand Down Expand Up @@ -428,10 +430,6 @@ table.docutils td, table.docutils th {
border-bottom: 1px solid #aaa;
}

table.footnote td, table.footnote th {
border: 0 !important;
}

th {
text-align: left;
padding-right: 5px;
Expand Down Expand Up @@ -615,19 +613,26 @@ ul.simple p {
margin-bottom: 0;
}

dl.footnote > dt,
dl.citation > dt {
aside.footnote > span,
div.citation > span {
float: left;
margin-right: 0.5em;
}

dl.footnote > dd,
dl.citation > dd {
aside.footnote > span:last-of-type,
div.citation > span:last-of-type {
padding-right: 0.5em;
}
aside.footnote > p {
margin-left: 2em;
}
div.citation > p {
margin-left: 4em;
}
aside.footnote > p:last-of-type,
div.citation > p:last-of-type {
margin-bottom: 0em;
}

dl.footnote > dd:after,
dl.citation > dd:after {
aside.footnote > p:last-of-type:after,
div.citation > p:last-of-type:after {
content: "";
clear: both;
}
Expand All @@ -644,10 +649,6 @@ dl.field-list > dt {
padding-right: 5px;
}

dl.field-list > dt:after {
content: ":";
}

dl.field-list > dd {
padding-left: 0.5em;
margin-top: 0em;
Expand All @@ -673,6 +674,16 @@ dd {
margin-left: 30px;
}

.sig dd {
margin-top: 0px;
margin-bottom: 0px;
}

.sig dl {
margin-top: 0px;
margin-bottom: 0px;
}

dl > dd:last-child,
dl > dd:last-child > :last-child {
margin-bottom: 0;
Expand Down Expand Up @@ -731,15 +742,24 @@ dl.glossary dt {

.classifier:before {
font-style: normal;
margin: 0.5em;
margin: 0 0.5em;
content: ":";
display: inline-block;
}

abbr, acronym {
border-bottom: dotted 1px;
cursor: help;
}

.translated {
background-color: rgba(207, 255, 207, 0.2)
}

.untranslated {
background-color: rgba(255, 207, 207, 0.2)
}

/* -- code displays --------------------------------------------------------- */

pre {
Expand All @@ -756,6 +776,7 @@ span.pre {
-ms-hyphens: none;
-webkit-hyphens: none;
hyphens: none;
white-space: nowrap;
}

div[class*="highlight-"] {
Expand Down
Loading