spinn_utilities.make_tools package¶
Submodules¶
spinn_utilities.make_tools.check_database_keys module¶
spinn_utilities.make_tools.converter module¶
- spinn_utilities.make_tools.converter.convert(src: str, dest: str, database_dir: str, database_key: str) str[source]¶
Converts a whole directory including sub-directories.
- Parameters:
src – Full source directory
dest – Full destination directory
database_dir – Full path to directory to place database file in.
database_key – database key for this conversion
- Returns:
Full path to the logs database
- Raises:
spinn_utilities.make_tools.log_sqllite_database module¶
- class spinn_utilities.make_tools.log_sqllite_database.LogSqlLiteDatabase(database_path: str)[source]¶
Bases:
AbstractContextManagerSpecific 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_DICTenvironment variable.- param database_file: Full path to the database.
(use default_database_file to get the default location)
- check_original(original: str) None[source]¶
Checks that an original log line has been added to the database.
Mainly used for testing
- Parameters:
original
- Raises:
ValueError – If the original is not in the database
- classmethod deprecated_database_file() str[source]¶
Finds the previous database file path.
If environment variable C_LOGS_DICT exists that is used, otherwise the default path in this directory is used.
This is deprecated as any new make will no longer use this file
- Returns:
Absolute path to where the database file is or will be
- classmethod filename_by_key(database_dir: str, database_key: str) str[source]¶
Builds the file name which includes the key
- Parameters:
database_dir – Full path to directory to place database file in.
database_key – key for the database
- Returns:
filename including the key
- Raises:
ValueError – If the key is not a single none digital character
- classmethod find_databases(database_dir: str) Dict[str, str][source]¶
Given a directory finds the databases and keys in it.
- Parameters:
database_dir – Full path to directory which may have logs databases) in it.
- Returns:
Map of database_keys to full database paths.
- 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
dest_path
- Returns:
The ID for this directory.
- 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
file_name
- Returns:
The ID for this file
- get_log_info(log_id: str) Tuple[int, str, str, str] | None[source]¶
Gets the data needed to replace a short log back to the original.
- Parameters:
log_id – The int id as a String
- Returns:
log level, file name, line number and the original text
spinn_utilities.make_tools.replacer module¶
Module contents¶
- class spinn_utilities.make_tools.FileConverter(log_database: LogSqlLiteDatabase, database_key: str)[source]¶
Bases:
objectConverts a file. See
convert().- Parameters:
log_database – Database to use
database_key – Key for this conversion
- convert(src_dir: str, dest_dir: str, file_name: str) None[source]¶
Converts the c file changing the log messages
- Parameters:
src_dir – Source directory
dest_dir – Destination directory
file_name – The name of the file to convert within the source directory; it will be made with the same name in the destination directory.