Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def completion_candidates_posargs(cls, args):
"""Complete positional arguments"""
return candidates.fs_path(args.curarg.before_cursor,
base=os.environ.get('HOME', '.'),
glob=r'*.torrent')
def completion_candidates_params(cls, option, args):
"""Complete parameters (e.g. --option parameter1,parameter2)"""
if option == '--path':
return candidates.fs_path(args.curarg.before_cursor,
base=objects.remotecfg['path.complete'],
directories_only=True)
def completion_candidates_posargs(cls, args):
"""Complete positional arguments"""
# If --columns or --sort is anywhere, we only display options
for arg in args:
if cls.short_options.get(arg, arg) in ('--columns', '--sort'):
return
settings = candidates.setting_names()
if args.curarg_index == 1:
log.debug('Returning setting names: %r', settings)
return settings
elif args.curarg_index >= 2:
log.debug('Completing values for %r', args[1])
# Remove command name from command line
return candidates.setting_values(args[1:])
async def completion_candidates_posargs(cls, args):
"""Complete positional arguments"""
if args.curarg_index == 1:
log.debug('Getting torrent filter candidates from %r', candidates.torrent_filter)
return await candidates.torrent_filter(args.curarg)
elif args.curarg_index == 2:
return candidates.fs_path(args.curarg.before_cursor,
base=objects.remotecfg['path.complete'],
directories_only=True)
async def completion_candidates_posargs(cls, args):
"""Complete positional arguments"""
def dest_path_candidates(curarg):
return candidates.fs_path(curarg.before_cursor,
base=objects.remotecfg['path.complete'],
directories_only=True)
curarg = args.curarg
if len(args) >= 3:
if args.curarg_index == 1:
return await candidates.torrent_filter(curarg)
elif args.curarg_index == 2:
return dest_path_candidates(curarg)
elif len(args) == 2:
# Single argument may be a path or a filter
filter_cands = await candidates.torrent_filter(curarg)
path_cands = dest_path_candidates(curarg)
return (path_cands,) + filter_cands
def completion_candidates_posargs(cls, args):
"""Complete positional arguments"""
# Command only takes one argument
if args.curarg_index == 1:
return candidates.fs_path(args.curarg,
base=os.path.dirname(defaults.DEFAULT_RCFILE))
async def completion_candidates_posargs(cls, args):
"""Complete positional arguments"""
# We don't care about options
args = args.without_options()
log.debug(args)
if args.curarg_index == 1:
# Complete file and directory names from torrent(s)
log.debug('torrent_path(%r)', args.curarg)
return await candidates.torrent_path(args.curarg, only='any')
elif args.curarg_index == 2:
first_arg_stripped = args[1].strip('/')
if '/' in first_arg_stripped:
# First argument contains a path separator, so destination is
# the new file name. The second argument can't contain a path
# separator if it's a file or directory.
if '/' not in args.curarg:
# To make it more convenient to adjust file/directory names,
# destination candidates are existing files or directories
# from the path specified in the first argument. Files if
# the first argument points to a file, directories if the
# first argument points to a directory.
source = Arg(first_arg_stripped, curpos=len(first_arg_stripped))
log.debug('Using destination candidates from: %r', source)
return await candidates.torrent_path(source, only='auto')
else:
def completion_candidates_posargs(cls, args):
"""Complete positional arguments"""
if args.curarg_index == 1:
return candidates.torrent_filter(args.curarg)
def completion_candidates_posargs(cls, args):
"""Complete positional arguments"""
return candidates.setting_names()
async def completion_candidates_posargs(cls, args):
"""Complete positional arguments"""
if args.curarg_index == 1:
log.debug('Getting torrent filter candidates from %r', candidates.torrent_filter)
return await candidates.torrent_filter(args.curarg)
elif args.curarg_index == 2:
return candidates.fs_path(args.curarg.before_cursor,
base=objects.remotecfg['path.complete'],
directories_only=True)