Skip to content

Commit

Permalink
Set black formatting to 120 chars per line.
Browse files Browse the repository at this point in the history
Added pyproject.toml
  • Loading branch information
Paebbels committed Aug 23, 2021
2 parents dac2e4d + 3dddb7d commit c58dff1
Show file tree
Hide file tree
Showing 33 changed files with 234 additions and 757 deletions.
20 changes: 5 additions & 15 deletions pyGHDL/cli/dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,9 @@ def __init__(self, *args, **kwargs):

# Change error and warning reporting
# --------------------------------------------------------------------------
self._LOG_MESSAGE_FORMAT__[
Severity.Fatal
] = "{DARK_RED}[FATAL] {message}{NOCOLOR}"
self._LOG_MESSAGE_FORMAT__[Severity.Fatal] = "{DARK_RED}[FATAL] {message}{NOCOLOR}"
self._LOG_MESSAGE_FORMAT__[Severity.Error] = "{RED}[ERROR] {message}{NOCOLOR}"
self._LOG_MESSAGE_FORMAT__[
Severity.Warning
] = "{YELLOW}[WARNING] {message}{NOCOLOR}"
self._LOG_MESSAGE_FORMAT__[Severity.Warning] = "{YELLOW}[WARNING] {message}{NOCOLOR}"
self._LOG_MESSAGE_FORMAT__[Severity.Normal] = "{GRAY}{message}{NOCOLOR}"

# class properties
Expand All @@ -199,15 +195,9 @@ def PrintHeadline(self):
# ============================================================================
# common arguments valid for all commands
# ----------------------------------------------------------------------------
@CommonSwitchArgumentAttribute(
"-d", "--debug", dest="debug", help="Enable debug mode."
)
@CommonSwitchArgumentAttribute(
"-v", "--verbose", dest="verbose", help="Print out detailed messages."
)
@CommonSwitchArgumentAttribute(
"-q", "--quiet", dest="quiet", help="Reduce messages to a minimum."
)
@CommonSwitchArgumentAttribute("-d", "--debug", dest="debug", help="Enable debug mode.")
@CommonSwitchArgumentAttribute("-v", "--verbose", dest="verbose", help="Print out detailed messages.")
@CommonSwitchArgumentAttribute("-q", "--quiet", dest="quiet", help="Reduce messages to a minimum.")
def Run(self):
ArgParseMixin.Run(self)

Expand Down
12 changes: 3 additions & 9 deletions pyGHDL/cli/lsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,9 @@ def _generateCLIParser() -> ArgumentParser:
parser = ArgumentParser(
description="VHDL Language Protocol Server. Find info about clients in `ghdl/ghdl-language-server <https://github.com/ghdl/ghdl-language-server>`__."
)
parser.add_argument(
"--version", "-V", action="version", version="%(prog)s " + version.__version__
)
parser.add_argument(
"--verbose", "-v", action="count", default=0, help="Show debug output"
)
parser.add_argument(
"--log-file", help="Redirect logs to the given file instead of stderr"
)
parser.add_argument("--version", "-V", action="version", version="%(prog)s " + version.__version__)
parser.add_argument("--verbose", "-v", action="count", default=0, help="Show debug output")
parser.add_argument("--log-file", help="Redirect logs to the given file instead of stderr")
parser.add_argument(
"--trace-file",
help="Save RPC data to FILE.in and FILE.out (overrides :envvar:`GHDL_LS_TRACE`)",
Expand Down
140 changes: 35 additions & 105 deletions pyGHDL/dom/Concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,21 @@

@export
class GenericAssociationItem(VHDLModel_GenericAssociationItem, DOMMixin):
def __init__(
self, associationNode: Iir, actual: ExpressionUnion, formal: Name = None
):
def __init__(self, associationNode: Iir, actual: ExpressionUnion, formal: Name = None):
super().__init__(actual, formal)
DOMMixin.__init__(self, associationNode)


@export
class PortAssociationItem(VHDLModel_PortAssociationItem, DOMMixin):
def __init__(
self, associationNode: Iir, actual: ExpressionUnion, formal: Name = None
):
def __init__(self, associationNode: Iir, actual: ExpressionUnion, formal: Name = None):
super().__init__(actual, formal)
DOMMixin.__init__(self, associationNode)


@export
class ParameterAssociationItem(VHDLModel_ParameterAssociationItem, DOMMixin):
def __init__(
self, associationNode: Iir, actual: ExpressionUnion, formal: Name = None
):
def __init__(self, associationNode: Iir, actual: ExpressionUnion, formal: Name = None):
super().__init__(actual, formal)
DOMMixin.__init__(self, associationNode)

Expand All @@ -113,22 +107,16 @@ def __init__(
DOMMixin.__init__(self, instantiationNode)

@classmethod
def parse(
cls, instantiationNode: Iir, instantiatedUnit: Iir, label: str
) -> "ComponentInstantiation":
def parse(cls, instantiationNode: Iir, instantiatedUnit: Iir, label: str) -> "ComponentInstantiation":
from pyGHDL.dom._Translate import (
GetNameFromNode,
GetGenericMapAspect,
GetPortMapAspect,
)

componentName = GetNameFromNode(instantiatedUnit)
genericAssociations = GetGenericMapAspect(
nodes.Get_Generic_Map_Aspect_Chain(instantiationNode)
)
portAssociations = GetPortMapAspect(
nodes.Get_Port_Map_Aspect_Chain(instantiationNode)
)
genericAssociations = GetGenericMapAspect(nodes.Get_Generic_Map_Aspect_Chain(instantiationNode))
portAssociations = GetPortMapAspect(nodes.Get_Port_Map_Aspect_Chain(instantiationNode))

return cls(
instantiationNode,
Expand All @@ -150,15 +138,11 @@ def __init__(
genericAssociations: Iterable[AssociationItem] = None,
portAssociations: Iterable[AssociationItem] = None,
):
super().__init__(
label, entityName, architectureName, genericAssociations, portAssociations
)
super().__init__(label, entityName, architectureName, genericAssociations, portAssociations)
DOMMixin.__init__(self, instantiationNode)

@classmethod
def parse(
cls, instantiationNode: Iir, instantiatedUnit: Iir, label: str
) -> "EntityInstantiation":
def parse(cls, instantiationNode: Iir, instantiatedUnit: Iir, label: str) -> "EntityInstantiation":
from pyGHDL.dom._Translate import (
GetNameFromNode,
GetGenericMapAspect,
Expand All @@ -173,12 +157,8 @@ def parse(
if architectureId != nodes.Null_Iir:
architectureName = GetNameOfNode(architectureId)

genericAssociations = GetGenericMapAspect(
nodes.Get_Generic_Map_Aspect_Chain(instantiationNode)
)
portAssociations = GetPortMapAspect(
nodes.Get_Port_Map_Aspect_Chain(instantiationNode)
)
genericAssociations = GetGenericMapAspect(nodes.Get_Generic_Map_Aspect_Chain(instantiationNode))
portAssociations = GetPortMapAspect(nodes.Get_Port_Map_Aspect_Chain(instantiationNode))

return cls(
instantiationNode,
Expand All @@ -200,15 +180,11 @@ def __init__(
genericAssociations: Iterable[AssociationItem] = None,
portAssociations: Iterable[AssociationItem] = None,
):
super().__init__(
label, configurationName, genericAssociations, portAssociations
)
super().__init__(label, configurationName, genericAssociations, portAssociations)
DOMMixin.__init__(self, instantiationNode)

@classmethod
def parse(
cls, instantiationNode: Iir, instantiatedUnit: Iir, label: str
) -> "ConfigurationInstantiation":
def parse(cls, instantiationNode: Iir, instantiatedUnit: Iir, label: str) -> "ConfigurationInstantiation":
from pyGHDL.dom._Translate import (
GetNameFromNode,
GetGenericMapAspect,
Expand All @@ -218,12 +194,8 @@ def parse(
configurationId = nodes.Get_Configuration_Name(instantiatedUnit)
configurationName = GetNameFromNode(configurationId)

genericAssociations = GetGenericMapAspect(
nodes.Get_Generic_Map_Aspect_Chain(instantiationNode)
)
portAssociations = GetPortMapAspect(
nodes.Get_Port_Map_Aspect_Chain(instantiationNode)
)
genericAssociations = GetGenericMapAspect(nodes.Get_Generic_Map_Aspect_Chain(instantiationNode))
portAssociations = GetPortMapAspect(nodes.Get_Port_Map_Aspect_Chain(instantiationNode))

return cls(
instantiationNode,
Expand Down Expand Up @@ -256,9 +228,7 @@ def parse(cls, blockNode: Iir, label: str) -> "ConcurrentBlockStatement":
# genericAssociations = GetGenericMapAspect(nodes.Get_Generic_Map_Aspect_Chain(instantiationNode))
# portAssociations = GetPortMapAspect(nodes.Get_Port_Map_Aspect_Chain(instantiationNode))

declaredItems = GetDeclaredItemsFromChainedNodes(
nodes.Get_Declaration_Chain(blockNode), "block", label
)
declaredItems = GetDeclaredItemsFromChainedNodes(nodes.Get_Declaration_Chain(blockNode), "block", label)
statements = GetConcurrentStatementsFromChainedNodes(
nodes.Get_Concurrent_Statement_Chain(blockNode), "block", label
)
Expand All @@ -280,9 +250,7 @@ def __init__(
DOMMixin.__init__(self, processNode)

@classmethod
def parse(
cls, processNode: Iir, label: str, hasSensitivityList: bool
) -> "ProcessStatement":
def parse(cls, processNode: Iir, label: str, hasSensitivityList: bool) -> "ProcessStatement":
from pyGHDL.dom._Translate import (
GetDeclaredItemsFromChainedNodes,
GetSequentialStatementsFromChainedNodes,
Expand All @@ -295,9 +263,7 @@ def parse(
# sensitivityListNode = nodes.Get_Sensitivity_List(processNode)
# print("sensi", GetIirKindOfNode(sensitivityListNode))

declaredItems = GetDeclaredItemsFromChainedNodes(
nodes.Get_Declaration_Chain(processNode), "process", label
)
declaredItems = GetDeclaredItemsFromChainedNodes(nodes.Get_Declaration_Chain(processNode), "process", label)
statements = GetSequentialStatementsFromChainedNodes(
nodes.Get_Sequential_Statement_Chain(processNode), "process", label
)
Expand Down Expand Up @@ -334,14 +300,10 @@ def parse(cls, generateNode: Iir) -> "IfGenerateBranch":
alternativeLabel = ""

declarationChain = nodes.Get_Declaration_Chain(body)
declaredItems = GetDeclaredItemsFromChainedNodes(
declarationChain, "if-generate branch", alternativeLabel
)
declaredItems = GetDeclaredItemsFromChainedNodes(declarationChain, "if-generate branch", alternativeLabel)

statementChain = nodes.Get_Concurrent_Statement_Chain(body)
statements = GetConcurrentStatementsFromChainedNodes(
statementChain, "if-generate branch", alternativeLabel
)
statements = GetConcurrentStatementsFromChainedNodes(statementChain, "if-generate branch", alternativeLabel)

return cls(generateNode, condition, declaredItems, statements, alternativeLabel)

Expand Down Expand Up @@ -375,14 +337,10 @@ def parse(cls, generateNode: Iir, condition: Iir) -> "ElsifGenerateBranch":
alternativeLabel = ""

declarationChain = nodes.Get_Declaration_Chain(body)
declaredItems = GetDeclaredItemsFromChainedNodes(
declarationChain, "elsif-generate branch", alternativeLabel
)
declaredItems = GetDeclaredItemsFromChainedNodes(declarationChain, "elsif-generate branch", alternativeLabel)

statementChain = nodes.Get_Concurrent_Statement_Chain(body)
statements = GetConcurrentStatementsFromChainedNodes(
statementChain, "elsif-generate branch", alternativeLabel
)
statements = GetConcurrentStatementsFromChainedNodes(statementChain, "elsif-generate branch", alternativeLabel)

return cls(generateNode, condition, declaredItems, statements, alternativeLabel)

Expand Down Expand Up @@ -413,14 +371,10 @@ def parse(cls, generateNode: Iir) -> "ElseGenerateBranch":
alternativeLabel = ""

declarationChain = nodes.Get_Declaration_Chain(body)
declaredItems = GetDeclaredItemsFromChainedNodes(
declarationChain, "else-generate branch", alternativeLabel
)
declaredItems = GetDeclaredItemsFromChainedNodes(declarationChain, "else-generate branch", alternativeLabel)

statementChain = nodes.Get_Concurrent_Statement_Chain(body)
statements = GetConcurrentStatementsFromChainedNodes(
statementChain, "else-generate branch", alternativeLabel
)
statements = GetConcurrentStatementsFromChainedNodes(statementChain, "else-generate branch", alternativeLabel)

return cls(generateNode, declaredItems, statements, alternativeLabel)

Expand Down Expand Up @@ -488,9 +442,7 @@ def __init__(
DOMMixin.__init__(self, node)

@classmethod
def parse(
cls, caseNode: Iir, choices: Iterable[ConcurrentChoice]
) -> "GenerateCase":
def parse(cls, caseNode: Iir, choices: Iterable[ConcurrentChoice]) -> "GenerateCase":
from pyGHDL.dom._Translate import (
GetDeclaredItemsFromChainedNodes,
GetConcurrentStatementsFromChainedNodes,
Expand All @@ -503,14 +455,10 @@ def parse(
alternativeLabel = ""

declarationChain = nodes.Get_Declaration_Chain(body)
declaredItems = GetDeclaredItemsFromChainedNodes(
declarationChain, "generate case", alternativeLabel
)
declaredItems = GetDeclaredItemsFromChainedNodes(declarationChain, "generate case", alternativeLabel)

statementChain = nodes.Get_Concurrent_Statement_Chain(body)
statements = GetConcurrentStatementsFromChainedNodes(
statementChain, "generate case", alternativeLabel
)
statements = GetConcurrentStatementsFromChainedNodes(statementChain, "generate case", alternativeLabel)

return cls(caseNode, choices, declaredItems, statements, alternativeLabel)

Expand Down Expand Up @@ -541,14 +489,10 @@ def parse(cls, caseNode: Iir) -> "OthersGenerateCase":
alternativeLabel = ""

declarationChain = nodes.Get_Declaration_Chain(body)
declaredItems = GetDeclaredItemsFromChainedNodes(
declarationChain, "case-generate others", alternativeLabel
)
declaredItems = GetDeclaredItemsFromChainedNodes(declarationChain, "case-generate others", alternativeLabel)

statementChain = nodes.Get_Concurrent_Statement_Chain(body)
statements = GetConcurrentStatementsFromChainedNodes(
statementChain, "case-generate others", alternativeLabel
)
statements = GetConcurrentStatementsFromChainedNodes(statementChain, "case-generate others", alternativeLabel)

return cls(caseNode, declaredItems, statements, alternativeLabel)

Expand Down Expand Up @@ -589,9 +533,7 @@ def parse(cls, generateNode: Iir, label: str) -> "CaseGenerateStatement":
nodes.Iir_Kind.Choice_By_Name,
nodes.Iir_Kind.Choice_By_Expression,
):
choiceExpression = GetExpressionFromNode(
nodes.Get_Choice_Expression(alternative)
)
choiceExpression = GetExpressionFromNode(nodes.Get_Choice_Expression(alternative))

choice = IndexedGenerateChoice(alternative, choiceExpression)
if sameAlternative:
Expand Down Expand Up @@ -699,23 +641,17 @@ def parse(cls, generateNode: Iir, label: str) -> "ForGenerateStatement":

body = nodes.Get_Generate_Statement_Body(generateNode)
declarationChain = nodes.Get_Declaration_Chain(body)
declaredItems = GetDeclaredItemsFromChainedNodes(
declarationChain, "for-generate", label
)
declaredItems = GetDeclaredItemsFromChainedNodes(declarationChain, "for-generate", label)

statementChain = nodes.Get_Concurrent_Statement_Chain(body)
statements = GetConcurrentStatementsFromChainedNodes(
statementChain, "for-generate", label
)
statements = GetConcurrentStatementsFromChainedNodes(statementChain, "for-generate", label)

return cls(generateNode, label, loopIndex, rng, declaredItems, statements)


@export
class WaveformElement(VHDLModel_WaveformElement, DOMMixin):
def __init__(
self, waveNode: Iir, expression: ExpressionUnion, after: ExpressionUnion
):
def __init__(self, waveNode: Iir, expression: ExpressionUnion, after: ExpressionUnion):
super().__init__(expression, after)
DOMMixin.__init__(self, waveNode)

Expand All @@ -735,9 +671,7 @@ def parse(cls, waveNode: Iir):


@export
class ConcurrentSimpleSignalAssignment(
VHDLModel_ConcurrentSimpleSignalAssignment, DOMMixin
):
class ConcurrentSimpleSignalAssignment(VHDLModel_ConcurrentSimpleSignalAssignment, DOMMixin):
def __init__(
self,
assignmentNode: Iir,
Expand All @@ -749,9 +683,7 @@ def __init__(
DOMMixin.__init__(self, assignmentNode)

@classmethod
def parse(
cls, assignmentNode: Iir, label: str
) -> "ConcurrentSimpleSignalAssignment":
def parse(cls, assignmentNode: Iir, label: str) -> "ConcurrentSimpleSignalAssignment":
from pyGHDL.dom._Translate import GetNameFromNode

target = nodes.Get_Target(assignmentNode)
Expand Down Expand Up @@ -784,8 +716,6 @@ def parse(cls, concurrentCallNode: Iir, label: str) -> "ConcurrentProcedureCall"

prefix = nodes.Get_Prefix(callNode)
procedureName = GetNameFromNode(prefix)
parameterAssociations = GetParameterMapAspect(
nodes.Get_Parameter_Association_Chain(callNode)
)
parameterAssociations = GetParameterMapAspect(nodes.Get_Parameter_Association_Chain(callNode))

return cls(concurrentCallNode, label, procedureName, parameterAssociations)

0 comments on commit c58dff1

Please sign in to comment.