wip
This commit is contained in:
		
							parent
							
								
									5aea99819a
								
							
						
					
					
						commit
						b4ebb9c5d3
					
				
							
								
								
									
										39
									
								
								tkdu.py
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								tkdu.py
									
									
									
									
									
								
							| @ -19,6 +19,7 @@ | ||||
| #    along with this program; if not, write to the Free Software | ||||
| #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| 
 | ||||
| from argparse import ArgumentParser | ||||
| import tkinter | ||||
| import sys | ||||
| import os | ||||
| @ -141,7 +142,7 @@ def allocate(path, files, canvas, x, y, w, h, first, depth): | ||||
|         color = colors[haskids] | ||||
|         if item[2] is None: | ||||
|             continue | ||||
|         x, y, w, h = pos = item[2] | ||||
|         x, y, w, h = item[2] | ||||
|         if w > 3*BORDER and h > 3*BORDER: | ||||
|             tk_call(canvas._w, | ||||
|                     "create", "rectangle", | ||||
| @ -407,7 +408,7 @@ def setdepth(e, c, i): | ||||
|     reconfigure(e) | ||||
| 
 | ||||
| 
 | ||||
| def main(f=sys.stdin): | ||||
| def old_main(f=sys.stdin): | ||||
|     files = {} | ||||
|     for line in f.readlines(): | ||||
|         sz, name = line[:-1].split(None, 1) | ||||
| @ -474,7 +475,6 @@ class DirDialog(tkinter.filedialog.LoadFileDialog): | ||||
|         self.set_filter(dir, pat) | ||||
|         names.sort() | ||||
|         subdirs = [os.pardir] | ||||
|         matchingfiles = [] | ||||
|         for name in names: | ||||
|             fullname = os.path.join(dir, name) | ||||
|             if os.path.isdir(fullname): | ||||
| @ -520,22 +520,49 @@ def main_builtin_du(args): | ||||
|         return | ||||
| 
 | ||||
|     if p == "-": | ||||
|         main() | ||||
|         old_main() | ||||
|     else: | ||||
|         p = abspath(p) | ||||
|         if os.path.isfile(p): | ||||
|             if p.endswith('.gz'): | ||||
|                 # gzipped file | ||||
|                 main(gzip.open(p, 'r')) | ||||
|                 old_main(gzip.open(p, 'r')) | ||||
|             else: | ||||
|                 main(open(p, 'r')) | ||||
|                 old_main(open(p, 'r')) | ||||
|         else: | ||||
|             putname(files, p, du(p, files)) | ||||
|             doit(p, files) | ||||
| 
 | ||||
| 
 | ||||
| argp = ArgumentParser( | ||||
|     prog='tkdu', | ||||
|     description='''Interactive explorer of `du` utility program. | ||||
|     'Useful when you need to interactively inspect disk usage | ||||
|     'on remote system but dont have `ncdu` or alike installed''', | ||||
|     epilog=''' | ||||
|     Controls: | ||||
|       * Press `q` to quit | ||||
|       * LMB: zoom in to item | ||||
|       * RMB: zoom out one level | ||||
|       * Press `1`..`9`: Show that many nested levels | ||||
|       * Press `0`: Show man nested levels | ||||
|     ''' | ||||
| ) | ||||
| 
 | ||||
| argp.add_argument( | ||||
|     'du_output', | ||||
|     help='du output file in plain text, gzipped or not' | ||||
| ) | ||||
| 
 | ||||
| 
 | ||||
| def main(): | ||||
|     args = argp.parse_args() | ||||
|     print(args) | ||||
| 
 | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     import sys | ||||
|     main() | ||||
|     main_builtin_du(sys.argv) | ||||
| 
 | ||||
| # vim:sts=4:sw=4: | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user