Permalink
Browse files

Initial, incomplete, terribly basic code! :D

  • Loading branch information...
0 parents commit 2f8953baf3af3893bb8b581c8253cddc7e8a32a1 @Osmose Osmose committed Nov 29, 2011
Showing with 114 additions and 0 deletions.
  1. +27 −0 LICENSE
  2. +2 −0 MANIFEST.in
  3. +19 −0 README.rst
  4. +1 −0 basket/__init__.py
  5. +38 −0 basket/base.py
  6. +27 −0 setup.py
@@ -0,0 +1,27 @@
+Copyright (c) 2011, Mozilla.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. Neither the name of jingo nor the names of its contributors may
+ be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,2 @@
+include LICENSE
+include README.rstx
@@ -0,0 +1,19 @@
+Basket-Client
+-------------
+
+Basket-Client is a small library for subscribing users to mailing lists through `Basket<https://github.com/mozilla/basket>`.
+
+Usage
+=====
+
+ from basket import subscribe
+
+ subscribe('user@example.com', ['basket-email-list-id'])
+
+See `the Basket documentation<https://github.com/mozilla/basket/tree/master/apps/news>` for more information.
+
+Settings
+========
+
+BASKET_URL
+ URL to basket server, e.g. `basket.mozilla.com`
@@ -0,0 +1 @@
+from base import subscribe
@@ -0,0 +1,38 @@
+import json
+
+from django.conf import settings
+
+import requests
+
+
+class BasketException(Exception):
+ pass
+
+
+def subscribe(email, newsletters, **kwargs):
+ kwargs.update(email=email, newsletters=newsletters)
+ return _post('subscribe', kwargs)
+
+def _url(path):
+ return 'https://%s/news/%s/' % (settings.BASKET_URL, path)
+
+
+def _post(path, data):
+ return _parse_response(requests.post(_url(path), data=data))
+
+
+def _get(path, data):
+ return _parse_response(requests.get(_url(path), data=data))
+
+
+def _parse_response(response):
+ if response.error:
+ raise BasketException('Error connecting to %s: %s. Ensure that '
+ 'BASKET_URL is configured correctly in your '
+ 'settings file.' % (response.url, response.error))
+
+ response_json = json.loads(response.content)
+ if response_json.get('desc', None):
+ raise BasketException(response_json['desc'])
+
+ return response_json
@@ -0,0 +1,27 @@
+from setuptools import setup, find_packages
+
+
+setup(
+ name='basket',
+ version='0.1.0',
+ description='A thin, practical wrapper around terminal formatting, positioning, and more',
+ long_description=open('README.rst').read(),
+ author='Erik Rose',
+ author_email='erikrose@grinchcentral.com',
+ license='GPL',
+ packages=find_packages(exclude=['ez_setup']),
+ tests_require=['Nose'],
+ url='https://github.com/erikrose/blessings',
+ include_package_data=True,
+ classifiers=[
+ 'Intended Audience :: Developers',
+ 'Natural Language :: English',
+ 'Environment :: Console',
+ 'Operating System :: POSIX',
+ 'Topic :: Software Development :: Libraries',
+ 'Topic :: Software Development :: User Interfaces',
+ 'Topic :: Terminals'
+ ],
+ keywords=['terminal', 'tty', 'curses', 'formatting', 'color'],
+ **extra_setup
+)

0 comments on commit 2f8953b

Please sign in to comment.