Skip to content

Commit 1bc3bc1

Browse files
committed
converting readme to rst and fixing setup.py
1 parent 163eff0 commit 1bc3bc1

File tree

5 files changed

+123
-95
lines changed

5 files changed

+123
-95
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ matrix:
1313
- python: 'nightly'
1414

1515
install:
16-
- pip install coverage flake8
16+
- pip install coverage flake8 Pygments docutils
1717

1818
script:
1919
- coverage run --source=pydf setup.py test
20-
- flake8 --max-line-length 120 pydf/
20+
- flake8 pydf/
21+
- python setup.py check -rms
2122
- python setup.py install
2223
- tests/check_file_permissions.py
2324
- python -c "import pydf; print(pydf.get_version())"

README.md

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

README.rst

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
pydf
2+
====
3+
4+
5+
|Build Status| |codecov.io| |PyPI Status| |license|
6+
7+
PDF generation in python using
8+
`wkhtmltopdf <http://wkhtmltopdf.org/>`__.
9+
10+
Wkhtmltopdf binaries are precompiled and included in the package making
11+
pydf easier to use, in particular this means pydf works on heroku.
12+
13+
Currently using **wkhtmltopdf 0.12.4 (with patched qt)**.
14+
15+
Install
16+
-------
17+
18+
::
19+
20+
pip install python-pdf
21+
22+
(pydf was taken, but I guess python-pdf is a clearer name anyway.)
23+
24+
Changelog
25+
---------
26+
27+
0.3
28+
~~~
29+
30+
- uprev wkhtmltopdf from **0.12.2 (beta)** to **0.12.4**.
31+
- code cleanup
32+
33+
Basic Usage
34+
-----------
35+
36+
.. code:: python
37+
38+
import pydf
39+
pdf = pydf.generate_pdf('<h1>this is html</h1>')
40+
with open('test_doc.pdf', 'w') as f:
41+
f.write(pdf)
42+
43+
pdf = pydf.generate_pdf('www.google.com')
44+
with open('google.pdf', 'w') as f:
45+
f.write(pdf)
46+
47+
API
48+
---
49+
50+
**generate\_pdf(source, [\*\*kwargs])**
51+
52+
Generate a pdf from either a url or a html string.
53+
54+
After the html and url arguments all other arguments are passed straight
55+
to wkhtmltopdf
56+
57+
For details on extra arguments see the output of get\_help() and
58+
get\_extended\_help()
59+
60+
All arguments whether specified or caught with extra\_kwargs are
61+
converted to command line args with
62+
``'--' + original_name.replace('_', '-')``.
63+
64+
Arguments which are True are passed with no value eg. just --quiet,
65+
False and None arguments are missed, everything else is passed with
66+
str(value).
67+
68+
**Arguments:**
69+
70+
- ``source``: html string to generate pdf from or url to get
71+
- ``quiet``: bool
72+
- ``grayscale``: bool
73+
- ``lowquality``: bool
74+
- ``margin_bottom``: string eg. 10mm
75+
- ``margin_left``: string eg. 10mm
76+
- ``margin_right``: string eg. 10mm
77+
- ``margin_top``: string eg. 10mm
78+
- ``orientation``: Portrait or Landscape
79+
- ``page_height``: string eg. 10mm
80+
- ``page_width``: string eg. 10mm
81+
- ``page_size``: string: A4, Letter, etc.
82+
- ``image_dpi``: int default 600
83+
- ``image_quality``: int default 94
84+
- ``extra_kwargs``: any exotic extra options for wkhtmltopdf
85+
86+
Returns string representing pdf
87+
88+
**get\_version()**
89+
90+
Get version of pydf and wkhtmltopdf binary
91+
92+
**get\_help()**
93+
94+
get help string from wkhtmltopdf binary uses -h command line option
95+
96+
**get\_extended\_help()**
97+
98+
get extended help string from wkhtmltopdf binary uses -H command line
99+
option
100+
101+
**execute\_wk(\*args)**
102+
103+
Low level function to call wkhtmltopdf, arguments are added to
104+
wkhtmltopdf binary and passed to subprocess with not processing.
105+
106+
.. |Build Status| image:: https://travis-ci.org/samuelcolvin/pydf.svg?branch=master
107+
:target: https://travis-ci.org/samuelcolvin/pydf
108+
.. |codecov.io| image:: http://codecov.io/github/samuelcolvin/pydf/coverage.svg?branch=master
109+
:target: http://codecov.io/github/samuelcolvin/pydf?branch=master
110+
.. |PyPI Status| image:: https://img.shields.io/pypi/v/pydf.svg?style=flat
111+
:target: https://pypi.python.org/pypi/pydf
112+
.. |license| image:: https://img.shields.io/pypi/l/pydf.svg
113+
:target: https://github.com/samuelcolvin/pydf

setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
[bdist_wheel]
22
universal = 1
3+
4+
[flake8]
5+
max-complexity = 10
6+
max-line-length = 120

setup.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import sys
21
import os
32
from setuptools import setup
43
from setuptools.command.install import install
54

65
description = 'PDF generation in python using wkhtmltopdf suitable for heroku'
7-
long_description = description
8-
if 'upload' in sys.argv or 'register' in sys.argv:
9-
import pypandoc
10-
long_description = pypandoc.convert('README.md', 'rst')
6+
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
7+
with open(os.path.join(THIS_DIR, 'README.rst')) as f:
8+
long_description = f.read()
119

1210

1311
class OverrideInstall(install):

0 commit comments

Comments
 (0)