Skip to content

Commit bc307f4

Browse files
committed
Moved README to rst, improved setup.py file, and added MANIFEST.in
1 parent a17a77c commit bc307f4

File tree

4 files changed

+183
-77
lines changed

4 files changed

+183
-77
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include README.rst LICENSE

README.md

Lines changed: 0 additions & 72 deletions
This file was deleted.

README.rst

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
pizzapi
2+
=======
3+
4+
This is a Python wrapper for the Dominos Pizza API.
5+
6+
It's a port of `the pizzapi node.js module <https://github.com/RIAEvangelist/node-dominos-pizza-api>`_ written by `RIAEvangelist <https://github.com/RIAEvangelist>`_.
7+
8+
Quick Start
9+
-----------
10+
11+
First construct a ``Customer`` object and set the customer's address:
12+
13+
.. code-block:: python
14+
15+
customer = Customer('Barack', 'Obama', '[email protected]', '2024561111', '700 Pennsylvania Avenue NW, Washington, DC, 20408')
16+
address = Address('700 Pennsylvania Avenue NW', 'Washington', 'DC', '20408')
17+
# or Address(*customer.address.split(',')) if you're lazy
18+
19+
Then, find a store that will deliver to the address.
20+
21+
.. code-block:: python
22+
23+
store = address.closest_store()
24+
25+
In order to add items to your order, you'll need the items' product codes.
26+
To find the codes, get the menu from the store, then search for items you want to add.
27+
You can do this by asking your ``Store`` object for its ``Menu``.
28+
29+
.. code-block:: python
30+
31+
menu = store.get_menu()
32+
33+
Then search ``menu`` with ``menu.search``. For example, running this command:
34+
35+
.. code-block:: python
36+
37+
menu.search(Name='Coke')
38+
39+
Should print this to the console:
40+
41+
.. code-block:: text
42+
43+
20BCOKE 20oz Bottle Coke® $1.89
44+
20BDCOKE 20oz Bottle Diet Coke® $1.89
45+
D20BZRO 20oz Bottle Coke Zero™ $1.89
46+
2LDCOKE 2-Liter Diet Coke® $2.99
47+
2LCOKE 2-Liter Coke® $2.99
48+
49+
After you've found your items' product codes, you can create an ``Order`` object add add your items:
50+
51+
.. code-block:: python
52+
53+
order = Order(store, customer, address)
54+
order.add_item('P12IPAZA') # add a 12-inch pan pizza
55+
order.add_item('MARINARA') # with an extra marinara cup
56+
order.add_item('20BCOKE') # and a 20oz bottle of coke
57+
58+
You can remove items as well!
59+
60+
.. code-block:: python
61+
62+
order.remove_item('20BCOKE')
63+
64+
Wrap your credit card information in a ``PaymentObject``:
65+
66+
.. code-block:: python
67+
68+
card = PaymentObject('4100123422343234', '0115', '777', '90210')
69+
70+
And that's it! Now you can place your order.
71+
72+
.. code-block:: python
73+
74+
order.place(card)
75+
76+
Or if you're just testing and don't want to actually order something, use ``.pay_with``.
77+
78+
.. code-block:: python
79+
80+
order.pay_with(card)

setup.py

Lines changed: 102 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,66 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
13
"""
4+
A setuptools based setup module.
5+
26
See:
37
https://packaging.python.org/en/latest/distributing.html
48
https://github.com/pypa/sampleproject
9+
https://github.com/kennethreitz/setup.py
10+
11+
Note: To use the 'upload' functionality of this file, you must:
12+
$ pip install twine
513
"""
14+
from __future__ import print_function
15+
import io
16+
import sys
17+
from os import path, system
18+
from shutil import rmtree
619

720
# Always prefer setuptools over distutils
8-
from setuptools import find_packages, setup
21+
from setuptools import find_packages, setup, Command
22+
23+
here = path.abspath(path.dirname(__file__))
24+
25+
# Import the README.rst and use it as the long-description.
26+
with io.open(path.join(here, 'README.rst'), encoding='utf-8') as f:
27+
long_description = '\n' + f.read()
28+
29+
30+
class PublishCommand(Command):
31+
"""Support setup.py publish."""
32+
33+
description = 'Build and publish the package.'
34+
user_options = []
35+
36+
@staticmethod
37+
def status(s):
38+
"""Prints things in bold."""
39+
print('\033[1m{0}\033[0m'.format(s))
40+
41+
def initialize_options(self):
42+
pass
43+
44+
def finalize_options(self):
45+
pass
46+
47+
def run(self):
48+
try:
49+
self.status('Removing previous builds…')
50+
rmtree(path.join(here, 'dist'))
51+
except OSError:
52+
pass
953

54+
self.status('Building Source and Wheel (universal) distribution…')
55+
system('{0} setup.py sdist bdist_wheel --universal'.format(sys.executable))
56+
57+
self.status('Uploading the package to PyPi via Twine…')
58+
system('twine upload dist/*')
59+
60+
sys.exit()
61+
62+
63+
# Where the magic happens:
1064
setup(
1165
name='pizzapi',
1266

@@ -16,27 +70,70 @@
1670
version='0.0.1',
1771

1872
description='A Python wrapper for the Dominos Pizza API',
73+
long_description=long_description,
1974

2075
# The project's main homepage.
2176
url='https://github.com/aluttik/pizzapi',
2277

2378
# Author details
2479
author='aluttik',
25-
author_email='',
80+
author_email='[email protected]',
2681

2782
# What does your project relate to?
2883
keywords='dominos pizza api',
2984

85+
# Choose your license
86+
license='MIT',
87+
88+
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
89+
classifiers=[
90+
# How mature is this project? Common values are
91+
# 3 - Alpha
92+
# 4 - Beta
93+
# 5 - Production/Stable
94+
'Development Status :: 3 - Alpha',
95+
96+
# Pick your license as you wish (should match "license" above)
97+
'License :: OSI Approved :: MIT License',
98+
99+
# TODO: Add testing/support for more python versions
100+
# Specify the Python versions you support here. In particular, ensure
101+
# that you indicate whether you support Python 2, Python 3 or both.
102+
'Programming Language :: Python',
103+
# 'Programming Language :: Python :: 2.6',
104+
'Programming Language :: Python :: 2.7',
105+
# 'Programming Language :: Python :: 3',
106+
# 'Programming Language :: Python :: 3.3',
107+
# 'Programming Language :: Python :: 3.4',
108+
# 'Programming Language :: Python :: 3.5',
109+
'Programming Language :: Python :: 3.6',
110+
'Programming Language :: Python :: Implementation :: CPython',
111+
'Programming Language :: Python :: Implementation :: PyPy'
112+
],
113+
30114
# You can just specify the packages manually here if your project is
31115
# simple. Or you can use find_packages().
32116
packages=find_packages(exclude=['tests']),
33117

118+
# TODO: Add a command line tool
119+
# To provide executable scripts, use entry points in preference to the
120+
# "scripts" keyword. Entry points provide cross-platform support and allow
121+
# pip to create the appropriate form of executable for the target platform.
122+
# entry_points={
123+
# 'console_scripts': [
124+
# 'pizzapi=pizzapi:main'
125+
# ],
126+
# },
127+
34128
# List run-time dependencies here. These will be installed by pip when
35129
# your project is installed. For an analysis of "install_requires" vs pip's
36130
# requirements files see:
37131
# https://packaging.python.org/en/latest/requirements.html
38132
install_requires=['requests', 'xmltodict'],
39-
extras_require={
40-
'test': ['mock', 'PyHamcrest', 'pytest'],
133+
include_package_data=True,
134+
135+
# setup.py publish support.
136+
cmdclass={
137+
'publish': PublishCommand,
41138
},
42-
)
139+
)

0 commit comments

Comments
 (0)