summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3
diff options
context:
space:
mode:
authorNed Deily <nad@acm.org>2012-09-09 01:47:27 (GMT)
committerNed Deily <nad@acm.org>2012-09-09 01:47:27 (GMT)
commit10fc104fede2449468fb9488bb44a9663382b3a8 (patch)
treeb40010b50230907c0cc16d830d0536dd30883784 /Lib/lib2to3
parentb9495c78a16c9fc0ddf55caa88f5eeda959da002 (diff)
downloadcpython-10fc104fede2449468fb9488bb44a9663382b3a8.zip
cpython-10fc104fede2449468fb9488bb44a9663382b3a8.tar.gz
cpython-10fc104fede2449468fb9488bb44a9663382b3a8.tar.bz2
Issue #15822: Fix installation of lib2to3 grammar pickles to ensure
they are created in the install locations and with the proper timestamp. (Solution suggested by MvL)
Diffstat (limited to 'Lib/lib2to3')
-rw-r--r--Lib/lib2to3/pgen2/driver.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/lib2to3/pgen2/driver.py b/Lib/lib2to3/pgen2/driver.py
index 16adec0..39dafb9 100644
--- a/Lib/lib2to3/pgen2/driver.py
+++ b/Lib/lib2to3/pgen2/driver.py
@@ -138,3 +138,20 @@ def _newer(a, b):
if not os.path.exists(b):
return True
return os.path.getmtime(a) >= os.path.getmtime(b)
+
+
+def main(*args):
+ """Main program, when run as a script: produce grammar pickle files.
+
+ Calls load_grammar for each argument, a path to a grammar text file.
+ """
+ if not args:
+ args = sys.argv[1:]
+ logging.basicConfig(level=logging.INFO, stream=sys.stdout,
+ format='%(message)s')
+ for gt in args:
+ load_grammar(gt, save=True, force=True)
+ return True
+
+if __name__ == "__main__":
+ sys.exit(int(not main()))