11. Code Documentation¶
11.1. Database Generator(dbgen)¶
11.2. Utils¶
-
class
riscof.utils.
ColoredFormatter
(*args, **kwargs)[source]¶ Class to create a log output which is colored based on level.
-
__init__
(*args, **kwargs)[source]¶ Initialize the formatter with specified format strings.
Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.
Use a style parameter of ‘%’, ‘{‘ or ‘$’ to specify that you want to use one of %-formatting,
str.format()
({}
) formatting orstring.Template
formatting in your format string.Changed in version 3.2: Added the
style
parameter.
-
format
(record)[source]¶ Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
-
-
class
riscof.utils.
Command
(*args, pathstyle='auto', ensure_absolute_paths=False)[source]¶ Class for command build which is supported by
suprocess
module. Supports automatic conversion ofpathlib.Path
instances to valid format forsubprocess
functions.-
__init__
(*args, pathstyle='auto', ensure_absolute_paths=False)[source]¶ Constructor.
- Parameters
pathstyle (str) – Determine the path style when adding instance of
pathlib.Path
. Path style determines the slash type which separates the path components. If pathstyle is auto, then on Windows backslashes are used and on Linux forward slashes are used. When backslashes should be prevented on all systems, the pathstyle should be posix. No other values are allowed.ensure_absolute_paths (bool) – If true, then any passed path will be converted to absolute path.
args – Initial command.
-
__iter__
()[source]¶ Support iteration so functions from
subprocess
module support Command instance.
-
__weakref__
¶ list of weak references to the object (if defined)
-
_is_shell_command
()[source]¶ Return true if current command is supposed to be executed as shell script otherwise false.
-
_path2str
(path)[source]¶ Convert
pathlib.Path
to string.The final form of the string is determined by the configuration of Command instance.
- Parameters
path – Path-like object which will be converted into string.
- Returns
String representation of path
-
append
(arg)[source]¶ Add new argument to command.
- Parameters
arg – Argument to be added. It may be list, tuple,
Command
instance or any instance which supportsstr()
.
-
run
(**kwargs)[source]¶ Execute the current command.
Uses
subprocess.Popen
to execute the command.- Returns
The return code of the process .
- Raises
subprocess.CalledProcessError – If check is set to true in kwargs and the process returns non-zero value.
-
-
class
riscof.utils.
CustomAction
(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]¶
-
class
riscof.utils.
MyParser
(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True)[source]¶
-
class
riscof.utils.
SortingHelpFormatter
(prog, indent_increment=2, max_help_position=24, width=None)[source]¶
-
riscof.utils.
absolute_path
(config_dir, entry_path)[source]¶ Create an absolute path based on the config’s file directory location and a path value from a configuration entry.
-
class
riscof.utils.
makeUtil
(makeCommand='make', makefilePath='./Makefile')[source]¶ Utility for ease of use of make commands like make and pmake. Supports automatic addition and execution of targets. Uses the class
shellCommand
to execute commands.-
__weakref__
¶ list of weak references to the object (if defined)
-
execute_all
(cwd)[source]¶ Function to execute all the defined targets.
- Parameters
cwd (str) – The working directory to be set while executing the make command.
-
execute_target
(tname, cwd='./')[source]¶ Function to execute a particular target only.
- Parameters
- Raises
AssertionError – If target name is not present in the list of defined targets.
-
-
riscof.utils.
setup_logging
(log_level)[source]¶ Setup logging
Verbosity decided on user input
- Parameters
log_level (str) – User defined log level
-
class
riscof.utils.
shellCommand
(*args, pathstyle='auto', ensure_absolute_paths=False)[source]¶ Sub Class of the command class which always executes commands as shell commands.
-
__init__
(*args, pathstyle='auto', ensure_absolute_paths=False)[source]¶ - Parameters
pathstyle (str) – Determine the path style when adding instance of
pathlib.Path
. Path style determines the slash type which separates the path components. If pathstyle is auto, then on Windows backslashes are used and on Linux forward slashes are used. When backslashes should be prevented on all systems, the pathstyle should be posix. No other values are allowed.ensure_absolute_paths (bool) – If true, then any passed path will be converted to absolute path.
args – Initial command.
-
11.3. Abstract Base Classes¶
-
class
riscof.pluginTemplate.
pluginTemplate
(*args, **kwargs)[source]¶ Metaclass for plugins as supported by
ABC
.-
__weakref__
¶ list of weak references to the object (if defined)
-
abstract
build
(isa_yaml, platform_yaml)[source]¶ Build the model as per specifications specified by DUT.
-