diff --git a/docs/api-documentation.md b/docs/api-documentation.md index 6ffa3b7..c2b05c3 100644 --- a/docs/api-documentation.md +++ b/docs/api-documentation.md @@ -31,11 +31,46 @@ * [GetValidNamedResources](#oelint_parser.cls_stash.Stash.GetValidNamedResources) * [IsImage](#oelint_parser.cls_stash.Stash.IsImage) * [IsPackageGroup](#oelint_parser.cls_stash.Stash.IsPackageGroup) -* [oelint\_parser.parser](#oelint_parser.parser) - * [get\_full\_scope](#oelint_parser.parser.get_full_scope) - * [prepare\_lines\_subparser](#oelint_parser.parser.prepare_lines_subparser) - * [prepare\_lines](#oelint_parser.parser.prepare_lines) - * [get\_items](#oelint_parser.parser.get_items) +* [oelint\_parser.rpl\_regex](#oelint_parser.rpl_regex) + * [RegexRpl](#oelint_parser.rpl_regex.RegexRpl) + * [search](#oelint_parser.rpl_regex.RegexRpl.search) + * [split](#oelint_parser.rpl_regex.RegexRpl.split) + * [match](#oelint_parser.rpl_regex.RegexRpl.match) + * [sub](#oelint_parser.rpl_regex.RegexRpl.sub) + * [finditer](#oelint_parser.rpl_regex.RegexRpl.finditer) +* [oelint\_parser.inlinerep](#oelint_parser.inlinerep) + * [bb\_utils\_filter](#oelint_parser.inlinerep.bb_utils_filter) + * [bb\_utils\_contains](#oelint_parser.inlinerep.bb_utils_contains) + * [bb\_utils\_contains\_any](#oelint_parser.inlinerep.bb_utils_contains_any) + * [oe\_utils\_conditional](#oelint_parser.inlinerep.oe_utils_conditional) + * [oe\_utils\_ifelse](#oelint_parser.inlinerep.oe_utils_ifelse) + * [oe\_utils\_any\_distro\_features](#oelint_parser.inlinerep.oe_utils_any_distro_features) + * [oe\_utils\_all\_distro\_features](#oelint_parser.inlinerep.oe_utils_all_distro_features) + * [oe\_utils\_vartrue](#oelint_parser.inlinerep.oe_utils_vartrue) + * [oe\_utils\_less\_or\_equal](#oelint_parser.inlinerep.oe_utils_less_or_equal) + * [oe\_utils\_version\_less\_or\_equal](#oelint_parser.inlinerep.oe_utils_version_less_or_equal) + * [oe\_utils\_both\_contain](#oelint_parser.inlinerep.oe_utils_both_contain) + * [inlinerep](#oelint_parser.inlinerep.inlinerep) +* [oelint\_parser.constants](#oelint_parser.constants) + * [Constants](#oelint_parser.constants.Constants) + * [GetByPath](#oelint_parser.constants.Constants.GetByPath) + * [AddConstants](#oelint_parser.constants.Constants.AddConstants) + * [RemoveConstants](#oelint_parser.constants.Constants.RemoveConstants) + * [OverrideConstants](#oelint_parser.constants.Constants.OverrideConstants) + * [FunctionsKnown](#oelint_parser.constants.Constants.FunctionsKnown) + * [FunctionsOrder](#oelint_parser.constants.Constants.FunctionsOrder) + * [VariablesMandatory](#oelint_parser.constants.Constants.VariablesMandatory) + * [VariablesSuggested](#oelint_parser.constants.Constants.VariablesSuggested) + * [MirrorsKnown](#oelint_parser.constants.Constants.MirrorsKnown) + * [VariablesProtected](#oelint_parser.constants.Constants.VariablesProtected) + * [VariablesProtectedAppend](#oelint_parser.constants.Constants.VariablesProtectedAppend) + * [VariablesOrder](#oelint_parser.constants.Constants.VariablesOrder) + * [VariablesKnown](#oelint_parser.constants.Constants.VariablesKnown) + * [DistrosKnown](#oelint_parser.constants.Constants.DistrosKnown) + * [MachinesKnown](#oelint_parser.constants.Constants.MachinesKnown) + * [ImagesClasses](#oelint_parser.constants.Constants.ImagesClasses) + * [ImagesVariables](#oelint_parser.constants.Constants.ImagesVariables) + * [SetsBase](#oelint_parser.constants.Constants.SetsBase) * [oelint\_parser.cls\_item](#oelint_parser.cls_item) * [\_\_id\_regex\_\_](#oelint_parser.cls_item.__id_regex__) * [Item](#oelint_parser.cls_item.Item) @@ -150,46 +185,11 @@ * [VarName](#oelint_parser.cls_item.Unset.VarName) * [Flag](#oelint_parser.cls_item.Unset.Flag) * [get\_items](#oelint_parser.cls_item.Unset.get_items) -* [oelint\_parser.rpl\_regex](#oelint_parser.rpl_regex) - * [RegexRpl](#oelint_parser.rpl_regex.RegexRpl) - * [search](#oelint_parser.rpl_regex.RegexRpl.search) - * [split](#oelint_parser.rpl_regex.RegexRpl.split) - * [match](#oelint_parser.rpl_regex.RegexRpl.match) - * [sub](#oelint_parser.rpl_regex.RegexRpl.sub) - * [finditer](#oelint_parser.rpl_regex.RegexRpl.finditer) -* [oelint\_parser.constants](#oelint_parser.constants) - * [Constants](#oelint_parser.constants.Constants) - * [GetByPath](#oelint_parser.constants.Constants.GetByPath) - * [AddConstants](#oelint_parser.constants.Constants.AddConstants) - * [RemoveConstants](#oelint_parser.constants.Constants.RemoveConstants) - * [OverrideConstants](#oelint_parser.constants.Constants.OverrideConstants) - * [FunctionsKnown](#oelint_parser.constants.Constants.FunctionsKnown) - * [FunctionsOrder](#oelint_parser.constants.Constants.FunctionsOrder) - * [VariablesMandatory](#oelint_parser.constants.Constants.VariablesMandatory) - * [VariablesSuggested](#oelint_parser.constants.Constants.VariablesSuggested) - * [MirrorsKnown](#oelint_parser.constants.Constants.MirrorsKnown) - * [VariablesProtected](#oelint_parser.constants.Constants.VariablesProtected) - * [VariablesProtectedAppend](#oelint_parser.constants.Constants.VariablesProtectedAppend) - * [VariablesOrder](#oelint_parser.constants.Constants.VariablesOrder) - * [VariablesKnown](#oelint_parser.constants.Constants.VariablesKnown) - * [DistrosKnown](#oelint_parser.constants.Constants.DistrosKnown) - * [MachinesKnown](#oelint_parser.constants.Constants.MachinesKnown) - * [ImagesClasses](#oelint_parser.constants.Constants.ImagesClasses) - * [ImagesVariables](#oelint_parser.constants.Constants.ImagesVariables) - * [SetsBase](#oelint_parser.constants.Constants.SetsBase) -* [oelint\_parser.inlinerep](#oelint_parser.inlinerep) - * [bb\_utils\_filter](#oelint_parser.inlinerep.bb_utils_filter) - * [bb\_utils\_contains](#oelint_parser.inlinerep.bb_utils_contains) - * [bb\_utils\_contains\_any](#oelint_parser.inlinerep.bb_utils_contains_any) - * [oe\_utils\_conditional](#oelint_parser.inlinerep.oe_utils_conditional) - * [oe\_utils\_ifelse](#oelint_parser.inlinerep.oe_utils_ifelse) - * [oe\_utils\_any\_distro\_features](#oelint_parser.inlinerep.oe_utils_any_distro_features) - * [oe\_utils\_all\_distro\_features](#oelint_parser.inlinerep.oe_utils_all_distro_features) - * [oe\_utils\_vartrue](#oelint_parser.inlinerep.oe_utils_vartrue) - * [oe\_utils\_less\_or\_equal](#oelint_parser.inlinerep.oe_utils_less_or_equal) - * [oe\_utils\_version\_less\_or\_equal](#oelint_parser.inlinerep.oe_utils_version_less_or_equal) - * [oe\_utils\_both\_contain](#oelint_parser.inlinerep.oe_utils_both_contain) - * [inlinerep](#oelint_parser.inlinerep.inlinerep) +* [oelint\_parser.parser](#oelint_parser.parser) + * [get\_full\_scope](#oelint_parser.parser.get_full_scope) + * [prepare\_lines\_subparser](#oelint_parser.parser.prepare_lines_subparser) + * [prepare\_lines](#oelint_parser.parser.prepare_lines) + * [get\_items](#oelint_parser.parser.get_items) @@ -851,686 +851,710 @@ returns if the file is likely a packagegroup recipe or not - `bool` - True if _file is a packagegroup recipe - + -# oelint\_parser.parser +# oelint\_parser.rpl\_regex - + -#### get\_full\_scope +## RegexRpl Objects ```python -def get_full_scope(_string: str, offset: int, _sstart: int, _send: int) -> str +class RegexRpl() ``` -get full block of an inline statement +Safe regex replacements + + + +#### search + +```python +@staticmethod +def search(pattern: str, + string: str, + timeout: int = 5, + default: object = None, + **kwargs) -> Union[Match, None] +``` + +replacement for re.search **Arguments**: -- `_string` _str_ - input string -- `offset` _int_ - offset in string -- `_sstart` _int_ - block start index -- `_send` _int_ - block end index +- `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**: -- `str` - full block on inline statement +- `Match` - Match object or None - + -#### prepare\_lines\_subparser +#### split ```python -def prepare_lines_subparser(_iter: Iterable, - lineOffset: int, - num: int, - line: int, - raw_line: str = None, - negative: bool = False) -> List[str] +@staticmethod +def split(pattern: str, + string: str, + timeout: int = 5, + default: object = None, + **kwargs) -> List[str] ``` -preprocess raw input +replacement for re.split **Arguments**: -- `_iter` _iterator_ - 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. -- `negative` _bool_ - Negative branch inline expansion. Defaults to False +- `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 of preproccessed chunks +- `list` - list object or None - + -#### prepare\_lines +#### match ```python -def prepare_lines(_file: str, - lineOffset: int = 0, - negative: bool = False) -> List[str] +@staticmethod +def match(pattern: str, + string: str, + timeout: int = 5, + default: object = None, + **kwargs) -> Union[Match, None] ``` -break raw file input into preprocessed chunks +replacement for re.match **Arguments**: -- `_file` _string_ - Full path to file -- `lineOffset` _int, optional_ - line offset counter. Defaults to 0. -- `negative` _bool_ - Negative branch inline expansion. Defaults to False +- `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` - preprocessed list of chunks +- `Match` - Match object or None - + -#### get\_items +#### sub ```python -def get_items(stash: object, - _file: str, - lineOffset: int = 0, - new_style_override_syntax: bool = False, - negative: bool = False) -> List[Item] +@staticmethod +def sub(pattern: str, + repl: str, + string: str, + timeout: int = 5, + default: str = '', + **kwargs) -> str ``` -parses file +replacement for re.sub **Arguments**: -- `stash` _oelint_parser.cls_stash.Stash_ - Stash object -- `_file` _string_ - Full path to file -- `lineOffset` _int, optional_ - line offset counter. Defaults to 0. -- `new_style_override_syntax` _bool, optional_ - default to new override syntax (default: False) -- `negative` _bool, optional_ - Negative branch inline expansion (default: False) +- `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**: -- `list` - List of oelint_parser.cls_item.* representations +- `str` - string - + -# oelint\_parser.cls\_item +#### finditer - +```python +@staticmethod +def finditer(pattern: str, + string: str, + timeout: int = 5, + default: object = None, + **kwargs) -> Scanner +``` -#### \_\_id\_regex\_\_ +replacement for re.finditer -noqa: P103 +**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. + -## Item Objects +**Returns**: -```python -class Item() -``` +- `Scanner` - Scanner object or None -Base class for all Stash items + - +# oelint\_parser.inlinerep -#### \_\_init\_\_ + + +#### bb\_utils\_filter ```python -def __init__(origin: str, - line: int, - infileline: int, - rawtext: str, - realraw: str, - new_style_override_syntax: bool = False) -> None +def bb_utils_filter(_in: str, negative_clause: bool = False) -> str ``` -constructor +bb.utils.filter emulation **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 +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + -**Arguments**: +**Returns**: -- `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) +- `str` - True argument of the conditional or None if not applicable - + -#### Line +#### bb\_utils\_contains ```python -@property -def Line() -> int +def bb_utils_contains(_in: str, negative_clause: bool = False) -> str ``` -Overall line count +bb.utils.contains emulation + +**Arguments**: + +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + **Returns**: -- `int` - overall line count of item +- `str` - True argument of the conditional or None if not applicable - + -#### Raw +#### bb\_utils\_contains\_any ```python -@property -def Raw() -> str +def bb_utils_contains_any(_in: str, negative_clause: bool = False) -> str ``` -Raw string (without inline code blocks) +bb.utils.contains_any emulation + +**Arguments**: + +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + **Returns**: -- `str` - raw string of item +- `str` - True argument of the conditional or None if not applicable - + -#### Origin +#### oe\_utils\_conditional ```python -@property -def Origin() -> str +def oe_utils_conditional(_in: str, negative_clause: bool = False) -> str ``` -origin of item +oe.utils.conditional emulation + +**Arguments**: + +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + **Returns**: -- `str` - full path of origin file +- `str` - True argument of the conditional or None if not applicable - + -#### InFileLine +#### oe\_utils\_ifelse ```python -@property -def InFileLine() -> int +def oe_utils_ifelse(_in: str, negative_clause: bool = False) -> str ``` -Line count in file +oe.utils.ifelse emulation + +**Arguments**: + +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + **Returns**: -- `int` - [description] +- `str` - True argument of the conditional or None if not applicable - + -#### RealRaw +#### oe\_utils\_any\_distro\_features ```python -@property -def RealRaw() -> str +def oe_utils_any_distro_features(_in: str, + negative_clause: bool = False) -> str ``` -Completely unprocessed raw text +oe.utils.any_distro_features emulation + +**Arguments**: + +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + **Returns**: -- `str` - completely unprocessed raw text +- `str` - True argument of the conditional or None if not applicable - + -#### IsFromClass +#### oe\_utils\_all\_distro\_features ```python -@property -def IsFromClass() -> bool +def oe_utils_all_distro_features(_in: str, + negative_clause: bool = False) -> str ``` -Item comes from a bbclass +oe.utils.all_distro_features emulation + +**Arguments**: + +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + **Returns**: -- `bool` - if item was set in a bbclass +- `str` - True argument of the conditional or None if not applicable - + -#### OverrideDelimiter +#### oe\_utils\_vartrue ```python -@property -def OverrideDelimiter() -> str +def oe_utils_vartrue(_in: str, negative_clause: bool = False) -> str ``` -Override delimiter +oe.utils.vartrue emulation + +**Arguments**: + +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + **Returns**: -- `str` - Override delimiter +- `str` - True argument of the conditional or None if not applicable - + -#### IsNewStyleOverrideSyntax +#### oe\_utils\_less\_or\_equal ```python -@property -def IsNewStyleOverrideSyntax() -> bool +def oe_utils_less_or_equal(_in: str, negative_clause: bool = False) -> str ``` -New style override syntax detected +oe.utils.less_or_equal emulation + +**Arguments**: + +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + **Returns**: -- `bool` - True if new style has been detected +- `str` - True argument of the conditional or None if not applicable - + -#### safe\_linesplit +#### oe\_utils\_version\_less\_or\_equal ```python -@staticmethod -def safe_linesplit(string: str) -> List[str] +def oe_utils_version_less_or_equal(_in: str, + negative_clause: bool = False) -> str ``` -Safely split an input line to chunks +oe.utils.version_less_or_equal emulation **Arguments**: -- `string` _str_ - raw input string +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch **Returns**: -- `list` - list of chunks of original string +- `str` - True argument of the conditional or None if not applicable - + -#### get\_items +#### oe\_utils\_both\_contain ```python -def get_items() -> List[str] +def oe_utils_both_contain(_in: str, negative_clause: bool = False) -> str ``` -Return single items +oe.utils.both_contain emulation + +**Arguments**: + +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + **Returns**: -- `list` - lines of raw input +- `str` - True argument of the conditional or None if not applicable - + -#### extract\_sub +#### inlinerep ```python -def extract_sub(name: str) -> Tuple[List[str], List[str]] +def inlinerep(_in: str, negative_clause: bool = False) -> str ``` -Extract modifiers +Replaces inline code expressions **Arguments**: -- `name` _str_ - input string +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch **Returns**: -- `tuple` - clean variable name, modifiers, package specific modifiers +- `str` - Expanded string or None, if not applicable - + -#### extract\_sub\_func +# oelint\_parser.constants + + + +## Constants Objects ```python -def extract_sub_func(name: str) -> Tuple[List[str], List[str]] +class Constants() ``` -Extract modifiers for functions +Interface for constants + + + +#### GetByPath + +```python +def GetByPath(path: str) -> Union[Dict, List] +``` + +Get constant from path **Arguments**: -- `name` _str_ - input value +- `path` _str_ - / joined path in the constant structure **Returns**: -- `tuple` - clean function name, modifiers + Union[Dict, List]: Item in structure or empty dictionary - + -#### IsFromAppend +#### AddConstants ```python -def IsFromAppend() -> bool +def AddConstants(_dict: dict) -> None ``` -Item originates from a bbappend +Add constants to the existing -**Returns**: +**Arguments**: -- `bool` - True if coming from a bbappend +- `dict` _dict_ - constant dictionary to add - + -#### GetAttributes +#### RemoveConstants ```python -def GetAttributes() -> dict +def RemoveConstants(_dict: dict) -> None ``` -Get all public attributes of this class +Remove constants from the existing -**Returns**: +**Arguments**: -- `dict` - all public attributes and their values +- `dict` _dict_ - constant dictionary to remove - + -## Variable Objects +#### OverrideConstants ```python -class Variable(Item) +def OverrideConstants(_dict: dict) -> None ``` -Items representing variables in bitbake. +Override constants in the existing db - +**Arguments**: -#### \_\_init\_\_ - -```python -def __init__(origin: str, - line: int, - infileline: int, - rawtext: str, - name: str, - value: str, - operator: str, - realraw: str, - new_style_override_syntax: bool = False) -> None -``` - -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 - - -**Arguments**: - -- `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) +- `dict` _dict]_ - constant dictionary with override values - + -#### VarName +#### FunctionsKnown ```python @property -def VarName() -> str +def FunctionsKnown() -> List[str] ``` -Variable name +Return known functions **Returns**: -- `str` - name of variable +- `list` - list of known functions - + -#### SubItem +#### FunctionsOrder ```python @property -def SubItem() -> str +def FunctionsOrder() -> List[str] ``` -Variable modifiers +Return function order **Returns**: -- `str` - variable modifiers like packages, machines, appends, prepends +- `list` - List of functions to order in their designated order - + -#### SubItems +#### VariablesMandatory ```python @property -def SubItems() -> List[str] +def VariablesMandatory() -> List[str] ``` -Variable modifiers list +Return mandatory variables **Returns**: -- `list` - variable modifiers list like packages, machines, appends, prepends +- `list` - List of mandatory variables - + -#### VarValue +#### VariablesSuggested ```python @property -def VarValue() -> str +def VariablesSuggested() -> List[str] ``` -variable value +Return suggested variables **Returns**: -- `str` - unstripped variable value +- `list` - List of suggested variables - + -#### VarOp +#### MirrorsKnown ```python @property -def VarOp() -> str +def MirrorsKnown() -> Dict[str, str] ``` -Variable operation +Return known mirrors and their replacements **Returns**: -- `str` - operation did on the variable +- `dict` - Dict of known mirrors and their replacements - + -#### VarNameComplete +#### VariablesProtected ```python @property -def VarNameComplete() -> str +def VariablesProtected() -> List[str] ``` -Complete variable name included overrides and flags +Return protected variables **Returns**: -- `str` - complete variable name +- `list` - List of protected variables - + -#### VarNameCompleteNoModifiers +#### VariablesProtectedAppend ```python @property -def VarNameCompleteNoModifiers() -> str +def VariablesProtectedAppend() -> List[str] ``` -Complete variable name included overrides but without modifiers like append, prepend and remove +Return protected variables in bbappend files **Returns**: -- `str` - complete variable name +- `list` - List of protected variables in bbappend files - + -#### RawVarName +#### VariablesOrder ```python @property -def RawVarName() -> str +def VariablesOrder() -> List[str] ``` -Variable name and flags combined +Variable order **Returns**: -- `str` - raw representation of the variable name +- `list` - List of variables to order in their designated order - + -#### VarValueStripped +#### VariablesKnown ```python @property -def VarValueStripped() -> str -``` - -Stripped variable value - -**Returns**: - -- `str` - stripped version of variable value - - - -#### IsAppend - -```python -def IsAppend() -> bool -``` - -Check if operation is an append - -**Returns**: - -- `bool` - True is variable is appended - - - -#### AppendOperation - -```python -def AppendOperation() -> List[str] +def VariablesKnown() -> List[str] ``` -Get variable modifiers +Known variables **Returns**: -- `list` - list could contain any combination of 'append', ' += ', 'prepend' and 'remove' +- `list` - List of known variables - + -#### get\_items +#### DistrosKnown ```python -def get_items(override: str = "", versioned: bool = False) -> List[str] +@property +def DistrosKnown() -> List[str] ``` -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) - +Known distros **Returns**: -- `list` - clean list of items in variable value +- `list` - List of known distros - + -#### IsMultiLine +#### MachinesKnown ```python -def IsMultiLine() -> bool +@property +def MachinesKnown() -> List[str] ``` -Check if variable has a multiline assignment +Known machines **Returns**: -- `bool` - True if multiline +- `list` - List of known machines - + -#### GetDistroEntry +#### ImagesClasses ```python -def GetDistroEntry() -> str +@property +def ImagesClasses() -> List[str] ``` -Get distro specific entries in variable +Classes that are used in images **Returns**: -- `str` - distro specific modifier of variable or "" +- `list` - Classes that are used in images - + -#### GetMachineEntry +#### ImagesVariables ```python -def GetMachineEntry() -> str +@property +def ImagesVariables() -> List[str] ``` -Get machine specific entries in variable +Variables that are used in images **Returns**: -- `str` - machine specific modifier of variable or "" +- `list` - Variables that are used in images - + -#### GetClassOverride +#### SetsBase ```python -def GetClassOverride() -> str +@property +def SetsBase() -> Dict[str, str] ``` -Get class specific entries in variable +Base variable set **Returns**: -- `str` - class specific modifier of variable or "" - - +- `dict` - dictionary with base variable set -#### IsImmediateModify + -```python -def IsImmediateModify() -> bool -``` +# oelint\_parser.cls\_item -Variable operation is done immediately + -**Returns**: +#### \_\_id\_regex\_\_ -- `bool` - true if it isn't a prepend/append or remove operation +noqa: P103 - + -## Comment Objects +## Item Objects ```python -class Comment(Item) +class Item() ``` -Items representing comments in bitbake. +Base class for all Stash items - + #### \_\_init\_\_ @@ -1547,214 +1571,247 @@ constructor **Arguments**: -- `origin` _str_ - Full path to file of origin +- `origin` _str_ - Full path of origin file - `line` _int_ - Overall line counter -- `infileline` _int_ - Line counter in the particular file +- `infileline` _int_ - Line number in file - `rawtext` _str_ - Raw input string (except inline code blocks) - `realraw` _str_ - Unprocessed input - **Arguments**: - `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) - + -#### get\_items +#### Line ```python -def get_items() -> List[str] +@property +def Line() -> int ``` -Get single lines of block +Overall line count **Returns**: -- `list` - single lines of comment block +- `int` - overall line count of item - + -## Include Objects +#### Raw ```python -class Include(Item) -``` +@property +def Raw() -> str +``` -Items that representing include/require statements. +Raw string (without inline code blocks) - +**Returns**: -#### \_\_init\_\_ +- `str` - raw string of item + + + +#### Origin ```python -def __init__(origin: str, - line: int, - infileline: int, - rawtext: str, - incname: str, - statement: str, - realraw: str, - new_style_override_syntax: bool = False) -> None +@property +def Origin() -> str ``` -constructor +origin of item -**Arguments**: +**Returns**: -- `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 - +- `str` - full path of origin file -**Arguments**: + -- `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) +#### InFileLine - +```python +@property +def InFileLine() -> int +``` -#### IncName +Line count in file + +**Returns**: + +- `int` - [description] + + + +#### RealRaw ```python @property -def IncName() -> str +def RealRaw() -> str ``` -Include name +Completely unprocessed raw text **Returns**: -- `str` - name of the file to include/require +- `str` - completely unprocessed raw text - + -#### Statement +#### IsFromClass ```python @property -def Statement() -> str +def IsFromClass() -> bool ``` -statement either include or require +Item comes from a bbclass **Returns**: -- `str` - include or require +- `bool` - if item was set in a bbclass - + -#### get\_items +#### OverrideDelimiter ```python -def get_items() -> Tuple[str, str] +@property +def OverrideDelimiter() -> str ``` -Get items +Override delimiter **Returns**: -- `list` - include name, include statement +- `str` - Override delimiter - + -## Export Objects +#### IsNewStyleOverrideSyntax ```python -class Export(Item) +@property +def IsNewStyleOverrideSyntax() -> bool ``` -Items representing export statements in bitbake. +New style override syntax detected - +**Returns**: -#### \_\_init\_\_ +- `bool` - True if new style has been detected + + + +#### safe\_linesplit ```python -def __init__(origin: str, - line: int, - infileline: int, - rawtext: str, - name: str, - value: str, - realraw: str, - new_style_override_syntax: bool = False) -> None +@staticmethod +def safe_linesplit(string: str) -> List[str] ``` -constructor +Safely split an input line to chunks **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 +- `string` _str_ - raw input string +**Returns**: + +- `list` - list of chunks of original string + + + +#### get\_items + +```python +def get_items() -> List[str] +``` + +Return single items + +**Returns**: + +- `list` - lines of raw input + + + +#### extract\_sub + +```python +def extract_sub(name: str) -> Tuple[List[str], List[str]] +``` + +Extract modifiers + **Arguments**: -- `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) +- `name` _str_ - input string + - +**Returns**: -#### Name +- `tuple` - clean variable name, modifiers, package specific modifiers + + + +#### extract\_sub\_func ```python -@property -def Name() -> str +def extract_sub_func(name: str) -> Tuple[List[str], List[str]] ``` -Name of the exported var +Extract modifiers for functions + +**Arguments**: + +- `name` _str_ - input value + **Returns**: -- `str` - name of the exported var +- `tuple` - clean function name, modifiers - + -#### Value +#### IsFromAppend ```python -@property -def Value() -> str +def IsFromAppend() -> bool ``` -value of the export +Item originates from a bbappend **Returns**: -- `str` - optional value of the export +- `bool` - True if coming from a bbappend - + -#### get\_items +#### GetAttributes ```python -def get_items() -> Tuple[str, str] +def GetAttributes() -> dict ``` -Get items +Get all public attributes of this class **Returns**: -- `list` - include name, include statement +- `dict` - all public attributes and their values - + -## Function Objects +## Variable Objects ```python -class Function(Item) +class Variable(Item) ``` -Items representing task definitions in bitbake. +Items representing variables in bitbake. - + #### \_\_init\_\_ @@ -1764,14 +1821,13 @@ def __init__(origin: str, infileline: int, rawtext: str, name: str, - body: str, + value: str, + operator: str, realraw: str, - python: bool = False, - fakeroot: bool = False, new_style_override_syntax: bool = False) -> None ``` -[summary] +constructor **Arguments**: @@ -1780,152 +1836,213 @@ def __init__(origin: str, - `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 +- `name` _str_ - Variable name +- `value` _str_ - Variable value +- `operator` _str_ - Operation performed to the variable **Arguments**: -- `python` _bool_ - python function according to parser (default: {False}) -- `fakeroot` _bool_ - uses fakeroot (default: {False}) - `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) - + -#### IsPython +#### VarName ```python @property -def IsPython() -> bool +def VarName() -> str ``` -Is python function +Variable name **Returns**: -- `bool` - is a python function +- `str` - name of variable - + -#### IsFakeroot +#### SubItem ```python @property -def IsFakeroot() -> bool +def SubItem() -> str ``` -Is fakeroot function +Variable modifiers **Returns**: -- `bool` - is a python function +- `str` - variable modifiers like packages, machines, appends, prepends - + -#### FuncName +#### SubItems ```python @property -def FuncName() -> str +def SubItems() -> List[str] ``` -Function name +Variable modifiers list **Returns**: -- `str` - name of function +- `list` - variable modifiers list like packages, machines, appends, prepends - + -#### FuncNameComplete +#### VarValue ```python @property -def FuncNameComplete() -> str +def VarValue() -> str ``` -Complete function name (including overrides) +variable value **Returns**: -- `str` - complete name of function +- `str` - unstripped variable value - + -#### SubItem +#### VarOp ```python @property -def SubItem() -> str +def VarOp() -> str ``` -Function modifiers +Variable operation **Returns**: -- `str` - function modifiers like packages, machines, appends, prepends +- `str` - operation did on the variable - + -#### SubItems +#### VarNameComplete ```python @property -def SubItems() -> List[str] +def VarNameComplete() -> str ``` -Function modifiers list +Complete variable name included overrides and flags **Returns**: -- `list` - function modifiers list like packages, machines, appends, prepends +- `str` - complete variable name - + -#### FuncBody +#### VarNameCompleteNoModifiers ```python @property -def FuncBody() -> str +def VarNameCompleteNoModifiers() -> str ``` -Function body +Complete variable name included overrides but without modifiers like append, prepend and remove **Returns**: -- `str` - function body text +- `str` - complete variable name - + -#### FuncBodyStripped +#### RawVarName ```python @property -def FuncBodyStripped() -> str +def RawVarName() -> str ``` -Stripped function body +Variable name and flags combined **Returns**: -- `str` - stripped function body text +- `str` - raw representation of the variable name - + -#### FuncBodyRaw +#### VarValueStripped ```python @property -def FuncBodyRaw() -> str +def VarValueStripped() -> str ``` -Raw function body (including brackets) +Stripped variable value **Returns**: -- `str` - raw function body text +- `str` - stripped version of variable value - + + +#### IsAppend + +```python +def IsAppend() -> bool +``` + +Check if operation is an append + +**Returns**: + +- `bool` - True is variable is appended + + + +#### AppendOperation + +```python +def AppendOperation() -> List[str] +``` + +Get variable modifiers + +**Returns**: + +- `list` - list could contain any combination of 'append', ' += ', 'prepend' and 'remove' + + + +#### get\_items + +```python +def get_items(override: str = "", versioned: bool = False) -> List[str] +``` + +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 + +```python +def IsMultiLine() -> bool +``` + +Check if variable has a multiline assignment + +**Returns**: + +- `bool` - True if multiline + + #### GetDistroEntry @@ -1933,13 +2050,13 @@ Raw function body (including brackets) def GetDistroEntry() -> str ``` -Get distro specific modifiers +Get distro specific entries in variable **Returns**: -- `str` - distro specific modifier or "" +- `str` - distro specific modifier of variable or "" - + #### GetMachineEntry @@ -1947,51 +2064,51 @@ Get distro specific modifiers def GetMachineEntry() -> str ``` -Get machine specific modifiers +Get machine specific entries in variable **Returns**: -- `str` - machine specific modifier or "" +- `str` - machine specific modifier of variable or "" - + -#### IsAppend +#### GetClassOverride ```python -def IsAppend() -> bool +def GetClassOverride() -> str ``` -Return if function appends another function +Get class specific entries in variable **Returns**: -- `bool` - True is append or prepend operation +- `str` - class specific modifier of variable or "" - + -#### get\_items +#### IsImmediateModify ```python -def get_items() -> List[str] +def IsImmediateModify() -> bool ``` -Get items of function body +Variable operation is done immediately **Returns**: -- `list` - single lines of function body +- `bool` - true if it isn't a prepend/append or remove operation - + -## PythonBlock Objects +## Comment Objects ```python -class PythonBlock(Item) +class Comment(Item) ``` -Items representing python functions in bitbake. +Items representing comments in bitbake. - + #### \_\_init\_\_ @@ -2000,7 +2117,6 @@ def __init__(origin: str, line: int, infileline: int, rawtext: str, - name: str, realraw: str, new_style_override_syntax: bool = False) -> None ``` @@ -2014,29 +2130,13 @@ constructor - `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 **Arguments**: - `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) - - -#### FuncName - -```python -@property -def FuncName() -> str -``` - -Function name - -**Returns**: - -- `str` - name of function - - + #### get\_items @@ -2044,23 +2144,23 @@ Function name def get_items() -> List[str] ``` -Get lines of function body +Get single lines of block **Returns**: -- `list` - lines of function body +- `list` - single lines of comment block - + -## FlagAssignment Objects +## Include Objects ```python -class FlagAssignment(Item) +class Include(Item) ``` -Items representing flag assignments in bitbake. +Items that representing include/require statements. - + #### \_\_init\_\_ @@ -2069,10 +2169,8 @@ def __init__(origin: str, line: int, infileline: int, rawtext: str, - name: str, - ident: str, - value: str, - varop: str, + incname: str, + statement: str, realraw: str, new_style_override_syntax: bool = False) -> None ``` @@ -2086,116 +2184,155 @@ constructor - `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 -- `varop` _str_ - variable operation +- `incname` _str_ - raw name of the include file +- `statement` _str_ - either include or require **Arguments**: - `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) - + -#### VarName +#### IncName ```python @property -def VarName() -> str +def IncName() -> str ``` -Variable name +Include name **Returns**: -- `str` - name of variable +- `str` - name of the file to include/require - + -#### Flag +#### Statement ```python @property -def Flag() -> str +def Statement() -> str ``` -Flag name +statement either include or require **Returns**: -- `str` - Flag name +- `str` - include or require - + -#### VarOp +#### get\_items ```python -@property -def VarOp() -> str +def get_items() -> Tuple[str, str] ``` -Modifier operation +Get items **Returns**: -- `str` - used modifier in operation +- `list` - include name, include statement - + -#### Value +## Export Objects ```python -@property -def Value() -> str +class Export(Item) ``` -Value - -**Returns**: - -- `str` - value set +Items representing export statements in bitbake. - + -#### ValueStripped +#### \_\_init\_\_ ```python -@property -def ValueStripped() -> str +def __init__(origin: str, + line: int, + infileline: int, + rawtext: str, + name: str, + value: str, + realraw: str, + new_style_override_syntax: bool = False) -> None ``` -Value stripped of the quotes +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 + + +**Arguments**: + +- `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) + + + +#### Name + +```python +@property +def Name() -> str +``` + +Name of the exported var **Returns**: -- `str` - value set +- `str` - name of the exported var - + + +#### Value + +```python +@property +def Value() -> str +``` + +value of the export + +**Returns**: + +- `str` - optional value of the export + + #### get\_items ```python -def get_items() -> Tuple[str, str, str, str] +def get_items() -> Tuple[str, str] ``` Get items **Returns**: -- `list` - variable name, flag, variable operation, modification value +- `list` - include name, include statement - + -## FunctionExports Objects +## Function Objects ```python -class FunctionExports(Item) +class Function(Item) ``` -Items representing EXPORT_FUNCTIONS in bitbake. +Items representing task definitions in bitbake. - + #### \_\_init\_\_ @@ -2205,11 +2342,14 @@ def __init__(origin: str, infileline: int, rawtext: str, name: str, + body: str, realraw: str, + python: bool = False, + fakeroot: bool = False, new_style_override_syntax: bool = False) -> None ``` -constructor +[summary] **Arguments**: @@ -2218,163 +2358,194 @@ constructor - `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 +- `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}) - `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) - + -#### FuncNames +#### IsPython ```python @property -def FuncNames() -> str +def IsPython() -> bool ``` -Function name +Is python function **Returns**: -- `str` - names of exported functions +- `bool` - is a python function - + -#### get\_items +#### IsFakeroot ```python -def get_items() -> List[str] +@property +def IsFakeroot() -> bool ``` -Get items +Is fakeroot function **Returns**: -- `list` - function names +- `bool` - is a python function - + -#### get\_items\_unaliased +#### FuncName ```python -def get_items_unaliased() -> List[str] +@property +def FuncName() -> str ``` -Get items with their bbclass scope names +Function name **Returns**: -- `list` - function names in the scope of a bbclass (foo becomes classname-foo in this case) +- `str` - name of function - + -## TaskAdd Objects +#### FuncNameComplete ```python -class TaskAdd(Item) +@property +def FuncNameComplete() -> str ``` -Items representing addtask statements in bitbake. +Complete function name (including overrides) - +**Returns**: -#### \_\_init\_\_ +- `str` - complete name of function + + + +#### SubItem ```python -def __init__(origin: str, - line: int, - infileline: int, - rawtext: str, - name: str, - realraw: str, - before: str = "", - after: str = "", - comment: str = "", - new_style_override_syntax: bool = False) -> None +@property +def SubItem() -> str ``` -constructor +Function modifiers -**Arguments**: +**Returns**: -- `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 - +- `str` - function modifiers like packages, machines, appends, prepends -**Arguments**: + -- `before` _str_ - before statement (default: {""}) -- `after` _str_ - after statement (default: {""}) -- `comment` _str_ - optional comment (default: {""}) -- `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) +#### SubItems - +```python +@property +def SubItems() -> List[str] +``` -#### FuncName +Function modifiers list + +**Returns**: + +- `list` - function modifiers list like packages, machines, appends, prepends + + + +#### FuncBody ```python @property -def FuncName() -> str +def FuncBody() -> str ``` -Function name +Function body **Returns**: -- `str` - name of function +- `str` - function body text - + -#### Before +#### FuncBodyStripped ```python @property -def Before() -> List[str] +def FuncBodyStripped() -> str ``` -Tasks executed before +Stripped function body **Returns**: -- `list` - tasks to be executed before +- `str` - stripped function body text - + -#### After +#### FuncBodyRaw ```python @property -def After() -> List[str] +def FuncBodyRaw() -> str ``` -Tasks executed after +Raw function body (including brackets) **Returns**: -- `list` - tasks to be executed after +- `str` - raw function body text - + -#### Comment +#### GetDistroEntry ```python -@property -def Comment() -> str +def GetDistroEntry() -> str ``` -Comment +Get distro specific modifiers **Returns**: -- `str` - comment if any +- `str` - distro specific modifier or "" - + + +#### GetMachineEntry + +```python +def GetMachineEntry() -> str +``` + +Get machine specific modifiers + +**Returns**: + +- `str` - machine specific modifier or "" + + + +#### IsAppend + +```python +def IsAppend() -> bool +``` + +Return if function appends another function + +**Returns**: + +- `bool` - True is append or prepend operation + + #### get\_items @@ -2382,23 +2553,23 @@ Comment def get_items() -> List[str] ``` -get items +Get items of function body **Returns**: -- `list` - function name, all before statements, all after statements +- `list` - single lines of function body - + -## TaskDel Objects +## PythonBlock Objects ```python -class TaskDel(Item) +class PythonBlock(Item) ``` -Items representing deltask statements in bitbake. +Items representing python functions in bitbake. - + #### \_\_init\_\_ @@ -2408,7 +2579,6 @@ def __init__(origin: str, infileline: int, rawtext: str, name: str, - comment: str, realraw: str, new_style_override_syntax: bool = False) -> None ``` @@ -2422,15 +2592,14 @@ constructor - `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 -- `comment` _str_ - optional comment +- `name` _str_ - Function name **Arguments**: - `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) - + #### FuncName @@ -2445,22 +2614,7 @@ Function name - `str` - name of function - - -#### Comment - -```python -@property -def Comment() -> str -``` - -Comment - -**Returns**: - -- `str` - comment if any - - + #### get\_items @@ -2468,23 +2622,23 @@ Comment def get_items() -> List[str] ``` -get items +Get lines of function body **Returns**: -- `list` - function name +- `list` - lines of function body - + -## MissingFile Objects +## FlagAssignment Objects ```python -class MissingFile(Item) +class FlagAssignment(Item) ``` -Items representing missing files found while parsing. +Items representing flag assignments in bitbake. - + #### \_\_init\_\_ @@ -2492,8 +2646,12 @@ Items representing missing files found while parsing. def __init__(origin: str, line: int, infileline: int, - filename: str, - statement: str, + rawtext: str, + name: str, + ident: str, + value: str, + varop: str, + realraw: str, new_style_override_syntax: bool = False) -> None ``` @@ -2504,141 +2662,118 @@ constructor - `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 +- `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 +- `varop` _str_ - variable operation **Arguments**: - `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) - + -#### Filename +#### VarName ```python @property -def Filename() -> str +def VarName() -> str ``` -Filename of the file missing +Variable name **Returns**: -- `str` - filename that can't be resolved +- `str` - name of variable - + -#### Statement +#### Flag ```python @property -def Statement() -> str +def Flag() -> str ``` -statement either include or require +Flag name **Returns**: -- `str` - include or require - - - -## AddPylib Objects - -```python -class AddPylib(Item) -``` - -Items representing addpylib statements in bitbake. +- `str` - Flag name - + -#### \_\_init\_\_ +#### VarOp ```python -def __init__(origin: str, - line: int, - infileline: int, - rawtext: str, - path: str, - namespace: str, - realraw: str, - new_style_override_syntax: bool = False) -> None +@property +def VarOp() -> str ``` -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 -- `path` _str_ - path to the namespace -- `namespace` _str_ - namespace name - +Modifier operation -**Arguments**: +**Returns**: -- `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) +- `str` - used modifier in operation - + -#### Path +#### Value ```python @property -def Path() -> str +def Value() -> str ``` -Path of the library addition +Value **Returns**: -- `str` - path of the library addition +- `str` - value set - + -#### Namespace +#### ValueStripped ```python @property -def Namespace() -> str +def ValueStripped() -> str ``` -Namespace of the addition +Value stripped of the quotes **Returns**: -- `str` - Namespace of the addition +- `str` - value set - + #### get\_items ```python -def get_items() -> Tuple[str, str] +def get_items() -> Tuple[str, str, str, str] ``` Get items **Returns**: -- `list` - library path, library namespace +- `list` - variable name, flag, variable operation, modification value - + -## Inherit Objects +## FunctionExports Objects ```python -class Inherit(Item) +class FunctionExports(Item) ``` -Items that representing inherit(_defer) statements. +Items representing EXPORT_FUNCTIONS in bitbake. - + #### \_\_init\_\_ @@ -2647,11 +2782,9 @@ def __init__(origin: str, line: int, infileline: int, rawtext: str, - statement: str, - classes: str, + name: str, realraw: str, - new_style_override_syntax: bool = False, - inherit_file_paths: Set[str] = None) -> None + new_style_override_syntax: bool = False) -> None ``` constructor @@ -2663,89 +2796,67 @@ constructor - `infileline` _int_ - Line counter in the particular file - `rawtext` _str_ - Raw input string (except inline code blocks) - `realraw` _str_ - Unprocessed input -- `class` _str_ - class code to inherit -- `statement` _str_ - inherit statement (INHERIT, inherit or inherit_defer) +- `name` _str_ - name of function to be exported **Arguments**: - `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) -- `inherit_file_paths` _Set[str]_ - Paths of the identified inherited classes - - - -#### Class - -```python -@property -def Class() -> str -``` -Class(es) to inherit - -**Returns**: - -- `str` - class(es) to inherit - - + -#### Statement +#### FuncNames ```python @property -def Statement() -> str +def FuncNames() -> str ``` -inherit statement +Function name **Returns**: -- `str` - inherit or inherit_defer +- `str` - names of exported functions - + -#### FilePaths +#### get\_items ```python -@property -def FilePaths() -> Set[str] +def get_items() -> List[str] ``` -File paths to identified bbclasses - -As some classes might not be resolvable in the current context -the order doesn't necessarily reflect the order of the -inherit statements +Get items **Returns**: -- `Set[str]` - File paths to identified bbclasses +- `list` - function names - + -#### get\_items +#### get\_items\_unaliased ```python -def get_items() -> List[str] +def get_items_unaliased() -> List[str] ``` -Get items +Get items with their bbclass scope names **Returns**: -- `list` - parsed Class items +- `list` - function names in the scope of a bbclass (foo becomes classname-foo in this case) - + -## Unset Objects +## TaskAdd Objects ```python -class Unset(Item) +class TaskAdd(Item) ``` -Items representing unset statements in bitbake. +Items representing addtask statements in bitbake. - + #### \_\_init\_\_ @@ -2756,7 +2867,9 @@ def __init__(origin: str, rawtext: str, name: str, realraw: str, - flag: str = "", + before: str = "", + after: str = "", + comment: str = "", new_style_override_syntax: bool = False) -> None ``` @@ -2769,738 +2882,625 @@ constructor - `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 variable to be unset +- `name` _str_ - name of task to be executed **Arguments**: -- `flag` _str_ - Flag to unset +- `before` _str_ - before statement (default: {""}) +- `after` _str_ - after statement (default: {""}) +- `comment` _str_ - optional comment (default: {""}) - `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) - + -#### VarName +#### FuncName ```python @property -def VarName() -> str +def FuncName() -> str ``` -Variable name +Function name **Returns**: -- `str` - name of the variable +- `str` - name of function - + -#### Flag +#### Before ```python @property -def Flag() -> str +def Before() -> List[str] ``` -Variable flag +Tasks executed before **Returns**: -- `str` - name of the variable flag +- `list` - tasks to be executed before - + -#### get\_items +#### After ```python -def get_items() -> List[str] +@property +def After() -> List[str] ``` -get items +Tasks executed after **Returns**: -- `list` - variable name, variable flag +- `list` - tasks to be executed after - + -# oelint\_parser.rpl\_regex - - - -## RegexRpl Objects +#### Comment ```python -class RegexRpl() -``` - -Safe regex replacements - - - -#### search - -```python -@staticmethod -def search(pattern: str, - string: str, - timeout: int = 5, - default: object = None, - **kwargs) -> Union[Match, None] +@property +def Comment() -> str ``` -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. - +Comment **Returns**: -- `Match` - Match object or None +- `str` - comment if any - + -#### split +#### get\_items ```python -@staticmethod -def split(pattern: str, - string: str, - timeout: int = 5, - default: object = None, - **kwargs) -> List[str] +def get_items() -> List[str] ``` -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. - +get items **Returns**: -- `list` - list object or None +- `list` - function name, all before statements, all after statements - + -#### match +## TaskDel Objects ```python -@staticmethod -def match(pattern: str, - string: str, - timeout: int = 5, - default: object = None, - **kwargs) -> Union[Match, None] +class TaskDel(Item) ``` -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 +Items representing deltask statements in bitbake. - + -#### sub +#### \_\_init\_\_ ```python -@staticmethod -def sub(pattern: str, - repl: str, - string: str, - timeout: int = 5, - default: str = '', - **kwargs) -> str +def __init__(origin: str, + line: int, + infileline: int, + rawtext: str, + name: str, + comment: str, + realraw: str, + new_style_override_syntax: bool = False) -> None ``` -replacement for re.sub +constructor **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 ''. +- `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 +- `comment` _str_ - optional comment -**Returns**: +**Arguments**: -- `str` - string +- `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) - + -#### finditer +#### FuncName ```python -@staticmethod -def finditer(pattern: str, - string: str, - timeout: int = 5, - default: object = None, - **kwargs) -> Scanner +@property +def FuncName() -> str ``` -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. - +Function name **Returns**: -- `Scanner` - Scanner object or None - - - -# oelint\_parser.constants - - - -## Constants Objects - -```python -class Constants() -``` - -Interface for constants +- `str` - name of function - + -#### GetByPath +#### Comment ```python -def GetByPath(path: str) -> Union[Dict, List] +@property +def Comment() -> str ``` -Get constant from path - -**Arguments**: - -- `path` _str_ - / joined path in the constant structure - +Comment **Returns**: - Union[Dict, List]: Item in structure or empty dictionary +- `str` - comment if any - + -#### AddConstants +#### get\_items ```python -def AddConstants(_dict: dict) -> None +def get_items() -> List[str] ``` -Add constants to the existing +get items -**Arguments**: +**Returns**: -- `dict` _dict_ - constant dictionary to add +- `list` - function name - + -#### RemoveConstants +## MissingFile Objects ```python -def RemoveConstants(_dict: dict) -> None +class MissingFile(Item) ``` -Remove constants from the existing - -**Arguments**: - -- `dict` _dict_ - constant dictionary to remove +Items representing missing files found while parsing. - + -#### OverrideConstants +#### \_\_init\_\_ ```python -def OverrideConstants(_dict: dict) -> None +def __init__(origin: str, + line: int, + infileline: int, + filename: str, + statement: str, + new_style_override_syntax: bool = False) -> None ``` -Override constants in the existing db +constructor **Arguments**: -- `dict` _dict]_ - constant dictionary with override values - - - -#### FunctionsKnown - -```python -@property -def FunctionsKnown() -> List[str] -``` - -Return known functions - -**Returns**: - -- `list` - list of known functions - - - -#### FunctionsOrder - -```python -@property -def FunctionsOrder() -> List[str] -``` - -Return function order +- `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 + -**Returns**: +**Arguments**: -- `list` - List of functions to order in their designated order +- `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) - + -#### VariablesMandatory +#### Filename ```python @property -def VariablesMandatory() -> List[str] +def Filename() -> str ``` -Return mandatory variables +Filename of the file missing **Returns**: -- `list` - List of mandatory variables +- `str` - filename that can't be resolved - + -#### VariablesSuggested +#### Statement ```python @property -def VariablesSuggested() -> List[str] +def Statement() -> str ``` -Return suggested variables +statement either include or require **Returns**: -- `list` - List of suggested variables +- `str` - include or require - + -#### MirrorsKnown +## AddPylib Objects ```python -@property -def MirrorsKnown() -> Dict[str, str] +class AddPylib(Item) ``` -Return known mirrors and their replacements - -**Returns**: - -- `dict` - Dict of known mirrors and their replacements +Items representing addpylib statements in bitbake. - + -#### VariablesProtected +#### \_\_init\_\_ ```python -@property -def VariablesProtected() -> List[str] +def __init__(origin: str, + line: int, + infileline: int, + rawtext: str, + path: str, + namespace: str, + realraw: str, + new_style_override_syntax: bool = False) -> None ``` -Return protected variables - -**Returns**: - -- `list` - List of protected variables - - - -#### VariablesProtectedAppend +constructor -```python -@property -def VariablesProtectedAppend() -> List[str] -``` +**Arguments**: -Return protected variables in bbappend files +- `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 +- `path` _str_ - path to the namespace +- `namespace` _str_ - namespace name + -**Returns**: +**Arguments**: -- `list` - List of protected variables in bbappend files +- `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) - + -#### VariablesOrder +#### Path ```python @property -def VariablesOrder() -> List[str] +def Path() -> str ``` -Variable order +Path of the library addition **Returns**: -- `list` - List of variables to order in their designated order +- `str` - path of the library addition - + -#### VariablesKnown +#### Namespace ```python @property -def VariablesKnown() -> List[str] +def Namespace() -> str ``` -Known variables +Namespace of the addition **Returns**: -- `list` - List of known variables +- `str` - Namespace of the addition - + -#### DistrosKnown +#### get\_items ```python -@property -def DistrosKnown() -> List[str] +def get_items() -> Tuple[str, str] ``` -Known distros +Get items **Returns**: -- `list` - List of known distros +- `list` - library path, library namespace - + -#### MachinesKnown +## Inherit Objects ```python -@property -def MachinesKnown() -> List[str] +class Inherit(Item) ``` -Known machines - -**Returns**: - -- `list` - List of known machines +Items that representing inherit(_defer) statements. - + -#### ImagesClasses +#### \_\_init\_\_ ```python -@property -def ImagesClasses() -> List[str] +def __init__(origin: str, + line: int, + infileline: int, + rawtext: str, + statement: str, + classes: str, + realraw: str, + new_style_override_syntax: bool = False, + inherit_file_paths: Set[str] = None) -> None ``` -Classes that are used in images - -**Returns**: - -- `list` - Classes that are used in images - - - -#### ImagesVariables +constructor -```python -@property -def ImagesVariables() -> List[str] -``` +**Arguments**: -Variables that are used in images +- `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 +- `class` _str_ - class code to inherit +- `statement` _str_ - inherit statement (INHERIT, inherit or inherit_defer) + -**Returns**: +**Arguments**: -- `list` - Variables that are used in images +- `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) +- `inherit_file_paths` _Set[str]_ - Paths of the identified inherited classes - + -#### SetsBase +#### Class ```python @property -def SetsBase() -> Dict[str, str] +def Class() -> str ``` -Base variable set +Class(es) to inherit **Returns**: -- `dict` - dictionary with base variable set - - - -# oelint\_parser.inlinerep +- `str` - class(es) to inherit - + -#### bb\_utils\_filter +#### Statement ```python -def bb_utils_filter(_in: str, negative_clause: bool = False) -> str +@property +def Statement() -> str ``` -bb.utils.filter emulation - -**Arguments**: - -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch - +inherit statement **Returns**: -- `str` - True argument of the conditional or None if not applicable +- `str` - inherit or inherit_defer - + -#### bb\_utils\_contains +#### FilePaths ```python -def bb_utils_contains(_in: str, negative_clause: bool = False) -> str +@property +def FilePaths() -> Set[str] ``` -bb.utils.contains emulation - -**Arguments**: +File paths to identified bbclasses -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch - +As some classes might not be resolvable in the current context +the order doesn't necessarily reflect the order of the +inherit statements **Returns**: -- `str` - True argument of the conditional or None if not applicable +- `Set[str]` - File paths to identified bbclasses - + -#### bb\_utils\_contains\_any +#### get\_items ```python -def bb_utils_contains_any(_in: str, negative_clause: bool = False) -> str +def get_items() -> List[str] ``` -bb.utils.contains_any emulation - -**Arguments**: - -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch - +Get items **Returns**: -- `str` - True argument of the conditional or None if not applicable +- `list` - parsed Class items - + -#### oe\_utils\_conditional +## Unset Objects ```python -def oe_utils_conditional(_in: str, negative_clause: bool = False) -> str +class Unset(Item) ``` -oe.utils.conditional emulation - -**Arguments**: - -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch - - -**Returns**: - -- `str` - True argument of the conditional or None if not applicable +Items representing unset statements in bitbake. - + -#### oe\_utils\_ifelse +#### \_\_init\_\_ ```python -def oe_utils_ifelse(_in: str, negative_clause: bool = False) -> str +def __init__(origin: str, + line: int, + infileline: int, + rawtext: str, + name: str, + realraw: str, + flag: str = "", + new_style_override_syntax: bool = False) -> None ``` -oe.utils.ifelse emulation +constructor **Arguments**: -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch +- `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 variable to be unset -**Returns**: +**Arguments**: -- `str` - True argument of the conditional or None if not applicable +- `flag` _str_ - Flag to unset +- `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) - + -#### oe\_utils\_any\_distro\_features +#### VarName ```python -def oe_utils_any_distro_features(_in: str, - negative_clause: bool = False) -> str +@property +def VarName() -> str ``` -oe.utils.any_distro_features emulation - -**Arguments**: - -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch - +Variable name **Returns**: -- `str` - True argument of the conditional or None if not applicable +- `str` - name of the variable - + -#### oe\_utils\_all\_distro\_features +#### Flag ```python -def oe_utils_all_distro_features(_in: str, - negative_clause: bool = False) -> str +@property +def Flag() -> str ``` -oe.utils.all_distro_features emulation - -**Arguments**: - -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch - +Variable flag **Returns**: -- `str` - True argument of the conditional or None if not applicable +- `str` - name of the variable flag - + -#### oe\_utils\_vartrue +#### get\_items ```python -def oe_utils_vartrue(_in: str, negative_clause: bool = False) -> str +def get_items() -> List[str] ``` -oe.utils.vartrue emulation +get items -**Arguments**: +**Returns**: -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch - +- `list` - variable name, variable flag -**Returns**: + -- `str` - True argument of the conditional or None if not applicable +# oelint\_parser.parser - + -#### oe\_utils\_less\_or\_equal +#### get\_full\_scope ```python -def oe_utils_less_or_equal(_in: str, negative_clause: bool = False) -> str +def get_full_scope(_string: str, offset: int, _sstart: int, _send: int) -> str ``` -oe.utils.less_or_equal emulation +get full block of an inline statement **Arguments**: -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch +- `_string` _str_ - input string +- `offset` _int_ - offset in string +- `_sstart` _int_ - block start index +- `_send` _int_ - block end index **Returns**: -- `str` - True argument of the conditional or None if not applicable +- `str` - full block on inline statement - + -#### oe\_utils\_version\_less\_or\_equal +#### prepare\_lines\_subparser ```python -def oe_utils_version_less_or_equal(_in: str, - negative_clause: bool = False) -> str +def prepare_lines_subparser(_iter: Iterable, + lineOffset: int, + num: int, + line: int, + raw_line: str = None, + negative: bool = False) -> List[str] ``` -oe.utils.version_less_or_equal emulation +preprocess raw input **Arguments**: -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch +- `_iter` _iterator_ - 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. +- `negative` _bool_ - Negative branch inline expansion. Defaults to False **Returns**: -- `str` - True argument of the conditional or None if not applicable +- `list` - list of preproccessed chunks - + -#### oe\_utils\_both\_contain +#### prepare\_lines ```python -def oe_utils_both_contain(_in: str, negative_clause: bool = False) -> str +def prepare_lines(_file: str, + lineOffset: int = 0, + negative: bool = False) -> List[str] ``` -oe.utils.both_contain emulation +break raw file input into preprocessed chunks **Arguments**: -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch +- `_file` _string_ - Full path to file +- `lineOffset` _int, optional_ - line offset counter. Defaults to 0. +- `negative` _bool_ - Negative branch inline expansion. Defaults to False **Returns**: -- `str` - True argument of the conditional or None if not applicable +- `list` - preprocessed list of chunks - + -#### inlinerep +#### get\_items ```python -def inlinerep(_in: str, negative_clause: bool = False) -> str +def get_items(stash: object, + _file: str, + lineOffset: int = 0, + new_style_override_syntax: bool = False, + negative: bool = False) -> List[Item] ``` -Replaces inline code expressions +parses file **Arguments**: -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch +- `stash` _oelint_parser.cls_stash.Stash_ - Stash object +- `_file` _string_ - Full path to file +- `lineOffset` _int, optional_ - line offset counter. Defaults to 0. +- `new_style_override_syntax` _bool, optional_ - default to new override syntax (default: False) +- `negative` _bool, optional_ - Negative branch inline expansion (default: False) **Returns**: -- `str` - Expanded string or None, if not applicable +- `list` - List of oelint_parser.cls_item.* representations diff --git a/oelint_parser/cls_item.py b/oelint_parser/cls_item.py index 545d9d2..0d03a7f 100644 --- a/oelint_parser/cls_item.py +++ b/oelint_parser/cls_item.py @@ -286,7 +286,6 @@ def __init__(self, self.__VarValue = value self.__VarOp = operator self.__RawVarName = self.VarName - self.__VarValueStripped = self.VarValue.strip().lstrip('"').rstrip('"') @property def VarName(self) -> str: @@ -371,7 +370,7 @@ def VarValueStripped(self) -> str: Returns: str: stripped version of variable value """ - return self.__VarValueStripped + return self.VarValue.strip().lstrip('"').rstrip('"') def IsAppend(self) -> bool: """Check if operation is an append @@ -659,8 +658,6 @@ def __init__(self, self.__SubItems = [x for x in self.SubItem.split( self.OverrideDelimiter) if x] self.__FuncBody = body - self.__FuncBodyStripped = body.replace( - "{", "").replace("}", "").replace("\n", "").strip() self.__FuncBodyRaw = textwrap.dedent( rawtext[rawtext.find("{") + 1:].rstrip().rstrip("}")) @@ -727,6 +724,10 @@ def FuncBody(self) -> str: """ return self.__FuncBody + @FuncBody.setter + def FuncBody(self, value: str) -> None: + self.__FuncBody = value + @property def FuncBodyStripped(self) -> str: """Stripped function body @@ -734,7 +735,8 @@ def FuncBodyStripped(self) -> str: Returns: str: stripped function body text """ - return self.__FuncBodyStripped + return self.__FuncBody.replace( + "{", "").replace("}", "").replace("\n", "").strip() @property def FuncBodyRaw(self) -> str: diff --git a/tests/test_parser.py b/tests/test_parser.py index c24b83e..a36efc3 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -564,6 +564,41 @@ def test_unset(self): self.assertEqual(x.VarName, "A") self.assertEqual(x.Flag, "my-flag") + def test_varvaluestripped_non_volatile(self): + from oelint_parser.cls_item import Variable + from oelint_parser.cls_stash import Stash + + self.__stash = Stash() + self.__stash.AddFile(OelintParserTest.RECIPE) + + _stash = self.__stash.GetItemsFor(classifier=Variable.CLASSIFIER, + attribute=Variable.ATTR_VAR, + attributeValue="LICENSE") + self.assertTrue(_stash, msg="Stash has no items") + + first = _stash[0].VarValueStripped + # now change + _stash[0].VarValue = 'abc' + + self.assertNotEqual(_stash[0].VarValueStripped, first) + + def test_function_stripped_non_volatile(self): + from oelint_parser.cls_item import Function + from oelint_parser.cls_stash import Stash + + self.__stash = Stash() + self.__stash.AddFile(OelintParserTest.RECIPE) + + _stash = self.__stash.GetItemsFor(classifier=Function.CLASSIFIER) + + self.assertTrue(_stash, msg="Stash has no items") + + first = _stash[0].FuncBodyStripped + # now change + _stash[0].FuncBody = 'abc' + + self.assertNotEqual(_stash[0].FuncBodyStripped, first) + if __name__ == "__main__": unittest.main()