X Tutup
Skip to content

Commit be7dff4

Browse files
author
Steve Canny
committed
initial commit
0 parents  commit be7dff4

File tree

11 files changed

+347
-0
lines changed

11 files changed

+347
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.coverage
2+
dist
3+
doc/_build
4+
*.egg-info
5+
*.pyc
6+
_scratch
7+
Session.vim
8+
.tox

Makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
PYTHON = python
2+
BEHAVE = behave
3+
SETUP = $(PYTHON) ./setup.py
4+
5+
.PHONY: accept clean coverage readme register sdist test upload
6+
7+
help:
8+
@echo "Please use \`make <target>' where <target> is one or more of"
9+
@echo " accept run acceptance tests using behave"
10+
@echo " clean delete intermediate work product and start fresh"
11+
@echo " coverage run nosetests with coverage"
12+
@echo " readme update README.html from README.rst"
13+
@echo " register update metadata (README.rst) on PyPI"
14+
@echo " test run tests using setup.py"
15+
@echo " sdist generate a source distribution into dist/"
16+
@echo " upload upload distribution tarball to PyPI"
17+
18+
accept:
19+
$(BEHAVE) --stop
20+
21+
clean:
22+
find . -type f -name \*.pyc -exec rm {} \;
23+
rm -rf dist *.egg-info .coverage .DS_Store
24+
25+
coverage:
26+
py.test --cov-report term-missing --cov=docx tests/
27+
28+
readme:
29+
rst2html README.rst >README.html
30+
open README.html
31+
32+
register:
33+
$(SETUP) register
34+
35+
sdist:
36+
$(SETUP) sdist
37+
38+
test:
39+
$(SETUP) test
40+
41+
upload:
42+
$(SETUP) sdist upload

README.rst

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
###########
2+
python-docx
3+
###########
4+
5+
VERSION: 0.3.0d1 (first development release)
6+
7+
8+
STATUS (as of July 29 2013)
9+
===========================
10+
11+
First development release. Under active development.
12+
13+
14+
Vision
15+
======
16+
17+
18+
Documentation
19+
=============
20+
21+
Documentation is hosted on Read The Docs (readthedocs.org) at
22+
https://python-docx.readthedocs.org/en/latest/.
23+
24+
25+
Reaching out
26+
============
27+
28+
We'd love to hear from you if you like |pd|, want a new feature, find a bug,
29+
need help using it, or just have a word of encouragement.
30+
31+
The **mailing list** for |pd| is (google groups ... )
32+
33+
The **issue tracker** is on github at `python-openxml/python-docx`_.
34+
35+
Feature requests are best broached initially on the mailing list, they can be
36+
added to the issue tracker once we've clarified the best approach,
37+
particularly the appropriate API signature.
38+
39+
.. _`python-openxml/python-docx`:
40+
https://github.com/python-openxml/python-docx
41+
42+
43+
Installation
44+
============
45+
46+
|pd| may be installed with ``pip`` if you have it available::
47+
48+
pip install python-docx
49+
50+
It can also be installed using ``easy_install``::
51+
52+
easy_install python-docx
53+
54+
If neither ``pip`` nor ``easy_install`` is available, it can be installed
55+
manually by downloading the distribution from PyPI, unpacking the tarball,
56+
and running ``setup.py``::
57+
58+
tar xvzf python-docx-0.0.1d1.tar.gz
59+
cd python-docx-0.0.1d1
60+
python setup.py install
61+
62+
|pd| depends on the ``lxml`` package. Both ``pip`` and ``easy_install`` will
63+
take care of satisfying that dependency for you, but if you use this last
64+
method you will need to install ``lxml`` yourself.
65+
66+
67+
Release History
68+
===============
69+
70+
July 29, 2013 - v0.3.0d1
71+
* Establish initial enviornment and development branches
72+
73+
74+
License
75+
=======
76+
77+
Licensed under the `MIT license`_. Short version: this code is copyrighted by
78+
me (Steve Canny), I give you permission to do what you want with it except
79+
remove my name from the credits. See the LICENSE file for specific terms.
80+
81+
.. _MIT license:
82+
http://www.opensource.org/licenses/mit-license.php
83+
84+
.. |pd| replace:: ``python-docx``

docx/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# __init__.py
4+
#
5+
# Copyright (C) 2012, 2013 Steve Canny scanny@cisco.com
6+
#
7+
# This module is part of python-docx and is released under the MIT License:
8+
# http://www.opensource.org/licenses/mit-license.php
9+
10+
__version__ = '0.3.0d1'

features/dummy.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Feature: No features yet

features/environment.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# environment.py
4+
#
5+
# Copyright (C) 2013 Steve Canny scanny@cisco.com
6+
#
7+
# This module is part of python-docx and is released under the MIT License:
8+
# http://www.opensource.org/licenses/mit-license.php
9+
10+
"""
11+
Used by behave to set testing environment before and after running acceptance
12+
tests.
13+
"""
14+
15+
import os
16+
17+
scratch_dir = os.path.abspath(
18+
os.path.join(os.path.split(__file__)[0], '_scratch')
19+
)
20+
21+
22+
def before_all(context):
23+
if not os.path.isdir(scratch_dir):
24+
os.mkdir(scratch_dir)

features/steps/docx_steps.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# docx_steps.py
4+
#
5+
# Copyright (C) 2013 Steve Canny scanny@cisco.com
6+
#
7+
# This module is part of python-docx and is released under the MIT License:
8+
# http://www.opensource.org/licenses/mit-license.php
9+
10+
"""Step implementations for python-docx acceptance tests"""

setup.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env python
2+
3+
import os
4+
import re
5+
6+
from setuptools import setup
7+
8+
# Read the version from docx.__version__ without importing the package
9+
# (and thus attempting to import packages it depends on that may not be
10+
# installed yet)
11+
thisdir = os.path.dirname(__file__)
12+
init_py_path = os.path.join(thisdir, 'docx', '__init__.py')
13+
version = re.search("__version__ = '([^']+)'",
14+
open(init_py_path).read()).group(1)
15+
16+
17+
NAME = 'python-docx'
18+
VERSION = version
19+
DESCRIPTION = (
20+
'Create and update Microsoft Word .docx files.'
21+
)
22+
KEYWORDS = 'docx office openxml pptx xslx'
23+
AUTHOR = 'Steve Canny'
24+
AUTHOR_EMAIL = 'python-docx@googlegroups.com'
25+
URL = 'https://github.com/python-openxml/python-docx'
26+
LICENSE = 'MIT'
27+
PACKAGES = ['docx']
28+
29+
INSTALL_REQUIRES = ['lxml']
30+
TEST_SUITE = 'tests'
31+
TESTS_REQUIRE = ['behave', 'mock', 'pytest']
32+
33+
CLASSIFIERS = [
34+
'Development Status :: 2 - Pre-Alpha',
35+
'Environment :: Console',
36+
'Intended Audience :: Developers',
37+
'License :: OSI Approved :: MIT License',
38+
'Operating System :: OS Independent',
39+
'Programming Language :: Python',
40+
'Programming Language :: Python :: 2',
41+
'Programming Language :: Python :: 2.6',
42+
'Programming Language :: Python :: 2.7',
43+
'Programming Language :: Python :: 3',
44+
'Programming Language :: Python :: 3.2',
45+
'Programming Language :: Python :: 3.3',
46+
'Topic :: Office/Business :: Office Suites',
47+
'Topic :: Software Development :: Libraries'
48+
]
49+
50+
readme = os.path.join(os.path.dirname(__file__), 'README.rst')
51+
LONG_DESCRIPTION = open(readme).read()
52+
53+
54+
params = {
55+
'name': NAME,
56+
'version': VERSION,
57+
'description': DESCRIPTION,
58+
'keywords': KEYWORDS,
59+
'long_description': LONG_DESCRIPTION,
60+
'author': AUTHOR,
61+
'author_email': AUTHOR_EMAIL,
62+
'url': URL,
63+
'license': LICENSE,
64+
'packages': PACKAGES,
65+
'install_requires': INSTALL_REQUIRES,
66+
'tests_require': TESTS_REQUIRE,
67+
'test_suite': TEST_SUITE,
68+
'classifiers': CLASSIFIERS,
69+
}
70+
71+
setup(**params)

tests/__init__.py

Whitespace-only changes.

tests/unitutil.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# unitutil.py
4+
#
5+
# Copyright (C) 2013 Steve Canny scanny@cisco.com
6+
#
7+
# This module is part of python-docx and is released under the MIT License:
8+
# http://www.opensource.org/licenses/mit-license.php
9+
10+
"""Utility functions for unit testing"""
11+
12+
import os
13+
14+
from mock import patch
15+
16+
17+
def abspath(relpath):
18+
thisdir = os.path.split(__file__)[0]
19+
return os.path.abspath(os.path.join(thisdir, relpath))
20+
21+
22+
def class_mock(q_class_name, request):
23+
"""
24+
Return a mock patching the class with qualified name *q_class_name*.
25+
Patch is reversed after calling test returns.
26+
"""
27+
_patch = patch(q_class_name, autospec=True)
28+
request.addfinalizer(_patch.stop)
29+
return _patch.start()
30+
31+
32+
def function_mock(q_function_name, request):
33+
"""
34+
Return a mock patching the function with qualified name
35+
*q_function_name*. Patch is reversed after calling test returns.
36+
"""
37+
_patch = patch(q_function_name)
38+
request.addfinalizer(_patch.stop)
39+
return _patch.start()
40+
41+
42+
def initializer_mock(cls, request):
43+
"""
44+
Return a mock for the __init__ method on *cls* where the patch is
45+
reversed after pytest uses it.
46+
"""
47+
_patch = patch.object(cls, '__init__', return_value=None)
48+
request.addfinalizer(_patch.stop)
49+
return _patch.start()
50+
51+
52+
def method_mock(cls, method_name, request):
53+
"""
54+
Return a mock for method *method_name* on *cls* where the patch is
55+
reversed after pytest uses it.
56+
"""
57+
_patch = patch.object(cls, method_name)
58+
request.addfinalizer(_patch.stop)
59+
return _patch.start()
60+
61+
62+
def var_mock(q_var_name, request):
63+
"""
64+
Return a mock patching the variable with qualified name *q_var_name*.
65+
Patch is reversed after calling test returns.
66+
"""
67+
_patch = patch(q_var_name)
68+
request.addfinalizer(_patch.stop)
69+
return _patch.start()

0 commit comments

Comments
 (0)
X Tutup