diff options
author | Justin Mayer <entroP@gmail.com> | 2021-08-18 12:38:23 +0200 |
---|---|---|
committer | Justin Mayer <entroP@gmail.com> | 2021-08-18 12:38:23 +0200 |
commit | f9fb0f980645550459e651f672a132d47a76f8da (patch) | |
tree | 9ae1fde326526fbaa8c55f1e8b61c149c1314ea7 | |
parent | fe40d2912824845d6304b56721886fb7db6470ff (diff) | |
download | feedgenerator-f9fb0f980645550459e651f672a132d47a76f8da.tar.gz |
Update code for Python 3.6+
-rw-r--r-- | feedgenerator/django/utils/encoding.py | 2 | ||||
-rw-r--r-- | feedgenerator/django/utils/feedgenerator.py | 8 | ||||
-rw-r--r-- | feedgenerator/django/utils/functional.py | 6 | ||||
-rw-r--r-- | feedgenerator/django/utils/timezone.py | 2 | ||||
-rw-r--r-- | feedgenerator/django/utils/xmlutils.py | 4 | ||||
-rw-r--r-- | setup.py | 1 |
6 files changed, 11 insertions, 12 deletions
diff --git a/feedgenerator/django/utils/encoding.py b/feedgenerator/django/utils/encoding.py index ce8334e..02bb65c 100644 --- a/feedgenerator/django/utils/encoding.py +++ b/feedgenerator/django/utils/encoding.py @@ -13,7 +13,7 @@ class DjangoUnicodeDecodeError(UnicodeDecodeError): def __str__(self): original = UnicodeDecodeError.__str__(self) - return '%s. You passed in %r (%s)' % (original, self.obj, + return '{}. You passed in {!r} ({})'.format(original, self.obj, type(self.obj)) def smart_text(s, encoding='utf-8', strings_only=False, errors='strict'): diff --git a/feedgenerator/django/utils/feedgenerator.py b/feedgenerator/django/utils/feedgenerator.py index bf33848..b5d858c 100644 --- a/feedgenerator/django/utils/feedgenerator.py +++ b/feedgenerator/django/utils/feedgenerator.py @@ -39,7 +39,7 @@ def rfc2822_date(date): # We do this ourselves to be timezone aware, email.Utils is not tz aware. dow = days[date.weekday()] month = months[date.month - 1] - time_str = date.strftime('%s, %%d %s %%Y %%H:%%M:%%S ' % (dow, month)) + time_str = date.strftime(f'{dow}, %d {month} %Y %H:%M:%S ') if is_aware(date): offset = date.tzinfo.utcoffset(date) timezone = (offset.days * 24 * 60) + (offset.seconds // 60) @@ -73,9 +73,9 @@ def get_tag_uri(url, date): fragment = '' if bits.fragment != '': fragment = '/%s' % (bits.fragment) - return 'tag:%s%s:%s%s' % (bits.hostname, d, bits.path, fragment) + return f'tag:{bits.hostname}{d}:{bits.path}{fragment}' -class SyndicationFeed(object): +class SyndicationFeed: "Base class for all syndication feeds. Subclasses should provide write()" def __init__(self, title, link, description, language=None, author_email=None, author_name=None, author_link=None, subtitle=None, categories=None, @@ -196,7 +196,7 @@ class SyndicationFeed(object): else: return datetime.datetime.now() -class Enclosure(object): +class Enclosure: "Represents an RSS enclosure" def __init__(self, url, length, mime_type): "All args are expected to be Python Unicode objects" diff --git a/feedgenerator/django/utils/functional.py b/feedgenerator/django/utils/functional.py index ba4d586..af31971 100644 --- a/feedgenerator/django/utils/functional.py +++ b/feedgenerator/django/utils/functional.py @@ -29,7 +29,7 @@ def memoize(func, cache, num_args): return result return wrapper -class cached_property(object): +class cached_property: """ Decorator that creates converts a method with a single self argument into a property cached on the instance. @@ -41,7 +41,7 @@ class cached_property(object): res = instance.__dict__[self.func.__name__] = self.func(instance) return res -class Promise(object): +class Promise: """ This is just a base class for the proxy class created in the closure of the lazy function. It can be used to recognize @@ -192,7 +192,7 @@ def new_method_proxy(func): return func(self._wrapped, *args) return inner -class LazyObject(object): +class LazyObject: """ A wrapper for another class that can be used to delay instantiation of the wrapped class. diff --git a/feedgenerator/django/utils/timezone.py b/feedgenerator/django/utils/timezone.py index 3ad8517..38a9a10 100644 --- a/feedgenerator/django/utils/timezone.py +++ b/feedgenerator/django/utils/timezone.py @@ -173,7 +173,7 @@ def deactivate(): if hasattr(_active, "value"): del _active.value -class override(object): +class override: """ Temporarily set the time zone for the current thread. diff --git a/feedgenerator/django/utils/xmlutils.py b/feedgenerator/django/utils/xmlutils.py index d234708..9bec3dd 100644 --- a/feedgenerator/django/utils/xmlutils.py +++ b/feedgenerator/django/utils/xmlutils.py @@ -17,5 +17,5 @@ class SimplerXMLGenerator(XMLGenerator): self._write('<' + name) # sort attributes for consistent output for (name, value) in sorted(attrs.items()): - self._write(' %s=%s' % (name, quoteattr(value))) - self._write(str('>')) + self._write(f' {name}={quoteattr(value)}') + self._write('>') @@ -1,6 +1,5 @@ #!/usr/bin/env python -from io import open # Using setuptools rather than distutils to get the `develop` command from setuptools import setup |