GeometrizeTwitterBot  1.0
Python Twitter bot for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables
Functions
script_wrangler Namespace Reference

This module contains code that manipulates ChaiScript template scripts before they can be executed by Geometrize. More...

Functions

def replace_tag
 Replaces all instances of a template ::TAG:: in the given code with the given value. More...
 
def replace_tags
 Replaces all instances of template ::TAG::s in the code from the given dictionary with their corresponding values. More...
 
def find_tags
 Returns a set of all the template ::TAG::s found in the given code. More...
 
def code_contains_tags
 Returns true if the given code contains any ::TAG::s, else false. More...
 

Detailed Description

This module contains code that manipulates ChaiScript template scripts before they can be executed by Geometrize.

The main purpose is to find and replace tags in scripts e.g. ::IMAGE_INPUT_PATH:: to "path/to/image.png"

Function Documentation

def script_wrangler.code_contains_tags (   code)

Returns true if the given code contains any ::TAG::s, else false.

27 
28 def code_contains_tags(code):
return find_tags == set()
def code_contains_tags
Returns true if the given code contains any ::TAG::s, else false.
Definition: script_wrangler.py:27

Here is the caller graph for this function:

def script_wrangler.find_tags (   code)

Returns a set of all the template ::TAG::s found in the given code.

18 
19 def find_tags(code):
20  tag_set = set()
21 
22  for match in re.finditer(r"::(.+?)::", code):
23  tag_set.add(match.group())
24 
25  return tag_set
def find_tags
Returns a set of all the template ::TAG::s found in the given code.
Definition: script_wrangler.py:18
def script_wrangler.replace_tag (   code,
  tag,
  value 
)

Replaces all instances of a template ::TAG:: in the given code with the given value.

8 
9 def replace_tag(code, tag, value):
10  return code.replace(tag, value)
def replace_tag
Replaces all instances of a template ::TAG:: in the given code with the given value.
Definition: script_wrangler.py:8

Here is the caller graph for this function:

def script_wrangler.replace_tags (   code,
  dict 
)

Replaces all instances of template ::TAG::s in the code from the given dictionary with their corresponding values.

12 
13 def replace_tags(code, dict):
14  for key, value in dict.items():
15  code = replace_tag(code, key, value)
16  return code
def replace_tag
Replaces all instances of a template ::TAG:: in the given code with the given value.
Definition: script_wrangler.py:8
def replace_tags
Replaces all instances of template ::TAG::s in the code from the given dictionary with their correspo...
Definition: script_wrangler.py:12

Here is the call graph for this function:

Here is the caller graph for this function: