@@ -548,7 +548,20 @@ <h1 class="title">Module <code>eyecite.tokenizers</code></h1>
548
548
cache_dir.mkdir(exist_ok=True)
549
549
cache = cache_dir / fingerprint
550
550
if cache.exists():
551
- hyperscan_db = hyperscan.loadb(cache.read_bytes())
551
+ cache_bytes = cache.read_bytes()
552
+ try:
553
+ # hyperscan >= 0.5.0 added a mandatory mode argument
554
+ hyperscan_db = hyperscan.loadb(
555
+ cache_bytes, mode=hyperscan.HS_MODE_BLOCK
556
+ )
557
+ except TypeError:
558
+ hyperscan_db = hyperscan.loadb(cache_bytes)
559
+ try:
560
+ # at some point Scratch became necessary --
561
+ # https://github.com/darvid/python-hyperscan/issues/50#issuecomment-1386243477
562
+ hyperscan_db.scratch = hyperscan.Scratch(hyperscan_db)
563
+ except AttributeError:
564
+ pass
552
565
553
566
if not hyperscan_db:
554
567
# No cache, so compile database.
@@ -849,7 +862,20 @@ <h3>Inherited members</h3>
849
862
cache_dir.mkdir(exist_ok=True)
850
863
cache = cache_dir / fingerprint
851
864
if cache.exists():
852
- hyperscan_db = hyperscan.loadb(cache.read_bytes())
865
+ cache_bytes = cache.read_bytes()
866
+ try:
867
+ # hyperscan >= 0.5.0 added a mandatory mode argument
868
+ hyperscan_db = hyperscan.loadb(
869
+ cache_bytes, mode=hyperscan.HS_MODE_BLOCK
870
+ )
871
+ except TypeError:
872
+ hyperscan_db = hyperscan.loadb(cache_bytes)
873
+ try:
874
+ # at some point Scratch became necessary --
875
+ # https://github.com/darvid/python-hyperscan/issues/50#issuecomment-1386243477
876
+ hyperscan_db.scratch = hyperscan.Scratch(hyperscan_db)
877
+ except AttributeError:
878
+ pass
853
879
854
880
if not hyperscan_db:
855
881
# No cache, so compile database.
@@ -935,7 +961,20 @@ <h3>Instance variables</h3>
935
961
cache_dir.mkdir(exist_ok=True)
936
962
cache = cache_dir / fingerprint
937
963
if cache.exists():
938
- hyperscan_db = hyperscan.loadb(cache.read_bytes())
964
+ cache_bytes = cache.read_bytes()
965
+ try:
966
+ # hyperscan >= 0.5.0 added a mandatory mode argument
967
+ hyperscan_db = hyperscan.loadb(
968
+ cache_bytes, mode=hyperscan.HS_MODE_BLOCK
969
+ )
970
+ except TypeError:
971
+ hyperscan_db = hyperscan.loadb(cache_bytes)
972
+ try:
973
+ # at some point Scratch became necessary --
974
+ # https://github.com/darvid/python-hyperscan/issues/50#issuecomment-1386243477
975
+ hyperscan_db.scratch = hyperscan.Scratch(hyperscan_db)
976
+ except AttributeError:
977
+ pass
939
978
940
979
if not hyperscan_db:
941
980
# No cache, so compile database.
0 commit comments