Giter Club home page Giter Club logo

oelint-parser's Introduction

oelint-parser

Build status PyPI version Python version Downloads

alternative parser for bitbake recipes

API documentation

Find the full API docs here

Examples

from oelint_parser.cls_stash import Stash

# 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 stash

Get variables from the files

To get variables from the stash object do

from oelint_parser.cls_item import Variable

# get all variables of the name PV from all files
for x in _stash.GetItemsFor(attribute=Variable.ATTR_VAR, attributeValue="PV"):
    print(x)

this returns the raw object representation

Expand raw variables

from oelint_parser.cls_item import Variable
from oelint_parser.helper_files import expand_term

# get all variables of the name PV from all files
for x in _stash.GetItemsFor(attribute=Variable.ATTR_VAR, attributeValue="PV"):
    # raw unexpanded variable
    print(x.VarValue)
    # raw unexpanded variable without quotes
    print(x.VarValueStripped)
    # expanded variable
    print(expand_term(stash, "/some/file", x.VarValueStripped))
    # single items from a list
    print(x.get_items())
    # expanded single items from a list
    print([expand_term(stash, "/some/file", y) for y in x.get_items()])

Working with constants

For 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 the oelint_parse.constants.CONSTANT class do exist. Each of the method accepts a dictionary with the same key mapping as listed below (multilevel paths are displayed a JSON pointer)

key type description getter for information
functions/known list known functions oelint_parse.constants.CONSTANT.FunctionsKnown
functions/order list preferred order of core functions oelint_parse.constants.CONSTANT.FunctionsOrder
images/known-classes list bbclasses to be known to be used in images oelint_parse.constants.CONSTANT.ImagesClasses
images/known-variables list variables known to be used in images oelint_parse.constants.CONSTANT.ImagesVariables
replacements/distros list known distro overrides oelint_parse.constants.CONSTANT.DistrosKnown
replacements/machines list known machine overrides oelint_parse.constants.CONSTANT.MachinesKnown
replacements/mirrors dict known mirrors oelint_parse.constants.CONSTANT.MirrorsKnown
variables/known list known variables oelint_parse.constants.CONSTANT.VariablesKnown
variables/mandatory list variables mandatory to a recipe oelint_parse.constants.CONSTANT.VariablesMandatory
variables/order list preferred order of variables oelint_parse.constants.CONSTANT.VariablesOrder
variables/protected list variables not to be used in recipes oelint_parse.constants.CONSTANT.VariablesProtected
variables/protected-append list variables not to be used in bbappends oelint_parse.constants.CONSTANT.VariablesProtectedAppend
variables/suggested list suggested variable in a recipe oelint_parse.constants.CONSTANT.VariablesSuggested
sets/base dict base set of variables always used for value expansion oelint_parse.constants.CONSTANT.SetsBase

Backward compatibility with rule/constant file

Originally offered support for rule or constant files is offered by the two new methods

  • oelint_parse.constants.CONSTANT.AddFromRuleFile
  • oelint_parse.constants.CONSTANT.AddFromConstantFile

NOTE these interfaces are considered legacy interfaces and will be removed at some point in the future

Contributing

Before any contribution please run the following (preferably in an virtual environment)

pip install -r requirements.txt
flake8
pytest
./gendoc.sh

oelint-parser's People

Contributors

priv-kweihmann avatar dependabot[bot] avatar leonheldattoradex avatar sangmo-kang avatar skycaptain avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.