/usr/bin/feedvalidator is in python-feedvalidator 0~svn1022-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | #!/usr/bin/python
"""$Id: demo.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
import getopt
import feedvalidator
import sys
import os
import urllib
import urllib2
import urlparse
def run():
# arg 1 is URL to validate
link = sys.argv[1:] and sys.argv[1] or 'http://www.intertwingly.net/blog/index.atom'
link = urlparse.urljoin('file:' + urllib.pathname2url(os.getcwd()) + '/', link)
try:
link = link.decode('utf-8').encode('idna')
except:
pass
print 'Validating %s' % link
curdir = os.path.abspath(os.path.dirname(sys.argv[0]))
basedir = urlparse.urljoin('file:' + curdir, ".")
try:
if link.startswith(basedir):
events = feedvalidator.validateStream(urllib.urlopen(link), firstOccurrenceOnly=1,base=link.replace(basedir,"http://www.feedvalidator.org/"))['loggedEvents']
else:
events = feedvalidator.validateURL(link, firstOccurrenceOnly=1)['loggedEvents']
except feedvalidator.logging.ValidationFailure, vf:
events = [vf.event]
# (optional) arg 2 is compatibility level
# "A" is most basic level
# "AA" mimics online validator
# "AAA" is experimental; these rules WILL change or disappear in future versions
from feedvalidator import compatibility
filter = sys.argv[2:] and sys.argv[2] or "AA"
filterFunc = getattr(compatibility, filter)
events = filterFunc(events)
from feedvalidator.formatter.text_plain import Formatter
output = Formatter(events)
if output:
print "\n".join(output)
sys.exit(1)
else:
print "No errors or warnings"
def main():
short_opts = "hV"
long_opts = ["help", "version"]
try:
opts, args = getopt.getopt(sys.argv[1:], short_opts, long_opts)
except getopt.GetoptError, error:
sys.stderr.write("error: %s\n\n" % error)
sys.stderr.write("Try `%s --help` for more information.\n" % sys.argv[0])
sys.exit(1)
for opt, value in opts:
if opt in ("-h", "--help"):
sys.stdout.write("""Usage: feedvalidator [OPTION] [FEED] [LEVEL]
Validate a feed as RSS, Atom or KML. The feed can be a local or remote URI.
The optional level argument can be one of the following:
A basic level only
AA mimic the online validator (default)
AAA experimental, these rules will change or disappear in future versions
The exit status is 0 for success or 1 for failure.
Options:
-h, --help display a short help message and exit
-V, --version display version information and exit
Report bugs using the `reportbug` command.
"""
)
sys.exit(0)
if opt in ("-V", "--version"):
sys.stdout.write("""feedvalidator - Feed Validator 0~svn1022
Copyright 2002, Sam Ruby and Mark Pilgrim
Licensed under an MIT variant free software license.
Written by Sam Ruby and Mark Pilgrim.
""")
sys.exit(0)
run()
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
pass
|