Documentation for GeneralUtils.py

Warning: This documentation was generated from the comments in the source code (using progrutils.documentPyFile()), with a few tweaks, under the principle that poor documentation is better than no documentation. In case of ambiguity, please refer to the code itself.

 

General Utilities, v.1.0

By Épiméthée

Some general-purpose helper functions which aren't really specific to Freedom Force.

 


Generic manipulation


getUniquesElements(listA,listB)

Returns a string, list or tuple of elements present only in the first of two strings, lists, tuples or dictionary keys


Dictionaries manipulations


makeDict(k, v)

Returns a dictionary from two lists

invertDict(myDict)

Returns a copy of a dictionary with keys as values and vice-versa


Lists and tuples manipulations


listAdd(listVar, listValue)

Adds an element to a persistent list using the missionobjvar module.
Also adds the element to a global variable list for faster access.

listRemove(listVar, listValue)

Removes an element from a persistent list using the missionobjvar module.
Also removes the element from its global variable list.

sequenceToString(theVar, delimiter = ' ')

Convert a tuple or a list to a string. Arrays and dictionaries are not supported.
Added FFX 3.2. Replaces tupleToString().


strings manipulations


cleanUpString(originalString)

Returns a version of a string containing only lowercase a-z and 0-1 characters. Could be useful for identifying that "Spider-Man", "spider_man" and "spiderman" refer to the same basic character.

stringToTuple(theVar, delimiter = ' ')

Convert a string to a tuple

stringToList(theVar, delimiter = ' ')

Converts string back to a list of strings, integers and float.
IMPORTANT: Other data types (variables, long integers, etc.) are not supported.; they' ll be converted to one of the above three types.


numbers manipulations


isDifferenceAcceptable(x, y, maxDifference = 1)

Is number x's value close enough to number y's?