Module Documentation¶
builder¶
Builder reads and executes tasks and lists of tasks.
-
laforge.builder.
run_build
(script_path, *, log, debug=False, dry_run=False)[source]¶ laforge’s core build command
-
class
laforge.builder.
FileCall
(method, kwargs)¶ -
property
kwargs
¶ Alias for field number 1
-
property
method
¶ Alias for field number 0
-
property
-
class
laforge.builder.
TaskList
(from_string, location='.')[source]¶ Todo
Implement cache_results=False
-
class
laforge.builder.
BaseTask
(*, identifier, verb, target, content, config)[source]¶ Create a task to (verb) (something)
Todo
- if “:” in self.content:
previous_result_key, actual_path_content = self.content.split(“:”)
-
property
path
¶ For handlers where dir[verb] + content = path
-
class
laforge.builder.
InternalPythonExecutor
(*, identifier, verb, target, content, config)[source]¶ Execute (without importing) Python script by path
This will set
__main__ = 'laforge'
..todo
Allow implict/explicit return of results.
command¶
Command-line interface for laforge.
sql¶
SQL utilities for mid-level interaction. Inspired by pathlib; powered by SQLALchemy.
Note
Supported: MSSQL, MariaDB/MySQL, PostgreSQL, SQLite. Supportable: Firebird, Oracle, Sybase.
-
class
laforge.sql.
Channel
(distro, *, server=None, database=None, schema=None, **engine_kwargs)[source]¶ Abstraction from Engine, other static details.
-
laforge.sql.
execute
(statement, fetch=False, channel=None)[source]¶ Convenience method, autofetches Channel if possible
-
class
laforge.sql.
Script
(query, channel=None)[source]¶ SQL query string, parsable by ‘go’ separation and execute()able.
-
to_table
()[source]¶ Executes all and tries to return a DataFrame for the result of the final query.
This is one of two ways that laforge retrieves tables.
Warning
This is limited by the capacity of Pandas to retrieve only the final result. For Microsoft SQL Server, if a lengthy set of queries is desired, the most reliable approach appears to be a single final query after a ‘go’ as a batch gterminator.
Warning
This will rename columns that do not conform to naming standards.
-
-
class
laforge.sql.
Table
(name, channel=None, **kwargs)[source]¶ Represents a SQL table, featuring methods to read/write DataFrames.
Todo
Factor out to superclass to allow views
tech¶
toolbox¶
Handful of utility functions
Note
These intentionally only depend on builtins.
Note
Some copyright information within this file is identified per-block below.
-
laforge.toolbox.
round_up
(n, nearest=1)[source]¶ Round up
n
to the nearestnearest
.- Parameters
n –
nearest – (Default value = 1)
-
laforge.toolbox.
prepare_to_access
(path)[source]¶ Make directory exist and verify that file would be writable
-
laforge.toolbox.
verify_file_is_writable
(path, retry_attempts=3, retry_seconds=5)[source]¶ Check for locked file (e.g. Excel has CSV open)
-
laforge.toolbox.
flatten
(foo)[source]¶ Take any set of nests in an iterator and reduce it into one generator.
‘Nests’ include any iterable except strings.
- Parameters
foo –
Note
flatten()
was authored by Amber Yust at https://stackoverflow.com/a/5286571. This function is not claimed under the laforge license.