Skip to content

Commit 4d32b80

Browse files
author
Brandon Black
committed
[release] v0.1.0 release candidate
1 parent 8035e2c commit 4d32b80

31 files changed

+2587
-2
lines changed

.codeclimate.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
languages:
2+
Python: true
3+
pep8:
4+
enabled: true
5+
checks:
6+
E501:
7+
enabled: false
8+
exclude_paths:
9+
- ".pylintrc"
10+
- "LICENSE"
11+
- "test/*"
12+
- "docs/*"
13+
- "*.in"
14+
- "*.txt"
15+
- "*.cfg"
16+
- "*.rst"
17+
- "*.ini"
18+
- "*.yml"
19+
- "*.*.yml"

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.DS_Store
2+
13
# Byte-compiled / optimized / DLL files
24
__pycache__/
35
*.py[cod]
@@ -9,6 +11,7 @@ __pycache__/
911
.Python
1012
env/
1113
build/
14+
docs/build/
1215
develop-eggs/
1316
dist/
1417
downloads/

.travis.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: python
2+
3+
matrix:
4+
include:
5+
- python: 2.7
6+
script: python setup.py flake8 && python setup.py test
7+
- python: 3.2
8+
script: python setup.py test
9+
- python: 3.3
10+
script: python setup.py test
11+
- python: 3.4
12+
script: python setup.py test
13+
- python: pypy
14+
script: python setup.py flake8 && python setup.py test

CONTRIBUTING.rst

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
Contributing Guidelines
2+
=======================
3+
4+
We love pull requests from everyone!
5+
6+
We encourage community contributions for all kinds of changes both big
7+
and small, but we ask that you adhere to the following guidelines for
8+
contributing code.
9+
10+
Proposing Changes
11+
'''''''''''''''''
12+
13+
As a starting point for all changes, we recommend `reporting an issue`_
14+
before you begin making any changes. Make sure to search the issues on
15+
this repository first to check and see the issue has already been
16+
previously discussed and whether or not it’s already being worked on.
17+
18+
- For small changes, improvements and bug fixes please feel free to
19+
send us a pull request with proposed changes along-side the issue you
20+
report.
21+
22+
- For larger more involved or design related changes, please open an
23+
issue and discuss the changes with the other contributors before
24+
submitting any pull requests.
25+
26+
Submitting A Pull Request
27+
'''''''''''''''''''''''''
28+
29+
1) Fork us and clone the repository locally.
30+
31+
.. code:: bash
32+
33+
git clone [email protected]:twitterdev/twitter-python-ads-sdk.git
34+
35+
2) Install development dependencies:
36+
37+
.. code:: bash
38+
39+
pip install -r requirements.txt
40+
41+
3) Make sure all tests pass before you start:
42+
43+
.. code:: bash
44+
45+
python setup.py test
46+
47+
4) Make your changes! (Don’t forget tests and documentation)
48+
49+
5) Test your changes again and make sure everything passes:
50+
51+
.. code:: bash
52+
53+
python setup.py flake8 && python setup.py test
54+
55+
The test suite will automatically enforce test coverage and code style.
56+
This project adhere’s fully to the `PEP-8 style guide`_ (100 character line
57+
length allowed) and we use `PyLint`_ to enforce style and code quality.
58+
59+
6) Submit your changes!
60+
61+
- Squash your development commits.
62+
- Write a `good commit message`_ for your change.
63+
- Push to your fork.
64+
- Submit a `pull request`_.
65+
66+
We try to at least comment on pull requests within one business day and
67+
may suggest changes.
68+
69+
Release Schedule and Versioning
70+
'''''''''''''''''''''''''''''''
71+
72+
We have a regular release cadence and adhere to `semantic versioning`_.
73+
When exactly your change ships will depend on the scope of your changes
74+
and what type of upcoming release its best suited for.
75+
76+
.. _reporting an issue: https://github.com/twitterdev/twitter-python-ads-sdk/issues?q=is%3Aopen+is%3Aissue
77+
.. _PEP-8 style guide: https://www.python.org/dev/peps/pep-0008
78+
.. _PyLint: https://github.com/twitterdev/twitter-python-ads-sdk/blob/master/.pylintrc
79+
.. _good commit message: http://chris.beams.io/posts/git-commit/
80+
.. _pull request: https://github.com/thoughtbot/suspenders/compare/
81+
.. _semantic versioning: http://semver.org/

LICENSE

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 @TwitterDev
3+
Copyright (C) 2015 Twitter, Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22-

MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include *.rst
2+
prune .DS_Store

README.rst

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
Getting Started |Build Status| |Code Climate| |PyPy Version|
2+
------------------------------------------------------------
3+
4+
Installation
5+
''''''''''''
6+
7+
.. code:: bash
8+
9+
# installing the latest signed release
10+
pip install twitter-ads
11+
12+
Quick Start
13+
'''''''''''
14+
15+
.. code:: python
16+
17+
from twitter_ads.client import Client
18+
from twitter_ads.campaign import Campaign
19+
20+
CONSUMER_KEY = 'your consumer key'
21+
CONSUMER_SECRET = 'your consumer secret'
22+
ACCESS_TOKEN = 'access token'
23+
ACCESS_TOKEN_SECRET = 'access token secret'
24+
ACCOUNT_ID = 'account id'
25+
26+
# initialize the client
27+
client = Client(
28+
CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
29+
30+
# load the advertiser account instance
31+
account = client.accounts(id=ACCOUNT_ID)
32+
33+
# load and update a specific campaign
34+
campaign = account.campaigns().next()
35+
campaign.name = 'updated campaign name'
36+
campaign.paused = True
37+
campaign.save()
38+
39+
# iterate through campaigns
40+
for campaign in account.campaigns():
41+
print(campaign.id)
42+
43+
44+
45+
Command Line Helper
46+
'''''''''''''''''''
47+
48+
.. code:: bash
49+
50+
# The twitter-ads command launches an interactive session for testing purposes
51+
# with a client instance automatically loaded from your .twurlrc file.
52+
53+
~ ❯ twitter-ads
54+
55+
For more help please see our `Examples and Guides`_ or check the online
56+
`Reference Documentation`_.
57+
58+
Compatibility & Versioning
59+
--------------------------
60+
61+
This project is designed to work with Python 2.7 or greater. While it
62+
may work on other version of Python, below are the platform and runtime
63+
versions we officially support and regularly test against.
64+
65+
+------------+----------------------+
66+
| Platform | Versions |
67+
+============+======================+
68+
| CPython | 2.7, 3.2, 3.3, 3.4 |
69+
+------------+----------------------+
70+
| PyPy | 2.x, 4.x |
71+
+------------+----------------------+
72+
73+
All releases adhere to strict `semantic versioning`_. For Example,
74+
major.minor.patch-pre (aka. stick.carrot.oops-peek).
75+
76+
Development
77+
-----------
78+
79+
If you’d like to contribute to the project or try an unreleased
80+
development version of this project locally, you can do so quite easily
81+
by following the examples below.
82+
83+
.. code:: bash
84+
85+
# clone the repository
86+
git clone [email protected]:twitterdev/twitter-python-ads-sdk.git
87+
cd twitter-python-ads-sdk
88+
89+
# install dependencies
90+
pip install -r requirements.txt
91+
92+
# installing a local unsigned release
93+
pip install -e .
94+
95+
We love community contributions! If you’re planning to send us a pull
96+
request, please make sure read our `Contributing Guidelines`_ first.
97+
98+
Feedback and Bug Reports
99+
------------------------
100+
101+
Found an issue? Please open up a `GitHub issue`_ or even better yet
102+
`send us`_ a pull request. Have a question? Want to discuss a new
103+
feature? Come chat with us in the `Twitter Community Forums`_.
104+
105+
License
106+
-------
107+
108+
The MIT License (MIT)
109+
110+
Copyright (C) 2015 Twitter, Inc.
111+
112+
Permission is hereby granted, free of charge, to any person obtaining a copy
113+
of this software and associated documentation files (the "Software"), to deal
114+
in the Software without restriction, including without limitation the rights
115+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
116+
copies of the Software, and to permit persons to whom the Software is
117+
furnished to do so, subject to the following conditions:
118+
119+
The above copyright notice and this permission notice shall be included in all
120+
copies or substantial portions of the Software.
121+
122+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
123+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
124+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
125+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
126+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
127+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
128+
SOFTWARE.
129+
130+
.. _Examples and Guides: https://github.com/twitterdev/twitter-python-ads-sdk/tree/master/examples
131+
.. _Reference Documentation: http://twitterdev.github.io/twitter-python-ads-sdk/reference/index.html
132+
.. _semantic versioning: http://semver.org
133+
.. _Contributing Guidelines: https://github.com/twitterdev/twitter-python-ads-sdk/blob/master/CONTRIBUTING.rst
134+
.. _GitHub issue: https://github.com/twitterdev/twitter-python-ads-sdk/issues
135+
.. _send us: https://github.com/twitterdev/twitter-python-ads-sdk/blob/master/CONTRIBUTING.rst
136+
.. _Twitter Community Forums: https://twittercommunity.com/c/advertiser-api
137+
138+
.. |Build Status| image:: https://travis-ci.org/twitterdev/twitter-python-ads-sdk.svg?branch=master
139+
:target: https://travis-ci.org/twitterdev/twitter-python-ads-sdk
140+
.. |Code Climate| image:: https://codeclimate.com/github/twitterdev/twitter-python-ads-sdk/badges/gpa.svg
141+
:target: https://codeclimate.com/github/twitterdev/twitter-python-ads-sdk
142+
.. |PyPy Version| image:: https://badge.fury.io/py/twitter-ads.svg
143+
:target: http://badge.fury.io/rb/twitter-ads

bin/twitter-ads

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python
2+
3+
import os, yaml, code, sys
4+
5+
try:
6+
import twitter_ads
7+
except ImportError:
8+
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
9+
import twitter_ads
10+
11+
from twitter_ads.client import Client
12+
13+
CLIENT = None
14+
BANNER = '** Twitter Ads API SDK for Python v{0} (twitter-ads) **'
15+
16+
# if twurl config is present, create client instance
17+
twurl_path = os.path.expanduser('~/.twurlrc')
18+
if os.path.isfile(twurl_path):
19+
with open(twurl_path, 'r') as stream:
20+
twurl_config = yaml.load(stream)
21+
profile_name = twurl_config['configuration']['default_profile'][0]
22+
profile_key = twurl_config['configuration']['default_profile'][1]
23+
default_profile = twurl_config['profiles'][profile_name][profile_key]
24+
25+
CLIENT = Client(default_profile['consumer_key'],
26+
default_profile['consumer_secret'],
27+
default_profile['token'],
28+
default_profile['secret'])
29+
30+
# begin an interactive session
31+
init_with = { 'CLIENT': CLIENT } if CLIENT else {}
32+
code.InteractiveConsole(locals=init_with).interact(
33+
BANNER.format(twitter_ads.utils.get_version()))

0 commit comments

Comments
 (0)