summaryrefslogtreecommitdiff
path: root/sphinx/util/fileutil.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/util/fileutil.py')
-rw-r--r--sphinx/util/fileutil.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/sphinx/util/fileutil.py b/sphinx/util/fileutil.py
index aab919ef2..772e41331 100644
--- a/sphinx/util/fileutil.py
+++ b/sphinx/util/fileutil.py
@@ -16,8 +16,15 @@ import posixpath
from docutils.utils import relative_path
from sphinx.util.osutil import copyfile, ensuredir, walk
+if False:
+ # For type annotation
+ from typing import Callable, Dict, Union # NOQA
+ from sphinx.util.matching import Matcher # NOQA
+ from sphinx.util.template import BaseRenderer # NOQA
+
def copy_asset_file(source, destination, context=None, renderer=None):
+ # type: (unicode, unicode, Dict, BaseRenderer) -> None
"""Copy an asset file to destination.
On copying, it expands the template variables if context argument is given and
@@ -40,16 +47,17 @@ def copy_asset_file(source, destination, context=None, renderer=None):
from sphinx.util.template import SphinxRenderer
renderer = SphinxRenderer()
- with codecs.open(source, 'r', encoding='utf-8') as fsrc:
+ with codecs.open(source, 'r', encoding='utf-8') as fsrc: # type: ignore
if destination.lower().endswith('_t'):
destination = destination[:-2]
- with codecs.open(destination, 'w', encoding='utf-8') as fdst:
- fdst.write(renderer.render_string(fsrc.read(), context))
+ with codecs.open(destination, 'w', encoding='utf-8') as fdst: # type: ignore
+ fdst.write(renderer.render_string(fsrc.read(), context)) # type: ignore
else:
copyfile(source, destination)
def copy_asset(source, destination, excluded=lambda path: False, context=None, renderer=None):
+ # type: (unicode, unicode, Union[Callable[[unicode], bool], Matcher], Dict, BaseRenderer) -> None # NOQA
"""Copy asset files to destination recursively.
On copying, it expands the template variables if context argument is given and