def resolveCrossId(id, forceType=None, **kwargs): """resolves id, where id is of the form rdId#id. id can also be a simple rdID. See resolveId for forceType. This lets you pass additional keyword arguments to getRD. """ try: rdId, rest = id.split("#") except ValueError: if "#" in id: raise common.LiteralParseError( "id", id, hint="There must be at most" " one hash sign ('#') in cross ids, separating the rd identifier" " from the rd-internal id") rdId, rest = id, None try: srcRD = caches.getRD(rdId, **kwargs) except common.RDNotFound, ex: ex.hint = ( "I was trying to resolve the reference %s; note that DaCHS only" " uses RDs residing below inputsDir and ignores all others." " If there's an RD that DaCHS insists isn't there, that's" " probably the reason." % id) raise
def validate(self): self._validateNext(MacDef) if len(self.name) < 2: raise common.LiteralParseError( "name", self.name, hint="Macro names must have at least two characters.")
def onElementComplete(self): mat = self.refPat.match(self.ref) if not mat: raise common.LiteralParseError( "ref", self.ref, hint="edit references have the form <element name>[<value of" " name or id attribute>]") self.triggerEl, self.triggerId = mat.groups()
def feed(self, ctx, instance, value): # if the child factory actually admits content_ (and needs nothing # else), allow attributes to be fed in, too. if "content_" in self.childFactory.managedAttrs: child = self.childFactory(instance, content_=value).finishElement(ctx) return self.feedObject(instance, child) raise common.LiteralParseError( self.name_, value, hint="These attributes have no literals at all, i.e.," " they are for internal use only.")
def resolveComplexId(ctx, id, forceType=None): """resolves a dotted id. See resolveId. """ try: pId, name = id.split(".") except ValueError: raise utils.logOldExc( common.LiteralParseError( "id", id, hint="A complex reference (parent.name) is expected here")) container = ctx.getById(pId) return resolveNameBased(container, name, forceType)