Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Unified Diff: Source/bindings/scripts/blink_idl_lexer.py

Issue 462613004: IDL parser: clean up cached lexer table updating code (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/blink_idl_lexer.py
diff --git a/Source/bindings/scripts/blink_idl_lexer.py b/Source/bindings/scripts/blink_idl_lexer.py
index 6bf439641fd3a7e4dfbca8e8024c09e5e95311ed..ba68c6c7dce1f27fee35f768d536401abfe5520b 100644
--- a/Source/bindings/scripts/blink_idl_lexer.py
+++ b/Source/bindings/scripts/blink_idl_lexer.py
@@ -69,6 +69,7 @@ tools_dir = os.path.join(third_party, os.pardir, 'tools')
sys.path.append(tools_dir)
from idl_parser.idl_lexer import IDLLexer
+LEXTAB = 'lextab'
REMOVE_TOKENS = ['COMMENT']
@@ -100,20 +101,15 @@ class BlinkIDLLexer(IDLLexer):
sys.path.append(outputdir)
if rewrite_tables:
- tablefile = os.path.join(outputdir, 'lextab.py')
-
- def unlink(filename):
+ tablefile_root = os.path.join(outputdir, LEXTAB)
+ # Also remove the .pyc/.pyo files, or they'll be used even if
+ # the .py file doesn't exist.
+ for ext in ('.py', '.pyc', '.pyo'):
try:
- os.unlink(filename)
+ os.unlink(tablefile_root + ext)
except OSError:
pass
- unlink(tablefile)
- # Also remove the .pyc/.pyo files, or they'll be used even if
- # the .py file doesn't exist.
- unlink(tablefile + 'c')
- unlink(tablefile + 'o')
-
IDLLexer.__init__(self)
# Overrides to parent class
self._RemoveTokens(REMOVE_TOKENS)
@@ -124,7 +120,7 @@ class BlinkIDLLexer(IDLLexer):
self._lexobj = lex.lex(object=self,
debug=debug,
optimize=optimize,
- lextab='lextab',
+ lextab=LEXTAB,
outputdir=outputdir)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698