Пример #1
0
        def parse_identifier(s, is_absolute):
            m = syntax.re_keyword_start.match(s)
            if m is None:
                raise Abort
            s = s[m.end():]
            if m.group(2) is None:
                # no prefix
                return (m.group(3), s)
            elif m.group(2) == path.i_module.i_prefix and is_absolute == False:
                # reference to local module in a relative keypath -
                # remove the prefix.  this makes it easier to handle
                # leafrefs in groupings.  local identifiers in relative keypaths
                # in groupings are resolved to point:
                #   (i) within the grouping only (checked by
                #       statements.validate_leafref_path()) and
                #  (ii) to elements where the grouping is used.  this is
                #       easier to handle if the prefix is removed here.
                return (m.group(3), s)
            else:
                return ((m.group(2), m.group(3)), s)

                prefix = m.group(2)
                mod = statements.prefix_to_module(path.i_module, prefix,
                                                  path.pos, errors)
                if mod is not None:
                    return ((mod, m.group(3)), s)
                else:
                    raise Abort
Пример #2
0
        def parse_identifier(s, is_absolute):
            m = syntax.re_keyword_start.match(s)
            if m is None:
                raise Abort
            s = s[m.end():]
            if m.group(2) is None:
                # no prefix
                return (m.group(3), s)
            elif m.group(2) == path.i_module.i_prefix and is_absolute == False:
                # reference to local module in a relative keypath -
                # remove the prefix.  this makes it easier to handle
                # leafrefs in groupings.  local identifiers in relative keypaths
                # in groupings are resolved to point:
                #   (i) within the grouping only (checked by
                #       statements.validate_leafref_path()) and
                #  (ii) to elements where the grouping is used.  this is
                #       easier to handle if the prefix is removed here.
                return (m.group(3), s)
            else:
                return ((m.group(2), m.group(3)), s)

                prefix = m.group(2)
                mod = statements.prefix_to_module(path.i_module, prefix,
                                                  path.pos, errors)
                if mod is not None:
                    return ((mod, m.group(3)), s)
                else:
                    raise Abort
        def parse_identifier(s):
            m = syntax.re_keyword_start.match(s)
            if m is None:
                raise Abort
            s = s[m.end():]
            if m.group(2) is None:
                # no prefix
                return (m.group(3), s)
            else:
                return ((m.group(2), m.group(3)), s)

                prefix = m.group(2)
                mod = statements.prefix_to_module(path.i_module, prefix,
                                                  path.pos, errors)
                if mod is not None:
                    return ((mod, m.group(3)), s)
                else:
                    raise Abort
Пример #4
0
        def parse_identifier(s):
            m = syntax.re_keyword_start.match(s)
            if m is None:
                raise Abort
            s = s[m.end():]
            if m.group(2) is None:
                # no prefix
                return (m.group(3), s)
            else:
                return ((m.group(2), m.group(3)), s)

                prefix = m.group(2)
                mod = statements.prefix_to_module(path.i_module, prefix,
                                                  path.pos, errors)
                if mod is not None:
                    return ((mod, m.group(3)), s)
                else:
                    raise Abort
 def str_to_val(self, errors, pos, s):
     if s.find(":") == -1:
         prefix = None
         name = s
     else:
         [prefix, name] = s.split(':', 1)
     if prefix is None or self.base.i_module.i_prefix == prefix:
         # check local identities
         pmodule = self.base.i_module
     else:
         # this is a prefixed name, check the imported modules
         pmodule = statements.prefix_to_module(self.base.i_module, prefix,
                                               pos, errors)
         if pmodule is None:
             return None
     if name not in pmodule.i_identities:
         err_add(errors, pos, 'TYPE_VALUE',
                 (s, self.definition, 'identityref not found'))
         return None
     val = pmodule.i_identities[name]
     my_identity = self.base.i_identity
     vals = []
     while True:
         if val == my_identity:
             return pmodule.i_identities[name]
         else:
             p = val.search_one('base')
             if p is None or p.i_identity is None:
                 err_add(errors, pos, 'TYPE_VALUE',
                         (s, self.definition,
                          'identityref not derived from %s' % \
                          my_identity.arg))
                 return None
             else:
                 val = p.i_identity
                 if val in vals:
                     # circular; has been reported already
                     return
                 vals.append(val)
Пример #6
0
 def str_to_val(self, errors, pos, s):
     if s.find(":") == -1:
         prefix = None
         name = s
     else:
         [prefix, name] = s.split(':', 1)
     if prefix is None or self.base.i_module.i_prefix == prefix:
         # check local identities
         pmodule = self.base.i_module
     else:
         # this is a prefixed name, check the imported modules
         pmodule = statements.prefix_to_module(self.base.i_module, prefix,
                                               pos, errors)
         if pmodule is None:
             return None
     if name not in pmodule.i_identities:
         err_add(errors, pos, 'TYPE_VALUE',
                 (s, self.definition, 'identityref not found'))
         return None
     val = pmodule.i_identities[name]
     my_identity = self.base.i_identity
     vals = []
     while True:
         if val == my_identity:
             return pmodule.i_identities[name]
         else:
             p = val.search_one('base')
             if p is None or p.i_identity is None:
                 err_add(errors, pos, 'TYPE_VALUE',
                         (s, self.definition,
                          'identityref not derived from %s' % \
                          my_identity.arg))
                 return None
             else:
                 val = p.i_identity
                 if val in vals:
                     # circular; has been reported already
                     return
                 vals.append(val)