Hi Hugo, so i'm pleased i can provide PI.py a Pitag or list of pitags directly with the search function, and get a list of objects back. But i would like to have that possibility in PIAF too. I would like to provide PIAF.py with a list of Paths to Attributes as we use them in PI AF. like db.search(r'baseelement/element/element|attribute|attribute|attribute')
Suggested solution
in PIAF.py there could be added a Search function just like in PI.py. But one that returns a collection of attribute objects.
it would probably have to split the string and loop through the descendants and children like here to return the last attribute.
i've tried to add this code to PIAF.py and that seems to work...it just needs some magic to make sure it can handle a list instead of a single string.
def search(self, AFtag: str): """ return a PIAFAttribute""" if len(AFtag) > 20 and "|" in AFtag: splittag = AFtag.split('|') elem = self.descendant(splittag[0]) attribute = elem.attributes[splittag[1]] if len(splittag) > 2: for x in range(len(splittag)-2): attribute = attribute.children[splittag[x+2]] return attribute
Feature request
Abstract
Hi Hugo, so i'm pleased i can provide PI.py a Pitag or list of pitags directly with the search function, and get a list of objects back. But i would like to have that possibility in PIAF too. I would like to provide PIAF.py with a list of Paths to Attributes as we use them in PI AF. like db.search(r'baseelement/element/element|attribute|attribute|attribute')
Suggested solution
in PIAF.py there could be added a Search function just like in PI.py. But one that returns a collection of attribute objects.
it would probably have to split the string and loop through the descendants and children like here to return the last attribute.
i've tried to add this code to PIAF.py and that seems to work...it just needs some magic to make sure it can handle a list instead of a single string.
def search(self, AFtag: str): """ return a PIAFAttribute""" if len(AFtag) > 20 and "|" in AFtag: splittag = AFtag.split('|') elem = self.descendant(splittag[0]) attribute = elem.attributes[splittag[1]] if len(splittag) > 2: for x in range(len(splittag)-2): attribute = attribute.children[splittag[x+2]] return attribute