Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/imh-pyth.../lib/python3....
File: compileall.py
"""Module/script to byte-compile all .py files to .pyc files.
[0] Fix | Delete
[1] Fix | Delete
When called as a script with arguments, this compiles the directories
[2] Fix | Delete
given as arguments recursively; the -l option prevents it from
[3] Fix | Delete
recursing into directories.
[4] Fix | Delete
[5] Fix | Delete
Without arguments, if compiles all modules on sys.path, without
[6] Fix | Delete
recursing into subdirectories. (Even though it should do so for
[7] Fix | Delete
packages -- for now, you'll have to deal with packages separately.)
[8] Fix | Delete
[9] Fix | Delete
See module py_compile for details of the actual byte-compilation.
[10] Fix | Delete
"""
[11] Fix | Delete
import os
[12] Fix | Delete
import sys
[13] Fix | Delete
import importlib.util
[14] Fix | Delete
import py_compile
[15] Fix | Delete
import struct
[16] Fix | Delete
import filecmp
[17] Fix | Delete
[18] Fix | Delete
from functools import partial
[19] Fix | Delete
from pathlib import Path
[20] Fix | Delete
[21] Fix | Delete
__all__ = ["compile_dir","compile_file","compile_path"]
[22] Fix | Delete
[23] Fix | Delete
def _walk_dir(dir, maxlevels, quiet=0):
[24] Fix | Delete
if quiet < 2 and isinstance(dir, os.PathLike):
[25] Fix | Delete
dir = os.fspath(dir)
[26] Fix | Delete
if not quiet:
[27] Fix | Delete
print('Listing {!r}...'.format(dir))
[28] Fix | Delete
try:
[29] Fix | Delete
names = os.listdir(dir)
[30] Fix | Delete
except OSError:
[31] Fix | Delete
if quiet < 2:
[32] Fix | Delete
print("Can't list {!r}".format(dir))
[33] Fix | Delete
names = []
[34] Fix | Delete
names.sort()
[35] Fix | Delete
for name in names:
[36] Fix | Delete
if name == '__pycache__':
[37] Fix | Delete
continue
[38] Fix | Delete
fullname = os.path.join(dir, name)
[39] Fix | Delete
if not os.path.isdir(fullname):
[40] Fix | Delete
yield fullname
[41] Fix | Delete
elif (maxlevels > 0 and name != os.curdir and name != os.pardir and
[42] Fix | Delete
os.path.isdir(fullname) and not os.path.islink(fullname)):
[43] Fix | Delete
yield from _walk_dir(fullname, maxlevels=maxlevels - 1,
[44] Fix | Delete
quiet=quiet)
[45] Fix | Delete
[46] Fix | Delete
def compile_dir(dir, maxlevels=None, ddir=None, force=False,
[47] Fix | Delete
rx=None, quiet=0, legacy=False, optimize=-1, workers=1,
[48] Fix | Delete
invalidation_mode=None, *, stripdir=None,
[49] Fix | Delete
prependdir=None, limit_sl_dest=None, hardlink_dupes=False):
[50] Fix | Delete
"""Byte-compile all modules in the given directory tree.
[51] Fix | Delete
[52] Fix | Delete
Arguments (only dir is required):
[53] Fix | Delete
[54] Fix | Delete
dir: the directory to byte-compile
[55] Fix | Delete
maxlevels: maximum recursion level (default `sys.getrecursionlimit()`)
[56] Fix | Delete
ddir: the directory that will be prepended to the path to the
[57] Fix | Delete
file as it is compiled into each byte-code file.
[58] Fix | Delete
force: if True, force compilation, even if timestamps are up-to-date
[59] Fix | Delete
quiet: full output with False or 0, errors only with 1,
[60] Fix | Delete
no output with 2
[61] Fix | Delete
legacy: if True, produce legacy pyc paths instead of PEP 3147 paths
[62] Fix | Delete
optimize: int or list of optimization levels or -1 for level of
[63] Fix | Delete
the interpreter. Multiple levels leads to multiple compiled
[64] Fix | Delete
files each with one optimization level.
[65] Fix | Delete
workers: maximum number of parallel workers
[66] Fix | Delete
invalidation_mode: how the up-to-dateness of the pyc will be checked
[67] Fix | Delete
stripdir: part of path to left-strip from source file path
[68] Fix | Delete
prependdir: path to prepend to beginning of original file path, applied
[69] Fix | Delete
after stripdir
[70] Fix | Delete
limit_sl_dest: ignore symlinks if they are pointing outside of
[71] Fix | Delete
the defined path
[72] Fix | Delete
hardlink_dupes: hardlink duplicated pyc files
[73] Fix | Delete
"""
[74] Fix | Delete
ProcessPoolExecutor = None
[75] Fix | Delete
if ddir is not None and (stripdir is not None or prependdir is not None):
[76] Fix | Delete
raise ValueError(("Destination dir (ddir) cannot be used "
[77] Fix | Delete
"in combination with stripdir or prependdir"))
[78] Fix | Delete
if ddir is not None:
[79] Fix | Delete
stripdir = dir
[80] Fix | Delete
prependdir = ddir
[81] Fix | Delete
ddir = None
[82] Fix | Delete
if workers < 0:
[83] Fix | Delete
raise ValueError('workers must be greater or equal to 0')
[84] Fix | Delete
if workers != 1:
[85] Fix | Delete
try:
[86] Fix | Delete
# Only import when needed, as low resource platforms may
[87] Fix | Delete
# fail to import it
[88] Fix | Delete
from concurrent.futures import ProcessPoolExecutor
[89] Fix | Delete
except ImportError:
[90] Fix | Delete
workers = 1
[91] Fix | Delete
if maxlevels is None:
[92] Fix | Delete
maxlevels = sys.getrecursionlimit()
[93] Fix | Delete
files = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels)
[94] Fix | Delete
success = True
[95] Fix | Delete
if workers != 1 and ProcessPoolExecutor is not None:
[96] Fix | Delete
# If workers == 0, let ProcessPoolExecutor choose
[97] Fix | Delete
workers = workers or None
[98] Fix | Delete
with ProcessPoolExecutor(max_workers=workers) as executor:
[99] Fix | Delete
results = executor.map(partial(compile_file,
[100] Fix | Delete
ddir=ddir, force=force,
[101] Fix | Delete
rx=rx, quiet=quiet,
[102] Fix | Delete
legacy=legacy,
[103] Fix | Delete
optimize=optimize,
[104] Fix | Delete
invalidation_mode=invalidation_mode,
[105] Fix | Delete
stripdir=stripdir,
[106] Fix | Delete
prependdir=prependdir,
[107] Fix | Delete
limit_sl_dest=limit_sl_dest,
[108] Fix | Delete
hardlink_dupes=hardlink_dupes),
[109] Fix | Delete
files)
[110] Fix | Delete
success = min(results, default=True)
[111] Fix | Delete
else:
[112] Fix | Delete
for file in files:
[113] Fix | Delete
if not compile_file(file, ddir, force, rx, quiet,
[114] Fix | Delete
legacy, optimize, invalidation_mode,
[115] Fix | Delete
stripdir=stripdir, prependdir=prependdir,
[116] Fix | Delete
limit_sl_dest=limit_sl_dest,
[117] Fix | Delete
hardlink_dupes=hardlink_dupes):
[118] Fix | Delete
success = False
[119] Fix | Delete
return success
[120] Fix | Delete
[121] Fix | Delete
def compile_file(fullname, ddir=None, force=False, rx=None, quiet=0,
[122] Fix | Delete
legacy=False, optimize=-1,
[123] Fix | Delete
invalidation_mode=None, *, stripdir=None, prependdir=None,
[124] Fix | Delete
limit_sl_dest=None, hardlink_dupes=False):
[125] Fix | Delete
"""Byte-compile one file.
[126] Fix | Delete
[127] Fix | Delete
Arguments (only fullname is required):
[128] Fix | Delete
[129] Fix | Delete
fullname: the file to byte-compile
[130] Fix | Delete
ddir: if given, the directory name compiled in to the
[131] Fix | Delete
byte-code file.
[132] Fix | Delete
force: if True, force compilation, even if timestamps are up-to-date
[133] Fix | Delete
quiet: full output with False or 0, errors only with 1,
[134] Fix | Delete
no output with 2
[135] Fix | Delete
legacy: if True, produce legacy pyc paths instead of PEP 3147 paths
[136] Fix | Delete
optimize: int or list of optimization levels or -1 for level of
[137] Fix | Delete
the interpreter. Multiple levels leads to multiple compiled
[138] Fix | Delete
files each with one optimization level.
[139] Fix | Delete
invalidation_mode: how the up-to-dateness of the pyc will be checked
[140] Fix | Delete
stripdir: part of path to left-strip from source file path
[141] Fix | Delete
prependdir: path to prepend to beginning of original file path, applied
[142] Fix | Delete
after stripdir
[143] Fix | Delete
limit_sl_dest: ignore symlinks if they are pointing outside of
[144] Fix | Delete
the defined path.
[145] Fix | Delete
hardlink_dupes: hardlink duplicated pyc files
[146] Fix | Delete
"""
[147] Fix | Delete
[148] Fix | Delete
if ddir is not None and (stripdir is not None or prependdir is not None):
[149] Fix | Delete
raise ValueError(("Destination dir (ddir) cannot be used "
[150] Fix | Delete
"in combination with stripdir or prependdir"))
[151] Fix | Delete
[152] Fix | Delete
success = True
[153] Fix | Delete
if quiet < 2 and isinstance(fullname, os.PathLike):
[154] Fix | Delete
fullname = os.fspath(fullname)
[155] Fix | Delete
name = os.path.basename(fullname)
[156] Fix | Delete
[157] Fix | Delete
dfile = None
[158] Fix | Delete
[159] Fix | Delete
if ddir is not None:
[160] Fix | Delete
dfile = os.path.join(ddir, name)
[161] Fix | Delete
[162] Fix | Delete
if stripdir is not None:
[163] Fix | Delete
fullname_parts = fullname.split(os.path.sep)
[164] Fix | Delete
stripdir_parts = stripdir.split(os.path.sep)
[165] Fix | Delete
ddir_parts = list(fullname_parts)
[166] Fix | Delete
[167] Fix | Delete
for spart, opart in zip(stripdir_parts, fullname_parts):
[168] Fix | Delete
if spart == opart:
[169] Fix | Delete
ddir_parts.remove(spart)
[170] Fix | Delete
[171] Fix | Delete
dfile = os.path.join(*ddir_parts)
[172] Fix | Delete
[173] Fix | Delete
if prependdir is not None:
[174] Fix | Delete
if dfile is None:
[175] Fix | Delete
dfile = os.path.join(prependdir, fullname)
[176] Fix | Delete
else:
[177] Fix | Delete
dfile = os.path.join(prependdir, dfile)
[178] Fix | Delete
[179] Fix | Delete
if isinstance(optimize, int):
[180] Fix | Delete
optimize = [optimize]
[181] Fix | Delete
[182] Fix | Delete
# Use set() to remove duplicates.
[183] Fix | Delete
# Use sorted() to create pyc files in a deterministic order.
[184] Fix | Delete
optimize = sorted(set(optimize))
[185] Fix | Delete
[186] Fix | Delete
if hardlink_dupes and len(optimize) < 2:
[187] Fix | Delete
raise ValueError("Hardlinking of duplicated bytecode makes sense "
[188] Fix | Delete
"only for more than one optimization level")
[189] Fix | Delete
[190] Fix | Delete
if rx is not None:
[191] Fix | Delete
mo = rx.search(fullname)
[192] Fix | Delete
if mo:
[193] Fix | Delete
return success
[194] Fix | Delete
[195] Fix | Delete
if limit_sl_dest is not None and os.path.islink(fullname):
[196] Fix | Delete
if Path(limit_sl_dest).resolve() not in Path(fullname).resolve().parents:
[197] Fix | Delete
return success
[198] Fix | Delete
[199] Fix | Delete
opt_cfiles = {}
[200] Fix | Delete
[201] Fix | Delete
if os.path.isfile(fullname):
[202] Fix | Delete
for opt_level in optimize:
[203] Fix | Delete
if legacy:
[204] Fix | Delete
opt_cfiles[opt_level] = fullname + 'c'
[205] Fix | Delete
else:
[206] Fix | Delete
if opt_level >= 0:
[207] Fix | Delete
opt = opt_level if opt_level >= 1 else ''
[208] Fix | Delete
cfile = (importlib.util.cache_from_source(
[209] Fix | Delete
fullname, optimization=opt))
[210] Fix | Delete
opt_cfiles[opt_level] = cfile
[211] Fix | Delete
else:
[212] Fix | Delete
cfile = importlib.util.cache_from_source(fullname)
[213] Fix | Delete
opt_cfiles[opt_level] = cfile
[214] Fix | Delete
[215] Fix | Delete
head, tail = name[:-3], name[-3:]
[216] Fix | Delete
if tail == '.py':
[217] Fix | Delete
if not force:
[218] Fix | Delete
try:
[219] Fix | Delete
mtime = int(os.stat(fullname).st_mtime)
[220] Fix | Delete
expect = struct.pack('<4sLL', importlib.util.MAGIC_NUMBER,
[221] Fix | Delete
0, mtime & 0xFFFF_FFFF)
[222] Fix | Delete
for cfile in opt_cfiles.values():
[223] Fix | Delete
with open(cfile, 'rb') as chandle:
[224] Fix | Delete
actual = chandle.read(12)
[225] Fix | Delete
if expect != actual:
[226] Fix | Delete
break
[227] Fix | Delete
else:
[228] Fix | Delete
return success
[229] Fix | Delete
except OSError:
[230] Fix | Delete
pass
[231] Fix | Delete
if not quiet:
[232] Fix | Delete
print('Compiling {!r}...'.format(fullname))
[233] Fix | Delete
try:
[234] Fix | Delete
for index, opt_level in enumerate(optimize):
[235] Fix | Delete
cfile = opt_cfiles[opt_level]
[236] Fix | Delete
ok = py_compile.compile(fullname, cfile, dfile, True,
[237] Fix | Delete
optimize=opt_level,
[238] Fix | Delete
invalidation_mode=invalidation_mode)
[239] Fix | Delete
if index > 0 and hardlink_dupes:
[240] Fix | Delete
previous_cfile = opt_cfiles[optimize[index - 1]]
[241] Fix | Delete
if filecmp.cmp(cfile, previous_cfile, shallow=False):
[242] Fix | Delete
os.unlink(cfile)
[243] Fix | Delete
os.link(previous_cfile, cfile)
[244] Fix | Delete
except py_compile.PyCompileError as err:
[245] Fix | Delete
success = False
[246] Fix | Delete
if quiet >= 2:
[247] Fix | Delete
return success
[248] Fix | Delete
elif quiet:
[249] Fix | Delete
print('*** Error compiling {!r}...'.format(fullname))
[250] Fix | Delete
else:
[251] Fix | Delete
print('*** ', end='')
[252] Fix | Delete
# escape non-printable characters in msg
[253] Fix | Delete
encoding = sys.stdout.encoding or sys.getdefaultencoding()
[254] Fix | Delete
msg = err.msg.encode(encoding, errors='backslashreplace').decode(encoding)
[255] Fix | Delete
print(msg)
[256] Fix | Delete
except (SyntaxError, UnicodeError, OSError) as e:
[257] Fix | Delete
success = False
[258] Fix | Delete
if quiet >= 2:
[259] Fix | Delete
return success
[260] Fix | Delete
elif quiet:
[261] Fix | Delete
print('*** Error compiling {!r}...'.format(fullname))
[262] Fix | Delete
else:
[263] Fix | Delete
print('*** ', end='')
[264] Fix | Delete
print(e.__class__.__name__ + ':', e)
[265] Fix | Delete
else:
[266] Fix | Delete
if ok == 0:
[267] Fix | Delete
success = False
[268] Fix | Delete
return success
[269] Fix | Delete
[270] Fix | Delete
def compile_path(skip_curdir=1, maxlevels=0, force=False, quiet=0,
[271] Fix | Delete
legacy=False, optimize=-1,
[272] Fix | Delete
invalidation_mode=None):
[273] Fix | Delete
"""Byte-compile all module on sys.path.
[274] Fix | Delete
[275] Fix | Delete
Arguments (all optional):
[276] Fix | Delete
[277] Fix | Delete
skip_curdir: if true, skip current directory (default True)
[278] Fix | Delete
maxlevels: max recursion level (default 0)
[279] Fix | Delete
force: as for compile_dir() (default False)
[280] Fix | Delete
quiet: as for compile_dir() (default 0)
[281] Fix | Delete
legacy: as for compile_dir() (default False)
[282] Fix | Delete
optimize: as for compile_dir() (default -1)
[283] Fix | Delete
invalidation_mode: as for compiler_dir()
[284] Fix | Delete
"""
[285] Fix | Delete
success = True
[286] Fix | Delete
for dir in sys.path:
[287] Fix | Delete
if (not dir or dir == os.curdir) and skip_curdir:
[288] Fix | Delete
if quiet < 2:
[289] Fix | Delete
print('Skipping current directory')
[290] Fix | Delete
else:
[291] Fix | Delete
success = success and compile_dir(
[292] Fix | Delete
dir,
[293] Fix | Delete
maxlevels,
[294] Fix | Delete
None,
[295] Fix | Delete
force,
[296] Fix | Delete
quiet=quiet,
[297] Fix | Delete
legacy=legacy,
[298] Fix | Delete
optimize=optimize,
[299] Fix | Delete
invalidation_mode=invalidation_mode,
[300] Fix | Delete
)
[301] Fix | Delete
return success
[302] Fix | Delete
[303] Fix | Delete
[304] Fix | Delete
def main():
[305] Fix | Delete
"""Script main program."""
[306] Fix | Delete
import argparse
[307] Fix | Delete
[308] Fix | Delete
parser = argparse.ArgumentParser(
[309] Fix | Delete
description='Utilities to support installing Python libraries.')
[310] Fix | Delete
parser.add_argument('-l', action='store_const', const=0,
[311] Fix | Delete
default=None, dest='maxlevels',
[312] Fix | Delete
help="don't recurse into subdirectories")
[313] Fix | Delete
parser.add_argument('-r', type=int, dest='recursion',
[314] Fix | Delete
help=('control the maximum recursion level. '
[315] Fix | Delete
'if `-l` and `-r` options are specified, '
[316] Fix | Delete
'then `-r` takes precedence.'))
[317] Fix | Delete
parser.add_argument('-f', action='store_true', dest='force',
[318] Fix | Delete
help='force rebuild even if timestamps are up to date')
[319] Fix | Delete
parser.add_argument('-q', action='count', dest='quiet', default=0,
[320] Fix | Delete
help='output only error messages; -qq will suppress '
[321] Fix | Delete
'the error messages as well.')
[322] Fix | Delete
parser.add_argument('-b', action='store_true', dest='legacy',
[323] Fix | Delete
help='use legacy (pre-PEP3147) compiled file locations')
[324] Fix | Delete
parser.add_argument('-d', metavar='DESTDIR', dest='ddir', default=None,
[325] Fix | Delete
help=('directory to prepend to file paths for use in '
[326] Fix | Delete
'compile-time tracebacks and in runtime '
[327] Fix | Delete
'tracebacks in cases where the source file is '
[328] Fix | Delete
'unavailable'))
[329] Fix | Delete
parser.add_argument('-s', metavar='STRIPDIR', dest='stripdir',
[330] Fix | Delete
default=None,
[331] Fix | Delete
help=('part of path to left-strip from path '
[332] Fix | Delete
'to source file - for example buildroot. '
[333] Fix | Delete
'`-d` and `-s` options cannot be '
[334] Fix | Delete
'specified together.'))
[335] Fix | Delete
parser.add_argument('-p', metavar='PREPENDDIR', dest='prependdir',
[336] Fix | Delete
default=None,
[337] Fix | Delete
help=('path to add as prefix to path '
[338] Fix | Delete
'to source file - for example / to make '
[339] Fix | Delete
'it absolute when some part is removed '
[340] Fix | Delete
'by `-s` option. '
[341] Fix | Delete
'`-d` and `-p` options cannot be '
[342] Fix | Delete
'specified together.'))
[343] Fix | Delete
parser.add_argument('-x', metavar='REGEXP', dest='rx', default=None,
[344] Fix | Delete
help=('skip files matching the regular expression; '
[345] Fix | Delete
'the regexp is searched for in the full path '
[346] Fix | Delete
'of each file considered for compilation'))
[347] Fix | Delete
parser.add_argument('-i', metavar='FILE', dest='flist',
[348] Fix | Delete
help=('add all the files and directories listed in '
[349] Fix | Delete
'FILE to the list considered for compilation; '
[350] Fix | Delete
'if "-", names are read from stdin'))
[351] Fix | Delete
parser.add_argument('compile_dest', metavar='FILE|DIR', nargs='*',
[352] Fix | Delete
help=('zero or more file and directory names '
[353] Fix | Delete
'to compile; if no arguments given, defaults '
[354] Fix | Delete
'to the equivalent of -l sys.path'))
[355] Fix | Delete
parser.add_argument('-j', '--workers', default=1,
[356] Fix | Delete
type=int, help='Run compileall concurrently')
[357] Fix | Delete
invalidation_modes = [mode.name.lower().replace('_', '-')
[358] Fix | Delete
for mode in py_compile.PycInvalidationMode]
[359] Fix | Delete
parser.add_argument('--invalidation-mode',
[360] Fix | Delete
choices=sorted(invalidation_modes),
[361] Fix | Delete
help=('set .pyc invalidation mode; defaults to '
[362] Fix | Delete
'"checked-hash" if the SOURCE_DATE_EPOCH '
[363] Fix | Delete
'environment variable is set, and '
[364] Fix | Delete
'"timestamp" otherwise.'))
[365] Fix | Delete
parser.add_argument('-o', action='append', type=int, dest='opt_levels',
[366] Fix | Delete
help=('Optimization levels to run compilation with.'
[367] Fix | Delete
'Default is -1 which uses optimization level of'
[368] Fix | Delete
'Python interpreter itself (specified by -O).'))
[369] Fix | Delete
parser.add_argument('-e', metavar='DIR', dest='limit_sl_dest',
[370] Fix | Delete
help='Ignore symlinks pointing outsite of the DIR')
[371] Fix | Delete
parser.add_argument('--hardlink-dupes', action='store_true',
[372] Fix | Delete
dest='hardlink_dupes',
[373] Fix | Delete
help='Hardlink duplicated pyc files')
[374] Fix | Delete
[375] Fix | Delete
args = parser.parse_args()
[376] Fix | Delete
compile_dests = args.compile_dest
[377] Fix | Delete
[378] Fix | Delete
if args.rx:
[379] Fix | Delete
import re
[380] Fix | Delete
args.rx = re.compile(args.rx)
[381] Fix | Delete
[382] Fix | Delete
if args.limit_sl_dest == "":
[383] Fix | Delete
args.limit_sl_dest = None
[384] Fix | Delete
[385] Fix | Delete
if args.recursion is not None:
[386] Fix | Delete
maxlevels = args.recursion
[387] Fix | Delete
else:
[388] Fix | Delete
maxlevels = args.maxlevels
[389] Fix | Delete
[390] Fix | Delete
if args.opt_levels is None:
[391] Fix | Delete
args.opt_levels = [-1]
[392] Fix | Delete
[393] Fix | Delete
if len(args.opt_levels) == 1 and args.hardlink_dupes:
[394] Fix | Delete
parser.error(("Hardlinking of duplicated bytecode makes sense "
[395] Fix | Delete
"only for more than one optimization level."))
[396] Fix | Delete
[397] Fix | Delete
if args.ddir is not None and (
[398] Fix | Delete
args.stripdir is not None or args.prependdir is not None
[399] Fix | Delete
):
[400] Fix | Delete
parser.error("-d cannot be used in combination with -s or -p")
[401] Fix | Delete
[402] Fix | Delete
# if flist is provided then load it
[403] Fix | Delete
if args.flist:
[404] Fix | Delete
try:
[405] Fix | Delete
with (sys.stdin if args.flist=='-' else open(args.flist)) as f:
[406] Fix | Delete
for line in f:
[407] Fix | Delete
compile_dests.append(line.strip())
[408] Fix | Delete
except OSError:
[409] Fix | Delete
if args.quiet < 2:
[410] Fix | Delete
print("Error reading file list {}".format(args.flist))
[411] Fix | Delete
return False
[412] Fix | Delete
[413] Fix | Delete
if args.invalidation_mode:
[414] Fix | Delete
ivl_mode = args.invalidation_mode.replace('-', '_').upper()
[415] Fix | Delete
invalidation_mode = py_compile.PycInvalidationMode[ivl_mode]
[416] Fix | Delete
else:
[417] Fix | Delete
invalidation_mode = None
[418] Fix | Delete
[419] Fix | Delete
success = True
[420] Fix | Delete
try:
[421] Fix | Delete
if compile_dests:
[422] Fix | Delete
for dest in compile_dests:
[423] Fix | Delete
if os.path.isfile(dest):
[424] Fix | Delete
if not compile_file(dest, args.ddir, args.force, args.rx,
[425] Fix | Delete
args.quiet, args.legacy,
[426] Fix | Delete
invalidation_mode=invalidation_mode,
[427] Fix | Delete
stripdir=args.stripdir,
[428] Fix | Delete
prependdir=args.prependdir,
[429] Fix | Delete
optimize=args.opt_levels,
[430] Fix | Delete
limit_sl_dest=args.limit_sl_dest,
[431] Fix | Delete
hardlink_dupes=args.hardlink_dupes):
[432] Fix | Delete
success = False
[433] Fix | Delete
else:
[434] Fix | Delete
if not compile_dir(dest, maxlevels, args.ddir,
[435] Fix | Delete
args.force, args.rx, args.quiet,
[436] Fix | Delete
args.legacy, workers=args.workers,
[437] Fix | Delete
invalidation_mode=invalidation_mode,
[438] Fix | Delete
stripdir=args.stripdir,
[439] Fix | Delete
prependdir=args.prependdir,
[440] Fix | Delete
optimize=args.opt_levels,
[441] Fix | Delete
limit_sl_dest=args.limit_sl_dest,
[442] Fix | Delete
hardlink_dupes=args.hardlink_dupes):
[443] Fix | Delete
success = False
[444] Fix | Delete
return success
[445] Fix | Delete
else:
[446] Fix | Delete
return compile_path(legacy=args.legacy, force=args.force,
[447] Fix | Delete
quiet=args.quiet,
[448] Fix | Delete
invalidation_mode=invalidation_mode)
[449] Fix | Delete
except KeyboardInterrupt:
[450] Fix | Delete
if args.quiet < 2:
[451] Fix | Delete
print("\n[interrupted]")
[452] Fix | Delete
return False
[453] Fix | Delete
return True
[454] Fix | Delete
[455] Fix | Delete
[456] Fix | Delete
if __name__ == '__main__':
[457] Fix | Delete
exit_status = int(not main())
[458] Fix | Delete
sys.exit(exit_status)
[459] Fix | Delete
[460] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function