示例#1
0
文件: command.py 项目: zsx/hotwire
 def __str__(self):
     def unijoin(args):
         return ' '.join(map(unicode, args))
     args = [self.builtin.name]
     args.extend(self.context.options)
     for cmdarg in self.args:
         if isinstance(cmdarg, CommandArgument) and cmdarg.isquoted:
             args.append(quote_arg(cmdarg))                
         else:
             args.append(cmdarg)
     if self.in_redir:
         args.extend(['<', self.in_redir])
     if self.out_redir:
         args.extend(['>', self.out_redir])            
     return unijoin(args)
示例#2
0
 def __str__(self):
     def unijoin(args):
         return ' '.join(map(unicode, args))
     args = [self.builtin.name]
     args.extend(self.context.options)
     for cmdarg in self.args:
         if isinstance(cmdarg, CommandArgument) and cmdarg.isquoted:
             args.append(quote_arg(cmdarg))                
         else:
             args.append(cmdarg)
     if self.in_redir:
         args.extend(['<', self.in_redir])
     if self.out_redir:
         args.extend(['>', self.out_redir])            
     return unijoin(args)
示例#3
0
def _mkfile_completion(text, fpath, fileobj=None):
    if not isinstance(text, unicode):
        text = unicode(text, 'utf-8')
    if not isinstance(fpath, unicode):
        fpath = unicode(fpath, 'utf-8')
    fs = Filesystem.getInstance()
    fname = unix_basename(fpath)
    if text.endswith('/'):
        textbase = ''
    else:
        textbase = unix_basename(text)
    fobj = fileobj or fs.get_file_sync(fpath)
    startidx = fpath.rindex(fname)
    suffix = quote_arg(fpath[startidx + len(textbase):])
    if fobj.test_directory(follow_link=True):
        suffix += '/'
    return Completion(suffix, fobj, fname)
示例#4
0
def _mkfile_completion(text, fpath, fileobj=None):
    if not isinstance(text, str):
        text = str(text, 'utf-8')
    if not isinstance(fpath, str):
        fpath = str(fpath, 'utf-8')             
    fs = Filesystem.getInstance()
    fname = unix_basename(fpath)
    if text.endswith('/'):
        textbase = ''
    else:
        textbase = unix_basename(text)         
    fobj = fileobj or fs.get_file_sync(fpath)
    startidx = fpath.rindex(fname)
    suffix = quote_arg(fpath[startidx+len(textbase):])
    if fobj.test_directory(follow_link=True):
        suffix += '/'
    return Completion(suffix, fobj, fname)     
示例#5
0
文件: completion.py 项目: zsx/hotwire
def _mkfile_completion(text, fpath, fileobj=None):
    if not isinstance(text, unicode):
        text = unicode(text, "utf-8")
    if not isinstance(fpath, unicode):
        fpath = unicode(fpath, "utf-8")
    fs = Filesystem.getInstance()
    fname = unix_basename(fpath)
    if text.endswith("/"):
        textbase = ""
    else:
        textbase = unix_basename(text)
    fobj = fileobj or fs.get_file_sync(fpath)
    startidx = fpath.rindex(fname)
    suffix = quote_arg(fpath[startidx + len(textbase) :])
    if fobj.test_directory(follow_link=True):
        suffix += "/"
    return Completion(suffix, fobj, fname)