Python docutils.languages.get_language() Examples
The following are 30
code examples of docutils.languages.get_language().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
docutils.languages
, or try the search function
.
Example #1
Source File: __init__.py From faces with GNU General Public License v2.0 | 6 votes |
def __init__(self, document, startnode=None): """ Initial setup for in-place document transforms. """ self.document = document """The document tree to transform.""" self.startnode = startnode """Node from which to begin the transform. For many transforms which apply to the document as a whole, `startnode` is not set (i.e. its value is `None`).""" self.language = languages.get_language( document.settings.language_code, document.reporter) """Language module local to this document."""
Example #2
Source File: languages.py From rst2pdf with MIT License | 6 votes |
def get_language_available(lang): """Docutils get_language() also returning the available language.""" module = get_language_silent(lang) docutils_lang = module.__name__.rsplit('.', 1)[-1] if docutils_lang == 'en' and docutils_lang != lang and '_' in lang: module = get_language_silent(lang.split('_', 1)[0]) docutils_lang = module.__name__.rsplit('.', 1)[-1] if docutils_lang != lang: warn = ( docutils_lang.split('_', 1)[0] == lang.split('_', 1)[0] and log.info or log.warning ) warn( "Language '%s' not supported by Docutils," " using '%s' instead." % (lang, docutils_lang) ) if docutils_lang == 'en' and lang.split('_', 1)[0] != 'en': lang = 'en_US' return lang, docutils_lang, module
Example #3
Source File: __init__.py From aws-builders-fair-projects with Apache License 2.0 | 6 votes |
def write(self, document, destination): """ Process a document into its final form. Translate `document` (a Docutils document tree) into the Writer's native format, and write it out to its `destination` (a `docutils.io.Output` subclass object). Normally not overridden or extended in subclasses. """ self.document = document self.language = languages.get_language( document.settings.language_code, document.reporter) self.destination = destination self.translate() output = self.destination.write(self.output) return output
Example #4
Source File: __init__.py From aws-builders-fair-projects with Apache License 2.0 | 6 votes |
def __init__(self, document, startnode=None): """ Initial setup for in-place document transforms. """ self.document = document """The document tree to transform.""" self.startnode = startnode """Node from which to begin the transform. For many transforms which apply to the document as a whole, `startnode` is not set (i.e. its value is `None`).""" self.language = languages.get_language( document.settings.language_code, document.reporter) """Language module local to this document."""
Example #5
Source File: __init__.py From aws-extender with MIT License | 6 votes |
def write(self, document, destination): """ Process a document into its final form. Translate `document` (a Docutils document tree) into the Writer's native format, and write it out to its `destination` (a `docutils.io.Output` subclass object). Normally not overridden or extended in subclasses. """ self.document = document self.language = languages.get_language( document.settings.language_code, document.reporter) self.destination = destination self.translate() output = self.destination.write(self.output) return output
Example #6
Source File: __init__.py From aws-extender with MIT License | 6 votes |
def __init__(self, document, startnode=None): """ Initial setup for in-place document transforms. """ self.document = document """The document tree to transform.""" self.startnode = startnode """Node from which to begin the transform. For many transforms which apply to the document as a whole, `startnode` is not set (i.e. its value is `None`).""" self.language = languages.get_language( document.settings.language_code, document.reporter) """Language module local to this document."""
Example #7
Source File: __init__.py From blackmamba with MIT License | 6 votes |
def write(self, document, destination): """ Process a document into its final form. Translate `document` (a Docutils document tree) into the Writer's native format, and write it out to its `destination` (a `docutils.io.Output` subclass object). Normally not overridden or extended in subclasses. """ self.document = document self.language = languages.get_language( document.settings.language_code, document.reporter) self.destination = destination self.translate() output = self.destination.write(self.output) return output
Example #8
Source File: __init__.py From blackmamba with MIT License | 6 votes |
def __init__(self, document, startnode=None): """ Initial setup for in-place document transforms. """ self.document = document """The document tree to transform.""" self.startnode = startnode """Node from which to begin the transform. For many transforms which apply to the document as a whole, `startnode` is not set (i.e. its value is `None`).""" self.language = languages.get_language( document.settings.language_code, document.reporter) """Language module local to this document."""
Example #9
Source File: __init__.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 6 votes |
def __init__(self, document, startnode=None): """ Initial setup for in-place document transforms. """ self.document = document """The document tree to transform.""" self.startnode = startnode """Node from which to begin the transform. For many transforms which apply to the document as a whole, `startnode` is not set (i.e. its value is `None`).""" self.language = languages.get_language( document.settings.language_code, document.reporter) """Language module local to this document."""
Example #10
Source File: __init__.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 6 votes |
def write(self, document, destination): """ Process a document into its final form. Translate `document` (a Docutils document tree) into the Writer's native format, and write it out to its `destination` (a `docutils.io.Output` subclass object). Normally not overridden or extended in subclasses. """ self.document = document self.language = languages.get_language( document.settings.language_code, document.reporter) self.destination = destination self.translate() output = self.destination.write(self.output) return output
Example #11
Source File: __init__.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 6 votes |
def __init__(self, document, startnode=None): """ Initial setup for in-place document transforms. """ self.document = document """The document tree to transform.""" self.startnode = startnode """Node from which to begin the transform. For many transforms which apply to the document as a whole, `startnode` is not set (i.e. its value is `None`).""" self.language = languages.get_language( document.settings.language_code, document.reporter) """Language module local to this document."""
Example #12
Source File: __init__.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
def write(self, document, destination): """ Process a document into its final form. Translate `document` (a Docutils document tree) into the Writer's native format, and write it out to its `destination` (a `docutils.io.Output` subclass object). Normally not overridden or extended in subclasses. """ self.document = document self.language = languages.get_language( document.settings.language_code, document.reporter) self.destination = destination self.translate() output = self.destination.write(self.output) return output
Example #13
Source File: __init__.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
def __init__(self, document, startnode=None): """ Initial setup for in-place document transforms. """ self.document = document """The document tree to transform.""" self.startnode = startnode """Node from which to begin the transform. For many transforms which apply to the document as a whole, `startnode` is not set (i.e. its value is `None`).""" self.language = languages.get_language( document.settings.language_code, document.reporter) """Language module local to this document."""
Example #14
Source File: __init__.py From bash-lambda-layer with MIT License | 6 votes |
def write(self, document, destination): """ Process a document into its final form. Translate `document` (a Docutils document tree) into the Writer's native format, and write it out to its `destination` (a `docutils.io.Output` subclass object). Normally not overridden or extended in subclasses. """ self.document = document self.language = languages.get_language( document.settings.language_code, document.reporter) self.destination = destination self.translate() output = self.destination.write(self.output) return output
Example #15
Source File: __init__.py From bash-lambda-layer with MIT License | 6 votes |
def __init__(self, document, startnode=None): """ Initial setup for in-place document transforms. """ self.document = document """The document tree to transform.""" self.startnode = startnode """Node from which to begin the transform. For many transforms which apply to the document as a whole, `startnode` is not set (i.e. its value is `None`).""" self.language = languages.get_language( document.settings.language_code, document.reporter) """Language module local to this document."""
Example #16
Source File: __init__.py From deepWordBug with Apache License 2.0 | 6 votes |
def __init__(self, document, startnode=None): """ Initial setup for in-place document transforms. """ self.document = document """The document tree to transform.""" self.startnode = startnode """Node from which to begin the transform. For many transforms which apply to the document as a whole, `startnode` is not set (i.e. its value is `None`).""" self.language = languages.get_language( document.settings.language_code, document.reporter) """Language module local to this document."""
Example #17
Source File: __init__.py From deepWordBug with Apache License 2.0 | 6 votes |
def write(self, document, destination): """ Process a document into its final form. Translate `document` (a Docutils document tree) into the Writer's native format, and write it out to its `destination` (a `docutils.io.Output` subclass object). Normally not overridden or extended in subclasses. """ self.document = document self.language = languages.get_language( document.settings.language_code, document.reporter) self.destination = destination self.translate() output = self.destination.write(self.output) return output
Example #18
Source File: __init__.py From faces with GNU General Public License v2.0 | 6 votes |
def __init__(self, document, startnode=None): """ Initial setup for in-place document transforms. """ self.document = document """The document tree to transform.""" self.startnode = startnode """Node from which to begin the transform. For many transforms which apply to the document as a whole, `startnode` is not set (i.e. its value is `None`).""" self.language = languages.get_language( document.settings.language_code, document.reporter) """Language module local to this document."""
Example #19
Source File: __init__.py From faces with GNU General Public License v2.0 | 6 votes |
def write(self, document, destination): """ Process a document into its final form. Translate `document` (a Docutils document tree) into the Writer's native format, and write it out to its `destination` (a `docutils.io.Output` subclass object). Normally not overridden or extended in subclasses. """ self.document = document self.language = languages.get_language( document.settings.language_code, document.reporter) self.destination = destination self.translate() output = self.destination.write(self.output) return output
Example #20
Source File: doctree2md.py From sphinx-markdown-builder with MIT License | 6 votes |
def __init__(self, document, builder=None): nodes.NodeVisitor.__init__(self, document) self.builder = builder self.settings = settings = document.settings lcode = settings.language_code self.language = languages.get_language(lcode, document.reporter) # Not-None here indicates Markdown should use HTTP for internal and # download links. self.markdown_http_base = ( builder.markdown_http_base if builder else None ) # Warn only once per writer about unsupported elements self._warned = set() # Lookup table to get section list from name self._lists = OrderedDict((('head', []), ('body', []), ('foot', []))) # Reset attributes modified by reading self.reset() # Attribute shortcuts self.head, self.body, self.foot = self._lists.values()
Example #21
Source File: peps.py From aws-extender with MIT License | 5 votes |
def apply(self): language = languages.get_language(self.document.settings.language_code, self.document.reporter) name = language.labels['contents'] title = nodes.title('', name) topic = nodes.topic('', title, classes=['contents']) name = nodes.fully_normalize_name(name) if not self.document.has_name(name): topic['names'].append(name) self.document.note_implicit_target(topic) pending = nodes.pending(parts.Contents) topic += pending self.document.insert(1, topic) self.document.note_pending(pending)
Example #22
Source File: __init__.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def get_language(self): # Obsolete, kept for backwards compatibility with Sphinx return self.language # Building blocks for the latex preamble # --------------------------------------
Example #23
Source File: languages.py From rst2pdf with MIT License | 5 votes |
def get_language_silent(lang): """Docutils get_language() with patches for older versions.""" try: return get_language(lang) except TypeError as err: # Docutils 0.8.1 if 'get_language() takes exactly 2 arguments' in str(err): class SilentReporter(object): def warning(self, msg): pass return get_language(lang, SilentReporter()) raise # re-raise any other TypeError except ImportError: # Docutils < 0.8 return get_language('en')
Example #24
Source File: peps.py From blackmamba with MIT License | 5 votes |
def apply(self): language = languages.get_language(self.document.settings.language_code, self.document.reporter) name = language.labels['contents'] title = nodes.title('', name) topic = nodes.topic('', title, classes=['contents']) name = nodes.fully_normalize_name(name) if not self.document.has_name(name): topic['names'].append(name) self.document.note_implicit_target(topic) pending = nodes.pending(parts.Contents) topic += pending self.document.insert(1, topic) self.document.note_pending(pending)
Example #25
Source File: writer_aux.py From blackmamba with MIT License | 5 votes |
def apply(self): language = languages.get_language(self.document.settings.language_code, self.document.reporter) for node in self.document.traverse(nodes.Admonition): node_name = node.__class__.__name__ # Set class, so that we know what node this admonition came from. node['classes'].append(node_name) if not isinstance(node, nodes.admonition): # Specific admonition. Transform into a generic admonition. admonition = nodes.admonition(node.rawsource, *node.children, **node.attributes) title = nodes.title('', language.labels[node_name]) admonition.insert(0, title) node.replace_self(admonition)
Example #26
Source File: parts.py From blackmamba with MIT License | 5 votes |
def run(self): if not (self.state_machine.match_titles or isinstance(self.state_machine.node, nodes.sidebar)): raise self.error('The "%s" directive may not be used within ' 'topics or body elements.' % self.name) document = self.state_machine.document language = languages.get_language(document.settings.language_code, document.reporter) if self.arguments: title_text = self.arguments[0] text_nodes, messages = self.state.inline_text(title_text, self.lineno) title = nodes.title(title_text, '', *text_nodes) else: messages = [] if 'local' in self.options: title = None else: title = nodes.title('', language.labels['contents']) topic = nodes.topic(classes=['contents']) topic['classes'] += self.options.get('class', []) # the latex2e writer needs source and line for a warning: topic.source, topic.line = self.state_machine.get_source_and_line() topic.line -= 1 if 'local' in self.options: topic['classes'].append('local') if title: name = title.astext() topic += title else: name = language.labels['contents'] name = nodes.fully_normalize_name(name) if not document.has_name(name): topic['names'].append(name) document.note_implicit_target(topic) pending = nodes.pending(parts.Contents, rawsource=self.block_text) pending.details.update(self.options) document.note_pending(pending) topic += pending return [topic] + messages
Example #27
Source File: __init__.py From faces with GNU General Public License v2.0 | 5 votes |
def get_language(self): # Obsolete, kept for backwards compatibility with Sphinx return self.language # Building blocks for the latex preamble # --------------------------------------
Example #28
Source File: __init__.py From blackmamba with MIT License | 5 votes |
def get_language(self): # Obsolete, kept for backwards compatibility with Sphinx return self.language # Building blocks for the latex preamble # --------------------------------------
Example #29
Source File: __init__.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
def get_language(self): # Obsolete, kept for backwards compatibility with Sphinx return self.language # Building blocks for the latex preamble # --------------------------------------
Example #30
Source File: peps.py From faces with GNU General Public License v2.0 | 5 votes |
def apply(self): language = languages.get_language(self.document.settings.language_code, self.document.reporter) name = language.labels['contents'] title = nodes.title('', name) topic = nodes.topic('', title, classes=['contents']) name = nodes.fully_normalize_name(name) if not self.document.has_name(name): topic['names'].append(name) self.document.note_implicit_target(topic) pending = nodes.pending(parts.Contents) topic += pending self.document.insert(1, topic) self.document.note_pending(pending)