mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
pep8
This commit is contained in:
parent
71e4857a47
commit
59a430f23a
48
setup.py
48
setup.py
@ -2,17 +2,22 @@
|
|||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
|
|
||||||
def check_version_info():
|
def check_version_info():
|
||||||
vi = sys.version_info
|
vi = sys.version_info
|
||||||
if vi[0] == 2 and vi[1:3] >= (7, 9):
|
if vi[0] == 2 and vi[1:3] >= (7, 9):
|
||||||
return None
|
return
|
||||||
raise SystemExit('calibre requires python >= 2.7.9 and < 3. Current python version: %s' % vi)
|
raise SystemExit(
|
||||||
|
'calibre requires python >= 2.7.9 and < 3. Current python version: %s'
|
||||||
|
% vi)
|
||||||
|
|
||||||
|
|
||||||
check_version_info()
|
check_version_info()
|
||||||
|
|
||||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||||
@ -20,18 +25,30 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|||||||
import setup.commands as commands
|
import setup.commands as commands
|
||||||
from setup import prints, get_warnings
|
from setup import prints, get_warnings
|
||||||
|
|
||||||
|
|
||||||
def option_parser():
|
def option_parser():
|
||||||
import optparse
|
import optparse
|
||||||
parser = optparse.OptionParser()
|
parser = optparse.OptionParser()
|
||||||
parser.add_option('-c', '--clean', default=False, action='store_true',
|
parser.add_option(
|
||||||
help=('Instead of running the command delete all files generated '
|
'-c',
|
||||||
'by the command'))
|
'--clean',
|
||||||
parser.add_option('--clean-backups', default=False, action='store_true',
|
default=False,
|
||||||
help='Delete all backup files from the source tree')
|
action='store_true',
|
||||||
parser.add_option('--clean-all', default=False, action='store_true',
|
help=('Instead of running the command delete all files generated '
|
||||||
help='Delete all machine generated files from the source tree')
|
'by the command'))
|
||||||
|
parser.add_option(
|
||||||
|
'--clean-backups',
|
||||||
|
default=False,
|
||||||
|
action='store_true',
|
||||||
|
help='Delete all backup files from the source tree')
|
||||||
|
parser.add_option(
|
||||||
|
'--clean-all',
|
||||||
|
default=False,
|
||||||
|
action='store_true',
|
||||||
|
help='Delete all machine generated files from the source tree')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def clean_backups():
|
def clean_backups():
|
||||||
for root, _, files in os.walk('.'):
|
for root, _, files in os.walk('.'):
|
||||||
for name in files:
|
for name in files:
|
||||||
@ -46,7 +63,7 @@ def main(args=sys.argv):
|
|||||||
print('\nWhere command is one of:')
|
print('\nWhere command is one of:')
|
||||||
print()
|
print()
|
||||||
for x in sorted(commands.__all__):
|
for x in sorted(commands.__all__):
|
||||||
print('%-20s -'%x, end=' ')
|
print('%-20s -' % x, end=' ')
|
||||||
c = getattr(commands, x)
|
c = getattr(commands, x)
|
||||||
desc = getattr(c, 'short_description', c.description)
|
desc = getattr(c, 'short_description', c.description)
|
||||||
print(desc)
|
print(desc)
|
||||||
@ -57,16 +74,16 @@ def main(args=sys.argv):
|
|||||||
|
|
||||||
command = args[1]
|
command = args[1]
|
||||||
if command not in commands.__all__:
|
if command not in commands.__all__:
|
||||||
print (command, 'is not a recognized command.')
|
print(command, 'is not a recognized command.')
|
||||||
print ('Valid commands:', ', '.join(commands.__all__))
|
print('Valid commands:', ', '.join(commands.__all__))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
command = getattr(commands, command)
|
command = getattr(commands, command)
|
||||||
|
|
||||||
parser = option_parser()
|
parser = option_parser()
|
||||||
command.add_all_options(parser)
|
command.add_all_options(parser)
|
||||||
parser.set_usage('Usage: python setup.py %s [options]\n\n'%args[1]+
|
parser.set_usage('Usage: python setup.py %s [options]\n\n' % args[1] +
|
||||||
command.description)
|
command.description)
|
||||||
|
|
||||||
opts, args = parser.parse_args(args)
|
opts, args = parser.parse_args(args)
|
||||||
|
|
||||||
@ -97,5 +114,6 @@ def main(args=sys.argv):
|
|||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user