mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 07:38:21 +00:00
Add --bom command-line option to prefix the script with a BOM
This commit is contained in:
parent
c3be2bd216
commit
1d7142a698
1 changed files with 9 additions and 1 deletions
10
main.py
10
main.py
|
@ -218,6 +218,7 @@ Usage: {progname}
|
||||||
[--assetid=<UUID>] * specify the asset UUID of the script
|
[--assetid=<UUID>] * specify the asset UUID of the script
|
||||||
[--shortname=<name>] * specify the script's short file name
|
[--shortname=<name>] * specify the script's short file name
|
||||||
[--prettify] Prettify source file. Disables all -O options.
|
[--prettify] Prettify source file. Disables all -O options.
|
||||||
|
[--bom] Prefix script with a UTF-8 byte-order mark
|
||||||
filename input file
|
filename input file
|
||||||
|
|
||||||
Options marked with * are used to define the preprocessor macros __AGENTID__,
|
Options marked with * are used to define the preprocessor macros __AGENTID__,
|
||||||
|
@ -384,7 +385,7 @@ def main(argv):
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.gnu_getopt(argv[1:], 'hO:o:p:P:HTyb:L:',
|
opts, args = getopt.gnu_getopt(argv[1:], 'hO:o:p:P:HTyb:L:',
|
||||||
('optimizer-options=', 'help', 'version', 'output=', 'header',
|
('optimizer-options=', 'help', 'version', 'output=', 'header',
|
||||||
'timestamp', 'python-exceptions', 'prettify',
|
'timestamp', 'python-exceptions', 'prettify', 'bom',
|
||||||
'preproc=', 'precmd=', 'prearg=', 'prenodef', 'preshow',
|
'preproc=', 'precmd=', 'prearg=', 'prenodef', 'preshow',
|
||||||
'avid=', 'avname=', 'assetid=', 'shortname=', 'builtins='
|
'avid=', 'avname=', 'assetid=', 'shortname=', 'builtins='
|
||||||
'libdata='))
|
'libdata='))
|
||||||
|
@ -407,6 +408,7 @@ def main(argv):
|
||||||
preshow = False
|
preshow = False
|
||||||
raise_exception = False
|
raise_exception = False
|
||||||
prettify = False
|
prettify = False
|
||||||
|
bom = False
|
||||||
builtins = None
|
builtins = None
|
||||||
libdata = None
|
libdata = None
|
||||||
|
|
||||||
|
@ -509,6 +511,9 @@ def main(argv):
|
||||||
|
|
||||||
elif opt == '--prettify':
|
elif opt == '--prettify':
|
||||||
prettify = True
|
prettify = True
|
||||||
|
|
||||||
|
elif opt == '--bom':
|
||||||
|
bom = True
|
||||||
del opts
|
del opts
|
||||||
|
|
||||||
if prettify:
|
if prettify:
|
||||||
|
@ -684,6 +689,9 @@ def main(argv):
|
||||||
|
|
||||||
del script_header, script_timestamp
|
del script_header, script_timestamp
|
||||||
|
|
||||||
|
if bom:
|
||||||
|
script = b'\xEF\xBB\xBF' + script
|
||||||
|
|
||||||
if outfile == '-':
|
if outfile == '-':
|
||||||
sys.stdout.write(script)
|
sys.stdout.write(script)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue