-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial, incomplete, terribly basic code! :D
- Loading branch information
Michael Kelly
committed
Nov 29, 2011
0 parents
commit 2f8953b
Showing
6 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include LICENSE | ||
include README.rstx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from base import subscribe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) |