GeometrizeTwitterBot  1.0
Python Twitter bot for geometrizing images into geometric primitives
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 (code, tag, value)
 Replaces all instances of a template ::TAG:: in the given code with the given value. More...
 
def replace_tags (code, dict)
 Replaces all instances of template ::TAG::s in the code from the given dictionary with their corresponding values. More...
 
def find_tags (code)
 Returns a set of all the template ::TAG::s found in the given code. More...
 
def code_contains_tags (code)
 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

◆ code_contains_tags()

def script_wrangler.code_contains_tags (   code)

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

27 def code_contains_tags(code):
28  return find_tags == set()
Here is the caller graph for this function:

◆ find_tags()

def script_wrangler.find_tags (   code)

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

18 def find_tags(code):
19  tag_set = set()
20 
21  for match in re.finditer(r"::(.+?)::", code):
22  tag_set.add(match.group())
23 
24  return tag_set
25 

◆ replace_tag()

def script_wrangler.replace_tag (   code,
  tag,
  value 
)

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

8 def replace_tag(code, tag, value):
9  return code.replace(tag, value)
10 
Here is the caller graph for this function:

◆ replace_tags()

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 def replace_tags(code, dict):
13  for key, value in dict.items():
14  code = replace_tag(code, key, value)
15  return code
16 
Here is the call graph for this function:
Here is the caller graph for this function:
script_wrangler.replace_tag
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
script_wrangler.code_contains_tags
def code_contains_tags(code)
Returns true if the given code contains any ::TAG::s, else false.
Definition: script_wrangler.py:27
script_wrangler.find_tags
def find_tags(code)
Returns a set of all the template ::TAG::s found in the given code.
Definition: script_wrangler.py:18
script_wrangler.replace_tags
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