Browse Source

Merge pull request #449 from saimn/remove-py37

Remove py37, use stdlib's cached_property
pull/452/head
Simon Conseil 4 years ago committed by GitHub
parent
commit
27a803f002
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .github/workflows/python-tests.yml
  2. 2
      .readthedocs.yml
  3. 2
      docs/changelog.rst
  4. 3
      setup.cfg
  5. 2
      sigal/gallery.py
  6. 3
      sigal/plugins/zip_gallery.py
  7. 21
      sigal/utils.py
  8. 9
      tox.ini

2
.github/workflows/python-tests.yml

@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, "3.10"]
python-version: [3.8, 3.9, "3.10"]
steps:
- uses: actions/checkout@v2

2
.readthedocs.yml

@ -4,7 +4,7 @@ build:
image: latest
python:
version: 3.7
version: 3.8
install:
- method: pip
path: .

2
docs/changelog.rst

@ -7,7 +7,7 @@ Version 2.3.dev
Not released yet.
Sigal now requires Python 3.7+.
Sigal now requires Python 3.8+.
- Add option ``max_img_pixels`` to allow processing huge images (sets
``PIL.Image.MAX_IMAGE_PIXELS``) [:issue:`431`].

3
setup.cfg

@ -15,7 +15,6 @@ classifiers =
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
@ -27,7 +26,7 @@ classifiers =
zip_safe = False
include_package_data = True
packages = find:
python_requires = >=3.7
python_requires = >=3.8
install_requires =
blinker
click

2
sigal/gallery.py

@ -33,6 +33,7 @@ import random
import sys
from collections import defaultdict
from datetime import datetime
from functools import cached_property
from itertools import cycle
from os.path import isfile, join, splitext
from urllib.parse import quote as url_quote
@ -46,7 +47,6 @@ from .image import get_exif_tags, get_image_metadata, get_size, process_image
from .settings import Status, get_thumb
from .utils import (
Devnull,
cached_property,
check_or_create_dir,
copy,
get_mime,

3
sigal/plugins/zip_gallery.py

@ -34,11 +34,11 @@ See :ref:`compatibility with the encrypt plugin <compatibility-with-encrypt>`.
import logging
import os
import zipfile
from functools import cached_property
from os.path import isfile, join
from sigal import signals
from sigal.gallery import Album
from sigal.utils import cached_property
logger = logging.getLogger(__name__)
@ -108,6 +108,7 @@ def generate_album_zip(album):
def nozip_gallery_file(album, settings=None):
"""Filesystem based switch to disable ZIP generation for an Album"""
Album.zip = cached_property(generate_album_zip)
Album.zip.__set_name__(Album, 'zip')
def register(settings):

21
sigal/utils.py

@ -119,24 +119,3 @@ def is_valid_html5_video(ext):
def get_mime(ext):
"""Returns mime type for extension."""
return VIDEO_MIMES[ext]
class cached_property:
"""A property that is only computed once per instance and then replaces
itself with an ordinary attribute. Deleting the attribute resets the
property.
Source:
https://github.com/pydanny/cached-property (BSD Licensed)
https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
"""
def __init__(self, func):
self.__doc__ = getattr(func, '__doc__')
self.func = func
def __get__(self, obj, cls):
if obj is None:
return self
value = obj.__dict__[self.func.__name__] = self.func(obj)
return value

9
tox.ini

@ -1,20 +1,19 @@
[tox]
envlist = py{37,38,39,310}-pillow{71,-latest},pypy3,check
envlist = py{38,39,310}-pillow{71,80,-latest},pypy3,check
skip_missing_interpreters = true
isolated_build = true
[gh-actions]
python =
3.7: py37-pillow71
3.8: py38-pillow-latest, check
3.9: py39-pillow-latest
3.8: py38-pillow71, check
3.9: py39-pillow80
3.10: py310-pillow-latest
pypy3: pypy3
[testenv]
deps =
pillow70: Pillow==7.0.0
pillow71: Pillow==7.1.0
pillow80: Pillow==8.0.0
extras =
all
tests

Loading…
Cancel
Save