PageRenderTime 83ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/itmi_vcfqc_optimized/pymodules/python2.7/lib/python/Sphinx-1.2.3-py2.7.egg/sphinx/config.py

https://gitlab.com/pooja043/Globus_Docker_4
Python | 284 lines | 259 code | 8 blank | 17 comment | 1 complexity | 4eebab159a44b83e34cc8f75de0b2b1c MD5 | raw file
  1. # -*- coding: utf-8 -*-
  2. """
  3. sphinx.config
  4. ~~~~~~~~~~~~~
  5. Build configuration file handling.
  6. :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
  7. :license: BSD, see LICENSE for details.
  8. """
  9. import os
  10. import re
  11. import sys
  12. from os import path
  13. from sphinx.errors import ConfigError
  14. from sphinx.locale import l_
  15. from sphinx.util.osutil import make_filename
  16. from sphinx.util.pycompat import bytes, b, execfile_
  17. nonascii_re = re.compile(b(r'[\x80-\xff]'))
  18. CONFIG_SYNTAX_ERROR = "There is a syntax error in your configuration file: %s"
  19. if sys.version_info >= (3, 0):
  20. CONFIG_SYNTAX_ERROR += "\nDid you change the syntax from 2.x to 3.x?"
  21. class Config(object):
  22. """
  23. Configuration file abstraction.
  24. """
  25. # the values are: (default, what needs to be rebuilt if changed)
  26. # If you add a value here, don't forget to include it in the
  27. # quickstart.py file template as well as in the docs!
  28. config_values = dict(
  29. # general options
  30. project = ('Python', 'env'),
  31. copyright = ('', 'html'),
  32. version = ('', 'env'),
  33. release = ('', 'env'),
  34. today = ('', 'env'),
  35. today_fmt = (None, 'env'), # the real default is locale-dependent
  36. language = (None, 'env'),
  37. locale_dirs = ([], 'env'),
  38. master_doc = ('contents', 'env'),
  39. source_suffix = ('.rst', 'env'),
  40. source_encoding = ('utf-8-sig', 'env'),
  41. exclude_patterns = ([], 'env'),
  42. # the next three are all deprecated now
  43. unused_docs = ([], 'env'),
  44. exclude_trees = ([], 'env'),
  45. exclude_dirnames = ([], 'env'),
  46. default_role = (None, 'env'),
  47. add_function_parentheses = (True, 'env'),
  48. add_module_names = (True, 'env'),
  49. trim_footnote_reference_space = (False, 'env'),
  50. show_authors = (False, 'env'),
  51. pygments_style = (None, 'html'),
  52. highlight_language = ('python', 'env'),
  53. templates_path = ([], 'html'),
  54. template_bridge = (None, 'html'),
  55. keep_warnings = (False, 'env'),
  56. modindex_common_prefix = ([], 'html'),
  57. rst_epilog = (None, 'env'),
  58. rst_prolog = (None, 'env'),
  59. trim_doctest_flags = (True, 'env'),
  60. primary_domain = ('py', 'env'),
  61. needs_sphinx = (None, None),
  62. nitpicky = (False, 'env'),
  63. nitpick_ignore = ([], 'html'),
  64. # HTML options
  65. html_theme = ('default', 'html'),
  66. html_theme_path = ([], 'html'),
  67. html_theme_options = ({}, 'html'),
  68. html_title = (lambda self: l_('%s %s documentation') %
  69. (self.project, self.release),
  70. 'html'),
  71. html_short_title = (lambda self: self.html_title, 'html'),
  72. html_style = (None, 'html'),
  73. html_logo = (None, 'html'),
  74. html_favicon = (None, 'html'),
  75. html_static_path = ([], 'html'),
  76. html_extra_path = ([], 'html'),
  77. # the real default is locale-dependent
  78. html_last_updated_fmt = (None, 'html'),
  79. html_use_smartypants = (True, 'html'),
  80. html_translator_class = (None, 'html'),
  81. html_sidebars = ({}, 'html'),
  82. html_additional_pages = ({}, 'html'),
  83. html_use_modindex = (True, 'html'), # deprecated
  84. html_domain_indices = (True, 'html'),
  85. html_add_permalinks = (u'\u00B6', 'html'),
  86. html_use_index = (True, 'html'),
  87. html_split_index = (False, 'html'),
  88. html_copy_source = (True, 'html'),
  89. html_show_sourcelink = (True, 'html'),
  90. html_use_opensearch = ('', 'html'),
  91. html_file_suffix = (None, 'html'),
  92. html_link_suffix = (None, 'html'),
  93. html_show_copyright = (True, 'html'),
  94. html_show_sphinx = (True, 'html'),
  95. html_context = ({}, 'html'),
  96. html_output_encoding = ('utf-8', 'html'),
  97. html_compact_lists = (True, 'html'),
  98. html_secnumber_suffix = ('. ', 'html'),
  99. html_search_language = (None, 'html'),
  100. html_search_options = ({}, 'html'),
  101. html_search_scorer = ('', None),
  102. # HTML help only options
  103. htmlhelp_basename = (lambda self: make_filename(self.project), None),
  104. # Qt help only options
  105. qthelp_basename = (lambda self: make_filename(self.project), None),
  106. # Devhelp only options
  107. devhelp_basename = (lambda self: make_filename(self.project), None),
  108. # Epub options
  109. epub_basename = (lambda self: make_filename(self.project), None),
  110. epub_theme = ('epub', 'html'),
  111. epub_theme_options = ({}, 'html'),
  112. epub_title = (lambda self: self.html_title, 'html'),
  113. epub_author = ('unknown', 'html'),
  114. epub_language = (lambda self: self.language or 'en', 'html'),
  115. epub_publisher = ('unknown', 'html'),
  116. epub_copyright = (lambda self: self.copyright, 'html'),
  117. epub_identifier = ('unknown', 'html'),
  118. epub_scheme = ('unknown', 'html'),
  119. epub_uid = ('unknown', 'env'),
  120. epub_cover = ((), 'env'),
  121. epub_guide = ((), 'env'),
  122. epub_pre_files = ([], 'env'),
  123. epub_post_files = ([], 'env'),
  124. epub_exclude_files = ([], 'env'),
  125. epub_tocdepth = (3, 'env'),
  126. epub_tocdup = (True, 'env'),
  127. epub_tocscope = ('default', 'env'),
  128. epub_fix_images = (False, 'env'),
  129. epub_max_image_width = (0, 'env'),
  130. epub_show_urls = ('inline', 'html'),
  131. epub_use_index = (lambda self: self.html_use_index, 'html'),
  132. # LaTeX options
  133. latex_documents = (lambda self: [(self.master_doc,
  134. make_filename(self.project) + '.tex',
  135. self.project,
  136. '', 'manual')],
  137. None),
  138. latex_logo = (None, None),
  139. latex_appendices = ([], None),
  140. latex_use_parts = (False, None),
  141. latex_use_modindex = (True, None), # deprecated
  142. latex_domain_indices = (True, None),
  143. latex_show_urls = ('no', None),
  144. latex_show_pagerefs = (False, None),
  145. # paper_size and font_size are still separate values
  146. # so that you can give them easily on the command line
  147. latex_paper_size = ('letter', None),
  148. latex_font_size = ('10pt', None),
  149. latex_elements = ({}, None),
  150. latex_additional_files = ([], None),
  151. latex_docclass = ({}, None),
  152. # now deprecated - use latex_elements
  153. latex_preamble = ('', None),
  154. # text options
  155. text_sectionchars = ('*=-~"+`', 'env'),
  156. text_newlines = ('unix', 'env'),
  157. # manpage options
  158. man_pages = (lambda self: [(self.master_doc,
  159. make_filename(self.project).lower(),
  160. '%s %s' % (self.project, self.release),
  161. [], 1)],
  162. None),
  163. man_show_urls = (False, None),
  164. # Texinfo options
  165. texinfo_documents = (lambda self: [(self.master_doc,
  166. make_filename(self.project).lower(),
  167. self.project, '',
  168. make_filename(self.project),
  169. 'The %s reference manual.' %
  170. make_filename(self.project),
  171. 'Python')],
  172. None),
  173. texinfo_appendices = ([], None),
  174. texinfo_elements = ({}, None),
  175. texinfo_domain_indices = (True, None),
  176. texinfo_show_urls = ('footnote', None),
  177. texinfo_no_detailmenu = (False, None),
  178. # linkcheck options
  179. linkcheck_ignore = ([], None),
  180. linkcheck_timeout = (None, None),
  181. linkcheck_workers = (5, None),
  182. linkcheck_anchors = (True, None),
  183. # gettext options
  184. gettext_compact = (True, 'gettext'),
  185. # XML options
  186. xml_pretty = (True, 'env'),
  187. )
  188. def __init__(self, dirname, filename, overrides, tags):
  189. self.overrides = overrides
  190. self.values = Config.config_values.copy()
  191. config = {}
  192. if "extensions" in overrides:
  193. config["extensions"] = overrides["extensions"]
  194. if dirname is not None:
  195. config_file = path.join(dirname, filename)
  196. config['__file__'] = config_file
  197. config['tags'] = tags
  198. olddir = os.getcwd()
  199. try:
  200. # we promise to have the config dir as current dir while the
  201. # config file is executed
  202. os.chdir(dirname)
  203. try:
  204. execfile_(filename, config)
  205. except SyntaxError, err:
  206. raise ConfigError(CONFIG_SYNTAX_ERROR % err)
  207. finally:
  208. os.chdir(olddir)
  209. self._raw_config = config
  210. # these two must be preinitialized because extensions can add their
  211. # own config values
  212. self.setup = config.get('setup', None)
  213. self.extensions = config.get('extensions', [])
  214. def check_unicode(self, warn):
  215. # check all string values for non-ASCII characters in bytestrings,
  216. # since that can result in UnicodeErrors all over the place
  217. for name, value in self._raw_config.iteritems():
  218. if isinstance(value, bytes) and nonascii_re.search(value):
  219. warn('the config value %r is set to a string with non-ASCII '
  220. 'characters; this can lead to Unicode errors occurring. '
  221. 'Please use Unicode strings, e.g. %r.' % (name, u'Content')
  222. )
  223. def init_values(self):
  224. config = self._raw_config
  225. for valname, value in self.overrides.iteritems():
  226. if '.' in valname:
  227. realvalname, key = valname.split('.', 1)
  228. config.setdefault(realvalname, {})[key] = value
  229. else:
  230. config[valname] = value
  231. for name in config:
  232. if name in self.values:
  233. self.__dict__[name] = config[name]
  234. del self._raw_config
  235. def __getattr__(self, name):
  236. if name.startswith('_'):
  237. raise AttributeError(name)
  238. if name not in self.values:
  239. raise AttributeError('No such config value: %s' % name)
  240. default = self.values[name][0]
  241. if hasattr(default, '__call__'):
  242. return default(self)
  243. return default
  244. def __getitem__(self, name):
  245. return getattr(self, name)
  246. def __setitem__(self, name, value):
  247. setattr(self, name, value)
  248. def __delitem__(self, name):
  249. delattr(self, name)
  250. def __contains__(self, name):
  251. return name in self.values