Browse Source

Remove custom copytree

pull/455/head
Simon Conseil 4 years ago
parent
commit
a9b69d3ad6
  1. 4
      .pre-commit-config.yaml
  2. 2
      pyproject.toml
  3. 20
      sigal/writer.py

4
.pre-commit-config.yaml

@ -5,9 +5,9 @@ repos:
- id: check-yaml
- id: check-added-large-files
- id: trailing-whitespace
exclude: ".*(galleria|photoswipe|jquery).*$"
exclude: ".*(galleria|photoswipe|jquery|leaflet).*$"
- id: end-of-file-fixer
exclude: ".*(galleria|photoswipe|jquery).*$"
exclude: ".*(galleria|photoswipe|jquery|leaflet).*$"
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:

2
pyproject.toml

@ -7,6 +7,6 @@ write_to = "sigal/version.py"
[tool.black]
line-length = 88
target-version = ['py37', 'py38', 'py39']
target-version = ['py38']
experimental-string-processing = true
skip-string-normalization = true

20
sigal/writer.py

@ -27,7 +27,6 @@ import shutil
import sys
import types
import jinja2
from jinja2 import ChoiceLoader, Environment, FileSystemLoader, PrefixLoader
from jinja2.exceptions import TemplateNotFound
@ -39,18 +38,6 @@ THEMES_PATH = os.path.normpath(
)
def copytree(src, dst, symlinks=False, ignore=None):
# FIXME: replace this with shutil.copytree and dirs_exist_ok when
# minimum Python is 3.8
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
shutil.copytree(s, d, symlinks, ignore)
else:
shutil.copy2(s, d)
class AbstractWriter:
template_file = None
@ -112,8 +99,11 @@ class AbstractWriter:
if os.path.isdir(self.theme_path):
shutil.rmtree(self.theme_path)
copytree(os.path.join(THEMES_PATH, 'default', 'static'), self.theme_path)
copytree(os.path.join(self.theme, 'static'), self.theme_path)
for static_path in (
os.path.join(THEMES_PATH, 'default', 'static'),
os.path.join(self.theme, 'static'),
):
shutil.copytree(static_path, self.theme_path, dirs_exist_ok=True)
if self.settings["user_css"]:
if not os.path.exists(self.settings["user_css"]):

Loading…
Cancel
Save