mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#301: use errno values from errno module.
This commit is contained in:
parent
a3f11db6b7
commit
0dc0837e01
@ -16,7 +16,7 @@ from os import path
|
||||
from docutils import nodes
|
||||
|
||||
from sphinx import package_dir, locale
|
||||
from sphinx.util import SEP, relative_uri
|
||||
from sphinx.util import SEP, EEXIST, relative_uri
|
||||
from sphinx.environment import BuildEnvironment
|
||||
from sphinx.util.console import bold, purple, darkgreen, term_width_line
|
||||
|
||||
@ -210,7 +210,7 @@ class Builder(object):
|
||||
path.join(self.doctreedir, ENV_PICKLE_FILENAME))
|
||||
self.info('done')
|
||||
except Exception, err:
|
||||
if type(err) is IOError and err.errno == 2:
|
||||
if type(err) is IOError and err.errno == EEXIST:
|
||||
self.info('not found')
|
||||
else:
|
||||
self.info('failed: %s' % err)
|
||||
|
@ -22,7 +22,7 @@ except ImportError:
|
||||
from docutils import nodes
|
||||
|
||||
from sphinx.errors import SphinxError
|
||||
from sphinx.util import ensuredir
|
||||
from sphinx.util import ensuredir, ENOENT
|
||||
from sphinx.util.compat import Directive
|
||||
|
||||
|
||||
@ -111,7 +111,7 @@ def render_dot(self, code, options, format, prefix='graphviz'):
|
||||
try:
|
||||
p = Popen(dot_args, stdout=PIPE, stdin=PIPE, stderr=PIPE)
|
||||
except OSError, err:
|
||||
if err.errno != 2: # No such file or directory
|
||||
if err.errno != ENOENT: # No such file or directory
|
||||
raise
|
||||
self.builder.warn('dot command %r cannot be run (needed for graphviz '
|
||||
'output), check the graphviz_dot setting' %
|
||||
|
@ -23,7 +23,7 @@ except ImportError:
|
||||
from docutils import nodes
|
||||
|
||||
from sphinx.errors import SphinxError
|
||||
from sphinx.util import ensuredir
|
||||
from sphinx.util import ensuredir, ENOENT
|
||||
from sphinx.util.png import read_png_depth, write_png_depth
|
||||
from sphinx.ext.mathbase import setup_math as mathbase_setup, wrap_displaymath
|
||||
|
||||
@ -119,7 +119,7 @@ def render_math(self, math):
|
||||
try:
|
||||
p = Popen(ltx_args, stdout=PIPE, stderr=PIPE)
|
||||
except OSError, err:
|
||||
if err.errno != 2: # No such file or directory
|
||||
if err.errno != ENOENT: # No such file or directory
|
||||
raise
|
||||
self.builder.warn('LaTeX command %r cannot be run (needed for math '
|
||||
'display), check the pngmath_latex setting' %
|
||||
@ -147,7 +147,7 @@ def render_math(self, math):
|
||||
try:
|
||||
p = Popen(dvipng_args, stdout=PIPE, stderr=PIPE)
|
||||
except OSError, err:
|
||||
if err.errno != 2: # No such file or directory
|
||||
if err.errno != ENOENT: # No such file or directory
|
||||
raise
|
||||
self.builder.warn('dvipng command %r cannot be run (needed for math '
|
||||
'display), check the pngmath_dvipng setting' %
|
||||
|
@ -26,6 +26,9 @@ from os import path
|
||||
import docutils
|
||||
import sphinx
|
||||
|
||||
# Errnos that we need.
|
||||
EEXIST = getattr(errno, 'EEXIST', 0)
|
||||
ENOENT = getattr(errno, 'ENOENT', 0)
|
||||
|
||||
# Generally useful regular expressions.
|
||||
ws_re = re.compile(r'\s+')
|
||||
@ -69,7 +72,7 @@ def ensuredir(path):
|
||||
os.makedirs(path)
|
||||
except OSError, err:
|
||||
# 0 for Jython/Win32
|
||||
if err.errno not in [0, getattr(errno, 'EEXIST', 0)]:
|
||||
if err.errno not in [0, EEXIST]:
|
||||
raise
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user