Пример #1
0
  def validate_metadata(self):
    if not 'title' in self.children:
      self.missingElement({"parent":self.name, "element":"title"})
    if not 'id' in self.children:
      self.missingElement({"parent":self.name, "element":"id"})
    if not 'updated' in self.children:
      self.missingElement({"parent":self.name, "element":"updated"})

    # ensure that there is a link rel="self"
    for link in self.links:
      if link.rel=='self': break
    else:
      offset = [self.line - self.dispatcher.locator.getLineNumber(),
                self.col  - self.dispatcher.locator.getColumnNumber()]
      self.log(MissingSelf({"parent":self.parent.name, "element":self.name}), offset)

    # can only have one alternate per type
    types={}
    for link in self.links:
      if not link.rel=='alternate': continue
      if not link.type in types: types[link.type]={}
      if link.rel in types[link.type]:
        if link.hreflang in types[link.type][link.rel]:
          self.log(DuplicateAtomLink({"parent":self.name, "element":"link", "type":link.type, "hreflang":link.hreflang}))
        else:
          types[link.type][link.rel] += [link.hreflang]
      else:
        types[link.type][link.rel] = [link.hreflang]

    if self.itunes: itunes_channel.validate(self)
Пример #2
0
  def validate_metadata(self):
    if not 'title' in self.children:
      self.missingElement({"parent":self.name, "element":"title"})
    if not 'id' in self.children:
      self.missingElement({"parent":self.name, "element":"id"})
    if not 'updated' in self.children:
      self.missingElement({"parent":self.name, "element":"updated"})

    # ensure that there is a link rel="self"
    for link in self.links:
      if link.rel=='self': break
    else:
      offset = [self.line - self.dispatcher.locator.getLineNumber(),
                self.col  - self.dispatcher.locator.getColumnNumber()]
      self.log(MissingSelf({"parent":self.parent.name, "element":self.name}), offset)

    # can only have one alternate per type
    types={}
    for link in self.links:
      if not link.rel=='alternate': continue
      if not link.type in types: types[link.type]={}
      if link.rel in types[link.type]:
        if link.hreflang in types[link.type][link.rel]:
          self.log(DuplicateAtomLink({"parent":self.name, "element":"link", "type":link.type, "hreflang":link.hreflang}))
        else:
          types[link.type][link.rel] += [link.hreflang]
      else:
        types[link.type][link.rel] = [link.hreflang]

    if self.itunes: itunes_channel.validate(self)
Пример #3
0
    def validate(self):
        if not "description" in self.children:
            self.log(MissingDescription({"parent": self.name, "element": "description"}))
        if not "link" in self.children:
            self.log(MissingLink({"parent": self.name, "element": "link"}))
        if not "title" in self.children:
            self.log(MissingTitle({"parent": self.name, "element": "title"}))
        if not "dc_language" in self.children and not "language" in self.children:
            if not self.xmlLang:
                self.log(MissingDCLanguage({"parent": self.name, "element": "language"}))
        if self.children.count("image") > 1:
            self.log(DuplicateElement({"parent": self.name, "element": "image"}))
        if self.children.count("textInput") > 1:
            self.log(DuplicateElement({"parent": self.name, "element": "textInput"}))
        if self.children.count("skipHours") > 1:
            self.log(DuplicateElement({"parent": self.name, "element": "skipHours"}))
        if self.children.count("skipDays") > 1:
            self.log(DuplicateElement({"parent": self.name, "element": "skipDays"}))
        if self.attrs.has_key((rdfNS, "about")):
            self.value = self.attrs.getValue((rdfNS, "about"))
            rfc2396.validate(self, extraParams={"attr": "rdf:about"})
            if not "items" in self.children:
                self.log(MissingElement({"parent": self.name, "element": "items"}))

        if self.itunes:
            itunes_channel.validate(self)
Пример #4
0
    def validate(self):
        if not "description" in self.children:
            self.log(
                MissingDescription({
                    "parent": self.name,
                    "element": "description"
                }))
        if not "link" in self.children:
            self.log(MissingLink({"parent": self.name, "element": "link"}))
        if not "title" in self.children:
            self.log(MissingTitle({"parent": self.name, "element": "title"}))
        if not "dc_language" in self.children and not "language" in self.children:
            if not self.xmlLang:
                self.log(
                    MissingDCLanguage({
                        "parent": self.name,
                        "element": "language"
                    }))
        if self.children.count("image") > 1:
            self.log(
                DuplicateElement({
                    "parent": self.name,
                    "element": "image"
                }))
        if self.children.count("textInput") > 1:
            self.log(
                DuplicateElement({
                    "parent": self.name,
                    "element": "textInput"
                }))
        if self.children.count("skipHours") > 1:
            self.log(
                DuplicateElement({
                    "parent": self.name,
                    "element": "skipHours"
                }))
        if self.children.count("skipDays") > 1:
            self.log(
                DuplicateElement({
                    "parent": self.name,
                    "element": "skipDays"
                }))
        if self.attrs.has_key((rdfNS, "about")):
            self.value = self.attrs.getValue((rdfNS, "about"))
            rfc2396.validate(self, extraParams={"attr": "rdf:about"})
            if not "items" in self.children:
                self.log(
                    MissingElement({
                        "parent": self.name,
                        "element": "items"
                    }))

        if self.itunes: itunes_channel.validate(self)
Пример #5
0
    def validate(self):
        if not "description" in self.children:
            self.log(MissingDescription({"parent": self.name, "element": "description"}))
        if not "link" in self.children:
            self.log(MissingLink({"parent": self.name, "element": "link"}))
        if not "title" in self.children:
            self.log(MissingTitle({"parent": self.name, "element": "title"}))
        if not "dc_language" in self.children and not "language" in self.children:
            if not self.xmlLang:
                self.log(MissingDCLanguage({"parent": self.name, "element": "language"}))
        if self.children.count("image") > 1:
            self.log(DuplicateElement({"parent": self.name, "element": "image"}))
        if self.children.count("textInput") > 1:
            self.log(DuplicateElement({"parent": self.name, "element": "textInput"}))
        if self.children.count("skipHours") > 1:
            self.log(DuplicateElement({"parent": self.name, "element": "skipHours"}))
        if self.children.count("skipDays") > 1:
            self.log(DuplicateElement({"parent": self.name, "element": "skipDays"}))
        if self.attrs.has_key((rdfNS, "about")):
            self.value = self.attrs.getValue((rdfNS, "about"))
            rfc2396.validate(self, extraParams={"attr": "rdf:about"})
            if not "items" in self.children:
                self.log(MissingElement({"parent": self.name, "element": "items"}))

        if self.parent.name == "rss" and self.parent.version == "2.0":
            for link in self.links:
                if link.rel == "self":
                    break
            else:
                self.log(MissingAtomSelfLink({}))

        if self.itunes:
            itunes_channel.validate(self)

        # don't warn about use of extension attributes for rss-board compliant feeds
        if self.docs == "http://www.rssboard.org/rss-specification":
            self.dispatcher.loggedEvents = [
                event for event in self.dispatcher.loggedEvents if not isinstance(event, UseOfExtensionAttr)
            ]
Пример #6
0
  def validate_metadata(self):
    if not 'title' in self.children:
      self.missingElement({"parent":self.name, "element":"title"})
    if not 'id' in self.children:
      self.missingElement({"parent":self.name, "element":"id"})
    if not 'updated' in self.children:
      self.missingElement({"parent":self.name, "element":"updated"})

    # complete feeds can only have current=self and no other links
    if 'fh_complete' in self.children:
      for link in self.links:
        if link.rel in link.rfc5005:
          if link.rel == "current":
            if link.href not in self.dispatcher.selfURIs:
              self.log(CurrentNotSelfInCompleteFeed({"rel":link.rel}))
          else:
            self.log(FeedRelInCompleteFeed({"rel":link.rel}))

    # ensure that there is a link rel="self"
    if self.name != 'source':
      for link in self.links:
        if link.rel=='self': break
      else:
        offset = [self.line - self.dispatcher.locator.getLineNumber(),
                  self.col  - self.dispatcher.locator.getColumnNumber()]
        self.log(MissingSelf({"parent":self.parent.name, "element":self.name}), offset)

    types={}
    archive=False
    current=False
    for link in self.links:
      if link.rel == 'current': current = True
      if link.rel in ['prev-archive', 'next-archive']: archive = True

      # attempts to link past the end of the list
      if link.rel == 'first' and link.href in self.dispatcher.selfURIs:
        for link2 in self.links:
          if link2.rel == 'previous':
              self.log(LinkPastEnd({"self":link.rel, "rel":link2.rel}))
      if link.rel == 'last' and link.href in self.dispatcher.selfURIs:
        for link2 in self.links:
          if link2.rel == 'next':
              self.log(LinkPastEnd({"self":link.rel, "rel":link2.rel}))

      # can only have one alternate per type
      if not link.rel=='alternate': continue
      if not link.type in types: types[link.type]={}
      if link.rel in types[link.type]:
        if link.hreflang in types[link.type][link.rel]:
          self.log(DuplicateAtomLink({"parent":self.name, "element":"link", "type":link.type, "hreflang":link.hreflang}))
        else:
          types[link.type][link.rel] += [link.hreflang]
      else:
        types[link.type][link.rel] = [link.hreflang]

    if 'fh_archive' in self.children:
      # archives should either have links or be marked complete
      if not archive and 'fh_complete' not in self.children:
        self.log(ArchiveIncomplete({}))

      # archives should have current links
      if not current and ('fh_complete' not in self.children):
        self.log(MissingCurrentInArchive({}))

    if self.itunes: itunes_channel.validate(self)
Пример #7
0
    def validate(self):
        if not "description" in self.children:
            self.log(
                MissingDescription({
                    "parent": self.name,
                    "element": "description"
                }))
        if not "link" in self.children:
            self.log(MissingLink({"parent": self.name, "element": "link"}))
        if not "title" in self.children:
            self.log(MissingTitle({"parent": self.name, "element": "title"}))
        if not "dc_language" in self.children and not "language" in self.children:
            if not self.xmlLang:
                self.log(
                    MissingDCLanguage({
                        "parent": self.name,
                        "element": "language"
                    }))
        if self.children.count("image") > 1:
            self.log(
                DuplicateElement({
                    "parent": self.name,
                    "element": "image"
                }))
        if self.children.count("textInput") > 1:
            self.log(
                DuplicateElement({
                    "parent": self.name,
                    "element": "textInput"
                }))
        if self.children.count("skipHours") > 1:
            self.log(
                DuplicateElement({
                    "parent": self.name,
                    "element": "skipHours"
                }))
        if self.children.count("skipDays") > 1:
            self.log(
                DuplicateElement({
                    "parent": self.name,
                    "element": "skipDays"
                }))
        if self.attrs.has_key((rdfNS, "about")):
            self.value = self.attrs.getValue((rdfNS, "about"))
            rfc2396.validate(self, extraParams={"attr": "rdf:about"})
            if not "items" in self.children:
                self.log(
                    MissingElement({
                        "parent": self.name,
                        "element": "items"
                    }))

        if self.parent.name == 'rss' and self.parent.version == '2.0':
            for link in self.links:
                if link.rel == 'self': break
            else:
                self.log(MissingAtomSelfLink({}))

        if self.itunes: itunes_channel.validate(self)

        # don't warn about use of extension attributes for rss-board compliant feeds
        if self.docs == 'http://www.rssboard.org/rss-specification':
            self.dispatcher.loggedEvents = [
                event for event in self.dispatcher.loggedEvents
                if not isinstance(event, UseOfExtensionAttr)
            ]
Пример #8
0
  def validate_metadata(self):
    if not 'title' in self.children:
      self.missingElement({"parent":self.name, "element":"title"})
    if not 'id' in self.children:
      self.missingElement({"parent":self.name, "element":"id"})
    if not 'updated' in self.children:
      self.missingElement({"parent":self.name, "element":"updated"})

    # complete feeds can only have current=self and no other links
    if 'fh_complete' in self.children:
      for link in self.links:
        if link.rel in link.rfc5005:
          if link.rel == "current":
            if link.href not in self.dispatcher.selfURIs:
              self.log(CurrentNotSelfInCompleteFeed({"rel":link.rel}))
          else:
            self.log(FeedRelInCompleteFeed({"rel":link.rel}))

    # ensure that there is a link rel="self"
    if self.name != 'source':
      for link in self.links:
        if link.rel=='self': break
      else:
        offset = [self.line - self.dispatcher.locator.getLineNumber(),
                  self.col  - self.dispatcher.locator.getColumnNumber()]
        self.log(MissingSelf({"parent":self.parent.name, "element":self.name}), offset)

    types={}
    archive=False
    current=False
    for link in self.links:
      if link.rel == 'current': current = True
      if link.rel in ['prev-archive', 'next-archive']: archive = True

      # attempts to link past the end of the list
      if link.rel == 'first' and link.href in self.dispatcher.selfURIs:
        for link2 in self.links:
          if link2.rel == 'previous':
              self.log(LinkPastEnd({"self":link.rel, "rel":link2.rel}))
      if link.rel == 'last' and link.href in self.dispatcher.selfURIs:
        for link2 in self.links:
          if link2.rel == 'next':
              self.log(LinkPastEnd({"self":link.rel, "rel":link2.rel}))

      # can only have one alternate per type
      if not link.rel=='alternate': continue
      if not link.type in types: types[link.type]={}
      if link.rel in types[link.type]:
        if link.hreflang in types[link.type][link.rel]:
          self.log(DuplicateAtomLink({"parent":self.name, "element":"link", "type":link.type, "hreflang":link.hreflang}))
        else:
          types[link.type][link.rel] += [link.hreflang]
      else:
        types[link.type][link.rel] = [link.hreflang]

    if 'fh_archive' in self.children:
      # archives should either have links or be marked complete
      if not archive and 'fh_complete' not in self.children:
        self.log(ArchiveIncomplete({}))

      # archives should have current links
      if not current and ('fh_complete' not in self.children):
        self.log(MissingCurrentInArchive({}))
 
    if self.itunes: itunes_channel.validate(self)