From 7a053dc74cf7561f0be0d7722b843b5374e43b8d Mon Sep 17 00:00:00 2001 From: Lars Kiesow Date: Sun, 29 Apr 2018 21:11:30 +0200 Subject: [PATCH] Consistent method naming This patch renames the entries `pubdate` method to `pubDate` to be consistent with the feed's method as well as the documentation. Note that for now, the old method is preserved as well but is marked as deprecated and to be removed. This fixes #71 --- feedgen/entry.py | 15 ++++++++++++++- tests/test_entry.py | 4 ++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/feedgen/entry.py b/feedgen/entry.py index 8c83bbf..6de4c5a 100644 --- a/feedgen/entry.py +++ b/feedgen/entry.py @@ -12,6 +12,7 @@ from datetime import datetime import dateutil.parser import dateutil.tz +import warnings from lxml import etree from feedgen.compat import string_types @@ -569,13 +570,25 @@ class FeedEntry(object): return self.__atom_published - def pubdate(self, pubDate=None): + def pubDate(self, pubDate=None): '''Get or set the pubDate of the entry which indicates when the entry was published. This method is just another name for the published(...) method. ''' return self.published(pubDate) + def pubdate(self, pubDate=None): + '''Get or set the pubDate of the entry which indicates when the entry + was published. This method is just another name for the published(...) + method. + + pubdate(…) is deprected and may be removed in feedgen ≥ 0.8. Use + pubDate(…) instead. + ''' + warnings.warn('pubdate(…) is deprected and may be removed in feedgen ' + '≥ 0.8. Use pubDate(…) instead.') + return self.published(pubDate) + def rights(self, rights=None): '''Get or set the rights value of the entry which conveys information about rights, e.g. copyrights, held in and over the entry. This ATOM diff --git a/tests/test_entry.py b/tests/test_entry.py index 173eabf..1df3da5 100644 --- a/tests/test_entry.py +++ b/tests/test_entry.py @@ -87,8 +87,8 @@ class TestSequenceFunctions(unittest.TestCase): assert fe.summary() == 'asdf' fe.description('asdfx') assert fe.description() == 'asdfx' - fe.pubdate('2017-02-05 13:26:58+01:00') - assert fe.pubdate().year == 2017 + fe.pubDate('2017-02-05 13:26:58+01:00') + assert fe.pubDate().year == 2017 fe.rights('asdfx') assert fe.rights() == 'asdfx' fe.comments('asdfx')