Skip to content

Commit

Permalink
release 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xrotwang committed Sep 17, 2019
1 parent fd00a7b commit 32db39a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 101 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changes
-------

5.0.0
~~~~~

Require python >= 3.5


4.7.2
~~~~~

Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
# built documents.
#
# The full version, including alpha/beta/rc tags.
release = '4.7.3.dev0'
release = '5.0.0'

# The short X.Y version.
version = '4.7.3.dev0'
version = '5.0.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ source =
tests

[coverage:report]
show_missing = true
skip_covered = true
show_missing = True
skip_covered = True

3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
'xlwt',
'webhelpers2>=2.0',
'nameparser',
'feedparser',
'waitress',
]


setup(
name='clld',
version='4.7.3.dev0',
version='5.0.0',
description=(
'Python library supporting the development of cross-linguistic databases'),
long_description=open('README.md').read(),
Expand Down
2 changes: 1 addition & 1 deletion src/clld/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from clld.db.models import common
from clld import interfaces

__version__ = "4.7.3.dev0"
__version__ = "5.0.0"


class Resource(namedtuple('Resource', 'name model interface with_index with_rdfdump')):
Expand Down
31 changes: 0 additions & 31 deletions src/clld/web/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@
from json import dumps
import re
from functools import partial
from datetime import datetime
from time import mktime

import requests
from requests.exceptions import Timeout
import feedparser
from pyramid.response import Response
import pyramid.httpexceptions
from pyramid.interfaces import IRoutesMapper
from pyramid.renderers import render, render_to_response

from clld.util import summary
from clld.interfaces import IRepresentation, IIndex, IMetadata
from clld.web.adapters import get_adapter, get_adapters
from clld.web.adapters.csv import CsvAdapter, CsvmJsonAdapter
Expand Down Expand Up @@ -270,28 +264,3 @@ def combined(ctx, req): # pragma: no cover
if urls:
res['map'] = CombinedMap(urls, req)
return res


def atom_feed(request, feed_url):
"""
Proxy feeds so they can be accessed via XHR requests.
We also convert RSS to ATOM so that the javascript Feed component can read them.
"""
ctx = {'url': feed_url, 'title': None, 'entries': []}
try:
res = requests.get(ctx['url'], timeout=(3.05, 1))
except Timeout:
res = None
if res and res.status_code == 200:
d = feedparser.parse(res.content.strip())
ctx['title'] = getattr(d.feed, 'title', None)
for e in d.entries:
ctx['entries'].append(dict(
title=e.title,
link=e.link,
updated=datetime.fromtimestamp(mktime(e.published_parsed)).isoformat(),
summary=summary(e.description)))
response = render_to_response('atom_feed.mako', ctx, request=request)
response.content_type = 'application/atom+xml'
return response
63 changes: 0 additions & 63 deletions tests/test_web_views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
from pyramid.response import Response
from pyramid.httpexceptions import HTTPNotAcceptable, HTTPNotFound, HTTPGone, HTTPFound
from requests.exceptions import ReadTimeout

from clld.db.models import common
from clld.interfaces import IDataTable
Expand Down Expand Up @@ -129,65 +128,3 @@ def test_unapi(env, request_factory, params, assertion):

with request_factory(params=params) as req:
assert assertion(unapi(req))


def test_atom_feed(env, mocker):
from clld.web.views import atom_feed

class FeedResponseWithTitle(object):
status_code = 200
content = b"""\
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">
<channel>
<title>Comments for The World Atlas of Language Structures Online</title>
<link>http://blog.wals.info</link>
<description>WALS Online Blog</description>
<item>
<title>Comment on Datapoint</title>
<link>http://blog.wals.info/datapoint</link>
<pubDate>Wed, 04 Nov 2015 22:11:03 +0000</pubDate>
<guid>http://blog.wals.info/datapoint-26a-wals_code_juk/</guid>
<description>Some description</description>
<content:encoded><![CDATA[<p>some description</p>
]]></content:encoded>
</item>
</channel>
"""

class FeedResponseWithoutTitle(object):
status_code = 200
content = b"""\
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">
<channel>
<link>http://blog.wals.info</link>
<description>WALS Online Blog</description>
</channel>
"""

class MockRequests1(object):
get = mocker.Mock(return_value=FeedResponseWithTitle)

class MockRequests2(object):
get = mocker.Mock(return_value=FeedResponseWithoutTitle)

class MockRequestsTimeout(object):
def get(self, *args, **kw):
raise ReadTimeout()

mocker.patch('clld.web.views.requests', MockRequests1())
res = atom_feed(env['request'], None)
assert '<entry>' in res.body.decode('utf8')

mocker.patch('clld.web.views.requests', MockRequests2())
res = atom_feed(env['request'], None)
assert '<entry>' not in res.body.decode('utf8')

mocker.patch('clld.web.views.requests', MockRequestsTimeout())
res = atom_feed(env['request'], None)
assert '<entry>' not in res.body.decode('utf8')

0 comments on commit 32db39a

Please sign in to comment.