[Checkins] SVN: hurry.zopeyui/ Initial import of zope support for hurry.yui.
Martijn Faassen
faassen at infrae.com
Tue Oct 7 11:54:04 EDT 2008
Log message for revision 91866:
Initial import of zope support for hurry.yui.
Changed:
A hurry.zopeyui/
A hurry.zopeyui/trunk/
A hurry.zopeyui/trunk/MANIFEST.in
A hurry.zopeyui/trunk/buildout.cfg
A hurry.zopeyui/trunk/setup.py
A hurry.zopeyui/trunk/src/
A hurry.zopeyui/trunk/src/hurry/
A hurry.zopeyui/trunk/src/hurry/__init__.py
A hurry.zopeyui/trunk/src/hurry/zopeyui/
A hurry.zopeyui/trunk/src/hurry/zopeyui/__init__.py
A hurry.zopeyui/trunk/src/hurry/zopeyui/configure.zcml
A hurry.zopeyui/trunk/svn-commit.tmp
A hurry.zopeyui/trunk/yuidl.py
-=-
Added: hurry.zopeyui/trunk/MANIFEST.in
===================================================================
--- hurry.zopeyui/trunk/MANIFEST.in (rev 0)
+++ hurry.zopeyui/trunk/MANIFEST.in 2008-10-07 15:54:03 UTC (rev 91866)
@@ -0,0 +1 @@
+recursive-include src/hurry/zopeyui/yui-build *
Added: hurry.zopeyui/trunk/buildout.cfg
===================================================================
--- hurry.zopeyui/trunk/buildout.cfg (rev 0)
+++ hurry.zopeyui/trunk/buildout.cfg 2008-10-07 15:54:03 UTC (rev 91866)
@@ -0,0 +1,20 @@
+[buildout]
+develop = . hurry.zoperesource hurry.yui
+parts = scripts devpython test
+versions = versions
+
+[versions]
+
+[scripts]
+recipe = zc.recipe.egg:scripts
+eggs = hurry.zopeyui
+
+[devpython]
+recipe = zc.recipe.egg
+interpreter = devpython
+eggs = hurry.zopeyui
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = hurry.zopeyui
+defaults = ['--tests-pattern', '^f?tests$', '-v']
Added: hurry.zopeyui/trunk/setup.py
===================================================================
--- hurry.zopeyui/trunk/setup.py (rev 0)
+++ hurry.zopeyui/trunk/setup.py 2008-10-07 15:54:03 UTC (rev 91866)
@@ -0,0 +1,39 @@
+from setuptools import setup, find_packages
+import sys, os, shutil
+import yuidl
+
+YUI_VERSION = '2.6.0'
+
+package_dir = os.path.dirname(__file__)
+yui_build_path = os.path.join(package_dir, 'src', 'hurry', 'zopeyui',
+ 'yui-build')
+
+def copy_yui(ex_path):
+ """Copy YUI to location 'yui-build' in package."""
+ yui_build_path = os.path.join(ex_path, 'yui', 'build')
+ shutil.rmtree(target_path, ignore_errors=True)
+ shutil.copytree(yui_build_path, yui_build_path)
+
+# only re-download if path doesn't exist
+if not os.path.exists(yui_build_path):
+ yuidl.download(YUI_VERSION, copy_yui)
+
+setup(
+ name='hurry.zopeyui',
+ version='0.1dev',
+ description="Zope integration for YUI.",
+ classifiers=[],
+ keywords='',
+ author='Martijn Faassen',
+ author_email='faassen at startifact.com',
+ license='ZPL 2.1',
+ packages=find_packages('src'),
+ package_dir={'': 'src'},
+ include_package_data=True,
+ zip_safe=False,
+ install_requires=[
+ 'setuptools',
+ 'hurry.zoperesource',
+ 'hurry.yui',
+ ],
+ )
Added: hurry.zopeyui/trunk/src/hurry/__init__.py
===================================================================
--- hurry.zopeyui/trunk/src/hurry/__init__.py (rev 0)
+++ hurry.zopeyui/trunk/src/hurry/__init__.py 2008-10-07 15:54:03 UTC (rev 91866)
@@ -0,0 +1,13 @@
+# XXX awful hack to make sure we don't get a warning due to two
+# namespace packages being loaded. Why this is needed I do not know,
+# haven't seen this before :(
+import warnings
+warnings.filterwarnings("ignore", "Module (.*) was already imported (.*)")
+
+# this is a namespace package
+try:
+ import pkg_resources
+ pkg_resources.declare_namespace(__name__)
+except ImportError:
+ import pkgutil
+ __path__ = pkgutil.extend_path(__path__, __name__)
Added: hurry.zopeyui/trunk/src/hurry/zopeyui/__init__.py
===================================================================
--- hurry.zopeyui/trunk/src/hurry/zopeyui/__init__.py (rev 0)
+++ hurry.zopeyui/trunk/src/hurry/zopeyui/__init__.py 2008-10-07 15:54:03 UTC (rev 91866)
@@ -0,0 +1 @@
+#
Added: hurry.zopeyui/trunk/src/hurry/zopeyui/configure.zcml
===================================================================
--- hurry.zopeyui/trunk/src/hurry/zopeyui/configure.zcml (rev 0)
+++ hurry.zopeyui/trunk/src/hurry/zopeyui/configure.zcml 2008-10-07 15:54:03 UTC (rev 91866)
@@ -0,0 +1,9 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser">
+ <include package="hurry.zoperesource" />
+
+ <browser:resourceDirectory
+ name="yui"
+ directory="yui-build" />
+
+</configure>
Added: hurry.zopeyui/trunk/svn-commit.tmp
===================================================================
--- hurry.zopeyui/trunk/svn-commit.tmp (rev 0)
+++ hurry.zopeyui/trunk/svn-commit.tmp 2008-10-07 15:54:03 UTC (rev 91866)
@@ -0,0 +1,4 @@
+Initial import of Zope support for hurry.yui.
+--This line, and those below, will be ignored--
+
+A .
Added: hurry.zopeyui/trunk/yuidl.py
===================================================================
--- hurry.zopeyui/trunk/yuidl.py (rev 0)
+++ hurry.zopeyui/trunk/yuidl.py 2008-10-07 15:54:03 UTC (rev 91866)
@@ -0,0 +1,45 @@
+import urllib2
+import tempfile, shutil
+import os
+
+SF_URL_TEMPLATE = 'http://sourceforge.net/project/downloading.php?group_id=165715&filename=yui_%s.zip'
+
+def download(version, callback):
+ """Download a yui of version.
+
+ When downloaded, call callback with path to directory
+ with an extracted YUI. The callback will then be able to copy
+ this to the appropriate location.
+ """
+ url = SF_URL_TEMPLATE % version
+ f = urllib2.urlopen(url)
+ data = f.read()
+ f.close()
+
+ download_url = find_a_href(data, 'direct link')
+
+ f = urllib2.urlopen(download_url)
+ file_data = f.read()
+ f.close()
+
+ dirpath = tempfile.mkdtemp()
+ try:
+ yui_path = os.path.join(dirpath, 'yui.zip')
+ ex_path = os.path.join(dirpath, 'yui_ex')
+ g = open(yui_path, 'wb')
+ g.write(file_data)
+ g.close()
+ os.system('unzip -qq "%s" -d "%s"' % (yui_path, ex_path))
+ callback(ex_path)
+ finally:
+ shutil.rmtree(dirpath, ignore_errors=True)
+
+def find_a_href(data, content):
+ """Given start of content of the <a href="">content</a> find href.
+ """
+ i = data.find(content)
+ a = '<a href="'
+ href_start = data.rfind(a, 0, i)
+ href_start += len(a)
+ href_end = data.find('"', href_start)
+ return data[href_start:href_end]
More information about the Checkins
mailing list