Fixes for Python 2.6
[animesorter.git] / animesorter2.py
index 2e185eb..e85a2b3 100755 (executable)
@@ -38,6 +38,9 @@ import shutil
 import logging
 import optparse
 
 import logging
 import optparse
 
+PROGRAM_NAME = 'animesorter2'
+PROGRAM_VERSION = '2.1.0'
+
 ### Default Configuration Variables ###
 DICT_FILE = os.path.join ('~','.config','animesorter2','animesorter.dict')
 WORK_DIR =  os.path.join ('~','downloads','usenet')
 ### Default Configuration Variables ###
 DICT_FILE = os.path.join ('~','.config','animesorter2','animesorter.dict')
 WORK_DIR =  os.path.join ('~','downloads','usenet')
@@ -262,6 +265,8 @@ def main():
             help='Enable pretend mode', action='store_true')
     parser.add_option('-e', '--editor', dest='run_editor', default=False,
             help='Run editor on dictionary', action='store_true')
             help='Enable pretend mode', action='store_true')
     parser.add_option('-e', '--editor', dest='run_editor', default=False,
             help='Run editor on dictionary', action='store_true')
+    parser.add_option('-V', '--version', dest='version', default=False,
+            help='Show version and exit', action='store_true')
 
     ## Parse the options
     (options, args) = parser.parse_args()
 
     ## Parse the options
     (options, args) = parser.parse_args()
@@ -271,6 +276,17 @@ def main():
     options.start_dir = os.path.abspath(os.path.expanduser(options.start_dir))
     options.output_dir = os.path.abspath(os.path.expanduser(options.output_dir))
 
     options.start_dir = os.path.abspath(os.path.expanduser(options.start_dir))
     options.output_dir = os.path.abspath(os.path.expanduser(options.output_dir))
 
+    ## Show version if necessary
+    if options.version:
+        print '%s - %s' % (PROGRAM_NAME, PROGRAM_VERSION)
+        print
+        print 'Copyright (c) 2005-2007 Ira W. Snyder (devel@irasnyder.com)'
+        print 'This program comes with ABSOLUTELY NO WARRANTY.'
+        print 'This is free software, and you are welcome to redistribute it'
+        print 'under certain conditions. See the file COPYING for details.'
+
+        sys.exit (0)
+
     ## Run editor if necessary
     if options.run_editor:
         editor = os.getenv ('EDITOR')
     ## Run editor if necessary
     if options.run_editor:
         editor = os.getenv ('EDITOR')
@@ -287,8 +303,8 @@ def main():
     if options.quiet:
         logging.getLogger().setLevel (logging.CRITICAL)
 
     if options.quiet:
         logging.getLogger().setLevel (logging.CRITICAL)
 
-    as = AnimeSorter2(options)
-    as.main()
+    sorter = AnimeSorter2(options)
+    sorter.main()
 
 if __name__ == '__main__':
     main ()
 
 if __name__ == '__main__':
     main ()