vsg.utilities¶
This module provides functions for rules to use.
-
vsg.utils.
begin_of_line_index
(oLine)¶ Finds the left most non whitespace character. Returns the index of the first non whitespace character.
Parameters:
oLine: (line object)Returns: (integer)
-
vsg.utils.
change_word
(oLine, sWord, sNewWord, iMax=1)¶ Changes one word in the line to another.
Parameters:
oLine: (line object)
sWord: (string)
sNewWord: (string)
-
vsg.utils.
clear_keyword_from_line
(oLine, sKeyword)¶ Removes a keyword from a line.
Parameters:
oLine: (line object)
sKeyword: (string)
-
vsg.utils.
copy_line
(oFile, iLineNumber)¶ Creates a copy of the line at iLineNumber and inserts it below iLineNumber.
Parameters:
oFile: (vhdlFile object)
iLineNumber: (integer)
-
vsg.utils.
create_violation_dict
(iLineNumber)¶ Builds a minimal violation dictionary.
Parameters:
iLineNumber: (integer)Returns: dictionary
-
vsg.utils.
end_of_line_index
(oLine)¶ Finds the end of the code on a line ignoring comments. Returns the index of the last code character.
Parameters:
oLine: (line object)Returns: (integer)
-
vsg.utils.
extract_architecture_identifier
(oLine)¶ Returns architecture name from architecture declaration or end.
Parameters:
oLine: (line object)Returns: (one element or empty list of strings)
-
vsg.utils.
extract_begin_label
(oLine)¶ Returns the label.
Parameters:
oLine: (line object)Returns: (one element list of strings)
-
vsg.utils.
extract_class_identifier_list
(oLine)¶ Returns a class identifiers list.
Parameters:
oLine: (line object)Returns: (list of strings)
-
vsg.utils.
extract_class_name
(oLine)¶ Returns the name of a type in a type declaration.
Parameters:
oLine: (line object)Returns: (one element list of strings)
-
vsg.utils.
extract_component_identifier
(oLine)¶ Returns the component identifier.
Parameters:
oLine: (line object)Returns: (one element or empty list of strings)
-
vsg.utils.
extract_end_label
(oLine)¶ Returns the end label.
Parameters:
oLine: (line object)Returns: (one element or empty list of strings)
-
vsg.utils.
extract_entity_identifier
(oLine)¶ Returns the entity identifier.
Parameters:
oLine: (line object)Returns: (one element or empty list of strings)
-
vsg.utils.
extract_generics
(oLine)¶ Returns a generics list.
Parameters:
oLine: (line object)Returns: (list of strings)
-
vsg.utils.
extract_label
(oLine)¶ Returns the label.
Parameters:
oLine: (line object)Returns: (one element list of strings)
-
vsg.utils.
extract_non_keywords
(sString)¶ - Returns a keyword list with the following removed:
- :’s commas semicolons vhdl keywords double quotes numbers ticks comments
Parameters:
sString: (string)Returns: (list of strings)
-
vsg.utils.
extract_port_assignments
(oLine)¶ Extracts port assignments from an instantiation.
Parameters:
oLine : (line object)Returns: (list of strings)
-
vsg.utils.
extract_port_name
(oLine)¶ Returns port name from line.
Parameters:
oLine: (line object)Returns: (one element list of strings)
-
vsg.utils.
extract_port_names_from_port_map
(oLine)¶ Returns port names from port assignment inside port map.
- Parameters:
- oLine: (line object)
Returns: (list of strings)
-
vsg.utils.
extract_string_after_string
(sLine, sString)¶ Extracts a string from a string after the given string.
Parameters:
sLine : (string)
sString : (string)
Returns: (string)
-
vsg.utils.
extract_string_before_string
(sLine, sString)¶ Extracts a string from a string before the given string.
Parameters:
sLine : (string)
sString : (string)
Returns: (string)
-
vsg.utils.
extract_type_identifier
(oLine)¶ Returns the type identifier from type declaration.
Parameters:
oLine: (line object)Returns: (one element list of strings)
-
vsg.utils.
extract_type_name
(oLine)¶ Returns the name of a type in various declarations.
Parameters:
oLine: (line object)Returns: (zero or one element list of strings)
-
vsg.utils.
extract_type_name_from_port
(oLine)¶ Returns the name of a type in port declaration.
Parameters:
oLine: (line object)Returns: (one element list of strings)
-
vsg.utils.
extract_type_name_from_port_vhdl_only
(oLine)¶ Returns the name of a VHDL only types in port declaration.
Parameters:
oLine: (line object)Returns: (one element list of strings)
-
vsg.utils.
extract_type_name_vhdl_only
(oLine)¶ Returns the name of a VHDL only types in various declarations.
Parameters:
oLine: (line object)Returns: (one element or empty list of strings)
-
vsg.utils.
extract_words
(oLine, words)¶ Returns words from line. Case insensitive, however returned words preserve their case.
Parameters:
oLine: (line object)
words: (list of words to extract)
Returns: (list of strings)
-
vsg.utils.
find_comment_index_in_string
(sString)¶ Finds the index of a comment in a string.
Parameters:
sString: (string)Returns: (None) or (Integer)
-
vsg.utils.
get_first_word
(oLine)¶ Returns the first word from a line at iIndex.
Parameters:
oLine: (line object)Returns: (string)
-
vsg.utils.
get_violating_line
(oFile, dViolation)¶ Returns a line from the file where a violation has occured.
Parameters:
oFile : (File object)
dViolation : (Violation dictionary)
Return: Line Object
-
vsg.utils.
get_violation_line_number
(dViolation)¶ Returns a line number of a violation.
Parameters:
dViolation: Violation dictionaryReturns: integer
-
vsg.utils.
get_word
(oLine, iIndex)¶ Returns a word from a line at iIndex.
Parameters:
oLine: (line object)
iIndex: (integer)
Returns: (string)
-
vsg.utils.
insert_line
(oFile, iIndex)¶ Inserts a blank line at iIndex into the file line list.
Parameters:
oFile: (File Object)
iIndex: (integer)
Returns: Nothing
-
vsg.utils.
is_number
(sString)¶ Returns boolean if the string passed is a number.
Parameters:
sLine: (string)Returns: boolean
-
vsg.utils.
is_port_mode
(sWord)¶ Returns True if given word is a valid port mode.
Returns False if given word is not a valid port mode.
Parameters:
sWord: (string)Returns: (boolean)
-
vsg.utils.
is_vhdl_keyword
(sWord)¶ Returns True if given word is a VHDL keyword.
Returns False if given word is not a VHDL keyword.
Parameters:
sWord: (string)Returns: (boolean)
-
vsg.utils.
reclassify_line
(oFile, iLineNumber)¶ Updates the following attributes on the current and next line:
- isFunctionReturn
- insideVariableAssignment
- isVariableAssignmentEnd
- isVariableAssignment
- insideSequential
- isSequentialEnd
- isSequential
- hasComment
- hasInlineComment
- commentColumn
Parameters:
oFile: (vhdlFile object)
iLineNumber: (integer)
-
vsg.utils.
remove_blank_line
(oFile, iLineNumber)¶ Removes a line if it is blank.
Parameters:
oFile: (vhdlFile object)
iLineNumber: (integer)
-
vsg.utils.
remove_closing_parenthesis_and_semicolon
(oLine)¶ Parameters:
oLine: (line object)Returns: (line object)
-
vsg.utils.
remove_comment
(sString)¶ Returns a string without comments.
Parameters:
sString: (string)Returns: (string)
-
vsg.utils.
remove_comment_attributes_from_line
(oLine)¶ Sets all comment attributes on a line to indicate no comment is present.
Parameters:
oLine: (line object)
-
vsg.utils.
remove_consecutive_characters
(sString, sChar)¶ Removes consecutive characters from a string.
Paramters:
sString : (string)
sChar : (single character string)
Returns: (string)
-
vsg.utils.
remove_line
(oFile, iLineNumber)¶ Removes a line from the file line list.
Parameters:
oFile: (File Object)
iLineNumber : (integer)
Returns: Nothing
-
vsg.utils.
remove_lines
(oFile, iStartLine, iEndLine)¶ Removes a series of lines from the file line list.
Parameters:
oFile: (File Object)
iStartLine: (integer)
iEndLine: (integer)
Returns: Nothing
-
vsg.utils.
remove_parenthesis
(sString, iOpenCount=0, iCloseCount=0)¶ Removes pairs of parenthesis and their contents.
Parameters:
sString : (string)Returns: (string)
-
vsg.utils.
remove_parenthesis_from_word
(sWord)¶ Removes parenthesis from words:
Hello(there) => Hello Hello => HelloParameters:
sWord: (string)Returns: (string)
-
vsg.utils.
remove_text_after_word
(sKeyword, sWord)¶ Removes all text after a keyword.
Parameters:
sKeyword: (string)
sWord: (string)
-
vsg.utils.
replace_word_by_index
(oLine, iIndex, sWord)¶ Replaces text in a line at a given index with a given word.
Parameters:
oLine: (Line Object)
iIndex: (integer)
sWord: (string)
Returns: Nothing
-
vsg.utils.
search_for_and_remove_keyword
(oFile, iLineNumber, sKeyword)¶ Searches for a keyword on lines below the current line and removes it if discovered.
Parameters:
oFile: (vhdlFile object)
iLineNumber: (integer)
sKeyword: (string)
-
vsg.utils.
split_line_after_word
(oFile, iLineNumber, sWord)¶ Splits the line after the word given and inserts it after the current line.
Parameters:
oFile: (vhdlFile object)
iLineNumber: (integer)
sWord: (string)
-
vsg.utils.
split_line_before_word
(oFile, iLineNumber, sWord)¶ Splits the line before the word given and inserts it after the current line.
Parameters:
oFile: (vhdlFile object)
iLineNumber: (integer)
sWord: (string)
-
vsg.utils.
split_line_on_comment
(sString)¶ Split a string at the index a comment is found and returns a list with two strings.
Parameters:
sString : (string)Returns: (list of strings)
-
vsg.utils.
strip_semicolon_from_word
(sWord)¶ Removes trailing semicolon from a word:
case; => case entity; => entityParameters:
sWord: (string)Returns: (string)
-
vsg.utils.
update_comment_line_attributes
(oLine)¶ Updates the following attributes on a line:
self.isComment self.hasComment self.hasInLineComment self.commentColumnParameters:
oLine: (Line Object)Returns: Nothing