mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Remove use of six.iteritems()
In Python 3, dict.items() is always an iterator.
This commit is contained in:
parent
844a3a5c22
commit
0d6be504ea
@ -13,8 +13,6 @@ import codecs
|
||||
from os import path
|
||||
from typing import cast
|
||||
|
||||
from six import iteritems
|
||||
|
||||
from sphinx import package_dir
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.domains.changeset import ChangeSetDomain
|
||||
@ -109,9 +107,9 @@ class ChangesBuilder(Builder):
|
||||
'version': version,
|
||||
'docstitle': self.config.html_title,
|
||||
'shorttitle': self.config.html_short_title,
|
||||
'libchanges': sorted(iteritems(libchanges)),
|
||||
'libchanges': sorted(libchanges.items()),
|
||||
'apichanges': sorted(apichanges),
|
||||
'otherchanges': sorted(iteritems(otherchanges)),
|
||||
'otherchanges': sorted(otherchanges.items()),
|
||||
'show_copyright': self.config.html_show_copyright,
|
||||
'show_sphinx': self.config.html_show_sphinx,
|
||||
}
|
||||
@ -152,7 +150,7 @@ class ChangesBuilder(Builder):
|
||||
}
|
||||
f.write(self.templates.render('changes/rstsource.html', ctx))
|
||||
themectx = dict(('theme_' + key, val) for (key, val) in
|
||||
iteritems(self.theme.get_options({})))
|
||||
self.theme.get_options({}).items())
|
||||
copy_asset_file(path.join(package_dir, 'themes', 'default', 'static', 'default.css_t'),
|
||||
self.outdir, context=themectx, renderer=self.templates)
|
||||
copy_asset_file(path.join(package_dir, 'themes', 'basic', 'static', 'basic.css'),
|
||||
|
@ -18,7 +18,7 @@ from os import path, walk, getenv
|
||||
from time import time
|
||||
from uuid import uuid4
|
||||
|
||||
from six import iteritems, StringIO
|
||||
from six import StringIO
|
||||
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.domains.python import pairindextypes
|
||||
@ -268,7 +268,7 @@ class MessageCatalogBuilder(I18nBuilder):
|
||||
ctime = datetime.fromtimestamp(
|
||||
timestamp, ltz).strftime('%Y-%m-%d %H:%M%z'),
|
||||
)
|
||||
for textdomain, catalog in status_iterator(iteritems(self.catalogs), # type: ignore
|
||||
for textdomain, catalog in status_iterator(self.catalogs.items(), # type: ignore
|
||||
__("writing message catalogs... "),
|
||||
"darkgreen", len(self.catalogs),
|
||||
self.app.verbosity,
|
||||
|
@ -25,7 +25,7 @@ from docutils.frontend import OptionParser
|
||||
from docutils.io import DocTreeInput, StringOutput
|
||||
from docutils.readers.doctree import Reader as DoctreeReader
|
||||
from docutils.utils import relative_path
|
||||
from six import iteritems, text_type, string_types
|
||||
from six import text_type, string_types
|
||||
from six.moves import cPickle as pickle
|
||||
|
||||
from sphinx import package_dir, __display_version__
|
||||
@ -589,7 +589,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
if self.theme:
|
||||
self.globalcontext.update(
|
||||
('theme_' + key, val) for (key, val) in
|
||||
iteritems(self.theme.get_options(self.theme_options)))
|
||||
self.theme.get_options(self.theme_options).items())
|
||||
self.globalcontext.update(self.config.html_context)
|
||||
|
||||
def get_doc_context(self, docname, body, metatags):
|
||||
@ -1023,7 +1023,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
|
||||
# user sidebar settings
|
||||
html_sidebars = self.get_builder_config('sidebars', 'html')
|
||||
for pattern, patsidebars in iteritems(html_sidebars):
|
||||
for pattern, patsidebars in html_sidebars.items():
|
||||
if patmatch(pagename, pattern):
|
||||
if matched:
|
||||
if has_wildcard(pattern):
|
||||
@ -1294,8 +1294,8 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
|
||||
# There are related codes in inline_all_toctres() and
|
||||
# HTMLTranslter#add_secnumber().
|
||||
new_secnumbers = {} # type: Dict[unicode, Tuple[int, ...]]
|
||||
for docname, secnums in iteritems(self.env.toc_secnumbers):
|
||||
for id, secnum in iteritems(secnums):
|
||||
for docname, secnums in self.env.toc_secnumbers.items():
|
||||
for id, secnum in secnums.items():
|
||||
alias = "%s/%s" % (docname, id)
|
||||
new_secnumbers[alias] = secnum
|
||||
|
||||
@ -1314,11 +1314,11 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
|
||||
# HTMLTranslter#add_fignumber().
|
||||
new_fignumbers = {} # type: Dict[unicode, Dict[unicode, Tuple[int, ...]]]
|
||||
# {u'foo': {'figure': {'id2': (2,), 'id1': (1,)}}, u'bar': {'figure': {'id1': (3,)}}}
|
||||
for docname, fignumlist in iteritems(self.env.toc_fignumbers):
|
||||
for figtype, fignums in iteritems(fignumlist):
|
||||
for docname, fignumlist in self.env.toc_fignumbers.items():
|
||||
for figtype, fignums in fignumlist.items():
|
||||
alias = "%s/%s" % (docname, figtype)
|
||||
new_fignumbers.setdefault(alias, {})
|
||||
for id, fignum in iteritems(fignums):
|
||||
for id, fignum in fignums.items():
|
||||
new_fignumbers[alias][id] = fignum
|
||||
|
||||
return {self.config.master_doc: new_fignumbers}
|
||||
|
@ -18,7 +18,7 @@ from os import path, getenv
|
||||
from typing import Any, NamedTuple, Union
|
||||
|
||||
from six import (
|
||||
PY2, PY3, iteritems, string_types, binary_type, text_type, integer_types, class_types
|
||||
PY2, PY3, string_types, binary_type, text_type, integer_types, class_types
|
||||
)
|
||||
|
||||
from sphinx.deprecation import RemovedInSphinx30Warning
|
||||
@ -246,7 +246,7 @@ class Config(object):
|
||||
def init_values(self):
|
||||
# type: () -> None
|
||||
config = self._raw_config
|
||||
for valname, value in iteritems(self.overrides):
|
||||
for valname, value in self.overrides.items():
|
||||
try:
|
||||
if '.' in valname:
|
||||
realvalname, key = valname.split('.', 1)
|
||||
@ -295,7 +295,7 @@ class Config(object):
|
||||
|
||||
def __iter__(self):
|
||||
# type: () -> Generator[ConfigValue, None, None]
|
||||
for name, value in iteritems(self.values):
|
||||
for name, value in self.values.items():
|
||||
yield ConfigValue(name, getattr(self, name), value[1]) # type: ignore
|
||||
|
||||
def add(self, name, default, rebuild, types):
|
||||
@ -316,7 +316,7 @@ class Config(object):
|
||||
"""Obtains serializable data for pickling."""
|
||||
# remove potentially pickling-problematic values from config
|
||||
__dict__ = {}
|
||||
for key, value in iteritems(self.__dict__):
|
||||
for key, value in self.__dict__.items():
|
||||
if key.startswith('_') or isinstance(value, UNSERIALIZEABLE_TYPES):
|
||||
pass
|
||||
else:
|
||||
@ -324,7 +324,7 @@ class Config(object):
|
||||
|
||||
# create a picklable copy of values list
|
||||
__dict__['values'] = {}
|
||||
for key, value in iteritems(self.values): # type: ignore
|
||||
for key, value in self.values.items(): # type: ignore
|
||||
real_value = getattr(self, key)
|
||||
if isinstance(real_value, UNSERIALIZEABLE_TYPES):
|
||||
# omit unserializable value
|
||||
@ -476,7 +476,7 @@ def check_unicode(config):
|
||||
"""
|
||||
nonascii_re = re.compile(br'[\x80-\xff]')
|
||||
|
||||
for name, value in iteritems(config._raw_config):
|
||||
for name, value in config._raw_config.items():
|
||||
if isinstance(value, binary_type) and nonascii_re.search(value):
|
||||
logger.warning(__('the config value %r is set to a string with non-ASCII '
|
||||
'characters; this can lead to Unicode errors occurring. '
|
||||
|
@ -12,8 +12,6 @@
|
||||
|
||||
import copy
|
||||
|
||||
from six import iteritems
|
||||
|
||||
from sphinx.errors import SphinxError
|
||||
from sphinx.locale import _
|
||||
|
||||
@ -183,7 +181,7 @@ class Domain(object):
|
||||
self.data = env.domaindata[self.name]
|
||||
if self.data['version'] != self.data_version:
|
||||
raise IOError('data of %r domain out of date' % self.label)
|
||||
for name, obj in iteritems(self.object_types):
|
||||
for name, obj in self.object_types.items():
|
||||
for rolename in obj.roles:
|
||||
self._role2type.setdefault(rolename, []).append(name)
|
||||
self._type2role[name] = obj.roles[0] if obj.roles else ''
|
||||
|
@ -12,7 +12,6 @@
|
||||
from typing import NamedTuple
|
||||
|
||||
from docutils import nodes
|
||||
from six import iteritems
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx import locale
|
||||
@ -112,7 +111,7 @@ class ChangeSetDomain(Domain):
|
||||
|
||||
def clear_doc(self, docname):
|
||||
# type: (unicode) -> None
|
||||
for version, changes in iteritems(self.data['changes']):
|
||||
for version, changes in self.data['changes'].items():
|
||||
for changeset in changes[:]:
|
||||
if changeset.docname == docname:
|
||||
changes.remove(changeset)
|
||||
@ -120,7 +119,7 @@ class ChangeSetDomain(Domain):
|
||||
def merge_domaindata(self, docnames, otherdata):
|
||||
# type: (List[unicode], Dict) -> None
|
||||
# XXX duplicates?
|
||||
for version, otherchanges in iteritems(otherdata['changes']):
|
||||
for version, otherchanges in otherdata['changes'].items():
|
||||
changes = self.data['changes'].setdefault(version, [])
|
||||
for changeset in otherchanges:
|
||||
if changeset.docname in docnames:
|
||||
|
@ -14,7 +14,7 @@ from copy import deepcopy
|
||||
|
||||
from docutils import nodes, utils
|
||||
from docutils.parsers.rst import directives
|
||||
from six import iteritems, text_type
|
||||
from six import text_type
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.directives import ObjectDescription
|
||||
@ -604,7 +604,7 @@ class ASTBase(UnicodeMixin):
|
||||
if type(self) is not type(other):
|
||||
return False
|
||||
try:
|
||||
for key, value in iteritems(self.__dict__):
|
||||
for key, value in self.__dict__.items():
|
||||
if value != getattr(other, key):
|
||||
return False
|
||||
except AttributeError:
|
||||
|
@ -13,7 +13,6 @@ import re
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst import directives
|
||||
from six import iteritems
|
||||
|
||||
from sphinx import addnodes, locale
|
||||
from sphinx.deprecation import DeprecatedDict, RemovedInSphinx30Warning
|
||||
@ -677,7 +676,7 @@ class PythonModuleIndex(Index):
|
||||
ignores = self.domain.env.config['modindex_common_prefix'] # type: ignore
|
||||
ignores = sorted(ignores, key=len, reverse=True)
|
||||
# list of all modules, sorted by module name
|
||||
modules = sorted(iteritems(self.domain.data['modules']),
|
||||
modules = sorted(self.domain.data['modules'].items(),
|
||||
key=lambda x: x[0].lower())
|
||||
# sort out collapsable modules
|
||||
prev_modname = ''
|
||||
@ -727,7 +726,7 @@ class PythonModuleIndex(Index):
|
||||
collapse = len(modules) - num_toplevels < num_toplevels
|
||||
|
||||
# sort by first letter
|
||||
sorted_content = sorted(iteritems(content))
|
||||
sorted_content = sorted(content.items())
|
||||
|
||||
return sorted_content, collapse
|
||||
|
||||
@ -923,9 +922,9 @@ class PythonDomain(Domain):
|
||||
|
||||
def get_objects(self):
|
||||
# type: () -> Iterator[Tuple[unicode, unicode, unicode, unicode, unicode, int]]
|
||||
for modname, info in iteritems(self.data['modules']):
|
||||
for modname, info in self.data['modules'].items():
|
||||
yield (modname, modname, 'module', info[0], 'module-' + modname, 0)
|
||||
for refname, (docname, type) in iteritems(self.data['objects']):
|
||||
for refname, (docname, type) in self.data['objects'].items():
|
||||
if type != 'module': # modules are already handled
|
||||
yield (refname, refname, type, docname, refname, 1)
|
||||
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
import re
|
||||
|
||||
from six import iteritems
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.directives import ObjectDescription
|
||||
from sphinx.domains import Domain, ObjType
|
||||
@ -172,7 +170,7 @@ class ReSTDomain(Domain):
|
||||
|
||||
def get_objects(self):
|
||||
# type: () -> Iterator[Tuple[unicode, unicode, unicode, unicode, unicode, int]]
|
||||
for (typ, name), docname in iteritems(self.data['objects']):
|
||||
for (typ, name), docname in self.data['objects'].items():
|
||||
yield name, name, typ, docname, typ + '-' + name, 1
|
||||
|
||||
|
||||
|
@ -17,7 +17,6 @@ from copy import copy
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst import directives
|
||||
from docutils.statemachine import ViewList
|
||||
from six import iteritems
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.deprecation import RemovedInSphinx30Warning
|
||||
@ -529,7 +528,7 @@ class StandardDomain(Domain):
|
||||
|
||||
# set up enumerable nodes
|
||||
self.enumerable_nodes = copy(self.enumerable_nodes) # create a copy for this instance
|
||||
for node, settings in iteritems(env.app.registry.enumerable_nodes):
|
||||
for node, settings in env.app.registry.enumerable_nodes.items():
|
||||
self.enumerable_nodes[node] = settings
|
||||
|
||||
def clear_doc(self, docname):
|
||||
@ -607,7 +606,7 @@ class StandardDomain(Domain):
|
||||
def note_labels(self, env, docname, document):
|
||||
# type: (BuildEnvironment, unicode, nodes.Node) -> None
|
||||
labels, anonlabels = self.data['labels'], self.data['anonlabels']
|
||||
for name, explicit in iteritems(document.nametypes):
|
||||
for name, explicit in document.nametypes.items():
|
||||
if not explicit:
|
||||
continue
|
||||
labelid = document.nameids[name]
|
||||
@ -647,7 +646,7 @@ class StandardDomain(Domain):
|
||||
|
||||
def check_consistency(self):
|
||||
# type: () -> None
|
||||
for name, (docname, labelid, lineno) in iteritems(self.data['citations']):
|
||||
for name, (docname, labelid, lineno) in self.data['citations'].items():
|
||||
if name not in self.data['citation_refs']:
|
||||
logger.warning(__('Citation [%s] is not referenced.'), name,
|
||||
type='ref', subtype='citation',
|
||||
@ -887,20 +886,20 @@ class StandardDomain(Domain):
|
||||
# handle the special 'doc' reference here
|
||||
for doc in self.env.all_docs:
|
||||
yield (doc, clean_astext(self.env.titles[doc]), 'doc', doc, '', -1)
|
||||
for (prog, option), info in iteritems(self.data['progoptions']):
|
||||
for (prog, option), info in self.data['progoptions'].items():
|
||||
if prog:
|
||||
fullname = ".".join([prog, option])
|
||||
yield (fullname, fullname, 'cmdoption', info[0], info[1], 1)
|
||||
else:
|
||||
yield (option, option, 'cmdoption', info[0], info[1], 1)
|
||||
for (type, name), info in iteritems(self.data['objects']):
|
||||
for (type, name), info in self.data['objects'].items():
|
||||
yield (name, name, type, info[0], info[1],
|
||||
self.object_types[type].attrs['searchprio'])
|
||||
for name, info in iteritems(self.data['labels']):
|
||||
for name, info in self.data['labels'].items():
|
||||
yield (name, info[2], 'label', info[0], info[1], -1)
|
||||
# add anonymous-only labels as well
|
||||
non_anon_labels = set(self.data['labels'])
|
||||
for name, info in iteritems(self.data['anonlabels']):
|
||||
for name, info in self.data['anonlabels'].items():
|
||||
if name not in non_anon_labels:
|
||||
yield (name, name, 'label', info[0], info[1], -1)
|
||||
|
||||
|
@ -13,7 +13,7 @@ import re
|
||||
import unicodedata
|
||||
from itertools import groupby
|
||||
|
||||
from six import text_type, iteritems
|
||||
from six import text_type
|
||||
|
||||
from sphinx.locale import _, __
|
||||
from sphinx.util import split_into, logging
|
||||
@ -60,7 +60,7 @@ class IndexEntries(object):
|
||||
# maintain links in sorted/deterministic order
|
||||
bisect.insort(entry[0], (main, uri))
|
||||
|
||||
for fn, entries in iteritems(self.env.indexentries):
|
||||
for fn, entries in self.env.indexentries.items():
|
||||
# new entry types must be listed in directives/other.py!
|
||||
for type, value, tid, main, index_key in entries:
|
||||
try:
|
||||
@ -146,7 +146,7 @@ class IndexEntries(object):
|
||||
# type: (Tuple[unicode, List]) -> unicode
|
||||
# hack: mutating the subitems dicts to a list in the keyfunc
|
||||
k, v = item
|
||||
v[1] = sorted((si, se) for (si, (se, void, void)) in iteritems(v[1]))
|
||||
v[1] = sorted((si, se) for (si, (se, void, void)) in v[1].items())
|
||||
if v[2] is None:
|
||||
# now calculate the key
|
||||
if k.startswith(u'\N{RIGHT-TO-LEFT MARK}'):
|
||||
|
@ -10,7 +10,6 @@
|
||||
"""
|
||||
|
||||
from docutils import nodes
|
||||
from six import iteritems
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.locale import __
|
||||
@ -261,7 +260,7 @@ class TocTree(object):
|
||||
def get_toctree_ancestors(self, docname):
|
||||
# type: (unicode) -> List[unicode]
|
||||
parent = {}
|
||||
for p, children in iteritems(self.env.toctree_includes):
|
||||
for p, children in self.env.toctree_includes.items():
|
||||
for child in children:
|
||||
parent[child] = p
|
||||
ancestors = [] # type: List[unicode]
|
||||
|
@ -15,7 +15,7 @@ from os import path
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.utils import relative_path
|
||||
from six import iteritems, itervalues
|
||||
from six import itervalues
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.environment.collectors import EnvironmentCollector
|
||||
@ -108,7 +108,7 @@ class ImageCollector(EnvironmentCollector):
|
||||
except (OSError, IOError) as err:
|
||||
logger.warning(__('image file %s not readable: %s') % (filename, err),
|
||||
location=node, type='image', subtype='not_readable')
|
||||
for key, files in iteritems(globbed):
|
||||
for key, files in globbed.items():
|
||||
candidates[key] = sorted(files, key=len)[0] # select by similarity
|
||||
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
"""
|
||||
|
||||
from docutils import nodes
|
||||
from six import iteritems
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.environment.adapters.toctree import TocTree
|
||||
@ -295,7 +294,7 @@ class TocTreeCollector(EnvironmentCollector):
|
||||
|
||||
if env.config.numfig:
|
||||
_walk_doc(env.config.master_doc, tuple()) # type: ignore
|
||||
for docname, fignums in iteritems(env.toc_fignumbers):
|
||||
for docname, fignums in env.toc_fignumbers.items():
|
||||
if fignums != old_fignumbers.get(docname):
|
||||
rewrite_needed.append(docname)
|
||||
|
||||
|
@ -17,7 +17,7 @@ import sys
|
||||
from typing import Any
|
||||
|
||||
from docutils.statemachine import ViewList
|
||||
from six import iteritems, itervalues, text_type, class_types, string_types
|
||||
from six import itervalues, text_type, class_types, string_types
|
||||
|
||||
import sphinx
|
||||
from sphinx.ext.autodoc.importer import mock, import_object, get_object_members
|
||||
@ -1429,7 +1429,7 @@ def get_documenters(app):
|
||||
def autodoc_attrgetter(app, obj, name, *defargs):
|
||||
# type: (Sphinx, Any, unicode, Any) -> Any
|
||||
"""Alternative getattr() for types"""
|
||||
for typ, func in iteritems(app.registry.autodoc_attrgettrs):
|
||||
for typ, func in app.registry.autodoc_attrgettrs.items():
|
||||
if isinstance(obj, typ):
|
||||
return func(obj, name, *defargs)
|
||||
|
||||
|
@ -15,7 +15,6 @@ import inspect
|
||||
import re
|
||||
from os import path
|
||||
|
||||
from six import iteritems
|
||||
from six.moves import cPickle as pickle
|
||||
|
||||
import sphinx
|
||||
@ -73,7 +72,7 @@ class CoverageBuilder(Builder):
|
||||
logger.warning(__('invalid regex %r in coverage_c_regexes'), exp)
|
||||
|
||||
self.c_ignorexps = {} # type: Dict[unicode, List[Pattern]]
|
||||
for (name, exps) in iteritems(self.config.coverage_ignore_c_items):
|
||||
for (name, exps) in self.config.coverage_ignore_c_items.items():
|
||||
self.c_ignorexps[name] = compile_regex_list('coverage_ignore_c_items',
|
||||
exps)
|
||||
self.mod_ignorexps = compile_regex_list('coverage_ignore_modules',
|
||||
@ -127,7 +126,7 @@ class CoverageBuilder(Builder):
|
||||
write_header(op, 'Undocumented C API elements', '=')
|
||||
op.write('\n')
|
||||
|
||||
for filename, undoc in iteritems(self.c_undoc):
|
||||
for filename, undoc in self.c_undoc.items():
|
||||
write_header(op, filename)
|
||||
for typ, name in sorted(undoc):
|
||||
op.write(' * %-50s [%9s]\n' % (name, typ))
|
||||
@ -247,7 +246,7 @@ class CoverageBuilder(Builder):
|
||||
if undoc['classes']:
|
||||
op.write('Classes:\n')
|
||||
for name, methods in sorted(
|
||||
iteritems(undoc['classes'])):
|
||||
undoc['classes'].items()):
|
||||
if not methods:
|
||||
op.write(' * %s\n' % name)
|
||||
else:
|
||||
|
@ -25,7 +25,6 @@
|
||||
"""
|
||||
|
||||
from docutils import nodes, utils
|
||||
from six import iteritems
|
||||
|
||||
import sphinx
|
||||
from sphinx.util.nodes import split_explicit_title
|
||||
@ -64,7 +63,7 @@ def make_link_role(base_url, prefix):
|
||||
|
||||
def setup_link_roles(app):
|
||||
# type: (Sphinx) -> None
|
||||
for name, (base_url, prefix) in iteritems(app.config.extlinks):
|
||||
for name, (base_url, prefix) in app.config.extlinks.items():
|
||||
app.add_role(name, make_link_role(base_url, prefix))
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@ from os import path
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.utils import relative_path
|
||||
from six import PY3, iteritems, string_types
|
||||
from six import PY3, string_types
|
||||
from six.moves.urllib.parse import urlsplit, urlunsplit
|
||||
|
||||
import sphinx
|
||||
@ -212,7 +212,7 @@ def load_mappings(app):
|
||||
cache_time = now - app.config.intersphinx_cache_limit * 86400
|
||||
inventories = InventoryAdapter(app.builder.env)
|
||||
update = False
|
||||
for key, value in iteritems(app.config.intersphinx_mapping):
|
||||
for key, value in app.config.intersphinx_mapping.items():
|
||||
name = None # type: unicode
|
||||
uri = None # type: unicode
|
||||
inv = None # type: Union[unicode, Tuple[unicode, ...]]
|
||||
@ -284,7 +284,7 @@ def load_mappings(app):
|
||||
for name, _x, invdata in named_vals + unnamed_vals:
|
||||
if name:
|
||||
inventories.named_inventory[name] = invdata
|
||||
for type, objects in iteritems(invdata):
|
||||
for type, objects in invdata.items():
|
||||
inventories.main_inventory.setdefault(type, {}).update(objects)
|
||||
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
from six import PY2, iteritems
|
||||
from six import PY2
|
||||
|
||||
import sphinx
|
||||
from sphinx.application import Sphinx
|
||||
@ -274,9 +274,9 @@ class Config(object):
|
||||
|
||||
def __init__(self, **settings):
|
||||
# type: (Any) -> None
|
||||
for name, (default, rebuild) in iteritems(self._config_values):
|
||||
for name, (default, rebuild) in self._config_values.items():
|
||||
setattr(self, name, default)
|
||||
for name, value in iteritems(settings):
|
||||
for name, value in settings.items():
|
||||
setattr(self, name, value)
|
||||
|
||||
|
||||
@ -312,7 +312,7 @@ def setup(app):
|
||||
app.connect('autodoc-process-docstring', _process_docstring)
|
||||
app.connect('autodoc-skip-member', _skip_member)
|
||||
|
||||
for name, (default, rebuild) in iteritems(Config._config_values):
|
||||
for name, (default, rebuild) in Config._config_values.items():
|
||||
app.add_config_value(name, default, rebuild)
|
||||
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import traceback
|
||||
import warnings
|
||||
|
||||
from docutils import nodes
|
||||
from six import iteritems, text_type
|
||||
from six import text_type
|
||||
|
||||
import sphinx
|
||||
from sphinx import addnodes
|
||||
@ -163,7 +163,7 @@ def collect_pages(app):
|
||||
# len(env._viewcode_modules), nonl=1)
|
||||
|
||||
for modname, entry in status_iterator(
|
||||
sorted(iteritems(env._viewcode_modules)), # type: ignore
|
||||
sorted(env._viewcode_modules.items()), # type: ignore
|
||||
'highlighting module code... ', "blue",
|
||||
len(env._viewcode_modules), # type: ignore
|
||||
app.verbosity, lambda x: x[0]):
|
||||
@ -188,7 +188,7 @@ def collect_pages(app):
|
||||
# the collected tags (HACK: this only works if the tag boundaries are
|
||||
# properly nested!)
|
||||
maxindex = len(lines) - 1
|
||||
for name, docname in iteritems(used):
|
||||
for name, docname in used.items():
|
||||
type, start, end = tags[name]
|
||||
backlink = urito(pagename, docname) + '#' + refname + '.' + name
|
||||
lines[start] = (
|
||||
|
@ -9,8 +9,6 @@
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
from six import iteritems
|
||||
|
||||
from sphinx.errors import VersionRequirementError
|
||||
from sphinx.locale import __
|
||||
from sphinx.util import logging
|
||||
@ -49,7 +47,7 @@ def verify_needs_extensions(app, config):
|
||||
if config.needs_extensions is None:
|
||||
return
|
||||
|
||||
for extname, reqversion in iteritems(config.needs_extensions):
|
||||
for extname, reqversion in config.needs_extensions.items():
|
||||
extension = app.extensions.get(extname)
|
||||
if extension is None:
|
||||
logger.warning(__('The %s extension is required by needs_extensions settings, '
|
||||
|
@ -18,7 +18,7 @@ from docutils.parsers.rst import Parser as RSTParser
|
||||
from docutils.readers import standalone
|
||||
from docutils.statemachine import StringList, string2lines
|
||||
from docutils.writers import UnfilteredWriter
|
||||
from six import text_type, iteritems
|
||||
from six import text_type
|
||||
from typing import Any, Union # NOQA
|
||||
|
||||
from sphinx.deprecation import RemovedInSphinx30Warning
|
||||
@ -282,7 +282,7 @@ class FiletypeNotFoundError(Exception):
|
||||
|
||||
def get_filetype(source_suffix, filename):
|
||||
# type: (Dict[unicode, unicode], unicode) -> unicode
|
||||
for suffix, filetype in iteritems(source_suffix):
|
||||
for suffix, filetype in source_suffix.items():
|
||||
if filename.endswith(suffix):
|
||||
# If default filetype (None), considered as restructuredtext.
|
||||
return filetype or 'restructuredtext'
|
||||
|
@ -13,7 +13,7 @@ from __future__ import print_function
|
||||
import re
|
||||
from zipfile import ZipFile
|
||||
|
||||
from six import iteritems, BytesIO, StringIO
|
||||
from six import BytesIO, StringIO
|
||||
|
||||
from sphinx.errors import PycodeError
|
||||
from sphinx.pycode.parser import Parser
|
||||
@ -111,7 +111,7 @@ class ModuleAnalyzer(object):
|
||||
parser.parse()
|
||||
|
||||
self.attr_docs = {}
|
||||
for (scope, comment) in iteritems(parser.comments):
|
||||
for (scope, comment) in parser.comments.items():
|
||||
if comment:
|
||||
self.attr_docs[scope] = comment.splitlines() + ['']
|
||||
else:
|
||||
|
@ -17,7 +17,7 @@ from types import MethodType
|
||||
|
||||
from docutils.parsers.rst import Directive
|
||||
from pkg_resources import iter_entry_points
|
||||
from six import iteritems, itervalues
|
||||
from six import itervalues
|
||||
|
||||
from sphinx.deprecation import RemovedInSphinx30Warning
|
||||
from sphinx.domains import ObjType
|
||||
@ -177,7 +177,7 @@ class SphinxComponentRegistry(object):
|
||||
domain.directives.update(self.domain_directives.get(domain.name, {}))
|
||||
domain.roles.update(self.domain_roles.get(domain.name, {}))
|
||||
domain.indices.extend(self.domain_indices.get(domain.name, []))
|
||||
for name, objtype in iteritems(self.domain_object_types.get(domain.name, {})):
|
||||
for name, objtype in self.domain_object_types.get(domain.name, {}).items():
|
||||
domain.add_object_type(name, objtype)
|
||||
|
||||
yield domain
|
||||
@ -365,7 +365,7 @@ class SphinxComponentRegistry(object):
|
||||
def add_translation_handlers(self, node, **kwargs):
|
||||
# type: (nodes.Node, Any) -> None
|
||||
logger.debug('[app] adding translation_handlers: %r, %r', node, kwargs)
|
||||
for builder_name, handlers in iteritems(kwargs):
|
||||
for builder_name, handlers in kwargs.items():
|
||||
translation_handlers = self.translation_handlers.setdefault(builder_name, {})
|
||||
try:
|
||||
visit, depart = handlers # unpack once for assertion
|
||||
@ -391,7 +391,7 @@ class SphinxComponentRegistry(object):
|
||||
# retry with builder.format
|
||||
handlers = self.translation_handlers.get(builder.format, {})
|
||||
|
||||
for name, (visit, depart) in iteritems(handlers):
|
||||
for name, (visit, depart) in handlers.items():
|
||||
setattr(translator, 'visit_' + name, MethodType(visit, translator))
|
||||
if depart:
|
||||
setattr(translator, 'depart_' + name, MethodType(depart, translator))
|
||||
@ -512,7 +512,7 @@ class SphinxComponentRegistry(object):
|
||||
def merge_source_suffix(app, config):
|
||||
# type: (Sphinx, Config) -> None
|
||||
"""Merge source_suffix which specified by user and added by extensions."""
|
||||
for suffix, filetype in iteritems(app.registry.source_suffix):
|
||||
for suffix, filetype in app.registry.source_suffix.items():
|
||||
if suffix not in app.config.source_suffix:
|
||||
app.config.source_suffix[suffix] = filetype
|
||||
elif app.config.source_suffix[suffix] is None:
|
||||
|
@ -12,7 +12,6 @@
|
||||
import re
|
||||
|
||||
from docutils import nodes, utils
|
||||
from six import iteritems
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.errors import SphinxError
|
||||
@ -403,12 +402,12 @@ def setup(app):
|
||||
# type: (Sphinx) -> Dict[unicode, Any]
|
||||
from docutils.parsers.rst import roles
|
||||
|
||||
for rolename, nodeclass in iteritems(generic_docroles):
|
||||
for rolename, nodeclass in generic_docroles.items():
|
||||
generic = roles.GenericRole(rolename, nodeclass)
|
||||
role = roles.CustomRole(rolename, generic, {'classes': [rolename]})
|
||||
roles.register_local_role(rolename, role)
|
||||
|
||||
for rolename, func in iteritems(specific_docroles):
|
||||
for rolename, func in specific_docroles.items():
|
||||
roles.register_local_role(rolename, func)
|
||||
|
||||
return {
|
||||
|
@ -11,7 +11,7 @@
|
||||
import re
|
||||
from os import path
|
||||
|
||||
from six import iteritems, itervalues, text_type, string_types
|
||||
from six import itervalues, text_type, string_types
|
||||
from six.moves import cPickle as pickle
|
||||
|
||||
from docutils.nodes import raw, comment, title, Text, NodeVisitor, SkipNode
|
||||
@ -305,7 +305,7 @@ class IndexBuilder(object):
|
||||
def load_terms(mapping):
|
||||
# type: (Dict[unicode, Any]) -> Dict[unicode, Set[unicode]]
|
||||
rv = {}
|
||||
for k, v in iteritems(mapping):
|
||||
for k, v in mapping.items():
|
||||
if isinstance(v, int):
|
||||
rv[k] = set([index2fn[v]])
|
||||
else:
|
||||
@ -328,7 +328,7 @@ class IndexBuilder(object):
|
||||
rv = {} # type: Dict[unicode, Dict[unicode, Tuple[int, int, int, unicode]]]
|
||||
otypes = self._objtypes
|
||||
onames = self._objnames
|
||||
for domainname, domain in sorted(iteritems(self.env.domains)):
|
||||
for domainname, domain in sorted(self.env.domains.items()):
|
||||
for fullname, dispname, type, docname, anchor, prio in \
|
||||
sorted(domain.get_objects()):
|
||||
if docname not in fn2index:
|
||||
@ -364,7 +364,7 @@ class IndexBuilder(object):
|
||||
# type: (Dict) -> Tuple[Dict[unicode, List[unicode]], Dict[unicode, List[unicode]]]
|
||||
rvs = {}, {} # type: Tuple[Dict[unicode, List[unicode]], Dict[unicode, List[unicode]]]
|
||||
for rv, mapping in zip(rvs, (self._mapping, self._title_mapping)):
|
||||
for k, v in iteritems(mapping):
|
||||
for k, v in mapping.items():
|
||||
if len(v) == 1:
|
||||
fn, = v
|
||||
if fn in fn2index:
|
||||
@ -383,7 +383,7 @@ class IndexBuilder(object):
|
||||
|
||||
objects = self.get_objects(fn2index) # populates _objtypes
|
||||
objtypes = dict((v, k[0] + ':' + k[1])
|
||||
for (k, v) in iteritems(self._objtypes))
|
||||
for (k, v) in self._objtypes.items())
|
||||
objnames = self._objnames
|
||||
return dict(docnames=docnames, filenames=filenames, titles=titles, terms=terms,
|
||||
objects=objects, objtypes=objtypes, objnames=objnames,
|
||||
|
@ -22,7 +22,7 @@ import re
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
from six import iteritems, PY3
|
||||
from six import PY3
|
||||
|
||||
try:
|
||||
import MeCab
|
||||
@ -162,14 +162,14 @@ class JanomeSplitter(BaseSplitter):
|
||||
|
||||
|
||||
class DefaultSplitter(BaseSplitter):
|
||||
patterns_ = dict([(re.compile(pattern), value) for pattern, value in iteritems({
|
||||
patterns_ = dict([(re.compile(pattern), value) for pattern, value in {
|
||||
u'[一二三四五六七八九十百千万億兆]': u'M',
|
||||
u'[一-龠々〆ヵヶ]': u'H',
|
||||
u'[ぁ-ん]': u'I',
|
||||
u'[ァ-ヴーア-ン゙ー]': u'K',
|
||||
u'[a-zA-Za-zA-Z]': u'A',
|
||||
u'[0-90-9]': u'N',
|
||||
})])
|
||||
}.items()])
|
||||
BIAS__ = -332
|
||||
BC1__ = {u'HH': 6, u'II': 2461, u'KH': 406, u'OH': -1378}
|
||||
BC2__ = {u'AA': -3267, u'AI': 2744, u'AN': -878, u'HH': -4070, u'HM': -1711,
|
||||
@ -434,7 +434,7 @@ class DefaultSplitter(BaseSplitter):
|
||||
# ctype_
|
||||
def ctype_(self, char):
|
||||
# type: (unicode) -> unicode
|
||||
for pattern, value in iteritems(self.patterns_):
|
||||
for pattern, value in self.patterns_.items():
|
||||
if pattern.match(char):
|
||||
return value
|
||||
return u'O'
|
||||
|
@ -16,7 +16,6 @@ from os import path
|
||||
from zipfile import ZipFile
|
||||
|
||||
import pkg_resources
|
||||
from six import iteritems
|
||||
from six.moves import configparser
|
||||
|
||||
from sphinx import package_dir
|
||||
@ -129,7 +128,7 @@ class Theme(object):
|
||||
except configparser.NoSectionError:
|
||||
pass
|
||||
|
||||
for option, value in iteritems(overrides):
|
||||
for option, value in overrides.items():
|
||||
if option not in options:
|
||||
logger.warning(__('unsupported theme option %r given') % option)
|
||||
else:
|
||||
@ -174,7 +173,7 @@ class HTMLThemeFactory(object):
|
||||
# type: () -> None
|
||||
"""Load built-in themes."""
|
||||
themes = self.find_themes(path.join(package_dir, 'themes'))
|
||||
for name, theme in iteritems(themes):
|
||||
for name, theme in themes.items():
|
||||
self.themes[name] = theme
|
||||
|
||||
def load_additional_themes(self, theme_paths):
|
||||
@ -183,7 +182,7 @@ class HTMLThemeFactory(object):
|
||||
for theme_path in theme_paths:
|
||||
abs_theme_path = path.abspath(path.join(self.app.confdir, theme_path))
|
||||
themes = self.find_themes(abs_theme_path)
|
||||
for name, theme in iteritems(themes):
|
||||
for name, theme in themes.items():
|
||||
self.themes[name] = theme
|
||||
|
||||
def load_extra_theme(self, name):
|
||||
|
@ -15,7 +15,7 @@ import sys
|
||||
import warnings
|
||||
|
||||
from docutils.utils import get_source_line
|
||||
from six import string_types, iteritems
|
||||
from six import string_types
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.deprecation import RemovedInSphinx30Warning, RemovedInSphinx40Warning
|
||||
@ -35,7 +35,7 @@ def deprecate_source_parsers(app, config):
|
||||
warnings.warn('The config variable "source_parsers" is deprecated. '
|
||||
'Please use app.add_source_parser() API instead.',
|
||||
RemovedInSphinx30Warning)
|
||||
for suffix, parser in iteritems(config.source_parsers):
|
||||
for suffix, parser in config.source_parsers.items():
|
||||
if isinstance(parser, string_types):
|
||||
parser = import_object(parser, 'source parser') # type: ignore
|
||||
app.add_source_parser(suffix, parser)
|
||||
|
@ -17,7 +17,7 @@ from os import path
|
||||
from typing import NamedTuple
|
||||
|
||||
import imagesize
|
||||
from six import PY3, BytesIO, iteritems
|
||||
from six import PY3, BytesIO
|
||||
|
||||
try:
|
||||
from PIL import Image # check for the Python Imaging Library
|
||||
@ -93,7 +93,7 @@ def guess_mimetype(filename='', content=None, default=None):
|
||||
|
||||
def get_image_extension(mimetype):
|
||||
# type: (unicode) -> unicode
|
||||
for ext, _mimetype in iteritems(mime_suffixes):
|
||||
for ext, _mimetype in mime_suffixes.items():
|
||||
if mimetype == _mimetype:
|
||||
return ext
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
import re
|
||||
|
||||
from six import iteritems, integer_types, string_types
|
||||
from six import integer_types, string_types
|
||||
|
||||
from sphinx.util.pycompat import u
|
||||
|
||||
@ -102,7 +102,7 @@ def dumps(obj, key=False):
|
||||
return '{%s}' % ','.join(sorted('%s:%s' % (
|
||||
dumps(key, True),
|
||||
dumps(value)
|
||||
) for key, value in iteritems(obj)))
|
||||
) for key, value in obj.items()))
|
||||
elif isinstance(obj, set):
|
||||
return '[%s]' % ','.join(sorted(dumps(x) for x in obj))
|
||||
elif isinstance(obj, (tuple, list)):
|
||||
|
@ -15,8 +15,6 @@ import time
|
||||
import traceback
|
||||
from math import sqrt
|
||||
|
||||
from six import iteritems
|
||||
|
||||
try:
|
||||
import multiprocessing
|
||||
except ImportError:
|
||||
@ -115,7 +113,7 @@ class ParallelTasks(object):
|
||||
|
||||
def _join_one(self):
|
||||
# type: () -> None
|
||||
for tid, pipe in iteritems(self._precvs):
|
||||
for tid, pipe in self._precvs.items():
|
||||
if pipe.poll():
|
||||
exc, logs, result = pipe.recv()
|
||||
if exc:
|
||||
|
@ -14,7 +14,6 @@ from itertools import product
|
||||
from operator import itemgetter
|
||||
from uuid import uuid4
|
||||
|
||||
from six import iteritems
|
||||
from six.moves import cPickle as pickle
|
||||
from six.moves import range, zip_longest
|
||||
|
||||
@ -102,7 +101,7 @@ def merge_doctrees(old, new, condition):
|
||||
# choose the old node with the best ratio for each new node and set the uid
|
||||
# as long as the ratio is under a certain value, in which case we consider
|
||||
# them not changed but different
|
||||
ratios = sorted(iteritems(ratios), key=itemgetter(1)) # type: ignore
|
||||
ratios = sorted(ratios.items(), key=itemgetter(1)) # type: ignore
|
||||
for (old_node, new_node), ratio in ratios:
|
||||
if new_node in seen:
|
||||
continue
|
||||
|
@ -10,7 +10,7 @@
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from six import iteritems, StringIO
|
||||
from six import StringIO
|
||||
|
||||
from sphinx.ext.autosummary import mangle_signature, import_by_name, extract_summary
|
||||
from sphinx.testing.util import etree_parse
|
||||
@ -140,7 +140,7 @@ def test_get_items_summary(make_app, app_params):
|
||||
'C.prop_attr2': 'This is a attribute docstring',
|
||||
'C.C2': 'This is a nested inner class docstring',
|
||||
}
|
||||
for key, expected in iteritems(expected_values):
|
||||
for key, expected in expected_values.items():
|
||||
assert autosummary_items[key][2] == expected, 'Summary for %s was %r -'\
|
||||
' expected %r' % (key, autosummary_items[key], expected)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user