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

Side by Side Diff: third_party/jinja2/_markupsafe/_bundle.py

Issue 23506004: Update Jinja2 (Python template library) to 2.7.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # -*- coding: utf-8 -*-
2 """
3 jinja2._markupsafe._bundle
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~
5
6 This script pulls in markupsafe from a source folder and
7 bundles it with Jinja2. It does not pull in the speedups
8 module though.
9
10 :copyright: Copyright 2010 by the Jinja team, see AUTHORS.
11 :license: BSD, see LICENSE for details.
12 """
13 import sys
14 import os
15 import re
16
17
18 def rewrite_imports(lines):
19 for idx, line in enumerate(lines):
20 new_line = re.sub(r'(import|from)\s+markupsafe\b',
21 r'\1 jinja2._markupsafe', line)
22 if new_line != line:
23 lines[idx] = new_line
24
25
26 def main():
27 if len(sys.argv) != 2:
28 print 'error: only argument is path to markupsafe'
29 sys.exit(1)
30 basedir = os.path.dirname(__file__)
31 markupdir = sys.argv[1]
32 for filename in os.listdir(markupdir):
33 if filename.endswith('.py'):
34 f = open(os.path.join(markupdir, filename))
35 try:
36 lines = list(f)
37 finally:
38 f.close()
39 rewrite_imports(lines)
40 f = open(os.path.join(basedir, filename), 'w')
41 try:
42 for line in lines:
43 f.write(line)
44 finally:
45 f.close()
46
47
48 if __name__ == '__main__':
49 main()
OLDNEW
« no previous file with comments | « third_party/jinja2/_markupsafe/__init__.py ('k') | third_party/jinja2/_markupsafe/_constants.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698