Permalink
Browse files

inital creation of pyramid_webassets

  • Loading branch information...
0 parents commit 4d09f149a4dc2cbcc37b79d2882b4f8da5371aa4 @sontek committed Jan 9, 2012
Showing with 154 additions and 0 deletions.
  1. +39 −0 .gitignore
  2. 0 CHANGES.txt
  3. 0 README.md
  4. +57 −0 pyramid_webassets/__init__.py
  5. +3 −0 requirements.txt
  6. +55 −0 setup.py
@@ -0,0 +1,39 @@
+*.db
+
+prod.ini
+
+# web assets generated directory
+gen/
+.webassets-cache/
+
+*.py[co]
+
+# Packages
+*.egg
+*.egg-info
+dist
+build
+_build
+eggs
+parts
+bin
+develop-eggs
+.installed.cfg
+
+# Installer logs
+pip-log.txt
+logs
+*.log
+*.pid
+
+# Unit test / coverage reports
+.coverage
+.tox
+
+# Vim
+*.swp
+.rope*
+
+# Tags for git-helpers
+tags
+
No changes.
No changes.
@@ -0,0 +1,57 @@
+from pyramid.settings import asbool
+from zope.interface import Interface
+from webassets import Environment
+
+class IWebAssetsEnvironment(Interface):
+ pass
+
+def add_web_asset(config, name, bundle):
+ asset_env = get_webassets_env(config)
+ asset_env.register(name, bundle)
+
+def get_webassets_env(config):
+ return config.registry.queryUtility(IWebAssetsEnvironment)
+
+def get_webassets_env_from_config(config, prefix='webassets'):
+ settings = config.registry.settings
+
+ def base_name(string):
+ return '%s.%s' % (prefix, string)
+
+ if not base_name('base_dir') in settings:
+ raise Exception("You need to provide webassets.base_dir in your configuration")
+ if not base_name('base_url') in settings:
+ raise Exception("You need to provide webassets.base_url in your configuration")
+
+ asset_dir = settings.get(base_name('base_dir'))
+ asset_url = settings.get(base_name('base_url'))
+ kwargs = {}
+
+ if base_name('debug') in settings:
+ dbg = settings.get(base_name('debug')).lower()
+
+ if dbg == 'false' or dbg == 'true':
+ dbg = asbool(dbg)
+
+ kwargs['debug'] = dbg
+
+ if base_name('cache') in settings:
+ kwargs['cache'] = asbool(settings.get(base_name('cache')))
+
+ if base_name('updater') in settings:
+ kwargs['updater'] = settings.get(base_name('updater'))
+
+ if base_name('jst_compiler') in settings:
+ kwargs['JST_COMPILER'] = settings.get(base_name('jst_compiler'))
+
+ assets_env = Environment(asset_dir, asset_url, **kwargs)
+
+ return assets_env
+
+def includeme(config):
+ assets_env = get_webassets_env_from_config(config)
+
+ config.registry.registerUtility(assets_env, IWebAssetsEnvironment)
+
+ config.add_directive('add_webasset', add_web_asset)
+ config.add_directive('get_webassets_env', get_webassets_env)
@@ -0,0 +1,3 @@
+pyramid
+webassets
+zope.interface
@@ -0,0 +1,55 @@
+import os
+import sys
+
+from setuptools import setup, find_packages, Command
+
+here = os.path.abspath(os.path.dirname(__file__))
+
+def _read(path):
+ with open(path) as f:
+ data= f.read()
+
+ f.close()
+
+ return data
+
+README = _read(os.path.join(here, 'README.md'))
+CHANGES = _read(os.path.join(here, 'CHANGES.txt'))
+
+#requires = open('requirements.txt').readlines()
+requires = ['pyramid', 'webassets', 'zope.interface']
+
+class PyTest(Command):
+ user_options = []
+ def initialize_options(self):
+ pass
+ def finalize_options(self):
+ pass
+ def run(self):
+ import subprocess
+ errno = subprocess.call('py.test')
+ raise SystemExit(errno)
+
+setup(name='pyramid_webassets',
+ version='0.0',
+ description='pyramid_webassets',
+ long_description=README + '\n\n' + CHANGES,
+ classifiers=[
+ "Programming Language :: Python",
+ "Framework :: Pylons",
+ "Topic :: Internet :: WWW/HTTP",
+ "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
+ ],
+ author='',
+ author_email='',
+ url='',
+ keywords='web wsgi bfg pylons pyramid',
+ packages=find_packages(),
+ include_package_data=True,
+ zip_safe=False,
+ test_suite='pyramid_webassets',
+ install_requires = requires,
+ cmdclass = {'test': PyTest},
+ paster_plugins=['pyramid'],
+ )
+

0 comments on commit 4d09f14

Please sign in to comment.