Example #1
0
    def option_parser(self, user_defaults=None, usage='', gui_mode=False):
        from calibre.utils.config import OptionParser
        parser = OptionParser(usage, gui_mode=gui_mode)
        groups = defaultdict(lambda: parser)
        for group, desc in self.groups.items():
            groups[group] = parser.add_option_group(group.upper(), desc)

        for pref in self.preferences:
            if not pref.switches:
                continue
            g = groups[pref.group]
            action = pref.action
            if action is None:
                action = 'store'
                if pref.default is True or pref.default is False:
                    action = 'store_' + ('false' if pref.default else 'true')
            args = dict(
                dest=pref.name,
                help=pref.help,
                metavar=pref.metavar,
                type=pref.type,
                choices=pref.choices,
                default=getattr(user_defaults, pref.name, pref.default),
                action=action,
            )
            g.add_option(*pref.switches, **args)

        return parser
Example #2
0
def option_parser():
    parser = OptionParser(usage=USAGE)
    parser.add_option('--list-recipes', default=False, action='store_true',
            help=_('List builtin recipe names. You can create an e-book from '
                'a builtin recipe like this: ebook-convert "Recipe Name.recipe" '
                'output.epub'))
    return parser
Example #3
0
    def option_parser(self, user_defaults=None, usage='', gui_mode=False):
        from calibre.utils.config import OptionParser
        parser = OptionParser(usage, gui_mode=gui_mode)
        groups = defaultdict(lambda : parser)
        for group, desc in self.groups.items():
            groups[group] = parser.add_option_group(group.upper(), desc)

        for pref in self.preferences:
            if not pref.switches:
                continue
            g = groups[pref.group]
            action = pref.action
            if action is None:
                action = 'store'
                if pref.default is True or pref.default is False:
                    action = 'store_' + ('false' if pref.default else 'true')
            args = dict(
                        dest=pref.name,
                        help=pref.help,
                        metavar=pref.metavar,
                        type=pref.type,
                        choices=pref.choices,
                        default=getattr(user_defaults, pref.name, pref.default),
                        action=action,
                        )
            g.add_option(*pref.switches, **args)

        return parser
Example #4
0
def option_parser():
    parser = OptionParser(usage=USAGE)
    parser.add_option('--list-recipes', default=False, action='store_true',
            help=_('List builtin recipe names. You can create an e-book from '
                'a builtin recipe like this: ebook-convert "Recipe Name.recipe" '
                'output.epub'))
    return parser
Example #5
0
def option_parser():
    from calibre.utils.config import OptionParser
    parser = OptionParser()
    parser.add_option('--make-errors-fatal',
                      action='store_true',
                      default=False,
                      dest='fatal_errors',
                      help='If set die on errors.')
    parser.add_option('--root',
                      dest='staging_root',
                      default='/usr',
                      help='Prefix under which to install files')
    parser.add_option(
        '--bindir',
        default=None,
        dest='staging_bindir',
        help=
        'Location where calibre launcher scripts were installed. Typically /usr/bin'
    )
    parser.add_option(
        '--sharedir',
        default=None,
        dest='staging_sharedir',
        help=
        'Location where calibre resources were installed, typically /usr/share/calibre'
    )

    return parser
Example #6
0
 def option_parser():
     """Parse command line options."""
     option_parser = OptionParser(
         usage='Comicvine [t:title] [a:authors] [i:id] [-- -v]')
     option_parser.add_option('--opf', '-o', action='store_true',
                              dest='opf')
     option_parser.add_option('--verbose', '-v', default=False,
                              action='store_true', dest='verbose')
     return option_parser
Example #7
0
 def option_parser():
   'Parse command line options'
   parser = OptionParser(
     usage='Comicvine [t:title] [a:authors] [i:id]')
   parser.add_option('--verbose', '-v', default=False, 
                     action='store_true', dest='verbose')
   parser.add_option('--debug_api', default=False,
                     action='store_true', dest='debug_api')
   return parser
Example #8
0
def option_parser():
    parser =  OptionParser(_('''\
%prog [opts] [path_to_ebook]

Launch the calibre edit book tool.
'''))
    setup_gui_option_parser(parser)
    parser.add_option('--edit-file', help=_(
        'Edit the named file inside the book'))
    return parser
Example #9
0
def option_parser(usage='''\
Usage: %prog [options]

Launch the Graphical User Interface
'''):
    parser = OptionParser(usage)
    # The b is required because of a regression in optparse.py in python 2.7.0
    parser.add_option(b'--redirect-console-output', default=False, action='store_true', dest='redirect',
                      help=_('Redirect console output to a dialog window (both stdout and stderr). Useful on windows where GUI apps do not have a output streams.'))
    return parser
Example #10
0
def option_parser():
    parser = OptionParser(usage=_('''
%prog [options] ISBN

Fetch a cover image/social metadata for the book identified by ISBN from LibraryThing.com
'''))
    parser.add_option('-u', '--username', default=None,
                      help='Username for LibraryThing.com')
    parser.add_option('-p', '--password', default=None,
                      help='Password for LibraryThing.com')
    return parser
Example #11
0
def option_parser():
    from calibre.utils.config import OptionParser
    parser = OptionParser(usage='%prog: [options] file')
    parser.add_option('-v', '--verbose', default=False, action='store_true',
            dest='verbose',
            help='Show detailed output information. Useful for debugging')
    parser.add_option('-k', '--keep-elements', default=None, action='store',
            dest='keep_elements',
            help='XPath specifying elements that should not be removed')

    return parser
Example #12
0
def option_parser():
    parser = OptionParser(usage=USAGE)
    parser.add_option(
        "--list-recipes",
        default=False,
        action="store_true",
        help=_(
            "List builtin recipe names. You can create an ebook from "
            'a builtin recipe like this: ebook-convert "Recipe Name.recipe" '
            "output.epub"
        ),
    )
    return parser
Example #13
0
def get_parser(usage):
    parser = OptionParser(usage)
    go = parser.add_option_group(_('GLOBAL OPTIONS'))
    go.is_global_options = True
    go.add_option(
        '--library-path',
        '--with-library',
        default=None,
        help=_(
            'Path to the calibre library. Default is to use the path stored in the settings.'
            ' You can also connect to a calibre Content server to perform actions on'
            ' remote libraries. To do so use a URL of the form: http://hostname:port/#library_id'
            ' for example, http://localhost:8080/#mylibrary. library_id is the library id'
            ' of the library you want to connect to on the Content server. You can use'
            ' the special library_id value of - to get a list of library ids available'
            ' on the server. For details on how to setup access via a Content server, see'
            ' {}.'
        ).format(localize_user_manual_link(
            'https://manual.calibre-ebook.com/generated/en/calibredb.html'
        ))
    )
    go.add_option(
        '-h', '--help', help=_('show this help message and exit'), action='help'
    )
    go.add_option(
        '--version',
        help=_("show program's version number and exit"),
        action='version'
    )
    go.add_option(
        '--username',
        help=_('Username for connecting to a calibre Content server')
    )
    go.add_option(
        '--password',
        help=_('Password for connecting to a calibre Content server.'
               ' To read the password from standard input, use the special value: {0}.'
               ' To read the password from a file, use: {1} (i.e. <f: followed by the full path to the file and a trailing >).'
               ' The angle brackets in the above are required, remember to escape them or use quotes'
               ' for your shell.').format(
                   '<stdin>', '<f:C:/path/to/file>' if iswindows else '<f:/path/to/file>')
    )
    go.add_option(
        '--timeout',
        type=float,
        default=120,
        help=_('The timeout, in seconds, when connecting to a calibre library over the network. The default is'
               ' two minutes.')
    )

    return parser
Example #14
0
def option_parser():
    parser = OptionParser(
        _('''\
%prog [opts] [path_to_ebook] [name_of_file_inside_book ...]

Launch the calibre Edit book tool. You can optionally also specify the names of
files inside the book which will be opened for editing automatically.
'''))
    setup_gui_option_parser(parser)
    parser.add_option(
        '--select-text',
        default=None,
        help=_('The text to select in the book when it is opened for editing'))
    return parser
Example #15
0
def option_parser():
    parser = OptionParser(usage=_('%prog book.lrf\nConvert an LRF file into an LRS (XML UTF-8 encoded) file'))
    parser.add_option('--output', '-o', default=None, help=_('Output LRS file'), dest='out')
    parser.add_option('--dont-output-resources', default=True, action='store_false',
                      help=_('Do not save embedded image and font files to disk'),
                      dest='output_resources')
    parser.add_option('--verbose', default=False, action='store_true', dest='verbose', help=_('Be more verbose'))
    return parser
Example #16
0
def option_parser():
    parser = OptionParser(usage=_('%prog [options] file.lrs\nCompile an LRS file into an LRF file.'))
    parser.add_option('-o', '--output', default=None, help=_('Path to output file'))
    parser.add_option('--verbose', default=False, action='store_true',
                      help=_('Verbose processing'))
    parser.add_option('--lrs', default=False, action='store_true',
                      help=_('Convert LRS to LRS, useful for debugging.'))
    return parser
Example #17
0
def option_parser(usage='''\
Usage: %prog [options]

Launch the Graphical User Interface
'''):
    parser = OptionParser(usage)
    return parser
Example #18
0
def option_parser():
    from calibre.utils.config import OptionParser
    USAGE = '%prog [options] input_file [output_file]\n\n' + re.sub(
        r'<.*?>', '', CLI_HELP['about'])
    parser = OptionParser(usage=USAGE)
    a = parser.add_option
    o = partial(a, default=False, action='store_true')
    o('--embed-fonts', '-e', dest='embed', help=CLI_HELP['embed'])
    o('--subset-fonts', '-f', dest='subset', help=CLI_HELP['subset'])
    a('--cover',
      '-c',
      help=_(
          'Path to a cover image. Changes the cover specified in the ebook. '
          'If no cover is present, or the cover is not properly identified, inserts a new cover.'
      ))
    a('--opf',
      '-o',
      help=
      _('Path to an OPF file. The metadata in the book is updated from the OPF file.'
        ))
    o('--jacket', '-j', help=CLI_HELP['jacket'])
    o('--remove-jacket', help=CLI_HELP['remove_jacket'])
    o('--smarten-punctuation', '-p', help=CLI_HELP['smarten_punctuation'])
    o('--remove-unused-css', '-u', help=CLI_HELP['remove_unused_css'])

    o('--verbose',
      help=_('Produce more verbose output, useful for debugging.'))

    return parser
Example #19
0
def option_parser(usage='''\
Usage: %prog [options]

Launch the Graphical User Interface
'''):
    parser = OptionParser(usage)
    # The b is required because of a regression in optparse.py in python 2.7.0
    parser.add_option(
        b'--redirect-console-output',
        default=False,
        action='store_true',
        dest='redirect',
        help=
        _('Redirect console output to a dialog window (both stdout and stderr). Useful on windows where GUI apps do not have a output streams.'
          ))
    return parser
Example #20
0
def option_parser():
    from calibre.utils.config import OptionParser
    parser = OptionParser()
    parser.add_option('--make-errors-fatal', action='store_true', default=False,
                      dest='fatal_errors', help='If set die on errors.')
    parser.add_option('--root', dest='staging_root', default='/usr',
            help='Prefix under which to install files')
    parser.add_option('--bindir', default=None, dest='staging_bindir',
        help='Location where calibre launcher scripts were installed. Typically /usr/bin')
    parser.add_option('--sharedir', default=None, dest='staging_sharedir',
        help='Location where calibre resources were installed, typically /usr/share/calibre')

    return parser
Example #21
0
def option_parser():
    parser = OptionParser('''\
%prog [opts] [path_to_ebook]

Launch the calibre tweak book tool.
''')
    setup_gui_option_parser(parser)
    return parser
Example #22
0
 def option_parser():
   'Parse command line options'
   parser = OptionParser(
     usage='Comicvine [t:title] [a:authors] [i:id]')
   parser.add_option('--opf', '-o', action='store_true', dest='opf')
   parser.add_option('--verbose', '-v', default=False, 
                     action='store_true', dest='verbose')
   parser.add_option('--debug_api', default=False,
                     action='store_true', dest='debug_api')
   return parser
Example #23
0
def option_parser():
    import textwrap
    from calibre.utils.config import OptionParser
    parser = OptionParser(usage=textwrap.dedent('''\
            %prog [options] input_font_file output_font_file characters_to_keep

            Subset the specified font, keeping only the glyphs for the characters in
            characters_to_keep. characters_to_keep is a comma separated list of characters of
            the form: a,b,c,A-Z,0-9,xyz

            You can specify ranges in the list of characters, as shown above.
            '''))
    parser.add_option('-c', '--codes', default=False, action='store_true',
            help='If specified, the list of characters is interpreted as '
            'numeric unicode codes instead of characters. So to specify the '
            'characters a,b you would use 97,98')
    parser.prog = 'subset-font'
    return parser
Example #24
0
def option_parser():
    parser =  OptionParser(_('''\
%prog [opts] [path_to_ebook] [name_of_file_inside_book ...]

Launch the calibre edit book tool. You can optionally also specify the names of
files inside the book which will be opened for editing automatically.
'''))
    setup_gui_option_parser(parser)
    return parser
Example #25
0
def option_parser():
    import textwrap
    from calibre.utils.config import OptionParser
    parser = OptionParser(usage=textwrap.dedent('''\
            %prog [options] input_font_file output_font_file characters_to_keep

            Subset the specified font, keeping only the glyphs for the characters in
            characters_to_keep. characters_to_keep is a comma separated list of characters of
            the form: a,b,c,A-Z,0-9,xyz

            You can specify ranges in the list of characters, as shown above.
            '''))
    parser.add_option('-c', '--codes', default=False, action='store_true',
            help='If specified, the list of characters is interpreted as '
            'numeric unicode codes instead of characters. So to specify the '
            'characters a,b you would use 97,98')
    parser.prog = 'subset-font'
    return parser
Example #26
0
def get_parser(usage):
    parser = OptionParser(usage)
    go = parser.add_option_group(_('GLOBAL OPTIONS'))
    go.is_global_options = True
    go.add_option(
        '--library-path',
        '--with-library',
        default=None,
        help=_(
            'Path to the calibre library. Default is to use the path stored in the settings.'
            ' You can also connect to a calibre Content server to perform actions on'
            ' remote libraries. To do so use a URL of the form: http://hostname:port/#library_id'
            ' for example, http://localhost:8080/#mylibrary. library_id is the library id'
            ' of the library you want to connect to on the Content server. You can use'
            ' the special library_id value of - to get a list of library ids available'
            ' on the server. For details on how to setup access via a Content server, see'
            ' {}.'
        ).format(localize_user_manual_link(
            'https://manual.calibre-ebook.com/generated/en/calibredb.html'
        ))
    )
    go.add_option(
        '-h', '--help', help=_('show this help message and exit'), action='help'
    )
    go.add_option(
        '--version',
        help=_("show program's version number and exit"),
        action='version'
    )
    go.add_option(
        '--username',
        help=_('Username for connecting to a calibre Content server')
    )
    go.add_option(
        '--password',
        help=_('Password for connecting to a calibre Content server.'
               ' To read the password from standard input, use the special value: {0}.'
               ' To read the password from a file, use: {1} (i.e. <f: followed by the full path to the file and a trailing >).'
               ' The angle brackets in the above are required, remember to escape them or use quotes'
               ' for your shell.').format(
                   '<stdin>', '<f:C:/path/to/file>' if iswindows else '<f:/path/to/file>')
    )

    return parser
Example #27
0
def option_parser():
    parser = OptionParser(usage=_('%prog [options] file.lrs\nCompile an LRS file into an LRF file.'))
    parser.add_option('-o', '--output', default=None, help=_('Path to output file'))
    parser.add_option('--verbose', default=False, action='store_true',
                      help=_('Verbose processing'))
    parser.add_option('--lrs', default=False, action='store_true',
                      help=_('Convert LRS to LRS, useful for debugging.'))
    return parser
Example #28
0
def option_parser():
    parser = OptionParser(usage=_(
        '%prog [options] file.epub\n\n'
        'Fix common problems in EPUB files that can cause them '
        'to be rejected by poorly designed publishing services.\n\n'
        'By default, no fixing is done and messages are printed out '
        'for each error detected. Use the options to control which errors '
        'are automatically fixed.'))
    for fixer in epub_fixers():
        fixer.add_options_to_parser(parser)

    return parser
Example #29
0
def get_parser(usage):
    parser = OptionParser(usage)
    go = parser.add_option_group(_('GLOBAL OPTIONS'))
    go.is_global_options = True
    go.add_option(
        '--library-path',
        '--with-library',
        default=None,
        help=
        _('Path to the calibre library. Default is to use the path stored in the settings.'
          ' You can also connect to a calibre Content server to perform actions on'
          ' remote libraries. To do so use a URL of the form: http://hostname:port/#library_id'
          ' for example, http://localhost:8080/#mylibrary. library_id is the library id'
          ' of the library you want to connect to on the Content server. You can use'
          ' the special library_id value of - to get a list of library ids available'
          ' on the server. For details on how to setup access via a Content server, see'
          ' {}.').
        format(
            localize_user_manual_link(
                'https://manual.calibre-ebook.com/generated/en/calibredb.html')
        ))
    go.add_option('-h',
                  '--help',
                  help=_('show this help message and exit'),
                  action='help')
    go.add_option('--version',
                  help=_("show program's version number and exit"),
                  action='version')
    go.add_option(
        '--username',
        help=_('Username for connecting to a calibre Content server'))
    go.add_option(
        '--password',
        help=_(
            'Password for connecting to a calibre Content server.'
            ' To read the password from standard input, use the special value: {}.'
            ' To read the password from a file, use: {}.)').format(
                '<stdin>', '<f:/path/to/file>'))

    return parser
Example #30
0
def option_parser():
    parser = OptionParser(_(
'''\
%%prog command [options] [arguments]

%%prog is the command line interface to the calibre books database.

command is one of:
  %s

For help on an individual command: %%prog command --help
'''
                          )%'\n  '.join(COMMANDS))
    return parser
Example #31
0
def option_parser():
    from calibre.utils.config import OptionParser
    parser = OptionParser(usage='%prog: [options] file')
    parser.add_option('-v', '--verbose', default=False, action='store_true',
            dest='verbose',
            help='Show detailed output information. Useful for debugging')
    parser.add_option('-k', '--keep-elements', default=None, action='store',
            dest='keep_elements',
            help='XPath specifying elements that should not be removed')

    return parser
Example #32
0
def option_parser():
    from calibre.utils.config import OptionParser

    parser = OptionParser()
    parser.add_option(
        "--make-errors-fatal", action="store_true", default=False, dest="fatal_errors", help="If set die on errors."
    )
    parser.add_option("--root", dest="staging_root", default="/usr", help="Prefix under which to install files")
    parser.add_option(
        "--bindir",
        default=None,
        dest="staging_bindir",
        help="Location where calibre launcher scripts were installed. Typically /usr/bin",
    )
    parser.add_option(
        "--sharedir",
        default=None,
        dest="staging_sharedir",
        help="Location where calibre resources were installed, typically /usr/share/calibre",
    )

    return parser
Example #33
0
def opts_to_parser(usage):
    from calibre.utils.config import OptionParser
    parser =  OptionParser(usage)
    for opt in options.itervalues():
        add_option = partial(parser.add_option, dest=opt.name, help=opt_to_cli_help(opt), default=opt.default)
        if opt.default is True or opt.default is False:
            boolean_option(add_option, opt)
        elif opt.choices:
            name = '--' + opt.name.replace('_', '-')
            add_option(name, choices=opt.choices)
        else:
            name = '--' + opt.name.replace('_', '-')
            otype = 'string'
            if isinstance(opt.default, (int, long, float)):
                otype = type(opt.default).__name__
            add_option(name, type=otype)

    return parser
Example #34
0
 def option_parser():
     """Parse command line options."""
     option_parser = OptionParser(
         usage='Comicvine [t:title] [a:authors] [i:id] [-- -v]')
     option_parser.add_option('--opf',
                              '-o',
                              action='store_true',
                              dest='opf')
     option_parser.add_option('--verbose',
                              '-v',
                              default=False,
                              action='store_true',
                              dest='verbose')
     return option_parser
Example #35
0
def option_parser():
    parser = OptionParser(usage='%prog book.lrf')
    parser.add_option(
        '--output-dir',
        '-o',
        default=None,
        help=
        'Output directory in which to store created HTML files. If it does not exist, it is created. By default the current directory is used.',
        dest='out')
    parser.add_option('--verbose',
                      default=False,
                      action='store_true',
                      dest='verbose')
    return parser
Example #36
0
def option_parser():
    parser = OptionParser(usage=_('''
%prog [options] ISBN

Fetch a cover image/social metadata for the book identified by ISBN from LibraryThing.com
'''))
    parser.add_option('-u',
                      '--username',
                      default=None,
                      help='Username for LibraryThing.com')
    parser.add_option('-p',
                      '--password',
                      default=None,
                      help='Password for LibraryThing.com')
    return parser
Example #37
0
def option_parser(
        usage=_('%prog URL\n\nWhere URL is for example https://google.com')):
    parser = OptionParser(usage=usage)
    parser.add_option(
        '-d',
        '--base-dir',
        help=_('Base directory into which URL is saved. Default is %default'),
        default='.',
        type='string',
        dest='dir')
    parser.add_option(
        '-t',
        '--timeout',
        help=
        _('Timeout in seconds to wait for a response from the server. Default: %default s'
          ),
        default=10.0,
        type='float',
        dest='timeout')
    parser.add_option(
        '-r',
        '--max-recursions',
        default=1,
        help=
        _('Maximum number of levels to recurse i.e. depth of links to follow. Default %default'
          ),
        type='int',
        dest='max_recursions')
    parser.add_option(
        '-n',
        '--max-files',
        default=sys.maxint,
        type='int',
        dest='max_files',
        help=
        _('The maximum number of files to download. This only applies to files from <a href> tags. Default is %default'
          ))
    parser.add_option(
        '--delay',
        default=0,
        dest='delay',
        type='float',
        help=
        _('Minimum interval in seconds between consecutive fetches. Default is %default s'
          ))
    parser.add_option(
        '--encoding',
        default=None,
        help=
        _('The character encoding for the websites you are trying to download. The default is to try and guess the encoding.'
          ))
    parser.add_option(
        '--match-regexp',
        default=[],
        action='append',
        dest='match_regexps',
        help=
        _('Only links that match this regular expression will be followed. '
          'This option can be specified multiple times, in which case as long '
          'as a link matches any one regexp, it will be followed. By default all '
          'links are followed.'))
    parser.add_option(
        '--filter-regexp',
        default=[],
        action='append',
        dest='filter_regexps',
        help=_(
            'Any link that matches this regular expression will be ignored.'
            ' This option can be specified multiple times, in which case as'
            ' long as any regexp matches a link, it will be ignored. By'
            ' default, no links are ignored. If both filter regexp and match'
            ' regexp are specified, then filter regexp is applied first.'))
    parser.add_option('--dont-download-stylesheets',
                      action='store_true',
                      default=False,
                      help=_('Do not download CSS stylesheets.'),
                      dest='no_stylesheets')
    parser.add_option(
        '--verbose',
        help=_('Show detailed output information. Useful for debugging'),
        default=False,
        action='store_true',
        dest='verbose')
    return parser
Example #38
0
def option_parser():
    parser = OptionParser(_('''\
%prog [options]

Fetch book metadata from online sources. You must specify at least one
of title, authors or ISBN.
'''
    ))
    parser.add_option('-t', '--title', help=_('Book title'))
    parser.add_option('-a', '--authors', help=_('Book author(s)'))
    parser.add_option('-i', '--isbn', help=_('Book ISBN'))
    parser.add_option('-I', '--identifier', action='append', default=[], help=_(
        'Identifiers such as ASIN/goodreads id etc. Can be specified multiple times for multiple identifiers.'
        ' For example: ') + '--identifier asin:B0082BAJA0')
    parser.add_option('-v', '--verbose', default=False, action='store_true',
                      help=_('Print the log to the console (stderr)'))
    parser.add_option('-o', '--opf', help=_('Output the metadata in OPF format instead of human readable text.'), action='store_true', default=False)
    parser.add_option('-c', '--cover',
            help=_('Specify a filename. The cover, if available, will be saved to it. Without this option, no cover will be downloaded.'))
    parser.add_option('-d', '--timeout', default='30',
            help=_('Timeout in seconds. Default is 30'))
    parser.add_option('-p', '--allowed-plugin', action='append', default=[],
            help=_('Specify the name of a metadata download plugin to use.'
                   ' By default, all metadata plugins will be used.'
                   ' Can be specified multiple times for multiple plugins.'
                   ' All plugin names: {}').format(', '.join(p.name for p in all_metadata_plugins())))

    return parser
Example #39
0
def option_parser():
    parser = OptionParser(usage=_('''\
    %prog options

    Customize calibre by loading external plugins.
    '''))
    parser.add_option(
        '-a',
        '--add-plugin',
        default=None,
        help=_(
            'Add a plugin by specifying the path to the zip file containing it.'
        ))
    parser.add_option(
        '-b',
        '--build-plugin',
        default=None,
        help=_('For plugin developers: Path to the directory where you are'
               ' developing the plugin. This command will automatically zip '
               'up the plugin and update it in calibre.'))
    parser.add_option(
        '-r',
        '--remove-plugin',
        default=None,
        help=_(
            'Remove a custom plugin by name. Has no effect on builtin plugins')
    )
    parser.add_option(
        '--customize-plugin',
        default=None,
        help=
        _('Customize plugin. Specify name of plugin and customization string separated by a comma.'
          ))
    parser.add_option('-l',
                      '--list-plugins',
                      default=False,
                      action='store_true',
                      help=_('List all installed plugins'))
    parser.add_option('--enable-plugin',
                      default=None,
                      help=_('Enable the named plugin'))
    parser.add_option('--disable-plugin',
                      default=None,
                      help=_('Disable the named plugin'))
    return parser
Example #40
0
def option_parser():
    from calibre.utils.config import OptionParser
    from calibre.constants import __appname__, __version__
    parser = OptionParser(usage=_('''%prog [options] mybook.lrf


Show/edit the metadata in an LRF file.\n\n'''),
                          version=__appname__ + ' ' + __version__,
                          epilog='Created by Kovid Goyal')
    parser.add_option("-t",
                      "--title",
                      action="store",
                      type="string",
                      dest="title",
                      help=_("Set the book title"))
    parser.add_option('--title-sort',
                      action='store',
                      type='string',
                      default=None,
                      dest='title_reading',
                      help=_('Set sort key for the title'))
    parser.add_option("-a",
                      "--author",
                      action="store",
                      type="string",
                      dest="author",
                      help=_("Set the author"))
    parser.add_option('--author-sort',
                      action='store',
                      type='string',
                      default=None,
                      dest='author_reading',
                      help=_('Set sort key for the author'))
    parser.add_option("-c",
                      "--category",
                      action="store",
                      type="string",
                      dest="category",
                      help=_("The category this book belongs"
                             " to. E.g.: History"))
    parser.add_option("--thumbnail",
                      action="store",
                      type="string",
                      dest="thumbnail",
                      help=_("Path to a graphic that will be"
                             " set as this files' thumbnail"))
    parser.add_option("--comment",
                      action="store",
                      type="string",
                      dest="comment",
                      help=_("Path to a TXT file containing the "
                             "comment to be stored in the LRF file."))
    parser.add_option("--get-thumbnail",
                      action="store_true",
                      dest="get_thumbnail",
                      default=False,
                      help=_("Extract thumbnail from LRF file"))
    parser.add_option('--publisher', default=None, help=_('Set the publisher'))
    parser.add_option('--classification',
                      default=None,
                      help=_('Set the book classification'))
    parser.add_option('--creator',
                      default=None,
                      help=_('Set the book creator'))
    parser.add_option('--producer',
                      default=None,
                      help=_('Set the book producer'))
    parser.add_option(
        '--get-cover',
        action='store_true',
        default=False,
        help=
        _('Extract cover from LRF file. Note that the LRF format has no defined cover, so we use some heuristics to guess the cover.'
          ))
    parser.add_option('--bookid',
                      action='store',
                      type='string',
                      default=None,
                      dest='book_id',
                      help=_('Set book ID'))
    # The SumPage element specifies the number of "View"s (visible pages for the BookSetting element conditions) of the content.
    # Basically, the total pages per the page size, font size, etc. when the
    # LRF is first created. Since this will change as the book is reflowed, it
    # is probably not worth using.
    # parser.add_option("-p", "--page", action="store", type="string", \
    #                dest="page", help=_("Don't know what this is for"))

    return parser
Example #41
0
def option_parser():
    parser = OptionParser(
        usage="""\
%prog [options]

Run an embedded python interpreter.
"""
    )
    parser.add_option("-c", "--command", help="Run python code.", default=None)
    parser.add_option("-e", "--exec-file", default=None, help="Run the python code in file.")
    parser.add_option(
        "-d", "--debug-device-driver", default=False, action="store_true", help="Debug the specified device driver."
    )
    parser.add_option(
        "-g",
        "--gui",
        default=False,
        action="store_true",
        help="Run the GUI with debugging enabled. Debug output is " "printed to stdout and stderr.",
    )
    parser.add_option(
        "--gui-debug",
        default=None,
        help="Run the GUI with a debug console, logging to the"
        " specified path. For internal use only, use the -g"
        " option to run the GUI in debug mode",
    )
    parser.add_option(
        "--show-gui-debug", default=None, help="Display the specified log file. For internal use" " only."
    )
    parser.add_option("-w", "--viewer", default=False, action="store_true", help="Run the ebook viewer")
    parser.add_option(
        "--paths",
        default=False,
        action="store_true",
        help="Output the paths necessary to setup the calibre environment",
    )
    parser.add_option(
        "--migrate",
        action="store_true",
        default=False,
        help="Migrate old database. Needs two arguments. Path " "to library1.db and path to new library folder.",
    )
    parser.add_option(
        "--add-simple-plugin",
        default=None,
        help="Add a simple plugin (i.e. a plugin that consists of only a "
        ".py file), by specifying the path to the py file containing the "
        "plugin code.",
    )
    parser.add_option(
        "--reinitialize-db",
        default=None,
        help="Re-initialize the sqlite calibre database at the "
        "specified path. Useful to recover from db corruption."
        " You can also specify the path to an SQL dump which "
        "will be used instead of trying to dump the database."
        " This can be useful when dumping fails, but dumping "
        "with sqlite3 works.",
    )
    parser.add_option("-p", "--py-console", help="Run python console", default=False, action="store_true")
    parser.add_option(
        "-m",
        "--inspect-mobi",
        action="store_true",
        default=False,
        help="Inspect the MOBI file(s) at the specified path(s)",
    )
    parser.add_option(
        "--tweak-book",
        default=None,
        help="Tweak the book (exports the book as a collection of HTML "
        "files and metadata, which you can edit using standard HTML "
        "editing tools, and then rebuilds the file from the edited HTML. "
        "Makes no additional changes to the HTML, unlike a full calibre "
        "conversion).",
    )
    parser.add_option(
        "-s",
        "--shutdown-running-calibre",
        default=False,
        action="store_true",
        help=_(
            "Cause a running calibre instance, if any, to be"
            " shutdown. Note that if there are running jobs, they "
            "will be silently aborted, so use with care."
        ),
    )

    parser.add_option("--test-build", help="Test binary modules in build", action="store_true", default=False)

    return parser
Example #42
0
def option_parser():
    parser = OptionParser(
        usage="""\
%prog [options]

Various command line interfaces useful for debugging calibre. With no options,
this command starts an embedded python interpreter. You can also run the main
calibre GUI and the calibre viewer in debug mode.

It also contains interfaces to various bits of calibre that do not have
dedicated command line tools, such as font subsetting, tweaking ebooks and so
on.

You can also use %prog to run standalone scripts. To do that use it like this:

    %prog mysrcipt.py -- --option1 --option2 file1 file2 ...

Everything after the -- is passed to the script.
"""
    )
    parser.add_option("-c", "--command", help="Run python code.")
    parser.add_option("-e", "--exec-file", help="Run the python code in file.")
    parser.add_option("-f", "--subset-font", help="Subset the specified font")
    parser.add_option("-d", "--debug-device-driver", default=False, action="store_true", help="Debug device detection")
    parser.add_option(
        "-g",
        "--gui",
        default=False,
        action="store_true",
        help="Run the GUI with debugging enabled. Debug output is " "printed to stdout and stderr.",
    )
    parser.add_option(
        "--gui-debug",
        default=None,
        help="Run the GUI with a debug console, logging to the"
        " specified path. For internal use only, use the -g"
        " option to run the GUI in debug mode",
    )
    parser.add_option(
        "--show-gui-debug", default=None, help="Display the specified log file. For internal use" " only."
    )
    parser.add_option("-w", "--viewer", default=False, action="store_true", help="Run the ebook viewer")
    parser.add_option(
        "--paths",
        default=False,
        action="store_true",
        help="Output the paths necessary to setup the calibre environment",
    )
    parser.add_option(
        "--add-simple-plugin",
        default=None,
        help="Add a simple plugin (i.e. a plugin that consists of only a "
        ".py file), by specifying the path to the py file containing the "
        "plugin code.",
    )
    parser.add_option(
        "--reinitialize-db",
        default=None,
        help="Re-initialize the sqlite calibre database at the "
        "specified path. Useful to recover from db corruption.",
    )
    parser.add_option("-p", "--py-console", help="Run python console", default=False, action="store_true")
    parser.add_option(
        "-m",
        "--inspect-mobi",
        action="store_true",
        default=False,
        help="Inspect the MOBI file(s) at the specified path(s)",
    )
    parser.add_option(
        "-t",
        "--tweak-book",
        default=None,
        help="Tweak the book (exports the book as a collection of HTML "
        "files and metadata, which you can edit using standard HTML "
        "editing tools, and then rebuilds the file from the edited HTML. "
        "Makes no additional changes to the HTML, unlike a full calibre "
        "conversion).",
    )
    parser.add_option(
        "-s",
        "--shutdown-running-calibre",
        default=False,
        action="store_true",
        help=_(
            "Cause a running calibre instance, if any, to be"
            " shutdown. Note that if there are running jobs, they "
            "will be silently aborted, so use with care."
        ),
    )
    parser.add_option("--test-build", help="Test binary modules in build", action="store_true", default=False)
    parser.add_option(
        "-r",
        "--run-plugin",
        help=_(
            "Run a plugin that provides a command line interface. For example:\n"
            'calibre-debug -r "Add Books" -- file1 --option1\n'
            "Everything after the -- will be passed to the plugin as arguments."
        ),
    )

    return parser
Example #43
0
def option_parser():
    parser = OptionParser(usage='''\
%prog [options]

Various command line interfaces useful for debugging calibre. With no options,
this command starts an embedded python interpreter. You can also run the main
calibre GUI and the calibre viewer in debug mode.

It also contains interfaces to various bits of calibre that do not have
dedicated command line tools, such as font subsetting, tweaking ebooks and so
on.

You can also use %prog to run standalone scripts. To do that use it like this:

    %prog mysrcipt.py -- --option1 --option2 file1 file2 ...

Everything after the -- is passed to the script.
''')
    parser.add_option('-c', '--command', help='Run python code.')
    parser.add_option('-e', '--exec-file', help='Run the python code in file.')
    parser.add_option('-f', '--subset-font', help='Subset the specified font')
    parser.add_option('-d', '--debug-device-driver', default=False, action='store_true',
                      help='Debug device detection')
    parser.add_option('-g', '--gui',  default=False, action='store_true',
                      help='Run the GUI with debugging enabled. Debug output is '
                      'printed to stdout and stderr.')
    parser.add_option('--gui-debug',  default=None,
                      help='Run the GUI with a debug console, logging to the'
                      ' specified path. For internal use only, use the -g'
                      ' option to run the GUI in debug mode',)
    parser.add_option('--show-gui-debug',  default=None,
                      help='Display the specified log file. For internal use'
                      ' only.',)
    parser.add_option('-w', '--viewer',  default=False, action='store_true',
                      help='Run the ebook viewer',)
    parser.add_option('--paths', default=False, action='store_true',
            help='Output the paths necessary to setup the calibre environment')
    parser.add_option('--add-simple-plugin', default=None,
            help='Add a simple plugin (i.e. a plugin that consists of only a '
            '.py file), by specifying the path to the py file containing the '
            'plugin code.')
    parser.add_option('--reinitialize-db', default=None,
            help='Re-initialize the sqlite calibre database at the '
            'specified path. Useful to recover from db corruption.')
    parser.add_option('-p', '--py-console', help='Run python console',
            default=False, action='store_true')
    parser.add_option('-m', '--inspect-mobi', action='store_true',
            default=False,
            help='Inspect the MOBI file(s) at the specified path(s)')
    parser.add_option('-t', '--tweak-book', action='store_true',
            help='Launch the calibre Tweak Book tool in debug mode.')
    parser.add_option('-s', '--shutdown-running-calibre', default=False,
            action='store_true',
            help=_('Cause a running calibre instance, if any, to be'
                ' shutdown. Note that if there are running jobs, they '
                'will be silently aborted, so use with care.'))
    parser.add_option('--test-build', help='Test binary modules in build',
            action='store_true', default=False)
    parser.add_option('-r', '--run-plugin', help=_(
        'Run a plugin that provides a command line interface. For example:\n'
        'calibre-debug -r "Add Books" -- file1 --option1\n'
        'Everything after the -- will be passed to the plugin as arguments.'))

    return parser
Example #44
0
def option_parser():
    parser = OptionParser(usage='%prog book.lrf')
    parser.add_option('--output-dir', '-o', default=None, help=(
        'Output directory in which to store created HTML files. If it does not exist, it is created. By default the current directory is used.'), dest='out')
    parser.add_option('--verbose', default=False, action='store_true', dest='verbose')
    return parser
Example #45
0
def option_parser():
    parser = OptionParser(usage=_('''\
{0}

Various command line interfaces useful for debugging calibre. With no options,
this command starts an embedded Python interpreter. You can also run the main
calibre GUI, the calibre viewer and the calibre editor in debug mode.

It also contains interfaces to various bits of calibre that do not have
dedicated command line tools, such as font subsetting, the e-book diff tool and so
on.

You can also use %prog to run standalone scripts. To do that use it like this:

    {1}

Everything after the -- is passed to the script.
''').format(_('%prog [options]'), '%prog myscript.py -- --option1 --option2 file1 file2 ...'))
    parser.add_option('-c', '--command', help=_('Run Python code.'))
    parser.add_option('-e', '--exec-file', help=_('Run the Python code in file.'))
    parser.add_option('-f', '--subset-font', action='store_true', default=False,
                      help=_('Subset the specified font. Use -- after this option to pass option to the font subsetting program.'))
    parser.add_option('-d', '--debug-device-driver', default=False, action='store_true',
                      help=_('Debug device detection'))
    parser.add_option('-g', '--gui',  default=False, action='store_true',
                      help=_('Run the GUI with debugging enabled. Debug output is '
                      'printed to stdout and stderr.'))
    parser.add_option('--gui-debug',  default=None,
                      help=_('Run the GUI with a debug console, logging to the'
                      ' specified path. For internal use only, use the -g'
                      ' option to run the GUI in debug mode'))
    parser.add_option('-w', '--viewer',  default=False, action='store_true',
                      help=_('Run the E-book viewer in debug mode'))
    parser.add_option('--paths', default=False, action='store_true',
            help=_('Output the paths necessary to setup the calibre environment'))
    parser.add_option('--add-simple-plugin', default=None,
            help=_('Add a simple plugin (i.e. a plugin that consists of only a '
            '.py file), by specifying the path to the py file containing the '
            'plugin code.'))
    parser.add_option('--reinitialize-db', default=None,
            help=_('Re-initialize the sqlite calibre database at the '
            'specified path. Useful to recover from db corruption.'))
    parser.add_option('-m', '--inspect-mobi', action='store_true',
            default=False,
            help=_('Inspect the MOBI file(s) at the specified path(s)'))
    parser.add_option('-t', '--edit-book', action='store_true',
            help=_('Launch the calibre "Edit book" tool in debug mode.'))
    parser.add_option('-x', '--explode-book', default=False, action='store_true',
            help=_('Explode the book into the specified directory.\nUsage: '
            '-x file.epub output_dir\n'
            'Exports the book as a collection of HTML '
            'files and metadata, which you can edit using standard HTML '
            'editing tools. Works with EPUB, AZW3, HTMLZ and DOCX files.'))
    parser.add_option('-i', '--implode-book', default=False, action='store_true', help=_(
        'Implode a previously exploded book.\nUsage: -i output_dir file.epub\n'
        'Imports the book from the files in output_dir which must have'
        ' been created by a previous call to --explode-book. Be sure to'
        ' specify the same file type as was used when exploding.'))
    parser.add_option('--export-all-calibre-data', default=False, action='store_true',
        help=_('Export all calibre data (books/settings/plugins). Normally, you will'
            ' be asked for the export dir and the libraries to export. You can also specify them'
            ' as command line arguments to skip the questions.'
            ' Use absolute paths for the export directory and libraries.'
            ' The special keyword "all" can be used to export all libraries.'))
    parser.add_option('--import-calibre-data', default=False, action='store_true',
        help=_('Import previously exported calibre data'))
    parser.add_option('-s', '--shutdown-running-calibre', default=False,
            action='store_true',
            help=_('Cause a running calibre instance, if any, to be'
                ' shutdown. Note that if there are running jobs, they '
                'will be silently aborted, so use with care.'))
    parser.add_option('--test-build', help=_('Test binary modules in build'),
            action='store_true', default=False)
    parser.add_option('-r', '--run-plugin', help=_(
        'Run a plugin that provides a command line interface. For example:\n'
        'calibre-debug -r "Add Books" -- file1 --option1\n'
        'Everything after the -- will be passed to the plugin as arguments.'))
    parser.add_option('--diff', action='store_true', default=False, help=_(
        'Run the calibre diff tool. For example:\n'
        'calibre-debug --diff file1 file2'))
    parser.add_option('--default-programs', default=None, choices=['register', 'unregister'],
                          help=_('(Un)register calibre from Windows Default Programs.') + ' --default-programs=(register|unregister)')

    return parser
Example #46
0
def get_parser(usage):
    parser = OptionParser(usage)
    go = parser.add_option_group(_('GLOBAL OPTIONS'))
    go.add_option('--library-path', '--with-library', default=None, help=_('Path to the calibre library. Default is to use the path stored in the settings.'))

    return parser
Example #47
0
def option_parser():
    parser = OptionParser(usage=_('''\
{0}

Various command line interfaces useful for debugging calibre. With no options,
this command starts an embedded python interpreter. You can also run the main
calibre GUI, the calibre viewer and the calibre editor in debug mode.

It also contains interfaces to various bits of calibre that do not have
dedicated command line tools, such as font subsetting, the ebook diff tool and so
on.

You can also use %prog to run standalone scripts. To do that use it like this:

    {1}

Everything after the -- is passed to the script.
''').format('%prog [options]',
            '%prog myscript.py -- --option1 --option2 file1 file2 ...'))
    parser.add_option('-c', '--command', help=_('Run python code.'))
    parser.add_option('-e',
                      '--exec-file',
                      help=_('Run the python code in file.'))
    parser.add_option(
        '-f',
        '--subset-font',
        action='store_true',
        default=False,
        help=
        _('Subset the specified font. Use -- after this option to pass option to the font subsetting program.'
          ))
    parser.add_option('-d',
                      '--debug-device-driver',
                      default=False,
                      action='store_true',
                      help=_('Debug device detection'))
    parser.add_option(
        '-g',
        '--gui',
        default=False,
        action='store_true',
        help=_('Run the GUI with debugging enabled. Debug output is '
               'printed to stdout and stderr.'))
    parser.add_option('--gui-debug',
                      default=None,
                      help=_(
                          'Run the GUI with a debug console, logging to the'
                          ' specified path. For internal use only, use the -g'
                          ' option to run the GUI in debug mode'))
    parser.add_option('-w',
                      '--viewer',
                      default=False,
                      action='store_true',
                      help=_('Run the ebook viewer in debug mode'))
    parser.add_option(
        '--paths',
        default=False,
        action='store_true',
        help=_('Output the paths necessary to setup the calibre environment'))
    parser.add_option(
        '--add-simple-plugin',
        default=None,
        help=_(
            'Add a simple plugin (i.e. a plugin that consists of only a '
            '.py file), by specifying the path to the py file containing the '
            'plugin code.'))
    parser.add_option(
        '--reinitialize-db',
        default=None,
        help=_('Re-initialize the sqlite calibre database at the '
               'specified path. Useful to recover from db corruption.'))
    parser.add_option('-p',
                      '--py-console',
                      help=_('Run python console'),
                      default=False,
                      action='store_true')
    parser.add_option(
        '-m',
        '--inspect-mobi',
        action='store_true',
        default=False,
        help=_('Inspect the MOBI file(s) at the specified path(s)'))
    parser.add_option(
        '-t',
        '--edit-book',
        action='store_true',
        help=_('Launch the calibre Edit Book tool in debug mode.'))
    parser.add_option(
        '-x',
        '--explode-book',
        default=None,
        help=_(
            'Explode the book (exports the book as a collection of HTML '
            'files and metadata, which you can edit using standard HTML '
            'editing tools, and then rebuilds the file from the edited HTML. '
            'Makes no additional changes to the HTML, unlike a full calibre '
            'conversion).'))
    parser.add_option(
        '-s',
        '--shutdown-running-calibre',
        default=False,
        action='store_true',
        help=_('Cause a running calibre instance, if any, to be'
               ' shutdown. Note that if there are running jobs, they '
               'will be silently aborted, so use with care.'))
    parser.add_option('--test-build',
                      help=_('Test binary modules in build'),
                      action='store_true',
                      default=False)
    parser.add_option(
        '-r',
        '--run-plugin',
        help=
        _('Run a plugin that provides a command line interface. For example:\n'
          'calibre-debug -r "Add Books" -- file1 --option1\n'
          'Everything after the -- will be passed to the plugin as arguments.'
          ))
    parser.add_option('--diff',
                      action='store_true',
                      default=False,
                      help=_('Run the calibre diff tool. For example:\n'
                             'calibre-debug --diff file1 file2'))
    parser.add_option(
        '--default-programs',
        default=None,
        choices=['register', 'unregister'],
        help=_('(Un)register calibre from Windows Default Programs.') +
        ' --default-programs=(register|unregister)')
    parser.add_option(
        '--new-server',
        action='store_true',
        help=
        'Run the new calibre content server. Any options specified after a -- will be passed to the server.'
    )

    return parser
Example #48
0
def option_parser():
    parser = OptionParser(_('''\
%prog [options]

Fetch book metadata from online sources. You must specify at least one
of title, authors or ISBN.
'''
    ))
    parser.add_option('-t', '--title', help=_('Book title'))
    parser.add_option('-a', '--authors', help=_('Book author(s)'))
    parser.add_option('-i', '--isbn', help=_('Book ISBN'))
    parser.add_option('-I', '--identifier', action='append', default=[], help=_(
        'Identifiers such as ASIN/goodreads id etc. Can be specified multiple times for multiple identifiers.'
        ' For example: ') + '--identifier asin:B0082BAJA0')
    parser.add_option('-v', '--verbose', default=False, action='store_true',
                      help=_('Print the log to the console (stderr)'))
    parser.add_option('-o', '--opf', help=_('Output the metadata in OPF format instead of human readable text.'), action='store_true', default=False)
    parser.add_option('-c', '--cover',
            help=_('Specify a filename. The cover, if available, will be saved to it. Without this option, no cover will be downloaded.'))
    parser.add_option('-d', '--timeout', default='30',
            help=_('Timeout in seconds. Default is 30'))
    parser.add_option('-p', '--allowed-plugin', action='append', default=[],
            help=_('Specify the name of a metadata download plugin to use.'
                   ' By default, all metadata plugins will be used.'
                   ' Can be specified multiple times for multiple plugins.'
                   ' All plugin names: {}').format(', '.join(p.name for p in all_metadata_plugins())))

    return parser
Example #49
0
def option_parser(usage=_('%prog URL\n\nWhere URL is for example http://google.com')):
    parser = OptionParser(usage=usage)
    parser.add_option('-d', '--base-dir',
                      help=_('Base directory into which URL is saved. Default is %default'),
                      default='.', type='string', dest='dir')
    parser.add_option('-t', '--timeout',
                      help=_('Timeout in seconds to wait for a response from the server. Default: %default s'),
                      default=10.0, type='float', dest='timeout')
    parser.add_option('-r', '--max-recursions', default=1,
                      help=_('Maximum number of levels to recurse i.e. depth of links to follow. Default %default'),
                      type='int', dest='max_recursions')
    parser.add_option('-n', '--max-files', default=sys.maxint, type='int', dest='max_files',
                      help=_('The maximum number of files to download. This only applies to files from <a href> tags. Default is %default'))
    parser.add_option('--delay', default=0, dest='delay', type='float',
                      help=_('Minimum interval in seconds between consecutive fetches. Default is %default s'))
    parser.add_option('--encoding', default=None,
                      help=_('The character encoding for the websites you are trying to download. The default is to try and guess the encoding.'))
    parser.add_option('--match-regexp', default=[], action='append', dest='match_regexps',
                      help=_('Only links that match this regular expression will be followed. '
                             'This option can be specified multiple times, in which case as long '
                             'as a link matches any one regexp, it will be followed. By default all '
                             'links are followed.'))
    parser.add_option('--filter-regexp', default=[], action='append', dest='filter_regexps',
                      help=_('Any link that matches this regular expression will be ignored.'
                             ' This option can be specified multiple times, in which case as'
                             ' long as any regexp matches a link, it will be ignored. By'
                             ' default, no links are ignored. If both filter regexp and match'
                             ' regexp are specified, then filter regexp is applied first.'))
    parser.add_option('--dont-download-stylesheets', action='store_true', default=False,
                      help=_('Do not download CSS stylesheets.'), dest='no_stylesheets')
    parser.add_option('--verbose', help=_('Show detailed output information. Useful for debugging'),
                      default=False, action='store_true', dest='verbose')
    return parser
Example #50
0
def option_parser():
    parser = OptionParser(_('''\
%prog [options]

Fetch book metadata from online sources. You must specify at least one
of title, authors or ISBN.
'''
    ))
    parser.add_option('-t', '--title', help=_('Book title'))
    parser.add_option('-a', '--authors', help=_('Book author(s)'))
    parser.add_option('-i', '--isbn', help=_('Book ISBN'))
    parser.add_option('-v', '--verbose', default=False, action='store_true',
                      help=_('Print the log to the console (stderr)'))
    parser.add_option('-o', '--opf', help=_('Output the metadata in OPF format instead of human readable text.'), action='store_true', default=False)
    parser.add_option('-c', '--cover',
            help=_('Specify a filename. The cover, if available, will be saved to it. Without this option, no cover will be downloaded.'))
    parser.add_option('-d', '--timeout', default='30',
            help=_('Timeout in seconds. Default is 30'))

    return parser
Example #51
0
def option_parser():
    try:
        from calibre.utils.config import OptionParser
        OptionParser
    except ImportError:
        from optparse import OptionParser
    parser = OptionParser(_('''\
%prog [options] [from to text]

Send mail using the SMTP protocol. %prog has two modes of operation. In the
compose mode you specify from to and text and these are used to build and
send an email message. In the filter mode, %prog reads a complete email
message from STDIN and sends it.

text is the body of the email message.
If text is not specified, a complete email message is read from STDIN.
from is the email address of the sender and to is the email address
of the recipient. When a complete email is read from STDIN, from and to
are only used in the SMTP negotiation, the message headers are not modified.
'''))
    c=parser.add_option_group('COMPOSE MAIL',
        _('Options to compose an email. Ignored if text is not specified')).add_option
    c('-a', '--attachment', help=_('File to attach to the email'))
    c('-s', '--subject', help=_('Subject of the email'))

    parser.add_option('-l', '--localhost',
                      help=_('Host name of localhost. Used when connecting '
                            'to SMTP server.'))
    r=parser.add_option_group('SMTP RELAY',
        _('Options to use an SMTP relay server to send mail. '
        'calibre will try to send the email directly unless --relay is '
        'specified.')).add_option
    r('-r', '--relay', help=_('An SMTP relay server to use to send mail.'))
    r('-p', '--port', default=-1,
      help=_('Port to connect to on relay server. Default is to use 465 if '
      'encryption method is SSL and 25 otherwise.'))
    r('-u', '--username', help=_('Username for relay'))
    r('-p', '--password', help=_('Password for relay'))
    r('-e', '--encryption-method', default='TLS',
      choices=['TLS', 'SSL', 'NONE'],
      help=_('Encryption method to use when connecting to relay. Choices are '
      'TLS, SSL and NONE. Default is TLS. WARNING: Choosing NONE is highly insecure'))
    parser.add_option('-o', '--outbox', help=_('Path to maildir folder to store '
                      'failed email messages in.'))
    parser.add_option('-f', '--fork', default=False, action='store_true',
                      help=_('Fork and deliver message in background. '
                      'If you use this option, you should also use --outbox '
                      'to handle delivery failures.'))
    parser.add_option('-t', '--timeout', help=_('Timeout for connection'))
    parser.add_option('-v', '--verbose', default=0, action='count',
                      help=_('Be more verbose'))
    return parser
Example #52
0
File: ui.py Project: rakyi/calibre
def option_parser():
    parser = OptionParser(usage=_('''\
    %prog options

    Customize calibre by loading external plugins.
    '''))
    parser.add_option('-a', '--add-plugin', default=None,
                      help=_('Add a plugin by specifying the path to the ZIP file containing it.'))
    parser.add_option('-b', '--build-plugin', default=None,
            help=_('For plugin developers: Path to the directory where you are'
                ' developing the plugin. This command will automatically zip '
                'up the plugin and update it in calibre.'))
    parser.add_option('-r', '--remove-plugin', default=None,
                      help=_('Remove a custom plugin by name. Has no effect on builtin plugins'))
    parser.add_option('--customize-plugin', default=None,
                      help=_('Customize plugin. Specify name of plugin and customization string separated by a comma.'))
    parser.add_option('-l', '--list-plugins', default=False, action='store_true',
                      help=_('List all installed plugins'))
    parser.add_option('--enable-plugin', default=None,
                      help=_('Enable the named plugin'))
    parser.add_option('--disable-plugin', default=None,
                      help=_('Disable the named plugin'))
    return parser
Example #53
0
def option_parser():
    parser = OptionParser(textwrap.dedent(
        '''\
        %prog [options]

        Fetch book metadata from Douban. You must specify one of title, author,
        publisher or ISBN. If you specify ISBN the others are ignored. Will
        fetch a maximum of 100 matches, so you should make your query as
        specific as possible.
        '''
    ))
    parser.add_option('-t', '--title', help='Book title')
    parser.add_option('-a', '--author', help='Book author(s)')
    parser.add_option('-p', '--publisher', help='Book publisher')
    parser.add_option('-i', '--isbn', help='Book ISBN')
    parser.add_option('-m', '--max-results', default=10,
                      help='Maximum number of results to fetch')
    parser.add_option('-v', '--verbose', default=0, action='count',
                      help='Be more verbose about errors')
    return parser
Example #54
0
def option_parser():
    parser = OptionParser(usage=_('''\
{0}

Various command line interfaces useful for debugging calibre. With no options,
this command starts an embedded Python interpreter. You can also run the main
calibre GUI, the calibre viewer and the calibre editor in debug mode.

It also contains interfaces to various bits of calibre that do not have
dedicated command line tools, such as font subsetting, the e-book diff tool and so
on.

You can also use %prog to run standalone scripts. To do that use it like this:

    {1}

Everything after the -- is passed to the script.
''').format(_('%prog [options]'),
            '%prog myscript.py -- --option1 --option2 file1 file2 ...'))
    parser.add_option('-c', '--command', help=_('Run Python code.'))
    parser.add_option('-e',
                      '--exec-file',
                      help=_('Run the Python code in file.'))
    parser.add_option(
        '-f',
        '--subset-font',
        action='store_true',
        default=False,
        help=
        _('Subset the specified font. Use -- after this option to pass option to the font subsetting program.'
          ))
    parser.add_option('-d',
                      '--debug-device-driver',
                      default=False,
                      action='store_true',
                      help=_('Debug device detection'))
    parser.add_option(
        '-g',
        '--gui',
        default=False,
        action='store_true',
        help=_('Run the GUI with debugging enabled. Debug output is '
               'printed to stdout and stderr.'))
    parser.add_option('--gui-debug',
                      default=None,
                      help=_(
                          'Run the GUI with a debug console, logging to the'
                          ' specified path. For internal use only, use the -g'
                          ' option to run the GUI in debug mode'))
    parser.add_option('-w',
                      '--viewer',
                      default=False,
                      action='store_true',
                      help=_('Run the E-book viewer in debug mode'))
    parser.add_option(
        '--paths',
        default=False,
        action='store_true',
        help=_('Output the paths necessary to setup the calibre environment'))
    parser.add_option(
        '--add-simple-plugin',
        default=None,
        help=_(
            'Add a simple plugin (i.e. a plugin that consists of only a '
            '.py file), by specifying the path to the py file containing the '
            'plugin code.'))
    parser.add_option(
        '--reinitialize-db',
        default=None,
        help=_('Re-initialize the sqlite calibre database at the '
               'specified path. Useful to recover from db corruption.'))
    parser.add_option(
        '-m',
        '--inspect-mobi',
        action='store_true',
        default=False,
        help=_('Inspect the MOBI file(s) at the specified path(s)'))
    parser.add_option(
        '-t',
        '--edit-book',
        action='store_true',
        help=_('Launch the calibre "Edit book" tool in debug mode.'))
    parser.add_option(
        '-x',
        '--explode-book',
        default=False,
        action='store_true',
        help=_('Explode the book into the specified directory.\nUsage: '
               '-x file.epub output_dir\n'
               'Exports the book as a collection of HTML '
               'files and metadata, which you can edit using standard HTML '
               'editing tools. Works with EPUB, AZW3, HTMLZ and DOCX files.'))
    parser.add_option(
        '-i',
        '--implode-book',
        default=False,
        action='store_true',
        help=_(
            'Implode a previously exploded book.\nUsage: -i output_dir file.epub\n'
            'Imports the book from the files in output_dir which must have'
            ' been created by a previous call to --explode-book. Be sure to'
            ' specify the same file type as was used when exploding.'))
    parser.add_option(
        '--export-all-calibre-data',
        default=False,
        action='store_true',
        help=
        _('Export all calibre data (books/settings/plugins). Normally, you will'
          ' be asked for the export dir and the libraries to export. You can also specify them'
          ' as command line arguments to skip the questions.'
          ' Use absolute paths for the export directory and libraries.'
          ' The special keyword "all" can be used to export all libraries.'))
    parser.add_option('--import-calibre-data',
                      default=False,
                      action='store_true',
                      help=_('Import previously exported calibre data'))
    parser.add_option(
        '-s',
        '--shutdown-running-calibre',
        default=False,
        action='store_true',
        help=_('Cause a running calibre instance, if any, to be'
               ' shutdown. Note that if there are running jobs, they '
               'will be silently aborted, so use with care.'))
    parser.add_option('--test-build',
                      help=_('Test binary modules in build'),
                      action='store_true',
                      default=False)
    parser.add_option(
        '-r',
        '--run-plugin',
        help=
        _('Run a plugin that provides a command line interface. For example:\n'
          'calibre-debug -r "Add Books" -- file1 --option1\n'
          'Everything after the -- will be passed to the plugin as arguments.'
          ))
    parser.add_option('--diff',
                      action='store_true',
                      default=False,
                      help=_('Run the calibre diff tool. For example:\n'
                             'calibre-debug --diff file1 file2'))
    parser.add_option(
        '--default-programs',
        default=None,
        choices=['register', 'unregister'],
        help=_('(Un)register calibre from Windows Default Programs.') +
        ' --default-programs=(register|unregister)')

    return parser
Example #55
0
def option_parser():
    parser = OptionParser(usage=_('''\
{0}

Various command line interfaces useful for debugging calibre. With no options,
this command starts an embedded python interpreter. You can also run the main
calibre GUI, the calibre viewer and the calibre editor in debug mode.

It also contains interfaces to various bits of calibre that do not have
dedicated command line tools, such as font subsetting, the ebook diff tool and so
on.

You can also use %prog to run standalone scripts. To do that use it like this:

    {1}

Everything after the -- is passed to the script.
''').format(_('%prog [options]'), '%prog myscript.py -- --option1 --option2 file1 file2 ...'))
    parser.add_option('-c', '--command', help=_('Run python code.'))
    parser.add_option('-e', '--exec-file', help=_('Run the python code in file.'))
    parser.add_option('-f', '--subset-font', action='store_true', default=False,
                      help=_('Subset the specified font. Use -- after this option to pass option to the font subsetting program.'))
    parser.add_option('-d', '--debug-device-driver', default=False, action='store_true',
                      help=_('Debug device detection'))
    parser.add_option('-g', '--gui',  default=False, action='store_true',
                      help=_('Run the GUI with debugging enabled. Debug output is '
                      'printed to stdout and stderr.'))
    parser.add_option('--gui-debug',  default=None,
                      help=_('Run the GUI with a debug console, logging to the'
                      ' specified path. For internal use only, use the -g'
                      ' option to run the GUI in debug mode'))
    parser.add_option('-w', '--viewer',  default=False, action='store_true',
                      help=_('Run the ebook viewer in debug mode'))
    parser.add_option('--paths', default=False, action='store_true',
            help=_('Output the paths necessary to setup the calibre environment'))
    parser.add_option('--add-simple-plugin', default=None,
            help=_('Add a simple plugin (i.e. a plugin that consists of only a '
            '.py file), by specifying the path to the py file containing the '
            'plugin code.'))
    parser.add_option('--reinitialize-db', default=None,
            help=_('Re-initialize the sqlite calibre database at the '
            'specified path. Useful to recover from db corruption.'))
    parser.add_option('-p', '--py-console', help=_('Run python console'),
            default=False, action='store_true')
    parser.add_option('-m', '--inspect-mobi', action='store_true',
            default=False,
            help=_('Inspect the MOBI file(s) at the specified path(s)'))
    parser.add_option('-t', '--edit-book', action='store_true',
            help=_('Launch the calibre Edit Book tool in debug mode.'))
    parser.add_option('-x', '--explode-book', default=None,
            help=_('Explode the book (exports the book as a collection of HTML '
            'files and metadata, which you can edit using standard HTML '
            'editing tools, and then rebuilds the file from the edited HTML. '
            'Makes no additional changes to the HTML, unlike a full calibre '
            'conversion).'))
    parser.add_option('--export-all-calibre-data', default=False, action='store_true',
        help=_('Export all calibre data (books/settings/plugins)'))
    parser.add_option('--import-calibre-data', default=False, action='store_true',
        help=_('Import previously exported calibre data'))
    parser.add_option('-s', '--shutdown-running-calibre', default=False,
            action='store_true',
            help=_('Cause a running calibre instance, if any, to be'
                ' shutdown. Note that if there are running jobs, they '
                'will be silently aborted, so use with care.'))
    parser.add_option('--test-build', help=_('Test binary modules in build'),
            action='store_true', default=False)
    parser.add_option('-r', '--run-plugin', help=_(
        'Run a plugin that provides a command line interface. For example:\n'
        'calibre-debug -r "Add Books" -- file1 --option1\n'
        'Everything after the -- will be passed to the plugin as arguments.'))
    parser.add_option('--diff', action='store_true', default=False, help=_(
        'Run the calibre diff tool. For example:\n'
        'calibre-debug --diff file1 file2'))
    parser.add_option('--default-programs', default=None, choices=['register', 'unregister'],
                          help=_('(Un)register calibre from Windows Default Programs.') + ' --default-programs=(register|unregister)')
    parser.add_option('--new-server', action='store_true',
        help='Run the new calibre content server. Any options specified after a -- will be passed to the server.')

    return parser
Example #56
0
File: meta.py Project: Farb/calibre
def option_parser():
    from calibre.utils.config import OptionParser
    from calibre.constants import __appname__, __version__
    parser = OptionParser(usage=_('''%prog [options] mybook.lrf


Show/edit the metadata in an LRF file.\n\n'''),
      version=__appname__+' '+__version__,
      epilog='Created by Kovid Goyal')
    parser.add_option("-t", "--title", action="store", type="string",
                    dest="title", help=_("Set the book title"))
    parser.add_option('--title-sort', action='store', type='string', default=None,
                      dest='title_reading', help=_('Set sort key for the title'))
    parser.add_option("-a", "--author", action="store", type="string",
                    dest="author", help=_("Set the author"))
    parser.add_option('--author-sort', action='store', type='string', default=None,
                      dest='author_reading', help=_('Set sort key for the author'))
    parser.add_option("-c", "--category", action="store", type="string",
                    dest="category", help=_("The category this book belongs"
                    " to. E.g.: History"))
    parser.add_option("--thumbnail", action="store", type="string",
                    dest="thumbnail", help=_("Path to a graphic that will be"
                    " set as this files' thumbnail"))
    parser.add_option("--comment", action="store", type="string",
                    dest="comment", help=_("Path to a txt file containing the "
                    "comment to be stored in the lrf file."))
    parser.add_option("--get-thumbnail", action="store_true",
                    dest="get_thumbnail", default=False,
                    help=_("Extract thumbnail from LRF file"))
    parser.add_option('--publisher', default=None, help=_('Set the publisher'))
    parser.add_option('--classification', default=None, help=_('Set the book classification'))
    parser.add_option('--creator', default=None, help=_('Set the book creator'))
    parser.add_option('--producer', default=None, help=_('Set the book producer'))
    parser.add_option('--get-cover', action='store_true', default=False,
                      help=_('Extract cover from LRF file. Note that the LRF format has no defined cover, so we use some heuristics to guess the cover.'))
    parser.add_option('--bookid', action='store', type='string', default=None,
                      dest='book_id', help=_('Set book ID'))
    # The SumPage element specifies the number of "View"s (visible pages for the BookSetting element conditions) of the content.
    # Basically, the total pages per the page size, font size, etc. when the
    # LRF is first created. Since this will change as the book is reflowed, it
    # is probably not worth using.
    # parser.add_option("-p", "--page", action="store", type="string", \
    #                dest="page", help=_("Don't know what this is for"))

    return parser
Example #57
0
def option_parser():
    try:
        from calibre.utils.config import OptionParser
        OptionParser
    except ImportError:
        from optparse import OptionParser
    parser = OptionParser(
        _('''\
%prog [options] [from to text]

Send mail using the SMTP protocol. %prog has two modes of operation. In the
compose mode you specify from to and text and these are used to build and
send an email message. In the filter mode, %prog reads a complete email
message from STDIN and sends it.

text is the body of the email message.
If text is not specified, a complete email message is read from STDIN.
from is the email address of the sender and to is the email address
of the recipient. When a complete email is read from STDIN, from and to
are only used in the SMTP negotiation, the message headers are not modified.
'''))
    c = parser.add_option_group(
        'COMPOSE MAIL',
        _('Options to compose an email. Ignored if text is not specified')
    ).add_option
    c('-a', '--attachment', help=_('File to attach to the email'))
    c('-s', '--subject', help=_('Subject of the email'))

    parser.add_option('-l',
                      '--localhost',
                      help=_('Host name of localhost. Used when connecting '
                             'to SMTP server.'))
    r = parser.add_option_group(
        'SMTP RELAY',
        _('Options to use an SMTP relay server to send mail. '
          'calibre will try to send the email directly unless --relay is '
          'specified.')).add_option
    r('-r', '--relay', help=_('An SMTP relay server to use to send mail.'))
    r('-p',
      '--port',
      default=-1,
      help=_('Port to connect to on relay server. Default is to use 465 if '
             'encryption method is SSL and 25 otherwise.'))
    r('-u', '--username', help=_('Username for relay'))
    r('-p', '--password', help=_('Password for relay'))
    r('-e',
      '--encryption-method',
      default='TLS',
      choices=['TLS', 'SSL', 'NONE'],
      help=_(
          'Encryption method to use when connecting to relay. Choices are '
          'TLS, SSL and NONE. Default is TLS. WARNING: Choosing NONE is highly insecure'
      ))
    r('--dont-verify-server-certificate',
      help=
      _('Do not verify the server certificate when connecting using TLS. This used'
        ' to be the default behavior in calibre versions before 3.27. If you are using'
        ' a relay with a self-signed or otherwise invalid certificate, you can use this option to restore'
        ' the pre 3.27 behavior'))
    r('--cafile',
      help=
      _('Path to a file of concatenated CA certificates in PEM format, used to verify the'
        ' server certificate when using TLS. By default, the system CA certificates are used.'
        ))
    parser.add_option('-o',
                      '--outbox',
                      help=_('Path to maildir folder to store '
                             'failed email messages in.'))
    parser.add_option(
        '-f',
        '--fork',
        default=False,
        action='store_true',
        help=_('Fork and deliver message in background. '
               'If you use this option, you should also use --outbox '
               'to handle delivery failures.'))
    parser.add_option('-t', '--timeout', help=_('Timeout for connection'))
    parser.add_option('-v',
                      '--verbose',
                      default=0,
                      action='count',
                      help=_('Be more verbose'))
    return parser
Example #58
0
def option_parser():
    parser = OptionParser(
        usage=_(
            """\
    %prog options

    Customize calibre by loading external plugins.
    """
        )
    )
    parser.add_option(
        "-a", "--add-plugin", default=None, help=_("Add a plugin by specifying the path to the zip file containing it.")
    )
    parser.add_option(
        "-b",
        "--build-plugin",
        default=None,
        help=_(
            "For plugin developers: Path to the directory where you are"
            " developing the plugin. This command will automatically zip "
            "up the plugin and update it in calibre."
        ),
    )
    parser.add_option(
        "-r",
        "--remove-plugin",
        default=None,
        help=_("Remove a custom plugin by name. Has no effect on builtin plugins"),
    )
    parser.add_option(
        "--customize-plugin",
        default=None,
        help=_("Customize plugin. Specify name of plugin and customization string separated by a comma."),
    )
    parser.add_option("-l", "--list-plugins", default=False, action="store_true", help=_("List all installed plugins"))
    parser.add_option("--enable-plugin", default=None, help=_("Enable the named plugin"))
    parser.add_option("--disable-plugin", default=None, help=_("Disable the named plugin"))
    return parser