adding file with Saerch object
[findit] / src / optparser.py
1 #!/usr/bin/env python
2 # -*-coding: utf-8 -*-
3 # vim: sw=4 ts=4 expandtab ai
4 # pylint: disable-msg=C0301
5
6 import os
7 from optparse import OptionParser
8
9 class OptParser(object):
10     # функция получения параметров из ком строки
11     def get(self):
12         parser = OptionParser(usage="Usage: %prog -d -c", version="%prog 0.1.0")
13         # Парсим параметры ком строки, заодно проверяя их тип
14         parser.add_option('--dir', '-d', dest='dir', type="string", \
15                 help="starting path for search" )
16         parser.add_option('--count', '-c', metavar='COUNT',dest='cnt', type="int", \
17                help="count of files for print")
18         (self.options, self.args) = parser.parse_args()
19     
20         # Проверяем полученные параметры
21 #        if not self.options.dir or not self.options.cnt:
22 #            parser.error("options --directory or --count not present")
23 #        if not os.path.isdir(self.options.dir):
24 #            parser.error(self.options.dir, "- It`s not directory")
25         return self.options.dir, self.options.cnt
26
27     def __init__(self):
28         self.get()