|
GeometrizeTwitterBot
1.0
Python Twitter bot for geometrizing images into geometric primitives
|
Module that interfaces with the Geometrize executable, composing and executing scripts on it to geometrize images.
More...
Module that interfaces with the Geometrize executable, composing and executing scripts on it to geometrize images.
◆ _compose_image_path()
def geometrize._compose_image_path |
( |
|
filename | ) |
|
|
private |
◆ _load_image()
def geometrize._load_image |
( |
|
filepath | ) |
|
|
private |
Loads up an image from the given filepath.
:return The loaded image, or None if the image failed to load.
26 print(
"Loading image from: " + filepath)
28 image = Image.open(filepath)
30 print(
"Failed to load image")
◆ _run_geometrize_code()
def geometrize._run_geometrize_code |
( |
|
code | ) |
|
|
private |
Executes the given script source code.
:return The Geometrize process return code, 0 indicates success.
16 script_inline_flag =
"--script_inline"
17 return call([executable_path, script_inline_flag, code])
◆ run_geometrize()
def geometrize.run_geometrize |
( |
|
code, |
|
|
|
tags = None |
|
) |
| |
Executes the given script source code.
:return True if the script executed successfully, else false.
40 print(
"Script has template tags that have not been replaced, will fail rather than run script")
43 print(
"Will run script")
48 print(
"Failed to execute test script")
◆ test_geometrize()
def geometrize.test_geometrize |
( |
| ) |
|
Performs some basic tests to ensure that Geometrize can run scripts and turn images into shapes properly.
:return True if the tests executed successfully, else false.
56 print(
"Loading test script")
59 print(
"Failed to read test script, test will fail")
65 print(
"Loading input image")
67 if input_image
is None:
68 print(
"Failed to read the input image, test script will fail")
71 print(
"Replacing script tags")
79 print(
"Failed to replace all template tags in script, script will fail")
83 print(
"Failed to replace all template tags in script, script will fail")
89 print(
"Failed to execute test script")
92 print(
"Checking if the test script saved the result image correctly")
95 if output_image
is None:
96 print(
"Failed to read the resulting geometrized image, test script will fail")
99 print(
"Printing input image to console\r\n")
102 print(
"Printing Geometrized image to console\r\n")
def get_geometrize_executable_path()
Gets the absolute path to where we expect to find the Geometrize executable.
Definition: dependency_locator.py:28
def test_geometrize()
Performs some basic tests to ensure that Geometrize can run scripts and turn images into shapes prope...
Definition: geometrize.py:55
def print_image_to_console(img)
Definition: image_console_printer.py:82
def _compose_image_path(filename)
Definition: geometrize.py:19
def run_geometrize(code, tags=None)
Executes the given script source code.
Definition: geometrize.py:35
def replace_tag(code, tag, value)
Replaces all instances of a template ::TAG:: in the given code with the given value.
Definition: script_wrangler.py:8
def get_geometrize_image_file_absolute_path(filename)
Composes an absolute path for an image file in the image data folder.
Definition: dependency_locator.py:42
def code_contains_tags(code)
Returns true if the given code contains any ::TAG::s, else false.
Definition: script_wrangler.py:27
def _load_image(filepath)
Loads up an image from the given filepath.
Definition: geometrize.py:24
def _run_geometrize_code(code)
Executes the given script source code.
Definition: geometrize.py:14
def replace_tags(code, dict)
Replaces all instances of template ::TAG::s in the code from the given dictionary with their correspo...
Definition: script_wrangler.py:12
def read_geometrize_script(filename)
Reads a Chaiscript script file out of the Twitter bot scripts folder, returning the text content of t...
Definition: dependency_locator.py:63