spinn_utilities.make_tools package

Submodules

spinn_utilities.make_tools.replacer module

class spinn_utilities.make_tools.replacer.Replacer(dict_pointer)[source]

Bases: object

Performs replacements.

Parameters:dict_pointer (str) – Where to find the dictionary file
replace(short)[source]

Apply the replacements to a short message.

Parameters:short (str) – The short message to apply the transform to.
Returns:The expanded message.
Return type:str

Module contents

class spinn_utilities.make_tools.Converter(src, dest, dict_file)[source]

Bases: object

Converts a whole directory including sub directories

Parameters:
  • src (str) – Full source directory
  • dest (str) – Full destination directory
  • dict_file (str) – Full path to dictionary file
static convert(src, dest, dict_file)[source]

Wrapper function around this class.

run()[source]

Runs the file converter on a whole directory including sub-directories.

Warning

This code is absolutely not thread safe. Interwoven calls even on different FileConverter objects is dangerous! It is highly likely that dict files become corrupted and the same message_id is used multiple times.

class spinn_utilities.make_tools.FileConverter(src, dest, dict_file)[source]

Bases: object

Creates the file_convertor to convert one file

Parameters:
  • src (str) – Source file
  • dest (str) – Destination file
  • dict_file (str) – File to hold dictionary mappings
bracket_count(text)[source]

Net count of open brackets in line.

Parameters:text (str) –
Return type:int
static convert(src, dest, dict_file, range_start=1)[source]

Static method to create Object and do the conversion

Parameters:
  • src (str) – Source file
  • dest (str) – Destination file
  • dict_file (str) – File to hold dictionary mappings
  • range_start (int) – id of last dictionary key used
Returns:

The last message id use which can in turn be passed into this method again (range_start) to get contiguous non-overlapping IDs across many files.

Return type:

int

dest

Full destination file name

Type:str
dict

File to hold dictionary mappings

Type:str
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)

src

Full source file name

Type:str
unique_src()[source]

Returns the suffix of the source and destination paths which is the same.

For example, assuming sources of /spinnaker/sPyNNaker/neural_modelling/src/common/in_spikes.h /spinnaker/sPyNNaker/neural_modelling/modified_src/common/in_spikes.h this returns src/common/in_spikes.h

Returns:A pointer to the source relative to the destination
Return type:str
class spinn_utilities.make_tools.Replacer(dict_pointer)[source]

Bases: object

Performs replacements.

Parameters:dict_pointer (str) – Where to find the dictionary file
replace(short)[source]

Apply the replacements to a short message.

Parameters:short (str) – The short message to apply the transform to.
Returns:The expanded message.
Return type:str