Helpers

Gensty helpers. A collection of functions to manipulate strings, search for files and create folders.

gensty.helpers.ReplaceToken(dict_replace, target)[source]

ReplaceToken. Based on dict, replaces key with the value on the target.

Parameters
  • dict_replace (dict) – Dictionary includes tokens to replace.

  • target (str) – String to be replced.

Returns

String with provided parameters from tokens.

Return type

str

gensty.helpers.checkExtension(path, ext)[source]

checkExtension. Defines if a file exists and having the given extension.

Parameters
  • path (str) – File path to check.

  • ext (str) – File extension.

Returns

True in case extension is correct.

Return type

bool

gensty.helpers.checkFont(path, supported_fonts=[])[source]

checkFont. Checks the provided file has one fo the supported extensions.

Parameters
  • path (str) – File path to check.

  • supported_fonts (list) – Supported fonts extensions

Returns

True in case font exists.

Return type

bool

gensty.helpers.createDir(dir)[source]

createDir. Forces directory creation by removing any pre-existing folder with same name.

Parameters

dir (str) – Directory to create.

gensty.helpers.findByExt(path, ext)[source]

findByExt.Finds file by extension. Returns list.

Parameters
  • path (str) – File path to check.

  • ext (str) – File extension.

Returns

A list of files having the given ext or False.

Return type

Union[List[str], bool]

gensty.helpers.fixString(s)[source]

fixString. Changes a string usually package or font name, so it can be use in LaTeX and parsed without issue.

Parameters

s (str) – String to be fixed.

Return type

str

gensty.helpers.getFontsByType(path, supported_fonts=[])[source]

getFontsByType. Gets supported fonts by file extesion in a given folder.

Parameters
  • path (str) – Directory includes fonts.

  • supported_fonts (list) – A list of supported fonts (extensions)

Returns

File paths of supported fonts.

Return type

List[str]

gensty.helpers.isFontPath(path)[source]

Checks if the path is file or folder. In case of folder returns all included fonts.

gensty.helpers.writePackage(filename, content)[source]

writePackage. Writes Style file.

Parameters
  • filename (str) – Filename for newely created file.

  • content (str) – Content of the LaTeX package.