Files
deb-python-pecan/pecan/commands/base.py
Jonathan LaCour bed5cbfa14 After a full-scale scan with pep8.py and pyflakes, identified and
resolved most of our PEP8 compliance issues.
2012-03-11 09:52:25 -07:00

50 lines
1.3 KiB
Python

"""
PasteScript base command for Pecan.
"""
from pecan import load_app
from paste.script import command as paste_command
import os.path
class Command(paste_command.Command):
"""
Base class for Pecan commands.
This provides some standard functionality for interacting with Pecan
applications and handles some of the basic PasteScript command cruft.
See ``paste.script.command.Command`` for more information.
"""
# command information
group_name = 'Pecan'
summary = ''
# command parser
parser = paste_command.Command.standard_parser()
def run(self, args):
try:
return paste_command.Command.run(self, args)
except paste_command.BadCommand, ex:
ex.args[0] = self.parser.error(ex.args[0])
raise
def load_app(self):
return load_app(self.validate_file(self.args))
def logging_file_config(self, config_file):
if os.path.splitext(config_file)[1].lower() == '.ini':
paste_command.Command.logging_file_config(self, config_file)
def validate_file(self, argv):
if not argv or not os.path.isfile(argv[0]):
raise paste_command.BadCommand(
'This command needs a valid config file.'
)
return argv[0]
def command(self):
pass