Merge lp:~rharding/launchpad/yuiv4 into lp:launchpad

Proposed by Richard Harding
Status: Work in progress
Proposed branch: lp:~rharding/launchpad/yuiv4
Merge into: lp:launchpad
Diff against target: 180 lines (+120/-13)
3 files modified
Makefile (+1/-1)
buildout-templates/bin/yui_extract.in (+113/-0)
buildout.cfg (+6/-12)
To merge this branch: bzr merge lp:~rharding/launchpad/yuiv4
Reviewer Review Type Date Requested Status
Launchpad code reviewers Pending
Review via email: mp+117800@code.launchpad.net

Description of the change

TBD

To post a comment you must log in.

Unmerged revisions

15733. By Richard Harding

I wonder if this will work

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile'
--- Makefile 2012-07-13 01:55:27 +0000
+++ Makefile 2012-08-01 21:25:23 +0000
@@ -66,7 +66,7 @@
66 bin/killservice bin/kill-test-services bin/lint.sh bin/retest \66 bin/killservice bin/kill-test-services bin/lint.sh bin/retest \
67 bin/run bin/run-testapp bin/sprite-util bin/start_librarian bin/stxdocs \67 bin/run bin/run-testapp bin/sprite-util bin/start_librarian bin/stxdocs \
68 bin/tags bin/test bin/tracereport bin/twistd bin/update-download-cache \68 bin/tags bin/test bin/tracereport bin/twistd bin/update-download-cache \
69 bin/watch_jsbuild69 bin/watch_jsbuild bin/yui_extract
7070
71BUILDOUT_TEMPLATES = buildout-templates/_pythonpath.py.in71BUILDOUT_TEMPLATES = buildout-templates/_pythonpath.py.in
7272
7373
=== added file 'buildout-templates/bin/yui_extract.in'
--- buildout-templates/bin/yui_extract.in 1970-01-01 00:00:00 +0000
+++ buildout-templates/bin/yui_extract.in 2012-08-01 21:25:23 +0000
@@ -0,0 +1,113 @@
1#!${buildout:executable}
2#
3# Copyright 2012 Canonical Ltd. This software is licensed under the
4# GNU Affero General Public License version 3 (see the file LICENSE).
5"""
6Extract the YUI library from the zip file in the download-cache into the build
7directory for our JS.
8
9Usage:
10
11 yui_extract -y 3.5.1 -d download-cache/dist -b build/js
12
13"""
14import argparse
15import os
16from os.path import (
17 basename,
18 exists,
19 isdir,
20 join,
21 )
22import shutil
23import sys
24from zipfile import ZipFile
25
26YUI_ZIP = "yui_%s.zip"
27YUI_DIR = None
28
29
30def _parse_args():
31 """Parse out the command options. We want to support
32
33 """
34 desc = "Extract YUI zip files into the build tree."
35
36 parser = argparse.ArgumentParser(description=desc)
37
38 parser.add_argument('-y', '--yui-version', dest='yui_version',
39 action='store',
40 default=None,
41 required=True,
42 help='What version of YUI to extract.')
43
44 parser.add_argument('-d', '--download-cache', dest="download_cache",
45 action="store",
46 default=None,
47 required=True,
48 help="Location of the download cache to find the YUI zip file.")
49
50 parser.add_argument('-b', '--build-dir', dest="build_dir",
51 action="store",
52 default=None,
53 required=True,
54 help="Location to extract the YUI zip to.")
55
56 args = parser.parse_args()
57 return args
58
59
60def _unzip(yui_zip, build_dir):
61 """Unzip the yui file and place the files into the build dir."""
62 # Zip extraction occurs into the cwd so change that.
63 yui_dirname = basename(yui_zip).replace('.zip', '').replace('_', '-')
64 yui_dir = join(build_dir, yui_dirname)
65 tmp_dir = join(build_dir, 'tmp')
66
67 # If the directory isn't there to remove, ignore it. If it does exist
68 # remove it so we drop our zip contents.
69 shutil.rmtree(yui_dir, ignore_errors=True)
70 shutil.rmtree(tmp_dir, ignore_errors=True)
71
72 os.makedirs(tmp_dir)
73
74 try:
75 zip = ZipFile(yui_zip, 'r')
76 zip.extractall(tmp_dir)
77 shutil.copytree(join(tmp_dir, 'yui', 'build'), yui_dir)
78 except Exception, exc:
79 sys.exit(exc)
80 finally:
81 # Make sure that we remove the tmp dir no matter what.
82 shutil.rmtree(tmp_dir, ignore_errors=True)
83
84
85def _validate_args(args):
86 """Verify that the args are valid.
87
88 The download cache exists.
89 We have a zip file for the YUI version specified.
90 The build directory exists.
91
92 """
93 if not isdir(args.download_cache):
94 sys.exit('Download cache not found.')
95
96 if not isdir(args.build_dir):
97 sys.exit('Build directory not found.')
98
99 yui_zip = "%s/%s" % (args.download_cache, YUI_ZIP % args.yui_version)
100 if not exists(yui_zip):
101 sys.exit('Could not find download: ' + yui_zip)
102
103def main(args):
104 """"""
105 # If any args aren't valid then output info on how to correct.
106 _validate_args(args)
107 yui_zip = "%s/%s" % (args.download_cache, YUI_ZIP % args.yui_version)
108 _unzip(yui_zip, args.build_dir)
109
110
111if __name__ == "__main__":
112 args = _parse_args()
113 main(args)
0114
=== modified file 'buildout.cfg'
--- buildout.cfg 2012-07-25 21:09:38 +0000
+++ buildout.cfg 2012-08-01 21:25:23 +0000
@@ -3,7 +3,6 @@
33
4[buildout]4[buildout]
5parts =5parts =
6 yui-default
7 scripts6 scripts
8 filetemplates7 filetemplates
9 tags8 tags
@@ -11,6 +10,9 @@
11 i18n10 i18n
12 txlongpoll11 txlongpoll
13 auditor12 auditor
13 yui-default
14 yui-3.5
15
14unzip = true16unzip = true
15eggs-directory = eggs17eggs-directory = eggs
16download-cache = download-cache18download-cache = download-cache
@@ -40,24 +42,16 @@
40[yui]42[yui]
41recipe = plone.recipe.command43recipe = plone.recipe.command
42command =44command =
43 mkdir -p ${buildout:yui-directory}/yui-${:yui_version}45 mkdir -p ${buildout:yui-directory}
44 rm -rf ${buildout:yui-directory}/yui-${:yui_version}/*46 bin/yui_extract --yui-version ${:yui_version} --download-cache download-cache/dist --build-dir ${buildout:yui-directory}
45 tar -zxf download-cache/dist/yui-${:yui_version}.tar.gz \
46 --wildcards --strip-components 2 \
47 -C ${buildout:yui-directory}/yui-${:yui_version} \
48 '*/build'
4947
50[yui-default]48[yui-default]
51<= yui49<= yui
52yui_version = ${versions:yui}50yui_version = ${versions:yui}
5351
54[yui-3.4]
55<= yui
56yui_version = 3.4.1
57
58[yui-3.5]52[yui-3.5]
59<=yui53<=yui
60yui_version = 3.5.0pr154yui_version = 3.5.1
6155
62[filetemplates]56[filetemplates]
63recipe = z3c.recipe.filetemplate57recipe = z3c.recipe.filetemplate