Skip to main content

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

# 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([_stash.ExpandTerm("/some/file", y, objref=x) for y in x.get_items()])

Filtering

You can filter by multiple items

from oelint_parser.cls_item import Variable

# get all variables of the name PV or BPV from all files
for x in _stash.GetItemsFor(attribute=Variable.ATTR_VAR, attributeValue=["PV", "BPV"]):
    # variable name
    print(x.VarName)
    # raw unexpanded variable
    print(x.VarValue)
    # raw unexpanded variable without quotes
    print(x.VarValueStripped)

and you can reduce the list after the initial filtering even more

from oelint_parser.cls_item import Variable

# get all variables of the name PV or BPV from all files if the value is '1.0'
for x in _stash.GetItemsFor(attribute=Variable.ATTR_VAR, attributeValue=["PV", "BPV"]).reduce(
                                attribute=Variable.ATTR_VARVAL, attributeValue=["1.0"]):
    # variable name
    print(x.VarName)
    # raw unexpanded variable -> "1.0"
    print(x.VarValue)
    # raw unexpanded variable without quotes -> 1.0
    print(x.VarValueStripped)

but if you need copies from a wider list to smaller lists use

from oelint_parser.cls_item import Variable

_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")

for x in _pv:
    # variable name
    print(x.VarName)
    # raw unexpanded variable -> "1.0"
    print(x.VarValue)
    # raw unexpanded variable without quotes -> 1.0
    print(x.VarValueStripped)

Expanding a Variable

To get the effective value of a Variable after parsing you can use

from oelint_parser.cls_item import Variable

result_set = _stash.ExpandVar(attribute=Variable.ATTR_VAR, attributeValue=["PV"]):
print(result_set.get('PV'))

Inline branch expansion

By default the parser will expand parsable and known inline blocks (${@oe.utils.something(...)}) to the branch value that would match if the programmed condition is true.

You can invert this selection by setting negative_inline to True in the Stash object.

E.g.

with some/file being

VAR_1 = "${@bb.utils.contains('BUILDHISTORY_FEATURES', 'image', 'foo', 'bar', d)}"

and

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()

the VAR_1's VarValue value would be foo.

With

from oelint_parser.cls_stash import Stash

# create an stash object
_stash = Stash(negative_inline=True)

# add any bitbake like file
_stash.AddFile("/some/file")

# Resolves proper cross file dependencies
_stash.Finalize()

the VAR_1's VarValue value would be bar.

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 directly 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
ignore/classes list classes to ignore in parsing oelint_parse.constants.CONSTANT.ClassIgnore
ignore/include list include/require files to ignore in parsing oelint_parse.constants.CONSTANT.IncludeIgnore
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
sets/base list base set of variables always used for value expansion oelint_parse.constants.CONSTANT.SetsBase
variables/known list known variables oelint_parse.constants.CONSTANT.VariablesKnown

For additional constants

from oelint_parser.constants import CONSTANTS

CONSTANTS.GetByPath('/-joined path')

will offer access

Contributing

Before any contribution please run the following

python3 -m venv --clear .env
. .env/bin/activate
pip install .[dev]
flake8 oelint_parser/ tests/
pytest
./gendoc.sh

Metadata

Release files for oelint-parser 8.13.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oelint-parser 8.13.2
File Size Uploaded
oelint_parser-8.13.2.tar.gz 30.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for oelint-parser 8.13.2
File Interpreter ABI Platform
oelint_parser-8.13.2-py3-none-any.whl Python 3 none any Details

Total release size: 103.6 kB

Release files / oelint_parser-8.13.2.tar.gz

Download URL oelint_parser-8.13.2.tar.gz
Size 30.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b60ab45101cd3b08f123d04f4813dedeb066c4ce6a28fce2784f56ab7a0a3f8e
BLAKE2b-256 checksum
How to use checksums
be4961a563455016c2363e5a3fd4565563dd98073569233a033a68138fcdea5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / oelint_parser-8.13.2-py3-none-any.whl

Download URL oelint_parser-8.13.2-py3-none-any.whl
Size 73.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e9191306bec32241084be09bf04ffed394d9b4d41ab5aa5cca5f80bfb9d12833
BLAKE2b-256 checksum
How to use checksums
e2b49cbcbc79596faabce5812af142d6121c4ad103f7e32950704047cd918c0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

8.13.2 This release

2 release files

8.13.1

2 release files

8.13.0

2 release files

8.12.5

2 release files

8.12.4

2 release files

8.12.1

2 release files

8.12.0

2 release files

8.11.6

2 release files

8.11.5

2 release files

8.11.4

2 release files

8.11.3

2 release files

8.11.2

2 release files

8.10.1

2 release files

8.10.0

2 release files

8.9.1

2 release files

8.9.0

2 release files

8.8.2

2 release files

8.8.1

2 release files

8.8.0

2 release files

8.7.2

2 release files

8.7.1

2 release files

8.7.0

2 release files

8.6.2

2 release files

8.6.1

2 release files

8.6.0

2 release files

8.5.1

2 release files

8.5.0

2 release files

8.4.3

2 release files

8.4.2

2 release files

8.4.1

2 release files

8.4.0

2 release files

8.3.0

2 release files

8.2.4

2 release files

8.2.3

2 release files

8.2.2

2 release files

8.2.1

2 release files

8.2.0

2 release files

8.1.1

2 release files

8.1.0

2 release files

8.0.2

2 release files

8.0.1

2 release files

8.0.0

2 release files

7.0.0

2 release files

6.5.0

2 release files

6.4.0

2 release files

6.3.1

2 release files

6.3.0

2 release files

6.2.0

2 release files

6.1.0

2 release files

6.0.0

2 release files

5.1.1

2 release files

5.1.0

2 release files

5.0.0

2 release files

4.0.2

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.5.5

2 release files

3.5.4

2 release files

3.5.3

2 release files

3.5.2

2 release files

3.5.1

2 release files

3.5.0

2 release files

3.4.1

2 release files

3.4.0

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.13.3

2 release files

2.13.2

2 release files

2.13.1

2 release files

2.13.0

2 release files

2.12.3

2 release files

2.12.2

2 release files

2.11.6

2 release files

2.11.5

2 release files

2.11.3

2 release files

2.11.1

2 release files

2.11.0

2 release files

2.10.3

2 release files

2.10.2

2 release files

2.9.5

2 release files

2.9.4

2 release files

2.9.3

2 release files

2.9.2

2 release files

2.9.1

2 release files

2.9.0

2 release files

2.8.1

2 release files

2.8.0

2 release files

2.7.0

2 release files

2.6.0

1 release file

2.5.0

1 release file

2.4.0

1 release file

2.3.1

1 release file

2.3.0

1 release file

2.2.2

1 release file

2.2.1

1 release file

2.2.0

1 release file

2.1.0

1 release file

2.0.0

2 release files

1.3.3

1 release file

1.3.2

2 release files

1.3.1

1 release file

1.3.0

1 release file

1.2.0

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.12

1 release file

1.0.11

2 release files

1.0.9

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page