--- /dev/null
+#!/usr/bin/env python
+# -*-coding: utf-8 -*-
+# vim: sw=4 ts=4 expandtab ai
+# pylint: disable-msg=C0301
+
+import os
+from optparse import OptionParser
+
+class OptParser(object):
+ # функция получения параметров из ком строки
+ 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")
+ (self.options, self.args) = parser.parse_args()
+
+ # Проверяем полученные параметры
+# if not self.options.dir or not self.options.cnt:
+# parser.error("options --directory or --count not present")
+ if not os.path.isdir(self.options.dir):
+ parser.error(self.options.dir, "- It`s not directory")
+ return self.options.dir, self.options.cnt
+
+ def __init__(self):
+ self.get()