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
|
diff -Nur -x '*.orig' -x '*~' python-feedvalidator-0~svn1022-dfsg/demo.py python-feedvalidator-0~svn1022-dfsg.new/demo.py
--- python-feedvalidator-0~svn1022-dfsg/demo.py 2008-03-12 18:22:48.000000000 +0000
+++ python-feedvalidator-0~svn1022-dfsg.new/demo.py 2008-08-22 14:45:03.000000000 +0100
@@ -6,6 +6,7 @@
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
+import getopt
import feedvalidator
import sys
import os
@@ -13,7 +14,7 @@
import urllib2
import urlparse
-if __name__ == '__main__':
+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)
@@ -50,3 +51,53 @@
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 @version@
+
+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
|