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

Module with functionality for locating the Geometrize executable and other dependencies. More...

Functions

def _get_geometrize_relative_path
 Gets a relative path to the Geometrize executable. More...
 
def get_geometrize_executable_path
 Gets the absolute path to where we expect to find the Geometrize executable. More...
 
def geometrize_executable_exists
 Checks if the Geometrize executable exists. More...
 
def get_geometrize_image_folder_absolute_path
 Returns the absolute path the bot image data folder. More...
 
def get_geometrize_image_file_absolute_path
 Composes an absolute path for an image file in the image data folder. More...
 
def get_geometrize_script_folder_absolute_path
 Gets an absolute path to the bot scripts folder. More...
 
def read_script_file
 Reads a Chaiscript script file at the given location, returning the text content of the file. More...
 
def read_geometrize_script
 Reads a Chaiscript script file out of the Twitter bot scripts folder, returning the text content of the file. More...
 

Detailed Description

Module with functionality for locating the Geometrize executable and other dependencies.

Function Documentation

def dependency_locator._get_geometrize_relative_path ( )
private

Gets a relative path to the Geometrize executable.

8 
10  if platform == "linux" or platform == "linux2":
11  return "../geometrize/Geometrize"
12  elif platform == "darwin":
13  return "../geometrize/Geometrize.app"
14  elif platform == "win32":
15  return "../geometrize/Geometrize.exe"
16  else:
17  print("Warning, the Geometrize bot might not work on this OS")
18  return "../geometrize/Geometrize"
def _get_geometrize_relative_path
Gets a relative path to the Geometrize executable.
Definition: dependency_locator.py:8

Here is the caller graph for this function:

def dependency_locator.geometrize_executable_exists ( )

Checks if the Geometrize executable exists.

Returns true if the Geometrize executable exists at the expected location, else false.

27 
29  return os.path.exists(get_geometrize_executable_path())
def geometrize_executable_exists
Checks if the Geometrize executable exists.
Definition: dependency_locator.py:27
def get_geometrize_executable_path
Gets the absolute path to where we expect to find the Geometrize executable.
Definition: dependency_locator.py:20

Here is the call graph for this function:

def dependency_locator.get_geometrize_executable_path ( )

Gets the absolute path to where we expect to find the Geometrize executable.

20 
22  relative_path = _get_geometrize_relative_path()
23  baseDir = os.path.dirname(__file__)
24  return os.path.normpath(os.path.join(baseDir, _get_geometrize_relative_path())).replace('\\', '/')
def _get_geometrize_relative_path
Gets a relative path to the Geometrize executable.
Definition: dependency_locator.py:8
def get_geometrize_executable_path
Gets the absolute path to where we expect to find the Geometrize executable.
Definition: dependency_locator.py:20

Here is the call graph for this function:

Here is the caller graph for this function:

def dependency_locator.get_geometrize_image_file_absolute_path (   filename)

Composes an absolute path for an image file in the image data folder.

36 
38  filepath = os.path.normpath(os.path.join(get_geometrize_image_folder_absolute_path(), filename)).replace('\\', '/')
39  return filepath
def get_geometrize_image_file_absolute_path
Composes an absolute path for an image file in the image data folder.
Definition: dependency_locator.py:36
def get_geometrize_image_folder_absolute_path
Returns the absolute path the bot image data folder.
Definition: dependency_locator.py:31

Here is the call graph for this function:

Here is the caller graph for this function:

def dependency_locator.get_geometrize_image_folder_absolute_path ( )

Returns the absolute path the bot image data folder.

31 
33  baseDir = os.path.dirname(__file__)
34  return os.path.normpath(os.path.join(baseDir, "../image_data/")).replace('\\', '/')
def get_geometrize_image_folder_absolute_path
Returns the absolute path the bot image data folder.
Definition: dependency_locator.py:31

Here is the caller graph for this function:

def dependency_locator.get_geometrize_script_folder_absolute_path ( )

Gets an absolute path to the bot scripts folder.

41 
43  baseDir = os.path.dirname(__file__)
44  return os.path.normpath(os.path.join(baseDir, "../script/")).replace('\\', '/')
def get_geometrize_script_folder_absolute_path
Gets an absolute path to the bot scripts folder.
Definition: dependency_locator.py:41

Here is the caller graph for this function:

def dependency_locator.read_geometrize_script (   filename)

Reads a Chaiscript script file out of the Twitter bot scripts folder, returning the text content of the file.

:return An empty string if we failed to read the script.

57 
58 def read_geometrize_script(filename):
59  filepath = os.path.normpath(os.path.join(get_geometrize_script_folder_absolute_path(), filename)).replace('\\', '/')
return read_script_file(filepath)
def read_geometrize_script
Reads a Chaiscript script file out of the Twitter bot scripts folder, returning the text content of t...
Definition: dependency_locator.py:57
def get_geometrize_script_folder_absolute_path
Gets an absolute path to the bot scripts folder.
Definition: dependency_locator.py:41
def read_script_file
Reads a Chaiscript script file at the given location, returning the text content of the file...
Definition: dependency_locator.py:47

Here is the call graph for this function:

Here is the caller graph for this function:

def dependency_locator.read_script_file (   filepath)

Reads a Chaiscript script file at the given location, returning the text content of the file.

:return An empty string if we failed to read the script.

47 
48 def read_script_file(filepath):
49  with open(filepath, 'r') as content_file:
50  content = content_file.read()
51  return content
52 
53  print("Failed to read Geometrize script at: " + filepath)
54  return ""
def read_script_file
Reads a Chaiscript script file at the given location, returning the text content of the file...
Definition: dependency_locator.py:47

Here is the caller graph for this function: