from heapq import nlargest
from fnmatch import fnmatch
-from misc import size_hum_read, _, NotebookWCloseBtns
+from misc import size_hum_read, _
from config import config
OUTTYPES = [
filelist = []
outtype, start_path, count, file_filter = get_criteria()
search_func = self.abstrac.filegetter(start_path, file_filter, get_stopit)
+
for fsize, fpath in nlargest(count, search_func):
filelist.append([int(fsize), fpath, size_hum_read(fsize)])
- self.present.show_out_toplevel(outtype, filelist)
+
+ results = [filelist, start_path]
+ self.present.show_out_toplevel(outtype, results)
def run(self):
self.present.run()
# Store only necessary files
for mask in file_filter:
if fnmatch(fname, mask):
- flpath = abspath(join(dirpath, fname))
+ # Crutch for non-unicode names
+ #flpath = unicode(join(dirpath, fname), '1251')
+ flpath = join(dirpath, fname)
# Show current path
self.presentation.show_current_status(flpath)
# Stop search via 'stopit' signal
self.outtype = params['outtype']
self.start_path = params['start_path']
self.count = params['count']
+ self.file_filter = params['file_filter'].split(';')
self.stopit = False
self.toplevel = None
def get_data(self):
- return self.outtype, self.start_path, int(self.count)
+ return self.outtype, self.start_path, int(self.count), self.file_filter
def get_stopit(self):
return False
def __init__(self, start_func, __):
import gtk
global gtk # for show_current_status()
+ from misc import NotebookWCloseBtns
self.nb = NotebookWCloseBtns()
self.nb.notebook.set_scrollable(True)
self.qty_spin.set_value(config['files']['count'])
# "Filter" label
- filter_label = gtk.Label(_('Filter'))
+ filter_label = gtk.Label(_('Filter (semicolon separated)'))
# "Filter" entry
self.filter_entry = gtk.Entry()
self.filter_entry.set_text(config['files']['filter'])
#=== Output type selecting ================================================
def show_out_toplevel(self, outtype, results):
- print 'Entering <' + outtype['name'] + '> output mode...'
out_submodule = __import__('files.' + outtype['name'], None, None, outtype)
self.out_toplevel = out_submodule.Gtk_Presentation(results).toplevel
self.nb.new_tab(self.out_toplevel, outtype['label'])