intficpy/sequence.py
def _parse_template_node(self, node, stack=None):
        """
        Parse, validate, and prepare the template for reading
        """
        stack = stack or []

        if not type(node) is list:
            raise IFPError(
                "Expected Sequence node (list); found {node}" f"\nLocation: {stack}"
            )
        for i in range(0, len(node)):
            stack.append(i)
            item = node[i]

            if isinstance(item, self.Label):
                if item.name in self.labels:
                    raise IFPError(
                        "Sequence Labels must be uniquely named within the Sequence. "
                        f'Label "{item.name}" at location {stack} was previously defined '
                        "for this Sequence."
                    )
                self.labels[item.name] = list(stack)
                stack.pop()
                continue

            if type(item) is str or isinstance(item, self.ControlItem):
                stack.pop()
                continue

            if callable(item):
                sig = signature(item)
                if len([p for p in sig.parameters]) != 1:
                    raise IFPError(
                        f"{item} found in Sequence. "
                        "Callables used as Sequence items must accept the Sequence instance "
                        "as the only argument."
                        f"\nLocation: {stack}"
                    )
                stack.pop()
                continue
            try:
                for key, sub_node in item.items():
                    if type(key) is not str:
                        raise IFPError(
                            "Only strings can be used as option names (dict keys) in Sequences. "
                            f"Found {key} ({type(key)})\nLocation: {stack}"
                        )
                    stack.append(key)
                    self._parse_template_node(sub_node, stack=stack)
                    stack.pop()
            except AttributeError:
                raise IFPError(
                    f"Expected Sequence item (string, function, dict or Sequence "
                    f"ControlItem); found {item}"
                    f"\nLocation: {stack}"
                )
            stack.pop()

        Parse, validate, and prepare the template for reading
        
Parse, validate, and prepare the template for reading
Parse validate and prepare the template for reading
def _parse_template_node(self, node, stack=None):
        stack = stack or []
        if not type(node) is list:
            raise IFPError(
                "Expected Sequence node (list); found {node}" f"\nLocation: {stack}"
            )
        for i in range(0, len(node)):
            stack.append(i)
            item = node[i]
            if isinstance(item, self.Label):
                if item.name in self.labels:
                    raise IFPError(
                        "Sequence Labels must be uniquely named within the Sequence. "
                        f'Label "{item.name}" at location {stack} was previously defined '
                        "for this Sequence."
                    )
                self.labels[item.name] = list(stack)
                stack.pop()
                continue
            if type(item) is str or isinstance(item, self.ControlItem):
                stack.pop()
                continue
            if callable(item):
                sig = signature(item)
                if len([p for p in sig.parameters]) != 1:
                    raise IFPError(
                        f"{item} found in Sequence. "
                        "Callables used as Sequence items must accept the Sequence instance "
                        "as the only argument."
                        f"\nLocation: {stack}"
                    )
                stack.pop()
                continue
            try:
                for key, sub_node in item.items():
                    if type(key) is not str:
                        raise IFPError(
                            "Only strings can be used as option names (dict keys) in Sequences. "
                            f"Found {key} ({type(key)})\nLocation: {stack}"
                        )
                    stack.append(key)
                    self._parse_template_node(sub_node, stack=stack)
                    stack.pop()
            except AttributeError:
                raise IFPError(
                    f"Expected Sequence item (string, function, dict or Sequence "
                    f"ControlItem); found {item}"
                    f"\nLocation: {stack}"
                )
            stack.pop()
def _parse_template_node ( self , node , stack = None ) : stack = stack or [ ] if not type ( node ) is list : raise IFPError ( "Expected Sequence node (list); found {node}" f"\nLocation: {stack}" ) for i in range ( 0 , len ( node ) ) : stack . append ( i ) item = node [ i ] if isinstance ( item , self . Label ) : if item . name in self . labels : raise IFPError ( "Sequence Labels must be uniquely named within the Sequence. " f'Label "{item.name}" at location {stack} was previously defined ' "for this Sequence." ) self . labels [ item . name ] = list ( stack ) stack . pop ( ) continue if type ( item ) is str or isinstance ( item , self . ControlItem ) : stack . pop ( ) continue if callable ( item ) : sig = signature ( item ) if len ( [ p for p in sig . parameters ] ) != 1 : raise IFPError ( f"{item} found in Sequence. " "Callables used as Sequence items must accept the Sequence instance " "as the only argument." f"\nLocation: {stack}" ) stack . pop ( ) continue try : for key , sub_node in item . items ( ) : if type ( key ) is not str : raise IFPError ( "Only strings can be used as option names (dict keys) in Sequences. " f"Found {key} ({type(key)})\nLocation: {stack}" ) stack . append ( key ) self . _parse_template_node ( sub_node , stack = stack ) stack . pop ( ) except AttributeError : raise IFPError ( f"Expected Sequence item (string, function, dict or Sequence " f"ControlItem); found {item}" f"\nLocation: {stack}" ) stack . pop ( )
Parse, validate, and prepare the template for reading
Parse validate and prepare the template for reading
"""
        Parse, validate, and prepare the template for reading
        """
self
node
stack