From 7b9f03e383a848383e06068c13675f8cbb50ba22 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 8 Mar 2015 16:02:03 +0100 Subject: [PATCH] Fix flake8. --- sphinx/builders/applehelp.py | 36 +++++++++++++++++------------------- sphinx/builders/html.py | 4 ++-- sphinx/config.py | 3 +-- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/sphinx/builders/applehelp.py b/sphinx/builders/applehelp.py index 5f2f061f5..c98962633 100644 --- a/sphinx/builders/applehelp.py +++ b/sphinx/builders/applehelp.py @@ -10,16 +10,14 @@ """ from __future__ import print_function -import os import codecs -import errno import pipes from os import path from sphinx.builders.html import StandaloneHTMLBuilder from sphinx.util import copy_static_entry -from sphinx.util.osutil import copyfile, ensuredir, os_path +from sphinx.util.osutil import copyfile, ensuredir from sphinx.util.console import bold from sphinx.util.pycompat import htmlescape from sphinx.util.matching import compile_matchers @@ -38,7 +36,8 @@ except AttributeError: # False access page (used because helpd expects strict XHTML) access_page_template = '''\ - + %(title)s @@ -55,11 +54,11 @@ access_page_template = '''\ class AppleHelpIndexerFailed(SphinxError): category = 'Help indexer failed' - + class AppleHelpCodeSigningFailed(SphinxError): category = 'Code signing failed' - - + + class AppleHelpBuilder(StandaloneHTMLBuilder): """ Builder that outputs an Apple help book. Requires Mac OS X as it relies @@ -74,25 +73,25 @@ class AppleHelpBuilder(StandaloneHTMLBuilder): # don't add links add_permalinks = False - + # this is an embedded HTML format embedded = True # don't generate the search index or include the search page search = False - + def init(self): super(AppleHelpBuilder, self).init() # the output files for HTML help must be .html only self.out_suffix = '.html' if self.config.applehelp_bundle_id is None: - raise SphinxError('You must set applehelp_bundle_id before ' \ + raise SphinxError('You must set applehelp_bundle_id before ' 'building Apple Help output') self.bundle_path = path.join(self.outdir, - self.config.applehelp_bundle_name \ - + '.help') + self.config.applehelp_bundle_name + + '.help') self.outdir = path.join(self.bundle_path, 'Contents', 'Resources', @@ -103,22 +102,22 @@ class AppleHelpBuilder(StandaloneHTMLBuilder): self.finish_tasks.add_task(self.copy_localized_files) self.finish_tasks.add_task(self.build_helpbook) - + def copy_localized_files(self): source_dir = path.join(self.confdir, self.config.applehelp_locale + '.lproj') target_dir = self.outdir - + if path.isdir(source_dir): self.info(bold('copying localized files... '), nonl=True) - + ctx = self.globalcontext.copy() matchers = compile_matchers(self.config.exclude_patterns) copy_static_entry(source_dir, target_dir, self, ctx, exclude_matchers=matchers) self.info('done') - + def build_helpbook(self): contents_dir = path.join(self.bundle_path, 'Contents') resources_dir = path.join(contents_dir, 'Resources') @@ -130,7 +129,7 @@ class AppleHelpBuilder(StandaloneHTMLBuilder): # Construct the Info.plist file toc = self.config.master_doc + self.out_suffix - + info_plist = { 'CFBundleDevelopmentRegion': self.config.applehelp_dev_region, 'CFBundleIdentifier': self.config.applehelp_bundle_id, @@ -188,7 +187,7 @@ class AppleHelpBuilder(StandaloneHTMLBuilder): finally: f.close() self.info('done') - + # Generate the help index self.info(bold('generating help index... '), nonl=True) @@ -258,4 +257,3 @@ class AppleHelpBuilder(StandaloneHTMLBuilder): raise AppleHelpCodeSigningFailed(output) else: self.info('done') - diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 2880f58b2..e60eb3a0a 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -79,7 +79,7 @@ class StandaloneHTMLBuilder(Builder): add_permalinks = True embedded = False # for things like HTML help or Qt help: suppresses sidebar search = True # for things like HTML help and Apple help: suppress search - + # This is a class attribute because it is mutated by Sphinx.add_javascript. script_files = ['_static/jquery.js', '_static/underscore.js', '_static/doctools.js'] @@ -584,7 +584,7 @@ class StandaloneHTMLBuilder(Builder): 'translations.js')) ctx = self.globalcontext.copy() - + # add context items for search function used in searchtools.js_t if self.indexer is not None: ctx.update(self.indexer.context_for_searchtool()) diff --git a/sphinx/config.py b/sphinx/config.py index de77401f9..ec6680027 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -14,7 +14,6 @@ from os import path, environ import shlex from six import PY3, iteritems, string_types, binary_type, integer_types -from six.moves.urllib.parse import quote as urlquote from sphinx.errors import ConfigError from sphinx.locale import l_ @@ -161,7 +160,7 @@ class Config(object): applehelp_indexer_path = ('/usr/bin/hiutil', 'applehelp'), applehelp_codesign_path = ('/usr/bin/codesign', 'applehelp'), applehelp_disable_external_tools = (False, None), - + # Epub options epub_basename = (lambda self: make_filename(self.project), None), epub_theme = ('epub', 'html'),