Skip to content

Latest commit

 

History

History
2654 lines (1643 loc) · 49.3 KB

api-documentation.md

File metadata and controls

2654 lines (1643 loc) · 49.3 KB

Table of Contents

oelint_parser

oelint_parser.const_vars

set_constantfile

def set_constantfile(obj)

set constants

Arguments:

  • obj dict - dictionary with constants

set_rulefile

def set_rulefile(obj)

set rules

Arguments:

  • obj dict - dictionary with rule definitions

get_mandatory_vars

def get_mandatory_vars()

get mandatory variables

Returns:

  • list - list of mandatory variable names

get_suggested_vars

def get_suggested_vars()

get suggested variables

Returns:

  • list - list of suggested variable names

get_known_mirrors

def get_known_mirrors()

get known mirror replacements

Returns:

  • dict - dictionary of known mirror replacements

get_protected_vars

def get_protected_vars()

get protected variables

Returns:

  • list - list of protected variables

get_protected_append_vars

def get_protected_append_vars()

get protected variables in bbappends

Returns:

  • list - list of protected variables

get_known_vars

def get_known_vars()

get list of known variables

Returns:

  • list - list of known variable names

get_known_distros

def get_known_distros()

get known distros

Returns:

  • list - list of known distro names

get_known_machines

def get_known_machines()

get known machines

Returns:

  • list - list of known machine names

get_image_classes

def get_image_classes()

get known classes used exclusively in an image

Returns:

  • list - list of known class names

get_image_variables

def get_image_variables()

get known variables used exclusively in an image

Returns:

  • list - list of known variable names

get_base_varset

def get_base_varset()

get variable baseset Set includes basic package definitions

Returns:

  • dict - base variable set

oelint_parser.cls_stash

Stash Objects

class Stash()

__init__

def __init__(quiet=False)

constructor

AddFile

def AddFile(_file, lineOffset=0, forcedLink=None)

Adds a file to the stash

Arguments:

  • _file str - Full path to file

Arguments:

  • lineOffset int - Line offset from the file that include this file (default: {0})
  • forcedLink type - Force link against a file (default: {None})

Returns:

  • list - List of {oelint_parser.cls_item.Item}

Append

def Append(item)

appends one or mote items to the stash

Arguments:

  • item Item - Item(s) to append

Remove

def Remove(item)

removes one or more items from the stash

Arguments:

  • item Item - Item(s) to remove

GetRecipes

def GetRecipes()

Get bb files in stash

Returns:

  • list - List of bb files in stash

GetLoneAppends

def GetLoneAppends()

Get bbappend without a matching bb

Returns:

  • list - list of bbappend without a matching bb

GetLinksForFile

def GetLinksForFile(filename)

Get file which this file is linked against

Arguments:

  • filename str - full path to file

Returns:

  • list - list of full paths the file is linked against

GetItemsFor

def GetItemsFor(filename=None,
                classifier=None,
                attribute=None,
                attributeValue=None,
                nolink=False)

Get items for filename

Arguments:

  • filename str - Full path to file (default: {None})
  • classifier str - class specifier (e.g. Variable) (default: {None})
  • attribute str - class attribute name (default: {None})
  • attributeValue str - value of the class attribute name (default: {None})
  • nolink bool - Consider linked files (default: {False})

Returns:

  • [type] - [description]

ExpandVar

def ExpandVar(filename=None,
              attribute=None,
              attributeValue=None,
              nolink=False)

Expand variable to dictionary

Arguments:

  • filename str - Full path to file (default: {None})
  • attribute str - class attribute name (default: {None})
  • attributeValue str - value of the class attribute name (default: {None})
  • nolink bool - Consider linked files (default: {False})

Returns:

  • {dict} - expanded variables from call + base set of variables

oelint_parser.rpl_regex

RegexRpl Objects

class RegexRpl()

Safe regex replacements

search

@staticmethod
def search(pattern, string, timeout=5, default=None, *args, **kwargs)

replacement for re.search

Arguments:

  • pattern str - regex pattern
  • string str - input string
  • timeout int, optional - Timeout for operation. On timeout default will be returned. Defaults to 5.
  • default type, optional - Default to return on timeout. Defaults to None.

Returns:

  • Match - Match object or None

split

@staticmethod
def split(pattern, string, timeout=5, default=None, *args, **kwargs)

replacement for re.split

Arguments:

  • pattern str - regex pattern
  • string str - input string
  • timeout int, optional - Timeout for operation. On timeout default will be returned. Defaults to 5.
  • default type, optional - Default to return on timeout. Defaults to None.

Returns:

  • list - list object or None

match

@staticmethod
def match(pattern, string, timeout=5, default=None, *args, **kwargs)

replacement for re.match

Arguments:

  • pattern str - regex pattern
  • string str - input string
  • timeout int, optional - Timeout for operation. On timeout default will be returned. Defaults to 5.
  • default type, optional - Default to return on timeout. Defaults to None.

Returns:

  • Match - Match object or None

sub

@staticmethod
def sub(pattern, repl, string, timeout=5, default='', *args, **kwargs)

replacement for re.sub

Arguments:

  • pattern str - regex pattern
  • repl str - replacement string
  • string str - input string
  • timeout int, optional - Timeout for operation. On timeout default will be returned. Defaults to 5.
  • default type, optional - Default to return on timeout. Defaults to ''.

Returns:

  • str - string

finditer

@staticmethod
def finditer(pattern, string, timeout=5, default=None, *args, **kwargs)

replacement for re.finditer

Arguments:

  • pattern str - regex pattern
  • string str - input string
  • timeout int, optional - Timeout for operation. On timeout default will be returned. Defaults to 5.
  • default type, optional - Default to return on timeout. Defaults to None.

Returns:

  • Scanner - Scanner object or None

oelint_parser.const_func

oelint_parser.inlinerep

oelint_parser.helper_files

get_files

def get_files(stash, _file, pattern)

Get files matching SRC_URI entries

Arguments:

  • stash oelint_parser.cls_stash.Stash - current stash
  • _file str - Full path to filename
  • pattern str - glob pattern to apply

Returns:

  • list - list of files matching pattern

get_layer_root

def get_layer_root(name)

Find the path to the layer root of a file

Arguments:

  • name str - filename

Returns:

  • str - path to layer root or empty string

find_local_or_in_layer

def find_local_or_in_layer(name, localdir)

Find file in local dir or in layer

Arguments:

  • name str - filename
  • localdir str - path to local dir

Returns:

  • str - path to found file or None

get_scr_components

def get_scr_components(string)

Return SRC_URI components

Arguments:

  • string str - raw string

Returns:

  • dict - scheme: protocol used, src: source URI, options: parsed options

safe_linesplit

def safe_linesplit(string)

Split line in a safe manner

Arguments:

  • string str - raw input

Returns:

  • list - safely split input

guess_recipe_name

def guess_recipe_name(_file)

Get the recipe name from filename

Arguments:

  • _file str - filename

Returns:

  • str - recipe name

guess_base_recipe_name

def guess_base_recipe_name(_file)

Get the base recipe name from filename (aka BPN)

Arguments:

  • _file str - filename

Returns:

  • str - recipe name

guess_recipe_version

def guess_recipe_version(_file)

Get recipe version from filename

Arguments:

  • _file str - filename

Returns:

  • str - recipe version

expand_term

def expand_term(stash, _file, value, spare=None, seen=None)

Expand a variable (replacing all variables by known content)

Arguments:

  • stash oelint_parser.cls_stash.Stash - current stash
  • _file str - Full path to file
  • value str - Variable value to expand

Returns:

  • str - expanded value

get_valid_package_names

def get_valid_package_names(stash, _file, strippn=False)

Get known valid names for packages

Arguments:

  • stash oelint_parser.cls_stash.Stash - current stash
  • _file str - Full path to file

Returns:

  • list - list of valid package names

get_valid_named_resources

def get_valid_named_resources(stash, _file)

Get list of valid SRCREV resource names

Arguments:

  • stash oelint_parser.cls_stash.Stash - current stash
  • _file str - Full path to file

Returns:

  • list - list of valid SRCREV resource names

is_image

def is_image(stash, _file)

returns if the file is likely an image recipe or not

Arguments:

  • stash oelint_parser.cls_stash.Stash - current stash
  • _file str - Full path to file

Returns:

  • bool - True if _file is an image recipe

is_packagegroup

def is_packagegroup(stash, _file)

returns if the file is likely a packagegroup recipe or not

Arguments:

  • stash oelint_parser.cls_stash.Stash - current stash
  • _file str - Full path to file

Returns:

  • bool - True if _file is a packagegroup recipe

oelint_parser.constants

Constants Objects

class Constants()

Interface for constants

AddConstants

def AddConstants(_dict)

Add constants to the existing

Arguments:

  • dict dict - constant dictionary to add

RemoveConstants

def RemoveConstants(_dict)

Remove constants from the existing

Arguments:

  • dict dict - constant dictionary to remove

OverrideConstants

def OverrideConstants(_dict)

Override constants in the existing db

Arguments:

  • dict dict] - constant dictionary with override values

AddFromRuleFile

def AddFromRuleFile(_dict)

Legacy interface to support rule files

Arguments:

  • dict dict - rule file dictionary

AddFromConstantFile

def AddFromConstantFile(_dict)

Legacy interface to support constant files

Arguments:

  • dict dict - constant file dictionary

FunctionsKnown

@property
def FunctionsKnown()

Return known functions

Returns:

  • list - list of known functions

FunctionsOrder

@property
def FunctionsOrder()

Return function order

Returns:

  • list - List of functions to order in their designated order

VariablesMandatory

@property
def VariablesMandatory()

Return mandatory variables

Returns:

  • list - List of mandatory variables

VariablesSuggested

@property
def VariablesSuggested()

Return suggested variables

Returns:

  • list - List of suggested variables

MirrorsKnown

@property
def MirrorsKnown()

Return known mirrors and their replacements

Returns:

  • dict - Dict of known mirrors and their replacements

VariablesProtected

@property
def VariablesProtected()

Return protected variables

Returns:

  • list - List of protected variables

VariablesProtectedAppend

@property
def VariablesProtectedAppend()

Return protected variables in bbappend files

Returns:

  • list - List of protected variables in bbappend files

VariablesOrder

@property
def VariablesOrder()

Variable order

Returns:

  • list - List of variables to order in their designated order

VariablesKnown

@property
def VariablesKnown()

Known variables

Returns:

  • list - List of known variables

DistrosKnown

@property
def DistrosKnown()

Known distros

Returns:

  • list - List of known distros

MachinesKnown

@property
def MachinesKnown()

Known machines

Returns:

  • list - List of known machines

ImagesClasses

@property
def ImagesClasses()

Classes that are used in images

Returns:

  • list - Classes that are used in images

ImagesVariables

@property
def ImagesVariables()

Variables that are used in images

Returns:

  • list - Variables that are used in images

SetsBase

@property
def SetsBase()

Base variable set

Returns:

  • dict - dictionary with base variable set

oelint_parser.cls_item

Item Objects

class Item()

Base class for all Stash items

__init__

def __init__(origin, line, infileline, rawtext, realraw)

constructor

Arguments:

  • origin str - Full path of origin file
  • line int - Overall line counter
  • infileline int - Line number in file
  • rawtext str - Raw input string (except inline code blocks)
  • realraw str - Unprocessed input

Line

@property
def Line()

Overall line count

Returns:

  • int - overall line count of item

Raw

@property
def Raw()

Raw string (without inline code blocks)

Returns:

  • str - raw string of item

Links

@property
def Links()

Linked files

Returns:

  • list - list of full path of linked files

Origin

@property
def Origin()

origin of item

Returns:

  • str - full path of origin file

InFileLine

@property
def InFileLine()

Line count in file

Returns:

  • int - [description]

IncludedFrom

@property
def IncludedFrom()

Files include this item

Returns:

  • list - list of files including this item

RealRaw

@property
def RealRaw()

Completely unprocessed raw text

Returns:

  • str - completely unprocessed raw text

IsFromClass

@property
def IsFromClass()

Item comes from a bbclass

Returns:

  • bool - if item was set in a bbclass

OverrideDelimiter

@property
def OverrideDelimiter()

Override delimiter

Returns:

  • str - Override delimiter

safe_linesplit

@staticmethod
def safe_linesplit(string)

Safely split an input line to chunks

Arguments:

  • string str - raw input string

Returns:

  • list - list of chunks of original string

get_items

def get_items()

Return single items

Returns:

  • list - lines of raw input

extract_sub

def extract_sub(name)

Extract modifiers

Arguments:

  • name str - input string

Returns:

  • tuple - clean variable name, modifiers, package specific modifiers

extract_sub_func

def extract_sub_func(name)

Extract modifiers for functions

Arguments:

  • name str - input value

Returns:

  • tuple - clean function name, modifiers

IsFromAppend

def IsFromAppend()

Item originates from a bbappend

Returns:

  • bool - True if coming from a bbappend

AddLink

def AddLink(_file)

Links files to each other in stash

Arguments:

  • _file str - Full path of file to link against

GetAttributes

def GetAttributes()

Get all public attributes of this class

Returns:

  • dict - all public attributes and their values

Variable Objects

class Variable(Item)

Stash item for variables

__init__

def __init__(origin, line, infileline, rawtext, name, value, operator, flag,
             realraw)

constructor

Arguments:

  • origin str - Full path to file of origin
  • line int - Overall line counter
  • infileline int - Line counter in the particular file
  • rawtext str - Raw input string (except inline code blocks)
  • realraw str - Unprocessed input
  • name str - Variable name
  • value str - Variable value
  • operator str - Operation performed to the variable
  • flag str - Optional variable flag

VarName

@property
def VarName()

Variable name

Returns:

  • str - name of variable

SubItem

@property
def SubItem()

Variable modifiers

Returns:

  • str - variable modifiers like packages, machines, appends, prepends

SubItems

@property
def SubItems()

Variable modifiers list

Returns:

  • list - variable modifiers list like packages, machines, appends, prepends

VarValue

@property
def VarValue()

variable value

Returns:

  • str - unstripped variable value

VarOp

@property
def VarOp()

Variable operation

Returns:

  • str - operation did on the variable

Flag

@property
def Flag()

Variable flag like PACKAGECONFIG[xyz]

Returns:

  • str - variable sub flags

VarNameComplete

@property
def VarNameComplete()

Complete variable name included overrides and flags

Returns:

  • str - complete variable name

RawVarName

@property
def RawVarName()

Variable name and flags combined

Returns:

  • str - raw representation of the variable name

VarValueStripped

@property
def VarValueStripped()

Stripped variable value

Returns:

  • str - stripped version of variable value

IsAppend

def IsAppend()

Check if operation is an append

Returns:

  • bool - True is variable is appended

AppendOperation

def AppendOperation()

Get variable modifiers

Returns:

  • list - list could contain any combination of 'append', ' += ', 'prepend' and 'remove'

get_items

def get_items(override="", versioned=False)

Get items of variable value

Arguments:

  • override str - String to take instead of VarValue
  • versioned bool - items can be versioned (versions will be stripped in this case)

Returns:

  • list - clean list of items in variable value

IsMultiLine

def IsMultiLine()

Check if variable has a multiline assignment

Returns:

  • bool - True if multiline

GetDistroEntry

def GetDistroEntry()

Get distro specific entries in variable

Returns:

  • str - distro specific modifier of variable or ""

GetMachineEntry

def GetMachineEntry()

Get machine specific entries in variable

Returns:

  • str - machine specific modifier of variable or ""

GetClassOverride

def GetClassOverride()

Get class specific entries in variable

Returns:

  • str - class specific modifier of variable or ""

Comment Objects

class Comment(Item)

__init__

def __init__(origin, line, infileline, rawtext, realraw)

constructor

Arguments:

  • origin str - Full path to file of origin
  • line int - Overall line counter
  • infileline int - Line counter in the particular file
  • rawtext str - Raw input string (except inline code blocks)
  • realraw str - Unprocessed input

get_items

def get_items()

Get single lines of block

Returns:

  • list - single lines of comment block

Include Objects

class Include(Item)

__init__

def __init__(origin, line, infileline, rawtext, incname, statement, realraw)

constructor

Arguments:

  • origin str - Full path to file of origin
  • line int - Overall line counter
  • infileline int - Line counter in the particular file
  • rawtext str - Raw input string (except inline code blocks)
  • realraw str - Unprocessed input
  • incname str - raw name of the include file
  • statement str - either include or require

IncName

@property
def IncName()

Include name

Returns:

  • str - name of the file to include/require

Statement

@property
def Statement()

statement either include or require

Returns:

  • str - include or require

get_items

def get_items()

Get items

Returns:

  • list - include name, include statement

Export Objects

class Export(Item)

__init__

def __init__(origin, line, infileline, rawtext, name, value, realraw)

constructor

Arguments:

  • origin str - Full path to file of origin
  • line int - Overall line counter
  • infileline int - Line counter in the particular file
  • rawtext str - Raw input string (except inline code blocks)
  • realraw str - Unprocessed input
  • name str - variable name of the export
  • value str - (optional) value of the export

Name

@property
def Name()

Name of the exported var

Returns:

  • str - name of the exported var

Value

@property
def Value()

value of the export

Returns:

  • str - optional value of the export

get_items

def get_items()

Get items

Returns:

  • list - include name, include statement

Function Objects

class Function(Item)

__init__

def __init__(origin,
             line,
             infileline,
             rawtext,
             name,
             body,
             realraw,
             python=False,
             fakeroot=False)

[summary]

Arguments:

  • origin str - Full path to file of origin
  • line int - Overall line counter
  • infileline int - Line counter in the particular file
  • rawtext str - Raw input string (except inline code blocks)
  • realraw str - Unprocessed input
  • name str - Raw function name
  • body str - Function body

Arguments:

  • python bool - python function according to parser (default: {False})
  • fakeroot bool - uses fakeroot (default: {False})

IsPython

@property
def IsPython()

Is python function

Returns:

  • bool - is a python function

IsFakeroot

@property
def IsFakeroot()

Is fakeroot function

Returns:

  • bool - is a python function

FuncName

@property
def FuncName()

Function name

Returns:

  • str - name of function

FuncNameComplete

@property
def FuncNameComplete()

Complete function name (including overrides)

Returns:

  • str - complete name of function

SubItem

@property
def SubItem()

Function modifiers

Returns:

  • str - function modifiers like packages, machines, appends, prepends

SubItems

@property
def SubItems()

Function modifiers list

Returns:

  • list - function modifiers list like packages, machines, appends, prepends

FuncBody

@property
def FuncBody()

Function body

Returns:

  • str - function body text

FuncBodyStripped

@property
def FuncBodyStripped()

Stripped function body

Returns:

  • str - stripped function body text

FuncBodyRaw

@property
def FuncBodyRaw()

Raw function body (including brackets)

Returns:

  • str - raw function body text

GetDistroEntry

def GetDistroEntry()

Get distro specific modifiers

Returns:

  • str - distro specific modifier or ""

GetMachineEntry

def GetMachineEntry()

Get machine specific modifiers

Returns:

  • str - machine specific modifier or ""

IsAppend

def IsAppend()

Return if function appends another function

Returns:

  • bool - True is append or prepend operation

get_items

def get_items()

Get items of function body

Returns:

  • list - single lines of function body

PythonBlock Objects

class PythonBlock(Item)

__init__

def __init__(origin, line, infileline, rawtext, name, realraw)

constructor

Arguments:

  • origin str - Full path to file of origin
  • line int - Overall line counter
  • infileline int - Line counter in the particular file
  • rawtext str - Raw input string (except inline code blocks)
  • realraw str - Unprocessed input
  • name str - Function name

FuncName

@property
def FuncName()

Function name

Returns:

  • str - name of function

get_items

def get_items()

Get lines of function body

Returns:

  • list - lines of function body

TaskAssignment Objects

class TaskAssignment(Item)

__init__

def __init__(origin, line, infileline, rawtext, name, ident, value, realraw)

constructor

Arguments:

  • origin str - Full path to file of origin
  • line int - Overall line counter
  • infileline int - Line counter in the particular file
  • rawtext str - Raw input string (except inline code blocks)
  • realraw str - Unprocessed input
  • name str - name of task to be modified
  • ident str - task flag
  • value str - value of modification

FuncName

@property
def FuncName()

Function name

Returns:

  • str - name of function

VarValue

@property
def VarValue()

Task flag value

Returns:

  • str - Task flag value

VarName

@property
def VarName()

Task flag name

Returns:

  • str - name of task flag

get_items

def get_items()

Get items

Returns:

  • list - function name, flag, modification value

FunctionExports Objects

class FunctionExports(Item)

__init__

def __init__(origin, line, infileline, rawtext, name, realraw)

constructor

Arguments:

  • origin str - Full path to file of origin
  • line int - Overall line counter
  • infileline int - Line counter in the particular file
  • rawtext str - Raw input string (except inline code blocks)
  • realraw str - Unprocessed input
  • name str - name of function to be exported

FuncNames

@property
def FuncNames()

Function name

Returns:

  • str - names of exported functions

get_items

def get_items()

Get items

Returns:

  • list - function names

get_items_unaliased

def get_items_unaliased()

Get items with their bbclass scope names

Returns:

  • list - function names in the scope of a bbclass (foo becomes classname-foo in this case)

TaskAdd Objects

class TaskAdd(Item)

__init__

def __init__(origin,
             line,
             infileline,
             rawtext,
             name,
             realraw,
             before="",
             after="")

constructor

Arguments:

  • origin str - Full path to file of origin
  • line int - Overall line counter
  • infileline int - Line counter in the particular file
  • rawtext str - Raw input string (except inline code blocks)
  • realraw str - Unprocessed input
  • name str - name of task to be executed

Arguments:

  • before str - before statement (default: {""})
  • after str - after statement (default: {""})

FuncName

@property
def FuncName()

Function name

Returns:

  • str - name of function

Before

@property
def Before()

Tasks executed before

Returns:

  • list - tasks to be executed before

After

@property
def After()

Tasks executed after

Returns:

  • list - tasks to be executed after

get_items

def get_items()

get items

Returns:

  • list - function name, all before statements, all after statements

MissingFile Objects

class MissingFile(Item)

__init__

def __init__(origin, line, infileline, filename, statement)

constructor

Arguments:

  • origin str - Full path to file of origin
  • line int - Overall line counter
  • infileline int - Line counter in the particular file
  • filename str - filename of the file that can't be found
  • statement str - either include or require

Filename

@property
def Filename()

Filename of the file missing

Returns:

  • str - filename that can't be resolved

Statement

@property
def Statement()

statement either include or require

Returns:

  • str - include or require

oelint_parser.parser

get_full_scope

def get_full_scope(_string, offset, _sstart, _send)

get full block of an inline statement

Arguments:

  • _string str - input string
  • offset int - offset in string
  • _sstart int - block start index
  • _send int - block end index

Returns:

  • str - full block on inline statement

prepare_lines_subparser

def prepare_lines_subparser(_iter, lineOffset, num, line, raw_line=None)

preprocess raw input

Arguments:

  • _iter interator - line interator object
  • lineOffset int - current line index
  • num int - internal line counter
  • line int - input string
  • raw_line string, optional - internal line representation. Defaults to None.

Returns:

  • list - list of preproccessed chunks

prepare_lines

def prepare_lines(_file, lineOffset=0)

break raw file input into preprocessed chunks

Arguments:

  • _file string - Full path to file
  • lineOffset int, optional - line offset counter. Defaults to 0.

Returns:

  • list - preprocessed list of chunks

get_items

def get_items(stash, _file, lineOffset=0)

parses file

Arguments:

  • stash oelint_parser.cls_stash.Stash - Stash object
  • _file string - Full path to file
  • lineOffset int, optional - line offset counter. Defaults to 0.

Returns:

  • list - List of oelint_parser.cls_item.* representations