예제 #1
0
    def _lls(self, dirname='', detail=1, recursive=0, all=False):
        "ローカル・ファイル・システムを幅優先で探索してファイル情報を出力する"
        dname = dirname if dirname else '.'
        if dirname.startswith('./'): dirname = dirname[2:]

        entries = os.listdir(dname)
        entries.sort()
        subdir = []
        if not detail:
            if not all:
                entries = [ent for ent in entries if not ent.startswith('.')]

            if dirname:
                cli.puts('%s:' % dirname)

            cli.showList(entries)
            cli.puts()
            for ent in entries:
                if os.path.isdir(os.path.join(dname, ent)): subdir.append(ent)

        else:
            if dirname: cli.puts('%s:' % dirname)
            for ent in entries:
                if not all and ent.startswith('.'): continue
                fmt, isdir = self._file_format(ent, dname)
                cli.puts(fmt)
                if isdir: subdir.append(ent)
            cli.puts()

        if not recursive: return
        del entries
        for dn in subdir:
            dirname = os.path.join(dname, dn)
            self._lls(dirname, detail, recursive, all)
예제 #2
0
 def date_cmd(self, line):
     """usage: date
 """
     #当日の日付情報を入手する
     tt = now()
     pattern = '%Y-%m-%d %H:%M:%S'
     dtext = _dt.fromtimestamp(tt).strftime(pattern)
     cli.puts(dtext)
예제 #3
0
    def echo_cmd(self, argv):
        """usage: echo [args] ..
- echo back argument """
        cmd = argv.pop(0)
        sep = ''
        for tt in argv:
            cli.puts(sep, end='')
            cli.puts(tt, end='')
            sep = ' '
        cli.puts()
예제 #4
0
    def lpwd_cmd(self, argv):
        """usage: lpwd
- print local work directory """
        cli.puts(os.getcwd())
예제 #5
0
    def verbose_cmd(self, argv):
        """usage: verbose
- toggle verbose flag  """
        cmd = 'alert'
        cli.verbose = not cli.verbose
        cli.puts('verbose:', cli.verbose, file=cli.syserr)