7459.4.8
by Francis J. Lacoste
Automatically include the YUI dependencies. |
1 |
#!/usr/bin/python
|
8687.15.4
by Karl Fogel
Add the copyright header block to more files; tweak format in a few files. |
2 |
#
|
3 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
|
4 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
7459.4.8
by Francis J. Lacoste
Automatically include the YUI dependencies. |
5 |
|
7459.4.9
by Francis J. Lacoste
Better docstring. |
6 |
"""Print the YUI modules we are using.
|
7 |
||
8752.2.1
by Curtis Hovey
Added base-layout macros to replace main-template-macros. |
8 |
It looks into the base-layout-macros.pt file for the yui modules included.
|
8524.1.1
by Edwin Grubbs
Refactored loading js in main-template.pt. |
9 |
It prints the path to the minified version of these modules.
|
7459.4.9
by Francis J. Lacoste
Better docstring. |
10 |
|
11 |
The output of this script is meant to be given to the lazr-js build.py script
|
|
12 |
so that they are included in the launchpad.js file.
|
|
13 |
"""
|
|
7459.4.8
by Francis J. Lacoste
Automatically include the YUI dependencies. |
14 |
|
15 |
||
16 |
__metaclass__ = type |
|
17 |
||
18 |
import os |
|
19 |
import re |
|
20 |
import sys |
|
21 |
||
22 |
TOP = os.path.normpath( |
|
23 |
os.path.join(os.path.dirname(__file__), '..')) |
|
24 |
ICING_ROOT = os.path.join(TOP, 'lib', 'canonical', 'launchpad', 'icing') |
|
25 |
MAIN_TEMPLATE = os.path.join( |
|
8752.2.1
by Curtis Hovey
Added base-layout macros to replace main-template-macros. |
26 |
TOP, 'lib', 'lp', 'app', 'templates', 'base-layout-macros.pt') |
7459.4.8
by Francis J. Lacoste
Automatically include the YUI dependencies. |
27 |
|
28 |
YUI_ROOT_RE = re.compile('yui string:\${icingroot}/(.*);') |
|
29 |
YUI_MOD_RE = re.compile('\${yui}/(.*?)\.js') |
|
30 |
||
8322.11.6
by Michael Nelson
Updated the utility yui-deps.py to include the yui2 dependencies in launchpad.js. |
31 |
|
32 |
yui_root = None |
|
7459.4.8
by Francis J. Lacoste
Automatically include the YUI dependencies. |
33 |
template = open(MAIN_TEMPLATE, 'r') |
34 |
for line in template: |
|
35 |
if yui_root is None: |
|
8322.11.10
by Michael Nelson
Moving the weight from launchpad.js to the individual pages that use the picker. |
36 |
match = YUI_ROOT_RE.search(line) |
37 |
if not match: |
|
38 |
continue
|
|
39 |
||
40 |
yui_root = os.path.join(ICING_ROOT, match.group(1)) |
|
41 |
if not os.path.isdir(yui_root): |
|
42 |
sys.stderr.write( |
|
43 |
"The found YUI root isn't valid: %s\n" % yui_root) |
|
44 |
sys.exit(1) |
|
7459.4.8
by Francis J. Lacoste
Automatically include the YUI dependencies. |
45 |
else: |
46 |
match = YUI_MOD_RE.search(line) |
|
8322.11.10
by Michael Nelson
Moving the weight from launchpad.js to the individual pages that use the picker. |
47 |
if not match: |
48 |
continue
|
|
49 |
# We want to bundle the minimized version
|
|
50 |
module = os.path.join(yui_root, match.group(1)) + '-min.js' |
|
7459.4.8
by Francis J. Lacoste
Automatically include the YUI dependencies. |
51 |
if not os.path.isfile(module): |
52 |
sys.stderr.write( |
|
53 |
"Found invalid YUI module: %s\n" % module) |
|
54 |
else: |
|
55 |
print module |