GeometrizeTwitterBot  1.0 Python Twitter bot for geometrizing images into geometric primitives
dependency_locator Namespace Reference

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

## Functions

def _get_geometrize_absolute_path
Gets an absolute path to where we expect to find 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...

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

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_absolute_path ( )
private

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

11  baseDir = os.path.normpath(os.path.join(os.path.dirname(__file__), "../geometrize/")).replace('\\', '/')
12
13  possibleExecutables = [name for name in os.listdir(baseDir) if re.match(r'[G|g]eometrize.*', name)]
14
15  if len(possibleExecutables) > 1:
16  print("Warning, found multiple Geometrize executables: " + str(possibleExecutables))
17
18  if not possibleExecutables:
19  print("Failed to find a path to the Geometrize executable")
20  if platform == "linux" or platform == "linux2" or platform == "darwin" or platform == "win32":
21  return baseDir + "/" + possibleExecutables
22  else:
23  print("Warning, the Geometrize bot might not work on this OS")
24
25  return baseDir + "/" + possibleExecutables
26
def _get_geometrize_absolute_path
Gets an absolute path to where we expect to find the Geometrize executable.
Definition: dependency_locator.py:9

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.

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

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.

def get_geometrize_executable_path
Gets the absolute path to where we expect to find the Geometrize executable.
Definition: dependency_locator.py:28
def _get_geometrize_absolute_path
Gets an absolute path to where we expect to find the Geometrize executable.
Definition: dependency_locator.py:9

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.

44  filepath = os.path.normpath(os.path.join(get_geometrize_image_folder_absolute_path(), filename)).replace('\\', '/')
45  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:42
def get_geometrize_image_folder_absolute_path
Returns the absolute path the bot image data folder.
Definition: dependency_locator.py:37

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.

39  baseDir = os.path.dirname(__file__)
40  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:37

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.

49  baseDir = os.path.dirname(__file__)
50  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:47

Here is the caller graph for this function: 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.

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

Here is the call graph for this function: Here is the caller graph for this function: 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.
{"ft_lang_label":"__label__en","ft_lang_prob":0.5635126,"math_prob":0.6033527,"size":2489,"snap":"2020-34-2020-40","text_gpt3_token_len":570,"char_repetition_ratio":0.17625755,"word_repetition_ratio":0.5625,"special_character_ratio":0.2057051,"punctuation_ratio":0.16622691,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9742232,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],"im_url_duplicate_count":[null,null,null,2,null,3,null,3,null,3,null,3,null,3,null,3,null,3,null,3,null,3,null,3,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-08-11T22:42:49Z\",\"WARC-Record-ID\":\"<urn:uuid:605d9109-1013-4882-8adf-4b19ec27cf62>\",\"Content-Length\":\"49505\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:0df8c435-392f-47f1-b100-119ad89d2189>\",\"WARC-Concurrent-To\":\"<urn:uuid:7d819312-9688-4e23-a815-c79e559e97cd>\",\"WARC-IP-Address\":\"185.199.110.153\",\"WARC-Target-URI\":\"http://botdocs.geometrize.co.uk/namespacedependency__locator.html\",\"WARC-Payload-Digest\":\"sha1:GRWXQ5WR7SPJXBTXD5H5RPFUZXIBUQEK\",\"WARC-Block-Digest\":\"sha1:POE4MGY6HBTQTSMNUMTWTCMO4ZACRNFV\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-34/CC-MAIN-2020-34_segments_1596439738855.80_warc_CC-MAIN-20200811205740-20200811235740-00214.warc.gz\"}"}