Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

moved options to their own path

- created options.py to hold a custom version of OptionParser
- updated front end script to use options
  • Loading branch information...
commit b77e16d97f7712de38625381e194d43e090a3fde 1 parent a524c2d
@ghickman authored
Showing with 76 additions and 64 deletions.
  1. +75 −0 tvrenamr/options.py
  2. +1 −64 tvrenamr/tvrenamr.py
View
75 tvrenamr/options.py
@@ -0,0 +1,75 @@
+from optparse import OptionParser as OptParser, SUPPRESS_HELP
+
+class OptionParser(OptParser):
+
+ def __init__(self, usage, version):
+ OptParser.__init__(self, usage=usage, version=version)
+
+ self.add_option('--config', dest='config', \
+ help='Select a location for your config file. If the '
+ 'path is invalid the default locations will be used.')
+ self.add_option('-c', '--canonical', dest='canonical',
+ help='Set the show\'s canonical name to use when '
+ 'performing the online lookup.')
+ self.add_option('--debug', action='store_true', dest='debug',
+ help=SUPPRESS_HELP)
+ self.add_option('--deluge', action='store_true', dest='deluge',
+ help='Checks Deluge to make sure the file has been '
+ 'completed before renaming.')
+ self.add_option('--deluge-ratio', dest='deluge_ratio',
+ help='Checks Deluge for completed and that the file '
+ 'has at least reached X share ratio.')
+ self.add_option('-d', '--dry-run', dest='dry', action='store_true',
+ help='Dry run your renaming.')
+ self.add_option('-e', '--episode', dest='episode',
+ help='Set the episode number. Currently this will '
+ 'cause errors when working with more than one file.')
+ self.add_option('--ignore-filelist', dest='ignore_filelist',
+ help=SUPPRESS_HELP)
+ self.add_option('--ignore-recursive', action='store_true',
+ dest='ignore_recursive',
+ help='Only use files from the root of a given '
+ 'directory, not entering any sub-directories.')
+ self.add_option('--log-file', dest='log_file',
+ help='Set the log file location.')
+ self.add_option('-l', '--log-level', dest='log_level',
+ help='Set the log level. Options: short, minimal, '
+ 'info and debug.')
+ self.add_option('--library', dest='library', default='thetvdb',
+ help='Set the library to use for retrieving episode '
+ 'titles. Options: thetvdb & tvrage.')
+ self.add_option('-n', '--name', dest='name',
+ help='Set the show\'s name. This will be used as the '
+ 'show\'s when the renaming is completed.')
+ self.add_option('-o', '--output', dest='output_format',
+ help='Set the output format for the episodes being '
+ 'renamed.')
+ self.add_option('--organise', action='store_true', dest='organise',
+ help='Organise renamed files into folders based on '
+ 'their show name and season number.')
+ self.add_option('--no-organise', action='store_false', dest='organise',
+ help='Explicitly tell Tv Renamr not to organise '
+ 'renamed files. Used to override the config.')
+ self.add_option('-q', '--quiet', action='store_true', dest='quiet',
+ help='Don\'t output logs to the command line')
+ self.add_option('-r', '--recursive', action='store_true',
+ dest='recursive',
+ help='Recursively lookup files in a given directory')
+ self.add_option('--rename-dir', dest='rename_dir',
+ help='The directory to move renamed files to, '
+ 'if not specified the working directory is used.')
+ self.add_option('--no-rename-dir', action='store_false',
+ dest='rename_dir',
+ help='Explicity tell Tv Renamr not to move renamed '
+ 'files. Used to override the config.')
+ self.add_option('--regex', dest='regex',
+ help='The regular expression to use when extracting '
+ 'information from files.')
+ self.add_option('-s', '--season', dest='season',
+ help='Set the season number.')
+ self.add_option('-t', '--the', action='store_true', dest='the',
+ help='Set the position of \'The\' in a show\'s name'
+ ' to the end of the file')
+
+ def parse_args(self):
+ return OptParser.parse_args(self)
View
65 tvrenamr/tvrenamr.py
@@ -11,77 +11,14 @@
from errors import *
from logs import start_logging
from main import TvRenamr
+from options import OptionParser
log = logging.getLogger('Core')
parser = OptionParser(usage="tvr [options] <file/folder>",
version="Tv Renamr %s" % __version__)
-parser.add_option('--config', dest='config', \
- help='Select a location for your config file. If the path \
- is invalid the default locations will be used.')
-parser.add_option('-c', '--canonical', dest='canonical',
- help='Set the show\'s canonical name to use when \
- performing the online lookup.')
-parser.add_option('--debug', action='store_true', dest='debug',
- help=SUPPRESS_HELP)
-parser.add_option('--deluge', action='store_true', dest='deluge',
- help='Checks Deluge to make sure the file has been \
- completed before renaming.')
-parser.add_option('--deluge-ratio', dest='deluge_ratio',
- help='Checks Deluge for completed and that the file has \
- at least reached X share ratio.')
-parser.add_option('-d', '--dry-run', dest='dry', action='store_true',
- help='Dry run your renaming.')
-parser.add_option('-e', '--episode', dest='episode',
- help='Set the episode number. Currently this will cause \
- errors when working with more than one file.')
-parser.add_option('--ignore-filelist', dest='ignore_filelist',
- help=SUPPRESS_HELP)
-parser.add_option('--ignore-recursive', action='store_true',
- dest='ignore_recursive',
- help='Only use files from the root of a given directory, \
- not entering any sub-directories.')
-parser.add_option('--log-file', dest='log_file',
- help='Set the log file location.')
-parser.add_option('-l', '--log-level', dest='log_level',
- help='Set the log level. Options: short, minimal, info and \
- debug.')
-parser.add_option('--library', dest='library', default='thetvdb',
- help='Set the library to use for retrieving episode \
- titles. Options: thetvdb & tvrage.')
-parser.add_option('-n', '--name', dest='name',
- help='Set the show\'s name. This will be used as the \
- show\'s when the renaming is completed.')
-parser.add_option('-o', '--output', dest='output_format',
- help='Set the output format for the episodes being \
- renamed.')
-parser.add_option('--organise', action='store_true', dest='organise',
- help='Organise renamed files into folders based on their \
- show name and season number.')
-parser.add_option('--no-organise', action='store_false', dest='organise',
- help='Explicitly tell Tv Renamr not to organise renamed \
- files. Used to override the config.')
-parser.add_option('-q', '--quiet', action='store_true', dest='quiet',
- help='Don\'t output logs to the command line')
-parser.add_option('-r', '--recursive', action='store_true', dest='recursive',
- help='Recursively lookup files in a given directory')
-parser.add_option('--rename-dir', dest='rename_dir',
- help='The directory to move renamed files to, \
- if not specified the working directory is used.')
-parser.add_option('--no-rename-dir', action='store_false', dest='rename_dir',
- help='Explicity tell Tv Renamr not to move renamed files. \
- Used to override the config.')
-parser.add_option('--regex', dest='regex',
- help='The regular expression to use when extracting \
- information from files.')
-parser.add_option('-s', '--season', dest='season',
- help='Set the season number.')
-parser.add_option('-t', '--the', action='store_true', dest='the',
- help='Set the position of \'The\' in a show\'s name to \
- the end of the file')
options, args = parser.parse_args()
-
class FrontEnd():
def __init__(self, path):
Please sign in to comment.
Something went wrong with that request. Please try again.