锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久精品欧美日韩精品,亚洲伊人久久综合影院,国产精品午夜久久http://m.shnenglu.com/qywyh/category/10019.html璞?>blogzh-cnSun, 29 Mar 2009 14:56:55 GMTSun, 29 Mar 2009 14:56:55 GMT60鏍戠姸鏄劇ず鐩綍鑴氭湰pytreehttp://m.shnenglu.com/qywyh/articles/78289.html璞?/dc:creator>璞?/author>Sun, 29 Mar 2009 11:56:00 GMThttp://m.shnenglu.com/qywyh/articles/78289.htmlhttp://m.shnenglu.com/qywyh/comments/78289.htmlhttp://m.shnenglu.com/qywyh/articles/78289.html#Feedback0http://m.shnenglu.com/qywyh/comments/commentRss/78289.htmlhttp://m.shnenglu.com/qywyh/services/trackbacks/78289.html
  1 #!/usr/bin/env python
  2 
  3 import os
  4 import os.path
  5 import re
  6 import sys
  7 
  8 re_sp = re.compile("/")
  9 max_level = 0x7FFFFFFF
 10 
 11 
 12 def get_dirname(path) :
 13     """
 14     get the dirname by a path
 15     """
 16     global re_sp
 17 
 18     path = os.path.realpath(path)
 19     lst_ret = re_sp.split(path)
 20     if 0 == len(lst_ret) :
 21         return ""
 22     return lst_ret[len(lst_ret)-1]
 23 
 24 
 25 def get_startmark(path, lvl) :
 26     """
 27     get the startmark which will be displayed first
 28     """
 29     global max_level
 30 
 31     new_str = ""
 32     for i in range(lvl) :
 33         new_str += '|'
 34 
 35     if True == os.path.isdir(path) :
 36         if len(os.listdir(path)) > 0 and lvl == max_level:
 37             new_str += "+"
 38         else :
 39             new_str += "-"
 40         for i in range(lvl) :
 41             new_str += ' '
 42     else :
 43         new_str += '|'
 44         for i in range(lvl) :
 45             new_str += ' '
 46     
 47     return new_str
 48 
 49 
 50 def dfs_dir(path, lvl) :
 51     """
 52     deep first search the path
 53     """
 54     global max_level
 55 
 56     new_str = get_startmark(path, lvl)
 57     print "%s%s" % (new_str, get_dirname(path)),
 58 
 59     #check file type
 60     if True == os.path.islink(path) :
 61         print "%s" % "[L]",
 62     if True == os.path.ismount(path) :
 63         print "%s" % "[M]",
 64     if False == os.path.isdir(path) :
 65         print "[%d]" % os.path.getsize(path)    
 66     else :
 67         print ""
 68 
 69     if False == os.path.isdir(path) :
 70         return
 71 
 72     if lvl == max_level :
 73         return
 74 
 75     files = os.listdir(path)
 76     for each_file in files :
 77         new_path = "%s/%s" % (path, each_file)
 78         dfs_dir(new_path, lvl+1)
 79 
 80 
 81 def pytree() :
 82     """
 83     the main function to run
 84     """
 85     global max_level
 86 
 87     argvs = sys.argv
 88     
 89     if 0 == len(argvs) % 2 :
 90         print "Argvs invalid!"
 91         sys.exit(-1)
 92     else :
 93         cur_path = ""
 94 
 95         for tmp_str in argvs :
 96             if tmp_str.startswith("-") :
 97                 if "-i" == tmp_str :
 98                     idx = argvs.index(tmp_str)
 99                     max_level = int(argvs[idx+1])
100                 if "-p" == tmp_str:
101                     idx = argvs.index(tmp_str)
102                     cur_path = os.path.realpath(argvs[idx+1])
103 
104         if "" == cur_path :
105             cur_path = os.getcwd()
106 
107         if False == os.path.isdir(cur_path) :
108             print "Argvs invalid : path not exits!"
109         else :
110             print "List Dir : %s" % cur_path
111             dfs_dir(cur_path, 0)
112 
113     
114 
115 
116 if __name__ == "__main__" :
117     pytree()
118 




]]>
国产亚洲色婷婷久久99精品| 99国产欧美久久久精品蜜芽| 国产精品99久久不卡| 国产视频久久| 欧美亚洲国产精品久久高清| 亚洲欧洲精品成人久久奇米网 | 亚洲精品无码久久久久sm| 久久精品国产亚洲AV无码娇色 | 99久久精品免费国产大片| 热久久国产欧美一区二区精品| 精品熟女少妇AV免费久久| 91久久精一区二区三区大全| 人妻无码久久精品| 日本福利片国产午夜久久| 久久久久高潮综合影院| 精品久久人人做人人爽综合 | 久久狠狠爱亚洲综合影院| 亚洲国产精品久久久久婷婷老年| 亚洲伊人久久成综合人影院 | 久久91精品国产91| 成人精品一区二区久久| 色综合久久久久综合体桃花网| 久久久久亚洲爆乳少妇无| 精品免费tv久久久久久久| 久久夜色精品国产噜噜噜亚洲AV | 综合人妻久久一区二区精品| 国产精品免费久久久久电影网| 久久夜色精品国产网站| 亚洲国产精品高清久久久| 午夜福利91久久福利| 99久久伊人精品综合观看| 成人久久久观看免费毛片 | 国产999精品久久久久久| 91精品国产高清久久久久久io | A狠狠久久蜜臀婷色中文网| 久久99这里只有精品国产| 日韩精品无码久久一区二区三| 久久久久久久久久久免费精品| 久久夜色精品国产| 日本精品久久久久久久久免费| 久久亚洲电影|