예제 #1
0
def list_func(lib, config, opts, args):
    fmt = opts.format
    if not fmt:
        # If no format is specified, fall back to a default.
        if opts.album:
            fmt = ui.config_val(config, 'beets', 'list_format_album',
                                DEFAULT_LIST_FORMAT_ALBUM)
        else:
            fmt = ui.config_val(config, 'beets', 'list_format_item',
                                DEFAULT_LIST_FORMAT_ITEM)
    list_items(lib, decargs(args), opts.album, opts.path, fmt)
예제 #2
0
def list_func(lib, config, opts, args):
    fmt = opts.format
    if not fmt:
        # If no format is specified, fall back to a default.
        if opts.album:
            fmt = ui.config_val(config, 'beets', 'list_format_album',
                                DEFAULT_LIST_FORMAT_ALBUM)
        else:
            fmt = ui.config_val(config, 'beets', 'list_format_item',
                                DEFAULT_LIST_FORMAT_ITEM)
    list_items(lib, decargs(args), opts.album, opts.path, fmt)
예제 #3
0
def modify_func(lib, config, opts, args):
    args = decargs(args)
    mods = [a for a in args if '=' in a]
    query = [a for a in args if '=' not in a]
    if not mods:
        raise ui.UserError('no modifications specified')
    write = opts.write if opts.write is not None else \
        ui.config_val(config, 'beets', 'import_write',
            DEFAULT_IMPORT_WRITE, bool)
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    modify_items(lib, mods, query, write, opts.move, opts.album, color,
                 not opts.yes)
예제 #4
0
def import_func(lib, config, opts, args):
    copy  = opts.copy  if opts.copy  is not None else \
        ui.config_val(config, 'beets', 'import_copy',
            DEFAULT_IMPORT_COPY, bool)
    write = opts.write if opts.write is not None else \
        ui.config_val(config, 'beets', 'import_write',
            DEFAULT_IMPORT_WRITE, bool)
    delete = ui.config_val(config, 'beets', 'import_delete',
            DEFAULT_IMPORT_DELETE, bool)
    autot = opts.autotag if opts.autotag is not None else DEFAULT_IMPORT_AUTOT
    art = opts.art if opts.art is not None else \
        ui.config_val(config, 'beets', 'import_art',
            DEFAULT_IMPORT_ART, bool)
    threaded = ui.config_val(config, 'beets', 'threaded',
            DEFAULT_THREADED, bool)
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    quiet = opts.quiet if opts.quiet is not None else DEFAULT_IMPORT_QUIET
    quiet_fallback_str = ui.config_val(config, 'beets', 'import_quiet_fallback',
            DEFAULT_IMPORT_QUIET_FALLBACK)
    singletons = opts.singletons
    timid = opts.timid if opts.timid is not None else \
        ui.config_val(config, 'beets', 'import_timid',
            DEFAULT_IMPORT_TIMID, bool)
    logpath = opts.logpath if opts.logpath is not None else \
        ui.config_val(config, 'beets', 'import_log', None)

    # Resume has three options: yes, no, and "ask" (None).
    resume = opts.resume if opts.resume is not None else \
        ui.config_val(config, 'beets', 'import_resume', DEFAULT_IMPORT_RESUME)
    if isinstance(resume, basestring):
        if resume.lower() in ('yes', 'true', 't', 'y', '1'):
            resume = True
        elif resume.lower() in ('no', 'false', 'f', 'n', '0'):
            resume = False
        else:
            resume = None

    if quiet_fallback_str == 'asis':
        quiet_fallback = importer.action.ASIS
    else:
        quiet_fallback = importer.action.SKIP
    import_files(lib, args, copy, write, autot, logpath, art, threaded,
                 color, delete, quiet, resume, quiet_fallback, singletons,
                 timid)
예제 #5
0
def update_func(lib, config, opts, args):
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    update_items(lib, decargs(args), opts.album, opts.move, color, opts.pretend)
예제 #6
0
def import_func(lib, config, opts, args):
    copy  = opts.copy  if opts.copy  is not None else \
        ui.config_val(config, 'beets', 'import_copy',
            DEFAULT_IMPORT_COPY, bool)
    write = opts.write if opts.write is not None else \
        ui.config_val(config, 'beets', 'import_write',
            DEFAULT_IMPORT_WRITE, bool)
    delete = ui.config_val(config, 'beets', 'import_delete',
            DEFAULT_IMPORT_DELETE, bool)
    autot = opts.autotag if opts.autotag is not None else DEFAULT_IMPORT_AUTOT
    art = opts.art if opts.art is not None else \
        ui.config_val(config, 'beets', 'import_art',
            DEFAULT_IMPORT_ART, bool)
    threaded = ui.config_val(config, 'beets', 'threaded',
            DEFAULT_THREADED, bool)
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    quiet = opts.quiet if opts.quiet is not None else DEFAULT_IMPORT_QUIET
    quiet_fallback_str = ui.config_val(config, 'beets', 'import_quiet_fallback',
            DEFAULT_IMPORT_QUIET_FALLBACK)
    singletons = opts.singletons
    timid = opts.timid if opts.timid is not None else \
        ui.config_val(config, 'beets', 'import_timid',
            DEFAULT_IMPORT_TIMID, bool)
    logpath = opts.logpath if opts.logpath is not None else \
        ui.config_val(config, 'beets', 'import_log', None)
    incremental = opts.incremental if opts.incremental is not None else \
        ui.config_val(config, 'beets', 'import_incremental',
            DEFAULT_IMPORT_INCREMENTAL, bool)
    ignore = ui.config_val(config, 'beets', 'ignore', DEFAULT_IGNORE, list)

    # Resume has three options: yes, no, and "ask" (None).
    resume = opts.resume if opts.resume is not None else \
        ui.config_val(config, 'beets', 'import_resume', DEFAULT_IMPORT_RESUME)
    if isinstance(resume, basestring):
        if resume.lower() in ('yes', 'true', 't', 'y', '1'):
            resume = True
        elif resume.lower() in ('no', 'false', 'f', 'n', '0'):
            resume = False
        else:
            resume = None

    if quiet_fallback_str == 'asis':
        quiet_fallback = importer.action.ASIS
    else:
        quiet_fallback = importer.action.SKIP

    if opts.library:
        query = args
        paths = []
    else:
        query = None
        paths = args

    import_files(lib, paths, copy, write, autot, logpath, art, threaded,
                 color, delete, quiet, resume, quiet_fallback, singletons,
                 timid, query, incremental, ignore)
예제 #7
0
def import_func(lib, config, opts, args):
    copy  = opts.copy  if opts.copy  is not None else \
        ui.config_val(config, 'beets', 'import_copy',
            DEFAULT_IMPORT_COPY, bool)
    move  = ui.config_val(config, 'beets', 'import_move',
                          DEFAULT_IMPORT_MOVE, bool)
    write = opts.write if opts.write is not None else \
        ui.config_val(config, 'beets', 'import_write',
            DEFAULT_IMPORT_WRITE, bool)
    delete = ui.config_val(config, 'beets', 'import_delete',
            DEFAULT_IMPORT_DELETE, bool)
    autot = opts.autotag if opts.autotag is not None else DEFAULT_IMPORT_AUTOT
    threaded = ui.config_val(config, 'beets', 'threaded',
            DEFAULT_THREADED, bool)
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    quiet = opts.quiet if opts.quiet is not None else DEFAULT_IMPORT_QUIET
    quiet_fallback_str = ui.config_val(config, 'beets', 'import_quiet_fallback',
            DEFAULT_IMPORT_QUIET_FALLBACK)
    singletons = opts.singletons
    timid = opts.timid if opts.timid is not None else \
        ui.config_val(config, 'beets', 'import_timid',
            DEFAULT_IMPORT_TIMID, bool)
    logpath = opts.logpath if opts.logpath is not None else \
        ui.config_val(config, 'beets', 'import_log', None)
    incremental = opts.incremental if opts.incremental is not None else \
        ui.config_val(config, 'beets', 'import_incremental',
            DEFAULT_IMPORT_INCREMENTAL, bool)
    ignore = ui.config_val(config, 'beets', 'ignore', DEFAULT_IGNORE, list)
    per_disc_numbering = ui.config_val(config, 'beets', 'per_disc_numbering',
                                       DEFAULT_PER_DISC_NUMBERING, bool)

    # Resume has three options: yes, no, and "ask" (None).
    resume = opts.resume if opts.resume is not None else \
        ui.config_val(config, 'beets', 'import_resume', DEFAULT_IMPORT_RESUME)
    if isinstance(resume, basestring):
        if resume.lower() in ('yes', 'true', 't', 'y', '1'):
            resume = True
        elif resume.lower() in ('no', 'false', 'f', 'n', '0'):
            resume = False
        else:
            resume = None

    # Special case: --copy flag suppresses import_move (which would
    # otherwise take precedence).
    if opts.copy:
        move = False

    if quiet_fallback_str == 'asis':
        quiet_fallback = importer.action.ASIS
    else:
        quiet_fallback = importer.action.SKIP

    if opts.library:
        query = args
        paths = []
    else:
        query = None
        paths = args

    import_files(lib, paths, copy, move, write, autot, logpath, threaded,
                 color, delete, quiet, resume, quiet_fallback, singletons,
                 timid, query, incremental, ignore, per_disc_numbering)
예제 #8
0
def import_func(lib, config, opts, args):
    copy  = opts.copy  if opts.copy  is not None else \
        ui.config_val(config, 'beets', 'import_copy',
            DEFAULT_IMPORT_COPY, bool)
    move = ui.config_val(config, 'beets', 'import_move', DEFAULT_IMPORT_MOVE,
                         bool)
    write = opts.write if opts.write is not None else \
        ui.config_val(config, 'beets', 'import_write',
            DEFAULT_IMPORT_WRITE, bool)
    delete = ui.config_val(config, 'beets', 'import_delete',
                           DEFAULT_IMPORT_DELETE, bool)
    autot = opts.autotag if opts.autotag is not None else DEFAULT_IMPORT_AUTOT
    threaded = ui.config_val(config, 'beets', 'threaded', DEFAULT_THREADED,
                             bool)
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    quiet = opts.quiet if opts.quiet is not None else DEFAULT_IMPORT_QUIET
    quiet_fallback_str = ui.config_val(config, 'beets',
                                       'import_quiet_fallback',
                                       DEFAULT_IMPORT_QUIET_FALLBACK)
    singletons = opts.singletons
    timid = opts.timid if opts.timid is not None else \
        ui.config_val(config, 'beets', 'import_timid',
            DEFAULT_IMPORT_TIMID, bool)
    logpath = opts.logpath if opts.logpath is not None else \
        ui.config_val(config, 'beets', 'import_log', None)
    incremental = opts.incremental if opts.incremental is not None else \
        ui.config_val(config, 'beets', 'import_incremental',
            DEFAULT_IMPORT_INCREMENTAL, bool)
    ignore = ui.config_val(config, 'beets', 'ignore', DEFAULT_IGNORE, list)
    per_disc_numbering = ui.config_val(config, 'beets', 'per_disc_numbering',
                                       DEFAULT_PER_DISC_NUMBERING, bool)

    # Resume has three options: yes, no, and "ask" (None).
    resume = opts.resume if opts.resume is not None else \
        ui.config_val(config, 'beets', 'import_resume', DEFAULT_IMPORT_RESUME)
    if isinstance(resume, basestring):
        if resume.lower() in ('yes', 'true', 't', 'y', '1'):
            resume = True
        elif resume.lower() in ('no', 'false', 'f', 'n', '0'):
            resume = False
        else:
            resume = None

    # Special case: --copy flag suppresses import_move (which would
    # otherwise take precedence).
    if opts.copy:
        move = False

    if quiet_fallback_str == 'asis':
        quiet_fallback = importer.action.ASIS
    else:
        quiet_fallback = importer.action.SKIP

    if opts.library:
        query = args
        paths = []
    else:
        query = None
        paths = args

    import_files(lib, paths, copy, move, write, autot, logpath, threaded,
                 color, delete, quiet, resume, quiet_fallback, singletons,
                 timid, query, incremental, ignore, per_disc_numbering)