Skip to content

Commit

Permalink
Merge pull request #1 from martin-majlis/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
fjhheras authored Sep 2, 2018
2 parents 34dc93c + 34488cb commit 104390c
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 38 deletions.
60 changes: 51 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,25 @@ pypi-html:

run-tests:
python3 -m unittest discover tests/ '*test.py'

run-type-check:
mypy ./example.py

run-coverage:
coverage run --source=wikipediaapi -m unittest discover tests/ '*test.py'
coverage report -m

release: run-tests pypi-html
if [ "x$(MSG)" = "x" ]; then \
echo "Use make release MSG='some msg'"; \
requirements:
pip3 install -r requirements.txt

requirements-dev:
pip3 install -r requirements-dev.txt

pre-release-check: run-tests run-coverage pypi-html run-type-check

release: pre-release-check
if [ "x$(MSG)" = "x" -o "x$(VERSION)" = "x" ]; then \
echo "Use make release MSG='some msg' VERSION='1.2.3'"; \
exit 1; \
fi; \
version=`grep __version__ wikipediaapi/__init__.py | sed -r 's/.*= \( *(.*), *(.*), *(.*)\)/\1.\2.\3/'`; \
Expand All @@ -35,13 +46,43 @@ release: run-tests pypi-html
exit 1; \
fi; \
echo "Current version: $$version"; \
short=`echo $$version | cut -f1-2 -d.`; \
echo "Short version: $$short"; \
sed -ri 's/^release = .*/release = "'$$version'"/' conf.py; \
sed -ri 's/^version = .*/version = "'$$short'"/' conf.py; \
git commit conf.py -m "Update version to $$version in conf.py"; \
as_number() { \
total=0; \
for p in `echo $$1 | tr "." "\n"`; do \
total=$$(( $$total * 1000 + $$p )); \
done; \
echo $$total; \
}; \
number_dots=`echo -n $(VERSION) | sed -r 's/[^.]//g' | wc -c`; \
if [ ! "$${number_dots}" = "2" ]; then \
echo "Version has to have format X.Y.Z"; \
echo "Specified version is $(VERSION)"; \
exit 2; \
fi; \
number_version=`as_number $$version`; \
number_VERSION=`as_number $(VERSION);`; \
if [ $$number_version -ge $$number_VERSION ]; then \
echo -n "Specified version $(VERSION) ($$number_VERSION) is lower than"; \
echo "current version $$version ($$number_version)"; \
echo "New version has to be greater"; \
exit 2; \
fi; \
has_documentation=`grep -c "^$(VERSION)\\$$" CHANGES.rst`; \
if [ $$has_documentation -eq 0 ]; then \
echo "There is no information about $(VERSION) in CHANGES.rst"; \
exit 3; \
fi; \
short_VERSION=`echo $(VERSION) | cut -f1-2 -d.`; \
commas_VERSION=`echo $(VERSION) | sed -r 's/\./, /g'`; \
echo "Short version: $$short_VERSION"; \
sed -ri 's/version=.*/version="'$(VERSION)'",/' setup.py; \
sed -ri 's/^release = .*/release = "'$(VERSION)'"/' conf.py; \
sed -ri 's/^version = .*/version = "'$$short_VERSION'"/' conf.py; \
sed -ri 's/^Current version is: .*/Current version is: "'$(VERSION)'"/' wikipediaapi/__init__.py; \
sed -ri 's/^__version__ = .*/__version__ = ('"$$commas_VERSION"')/' wikipediaapi/__init__.py; \
git commit setup.py conf.py wikipediaapi/__init__.py -m "Update version to $(VERSION) for new release."; \
git push; \
git tag $$version -m "$(MSG)"; \
git tag $(VERSION) -m "$(MSG)"; \
git push --tags origin master

# Catch-all target: route all unknown targets to Sphinx using the new
Expand All @@ -51,3 +92,4 @@ release: run-tests pypi-html




2 changes: 1 addition & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
# The short X.Y version.
version = "0.3"
# The full version, including alpha/beta/rc tags.
release = "0.3.5"
release = "0.3.7"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mypy
sphinx
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
requests
typing
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def fix_doc(txt):

setup(
name='Wikipedia-API',
version='0.3.5',
version="0.3.7",
description='Python Wrapper for Wikipedia',
long_description=README + '\n\n' + CHANGES,
classifiers=[
Expand Down
16 changes: 16 additions & 0 deletions tests/extract_html_format_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,19 @@ def test_text(self):
"<p>Text for section 5.1\n\n\n</p>"
)
)

def test_with_erroneous_edit(self):
page = self.wiki.page('Test_Edit')
self.maxDiff = None
section = page.section_by_title('Section with Edit')
self.assertEqual(section.title, 'Section with Edit')
self.assertEqual(
page.text,
(
"<p><b>Summary</b> text\n\n</p>\n\n" +
"<h2>Section 1</h2>\n" +
"<p>Text for section 1</p>\n\n"
"<h3>Section with Edit</h3>\n" +
"<p>Text for section with edit\n\n\n</p>"
)
)
30 changes: 30 additions & 0 deletions tests/mock_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,36 @@ def wikipedia_api_request(page, params):
}
}
},
'en:action=query&prop=extracts&titles=Test_Edit&': {
"batchcomplete": "",
"warnings": {
"extracts": {
"*": "\"exlimit\" was too large for a whole article extracts request, lowered to 1."
}
},
"query": {
"normalized": [
{
"from": "Test_Edit",
"to": "Test Edit"
}
],
"pages": {
"4": {
"pageid": 4,
"ns": 0,
"title": "Test Edit",
"extract": (
"<p><b>Summary</b> text\n\n</p>\n" +
"<h2>Section 1</h2>\n" +
"<p>Text for section 1</p>\n\n\n" +
"<h3><span id=\"s1.Edit\">Section with Edit</span><span>Edit</span></h3>\n" +
"<p>Text for section with edit\n\n\n</p>"
)
}
}
}
},
'en:action=query&inprop=protection|talkid|watched|watchers|visitingwatchers|notificationtimestamp|subjectid|url|readable|preload|displaytitle&prop=info&titles=Test_1&': {
"batchcomplete": "",
"query": {
Expand Down
4 changes: 2 additions & 2 deletions wikipediaapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Wikipedia-API is easy to use Python wrapper for `Wikipedias'`_ API. It supports extracting texts, sections, links, categories, translations, etc from Wikipedia. Documentation provides code snippets for the most common use cases.
You can learn more at: http://wikipedia-api.readthedocs.io/en/latest/
Current version is: 0.3.5
Current version is: "0.3.7"
'''
from .wikipedia import *
__version__ = (0, 3, 5)
__version__ = (0, 3, 7)
Loading

0 comments on commit 104390c

Please sign in to comment.