macaron.parsers package
Subpackages
Submodules
macaron.parsers.actionparser module
This module contains the parser for GitHub Actions Workflow files.
- macaron.parsers.actionparser.parse(workflow_path)
Parse the GitHub Actions workflow YAML file.
- Parameters:
workflow_path (str) – Path to the GitHub Actions.
- Returns:
The parsed workflow.
- Return type:
Workflow
- Raises:
ParseError – When parsing fails with errors.
- macaron.parsers.actionparser.get_run_step(step)
Get the parsed GitHub Action run step for inlined shell scripts.
If the run step cannot be validated this function returns None.
- Parameters:
step (Step) – The parsed step object.
- Returns:
The inlined run script or None if the run step cannot be validated.
- Return type:
str | None
- macaron.parsers.actionparser.get_step_input(step, key)
Get an input value from a GitHub Action step.
If the input value cannot be found or the step inputs cannot be validated this function returns None.
macaron.parsers.bashparser module
This module is a Python wrapper for the compiled bashparser binary.
The bashparser Go module is based on the github.com/mvdan/sh Go module and is distributed
together with Macaron as a compiled binary.
See Also https://github.com/mvdan/sh.
- macaron.parsers.bashparser.parse_file(file_path, macaron_path=None)
Parse a bash script file.
- Parameters:
- Returns:
The parsed bash script in JSON (dict) format.
- Return type:
- Raises:
ParseError – When parsing fails with errors.
- macaron.parsers.bashparser.parse(bash_content, macaron_path=None)
Parse a bash script’s content.
- Parameters:
- Returns:
The parsed bash script in JSON (dict) format.
- Return type:
- Raises:
ParseError – When parsing fails with errors.
- macaron.parsers.bashparser.parse_raw(bash_content, macaron_path=None)
Parse a bash script’s content.
- Parameters:
- Returns:
The parsed bash script AST in typed JSON (dict) format.
- Return type:
- Raises:
ParseError – When parsing fails with errors.
- macaron.parsers.bashparser.parse_expr(bash_expr_content, macaron_path=None)
Parse a bash script’s content.
- Parameters:
- Returns:
The parsed bash expr AST in typed JSON (dict) format.
- Return type:
- Raises:
ParseError – When parsing fails with errors.
macaron.parsers.bashparser_model module
Type definitions for Bash AST as produced (and json-serialised) by the “mvdan.cc/sh/v3/syntax” bash parser.
- class macaron.parsers.bashparser_model.UnAritOperators(value)
Bases:
Enum- Not = 34
- BitNegation = 35
- Inc = 36
- Dec = 37
- Plus = 68
- Minus = 70
- class macaron.parsers.bashparser_model.UnaryArithm
Bases:
TypedDict-
X:
Union[BinaryArithm,UnaryArithm,ParenArithm,Word]
-
X:
- macaron.parsers.bashparser_model.is_unary_arithm(expr)
- Return type:
TypeGuard[UnaryArithm]
- class macaron.parsers.bashparser_model.BinAritOperators(value)
Bases:
Enum- Add = 68
- Sub = 70
- Mul = 38
- Quo = 85
- Rem = 76
- Pow = 39
- Eql = 40
- Gtr = 54
- Lss = 56
- Neq = 41
- Leq = 42
- Geq = 43
- And = 9
- Or = 12
- Xor = 80
- Shr = 55
- Shl = 61
- AndArit = 10
- OrArit = 11
- Comma = 82
- TernQuest = 72
- TernColon = 87
- Assgn = 74
- AddAssgn = 44
- SubAssgn = 45
- MulAssgn = 46
- QuoAssgn = 47
- RemAssgn = 48
- AndAssgn = 49
- OrAssgn = 50
- XorAssgn = 51
- ShlAssgn = 52
- ShrAssgn = 53
- class macaron.parsers.bashparser_model.BinaryArithm
Bases:
TypedDict-
X:
Union[BinaryArithm,UnaryArithm,ParenArithm,Word]
-
Y:
Union[BinaryArithm,UnaryArithm,ParenArithm,Word]
-
X:
- macaron.parsers.bashparser_model.is_binary_arithm(expr)
- Return type:
TypeGuard[BinaryArithm]
- class macaron.parsers.bashparser_model.ParenArithm
Bases:
TypedDict-
X:
Union[BinaryArithm,UnaryArithm,ParenArithm,Word]
-
X:
- macaron.parsers.bashparser_model.is_paren_arithm(expr)
- Return type:
TypeGuard[ParenArithm]
- class macaron.parsers.bashparser_model.Slice
Bases:
TypedDict-
Offset:
Union[BinaryArithm,UnaryArithm,ParenArithm,Word]
-
Length:
Union[BinaryArithm,UnaryArithm,ParenArithm,Word]
-
Offset:
- class macaron.parsers.bashparser_model.ParNamesOperators(value)
Bases:
Enum- NamesPrefix = 38
- NamesPrefixWords = 84
- class macaron.parsers.bashparser_model.ParExpOperators(value)
Bases:
Enum- AlternateUnset = 68
- AlternateUnsetOrNull = 69
- DefaultUnset = 70
- DefaultUnsetOrNull = 71
- ErrorUnset = 72
- ErrorUnsetOrNull = 73
- AssignUnset = 74
- AssignUnsetOrNull = 75
- RemSmallSuffix = 76
- RemLargeSuffix = 77
- RemSmallPrefix = 78
- RemLargePrefix = 79
- UpperFirst = 80
- UpperAll = 81
- LowerFirst = 82
- LowerAll = 83
- OtherParamOps = 84
- class macaron.parsers.bashparser_model.ParamExp
Bases:
TypedDict-
Index:
NotRequired[Union[BinaryArithm,UnaryArithm,ParenArithm,Word]]
-
Index:
- class macaron.parsers.bashparser_model.ArithmExp
Bases:
TypedDict-
X:
Union[BinaryArithm,UnaryArithm,ParenArithm,Word]
-
X:
- class macaron.parsers.bashparser_model.GlobOperators(value)
Bases:
Enum- GlobZeroOrOne = 122
- GlobZeroOrMore = 123
- GlobOneOrMore = 124
- GlobOne = 125
- GlobExcept = 126
- class macaron.parsers.bashparser_model.RedirOperators(value)
Bases:
Enum- RdrOut = 54
- AppOut = 55
- RdrIn = 56
- RdrInOut = 57
- DplIn = 58
- DplOut = 59
- ClbOut = 60
- Hdoc = 61
- DashHdoc = 62
- WordHdoc = 63
- RdrAll = 64
- AppAll = 65
- class macaron.parsers.bashparser_model.ArrayElem
Bases:
TypedDict-
Index:
NotRequired[Union[BinaryArithm,UnaryArithm,ParenArithm,Word]]
-
Index:
- class macaron.parsers.bashparser_model.Assign
Bases:
TypedDict-
Index:
NotRequired[Union[BinaryArithm,UnaryArithm,ParenArithm,Word]]
-
Index:
- class macaron.parsers.bashparser_model.IfClause
Bases:
TypedDict-
Else:
NotRequired[IfClause|ElseClause]
-
Else:
- macaron.parsers.bashparser_model.is_else_clause(clause)
- Return type:
TypeGuard[ElseClause]
- macaron.parsers.bashparser_model.is_while_clause(cmd)
- Return type:
TypeGuard[WhileClause]
- class macaron.parsers.bashparser_model.CStyleLoop
Bases:
TypedDict-
Init:
NotRequired[Union[BinaryArithm,UnaryArithm,ParenArithm,Word]]
-
Cond:
NotRequired[Union[BinaryArithm,UnaryArithm,ParenArithm,Word]]
-
Post:
NotRequired[Union[BinaryArithm,UnaryArithm,ParenArithm,Word]]
-
Init:
- macaron.parsers.bashparser_model.is_cstyle_loop(loop)
- Return type:
TypeGuard[CStyleLoop]
- class macaron.parsers.bashparser_model.ForClause
Bases:
TypedDict-
Loop:
Union[WordIter,CStyleLoop]
-
Loop:
- class macaron.parsers.bashparser_model.CaseOperators(value)
Bases:
Enum- Break = 30
- Fallthrough = 31
- Resume = 32
- ResumeKorn = 33
- macaron.parsers.bashparser_model.is_case_clause(cmd)
- Return type:
TypeGuard[CaseClause]
- class macaron.parsers.bashparser_model.BinCmdOperators(value)
Bases:
Enum- AndStmt = 10
- OrStmt = 11
- Pipe = 12
- PipeAll = 13
- class macaron.parsers.bashparser_model.ArithmCmd
Bases:
TypedDict-
X:
Union[BinaryArithm,UnaryArithm,ParenArithm,Word]
-
X:
- class macaron.parsers.bashparser_model.BinTestOperators(value)
Bases:
Enum- TsReMatch = 112
- TsNewer = 113
- TsOlder = 114
- TsDevIno = 115
- TsEql = 116
- TsNeq = 117
- TsLeq = 118
- TsGeq = 119
- TsLss = 120
- TsGtr = 121
- AndTest = 10
- OrTest = 11
- TsMatchShort = 74
- TsMatch = 40
- TsNoMatch = 41
- TsBefore = 56
- TsAfter = 54
- class macaron.parsers.bashparser_model.BinaryTest
Bases:
TypedDict-
X:
Union[BinaryTest,UnaryTest,ParenTest,Word]
-
Y:
Union[BinaryTest,UnaryTest,ParenTest,Word]
-
X:
- macaron.parsers.bashparser_model.is_binary_test(test_expr)
- Return type:
TypeGuard[BinaryTest]
- class macaron.parsers.bashparser_model.UnTestOperators(value)
Bases:
Enum- TsExists = 88
- TsRegFile = 89
- TsDirect = 90
- TsCharSp = 91
- TsBlckSp = 92
- TsNmPipe = 93
- TsSocket = 94
- TsSmbLink = 95
- TsSticky = 96
- TsGIDSet = 97
- TsUIDSet = 98
- TsGrpOwn = 99
- TsUsrOwn = 100
- TsModif = 101
- TsRead = 102
- TsWrite = 103
- TsExec = 104
- TsNoEmpty = 105
- TsFdTerm = 106
- TsEmpStr = 107
- TsNempStr = 108
- TsOptSet = 109
- TsVarSet = 110
- TsRefVar = 111
- TsNot = 34
- class macaron.parsers.bashparser_model.UnaryTest
Bases:
TypedDict-
X:
Union[BinaryTest,UnaryTest,ParenTest,Word]
-
X:
- class macaron.parsers.bashparser_model.ParenTest
Bases:
TypedDict-
X:
Union[BinaryTest,UnaryTest,ParenTest,Word]
-
X:
- class macaron.parsers.bashparser_model.TestClause
Bases:
TypedDict-
X:
Union[BinaryTest,UnaryTest,ParenTest,Word]
-
X:
- macaron.parsers.bashparser_model.is_test_clause(cmd)
- Return type:
TypeGuard[TestClause]
- macaron.parsers.bashparser_model.is_decl_clause(cmd)
- Return type:
TypeGuard[DeclClause]
- class macaron.parsers.bashparser_model.LetClause
Bases:
TypedDict-
Exprs:
list[Union[BinaryArithm,UnaryArithm,ParenArithm,Word]]
-
Exprs:
- macaron.parsers.bashparser_model.is_time_clause(cmd)
- Return type:
TypeGuard[TimeClause]
- macaron.parsers.bashparser_model.is_coproc_clause(cmd)
- Return type:
TypeGuard[CoprocClause]
- class macaron.parsers.bashparser_model.Stmt
Bases:
TypedDict-
Cmd:
Union[CallExpr,IfClause,WhileClause,ForClause,CaseClause,Block,Subshell,BinaryCmd,FuncDecl,ArithmCmd,TestClause,DeclClause,LetClause,TimeClause,CoprocClause,TestDecl]
-
Cmd:
macaron.parsers.github_workflow_model module
- class macaron.parsers.github_workflow_model.On
Bases:
TypedDict-
pull_request:
NotRequired[Ref1]
-
pull_request_target:
NotRequired[Ref1]
-
push:
NotRequired[Ref1]
-
workflow_call:
NotRequired[WorkflowCall]
-
workflow_dispatch:
NotRequired[WorkflowDispatch]
-
schedule:
NotRequired[list[ScheduleItem]]
-
pull_request:
- class macaron.parsers.github_workflow_model.Container
Bases:
TypedDict-
credentials:
NotRequired[Credentials]
-
credentials:
- class macaron.parsers.github_workflow_model.ReusableWorkflowCallJob
Bases:
dict-
strategy:
NotRequired[Strategy]
-
strategy:
- class macaron.parsers.github_workflow_model.Identified(id, obj)
Bases:
Generic[T]- __init__(id, obj)
- macaron.parsers.github_workflow_model.is_normal_job(job)
- Return type:
TypeGuard[NormalJob]
- macaron.parsers.github_workflow_model.is_reusable_workflow_call_job(job)
- Return type:
TypeGuard[ReusableWorkflowCallJob]
- macaron.parsers.github_workflow_model.is_run_step(step)
- Return type:
TypeGuard[Step5]
- macaron.parsers.github_workflow_model.is_action_step(step)
- Return type:
TypeGuard[Step4]
macaron.parsers.pomparser module
This module contains the parser for POM files.