Package: oelint-parser
oelint-parseralternative parser for bitbake recipesAPI documentationFind the full API docshereExamplesfromoelint_parser.cls_stashimportStash# create an stash object_stash=Stash()# add any bitbake like file_stash.AddFile("/some/file")# Resolves proper cross file dependencies_stash.Finalize()# Use _stash.GetItemsFor() method to filter the stashGet variables from the filesTo get variables from the stash object dofromoelint_parser.cls_itemimportVariable# get all variables of the name PV from all filesforxin_stash.GetItemsFor(attribute=Variable.ATTR_VAR,attributeValue="PV"):print(x)this returns the raw object representationExpand raw variablesfromoelint_parser.cls_itemimportVariable# get all variables of the name PV from all filesforxin_stash.GetItemsFor(attribute=Variable.ATTR_VAR,attributeValue="PV"):# raw unexpanded variableprint(x.VarValue)# raw unexpanded variable without quotesprint(x.VarValueStripped)# expanded variableprint(expand_term(stash,"/some/file",x.VarValueStripped))# single items from a listprint(x.get_items())# expanded single items from a listprint([_stash.ExpandTerm("/some/file",y)foryinx.get_items()])FilteringYou can filter by multiple itemsfromoelint_parser.cls_itemimportVariable# get all variables of the name PV or BPV from all filesforxin_stash.GetItemsFor(attribute=Variable.ATTR_VAR,attributeValue=["PV","BPV"]):# variable nameprint(x.VarName)# raw unexpanded variableprint(x.VarValue)# raw unexpanded variable without quotesprint(x.VarValueStripped)and you can reduce the list after the initial filtering even morefromoelint_parser.cls_itemimportVariable# get all variables of the name PV or BPV from all files if the value is '1.0'forxin_stash.GetItemsFor(attribute=Variable.ATTR_VAR,attributeValue=["PV","BPV"]).reduce(attribute=Variable.ATTR_VARVAL,attributeValue=["1.0"]):# variable nameprint(x.VarName)# raw unexpanded variable -> "1.0"print(x.VarValue)# raw unexpanded variable without quotes -> 1.0print(x.VarValueStripped)but if you need copies from a wider list to smaller lists usefromoelint_parser.cls_itemimportVariable_all=_stash.GetItemsFor(attribute=Variable.ATTR_VAR,attributeValue=["PV","BPV"])_pv=_stash.Reduce(_all,attribute=Variable.ATTR_VAR,attributeValue="PV")_bpv=_stash.Reduce(_all,attribute=Variable.ATTR_VAR,attributeValue="BPV")forxin_pv:# variable nameprint(x.VarName)# raw unexpanded variable -> "1.0"print(x.VarValue)# raw unexpanded variable without quotes -> 1.0print(x.VarValueStripped)Expanding a VariableTo get the effective value of a Variable after parsing you can usefromoelint_parser.cls_itemimportVariableresult_set=_stash.ExpandVar(attribute=Variable.ATTR_VAR,attributeValue=["PV"]):print(result_set.get('PV'))Working with constantsFor this library a few basic sets of constant information, such as basic package definitions, known machines and functions are
needed.
Those can be easily modified, in case you have additional information to add/remove/modify.The actual database is not accessible by the user, but a few methods in theoelint_parse.constants.CONSTANTclass do exist.
Each of the method accepts a dictionary with the same key mapping as listed below (multilevel paths are displayed a JSON pointer)keytypedescriptiongetter for informationfunctions/knownlistknown functionsoelint_parse.constants.CONSTANT.FunctionsKnownfunctions/orderlistpreferred order of core functionsoelint_parse.constants.CONSTANT.FunctionsOrderimages/known-classeslistbbclasses to be known to be used in imagesoelint_parse.constants.CONSTANT.ImagesClassesimages/known-variableslistvariables known to be used in imagesoelint_parse.constants.CONSTANT.ImagesVariablesreplacements/distroslistknown distro overridesoelint_parse.constants.CONSTANT.DistrosKnownreplacements/machineslistknown machine overridesoelint_parse.constants.CONSTANT.MachinesKnownreplacements/mirrorsdictknown mirrorsoelint_parse.constants.CONSTANT.MirrorsKnownvariables/knownlistknown variablesoelint_parse.constants.CONSTANT.VariablesKnownvariables/mandatorylistvariables mandatory to a recipeoelint_parse.constants.CONSTANT.VariablesMandatoryvariables/orderlistpreferred order of variablesoelint_parse.constants.CONSTANT.VariablesOrdervariables/protectedlistvariables not to be used in recipesoelint_parse.constants.CONSTANT.VariablesProtectedvariables/protected-appendlistvariables not to be used in bbappendsoelint_parse.constants.CONSTANT.VariablesProtectedAppendvariables/suggestedlistsuggested variable in a recipeoelint_parse.constants.CONSTANT.VariablesSuggestedsets/basedictbase set of variables always used for value expansionoelint_parse.constants.CONSTANT.SetsBaseContributingBefore any contribution please run the following (preferably in an virtual environment)pipinstall-rrequirements.txt
flake8
pytest
./gendoc.sh