From 6f27156fbe17573b80e391160d4862f5ad19da18 Mon Sep 17 00:00:00 2001 From: Alexandr Popov Date: Sun, 15 Mar 2009 11:18:21 +0300 Subject: [PATCH] very big Bad commit :) - adding old created files --- src/cli.py | 6 ++++-- src/configure.py | 6 +++--- src/filelist.py | 17 ----------------- src/input.py | 13 ------------- src/main.py | 14 ++++---------- src/optparser.py | 16 ++++++++++------ src/resultlist.py | 17 +++++++++++++++++ src/searchfile.py | 6 +++--- 8 files changed, 41 insertions(+), 54 deletions(-) mode change 100644 => 100755 src/cli.py mode change 100644 => 100755 src/configure.py delete mode 100644 src/filelist.py delete mode 100644 src/input.py mode change 100644 => 100755 src/main.py mode change 100644 => 100755 src/optparser.py create mode 100755 src/resultlist.py mode change 100644 => 100755 src/searchfile.py diff --git a/src/cli.py b/src/cli.py old mode 100644 new mode 100755 index d8670a4..3f88185 --- a/src/cli.py +++ b/src/cli.py @@ -1,3 +1,4 @@ + #!/usr/bin/env python # -*-coding: utf-8 -*- # vim: sw=4 ts=4 expandtab ai @@ -8,5 +9,6 @@ class Cli(object): def __init__(self): pass - def show(self, path, size): - print "%12g %s" % (size/1024./1024., path) + def show(self, fproperties): + path, size = fproperties + print "%12g %s" % (size/1024./1024., path) \ No newline at end of file diff --git a/src/configure.py b/src/configure.py old mode 100644 new mode 100755 index eb3e311..086fc41 --- a/src/configure.py +++ b/src/configure.py @@ -7,13 +7,13 @@ class Configure(object): def load(self, config_file): - # Здесь планируется загрузка конфига из файла - пока так присваивается + # Здесь планируется загрузка конфига из файла - пока так присваивается self.default_start_dir = '/home/' self.default_count = 10 - + def get(self, param): return self.__getattribute__(param) def __init__(self): config_file='findit.cfg' - self.load(config_file) + self.load(config_file) \ No newline at end of file diff --git a/src/filelist.py b/src/filelist.py deleted file mode 100644 index 73eb5d1..0000000 --- a/src/filelist.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python -# -*-coding: utf-8 -*- -# vim: sw=4 ts=4 expandtab ai -# pylint: disable-msg=C0301 - -class FileList(object): - - def __init__(self, out_ui): - self.ui = out_ui - self.flist = [] - - def add(self, fpath, fsize): - self.flist.append((fpath, fsize)) - - def show(self): - for fpath, fsize in self.flist: - self.ui.show(fpath, fsize) diff --git a/src/input.py b/src/input.py deleted file mode 100644 index 51d612d..0000000 --- a/src/input.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -# -*-coding: utf-8 -*- -# vim: sw=4 ts=4 expandtab ai -# pylint: disable-msg=C0301 - -class Input(object): - def __init__(self, parser): - self.ui = parser - self.get_st_par() - - def get_st_par(self): - self.st_dir, self.st_cnt = self.ui.get() - return self.st_dir, self.st_cnt diff --git a/src/main.py b/src/main.py old mode 100644 new mode 100755 index b6a1cf9..3c7b7ae --- a/src/main.py +++ b/src/main.py @@ -9,12 +9,6 @@ pass from optparser import OptParser vvod = OptParser() -# Каким то макаром принимаем решение о объекте ввода -pass -# решили какой - подгружаем его -from input import Input -input = Input(vvod) - # Каким то макаром принимаем решение о объекте конфигурации pass # решили какой - подгружаем его @@ -30,17 +24,17 @@ output = Cli() # Каким то макаром принимаем решение о объекте результата pass # решили какой - подгружаем его -from filelist import FileList -result = FileList(output) +from resultlist import ResultList +result = ResultList(output) # Каким то макаром принимаем решение о объекте поиска pass # решили какой - подгружаем его from searchfile import SearchFile -search = SearchFile(input, config, result) +search = SearchFile(vvod, config, result) # Запускаем поиск search.run() # Выводим результат -result.show() +result.show() \ No newline at end of file diff --git a/src/optparser.py b/src/optparser.py old mode 100644 new mode 100755 index bfa0047..293a3b8 --- a/src/optparser.py +++ b/src/optparser.py @@ -7,17 +7,21 @@ import os from optparse import OptionParser class OptParser(object): - + def __init__(self): - self.get() - - # функция получения параметров из ком строки - def get(self): parser = OptionParser(usage="Usage: %prog -d -c", version="%prog 0.1.0") # Парсим параметры ком строки parser.add_option('--dir', '-d', dest='dir', type="string", \ help="starting path for search" ) parser.add_option('--count', '-c', metavar='COUNT',dest='cnt', type="int", \ help="count of files for print") + parser.add_option('--config', '-C', metavar='CONFIG',dest='cfg', type="string", \ + help="config file") (self.options, self.args) = parser.parse_args() - return self.options.dir, self.options.cnt + + # функция получения параметров из ком строки + def get(self): + return self.options + + def get_st_par(self): + return self.options.dir, self.options.cnt \ No newline at end of file diff --git a/src/resultlist.py b/src/resultlist.py new file mode 100755 index 0000000..1099eb8 --- /dev/null +++ b/src/resultlist.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python +# -*-coding: utf-8 -*- +# vim: sw=4 ts=4 expandtab ai +# pylint: disable-msg=C0301 + +class ResultList(object): + + def __init__(self, out_ui): + self.ui = out_ui + self.rlist = [] + + def add(self, rproperties): + self.rlist.append(rproperties) + + def show(self): + for rproperties in self.rlist: + self.ui.show(rproperties) \ No newline at end of file diff --git a/src/searchfile.py b/src/searchfile.py old mode 100644 new mode 100755 index 5b663d6..e128396 --- a/src/searchfile.py +++ b/src/searchfile.py @@ -5,8 +5,8 @@ class SearchFile(object): - def __init__(self, input, config, result): - self.path, self.count = input.get_st_par() + def __init__(self, vvod, config, result): + self.path, self.count = vvod.get_st_par() if not self.path: self.path = config.get("default_start_dir") if not self.count: @@ -25,4 +25,4 @@ class SearchFile(object): def run(self): import heapq for fsize, fpath in heapq.nlargest(self.count, self.filesorter(self.path)): - self.result.add(fpath, fsize) + self.result.add((fpath, fsize)) \ No newline at end of file -- 1.7.9.5