plasoscaffolder.common package

Submodules

plasoscaffolder.common.base_code_formatter module

Base code formatter.

class plasoscaffolder.common.base_code_formatter.BaseCodeFormatter[source]

Bases: object

Base class representing the base class for the code formatter.

Format(code: str) → str[source]

Formats the code.

Parameters:code (str) – the code to format
Returns:the formatted code.
Return type:str

plasoscaffolder.common.base_file_handler module

Base file handler.

class plasoscaffolder.common.base_file_handler.BaseFileHandler[source]

Bases: object

Base class representing the base class for the file handler.

AddContent(source: str, content: str) → str[source]

Add content to a file and create file if non existing.

Parameters:
  • source (str) – The path of the file to edit.
  • content (str) – The content to append to the file.
Returns:

the path of the edited file.

Return type:

str

CopyFile(source: str, destination: str) → str[source]

Copies a file.

Parameters:
  • source (str) – path of the file to copy
  • destination (str) – path to copy the file to.
Returns:

the path of the copied file

Return type:

str

CreateFile(directory_path: str, file_name: str, filename_suffix: str)[source]

Creates an empty file.

Parameters:
  • directory_path (str) – The path to the directory the file should be created.
  • file_name (str) – the name of the new file.
  • filename_suffix (str) – the suffix of the new file.
Returns:

the path of the created file

Return type:

str

CreateFileFromPath(file_path: str) → str[source]

Creates a empty file.

Parameters:file_path (str) – the path to the file.
Returns:the path of the created file
Return type:str
classmethod CreateFilePath(path: str, name: str, suffix: str) → str[source]

Creates the file path out of the directory path, filename and suffix.

Parameters:
  • path (str) – the path to the file directory
  • name (str) – the filename
  • suffix (str) – the suffix
Returns:

the joined path to the file

Return type:

str

CreateFolderForFilePathIfNotExist(file_path: str)[source]

Creates folders for the given file if it does not exist.

Parameters:file_path (str) – the path to the file
Returns:the directory path of the created directory
Return type:str
CreateOrModifyFileWithContent(source: str, content: str)[source]

Add content to file or modify file and create folder if they don’t exist.

Parameters:
  • source (str) – the file to edit / create
  • content (str) – the content to add to the file

plasoscaffolder.common.base_output_handler module

base output handler

class plasoscaffolder.common.base_output_handler.BaseOutputHandler[source]

Bases: object

Base class representing the Base class for the output handler class

Confirm(text: str, default=True, abort=True)[source]

Ask for a confirmation, either yes or no to a question.

Parameters:
  • text (str) – prompts the user for a confirmation, with the given test as the question
  • default (bool) – the default for the confirmation answer. If True the default is Y(es), if False the default is N(o)
  • abort (bool) – if the program should abort if the user answer to the confirm prompt is no. The default is an abort.
Returns:

False if the user entered no, True if the user entered yes

Return type:

bool

PrintError(text: str)[source]

An echo for errors.

Parameters:text (str) – the text to print
PrintInfo(text: str)[source]

An echo for information.

Parameters:text (str) – the text to print
PromptError(text: str) → str[source]

A prompt for errors.

Parameters:text (str) – the text to prompt
Returns:the user input
Return type:str
PromptInfo(text: str) → str[source]

A prompt for information.

Parameters:text (str) – the text to prompt
Returns:the user input
Return type:str
PromptInfoWithDefault(text: str, text_type: object, default: object) → str[source]

A prompt for information, with a default value and a required type.

Parameters:
  • text (str) – the text to prompt
  • text_type (object) – the type of the input
  • default (object) – the default value
Returns:

the user input

Return type:

str

plasoscaffolder.common.code_formatter module

To Format the code

class plasoscaffolder.common.code_formatter.CodeFormatter(yapf_path: str)[source]

Bases: plasoscaffolder.common.base_code_formatter.BaseCodeFormatter

Class handles the code formation of files.

Format(code: str) → str[source]

Formats the code.

Parameters:code (str) – the code to format
Returns:the formatted code
Return type:str

plasoscaffolder.common.file_handler module

The file handler.

class plasoscaffolder.common.file_handler.FileHandler[source]

Bases: plasoscaffolder.common.base_file_handler.BaseFileHandler

Class handles the creation of Files.

AddContent(source: str, content: str) → str[source]

Add content to a file and create file if non existing.

Parameters:
  • source (str) – The path of the file to edit.
  • content (str) – The content to append to the file.
Returns:

the path of the edited file.

Return type:

str

CopyFile(source: str, destination: str) → str[source]

Copies a file.

Parameters:
  • source (str) – path of the file to copy
  • destination (str) – path to copy the file to.
Returns:

the path of the copied file

Return type:

str

CreateFile(directory_path: str, file_name: str, filename_suffix: str)[source]

Creates a empty file.

Parameters:
  • directory_path (str) – The path to the directory the file should be created.
  • file_name (str) – the name of the new file.
  • filename_suffix (str) – the suffix of the new file.
Returns:

the path of the created file

Return type:

str

CreateFileFromPath(file_path: str) → str[source]

Creates a empty file.

Parameters:file_path (str) – the path to the file.
Returns:the path of the created file
Return type:str
classmethod CreateFilePath(path: str, name: str, suffix: str) → str[source]

Creates the file path out of the directory path, filename and suffix.

Parameters:
  • path (str) – the path to the file directory
  • name (str) – the filename
  • suffix (str) – the suffix
Returns:

the joined path to the file

Return type:

str

CreateFolderForFilePathIfNotExist(file_path: str)[source]

Creates folders for the given file if it does not exist.

Parameters:file_path (str) – the path to the file
Returns:the directory path of the created directory
Return type:str
CreateOrModifyFileWithContent(source: str, content: str)[source]

plasoscaffolder.common.output_handler_click module

The output file handler for click

class plasoscaffolder.common.output_handler_click.OutputHandlerClick[source]

Bases: plasoscaffolder.common.base_output_handler.BaseOutputHandler

Class representing the output handler for click.

Confirm(text: str, default=True, abort=True)[source]

Ask for a confirmation, either yes or no to a question.

Parameters:
  • text (str) – prompts the user for a confirmation, with the given test as the question
  • default (bool) – the default for the confirmation answer. If True the default is Y(es), if False the default is N(o)
  • abort (bool) – if the program should abort if the user answer to the confirm prompt is no. The default is an abort.
Returns:

False if the user entered no, True if the user entered yes

Return type:

bool

PrintError(text: str)[source]

A echo for errors with click.

Parameters:text (str) – the text to print
PrintInfo(text: str)[source]

A echo for information with click.

Parameters:text (str) – the text to print
PromptError(text: str) → str[source]

A prompt for errors with click.

Parameters:text (str) – the text to prompt
Returns:the user input
Return type:str
PromptInfo(text: str) → str[source]

A prompt for information with click.

Parameters:text (str) – the text to prompt
Returns:the user input
Return type:str
PromptInfoWithDefault(text: str, text_type: object, default: object) → str[source]

A prompt for information, with a default value and a required type.

Parameters:
  • text (str) – the text to prompt
  • text_type (object) – the type of the input
  • default (object) – the default value
Returns:

the user input

Return type:

str

plasoscaffolder.common.type_mapper module

The mapper between SQL and python data types

class plasoscaffolder.common.type_mapper.TypeMapperSQLitePython[source]

Bases: object

The mapper between SQLite and python data types

The mappings taken from the site: https://sqlite.org/datatype3.html

MAPPINGS = {'BIGINT': <class 'int'>, 'NCHAR': <class 'str'>, 'DOUBLE': <class 'float'>, 'NUMERIC': <class 'int'>, 'CHAR': <class 'str'>, 'CLOB': <class 'str'>, 'FLOAT': <class 'float'>, 'DATE': <class 'int'>, 'STRING': <class 'str'>, 'TINYINT': <class 'int'>, 'SMALLINT': <class 'int'>, 'BOOLEAN': <class 'bool'>, 'DECIMAL': <class 'int'>, 'INT': <class 'int'>, 'NATIVE CHARACTER': <class 'str'>, 'MEDIUMINT': <class 'int'>, 'BLOB': <class 'bytes'>, 'DOUBLE PRECISION': <class 'float'>, 'VARYING CHARACTER': <class 'str'>, 'DATETIME': <class 'int'>, 'REAL': <class 'float'>, 'INT8': <class 'int'>, 'INT2': <class 'int'>, 'INTEGER': <class 'int'>, 'CHARACTER': <class 'str'>, 'VARCHAR': <class 'str'>, 'UNSIGNED BIG INT': <class 'int'>, 'TEXT': <class 'str'>, 'NVARCHAR': <class 'str'>}

Module contents