Package hydra.python
Interface Serde
-
public interface SerdePython serializer: converts Python AST to concrete syntax
-
-
Method Summary
Static Methods Modifier and Type Method Description static ExprannotatedRhsToExpr(AnnotatedRhs arhs)Serialize an annotated RHSstatic ExprannotatedStatementToExpr(AnnotatedStatement as_)Serialize an annotated statement (with optional doc comment)static ExprannotationToExpr(Annotation ann)Serialize a type annotationstatic ExprargsToExpr(Args args)Serialize function argumentsstatic ExprassignmentExpressionToExpr(AssignmentExpression ae)Serialize an assignment expression (walrus operator)static ExprassignmentToExpr(Assignment a)Serialize an assignmentstatic ExpratomToExpr(Atom atom)Serialize a Python atom (literal or basic expression)static ExprattributeToExpr(Attribute attr)Serialize an attribute accessstatic ExprawaitPrimaryToExpr(AwaitPrimary ap)Serialize an await primary expressionstatic ExprbitwiseAndToExpr(BitwiseAnd band)Serialize a bitwise AND expressionstatic ExprbitwiseOrToExpr(BitwiseOr bor)Serialize a bitwise OR expressionstatic ExprbitwiseXorToExpr(BitwiseXor bxor)Serialize a bitwise XOR expressionstatic ExprblockToExpr(Block b)Serialize a blockstatic ExprcapturePatternToExpr(CapturePattern cp)Serialize a capture patternstatic ExprcaseBlockToExpr(CaseBlock cb)Serialize a case blockstatic ExprclassDefinitionToExpr(ClassDefinition cd)Serialize a class definitionstatic ExprclassPatternToExpr(ClassPattern cp)Serialize a class patternstatic ExprclosedPatternToExpr(ClosedPattern cp)Serialize a closed patternstatic ExprcompareOpBitwiseOrPairToExpr(CompareOpBitwiseOrPair pair)Serialize a (compare-op, bitwise-or) pair as `<op> <rhs>`static java.lang.StringcompareOpToString(CompareOp op)Render a Python comparison operator to its source-code formstatic ExprcomparisonToExpr(Comparison cmp)Serialize a comparison expression: `<lhs>` if rhs is empty, otherwise `<lhs> <op1> <rhs1> <op2> <rhs2> ...`static ExprcompoundStatementToExpr(CompoundStatement cs)Serialize a compound (multi-line) Python statementstatic ExprconditionalToExpr(Conditional c)Serialize a conditional expression (ternary)static ExprconjunctionToExpr(Conjunction c)Serialize a conjunction (and expression)static ExprdecoratorsToExpr(Decorators decs)Serialize decoratorsstatic ExprdictToExpr(Dict d)Serialize a Python dictionarystatic ExprdisjunctionToExpr(Disjunction d)Serialize a disjunction (or expression)static ExprdottedAsNameToExpr(DottedAsName dan)Serialize a dotted as namestatic ExprdottedNameToExpr(DottedName dn)Serialize a dotted name (e.g., module.submodule)static ExprdoubleStarredKvpairToExpr(DoubleStarredKvpair dskv)Serialize a double-starred key-value pairstatic java.lang.StringescapePythonString(java.lang.Boolean doubleQuoted, java.lang.String s)Escape special characters in a Python string and wrap in quotesstatic ExprexpressionToExpr(Expression expr)Serialize a Python expressionstatic ExprfactorToExpr(Factor f)Serialize a factor expressionstatic ExprfunctionDefinitionToExpr(FunctionDefinition fd)Serialize a function definitionstatic ExprfunctionDefRawToExpr(FunctionDefRaw fdr)Serialize a raw function definitionstatic ExprgroupToExpr(Group g)Serialize a parenthesized groupstatic ExprguardToExpr(Guard g)Serialize a guard clausestatic ExprimportFromAsNameToExpr(ImportFromAsName ifan)Serialize an import from as namestatic ExprimportFromTargetsToExpr(ImportFromTargets t)Serialize import from targetsstatic ExprimportFromToExpr(ImportFrom if_)Serialize an import from statementstatic ExprimportNameToExpr(ImportName in_)Serialize an import namestatic ExprimportStatementToExpr(ImportStatement is_)Serialize an import statementstatic ExprinversionToExpr(Inversion i)Serialize an inversion (not expression)static ExprkeywordPatternsToExpr(KeywordPatterns kp)Serialize keyword patternsstatic ExprkeywordPatternToExpr(KeywordPattern kp)Serialize a keyword patternstatic ExprkvpairToExpr(Kvpair kv)Serialize a key-value pairstatic ExprkwargOrDoubleStarredToExpr(KwargOrDoubleStarred kds)Serialize a kwarg or double starredstatic ExprkwargOrStarredToExpr(KwargOrStarred ks)Serialize a kwarg or starredstatic ExprkwargToExpr(Kwarg k)Serialize a keyword argumentstatic ExprlambdaParametersToExpr(LambdaParameters lp)Serialize lambda parametersstatic ExprlambdaParamNoDefaultToExpr(LambdaParamNoDefault p)Serialize a lambda parameter without defaultstatic ExprlambdaStarEtcToExpr(LambdaStarEtc lse)Serialize lambda star etcstatic ExprlambdaToExpr(Lambda l)Serialize a lambda expressionstatic ExprlistToExpr(List l)Serialize a Python liststatic ExprmatchStatementToExpr(MatchStatement ms)Serialize a match statementstatic ExprmoduleToExpr(Module mod)Serialize a Python module to an AST expressionstatic ExprnamedExpressionToExpr(NamedExpression ne)Serialize a named expressionstatic ExprnameOrAttributeToExpr(NameOrAttribute noa)Serialize a name or attributestatic ExprnameToExpr(Name n)Serialize a Python name/identifierstatic ExprnumberToExpr(Number_ num)Serialize a Python number literalstatic ExprorPatternToExpr(OrPattern op)Serialize an or patternstatic ExprparametersToExpr(Parameters p)Serialize function parametersstatic ExprparamNoDefaultParametersToExpr(ParamNoDefaultParameters pndp)Serialize parameters without defaultsstatic ExprparamNoDefaultToExpr(ParamNoDefault pnd)Serialize a parameter without defaultstatic ExprparamToExpr(Param p)Serialize a parameterstatic ExprpatternCaptureTargetToExpr(PatternCaptureTarget pct)Serialize a pattern capture targetstatic ExprpatternsToExpr(Patterns ps)Serialize patternsstatic ExprpatternToExpr(Pattern p)Serialize a patternstatic ExprposArgToExpr(PosArg pa)Serialize a positional argumentstatic ExprpositionalPatternsToExpr(PositionalPatterns pp)Serialize positional patternsstatic ExprpowerToExpr(Power p)Serialize a power expressionstatic ExprprimaryRhsToExpr(PrimaryRhs rhs)Serialize a primary RHSstatic ExprprimaryToExpr(Primary p)Serialize a primary expressionstatic ExprprimaryWithRhsToExpr(PrimaryWithRhs pwr)Serialize a primary with RHSstatic java.lang.StringpythonDocEntityRef(EntityReference ref)Render a hydra.packaging.EntityReference as Sphinx/RST link syntaxstatic java.lang.StringpythonFloatLiteralText(java.lang.String s)static ExprraiseExpressionToExpr(RaiseExpression re)Serialize a raise expressionstatic ExprraiseStatementToExpr(RaiseStatement rs)Serialize a raise statementstatic ExprrelativeImportPrefixToExpr(RelativeImportPrefix p)Serialize a relative import prefixstatic ExprreturnStatementToExpr(ReturnStatement rs)Serialize a return statementstatic ExprsetToExpr(Set s)Serialize a Python setstatic ExprshiftExpressionToExpr(ShiftExpression se)Serialize a shift expressionstatic ExprsimpleStatementToExpr(SimpleStatement ss)Serialize a simple (single-line) Python statementstatic ExprsimpleTypeParameterToExpr(SimpleTypeParameter stp)Serialize a simple type parameterstatic ExprsingleTargetToExpr(SingleTarget st)Serialize a single targetstatic ExprsliceOrStarredExpressionToExpr(SliceOrStarredExpression s)Serialize a slice or starred expressionstatic ExprslicesToExpr(Slices s)Serialize slicesstatic ExprsliceToExpr(Slice s)Serialize a slicestatic ExprstarAtomToExpr(StarAtom sa)Serialize a star atomstatic ExprstarExpressionToExpr(StarExpression se)Serialize a star expressionstatic ExprstarNamedExpressionToExpr(StarNamedExpression sne)Serialize a star named expressionstatic ExprstarredExpressionToExpr(StarredExpression se)Serialize a starred expressionstatic ExprstarTargetToExpr(StarTarget st)Serialize a star targetstatic ExprstatementToExpr(Statement stmt)Serialize a Python statementstatic java.lang.StringstringPrefixToText(StringPrefix p)Serialize a Python string prefix to its source-form charactersstatic ExprstringToExpr(String_ s)Serialize a Python string literalstatic ExprsubjectExpressionToExpr(SubjectExpression se)Serialize a subject expressionstatic ExprsumToExpr(Sum s)Serialize a sum expressionstatic ExprtargetWithStarAtomToExpr(TargetWithStarAtom t)Serialize a target with star atomstatic ExprtermToExpr(Term t)Serialize a term expressionstatic java.lang.StringtoPythonComments(java.lang.String doc_)Convert a doc string to Python comment format.static ExprtPrimaryAndNameToExpr(TPrimaryAndName pn)Serialize a TPrimaryAndName as primary.namestatic ExprtPrimaryToExpr(TPrimary tp)Serialize a target-side primary expressionstatic ExprtupleToExpr(Tuple t)Serialize a Python tuplestatic ExprtypeAliasToExpr(TypeAlias ta)Serialize a type aliasstatic ExprtypedAssignmentToExpr(TypedAssignment ta)Serialize a typed assignmentstatic ExprtypeParameterToExpr(TypeParameter tp)Serialize a type parameterstatic ExpruntypedAssignmentToExpr(UntypedAssignment ua)Serialize an untyped assignmentstatic ExprvaluePatternToExpr(ValuePattern vp)Serialize a value patternstatic ExprwhileStatementToExpr(WhileStatement ws)Serialize a while statement
-
-
-
Method Detail
-
annotatedRhsToExpr
static Expr annotatedRhsToExpr(AnnotatedRhs arhs)
Serialize an annotated RHS
-
annotatedStatementToExpr
static Expr annotatedStatementToExpr(AnnotatedStatement as_)
Serialize an annotated statement (with optional doc comment)
-
annotationToExpr
static Expr annotationToExpr(Annotation ann)
Serialize a type annotation
-
assignmentExpressionToExpr
static Expr assignmentExpressionToExpr(AssignmentExpression ae)
Serialize an assignment expression (walrus operator)
-
assignmentToExpr
static Expr assignmentToExpr(Assignment a)
Serialize an assignment
-
awaitPrimaryToExpr
static Expr awaitPrimaryToExpr(AwaitPrimary ap)
Serialize an await primary expression
-
bitwiseAndToExpr
static Expr bitwiseAndToExpr(BitwiseAnd band)
Serialize a bitwise AND expression
-
bitwiseXorToExpr
static Expr bitwiseXorToExpr(BitwiseXor bxor)
Serialize a bitwise XOR expression
-
capturePatternToExpr
static Expr capturePatternToExpr(CapturePattern cp)
Serialize a capture pattern
-
classDefinitionToExpr
static Expr classDefinitionToExpr(ClassDefinition cd)
Serialize a class definition
-
classPatternToExpr
static Expr classPatternToExpr(ClassPattern cp)
Serialize a class pattern
-
closedPatternToExpr
static Expr closedPatternToExpr(ClosedPattern cp)
Serialize a closed pattern
-
compareOpBitwiseOrPairToExpr
static Expr compareOpBitwiseOrPairToExpr(CompareOpBitwiseOrPair pair)
Serialize a (compare-op, bitwise-or) pair as `<op> <rhs>`
-
compareOpToString
static java.lang.String compareOpToString(CompareOp op)
Render a Python comparison operator to its source-code form
-
comparisonToExpr
static Expr comparisonToExpr(Comparison cmp)
Serialize a comparison expression: `<lhs>` if rhs is empty, otherwise `<lhs> <op1> <rhs1> <op2> <rhs2> ...`
-
compoundStatementToExpr
static Expr compoundStatementToExpr(CompoundStatement cs)
Serialize a compound (multi-line) Python statement
-
conditionalToExpr
static Expr conditionalToExpr(Conditional c)
Serialize a conditional expression (ternary)
-
conjunctionToExpr
static Expr conjunctionToExpr(Conjunction c)
Serialize a conjunction (and expression)
-
decoratorsToExpr
static Expr decoratorsToExpr(Decorators decs)
Serialize decorators
-
disjunctionToExpr
static Expr disjunctionToExpr(Disjunction d)
Serialize a disjunction (or expression)
-
dottedAsNameToExpr
static Expr dottedAsNameToExpr(DottedAsName dan)
Serialize a dotted as name
-
dottedNameToExpr
static Expr dottedNameToExpr(DottedName dn)
Serialize a dotted name (e.g., module.submodule)
-
doubleStarredKvpairToExpr
static Expr doubleStarredKvpairToExpr(DoubleStarredKvpair dskv)
Serialize a double-starred key-value pair
-
escapePythonString
static java.lang.String escapePythonString(java.lang.Boolean doubleQuoted, java.lang.String s)Escape special characters in a Python string and wrap in quotes
-
expressionToExpr
static Expr expressionToExpr(Expression expr)
Serialize a Python expression
-
functionDefRawToExpr
static Expr functionDefRawToExpr(FunctionDefRaw fdr)
Serialize a raw function definition
-
functionDefinitionToExpr
static Expr functionDefinitionToExpr(FunctionDefinition fd)
Serialize a function definition
-
importFromAsNameToExpr
static Expr importFromAsNameToExpr(ImportFromAsName ifan)
Serialize an import from as name
-
importFromTargetsToExpr
static Expr importFromTargetsToExpr(ImportFromTargets t)
Serialize import from targets
-
importFromToExpr
static Expr importFromToExpr(ImportFrom if_)
Serialize an import from statement
-
importNameToExpr
static Expr importNameToExpr(ImportName in_)
Serialize an import name
-
importStatementToExpr
static Expr importStatementToExpr(ImportStatement is_)
Serialize an import statement
-
keywordPatternToExpr
static Expr keywordPatternToExpr(KeywordPattern kp)
Serialize a keyword pattern
-
keywordPatternsToExpr
static Expr keywordPatternsToExpr(KeywordPatterns kp)
Serialize keyword patterns
-
kwargOrDoubleStarredToExpr
static Expr kwargOrDoubleStarredToExpr(KwargOrDoubleStarred kds)
Serialize a kwarg or double starred
-
kwargOrStarredToExpr
static Expr kwargOrStarredToExpr(KwargOrStarred ks)
Serialize a kwarg or starred
-
lambdaParamNoDefaultToExpr
static Expr lambdaParamNoDefaultToExpr(LambdaParamNoDefault p)
Serialize a lambda parameter without default
-
lambdaParametersToExpr
static Expr lambdaParametersToExpr(LambdaParameters lp)
Serialize lambda parameters
-
lambdaStarEtcToExpr
static Expr lambdaStarEtcToExpr(LambdaStarEtc lse)
Serialize lambda star etc
-
matchStatementToExpr
static Expr matchStatementToExpr(MatchStatement ms)
Serialize a match statement
-
nameOrAttributeToExpr
static Expr nameOrAttributeToExpr(NameOrAttribute noa)
Serialize a name or attribute
-
namedExpressionToExpr
static Expr namedExpressionToExpr(NamedExpression ne)
Serialize a named expression
-
paramNoDefaultParametersToExpr
static Expr paramNoDefaultParametersToExpr(ParamNoDefaultParameters pndp)
Serialize parameters without defaults
-
paramNoDefaultToExpr
static Expr paramNoDefaultToExpr(ParamNoDefault pnd)
Serialize a parameter without default
-
parametersToExpr
static Expr parametersToExpr(Parameters p)
Serialize function parameters
-
patternCaptureTargetToExpr
static Expr patternCaptureTargetToExpr(PatternCaptureTarget pct)
Serialize a pattern capture target
-
positionalPatternsToExpr
static Expr positionalPatternsToExpr(PositionalPatterns pp)
Serialize positional patterns
-
primaryRhsToExpr
static Expr primaryRhsToExpr(PrimaryRhs rhs)
Serialize a primary RHS
-
primaryWithRhsToExpr
static Expr primaryWithRhsToExpr(PrimaryWithRhs pwr)
Serialize a primary with RHS
-
pythonDocEntityRef
static java.lang.String pythonDocEntityRef(EntityReference ref)
Render a hydra.packaging.EntityReference as Sphinx/RST link syntax
-
pythonFloatLiteralText
static java.lang.String pythonFloatLiteralText(java.lang.String s)
-
raiseExpressionToExpr
static Expr raiseExpressionToExpr(RaiseExpression re)
Serialize a raise expression
-
raiseStatementToExpr
static Expr raiseStatementToExpr(RaiseStatement rs)
Serialize a raise statement
-
relativeImportPrefixToExpr
static Expr relativeImportPrefixToExpr(RelativeImportPrefix p)
Serialize a relative import prefix
-
returnStatementToExpr
static Expr returnStatementToExpr(ReturnStatement rs)
Serialize a return statement
-
shiftExpressionToExpr
static Expr shiftExpressionToExpr(ShiftExpression se)
Serialize a shift expression
-
simpleStatementToExpr
static Expr simpleStatementToExpr(SimpleStatement ss)
Serialize a simple (single-line) Python statement
-
simpleTypeParameterToExpr
static Expr simpleTypeParameterToExpr(SimpleTypeParameter stp)
Serialize a simple type parameter
-
singleTargetToExpr
static Expr singleTargetToExpr(SingleTarget st)
Serialize a single target
-
sliceOrStarredExpressionToExpr
static Expr sliceOrStarredExpressionToExpr(SliceOrStarredExpression s)
Serialize a slice or starred expression
-
starExpressionToExpr
static Expr starExpressionToExpr(StarExpression se)
Serialize a star expression
-
starNamedExpressionToExpr
static Expr starNamedExpressionToExpr(StarNamedExpression sne)
Serialize a star named expression
-
starTargetToExpr
static Expr starTargetToExpr(StarTarget st)
Serialize a star target
-
starredExpressionToExpr
static Expr starredExpressionToExpr(StarredExpression se)
Serialize a starred expression
-
stringPrefixToText
static java.lang.String stringPrefixToText(StringPrefix p)
Serialize a Python string prefix to its source-form characters
-
subjectExpressionToExpr
static Expr subjectExpressionToExpr(SubjectExpression se)
Serialize a subject expression
-
tPrimaryAndNameToExpr
static Expr tPrimaryAndNameToExpr(TPrimaryAndName pn)
Serialize a TPrimaryAndName as primary.name
-
targetWithStarAtomToExpr
static Expr targetWithStarAtomToExpr(TargetWithStarAtom t)
Serialize a target with star atom
-
toPythonComments
static java.lang.String toPythonComments(java.lang.String doc_)
Convert a doc string to Python comment format. Empty source lines emit `#` (no trailing space) so blank comment lines don't carry trailing whitespace into the generated file.
-
typeParameterToExpr
static Expr typeParameterToExpr(TypeParameter tp)
Serialize a type parameter
-
typedAssignmentToExpr
static Expr typedAssignmentToExpr(TypedAssignment ta)
Serialize a typed assignment
-
untypedAssignmentToExpr
static Expr untypedAssignmentToExpr(UntypedAssignment ua)
Serialize an untyped assignment
-
valuePatternToExpr
static Expr valuePatternToExpr(ValuePattern vp)
Serialize a value pattern
-
whileStatementToExpr
static Expr whileStatementToExpr(WhileStatement ws)
Serialize a while statement
-
-