Import feedgenerator_1.9.orig.tar.gz
Vincent Cheng
7 years ago
35 | 35 | from .timezone import is_aware |
36 | 36 | |
37 | 37 | def rfc2822_date(date): |
38 | # We can't use strftime() because it produces locale-dependant results, so | |
38 | # We can't use strftime() because it produces locale-dependent results, so | |
39 | 39 | # we have to map english month and day names manually |
40 | 40 | months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',) |
41 | 41 | days = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun') |
79 | 79 | d = '' |
80 | 80 | if date is not None: |
81 | 81 | d = ',%s' % datetime_safe.new_datetime(date).strftime('%Y-%m-%d') |
82 | return 'tag:%s%s:%s/%s' % (bits.hostname, d, bits.path, bits.fragment) | |
82 | fragment = '' | |
83 | if bits.fragment != '': | |
84 | fragment = '/%s' % (bits.fragment) | |
85 | return 'tag:%s%s:%s%s' % (bits.hostname, d, bits.path, fragment) | |
83 | 86 | |
84 | 87 | class SyndicationFeed(object): |
85 | 88 | "Base class for all syndication feeds. Subclasses should provide write()" |
345 | 348 | def add_item_elements(self, handler, item): |
346 | 349 | handler.addQuickElement("title", item['title']) |
347 | 350 | handler.addQuickElement("link", "", {"href": item['link'], "rel": "alternate"}) |
351 | ||
352 | updateddate = datetime.datetime.now() | |
348 | 353 | if item['pubdate'] is not None: |
349 | 354 | handler.addQuickElement("published", rfc3339_date(item['pubdate'])) |
355 | updateddate = item['pubdate'] | |
350 | 356 | if item['updateddate'] is not None: |
351 | handler.addQuickElement("updated", rfc3339_date(item['updateddate'])) | |
357 | updateddate = item['updateddate'] | |
358 | handler.addQuickElement("updated", rfc3339_date(updateddate)) | |
352 | 359 | |
353 | 360 | # Author information. |
354 | 361 | if item['author_name'] is not None: |
35 | 35 | from .timezone import is_aware |
36 | 36 | |
37 | 37 | def rfc2822_date(date): |
38 | # We can't use strftime() because it produces locale-dependant results, so | |
38 | # We can't use strftime() because it produces locale-dependent results, so | |
39 | 39 | # we have to map english month and day names manually |
40 | 40 | months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',) |
41 | 41 | days = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun') |
79 | 79 | d = '' |
80 | 80 | if date is not None: |
81 | 81 | d = ',%s' % datetime_safe.new_datetime(date).strftime('%Y-%m-%d') |
82 | return 'tag:%s%s:%s/%s' % (bits.hostname, d, bits.path, bits.fragment) | |
82 | fragment = '' | |
83 | if bits.fragment != '': | |
84 | fragment = '/%s' % (bits.fragment) | |
85 | return 'tag:%s%s:%s%s' % (bits.hostname, d, bits.path, fragment) | |
83 | 86 | |
84 | 87 | class SyndicationFeed(object): |
85 | 88 | "Base class for all syndication feeds. Subclasses should provide write()" |
345 | 348 | def add_item_elements(self, handler, item): |
346 | 349 | handler.addQuickElement("title", item['title']) |
347 | 350 | handler.addQuickElement("link", "", {"href": item['link'], "rel": "alternate"}) |
351 | ||
352 | updateddate = datetime.datetime.now() | |
348 | 353 | if item['pubdate'] is not None: |
349 | 354 | handler.addQuickElement("published", rfc3339_date(item['pubdate'])) |
355 | updateddate = item['pubdate'] | |
350 | 356 | if item['updateddate'] is not None: |
351 | handler.addQuickElement("updated", rfc3339_date(item['updateddate'])) | |
357 | updateddate = item['updateddate'] | |
358 | handler.addQuickElement("updated", rfc3339_date(updateddate)) | |
352 | 359 | |
353 | 360 | # Author information. |
354 | 361 | if item['author_name'] is not None: |
35 | 35 | from .timezone import is_aware |
36 | 36 | |
37 | 37 | def rfc2822_date(date): |
38 | # We can't use strftime() because it produces locale-dependant results, so | |
38 | # We can't use strftime() because it produces locale-dependent results, so | |
39 | 39 | # we have to map english month and day names manually |
40 | 40 | months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',) |
41 | 41 | days = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun') |
79 | 79 | d = '' |
80 | 80 | if date is not None: |
81 | 81 | d = ',%s' % datetime_safe.new_datetime(date).strftime('%Y-%m-%d') |
82 | return 'tag:%s%s:%s/%s' % (bits.hostname, d, bits.path, bits.fragment) | |
82 | fragment = '' | |
83 | if bits.fragment != '': | |
84 | fragment = '/%s' % (bits.fragment) | |
85 | return 'tag:%s%s:%s%s' % (bits.hostname, d, bits.path, fragment) | |
83 | 86 | |
84 | 87 | class SyndicationFeed(object): |
85 | 88 | "Base class for all syndication feeds. Subclasses should provide write()" |
345 | 348 | def add_item_elements(self, handler, item): |
346 | 349 | handler.addQuickElement("title", item['title']) |
347 | 350 | handler.addQuickElement("link", "", {"href": item['link'], "rel": "alternate"}) |
351 | ||
352 | updateddate = datetime.datetime.now() | |
348 | 353 | if item['pubdate'] is not None: |
349 | 354 | handler.addQuickElement("published", rfc3339_date(item['pubdate'])) |
355 | updateddate = item['pubdate'] | |
350 | 356 | if item['updateddate'] is not None: |
351 | handler.addQuickElement("updated", rfc3339_date(item['updateddate'])) | |
357 | updateddate = item['updateddate'] | |
358 | handler.addQuickElement("updated", rfc3339_date(updateddate)) | |
352 | 359 | |
353 | 360 | # Author information. |
354 | 361 | if item['author_name'] is not None: |
0 | 0 | Metadata-Version: 1.1 |
1 | 1 | Name: feedgenerator |
2 | Version: 1.8 | |
2 | Version: 1.9 | |
3 | 3 | Summary: Standalone version of django.utils.feedgenerator |
4 | 4 | Home-page: https://github.com/getpelican/feedgenerator |
5 | Author: Dirk Makowski | |
6 | Author-email: dm@parenchym.com | |
5 | Author: Pelican Dev Team | |
6 | Author-email: authors@getpelican.com | |
7 | 7 | License: UNKNOWN |
8 | 8 | Description: FeedGenerator |
9 | 9 | ============= |
35 | 35 | from .timezone import is_aware |
36 | 36 | |
37 | 37 | def rfc2822_date(date): |
38 | # We can't use strftime() because it produces locale-dependant results, so | |
38 | # We can't use strftime() because it produces locale-dependent results, so | |
39 | 39 | # we have to map english month and day names manually |
40 | 40 | months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',) |
41 | 41 | days = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun') |
79 | 79 | d = '' |
80 | 80 | if date is not None: |
81 | 81 | d = ',%s' % datetime_safe.new_datetime(date).strftime('%Y-%m-%d') |
82 | return 'tag:%s%s:%s/%s' % (bits.hostname, d, bits.path, bits.fragment) | |
82 | fragment = '' | |
83 | if bits.fragment != '': | |
84 | fragment = '/%s' % (bits.fragment) | |
85 | return 'tag:%s%s:%s%s' % (bits.hostname, d, bits.path, fragment) | |
83 | 86 | |
84 | 87 | class SyndicationFeed(object): |
85 | 88 | "Base class for all syndication feeds. Subclasses should provide write()" |
345 | 348 | def add_item_elements(self, handler, item): |
346 | 349 | handler.addQuickElement("title", item['title']) |
347 | 350 | handler.addQuickElement("link", "", {"href": item['link'], "rel": "alternate"}) |
351 | ||
352 | updateddate = datetime.datetime.now() | |
348 | 353 | if item['pubdate'] is not None: |
349 | 354 | handler.addQuickElement("published", rfc3339_date(item['pubdate'])) |
355 | updateddate = item['pubdate'] | |
350 | 356 | if item['updateddate'] is not None: |
351 | handler.addQuickElement("updated", rfc3339_date(item['updateddate'])) | |
357 | updateddate = item['updateddate'] | |
358 | handler.addQuickElement("updated", rfc3339_date(updateddate)) | |
352 | 359 | |
353 | 360 | # Author information. |
354 | 361 | if item['author_name'] is not None: |
0 | 0 | Metadata-Version: 1.1 |
1 | 1 | Name: feedgenerator |
2 | Version: 1.8 | |
2 | Version: 1.9 | |
3 | 3 | Summary: Standalone version of django.utils.feedgenerator |
4 | 4 | Home-page: https://github.com/getpelican/feedgenerator |
5 | Author: Dirk Makowski | |
6 | Author-email: dm@parenchym.com | |
5 | Author: Pelican Dev Team | |
6 | Author-email: authors@getpelican.com | |
7 | 7 | License: UNKNOWN |
8 | 8 | Description: FeedGenerator |
9 | 9 | ============= |
0 | #! /usr/bin/python | |
0 | #!/usr/bin/env python | |
1 | 1 | |
2 | 2 | # Using setuptools rather than distutils to get the `develop` command |
3 | 3 | from setuptools import setup |
5 | 5 | |
6 | 6 | NAME = 'feedgenerator' |
7 | 7 | PACKAGES = ['feedgenerator', 'feedgenerator.django', |
8 | 'feedgenerator.django.utils'] | |
8 | 'feedgenerator.django.utils'] | |
9 | 9 | DESCRIPTION = 'Standalone version of django.utils.feedgenerator' |
10 | 10 | LONG_DESCRIPTION = open('README.rst').read() |
11 | 11 | |
25 | 25 | 'Topic :: Internet :: WWW/HTTP', |
26 | 26 | 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', |
27 | 27 | 'Topic :: Software Development :: Libraries :: Python Modules', |
28 | ] | |
28 | ] | |
29 | 29 | |
30 | 30 | AUTHOR = 'Django Software Foundation' |
31 | 31 | AUTHOR_EMAIL = 'foundation@djangoproject.com' |
32 | MAINTAINER = 'Dirk Makowski' | |
33 | MAINTAINER_EMAIL = 'dm@parenchym.com' | |
32 | MAINTAINER = 'Pelican Dev Team' | |
33 | MAINTAINER_EMAIL = 'authors@getpelican.com' | |
34 | 34 | KEYWORDS = "feed atom rss".split(' ') |
35 | VERSION = '1.8' | |
35 | VERSION = '1.9' | |
36 | 36 | |
37 | 37 | TEST_SUITE = 'tests_feedgenerator' |
38 | 38 |
Binary diff not shown
7 | 7 | import unittest |
8 | 8 | |
9 | 9 | import six |
10 | import datetime | |
10 | 11 | |
11 | 12 | import feedgenerator |
12 | 13 | |
25 | 26 | link="http://www.holovaty.com/test/", |
26 | 27 | description="Testing.", |
27 | 28 | content="Full content of our testing entry.", |
29 | pubdate=datetime.datetime(2016,8,11,0,0,0,0), | |
28 | 30 | ) |
29 | 31 | |
30 | 32 | |
33 | 35 | Umlauts: äöüßÄÖÜ |
34 | 36 | Chinese: 老师是四十四,是不是? |
35 | 37 | Finnish: Mustan kissan paksut posket. (ah, no special chars) Kärpänen sanoi kärpäselle: tuu kattoon kattoon ku kaveri tapettiin tapettiin. |
36 | </description><language>en</language><lastBuildDate>%DATE%</lastBuildDate><item><title>Hello</title><link>http://www.holovaty.com/test/</link><description>Testing.</description></item></channel></rss>""" | |
38 | </description><language>en</language><lastBuildDate>%DATE%</lastBuildDate><item><title>Hello</title><link>http://www.holovaty.com/test/</link><description>Testing.</description><pubDate>Thu, 11 Aug 2016 00:00:00 -0000</pubDate></item></channel></rss>""" | |
37 | 39 | |
38 | 40 | EXPECTED_RESULT_ATOM = """<?xml version="1.0" encoding="utf-8"?> |
39 | <feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Poynter E-Media Tidbits</title><link href="http://www.poynter.org/column.asp?id=31" rel="alternate"></link><id>http://www.poynter.org/column.asp?id=31</id><updated>%DATE%</updated><entry><title>Hello</title><link href="http://www.holovaty.com/test/" rel="alternate"></link><id>tag:www.holovaty.com:/test//</id><summary type="html">Testing.</summary><content type="html">Full content of our testing entry.</content></entry></feed>""" | |
41 | <feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Poynter E-Media Tidbits</title><link href="http://www.poynter.org/column.asp?id=31" rel="alternate"></link><id>http://www.poynter.org/column.asp?id=31</id><updated>%DATE%</updated><entry><title>Hello</title><link href="http://www.holovaty.com/test/" rel="alternate"></link><published>2016-08-11T00:00:00Z</published><updated>2016-08-11T00:00:00Z</updated><id>tag:www.holovaty.com,2016-08-11:/test/</id><summary type="html">Testing.</summary><content type="html">Full content of our testing entry.</content></entry></feed>""" | |
40 | 42 | |
41 | 43 | ENCODING = 'utf-8' |
42 | 44 | |
70 | 72 | for k, v in FIXT_FEED.items(): |
71 | 73 | self.assertEqual(type(v), ty) |
72 | 74 | for k, v in FIXT_ITEM.items(): |
73 | self.assertEqual(type(v), ty) | |
75 | if k == "pubdate" or k == "updateddate": | |
76 | self.assertEqual(type(v), datetime.datetime) | |
77 | else: | |
78 | self.assertEqual(type(v), ty) | |
74 | 79 | self.assertEqual(type(EXPECTED_RESULT_RSS), ty) |
75 | 80 | |
76 | 81 | def test_001_string_results_rss(self): |
96 | 101 | self.assertEqual(type(result), type(expected_result)) |
97 | 102 | self.assertEqual(result, expected_result) |
98 | 103 | |
99 | def OFF_test_002_file_results(self): | |
100 | pass | |
101 | # DO-IT_YOURSELF: Run usage_example with python2 and python3. | |
102 | # Each will create a feed file. | |
103 | # Compare the files, they must be equal! | |
104 | # XXX Argh -- No, the lastBuildDate will differ. | |
105 | # But this is allowed. | |
106 | ||
107 | def test_003_string_results_atom(self): | |
104 | def test_002_string_results_atom(self): | |
108 | 105 | #import ipdb; ipdb.set_trace() |
109 | 106 | feed = feedgenerator.Atom1Feed(**FIXT_FEED) |
110 | 107 | feed.add_item(**FIXT_ITEM) |
Binary diff not shown