示例#1
0
    def do_run(self, options, args):

        if not args:
            args = ['.']

        for fs, path, is_dir in self.get_resources(args, single=True):
            if not is_dir:
                self.error(u"'%s' is not a dir\n" % path)
                return 1
            fs.cache_hint(True)
            if options.gui:
                from fs.browsewin import browse
                if path:
                    fs = fs.opendir(path)
                browse(fs, hide_dotfiles=not options.all)
            else:
                if options.depth < 0:
                    max_levels = None
                else:
                    max_levels = options.depth
                print_fs(fs,
                         path or '',
                         file_out=self.output_file,
                         max_levels=max_levels,
                         terminal_colors=self.terminal_colors,
                         hide_dotfiles=not options.all,
                         dirs_first=options.dirsfirst)
示例#2
0
文件: fstree.py 项目: dmikam/python
 def do_run(self, options, args):        
     
     if not args:
         args = ['.']
 
     for fs, path, is_dir in self.get_resources(args, single=True):                            
         if not is_dir:
             self.error(u"'%s' is not a dir\n" % path)
             return 1
         fs.cache_hint(True)
         if options.gui:
             from fs.browsewin import browse
             if path:
                 fs = fs.opendir(path)
             browse(fs, hide_dotfiles=not options.all)
         else:
             if options.depth < 0:
                 max_levels = None
             else:
                 max_levels = options.depth
             print_fs(fs, path or '',
                      file_out=self.output_file,
                      max_levels=max_levels,
                      terminal_colors=self.terminal_colors,
                      hide_dotfiles=not options.all,
                      dirs_first=options.dirsfirst)        
示例#3
0
 def printtree(self, max_levels=5):
     """Prints a tree structure of the FS object to the console
     
     :param max_levels: The maximum sub-directories to display, defaults to
         5. Set to None for no limit 
     
     """
     from fs.utils import print_fs
     print_fs(self, max_levels=max_levels)
示例#4
0
 def printtree(self, max_levels=5):
     """Prints a tree structure of the FS object to the console
     
     :param max_levels: The maximum sub-directories to display, defaults to
         5. Set to None for no limit 
     
     """
     from fs.utils import print_fs
     print_fs(self, max_levels=max_levels)
示例#5
0
文件: fstree.py 项目: rimrim/pyfs
    def do_run(self, options, args):

        if not args:
            args = ['.']

        for fs, path, is_dir in self.get_resources(args, single=True):
            if not is_dir:
                self.error("'%s' is not a dir\n" % path)
                return 1
            fs.cache_hint(True)
            if options.gui:
                from fs.browsewin import browse
                if path:
                    fs = fs.opendir(path)
                browse(fs, hide_dotfiles=not options.all)
            else:
                if options.depth < 0:
                    max_levels = None
                else:
                    max_levels = options.depth
                self.output(self.wrap_dirname(args[0] + '\n'))
                dircount, filecount = print_fs(
                    fs,
                    path or '',
                    file_out=self.output_file,
                    max_levels=max_levels,
                    terminal_colors=self.terminal_colors,
                    hide_dotfiles=not options.all,
                    dirs_first=options.dirsfirst,
                    files_wildcard=options.pattern,
                    dirs_only=options.dirsonly)
                self.output('\n')

                def pluralize(one, many, count):
                    if count == 1:
                        return '%i %s' % (count, one)
                    else:
                        return '%i %s' % (count, many)

                self.output("%s, %s\n" %
                            (pluralize('directory', 'directories', dircount),
                             pluralize('file', 'files', filecount)))
示例#6
0
    def do_run(self, options, args):

        if not args:
            args = ['.']

        for fs, path, is_dir in self.get_resources(args, single=True):
            if not is_dir:
                self.error(u"'%s' is not a dir\n" % path)
                return 1
            fs.cache_hint(True)
            if options.gui:
                from fs.browsewin import browse
                if path:
                    fs = fs.opendir(path)
                browse(fs, hide_dotfiles=not options.all)
            else:
                if options.depth < 0:
                    max_levels = None
                else:
                    max_levels = options.depth
                self.output(self.wrap_dirname(args[0] + '\n'))
                dircount, filecount = print_fs(fs, path or '',
                                               file_out=self.output_file,
                                               max_levels=max_levels,
                                               terminal_colors=self.terminal_colors,
                                               hide_dotfiles=not options.all,
                                               dirs_first=options.dirsfirst,
                                               files_wildcard=options.pattern,
                                               dirs_only=options.dirsonly)
                self.output('\n')
                def pluralize(one, many, count):
                    if count == 1:
                        return '%i %s' % (count, one)
                    else:
                        return '%i %s' % (count, many)

                self.output("%s, %s\n" % (pluralize('directory', 'directories', dircount),
                                  pluralize('file', 'files', filecount)))