spinn_utilities.make_tools package

Submodules

spinn_utilities.make_tools.converter module

spinn_utilities.make_tools.converter.convert(src, dest, new_dict)[source]

Converts a whole directory including sub-directories.

Parameters:
  • src (str) – Full source directory

  • dest (str) – Full destination directory

  • new_dict (bool) – Whether we should generate a new dictionary/DB. If not, we add to the existing one.

spinn_utilities.make_tools.log_sqllite_database module

class spinn_utilities.make_tools.log_sqllite_database.LogSqlLiteDatabase(new_dict=False)[source]

Bases: AbstractContextManager

Specific implementation of the Database for SQLite 3.

Note

Not thread-safe on the same database. Threads can access different DBs just fine.

Note

This totally relies on the way SQLite’s type affinities function. You can’t port to a different database engine without a lot of work.

Connects to a log dict. The location of the file can be overridden using the C_LOGS_DICT environment variable.

Parameters:

new_dict (bool) – Flag to say if this is a new dict or not. If True, clears and previous values. If False, makes sure the dict exists.

check_original(original: str)[source]

Checks that an original log line has been added to the database.

Mainly used for testing

Parameters:

original (str) –

Raises:

ValueError – If the original is not in the database

close()[source]

Finalises and closes the database.

get_directory_id(src_path: str, dest_path: str) int[source]

gets the Ids for this directory. Making a new one if needed

Parameters:
  • src_path (str) –

  • dest_path (str) –

Return type:

int

get_file_id(directory_id: int, file_name: str) int[source]

Gets the id for this file, making a new one if needed.

Parameters:
  • directory_id (int) –

  • file_name (str) –

Return type:

int

get_log_info(log_id: str) Tuple[int, str, int, str] | None[source]

Gets the data needed to replace a short log back to the original.

Parameters:

log_id (str) – The int id as a String

Return type:

tuple(int, str, int, str)

get_max_log_id()[source]

Get the max id of any log message.

Return type:

int

set_log_info(log_level: int, line_num: int, original: str, file_id: int)[source]

Saves the data needed to replace a short log back to the original.

Parameters:
  • log_level (int) –

  • line_num (int) –

  • original (str) –

  • file_id (int) –

spinn_utilities.make_tools.replacer module

class spinn_utilities.make_tools.replacer.Replacer(new_dict=False)[source]

Bases: LogSqlLiteDatabase

Performs replacements.

Connects to a log dict. The location of the file can be overridden using the C_LOGS_DICT environment variable.

Parameters:

new_dict (bool) – Flag to say if this is a new dict or not. If True, clears and previous values. If False, makes sure the dict exists.

replace(short: str) str[source]

Apply the replacements to a short message.

Parameters:

short (str) –

Return type:

str

Module contents

class spinn_utilities.make_tools.FileConverter[source]

Bases: object

Converts a file. See convert().

bracket_count(text)[source]

Net count of open brackets in line.

Parameters:

text (str) –

Return type:

int

static convert(src_dir, dest_dir, file_name)[source]

Static method to create Object and do the conversion.

Parameters:
  • src_dir (str) – Source directory

  • dest_dir (str) – Destination directory

  • file_name (str) – The name of the file to convert within the source directory; it will be made with the same name in the destination directory.

quote_part(text)[source]

Net count of double quotes in line.

Parameters:

text (str) –

Return type:

int

split_by_comma_plus(main, line_num)[source]

Split line by comma and partially parse.

Parameters:
  • main (str) –

  • line_num (int) –

Return type:

list(str)

Raises:

UnexpectedCException