aboutsummaryrefslogtreecommitdiff
path: root/python/bro.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/bro.py')
-rwxr-xr-xpython/bro.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/python/bro.py b/python/bro.py
index c4cf7e2..c6f74ce 100755
--- a/python/bro.py
+++ b/python/bro.py
@@ -79,6 +79,8 @@ def main(args=None):
help='Base 2 logarithm of the maximum input block size. '
'Range is 16 to 24. If set to 0, the value will be set based '
'on the quality. Defaults to 0.')
+ params.add_argument('--custom-dictionary', metavar="FILE", type=str, dest='dictfile',
+ help='Custom dictionary file.', default = None)
# set default values using global DEFAULT_PARAMS dictionary
parser.set_defaults(**DEFAULT_PARAMS)
@@ -103,13 +105,22 @@ def main(args=None):
else:
outfile = get_binary_stdio('stdout')
+ if options.dictfile:
+ if not os.path.isfile(options.dictfile):
+ parser.error('file "%s" not found' % options.dictfile)
+ with open(options.dictfile, "rb") as dictfile:
+ custom_dictionary = dictfile.read()
+ else:
+ custom_dictionary = ''
+
+
try:
if options.decompress:
- data = brotli.decompress(data)
+ data = brotli.decompress(data, dictionary=custom_dictionary)
else:
data = brotli.compress(
data, mode=options.mode, quality=options.quality,
- lgwin=options.lgwin, lgblock=options.lgblock)
+ lgwin=options.lgwin, lgblock=options.lgblock, dictionary=custom_dictionary)
except brotli.error as e:
parser.exit(1,'bro: error: %s: %s' % (e, options.infile or 'sys.stdin'))