Procházet zdrojové kódy

cache=True now uses a temp directory instead of working directory

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.0
Erez Sh před 3 roky
rodič
revize
f560ce1754
1 změnil soubory, kde provedl 2 přidání a 1 odebrání
  1. +2
    -1
      lark/lark.py

+ 2
- 1
lark/lark.py Zobrazit soubor

@@ -3,6 +3,7 @@ from lark.exceptions import UnexpectedCharacters, UnexpectedInput, UnexpectedTok

import sys, os, pickle, hashlib
from io import open
import tempfile


from .utils import STRING_TYPE, Serialize, SerializeMemoizer, FS, isascii, logger
@@ -244,7 +245,7 @@ class Lark(Serialize):
options_str = ''.join(k+str(v) for k, v in options.items() if k not in unhashable)
s = grammar + options_str + __version__
md5 = hashlib.md5(s.encode()).hexdigest()
cache_fn = '.lark_cache_%s.tmp' % md5
cache_fn = tempfile.gettempdir() + '/.lark_cache_%s.tmp' % md5

if FS.exists(cache_fn):
logger.debug('Loading grammar from cache: %s', cache_fn)


Načítá se…
Zrušit
Uložit