This commit is contained in:
Kovid Goyal 2017-02-01 10:17:39 +05:30
parent 71e4857a47
commit 59a430f23a

View File

@ -8,11 +8,16 @@ __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(
'-c',
'--clean',
default=False,
action='store_true',
help=('Instead of running the command delete all files generated ' help=('Instead of running the command delete all files generated '
'by the command')) 'by the command'))
parser.add_option('--clean-backups', default=False, action='store_true', parser.add_option(
'--clean-backups',
default=False,
action='store_true',
help='Delete all backup files from the source tree') help='Delete all backup files from the source tree')
parser.add_option('--clean-all', default=False, action='store_true', parser.add_option(
'--clean-all',
default=False,
action='store_true',
help='Delete all machine generated files from the source tree') 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:
@ -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())