aboutsummaryrefslogtreecommitdiff
path: root/research
diff options
context:
space:
mode:
authorEugene Kliuchnikov <eustas.ru@gmail.com>2023-01-03 20:44:14 +0100
committerGitHub <noreply@github.com>2023-01-03 20:44:14 +0100
commitce92c95601500990ede414314ca1c6c955277efe (patch)
tree1d91a82efa9a9d0fc845bd6472bea4e057143975 /research
parent0ff60731f803851cfd816205b32bb1dc6657c3b0 (diff)
downloadbrotli-ce92c95601500990ede414314ca1c6c955277efe.zip
brotli-ce92c95601500990ede414314ca1c6c955277efe.tar.gz
brotli-ce92c95601500990ede414314ca1c6c955277efe.tar.bz2
brotlidump: fix dictionary file discovery (#997)
Diffstat (limited to 'research')
-rw-r--r--research/brotlidump.py11
l---------research/dictionary.bin1
2 files changed, 9 insertions, 3 deletions
diff --git a/research/brotlidump.py b/research/brotlidump.py
index 432e73b..ccdec61 100644
--- a/research/brotlidump.py
+++ b/research/brotlidump.py
@@ -14,6 +14,8 @@ from itertools import accumulate, repeat
from collections import defaultdict, deque
from functools import partial
+DICTIONARY_PATH = 'dictionary.bin'
+
class InvalidStream(Exception): pass
#lookup table
L, I, D = "literal", "insert&copy", "distance"
@@ -1263,7 +1265,7 @@ class WordList:
10, 10, 10, 9, 9, 8, 7, 7, 8, 7,
7, 6, 6, 5, 5]
def __init__(self):
- self.file = open('dict', 'rb')
+ self.file = open(DICTIONARY_PATH, 'rb')
self.compileActions()
def word(self, size, dist):
@@ -2340,9 +2342,12 @@ __test__ = {
}
-if __name__=='__main__':
+if __name__ == '__main__':
+ import os
import sys
- if len(sys.argv)>1:
+ here = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
+ DICTIONARY_PATH = os.path.realpath(os.path.join(here, DICTIONARY_PATH))
+ if len(sys.argv) > 1:
l = Layout(BitStream(open(sys.argv[1],'rb').read()))
l.processStream()
else:
diff --git a/research/dictionary.bin b/research/dictionary.bin
new file mode 120000
index 0000000..5fd53ea
--- /dev/null
+++ b/research/dictionary.bin
@@ -0,0 +1 @@
+../c/common/dictionary.bin \ No newline at end of file