diff --git a/docs/api-documentation.md b/docs/api-documentation.md index bb3046b..ea1c5f1 100644 --- a/docs/api-documentation.md +++ b/docs/api-documentation.md @@ -1,6 +1,43 @@ # Table of Contents * [oelint\_parser](#oelint_parser) +* [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.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) + * [d\_getvar](#oelint_parser.inlinerep.d_getvar) + * [inlinerep](#oelint_parser.inlinerep.inlinerep) +* [oelint\_parser.constants](#oelint_parser.constants) + * [Constants](#oelint_parser.constants.Constants) + * [\_\_init\_\_](#oelint_parser.constants.Constants.__init__) + * [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) + * [MirrorsKnown](#oelint_parser.constants.Constants.MirrorsKnown) + * [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) + * [ClassIgnore](#oelint_parser.constants.Constants.ClassIgnore) + * [IncludeIgnore](#oelint_parser.constants.Constants.IncludeIgnore) * [oelint\_parser.cls\_stash](#oelint_parser.cls_stash) * [Stash](#oelint_parser.cls_stash.Stash) * [StashList](#oelint_parser.cls_stash.Stash.StashList) @@ -32,11 +69,6 @@ * [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.cls\_item](#oelint_parser.cls_item) * [\_\_id\_regex\_\_](#oelint_parser.cls_item.__id_regex__) * [Item](#oelint_parser.cls_item.Item) @@ -169,34 +201,6 @@ * [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) - * [MirrorsKnown](#oelint_parser.constants.Constants.MirrorsKnown) - * [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) @@ -204,1695 +208,1794 @@ oelint_parser is a library to parse bitbake files. - + -# oelint\_parser.cls\_stash +# oelint\_parser.parser - + -## Stash Objects +#### get\_full\_scope ```python -class Stash() +def get_full_scope(_string: str, offset: int, _sstart: int, _send: int) -> str ``` -The Stash object is the central storage for extracting the bitbake information. +get full block of an inline statement - +**Arguments**: -## StashList Objects +- `_string` _str_ - input string +- `offset` _int_ - offset in string +- `_sstart` _int_ - block start index +- `_send` _int_ - block end index + -```python -class StashList(UserList) -``` +**Returns**: -Extended list of Items. +- `str` - full block on inline statement - + -#### \_\_init\_\_ +#### prepare\_lines\_subparser ```python -def __init__(stash: 'Stash', items: Iterable[Item]) -> None +def prepare_lines_subparser(_iter: Iterable, + lineOffset: int, + num: int, + line: int, + raw_line: str = None, + negative: bool = False) -> tuple[dict, str, int] ``` -StashList - Extended list of Items. +preprocess raw input **Arguments**: -- `stash` _Stash_ - Parent stash object -- `items` _Iterable_ - Iterable input +- `_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**: -#### insert + tuple[dict, str, int]: preproccessed chunk, buffer for next iteration, number of lines + + + +#### prepare\_lines ```python -def insert(index: int, item: Item) -> None +def prepare_lines(_file: str, + lineOffset: int = 0, + negative: bool = False) -> List[str] ``` -Insert into list +break raw file input into preprocessed chunks **Arguments**: -- `index` _int_ - index where to insert -- `item` _Item_ - object to insert +- `_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**: -#### append +- `list` - preprocessed list of chunks + + + +#### get\_items ```python -def append(item: Union[Item, Iterable[Item]]) -> None +def get_items(stash: object, + _file: str, + lineOffset: int = 0, + new_style_override_syntax: bool = False, + negative: bool = False) -> List[Item] ``` -Append to list +parses file **Arguments**: -- `item` _Union[Item, Iterable[Item]]_ - Item or Iterable of Items +- `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**: -#### extend +- `list` - List of oelint_parser.cls_item.* representations + + + +# oelint\_parser.inlinerep + + + +#### bb\_utils\_filter ```python -def extend(other: 'Stash.StashList') -> None +def bb_utils_filter(_in: str, negative_clause: bool = False) -> str ``` -Extend list +bb.utils.filter emulation **Arguments**: -- `other` _Stash.StashList_ - Other stash other +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + - +**Returns**: -#### remove +- `str` - True argument of the conditional or None if not applicable + + + +#### bb\_utils\_contains ```python -def remove(item: Union[Item, Iterable[Item]]) -> None +def bb_utils_contains(_in: str, negative_clause: bool = False) -> str ``` -Remove from list +bb.utils.contains emulation **Arguments**: -- `item` _Item_ - Item(s) to remove +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + - +**Returns**: -#### reduce +- `str` - True argument of the conditional or None if not applicable -```python -def reduce(filename: str = None, - classifier: Union[Iterable[str], str] = None, - attribute: Union[Iterable[str], str] = None, - attributeValue: Union[Iterable[str], str] = None, - nolink: bool = False) -> 'Stash.StashList' -``` + -Filters the list. +#### bb\_utils\_contains\_any -NOTE: This is a destructive operation. -If you want to have a copy returned use +```python +def bb_utils_contains_any(_in: str, negative_clause: bool = False) -> str +``` -Stash.Reduce(,...) instead. +bb.utils.contains_any emulation **Arguments**: -- `filename` _str, optional_ - Full path to file. Defaults to None. -- `classifier` _Union[Iterable[str], str], optional_ - (iterable of) class specifier (e.g. Variable). Defaults to None. -- `attribute` _Union[Iterable[str], str], optional_ - (iterable of) class attribute name. Defaults to None. -- `attributeValue` _Union[Iterable[str], str], optional_ - (iterable of) value of the class attribute value. Defaults to None. -- `nolink` _bool, optional_ - Consider linked files. Defaults to False. +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch **Returns**: -- `Stash.StashList` - self +- `str` - True argument of the conditional or None if not applicable - + -#### \_\_init\_\_ +#### oe\_utils\_conditional ```python -def __init__(quiet: bool = False, - new_style_override_syntax: bool = False, - negative_inline: bool = False) -> None +def oe_utils_conditional(_in: str, negative_clause: bool = False) -> str ``` -Stash object +oe.utils.conditional emulation **Arguments**: -- `quiet` _bool, optional_ - No progress printing. Defaults to False. -- `new_style_override_syntax` _bool, optional_ - Enforce new override syntax. Defaults to False. -- `negative_inline` _bool, optional_ - Negative branch inline expansion. Defaults to False. +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + - +**Returns**: -#### AddFile +- `str` - True argument of the conditional or None if not applicable + + + +#### oe\_utils\_ifelse ```python -def AddFile(_file: str, - lineOffset: int = 0, - forcedLink: str = None) -> List[Item] +def oe_utils_ifelse(_in: str, negative_clause: bool = False) -> str ``` -Adds a file to the stash +oe.utils.ifelse emulation **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}) +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch **Returns**: -- `list` - List of {oelint_parser.cls_item.Item} +- `str` - True argument of the conditional or None if not applicable - + -#### FingerPrint +#### oe\_utils\_any\_distro\_features ```python -@property -def FingerPrint() -> str +def oe_utils_any_distro_features(_in: str, + negative_clause: bool = False) -> str ``` -Get the SHA1 fingerprint of the current Stash +oe.utils.any_distro_features emulation + +**Arguments**: + +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + **Returns**: -- `str` - hexdigest checksum +- `str` - True argument of the conditional or None if not applicable - + -#### Append +#### oe\_utils\_all\_distro\_features ```python -def Append(item: Union[Item, Iterable[Item]]) -> None +def oe_utils_all_distro_features(_in: str, + negative_clause: bool = False) -> str ``` -appends one or mote items to the stash +oe.utils.all_distro_features emulation **Arguments**: -- `item` _Item_ - Item(s) to append - - - -#### Remove - -```python -def Remove(item: Union[Item, Iterable[Item]]) -> None -``` - -removes one or more items from the stash +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + -**Arguments**: +**Returns**: -- `item` _Item_ - Item(s) to remove +- `str` - True argument of the conditional or None if not applicable - + -#### AddDistroMachineFromLayer +#### oe\_utils\_vartrue ```python -def AddDistroMachineFromLayer(path: str) -> None +def oe_utils_vartrue(_in: str, negative_clause: bool = False) -> str ``` -adds machine and distro configuration from the layer of the provided file +oe.utils.vartrue emulation **Arguments**: -- `path` _str_ - Path to file - - - -#### Finalize +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + -```python -def Finalize() -> None -``` +**Returns**: -finalize the dependencies within the stash +- `str` - True argument of the conditional or None if not applicable - + -#### GetRecipes +#### oe\_utils\_less\_or\_equal ```python -@functools.cache -def GetRecipes() -> None +def oe_utils_less_or_equal(_in: str, negative_clause: bool = False) -> str ``` -Get bb files in stash - -**Returns**: - -- `list` - List of bb files in stash - - - -#### GetLoneAppends +oe.utils.less_or_equal emulation -```python -@functools.cache -def GetLoneAppends() -> List[str] -``` +**Arguments**: -Get bbappend without a matching bb +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + **Returns**: -- `list` - list of bbappend without a matching bb +- `str` - True argument of the conditional or None if not applicable - + -#### GetConfFiles +#### oe\_utils\_version\_less\_or\_equal ```python -@functools.cache -def GetConfFiles() -> List[str] +def oe_utils_version_less_or_equal(_in: str, + negative_clause: bool = False) -> str ``` -Get configurations files - -**Returns**: - -- `List[str]` - List of configuration files - - - -#### GetBBClasses +oe.utils.version_less_or_equal emulation -```python -@functools.cache -def GetBBClasses() -> List[str] -``` +**Arguments**: -Get bbclass files +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch + **Returns**: -- `List[str]` - List of bbclass files +- `str` - True argument of the conditional or None if not applicable - + -#### GetLinksForFile +#### oe\_utils\_both\_contain ```python -@functools.cache -def GetLinksForFile(filename: str) -> List[str] +def oe_utils_both_contain(_in: str, negative_clause: bool = False) -> str ``` -Get file which this file is linked against +oe.utils.both_contain emulation **Arguments**: -- `filename` _str_ - full path to file +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch **Returns**: -- `list` - list of full paths the file is linked against +- `str` - True argument of the conditional or None if not applicable - + -#### Reduce +#### d\_getvar ```python -def Reduce(in_list: Iterable[Item], - filename: str = None, - classifier: Union[Iterable[str], str] = None, - attribute: Union[Iterable[str], str] = None, - attributeValue: Union[Iterable[str], str] = None, - nolink: bool = False) -> List[Item] +def d_getvar(_in: str) -> str ``` -Reduce a list by filtering +d.getVar emulation in inline block **Arguments**: -- `in_list` _Stash.StashList_ - Input list. -- `filename` _str, optional_ - Full path to file. Defaults to None. -- `classifier` _Union[Iterable[str], str], optional_ - (iterable of) class specifier (e.g. Variable). Defaults to None. -- `attribute` _Union[Iterable[str], str], optional_ - (iterable of) class attribute name. Defaults to None. -- `attributeValue` _Union[Iterable[str], str], optional_ - (iterable of) value of the class attribute value. Defaults to None. -- `nolink` _bool, optional_ - Consider linked files. Defaults to False. +- `_in` _str_ - Input string **Returns**: -- `List[Item]` - Returns a list of items fitting the set filters +- `str` - Variable reference if found - + -#### GetItemsFor +#### inlinerep ```python -def GetItemsFor(filename: str = None, - classifier: Union[Iterable[str], str] = None, - attribute: Union[Iterable[str], str] = None, - attributeValue: Union[Iterable[str], str] = None, - nolink: bool = False) -> 'Stash.StashList' +def inlinerep(_in: str, negative_clause: bool = False) -> str ``` -Get items for filename +Replaces inline code expressions **Arguments**: -- `filename` _str, optional_ - Full path to file. Defaults to None. -- `classifier` _Union[Iterable[str], str], optional_ - (iterable of) class specifier (e.g. Variable). Defaults to None. -- `attribute` _Union[Iterable[str], str], optional_ - (iterable of) class attribute name. Defaults to None. -- `attributeValue` _Union[Iterable[str], str], optional_ - (iterable of) value of the class attribute value. Defaults to None. -- `nolink` _bool, optional_ - Consider linked files. Defaults to False. +- `_in` _str_ - Input string +- `negative_clause` _bool_ - return negative branch **Returns**: -- `Stash.StashList` - Returns a list of items fitting the set filters +- `str` - Expanded string or None, if not applicable - + -#### ExpandVar +# oelint\_parser.constants + + + +## Constants Objects ```python -def ExpandVar(filename: str = None, - attribute: Union[Iterable[str], str] = None, - attributeValue: Union[Iterable[str], str] = None, - nolink: bool = False) -> dict +class Constants() ``` -Expand variable to dictionary +Interface for constants -**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}) - +#### \_\_init\_\_ -**Returns**: +```python +def __init__(file_: str = DEFAULT_DB) -> None +``` -- `{dict}` - expanded variables from call + base set of variables +Constants interface - +**Arguments**: -#### GetFiles +- `file_` _str, optional_ - File to load. Defaults to DEFAULT_DB. + + + +#### GetByPath ```python -@functools.cache -def GetFiles(_file: str, pattern: str) -> List[str] +def GetByPath(path: str) -> Union[Dict, List] ``` -Get files matching SRC_URI entries +Get constant from path **Arguments**: -- `_file` _str_ - Full path to filename -- `pattern` _str_ - glob pattern to apply +- `path` _str_ - / joined path in the constant structure **Returns**: -- `list` - list of files matching pattern + Union[Dict, List]: Item in structure or empty dictionary - + -#### GetLayerRoot +#### AddConstants ```python -@functools.cache -def GetLayerRoot(name: str) -> str +def AddConstants(_dict: dict) -> None ``` -Find the path to the layer root of a file +Add constants to the existing **Arguments**: -- `name` _str_ - filename - - -**Returns**: - -- `str` - path to layer root or empty string +- `dict` _dict_ - constant dictionary to add - + -#### FindLocalOrLayer +#### RemoveConstants ```python -@functools.cache -def FindLocalOrLayer(name: str, localdir: str) -> str +def RemoveConstants(_dict: dict) -> None ``` -Find file in local dir or in layer +Remove constants from the existing **Arguments**: -- `name` _str_ - filename -- `localdir` _str_ - path to local dir - +- `dict` _dict_ - constant dictionary to remove -**Returns**: - -- `str` - path to found file or None - - + -#### GetScrComponents +#### OverrideConstants ```python -@functools.cache -def GetScrComponents(string: str) -> dict +def OverrideConstants(_dict: dict) -> None ``` -Return SRC_URI components +Override constants in the existing db **Arguments**: -- `string` _str_ - raw string - +- `dict` _dict]_ - constant dictionary with override values + + + +#### FunctionsKnown + +```python +@property +def FunctionsKnown() -> List[str] +``` + +Return known functions **Returns**: -- `dict` - scheme: protocol used, src: source URI, options: parsed options +- `list` - list of known functions - + -#### SafeLineSplit +#### FunctionsOrder ```python -@functools.cache -def SafeLineSplit(string: str) -> List[str] +@property +def FunctionsOrder() -> List[str] ``` -Split line in a safe manner - -**Arguments**: - -- `string` _str_ - raw input - +Return function order **Returns**: -- `list` - safely split input +- `list` - List of functions to order in their designated order - + -#### GuessRecipeName +#### MirrorsKnown ```python -@functools.cache -def GuessRecipeName(_file: str) -> str +@property +def MirrorsKnown() -> Dict[str, str] ``` -Get the recipe name from filename - -**Arguments**: - -- `_file` _str_ - filename - +Return known mirrors and their replacements **Returns**: -- `str` - recipe name +- `dict` - Dict of known mirrors and their replacements - + -#### GuessBaseRecipeName +#### VariablesKnown ```python -@functools.cache -def GuessBaseRecipeName(_file: str) -> str +@property +def VariablesKnown() -> List[str] ``` -Get the base recipe name from filename (aka BPN) - -**Arguments**: - -- `_file` _str_ - filename - +Known variables **Returns**: -- `str` - recipe name +- `list` - List of known variables - + -#### GuessRecipeVersion +#### DistrosKnown ```python -@functools.cache -def GuessRecipeVersion(_file: str) -> str +@property +def DistrosKnown() -> List[str] ``` -Get recipe version from filename - -**Arguments**: - -- `_file` _str_ - filename - +Known distros **Returns**: -- `str` - recipe version +- `list` - List of known distros - + -#### ExpandTerm +#### MachinesKnown ```python -def ExpandTerm(_file: str, - value: str, - spare: List[str] = None, - seen: List[str] = None, - objref: Variable = None) -> str +@property +def MachinesKnown() -> List[str] ``` -Expand a variable (replacing all variables by known content) - -**Arguments**: - -- `_file` _str_ - Full path to file -- `value` _str_ - Variable value to expand -- `spare` _list[str]_ - items to keep unexpanded (default: None) -- `seen` _list[str]_ - seen items (default: None) -- `objref` _Variable_ - reference to the calling variable instance (default: None) - +Known machines **Returns**: -- `str` - expanded value +- `list` - List of known machines - + -#### GetValidPackageNames +#### ImagesClasses ```python -@functools.cache -def GetValidPackageNames(_file: str, strippn: bool = False) -> List[str] +@property +def ImagesClasses() -> List[str] ``` -Get known valid names for packages - -**Arguments**: - -- `_file` _str_ - Full path to file -- `strippn` _bool_ - strip the package name (default: False) - +Classes that are used in images **Returns**: -- `list` - list of valid package names +- `list` - Classes that are used in images - + -#### GetValidNamedResources +#### ImagesVariables ```python -@functools.cache -def GetValidNamedResources(_file: str) -> List[str] +@property +def ImagesVariables() -> List[str] ``` -Get list of valid SRCREV resource names - -**Arguments**: - -- `_file` _str_ - Full path to file - +Variables that are used in images **Returns**: -- `list` - list of valid SRCREV resource names +- `list` - Variables that are used in images - + -#### IsImage +#### SetsBase ```python -@functools.cache -def IsImage(_file: str) -> bool +@property +def SetsBase() -> Dict[str, str] ``` -returns if the file is likely an image recipe or not - -**Arguments**: - -- `_file` _str_ - Full path to file - +Base variable set **Returns**: -- `bool` - True if _file is an image recipe +- `dict` - dictionary with base variable set - + -#### IsPackageGroup +#### ClassIgnore ```python -@functools.cache -def IsPackageGroup(_file: str) -> bool +@property +def ClassIgnore() -> List[str] ``` -returns if the file is likely a packagegroup recipe or not +_summary_ -**Arguments**: +**Returns**: -- `_file` _str_ - Full path to file - +- `List[str]` - List of classes to ignore + + + +#### IncludeIgnore + +```python +@property +def IncludeIgnore() -> List[str] +``` + +Includes to ignore **Returns**: -- `bool` - True if _file is a packagegroup recipe +- `List[str]` - List of paths to ignore - + -# oelint\_parser.parser +# oelint\_parser.cls\_stash - + -#### get\_full\_scope +## Stash Objects ```python -def get_full_scope(_string: str, offset: int, _sstart: int, _send: int) -> str +class Stash() ``` -get full block of an inline statement +The Stash object is the central storage for extracting the bitbake information. -**Arguments**: + -- `_string` _str_ - input string -- `offset` _int_ - offset in string -- `_sstart` _int_ - block start index -- `_send` _int_ - block end index - +## StashList Objects -**Returns**: +```python +class StashList(UserList) +``` -- `str` - full block on inline statement +Extended list of Items. - + -#### prepare\_lines\_subparser +#### \_\_init\_\_ ```python -def prepare_lines_subparser(_iter: Iterable, - lineOffset: int, - num: int, - line: int, - raw_line: str = None, - negative: bool = False) -> tuple[dict, str, int] +def __init__(stash: 'Stash', items: Iterable[Item]) -> None ``` -preprocess raw input +StashList - Extended list of Items. **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 - +- `stash` _Stash_ - Parent stash object +- `items` _Iterable_ - Iterable input -**Returns**: + - tuple[dict, str, int]: preproccessed chunk, buffer for next iteration, number of lines +#### insert - +```python +def insert(index: int, item: Item) -> None +``` -#### prepare\_lines +Insert into list + +**Arguments**: + +- `index` _int_ - index where to insert +- `item` _Item_ - object to insert + + + +#### append ```python -def prepare_lines(_file: str, - lineOffset: int = 0, - negative: bool = False) -> List[str] +def append(item: Union[Item, Iterable[Item]]) -> None ``` -break raw file input into preprocessed chunks +Append to list **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 - +- `item` _Union[Item, Iterable[Item]]_ - Item or Iterable of Items -**Returns**: + -- `list` - preprocessed list of chunks +#### extend - +```python +def extend(other: 'Stash.StashList') -> None +``` -#### get\_items +Extend list + +**Arguments**: + +- `other` _Stash.StashList_ - Other stash other + + + +#### remove ```python -def get_items(stash: object, - _file: str, - lineOffset: int = 0, - new_style_override_syntax: bool = False, - negative: bool = False) -> List[Item] +def remove(item: Union[Item, Iterable[Item]]) -> None ``` -parses file +Remove from list **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) - +- `item` _Item_ - Item(s) to remove -**Returns**: + -- `list` - List of oelint_parser.cls_item.* representations +#### reduce - +```python +def reduce(filename: str = None, + classifier: Union[Iterable[str], str] = None, + attribute: Union[Iterable[str], str] = None, + attributeValue: Union[Iterable[str], str] = None, + nolink: bool = False) -> 'Stash.StashList' +``` -# oelint\_parser.cls\_item +Filters the list. - +NOTE: This is a destructive operation. +If you want to have a copy returned use -#### \_\_id\_regex\_\_ +Stash.Reduce(,...) instead. -noqa: P103 +**Arguments**: - +- `filename` _str, optional_ - Full path to file. Defaults to None. +- `classifier` _Union[Iterable[str], str], optional_ - (iterable of) class specifier (e.g. Variable). Defaults to None. +- `attribute` _Union[Iterable[str], str], optional_ - (iterable of) class attribute name. Defaults to None. +- `attributeValue` _Union[Iterable[str], str], optional_ - (iterable of) value of the class attribute value. Defaults to None. +- `nolink` _bool, optional_ - Consider linked files. Defaults to False. + -## Item Objects +**Returns**: + +- `Stash.StashList` - self + + + +#### \_\_init\_\_ ```python -class Item() +def __init__(quiet: bool = False, + new_style_override_syntax: bool = False, + negative_inline: bool = False) -> None ``` -Base class for all Stash items +Stash object - +**Arguments**: -#### \_\_init\_\_ +- `quiet` _bool, optional_ - No progress printing. Defaults to False. +- `new_style_override_syntax` _bool, optional_ - Enforce new override syntax. Defaults to False. +- `negative_inline` _bool, optional_ - Negative branch inline expansion. Defaults to False. + + + +#### AddFile ```python -def __init__(origin: str, - line: int, - infileline: int, - rawtext: str, - realraw: str, - inline_blocks: List[Tuple[str, str]], - new_style_override_syntax: bool = False) -> None +def AddFile(_file: str, + lineOffset: int = 0, + forcedLink: str = None) -> List[Item] ``` -constructor +Adds a file to the stash **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 +- `_file` _str_ - Full path to file + **Arguments**: -- `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) +- `lineOffset` _int_ - Line offset from the file that include this file (default: {0}) +- `forcedLink` _type_ - Force link against a file (default: {None}) + - +**Returns**: -#### Line +- `list` - List of {oelint_parser.cls_item.Item} + + + +#### FingerPrint ```python @property -def Line() -> int +def FingerPrint() -> str ``` -Overall line count +Get the SHA1 fingerprint of the current Stash **Returns**: -- `int` - overall line count of item +- `str` - hexdigest checksum - + -#### Raw +#### Append ```python -@property -def Raw() -> str +def Append(item: Union[Item, Iterable[Item]]) -> None ``` -Raw string (without inline code blocks) +appends one or mote items to the stash -**Returns**: +**Arguments**: -- `str` - raw string of item +- `item` _Item_ - Item(s) to append - + -#### Origin +#### Remove ```python -@property -def Origin() -> str +def Remove(item: Union[Item, Iterable[Item]]) -> None ``` -origin of item +removes one or more items from the stash -**Returns**: +**Arguments**: -- `str` - full path of origin file +- `item` _Item_ - Item(s) to remove - + -#### InFileLine +#### AddDistroMachineFromLayer ```python -@property -def InFileLine() -> int +def AddDistroMachineFromLayer(path: str) -> None ``` -Line count in file +adds machine and distro configuration from the layer of the provided file -**Returns**: +**Arguments**: -- `int` - [description] +- `path` _str_ - Path to file - + + +#### Finalize + +```python +def Finalize() -> None +``` + +finalize the dependencies within the stash + + -#### RealRaw +#### GetRecipes ```python -@property -def RealRaw() -> str +@functools.cache +def GetRecipes() -> None ``` -Completely unprocessed raw text +Get bb files in stash **Returns**: -- `str` - completely unprocessed raw text +- `list` - List of bb files in stash - + -#### IsFromClass +#### GetLoneAppends ```python -@property -def IsFromClass() -> bool +@functools.cache +def GetLoneAppends() -> List[str] ``` -Item comes from a bbclass +Get bbappend without a matching bb **Returns**: -- `bool` - if item was set in a bbclass +- `list` - list of bbappend without a matching bb - + -#### OverrideDelimiter +#### GetConfFiles ```python -@property -def OverrideDelimiter() -> str +@functools.cache +def GetConfFiles() -> List[str] ``` -Override delimiter +Get configurations files **Returns**: -- `str` - Override delimiter +- `List[str]` - List of configuration files - + -#### IsNewStyleOverrideSyntax +#### GetBBClasses ```python -@property -def IsNewStyleOverrideSyntax() -> bool +@functools.cache +def GetBBClasses() -> List[str] ``` -New style override syntax detected +Get bbclass files **Returns**: -- `bool` - True if new style has been detected +- `List[str]` - List of bbclass files - + -#### safe\_linesplit +#### GetLinksForFile ```python -@staticmethod -def safe_linesplit(string: str) -> List[str] +@functools.cache +def GetLinksForFile(filename: str) -> List[str] ``` -Safely split an input line to chunks +Get file which this file is linked against **Arguments**: -- `string` _str_ - raw input string +- `filename` _str_ - full path to file **Returns**: -- `list` - list of chunks of original string +- `list` - list of full paths the file is linked against - + -#### get\_items +#### Reduce ```python -def get_items() -> List[str] +def Reduce(in_list: Iterable[Item], + filename: str = None, + classifier: Union[Iterable[str], str] = None, + attribute: Union[Iterable[str], str] = None, + attributeValue: Union[Iterable[str], str] = None, + nolink: bool = False) -> List[Item] ``` -Return single items +Reduce a list by filtering + +**Arguments**: + +- `in_list` _Stash.StashList_ - Input list. +- `filename` _str, optional_ - Full path to file. Defaults to None. +- `classifier` _Union[Iterable[str], str], optional_ - (iterable of) class specifier (e.g. Variable). Defaults to None. +- `attribute` _Union[Iterable[str], str], optional_ - (iterable of) class attribute name. Defaults to None. +- `attributeValue` _Union[Iterable[str], str], optional_ - (iterable of) value of the class attribute value. Defaults to None. +- `nolink` _bool, optional_ - Consider linked files. Defaults to False. + **Returns**: -- `list` - lines of raw input +- `List[Item]` - Returns a list of items fitting the set filters - + -#### extract\_sub +#### GetItemsFor ```python -def extract_sub(name: str) -> Tuple[List[str], List[str]] +def GetItemsFor(filename: str = None, + classifier: Union[Iterable[str], str] = None, + attribute: Union[Iterable[str], str] = None, + attributeValue: Union[Iterable[str], str] = None, + nolink: bool = False) -> 'Stash.StashList' ``` -Extract modifiers +Get items for filename **Arguments**: -- `name` _str_ - input string +- `filename` _str, optional_ - Full path to file. Defaults to None. +- `classifier` _Union[Iterable[str], str], optional_ - (iterable of) class specifier (e.g. Variable). Defaults to None. +- `attribute` _Union[Iterable[str], str], optional_ - (iterable of) class attribute name. Defaults to None. +- `attributeValue` _Union[Iterable[str], str], optional_ - (iterable of) value of the class attribute value. Defaults to None. +- `nolink` _bool, optional_ - Consider linked files. Defaults to False. **Returns**: -- `tuple` - clean variable name, modifiers, package specific modifiers +- `Stash.StashList` - Returns a list of items fitting the set filters - + -#### extract\_sub\_func +#### ExpandVar ```python -def extract_sub_func(name: str) -> Tuple[List[str], List[str]] +def ExpandVar(filename: str = None, + attribute: Union[Iterable[str], str] = None, + attributeValue: Union[Iterable[str], str] = None, + nolink: bool = False) -> dict ``` -Extract modifiers for functions +Expand variable to dictionary **Arguments**: -- `name` _str_ - input value +- `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**: -- `tuple` - clean function name, modifiers +- `{dict}` - expanded variables from call + base set of variables - + -#### IsFromAppend +#### GetFiles ```python -def IsFromAppend() -> bool +@functools.cache +def GetFiles(_file: str, pattern: str) -> List[str] ``` -Item originates from a bbappend +Get files matching SRC_URI entries + +**Arguments**: + +- `_file` _str_ - Full path to filename +- `pattern` _str_ - glob pattern to apply + **Returns**: -- `bool` - True if coming from a bbappend +- `list` - list of files matching pattern - + -#### GetAttributes +#### GetLayerRoot ```python -def GetAttributes() -> dict +@functools.cache +def GetLayerRoot(name: str) -> str ``` -Get all public attributes of this class +Find the path to the layer root of a file + +**Arguments**: + +- `name` _str_ - filename + **Returns**: -- `dict` - all public attributes and their values +- `str` - path to layer root or empty string - + -## Variable Objects +#### FindLocalOrLayer ```python -class Variable(Item) +@functools.cache +def FindLocalOrLayer(name: str, localdir: str) -> str ``` -Items representing variables in bitbake. +Find file in local dir or in layer - +**Arguments**: -#### \_\_init\_\_ +- `name` _str_ - filename +- `localdir` _str_ - path to local dir + + +**Returns**: + +- `str` - path to found file or None + + + +#### GetScrComponents ```python -def __init__(name: str, value: str, operator: str, *args, **kwargs) -> None +@functools.cache +def GetScrComponents(string: str) -> dict ``` -constructor +Return SRC_URI components **Arguments**: -- `name` _str_ - Variable name -- `value` _str_ - Variable value -- `operator` _str_ - Operation performed to the variable +- `string` _str_ - raw string + - +**Returns**: -#### VarName +- `dict` - scheme: protocol used, src: source URI, options: parsed options + + + +#### SafeLineSplit ```python -@property -def VarName() -> str +@functools.cache +def SafeLineSplit(string: str) -> List[str] ``` -Variable name +Split line in a safe manner + +**Arguments**: + +- `string` _str_ - raw input + **Returns**: -- `str` - name of variable +- `list` - safely split input - + -#### SubItem +#### GuessRecipeName ```python -@property -def SubItem() -> str +@functools.cache +def GuessRecipeName(_file: str) -> str ``` -Variable modifiers +Get the recipe name from filename + +**Arguments**: + +- `_file` _str_ - filename + **Returns**: -- `str` - variable modifiers like packages, machines, appends, prepends +- `str` - recipe name - + -#### SubItems +#### GuessBaseRecipeName ```python -@property -def SubItems() -> List[str] +@functools.cache +def GuessBaseRecipeName(_file: str) -> str ``` -Variable modifiers list +Get the base recipe name from filename (aka BPN) + +**Arguments**: + +- `_file` _str_ - filename + **Returns**: -- `list` - variable modifiers list like packages, machines, appends, prepends +- `str` - recipe name - + -#### VarValue +#### GuessRecipeVersion ```python -@property -def VarValue() -> str +@functools.cache +def GuessRecipeVersion(_file: str) -> str ``` -variable value +Get recipe version from filename + +**Arguments**: + +- `_file` _str_ - filename + **Returns**: -- `str` - unstripped variable value +- `str` - recipe version - + -#### VarOp +#### ExpandTerm ```python -@property -def VarOp() -> str +def ExpandTerm(_file: str, + value: str, + spare: List[str] = None, + seen: List[str] = None, + objref: Variable = None) -> str ``` -Variable operation +Expand a variable (replacing all variables by known content) + +**Arguments**: + +- `_file` _str_ - Full path to file +- `value` _str_ - Variable value to expand +- `spare` _list[str]_ - items to keep unexpanded (default: None) +- `seen` _list[str]_ - seen items (default: None) +- `objref` _Variable_ - reference to the calling variable instance (default: None) + **Returns**: -- `str` - operation did on the variable +- `str` - expanded value - + -#### VarNameComplete +#### GetValidPackageNames ```python -@property -def VarNameComplete() -> str +@functools.cache +def GetValidPackageNames(_file: str, strippn: bool = False) -> List[str] ``` -Complete variable name included overrides and flags +Get known valid names for packages + +**Arguments**: + +- `_file` _str_ - Full path to file +- `strippn` _bool_ - strip the package name (default: False) + **Returns**: -- `str` - complete variable name +- `list` - list of valid package names - + -#### VarNameCompleteNoModifiers +#### GetValidNamedResources ```python -@property -def VarNameCompleteNoModifiers() -> str +@functools.cache +def GetValidNamedResources(_file: str) -> List[str] ``` -Complete variable name included overrides but without modifiers like append, prepend and remove +Get list of valid SRCREV resource names + +**Arguments**: + +- `_file` _str_ - Full path to file + **Returns**: -- `str` - complete variable name +- `list` - list of valid SRCREV resource names - + -#### RawVarName +#### IsImage ```python -@property -def RawVarName() -> str +@functools.cache +def IsImage(_file: str) -> bool ``` -Variable name and flags combined +returns if the file is likely an image recipe or not + +**Arguments**: + +- `_file` _str_ - Full path to file + **Returns**: -- `str` - raw representation of the variable name +- `bool` - True if _file is an image recipe - + -#### VarValueStripped +#### IsPackageGroup ```python -@property -def VarValueStripped() -> str +@functools.cache +def IsPackageGroup(_file: str) -> bool ``` -Stripped variable value +returns if the file is likely a packagegroup recipe or not -**Returns**: +**Arguments**: -- `str` - stripped version of variable value +- `_file` _str_ - Full path to file + - +**Returns**: -#### IsAppend +- `bool` - True if _file is a packagegroup recipe -```python -def IsAppend() -> bool -``` + -Check if operation is an append +# oelint\_parser.cls\_item -**Returns**: + -- `bool` - True is variable is appended +#### \_\_id\_regex\_\_ - +noqa: P103 -#### AppendOperation + + +## Item Objects ```python -def AppendOperation() -> List[str] +class Item() ``` -Get variable modifiers - -**Returns**: - -- `list` - list could contain any combination of 'append', ' += ', 'prepend' and 'remove' +Base class for all Stash items - + -#### get\_items +#### \_\_init\_\_ ```python -def get_items(override: str = "", versioned: bool = False) -> List[str] +def __init__(origin: str, + line: int, + infileline: int, + rawtext: str, + realraw: str, + inline_blocks: List[Tuple[str, str]], + new_style_override_syntax: bool = False) -> None ``` -Get items of variable value +constructor **Arguments**: -- `override` _str_ - String to take instead of VarValue -- `versioned` _bool_ - items can be versioned (versions will be stripped in this case) - +- `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 -**Returns**: +**Arguments**: -- `list` - clean list of items in variable value +- `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) - + -#### IsMultiLine +#### Line ```python -def IsMultiLine() -> bool +@property +def Line() -> int ``` -Check if variable has a multiline assignment +Overall line count **Returns**: -- `bool` - True if multiline +- `int` - overall line count of item - + -#### GetDistroEntry +#### Raw ```python -def GetDistroEntry() -> str +@property +def Raw() -> str ``` -Get distro specific entries in variable +Raw string (without inline code blocks) **Returns**: -- `str` - distro specific modifier of variable or "" +- `str` - raw string of item - + -#### GetMachineEntry +#### Origin ```python -def GetMachineEntry() -> str +@property +def Origin() -> str ``` -Get machine specific entries in variable +origin of item **Returns**: -- `str` - machine specific modifier of variable or "" +- `str` - full path of origin file - + -#### GetClassOverride +#### InFileLine ```python -def GetClassOverride() -> str +@property +def InFileLine() -> int ``` -Get class specific entries in variable +Line count in file **Returns**: -- `str` - class specific modifier of variable or "" +- `int` - [description] - + -#### IsImmediateModify +#### RealRaw ```python -def IsImmediateModify() -> bool +@property +def RealRaw() -> str ``` -Variable operation is done immediately +Completely unprocessed raw text **Returns**: -- `bool` - true if it isn't a prepend/append or remove operation +- `str` - completely unprocessed raw text - + -## Comment Objects +#### IsFromClass ```python -class Comment(Item) +@property +def IsFromClass() -> bool ``` -Items representing comments in bitbake. +Item comes from a bbclass - +**Returns**: -#### \_\_init\_\_ +- `bool` - if item was set in a bbclass + + + +#### OverrideDelimiter ```python -def __init__(*args, **kwargs) -> None +@property +def OverrideDelimiter() -> str ``` -constructor +Override delimiter - +**Returns**: -#### get\_items +- `str` - Override delimiter + + + +#### IsNewStyleOverrideSyntax ```python -def get_items() -> List[str] +@property +def IsNewStyleOverrideSyntax() -> bool ``` -Get single lines of block +New style override syntax detected **Returns**: -- `list` - single lines of comment block +- `bool` - True if new style has been detected - + -## Include Objects +#### safe\_linesplit ```python -class Include(Item) +@staticmethod +def safe_linesplit(string: str) -> List[str] ``` -Items that representing include/require statements. +Safely split an input line to chunks + +**Arguments**: + +- `string` _str_ - raw input string + + +**Returns**: - +- `list` - list of chunks of original string -#### \_\_init\_\_ + + +#### get\_items ```python -def __init__(incname: str, fileincluded: str, statement: str, *args, - **kwargs) -> None +def get_items() -> List[str] ``` -constructor +Return single items -**Arguments**: +**Returns**: -- `incname` _str_ - raw name of the include file -- `fileincluded` _str_ - path of the file included -- `statement` _str_ - either include or require +- `list` - lines of raw input - + -#### IncName +#### extract\_sub ```python -@property -def IncName() -> str +def extract_sub(name: str) -> Tuple[List[str], List[str]] ``` -Include name +Extract modifiers + +**Arguments**: + +- `name` _str_ - input string + **Returns**: -- `str` - name of the file to include/require +- `tuple` - clean variable name, modifiers, package specific modifiers - + -#### Statement +#### extract\_sub\_func ```python -@property -def Statement() -> str +def extract_sub_func(name: str) -> Tuple[List[str], List[str]] ``` -statement either include or require +Extract modifiers for functions + +**Arguments**: + +- `name` _str_ - input value + **Returns**: -- `str` - include or require +- `tuple` - clean function name, modifiers - + -#### FileIncluded +#### IsFromAppend ```python -@property -def FileIncluded() -> str +def IsFromAppend() -> bool ``` -The file included +Item originates from a bbappend **Returns**: -- `str` - path to file +- `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 - + -## Export Objects +## Variable Objects ```python -class Export(Item) +class Variable(Item) ``` -Items representing export statements in bitbake. +Items representing variables in bitbake. - + #### \_\_init\_\_ ```python -def __init__(name: str, value: str, *args, **kwargs) -> None +def __init__(name: str, value: str, operator: str, *args, **kwargs) -> None ``` constructor **Arguments**: -- `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` _str_ - Variable name +- `value` _str_ - Variable value +- `operator` _str_ - Operation performed to the variable - + -#### Name +#### VarName ```python @property -def Name() -> str +def VarName() -> str ``` -Name of the exported var +Variable name **Returns**: -- `str` - name of the exported var +- `str` - name of variable - + -#### Value +#### SubItem ```python @property -def Value() -> str +def SubItem() -> str ``` -value of the export +Variable modifiers **Returns**: -- `str` - optional value of the export +- `str` - variable modifiers like packages, machines, appends, prepends - + -#### get\_items +#### SubItems ```python -def get_items() -> Tuple[str, str] +@property +def SubItems() -> List[str] ``` -Get items +Variable modifiers list **Returns**: -- `list` - include name, include statement - - - -## Function Objects - -```python -class Function(Item) -``` - -Items representing task definitions in bitbake. +- `list` - variable modifiers list like packages, machines, appends, prepends - + -#### \_\_init\_\_ +#### VarValue ```python -def __init__(name: str, - body: str, - python: bool = False, - fakeroot: bool = False, - *args, - **kwargs) -> None +@property +def VarValue() -> str ``` -[summary] - -**Arguments**: - -- `name` _str_ - Raw function name -- `body` _str_ - Function body - +variable value -**Arguments**: +**Returns**: -- `python` _bool_ - python function according to parser (default: {False}) -- `fakeroot` _bool_ - uses fakeroot (default: {False}) +- `str` - unstripped variable value - + -#### IsPython +#### VarOp ```python @property -def IsPython() -> bool +def VarOp() -> str ``` -Is python function +Variable operation **Returns**: -- `bool` - is a python function +- `str` - operation did on the variable - + -#### IsFakeroot +#### VarNameComplete ```python @property -def IsFakeroot() -> bool +def VarNameComplete() -> str ``` -Is fakeroot function +Complete variable name included overrides and flags **Returns**: -- `bool` - is a python function +- `str` - complete variable name - + -#### FuncName +#### VarNameCompleteNoModifiers ```python @property -def FuncName() -> str +def VarNameCompleteNoModifiers() -> str ``` -Function name +Complete variable name included overrides but without modifiers like append, prepend and remove **Returns**: -- `str` - name of function +- `str` - complete variable name - + -#### FuncNameComplete +#### RawVarName ```python @property -def FuncNameComplete() -> str +def RawVarName() -> str ``` -Complete function name (including overrides) +Variable name and flags combined **Returns**: -- `str` - complete name of function +- `str` - raw representation of the variable name - + -#### SubItem +#### VarValueStripped ```python @property -def SubItem() -> str +def VarValueStripped() -> str ``` -Function modifiers +Stripped variable value **Returns**: -- `str` - function modifiers like packages, machines, appends, prepends +- `str` - stripped version of variable value - + -#### SubItems +#### IsAppend ```python -@property -def SubItems() -> List[str] +def IsAppend() -> bool ``` -Function modifiers list +Check if operation is an append **Returns**: -- `list` - function modifiers list like packages, machines, appends, prepends +- `bool` - True is variable is appended - + -#### FuncBody +#### AppendOperation ```python -@property -def FuncBody() -> str +def AppendOperation() -> List[str] ``` -Function body +Get variable modifiers **Returns**: -- `str` - function body text +- `list` - list could contain any combination of 'append', ' += ', 'prepend' and 'remove' - + -#### FuncBodyStripped +#### get\_items ```python -@property -def FuncBodyStripped() -> str +def get_items(override: str = "", versioned: bool = False) -> List[str] ``` -Stripped function body +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**: -- `str` - stripped function body text +- `list` - clean list of items in variable value - + -#### FuncBodyRaw +#### IsMultiLine -```python -@property -def FuncBodyRaw() -> str +```python +def IsMultiLine() -> bool ``` -Raw function body (including brackets) +Check if variable has a multiline assignment **Returns**: -- `str` - raw function body text +- `bool` - True if multiline - + #### GetDistroEntry @@ -1900,13 +2003,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 @@ -1914,80 +2017,61 @@ 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\_\_ ```python -def __init__(name: str, *args, **kwargs) -> None +def __init__(*args, **kwargs) -> None ``` constructor -**Arguments**: - -- `name` _str_ - Function name - - - -#### FuncName - -```python -@property -def FuncName() -> str -``` - -Function name - -**Returns**: - -- `str` - name of function - - + #### get\_items @@ -1995,28 +2079,28 @@ 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\_\_ ```python -def __init__(name: str, ident: str, value: str, varop: str, *args, +def __init__(incname: str, fileincluded: str, statement: str, *args, **kwargs) -> None ``` @@ -2024,626 +2108,626 @@ constructor **Arguments**: -- `name` _str_ - name of task to be modified -- `ident` _str_ - task flag -- `value` _str_ - value of modification -- `varop` _str_ - variable operation - - - -#### VarName - -```python -@property -def VarName() -> str -``` - -Variable name - -**Returns**: - -- `str` - name of variable - - - -#### Flag - -```python -@property -def Flag() -> str -``` - -Flag name - -**Returns**: - -- `str` - Flag name +- `incname` _str_ - raw name of the include file +- `fileincluded` _str_ - path of the file included +- `statement` _str_ - either include or require - + -#### VarOp +#### IncName ```python @property -def VarOp() -> str +def IncName() -> str ``` -Modifier operation +Include name **Returns**: -- `str` - used modifier in operation +- `str` - name of the file to include/require - + -#### Value +#### Statement ```python @property -def Value() -> str +def Statement() -> str ``` -Value +statement either include or require **Returns**: -- `str` - value set +- `str` - include or require - + -#### ValueStripped +#### FileIncluded ```python @property -def ValueStripped() -> str +def FileIncluded() -> str ``` -Value stripped of the quotes +The file included **Returns**: -- `str` - value set +- `str` - path to file - + #### 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 +## Export Objects ```python -class FunctionExports(Item) +class Export(Item) ``` -Items representing EXPORT_FUNCTIONS in bitbake. +Items representing export statements in bitbake. - + #### \_\_init\_\_ ```python -def __init__(name: str, *args, **kwargs) -> None +def __init__(name: str, value: str, *args, **kwargs) -> None ``` constructor **Arguments**: -- `name` _str_ - name of function to be exported +- `name` _str_ - variable name of the export +- `value` _str_ - (optional) value of the export + - +**Arguments**: -#### FuncNames +- `new_style_override_syntax` _bool_ - Use ':' a override delimiter (default: {False}) + + + +#### Name ```python @property -def FuncNames() -> str +def Name() -> str ``` -Function name +Name of the exported var **Returns**: -- `str` - names of exported functions +- `str` - name of the exported var - + -#### get\_items +#### Value ```python -def get_items() -> List[str] +@property +def Value() -> str ``` -Get items +value of the export **Returns**: -- `list` - function names +- `str` - optional value of the export - + -#### get\_items\_unaliased +#### get\_items ```python -def get_items_unaliased() -> List[str] +def get_items() -> Tuple[str, str] ``` -Get items with their bbclass scope names +Get items **Returns**: -- `list` - function names in the scope of a bbclass (foo becomes classname-foo in this case) +- `list` - include name, include statement - + -## TaskAdd Objects +## Function Objects ```python -class TaskAdd(Item) +class Function(Item) ``` -Items representing addtask statements in bitbake. +Items representing task definitions in bitbake. - + #### \_\_init\_\_ ```python def __init__(name: str, - before: str = "", - after: str = "", - comment: str = "", + body: str, + python: bool = False, + fakeroot: bool = False, *args, **kwargs) -> None ``` -constructor +[summary] **Arguments**: -- `name` _str_ - name of task to be executed +- `name` _str_ - Raw function name +- `body` _str_ - Function body **Arguments**: -- `before` _str_ - before statement (default: {""}) -- `after` _str_ - after statement (default: {""}) -- `comment` _str_ - optional comment (default: {""}) - - - -#### FuncName - -```python -@property -def FuncName() -> str -``` - -Function name - -**Returns**: - -- `str` - name of function +- `python` _bool_ - python function according to parser (default: {False}) +- `fakeroot` _bool_ - uses fakeroot (default: {False}) - + -#### Before +#### IsPython ```python @property -def Before() -> List[str] +def IsPython() -> bool ``` -Tasks executed before +Is python function **Returns**: -- `list` - tasks to be executed before +- `bool` - is a python function - + -#### After +#### IsFakeroot ```python @property -def After() -> List[str] +def IsFakeroot() -> bool ``` -Tasks executed after +Is fakeroot function **Returns**: -- `list` - tasks to be executed after +- `bool` - is a python function - + -#### Comment +#### FuncName ```python @property -def Comment() -> str +def FuncName() -> str ``` -Comment +Function name **Returns**: -- `str` - comment if any +- `str` - name of function - + -#### get\_items +#### FuncNameComplete ```python -def get_items() -> List[str] +@property +def FuncNameComplete() -> str ``` -get items +Complete function name (including overrides) **Returns**: -- `list` - function name, all before statements, all after statements +- `str` - complete name of function - + -## TaskDel Objects +#### SubItem ```python -class TaskDel(Item) +@property +def SubItem() -> str ``` -Items representing deltask statements in bitbake. +Function modifiers - +**Returns**: -#### \_\_init\_\_ +- `str` - function modifiers like packages, machines, appends, prepends + + + +#### SubItems ```python -def __init__(name: str, comment: str, *args, **kwargs) -> None +@property +def SubItems() -> List[str] ``` -constructor +Function modifiers list -**Arguments**: +**Returns**: -- `name` _str_ - name of task to be executed -- `comment` _str_ - optional comment +- `list` - function modifiers list like packages, machines, appends, prepends - + -#### FuncName +#### FuncBody ```python @property -def FuncName() -> str +def FuncBody() -> str ``` -Function name +Function body **Returns**: -- `str` - name of function +- `str` - function body text - + -#### Comment +#### FuncBodyStripped ```python @property -def Comment() -> str +def FuncBodyStripped() -> str ``` -Comment +Stripped function body **Returns**: -- `str` - comment if any +- `str` - stripped function body text - + -#### get\_items +#### FuncBodyRaw ```python -def get_items() -> List[str] +@property +def FuncBodyRaw() -> str ``` -get items +Raw function body (including brackets) **Returns**: -- `list` - function name +- `str` - raw function body text - + -## MissingFile Objects +#### GetDistroEntry ```python -class MissingFile(Item) +def GetDistroEntry() -> str ``` -Items representing missing files found while parsing. +Get distro specific modifiers - +**Returns**: -#### \_\_init\_\_ +- `str` - distro specific modifier or "" + + + +#### GetMachineEntry ```python -def __init__(filename: str, statement: str, *args, **kwargs) -> None +def GetMachineEntry() -> str ``` -constructor +Get machine specific modifiers -**Arguments**: +**Returns**: -- `filename` _str_ - filename of the file that can't be found -- `statement` _str_ - either include or require +- `str` - machine specific modifier or "" - + -#### Filename +#### IsAppend ```python -@property -def Filename() -> str +def IsAppend() -> bool ``` -Filename of the file missing +Return if function appends another function **Returns**: -- `str` - filename that can't be resolved +- `bool` - True is append or prepend operation - + -#### Statement +#### get\_items ```python -@property -def Statement() -> str +def get_items() -> List[str] ``` -statement either include or require +Get items of function body **Returns**: -- `str` - include or require +- `list` - single lines of function body - + -## AddPylib Objects +## PythonBlock Objects ```python -class AddPylib(Item) +class PythonBlock(Item) ``` -Items representing addpylib statements in bitbake. +Items representing python functions in bitbake. - + #### \_\_init\_\_ ```python -def __init__(path: str, namespace: str, *args, **kwargs) -> None +def __init__(name: str, *args, **kwargs) -> None ``` constructor **Arguments**: -- `path` _str_ - path to the namespace -- `namespace` _str_ - namespace name +- `name` _str_ - Function name - + -#### Path +#### FuncName ```python @property -def Path() -> str +def FuncName() -> str ``` -Path of the library addition +Function name **Returns**: -- `str` - path of the library addition +- `str` - name of function - + -#### Namespace +#### get\_items ```python -@property -def Namespace() -> str +def get_items() -> List[str] ``` -Namespace of the addition +Get lines of function body **Returns**: -- `str` - Namespace of the addition +- `list` - lines of function body - + -#### get\_items +## FlagAssignment Objects ```python -def get_items() -> Tuple[str, str] +class FlagAssignment(Item) ``` -Get items +Items representing flag assignments in bitbake. -**Returns**: + -- `list` - library path, library namespace +#### \_\_init\_\_ - +```python +def __init__(name: str, ident: str, value: str, varop: str, *args, + **kwargs) -> None +``` -## AddFragements Objects +constructor + +**Arguments**: + +- `name` _str_ - name of task to be modified +- `ident` _str_ - task flag +- `value` _str_ - value of modification +- `varop` _str_ - variable operation + + + +#### VarName ```python -class AddFragements(Item) +@property +def VarName() -> str ``` -Items representing addfragment statements in bitbake. +Variable name - +**Returns**: -#### \_\_init\_\_ +- `str` - name of variable + + + +#### Flag ```python -def __init__(path: str, variable: str, flagged: str, *args, **kwargs) -> None +@property +def Flag() -> str ``` -constructor +Flag name -**Arguments**: +**Returns**: -- `path` _str_ - path to the namespace -- `variable` _str_ - variable name -- `flagged` _str_ - flagged variable name(s) +- `str` - Flag name - + -#### Path +#### VarOp ```python @property -def Path() -> str +def VarOp() -> str ``` -Path of the fragment +Modifier operation **Returns**: -- `str` - path of the fragment +- `str` - used modifier in operation - + -#### Variable +#### Value ```python @property -def Variable() -> str +def Value() -> str ``` -Variable of the fragment +Value **Returns**: -- `str` - Variable of the fragment +- `str` - value set - + -#### Flagged +#### ValueStripped ```python @property -def Flagged() -> str +def ValueStripped() -> str ``` -Flagged variables of the fragment +Value stripped of the quotes **Returns**: -- `str` - Flagged variables of the fragment +- `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, variable, flagged +- `list` - variable name, flag, variable operation, modification value - + -## IncludeAll Objects +## FunctionExports Objects ```python -class IncludeAll(Item) +class FunctionExports(Item) ``` -Items representing include_all statements in bitbake. +Items representing EXPORT_FUNCTIONS in bitbake. - + #### \_\_init\_\_ ```python -def __init__(file: str, *args, **kwargs) -> None +def __init__(name: str, *args, **kwargs) -> None ``` constructor **Arguments**: -- `file` _str_ - path to the file +- `name` _str_ - name of function to be exported - + -#### File +#### FuncNames ```python @property -def File() -> str +def FuncNames() -> str ``` -Path to include +Function name **Returns**: -- `str` - Path to include +- `str` - names of exported functions - + #### get\_items ```python -def get_items() -> Tuple[str, str] +def get_items() -> List[str] ``` Get items **Returns**: -- `list` - file +- `list` - function names - + -## Inherit Objects +#### get\_items\_unaliased ```python -class Inherit(Item) +def get_items_unaliased() -> List[str] ``` -Items that representing inherit(_defer) statements. +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 + +```python +class TaskAdd(Item) +``` + +Items representing addtask statements in bitbake. + + #### \_\_init\_\_ ```python -def __init__(statement: str, - classes: str, - inherit_file_paths: Set[str] = None, +def __init__(name: str, + before: str = "", + after: str = "", + comment: str = "", *args, **kwargs) -> None ``` @@ -2652,64 +2736,76 @@ constructor **Arguments**: -- `class` _str_ - class code to inherit -- `statement` _str_ - inherit statement (INHERIT, inherit or inherit_defer) +- `name` _str_ - name of task to be executed **Arguments**: -- `inherit_file_paths` _Set[str]_ - Paths of the identified inherited classes +- `before` _str_ - before statement (default: {""}) +- `after` _str_ - after statement (default: {""}) +- `comment` _str_ - optional comment (default: {""}) - + -#### Class +#### FuncName ```python @property -def Class() -> str +def FuncName() -> str ``` -Class(es) to inherit +Function name **Returns**: -- `str` - class(es) to inherit +- `str` - name of function - + -#### Statement +#### Before ```python @property -def Statement() -> str +def Before() -> List[str] ``` -inherit statement +Tasks executed before **Returns**: -- `str` - inherit or inherit_defer +- `list` - tasks to be executed before - + -#### FilePaths +#### After ```python @property -def FilePaths() -> Set[str] +def After() -> List[str] ``` -File paths to identified bbclasses +Tasks executed after -As some classes might not be resolvable in the current context -the order doesn't necessarily reflect the order of the -inherit statements +**Returns**: + +- `list` - tasks to be executed after + + + +#### Comment + +```python +@property +def Comment() -> str +``` + +Comment **Returns**: -- `Set[str]` - File paths to identified bbclasses +- `str` - comment if any - + #### get\_items @@ -2717,72 +2813,68 @@ inherit statements def get_items() -> List[str] ``` -Get items +get items **Returns**: -- `list` - parsed Class items +- `list` - function name, all before statements, all after statements - + -## Unset Objects +## TaskDel Objects ```python -class Unset(Item) +class TaskDel(Item) ``` -Items representing unset statements in bitbake. +Items representing deltask statements in bitbake. - + #### \_\_init\_\_ ```python -def __init__(name: str, flag: str = "", *args, **kwargs) -> None +def __init__(name: str, comment: str, *args, **kwargs) -> None ``` constructor **Arguments**: -- `name` _str_ - name of variable to be unset - - -**Arguments**: - -- `flag` _str_ - Flag to unset +- `name` _str_ - name of task to be executed +- `comment` _str_ - optional comment - + -#### 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 +#### Comment ```python @property -def Flag() -> str +def Comment() -> str ``` -Variable flag +Comment **Returns**: -- `str` - name of the variable flag +- `str` - comment if any - + #### get\_items @@ -2794,613 +2886,588 @@ get items **Returns**: -- `list` - variable name, variable flag - - - -# oelint\_parser.rpl\_regex - - - -## RegexRpl Objects - -```python -class RegexRpl() -``` - -Safe regex replacements +- `list` - function name - + -#### search +## MissingFile Objects ```python -@staticmethod -def search(pattern: str, - string: str, - timeout: int = 5, - default: object = None, - **kwargs) -> Union[Match, None] +class MissingFile(Item) ``` -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 +Items representing missing files found while parsing. - + -#### split +#### \_\_init\_\_ ```python -@staticmethod -def split(pattern: str, - string: str, - timeout: int = 5, - default: object = None, - **kwargs) -> List[str] +def __init__(filename: str, statement: str, *args, **kwargs) -> None ``` -replacement for re.split +constructor **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 +- `filename` _str_ - filename of the file that can't be found +- `statement` _str_ - either include or require - + -#### match +#### Filename ```python -@staticmethod -def match(pattern: str, - string: str, - timeout: int = 5, - default: object = None, - **kwargs) -> Union[Match, None] +@property +def Filename() -> str ``` -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. - +Filename of the file missing **Returns**: -- `Match` - Match object or None +- `str` - filename that can't be resolved - + -#### sub +#### Statement ```python -@staticmethod -def sub(pattern: str, - repl: str, - string: str, - timeout: int = 5, - default: str = '', - **kwargs) -> str +@property +def Statement() -> str ``` -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 ''. - +statement either include or require **Returns**: -- `str` - string +- `str` - include or require - + -#### finditer +## AddPylib Objects ```python -@staticmethod -def finditer(pattern: str, - string: str, - timeout: int = 5, - default: object = None, - **kwargs) -> Scanner +class AddPylib(Item) ``` -replacement for re.finditer +Items representing addpylib statements in bitbake. -**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. - +#### \_\_init\_\_ -**Returns**: +```python +def __init__(path: str, namespace: str, *args, **kwargs) -> None +``` -- `Scanner` - Scanner object or None +constructor - +**Arguments**: -# oelint\_parser.constants +- `path` _str_ - path to the namespace +- `namespace` _str_ - namespace name - + -## Constants Objects +#### Path ```python -class Constants() +@property +def Path() -> str ``` -Interface for constants +Path of the library addition - +**Returns**: -#### GetByPath +- `str` - path of the library addition -```python -def GetByPath(path: str) -> Union[Dict, List] -``` + -Get constant from path +#### Namespace -**Arguments**: +```python +@property +def Namespace() -> str +``` -- `path` _str_ - / joined path in the constant structure - +Namespace of the addition **Returns**: - Union[Dict, List]: Item in structure or empty dictionary +- `str` - Namespace of the addition - + -#### AddConstants +#### get\_items ```python -def AddConstants(_dict: dict) -> None +def get_items() -> Tuple[str, str] ``` -Add constants to the existing +Get items -**Arguments**: +**Returns**: -- `dict` _dict_ - constant dictionary to add +- `list` - library path, library namespace - + -#### RemoveConstants +## AddFragements Objects ```python -def RemoveConstants(_dict: dict) -> None +class AddFragements(Item) ``` -Remove constants from the existing - -**Arguments**: - -- `dict` _dict_ - constant dictionary to remove +Items representing addfragment statements in bitbake. - + -#### OverrideConstants +#### \_\_init\_\_ ```python -def OverrideConstants(_dict: dict) -> None +def __init__(path: str, variable: str, flagged: str, *args, **kwargs) -> None ``` -Override constants in the existing db +constructor **Arguments**: -- `dict` _dict]_ - constant dictionary with override values +- `path` _str_ - path to the namespace +- `variable` _str_ - variable name +- `flagged` _str_ - flagged variable name(s) - + -#### FunctionsKnown +#### Path ```python @property -def FunctionsKnown() -> List[str] +def Path() -> str ``` -Return known functions +Path of the fragment **Returns**: -- `list` - list of known functions +- `str` - path of the fragment - + -#### FunctionsOrder +#### Variable ```python @property -def FunctionsOrder() -> List[str] +def Variable() -> str ``` -Return function order +Variable of the fragment **Returns**: -- `list` - List of functions to order in their designated order +- `str` - Variable of the fragment - + -#### MirrorsKnown +#### Flagged ```python @property -def MirrorsKnown() -> Dict[str, str] +def Flagged() -> str ``` -Return known mirrors and their replacements +Flagged variables of the fragment **Returns**: -- `dict` - Dict of known mirrors and their replacements +- `str` - Flagged variables of the fragment - + -#### VariablesKnown +#### get\_items ```python -@property -def VariablesKnown() -> List[str] +def get_items() -> Tuple[str, str] ``` -Known variables +Get items **Returns**: -- `list` - List of known variables +- `list` - library path, variable, flagged - + -#### DistrosKnown +## IncludeAll Objects ```python -@property -def DistrosKnown() -> List[str] +class IncludeAll(Item) ``` -Known distros +Items representing include_all statements in bitbake. -**Returns**: + -- `list` - List of known distros +#### \_\_init\_\_ - +```python +def __init__(file: str, *args, **kwargs) -> None +``` -#### MachinesKnown +constructor + +**Arguments**: + +- `file` _str_ - path to the file + + + +#### File ```python @property -def MachinesKnown() -> List[str] +def File() -> str ``` -Known machines +Path to include **Returns**: -- `list` - List of known machines +- `str` - Path to include - + -#### ImagesClasses +#### get\_items ```python -@property -def ImagesClasses() -> List[str] +def get_items() -> Tuple[str, str] ``` -Classes that are used in images +Get items **Returns**: -- `list` - Classes that are used in images +- `list` - file - + -#### ImagesVariables +## Inherit Objects + +```python +class Inherit(Item) +``` + +Items that representing inherit(_defer) statements. + + + +#### \_\_init\_\_ + +```python +def __init__(statement: str, + classes: str, + inherit_file_paths: Set[str] = None, + *args, + **kwargs) -> None +``` + +constructor + +**Arguments**: + +- `class` _str_ - class code to inherit +- `statement` _str_ - inherit statement (INHERIT, inherit or inherit_defer) + + +**Arguments**: + +- `inherit_file_paths` _Set[str]_ - Paths of the identified inherited classes + + + +#### Class ```python @property -def ImagesVariables() -> List[str] +def Class() -> str ``` -Variables that are used in images +Class(es) to inherit **Returns**: -- `list` - Variables that are used in images +- `str` - class(es) to inherit - + -#### SetsBase +#### Statement ```python @property -def SetsBase() -> Dict[str, str] +def Statement() -> str ``` -Base variable set +inherit statement **Returns**: -- `dict` - dictionary with base variable set - - - -# oelint\_parser.inlinerep +- `str` - inherit or inherit_defer - + -#### bb\_utils\_filter +#### FilePaths ```python -def bb_utils_filter(_in: str, negative_clause: bool = False) -> str +@property +def FilePaths() -> Set[str] ``` -bb.utils.filter 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 +#### get\_items ```python -def bb_utils_contains(_in: str, negative_clause: bool = False) -> str +def get_items() -> List[str] ``` -bb.utils.contains emulation +Get items -**Arguments**: +**Returns**: -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch - +- `list` - parsed Class items -**Returns**: + -- `str` - True argument of the conditional or None if not applicable +## Unset Objects - +```python +class Unset(Item) +``` -#### bb\_utils\_contains\_any +Items representing unset statements in bitbake. + + + +#### \_\_init\_\_ ```python -def bb_utils_contains_any(_in: str, negative_clause: bool = False) -> str +def __init__(name: str, flag: str = "", *args, **kwargs) -> None ``` -bb.utils.contains_any emulation +constructor **Arguments**: -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch +- `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 - + -#### oe\_utils\_conditional +#### VarName ```python -def oe_utils_conditional(_in: str, negative_clause: bool = False) -> str +@property +def VarName() -> str ``` -oe.utils.conditional 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\_ifelse +#### Flag ```python -def oe_utils_ifelse(_in: str, negative_clause: bool = False) -> str +@property +def Flag() -> str ``` -oe.utils.ifelse 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\_any\_distro\_features +#### get\_items ```python -def oe_utils_any_distro_features(_in: str, - negative_clause: bool = False) -> str +def get_items() -> List[str] ``` -oe.utils.any_distro_features 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.rpl\_regex - + -#### oe\_utils\_all\_distro\_features +## RegexRpl Objects ```python -def oe_utils_all_distro_features(_in: str, - negative_clause: bool = False) -> str +class RegexRpl() ``` -oe.utils.all_distro_features emulation - -**Arguments**: - -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch - - -**Returns**: - -- `str` - True argument of the conditional or None if not applicable +Safe regex replacements - + -#### oe\_utils\_vartrue +#### search ```python -def oe_utils_vartrue(_in: str, negative_clause: bool = False) -> str +@staticmethod +def search(pattern: str, + string: str, + timeout: int = 5, + default: object = None, + **kwargs) -> Union[Match, None] ``` -oe.utils.vartrue emulation +replacement for re.search **Arguments**: -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch +- `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` - True argument of the conditional or None if not applicable +- `Match` - Match object or None - + -#### oe\_utils\_less\_or\_equal +#### split ```python -def oe_utils_less_or_equal(_in: str, negative_clause: bool = False) -> str +@staticmethod +def split(pattern: str, + string: str, + timeout: int = 5, + default: object = None, + **kwargs) -> List[str] ``` -oe.utils.less_or_equal emulation +replacement for re.split **Arguments**: -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch +- `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` - True argument of the conditional or None if not applicable +- `list` - list object or None - + -#### oe\_utils\_version\_less\_or\_equal +#### match ```python -def oe_utils_version_less_or_equal(_in: str, - negative_clause: bool = False) -> str +@staticmethod +def match(pattern: str, + string: str, + timeout: int = 5, + default: object = None, + **kwargs) -> Union[Match, None] ``` -oe.utils.version_less_or_equal emulation +replacement for re.match **Arguments**: -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch +- `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` - True argument of the conditional or None if not applicable +- `Match` - Match object or None - + -#### oe\_utils\_both\_contain +#### sub ```python -def oe_utils_both_contain(_in: str, negative_clause: bool = False) -> str +@staticmethod +def sub(pattern: str, + repl: str, + string: str, + timeout: int = 5, + default: str = '', + **kwargs) -> str ``` -oe.utils.both_contain emulation +replacement for re.sub **Arguments**: -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch +- `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` - True argument of the conditional or None if not applicable +- `str` - string - + -#### inlinerep +#### finditer ```python -def inlinerep(_in: str, negative_clause: bool = False) -> str +@staticmethod +def finditer(pattern: str, + string: str, + timeout: int = 5, + default: object = None, + **kwargs) -> Scanner ``` -Replaces inline code expressions +replacement for re.finditer **Arguments**: -- `_in` _str_ - Input string -- `negative_clause` _bool_ - return negative branch +- `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` - Expanded string or None, if not applicable +- `Scanner` - Scanner object or None diff --git a/oelint_parser/cls_stash.py b/oelint_parser/cls_stash.py index e0eaf07..73a9f53 100644 --- a/oelint_parser/cls_stash.py +++ b/oelint_parser/cls_stash.py @@ -18,7 +18,10 @@ __class_id_native_regex__ = regex.compile(r"^(.+)(-native)$") __class_id_cross_regex__ = regex.compile(r"^(.+)(-cross)$") __variable_pattern_regex__ = regex.compile(r"\$\{(.+?)\}") -__variable_pattern_regex_2__ = regex.compile(r"d.getVar\(.(.+?).(True|False|,|\s+)*\)") +__variable_pattern_regex_2__ = regex.compile( + r"d.getVar\(.(.+?).(True|False|,|\s+)*\)") +__oe_utils_read_file_regex__ = regex.compile( + r"\{@\s*(.*)oe\.utils\.read_file\((?P.*)\)\}") class Stash(): @@ -196,7 +199,8 @@ def AddFile(self, _file: str, lineOffset: int = 0, forcedLink: str = None) -> Li if item.Origin not in self.__map: self.__map[item.Origin] = [] self.__map[item.Origin].append(_file) - _maxline = max(x.Line for x in self.__list if x.Origin == item.Origin) + _maxline = max( + x.Line for x in self.__list if x.Origin == item.Origin) for r in res: # pretend that we are adding the file to the end of the original r.Line += _maxline @@ -294,10 +298,12 @@ def GetLoneAppends(self) -> List[str]: list -- list of bbappend without a matching bb """ __linked_appends = set() - __appends = {x.Origin for x in self.__list if x.Origin.endswith('.bbappend')} + __appends = { + x.Origin for x in self.__list if x.Origin.endswith('.bbappend')} for k, v in self.__map.items(): if k.endswith('.bb'): - __linked_appends.update(x for x in v if x.endswith('.bbappend')) + __linked_appends.update( + x for x in v if x.endswith('.bbappend')) return sorted({x for x in __appends if x not in __linked_appends}) @functools.cache # noqa: B019 @@ -343,7 +349,8 @@ def _filter(x: Item, attname: Iterable[str], attvalue: Iterable[str]) -> bool: attr_ = x.GetAttributes() res = False for name in attname: - res |= name in attr_ and (not attvalue or any(x == attr_.get(name) for x in attvalue)) + res |= name in attr_ and (not attvalue or any( + x == attr_.get(name) for x in attvalue)) return res return [x for x in items if _filter(x, attname, attvalue)] @@ -389,11 +396,14 @@ def Reduce(self, if not isinstance(attributeValue, (list, set, tuple)): attributeValue = [attributeValue] if attributeValue else [] if filename: - in_list = self.__get_items_by_file(tuple(in_list), filename, nolink=nolink) + in_list = self.__get_items_by_file( + tuple(in_list), filename, nolink=nolink) if classifier: - in_list = self.__get_items_by_classifier(tuple(in_list), tuple(classifier)) + in_list = self.__get_items_by_classifier( + tuple(in_list), tuple(classifier)) if attribute: - in_list = self.__get_items_by_attribute(tuple(in_list), tuple(attribute), tuple(attributeValue)) + in_list = self.__get_items_by_attribute( + tuple(in_list), tuple(attribute), tuple(attributeValue)) return sorted(set(in_list), key=lambda x: x.Line) def GetItemsFor(self, @@ -444,7 +454,14 @@ def ExpandVar(self, attributeValue=attributeValue, nolink=nolink) - _res += self.GetItemsFor(filename=filename, classifier=Unset.CLASSIFIER) + _res += self.GetItemsFor(filename=filename, + classifier=Unset.CLASSIFIER) + + if filename is None: + if _res: + filename = _res[0].Origin + else: + return {} _exp = { "PN": self.GuessRecipeName(filename), "PV": self.GuessRecipeVersion(filename), @@ -668,7 +685,8 @@ def GuessBaseRecipeName(self, _file: str) -> str: Returns: str -- recipe name """ - tmp_ = RegexRpl.sub(__class_id_regex__, r"\2", self.GuessRecipeName(_file)) + tmp_ = RegexRpl.sub(__class_id_regex__, r"\2", + self.GuessRecipeName(_file)) tmp_ = RegexRpl.sub(__class_id_native_regex__, r"\1", tmp_) tmp_ = RegexRpl.sub(__class_id_cross_regex__, r"\1", tmp_) return tmp_ @@ -711,9 +729,10 @@ def ExpandTerm(self, _file: str, value: str, spare: List[str] = None, seen: List if INLINE_BLOCK in value and objref is not None: value = self._ReverseInlineBlock(objref) res = str(value) - for m in list(RegexRpl.finditer(__variable_pattern_regex__, value)) + list(RegexRpl.finditer(__variable_pattern_regex_2__, value)): + + def _expand(res, _file, m, quote: str = ''): if m.group(1) in spare: - continue + return res _comp = [x for x in self.GetItemsFor(filename=_file, classifier=Variable.CLASSIFIER, attribute=Variable.ATTR_VAR, attributeValue=m.group(1)) if not x.AppendOperation()] if any(_comp): @@ -733,7 +752,8 @@ def ExpandTerm(self, _file: str, value: str, spare: List[str] = None, seen: List _rpl = seen[m.group(1)] elif m.group(1) in baseset: seen[m.group(1)] = "" - _rpl = self.ExpandTerm(_file, baseset[m.group(1)], seen=seen) + _rpl = self.ExpandTerm( + _file, baseset[m.group(1)], seen=seen) seen[m.group(1)] = _rpl else: _rpl = m.group(1) @@ -745,9 +765,23 @@ def ExpandTerm(self, _file: str, value: str, spare: List[str] = None, seen: List elif m.group(1) in ["PV"]: res = res.replace(m.group(0), self.GuessRecipeVersion(_file)) elif m.group(1) in ["FILE"]: - res = res.replace(m.group(0), f'"{_file}"') - elif not any(_comp): - continue + res = res.replace(m.group(0), f'{quote}{_file}{quote}') + elif m.group(1) in ["THISDIR"]: + res = res.replace( + m.group(0), f'{quote}{os.path.dirname(_file)}{quote}') + return res + for m in list(RegexRpl.finditer(__variable_pattern_regex__, value)): + res = _expand(res, _file, m) + for m in list(RegexRpl.finditer(__variable_pattern_regex_2__, value)): + res = _expand(res, _file, m, quote='"') + for m in list(RegexRpl.finditer(__oe_utils_read_file_regex__, value)): + try: + _fullpath = self.ExpandTerm(_file, m.group( + "file"), spare=spare, seen=seen).strip("'\"") + with open(_fullpath) as i: + res = i.read() + except (FileNotFoundError, PermissionError, NotADirectoryError): + res = '' return res @functools.cache # noqa: B019 @@ -799,7 +833,8 @@ def GetValidNamedResources(self, _file: str) -> List[str]: for name in [x for x in self.SafeLineSplit(item.VarValueStripped) if x]: _url = self.GetScrComponents(name) if "name" in _url["options"]: - res.add(_url["options"]["name"].replace("${PN}", _recipe_name)) + res.add(_url["options"]["name"].replace( + "${PN}", _recipe_name)) return res @functools.cache # noqa: B019 @@ -814,9 +849,11 @@ def IsImage(self, _file: str) -> bool: """ res = False - _inherits = self.GetItemsFor(filename=_file, classifier=Inherit.CLASSIFIER) + _inherits = self.GetItemsFor( + filename=_file, classifier=Inherit.CLASSIFIER) for item in _inherits: - res |= any(True for x in item.get_items() if x in CONSTANTS.ImagesClasses) + res |= any(True for x in item.get_items() + if x in CONSTANTS.ImagesClasses) for _var in CONSTANTS.ImagesVariables: res |= any(self.GetItemsFor(filename=_file, classifier=Variable.CLASSIFIER, @@ -834,5 +871,6 @@ def IsPackageGroup(self, _file: str) -> bool: Returns: bool -- True if _file is a packagegroup recipe """ - _inherits = self.GetItemsFor(filename=_file, classifier=Inherit.CLASSIFIER) + _inherits = self.GetItemsFor( + filename=_file, classifier=Inherit.CLASSIFIER) return any(x for x in _inherits if "packagegroup" in x.get_items()) diff --git a/oelint_parser/constants.py b/oelint_parser/constants.py index fb98253..7b0bb28 100644 --- a/oelint_parser/constants.py +++ b/oelint_parser/constants.py @@ -10,8 +10,13 @@ class Constants(): """Interface for constants""" - def __init__(self) -> None: - self.__db = self.__load_db(DEFAULT_DB) + def __init__(self, file_: str = DEFAULT_DB) -> None: + """Constants interface + + Args: + file_ (str, optional): File to load. Defaults to DEFAULT_DB. + """ + self.__db = self.__load_db(file_) def __load_db(self, path: str) -> dict: try: diff --git a/oelint_parser/inlinerep.py b/oelint_parser/inlinerep.py index aeea181..92ed7ed 100644 --- a/oelint_parser/inlinerep.py +++ b/oelint_parser/inlinerep.py @@ -2,24 +2,29 @@ from oelint_parser.rpl_regex import RegexRpl -__bb_utils_filter_regex__ = regex.compile(r'(.*)bb\.utils\.filter\(\s*(?P.*?),.*?,.*?\)') +__bb_utils_filter_regex__ = regex.compile( + r'(.*)bb\.utils\.filter\(\s*(?P.*?),.*?,.*?\)') __bb_utils_contains_regex__ = regex.compile( r"(.*)bb\.utils\.contains\(.*?,\s*.*?,\s*(?P.*?),\s*(?P.*?),\s*.\)") __bb_utils_contains_any_regex__ = regex.compile( r"(.*)bb\.utils\.contains_any\(.*?,\s*.*?,\s*(?P.*?),\s*(?P.*?),\s*.\)") __oe_utils_conditional_regex__ = regex.compile( r"(.*)oe\.utils\.conditional\(.*?,\s*.*?,\s*(?P.*?),\s*(?P.*?),\s*.*?\)") -__oe_utils_ifelse_regex__ = regex.compile(r"(.*)oe\.utils\.ifelse\(.*?,\s*(?P.*?),\s*(?P.*?)\)") +__oe_utils_ifelse_regex__ = regex.compile( + r"(.*)oe\.utils\.ifelse\(.*?,\s*(?P.*?),\s*(?P.*?)\)") __oe_utils_any_distro_features_regex__ = regex.compile( r"(.*)oe\.utils\.any_distro_features\(.*?,\s*(?P.*?)(,\s*(?P.*?)(,\s*(?P.*?))*)*\)") __oe_utils_all_distro_features_regex__ = regex.compile( r"(.*)oe\.utils\.all_distro_features\(.*?,\s*(?P.*?)(,\s*(?P.*?)(,\s*(?P.*?))*)*\)") -__oe_utils_vartrue_regex__ = regex.compile(r"(.*)oe\.utils\.vartrue\(.*?,\s*(?P.*?),\s*(?P.*?),.*?\)") +__oe_utils_vartrue_regex__ = regex.compile( + r"(.*)oe\.utils\.vartrue\(.*?,\s*(?P.*?),\s*(?P.*?),.*?\)") __oe_utils_less_or_equal_regex__ = regex.compile( r"(.*)oe\.utils\.less_or_equal\(.*?,\s*.*?,\s*(?P.*?),\s*(?P.*?),.*?\)") __oe_utils_version_less_or_equal_regex__ = regex.compile( r"(.*)oe\.utils\.version_less_or_equal\(.*?,\s*.*?,\s*(?P.*?),\s*(?P.*?),.*?\)") -__oe_utils_both_contain_regex__ = regex.compile(r"(.*)oe\.utils\.both_contain\(.*?,\s*.*?,\s*(?P.*?),.*?\)") +__oe_utils_both_contain_regex__ = regex.compile( + r"(.*)oe\.utils\.both_contain\(.*?,\s*.*?,\s*(?P.*?),.*?\)") +__d_getvar_regex__ = regex.compile(r'\s*d\.getVar\(\s*(?P.*?)\s*\)') def bb_utils_filter(_in: str, negative_clause: bool = False) -> str: @@ -246,6 +251,23 @@ def oe_utils_both_contain(_in: str, negative_clause: bool = False) -> str: return None +def d_getvar(_in: str) -> str: + """d.getVar emulation in inline block + + Args: + _in (str): Input string + + Returns: + str: Variable reference if found + """ + if 'd.getVar' not in _in: + return None + m = RegexRpl.match(__d_getvar_regex__, _in) + if m: + return '${' + m.group("val").strip("\"'") + '}' + return None + + def inlinerep(_in: str, negative_clause: bool = False) -> str: """Replaces inline code expressions @@ -269,6 +291,7 @@ def inlinerep(_in: str, negative_clause: bool = False) -> str: oe_utils_less_or_equal(_clean_in, negative_clause), oe_utils_vartrue(_clean_in, negative_clause), oe_utils_version_less_or_equal(_clean_in, negative_clause), + d_getvar(_clean_in), ]: if x is not None: return x diff --git a/tests/test_expand.py b/tests/test_expand.py index d31feb1..1f6353c 100644 --- a/tests/test_expand.py +++ b/tests/test_expand.py @@ -39,7 +39,65 @@ def test_expand_ref_other(self): attributeValue="A") self.assertTrue(_stash, msg="Stash has no items") for item in _stash[0].get_items(): - self.assertEqual(self.__stash.ExpandTerm(_file, item), '${@some.function(d, foo)}/abc') + self.assertEqual(self.__stash.ExpandTerm( + _file, item), '${@some.function(d, foo)}/abc') + + def test_expand_thisdir(self): + from oelint_parser.cls_stash import Stash + from oelint_parser.cls_item import Variable + self.__stash = Stash() + _file = self._create_tempfile( + ''' + A = "${THISDIR}" + ''') + self.__stash.AddFile(_file) + self.__stash.Finalize() + + _stash: list[Variable] = self.__stash.GetItemsFor(classifier=Variable.CLASSIFIER, + attribute=Variable.ATTR_VAR, + attributeValue="A") + self.assertTrue(_stash, msg="Stash has no items") + for item in _stash[0].get_items(): + self.assertEqual(self.__stash.ExpandTerm( + _file, item), os.path.dirname(_file)) + + def test_expand_thisdir_py(self): + from oelint_parser.cls_stash import Stash + from oelint_parser.cls_item import Variable + self.__stash = Stash() + _file = self._create_tempfile( + ''' + A = "${@d.getVar('THISDIR')}" + ''') + self.__stash.AddFile(_file) + self.__stash.Finalize() + + _stash: list[Variable] = self.__stash.GetItemsFor(classifier=Variable.CLASSIFIER, + attribute=Variable.ATTR_VAR, + attributeValue="A") + self.assertTrue(_stash, msg="Stash has no items") + for item in _stash[0].get_items(): + self.assertEqual(self.__stash.ExpandTerm( + _file, item), os.path.dirname(_file)) + + def test_expand_readfile(self): + from oelint_parser.cls_stash import Stash + from oelint_parser.cls_item import Variable + self.__stash = Stash() + _cnt = textwrap.dedent(''' + A = "${@oe.utils.read_file('${FILE}')}" + ''') + _file = self._create_tempfile(_cnt) + self.__stash.AddFile(_file) + self.__stash.Finalize() + + _stash: list[Variable] = self.__stash.GetItemsFor(classifier=Variable.CLASSIFIER, + attribute=Variable.ATTR_VAR, + attributeValue="A") + self.assertTrue(_stash, msg="Stash has no items") + for item in _stash: + self.assertEqual(self.__stash.ExpandTerm( + _file, item.VarValue, objref=item).strip(), _cnt.strip()) def test_expand_inline_block(self): from oelint_parser.cls_stash import Stash @@ -57,7 +115,8 @@ def test_expand_inline_block(self): attributeValue="A") self.assertTrue(_stash, msg="Stash has no items") for item in _stash[0].get_items(): - self.assertEqual(self.__stash.ExpandTerm(_file, item, objref=_stash[0]), '${@some.function(d, foo)}/abc') + self.assertEqual(self.__stash.ExpandTerm( + _file, item, objref=_stash[0]), '${@some.function(d, foo)}/abc') def test_expand_multiple_inline_block(self): from oelint_parser.cls_stash import Stash @@ -96,7 +155,8 @@ def test_expand_nested_ref(self): attributeValue="A") self.assertTrue(_stash, msg="Stash has no items") for item in _stash[0].get_items(): - self.assertEqual(self.__stash.ExpandTerm(_file, item, objref=_stash[0]), '${@some.function(d, foo)}/200/abc') + self.assertEqual(self.__stash.ExpandTerm( + _file, item, objref=_stash[0]), '${@some.function(d, foo)}/200/abc') def test_expand_nested_python_ref(self): from oelint_parser.cls_stash import Stash @@ -116,7 +176,8 @@ def test_expand_nested_python_ref(self): attributeValue="A") self.assertTrue(_stash, msg="Stash has no items") for item in _stash[0].get_items(): - self.assertEqual(self.__stash.ExpandTerm(_file, item, objref=_stash[0]), '${@some.function(d, 200)}/abc') + self.assertEqual(self.__stash.ExpandTerm( + _file, item, objref=_stash[0]), '${@some.function(d, 200)}/abc') def test_expand_file_ref(self): from oelint_parser.cls_stash import Stash @@ -135,7 +196,8 @@ def test_expand_file_ref(self): attributeValue="A") self.assertTrue(_stash, msg="Stash has no items") for item in _stash[0].get_items(): - self.assertEqual(self.__stash.ExpandTerm(_file, item, objref=_stash[0]), f'${{@some.function(d, "{_file}")}}/abc') + self.assertEqual(self.__stash.ExpandTerm( + _file, item, objref=_stash[0]), f'${{@some.function(d, "{_file}")}}/abc') def test_expandvar_ref_other(self): from oelint_parser.cls_stash import Stash @@ -149,8 +211,10 @@ def test_expandvar_ref_other(self): self.__stash.AddFile(_file) self.__stash.Finalize() - res = self.__stash.ExpandVar(_file, attribute=Variable.ATTR_VAR, attributeValue='A') - self.assertEqual(' '.join(res.get('A', '')), '${@some.function(d, foo)}/abc') + res = self.__stash.ExpandVar( + _file, attribute=Variable.ATTR_VAR, attributeValue='A') + self.assertEqual(' '.join(res.get('A', '')), + '${@some.function(d, foo)}/abc') def test_expandvar_inline_block(self): from oelint_parser.cls_stash import Stash @@ -163,8 +227,10 @@ def test_expandvar_inline_block(self): self.__stash.AddFile(_file) self.__stash.Finalize() - res = self.__stash.ExpandVar(_file, attribute=Variable.ATTR_VAR, attributeValue='A') - self.assertEqual(' '.join(res.get('A', '')), '${@some.function(d, foo)}/abc') + res = self.__stash.ExpandVar( + _file, attribute=Variable.ATTR_VAR, attributeValue='A') + self.assertEqual(' '.join(res.get('A', '')), + '${@some.function(d, foo)}/abc') def test_expandvar_multiple_inline_block(self): from oelint_parser.cls_stash import Stash @@ -177,8 +243,10 @@ def test_expandvar_multiple_inline_block(self): self.__stash.AddFile(_file) self.__stash.Finalize() - res = self.__stash.ExpandVar(_file, attribute=Variable.ATTR_VAR, attributeValue='A') - self.assertEqual(' '.join(res.get('A', '')), '${@some.function(d, foo)}/abc ${@some.function2(d, foo)}/def') + res = self.__stash.ExpandVar( + _file, attribute=Variable.ATTR_VAR, attributeValue='A') + self.assertEqual(' '.join(res.get( + 'A', '')), '${@some.function(d, foo)}/abc ${@some.function2(d, foo)}/def') def test_expandvar_nested_ref(self): from oelint_parser.cls_stash import Stash @@ -193,8 +261,10 @@ def test_expandvar_nested_ref(self): self.__stash.AddFile(_file) self.__stash.Finalize() - res = self.__stash.ExpandVar(_file, attribute=Variable.ATTR_VAR, attributeValue='A') - self.assertEqual(' '.join(res.get('A', '')), '${@some.function(d, foo)}/200/abc') + res = self.__stash.ExpandVar( + _file, attribute=Variable.ATTR_VAR, attributeValue='A') + self.assertEqual(' '.join(res.get('A', '')), + '${@some.function(d, foo)}/200/abc') def test_expandvar_nested_python_ref(self): from oelint_parser.cls_stash import Stash @@ -209,8 +279,12 @@ def test_expandvar_nested_python_ref(self): self.__stash.AddFile(_file) self.__stash.Finalize() - res = self.__stash.ExpandVar(_file, attribute=Variable.ATTR_VAR, attributeValue='A') - self.assertEqual(' '.join(res.get('A', '')), '${@some.function(d, 200)}/abc') + res = self.__stash.ExpandVar( + _file, attribute=Variable.ATTR_VAR, attributeValue='A') + import logging + logging.warning(res) + self.assertEqual(' '.join(res.get('A', '')), + '${@some.function(d, 200)}/abc') def test_expandvar_file_ref(self): from oelint_parser.cls_stash import Stash @@ -224,5 +298,7 @@ def test_expandvar_file_ref(self): self.__stash.AddFile(_file) self.__stash.Finalize() - res = self.__stash.ExpandVar(_file, attribute=Variable.ATTR_VAR, attributeValue='A') - self.assertEqual(' '.join(res.get('A', '')), f'${{@some.function(d, "{_file}")}}/abc') + res = self.__stash.ExpandVar( + _file, attribute=Variable.ATTR_VAR, attributeValue='A') + self.assertEqual(' '.join(res.get('A', '')), + f'${{@some.function(d, "{_file}")}}/abc')