Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, filecontent):
self.filecontent = filecontent
self.lines = [line.line('')]
self.hasArchitecture = False
self.hasEntity = False
self._processFile()
self.filename = None
def __init__(self):
line.__init__(self, '')
self.isBlank = True
iStartGroupIndex = None
for iLineNumber, oLine in enumerate(oFile.lines):
if not fGroupFound and oLine.isArchitectureKeyword:
fGroupFound = True
iStartGroupIndex = iLineNumber
if oLine.isArchitectureBegin:
lGroup.append(oLine)
fGroupFound = False
self._check_keyword_alignment(iStartGroupIndex, '--', lGroup)
lGroup = []
iStartGroupIndex = None
if fGroupFound:
if oLine.hasComment and not oLine.isComment:
lGroup.append(oLine)
else:
lGroup.append(line.line('Removed line'))
for iLineNumber, oLine in enumerate(oFile.lines):
if not oLine.insideEntity:
if oLine.isPortKeyword and not fGroupFound:
fGroupFound = True
iStartGroupIndex = iLineNumber
if oLine.isEndPortMap:
lGroup.append(oLine)
fGroupFound = False
self._check_keyword_alignment(iStartGroupIndex, ':', lGroup)
lGroup = []
iStartGroupIndex = None
if fGroupFound:
if oLine.isPortDeclaration:
lGroup.append(oLine)
else:
lGroup.append(line.line('Removed line'))
dVars['fFunctionIsDetected'] = False
dVars['fFunctionBeginDetected'] = False
dVars['fFunctionReturnTypeDetected'] = False
dVars['iOpenParenthesis'] = 0
dVars['iCloseParenthesis'] = 0
dVars['iCurrentIndentLevel'] = 0
dVars['iGenerateLevel'] = 0
dVars['iIfLevel'] = 0
dVars['fConstantArray'] = False
dVars['iForLoopLevel'] = 0
dVars['bFirstWhenSeen'] = False
oLinePrevious = line.blank_line()
for sLine in self.filecontent:
oLine = line.line(sLine.replace('\t', ' ').rstrip())
# preIndent = str(dVars['iCurrentIndentLevel'])
update.inside_attributes(dVars, self.lines[-1], oLine)
classify.blank(oLine)
classify.comment(dVars, oLine)
classify.library(oLine)
classify.entity(self, dVars, oLine)
classify.assert_statement(dVars, oLine)
classify.code_tags(dVars, oLine, oLinePrevious)
classify.port(dVars, oLine)
classify.generic(dVars, oLine)
classify.concurrent(dVars, oLine)
classify.architecture(self, dVars, oLine)
def _analyze(self, oFile, oLine, iLineNumber):
if oLine.isGenericKeyword and not self.fGroupFound and not oLine.isGenericDeclaration:
self.fGroupFound = True
self.iStartGroupIndex = iLineNumber
if oLine.isEndGenericMap and self.fGroupFound:
self.lGroup.append(oLine)
self.fGroupFound = False
check.keyword_alignment(self, self.iStartGroupIndex, ':', self.lGroup)
self.lGroup = []
self.iStartGroupIndex = None
if self.fGroupFound:
if oLine.isGenericDeclaration:
self.lGroup.append(oLine)
else:
self.lGroup.append(line.line('Removed line'))
def __init__(self):
line.__init__(self, '')
self.isBlank = True
def _fix_violations(self, oFile):
for iLineNumber in self.violations[::-1]:
oFile.lines[iLineNumber].line = re.sub(r'\)(\s*);', r' \1 ', oFile.lines[iLineNumber].line)
oFile.lines[iLineNumber].isTypeEnd = False
oFile.lines.insert(iLineNumber + 1, line.line(' );'))
oFile.lines[iLineNumber + 1].isTypeEnd = True
oFile.lines[iLineNumber + 1].insideType = True
oFile.lines[iLineNumber + 1].indentLevel = oFile.lines[iLineNumber].indentLevel - 1
def _fix_violations(self, oFile):
for dViolation in self.violations[::-1]:
iLineNumber = utils.get_violation_linenumber(dViolation)
oLine = oFile.lines[iLineNumber]
oLine.update_line(re.sub('begin', ' '*len('begin'), oLine.line, 1, flags=re.IGNORECASE))
oLine.isProcessBegin = False
oFile.lines.insert(iLineNumber + 1, line.line(' begin'))
oFile.lines[iLineNumber + 1].isProcessBegin = True
oFile.lines[iLineNumber + 1].indentLevel = oLine.indentLevel