Ver código fonte

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 3 anos atrás
pai
commit
f560ce1754
1 arquivos alterados com 2 adições e 1 exclusões
  1. +2
    -1
      lark/lark.py

+ 2
- 1
lark/lark.py Ver arquivo

@@ -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)


Carregando…
Cancelar
Salvar