bir iki hata düzeltildi.
- help düzgün çalışmıyordu... - usage optparse'da kullanılan bir değişken, yerine usage_text kullandım - updatedb komutu çalışsın. - ParseError yakalanmak için bir exception olsun.
This commit is contained in:
+15
-15
@@ -8,7 +8,7 @@ from pisi.config import config
|
|||||||
|
|
||||||
|
|
||||||
# globals
|
# globals
|
||||||
usage = """%prog <command> [options] [arguments]
|
usage_text = """%prog <command> [options] [arguments]
|
||||||
|
|
||||||
where <command> is one of:
|
where <command> is one of:
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class Command(object):
|
|||||||
"""generic help string for any command"""
|
"""generic help string for any command"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# now for the real parser THIS IS ABSOLUTELY NECESSARY
|
# now for the real parser THIS IS ABSOLUTELY NECESSARY
|
||||||
self.parser = OptionParser(usage=usage,
|
self.parser = OptionParser(usage=usage_text,
|
||||||
version="%prog " + pisi.__version__)
|
version="%prog " + pisi.__version__)
|
||||||
#self.parser.allow_interspersed_args = False
|
#self.parser.allow_interspersed_args = False
|
||||||
self.options()
|
self.options()
|
||||||
@@ -109,12 +109,12 @@ class Help(Command):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Help, self).__init__()
|
super(Help, self).__init__()
|
||||||
|
|
||||||
def run(self, args=None):
|
def run(self):
|
||||||
if not args:
|
if not self.args:
|
||||||
print usage
|
print usage_text
|
||||||
return
|
return
|
||||||
|
|
||||||
for arg in args:
|
for arg in self.args:
|
||||||
obj = cmdObject(arg, True)
|
obj = cmdObject(arg, True)
|
||||||
obj.help()
|
obj.help()
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ class Index(Command):
|
|||||||
indexhelper.index()
|
indexhelper.index()
|
||||||
else:
|
else:
|
||||||
print 'Indexing only a single directory supported'
|
print 'Indexing only a single directory supported'
|
||||||
self.die()
|
return
|
||||||
|
|
||||||
class UpdateDB(Command):
|
class UpdateDB(Command):
|
||||||
"""updatedb: update source and package databases"""
|
"""updatedb: update source and package databases"""
|
||||||
@@ -217,27 +217,27 @@ class UpdateDB(Command):
|
|||||||
self.help()
|
self.help()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
from pisi.cli import indexhelper
|
||||||
indexfile = self.args[0]
|
indexfile = self.args[0]
|
||||||
indexhelper.updatedb(indexfile)
|
indexhelper.updatedb(indexfile)
|
||||||
######## end commands #########
|
######## end commands #########
|
||||||
|
|
||||||
class ParserError:
|
class ParserError(Exception):
|
||||||
def __init__(self, msg):
|
pass
|
||||||
self.msg = msg
|
|
||||||
|
|
||||||
class Parser(OptionParser):
|
class Parser(OptionParser):
|
||||||
def __init__(self, usage, version):
|
def __init__(self, version):
|
||||||
OptionParser.__init__(self, usage=usage, version=version)
|
OptionParser.__init__(self, usage=usage_text, version=version)
|
||||||
|
|
||||||
def error(self, msg):
|
def error(self, msg):
|
||||||
raise ParserError(msg)
|
raise ParserError, msg
|
||||||
|
|
||||||
class PisiCLI(object):
|
class PisiCLI(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# first construct a parser for common options
|
# first construct a parser for common options
|
||||||
# this is really dummy
|
# this is really dummy
|
||||||
self.parser = Parser(usage=usage, version="%prog " + pisi.__version__)
|
self.parser = Parser(version="%prog " + pisi.__version__)
|
||||||
#self.parser.allow_interspersed_args = False
|
#self.parser.allow_interspersed_args = False
|
||||||
self.parser = commonopts(self.parser)
|
self.parser = commonopts(self.parser)
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@ class PisiCLI(object):
|
|||||||
self.die()
|
self.die()
|
||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
print usage
|
print usage_text
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def runCommand(self):
|
def runCommand(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user