fusetools.text_tools.Export

class fusetools.text_tools.Export[source]

Bases: object

Functions for exporting Python text objects.

Methods

concat_text_files

Concatenates contents of specified files into a target file and saves it.

dump_json

Exports a Python dictionary object to a JSON file.

dump_sql

Exports a Python string object to a SQL file.

find_replace_text

Finds and replaces a string in all text files in a target folder.

classmethod concat_text_files(input_files, output_file)[source]

Concatenates contents of specified files into a target file and saves it.

Parameters
  • input_files – List of text files to concatenate.

  • output_file – Target output file.

Returns

Concatenated target output file.

classmethod dump_json(obj, filepath)[source]

Exports a Python dictionary object to a JSON file.

Parameters
  • obj – Python dictionary object.

  • filepath – Filepath to save object to.

Returns

Exported JSON file.

classmethod dump_sql(obj, filepath)[source]

Exports a Python string object to a SQL file.

Parameters
  • obj – Python string object.

  • filepath – Filepath to save object to.

Returns

Exported SQL file.

classmethod find_replace_text(directory, find, replace, file_pattern, specific_file=False)[source]

Finds and replaces a string in all text files in a target folder.

Parameters
  • directory – Target folder containing files.

  • find – String to search for.

  • replace – New string to replace with.

  • file_pattern – Pattern of text files to scan.

Returns

Saved files with replaced text.