extensions Package¶
extensions
Package¶
asciidoc
Module¶
asciidoc - converts an AsciiDoc text file to HTML or DocBook
Copyright (C) 2002-2010 Stuart Rackham. Free use of this software is granted under the terms of the GNU General Public License (GPL).
-
class
leo.extensions.asciidoc.
AbstractBlock
[source]¶ -
blocknames
= []¶
-
get_param
(name, params=None)[source]¶ Return named processing parameter from params dictionary. If the parameter is not in params look in self.parameters.
-
is_conf_entry
(param)[source]¶ Return True if param matches an allowed configuration file entry name.
-
merge_attributes
(attrs, params=[])[source]¶ Use the current block’s attribute list (attrs dictionary) to build a dictionary of block processing parameters (self.parameters) and tag substitution attributes (self.attributes).
1. Copy the default parameters (self.*) to self.parameters. self.parameters are used internally to render the current block. Optional params array of additional parameters.
2. Copy attrs to self.attributes. self.attributes are used for template and tag substitution in the current block.
3. If a style attribute was specified update self.parameters with the corresponding style parameters; if there are any style parameters remaining add them to self.attributes (existing attribute list entries take precedence).
4. Set named positional attributes in self.attributes if self.posattrs was specified.
5. Finally self.parameters is updated with any corresponding parameters specified in attrs.
-
pop_blockname
()[source]¶ On block exits restore previous (parent) ‘blockname’ attribute or undefine it if we’re no longer inside a block.
-
push_blockname
(blockname=None)[source]¶ On block entry set the ‘blockname’ attribute. Only applies to delimited blocks, lists and tables.
-
-
class
leo.extensions.asciidoc.
AbstractBlocks
[source]¶ List of block definitions.
-
BLOCK_TYPE
= None¶
-
PREFIX
= ''¶
-
-
class
leo.extensions.asciidoc.
AttrDict
[source]¶ Bases:
dict
Like a dictionary except values can be accessed as attributes i.e. obj.foo can be used in addition to obj[‘foo’]. If an item is not present None is returned.
-
class
leo.extensions.asciidoc.
AttributeEntry
[source]¶ Static methods and attributes only.
-
attributes
= {}¶
-
name
= None¶
-
name2
= None¶
-
pattern
= None¶
-
subs
= None¶
-
value
= None¶
-
-
class
leo.extensions.asciidoc.
AttributeList
[source]¶ Static methods and attributes only.
-
attrs
= {}¶
-
match
= None¶
-
pattern
= None¶
-
-
class
leo.extensions.asciidoc.
BlockTitle
[source]¶ Static methods and attributes only.
-
pattern
= None¶
-
title
= None¶
-
-
class
leo.extensions.asciidoc.
Column
(width=None, align_spec=None, style=None)[source]¶ Table column.
-
class
leo.extensions.asciidoc.
Config
[source]¶ Methods to process configuration files.
-
ENTRIES_SECTIONS
= ('tags', 'miscellaneous', 'attributes', 'specialcharacters', 'specialwords', 'macros', 'replacements', 'quotes', 'titles', 'paradef-.+', 'listdef-.+', 'blockdef-.+', 'tabledef-.+', 'tabletags-.+', 'listtags-.+', 'replacements[23]', 'old_tabledef-.+')¶
-
entries_section
(section_name)[source]¶ Return True if conf file section contains entries, not a markup template.
-
find_config_dir
(*dirnames)[source]¶ Return path of configuration directory. Try all the well known locations. Return None if directory not found.
-
find_in_dirs
(filename, dirs=None)[source]¶ Find conf files from dirs list. Return list of found file paths. Return empty list if not found in any of the locations.
-
init
(cmd)[source]¶ Check Python version and locate the executable and configuration files directory. cmd is the asciidoc command or asciidoc.py path.
-
load_backend
(dirs=None)[source]¶ Load the backend configuration files from dirs list. If dirs not specified try all the well known locations. If a <backend>.conf file was found return it’s full path name, if not found return None.
-
load_file
(fname, dir=None, include=[], exclude=[])[source]¶ Loads sections dictionary with sections from file fname. Existing sections are overlaid. The ‘include’ list contains the section names to be loaded. The ‘exclude’ list contains section names not to be loaded. Return False if no file was found in any of the locations.
-
load_filters
(dirs=None)[source]¶ Load filter configuration files from ‘filters’ directory in dirs list. If dirs not specified try all the well known locations. Suppress loading if a file named __noautoload__ is in same directory as the conf file unless the filter has been specified with the –filter command-line option (in which case it is loaded unconditionally).
-
load_from_dirs
(filename, dirs=None, include=[])[source]¶ Load conf file from dirs list. If dirs not specified try all the well known locations. Return False if no file was sucessfully loaded.
-
load_sections
(sections, attrs=None)[source]¶ Loads sections dictionary. Each dictionary entry contains a list of lines. Updates ‘attrs’ with parsed [attributes] section entries.
-
parse_replacements
(sect='replacements')[source]¶ Parse replacements section into self.replacements dictionary.
Parse [tags] section entries into self.tags dictionary.
Perform attribute substitution on ‘section’ using document attributes plus ‘d’ attributes. Return tuple (stag,etag) containing pre and post | placeholder tags. ‘skipstart’ and ‘skipend’ are used to suppress substitution.
-
static
set_replacement
(rep, replacements)[source]¶ Add pattern and replacement to replacements dictionary.
-
subs_replacements
(s, sect='replacements')[source]¶ Substitute patterns from self.replacements in ‘s’.
-
subs_section
(section, d)[source]¶ Section attribute substitution using attributes from document.attributes and ‘d’. Lines containing undefinded attributes are deleted.
-
subs_specialwords
(s)[source]¶ Search for word patterns from self.specialwords in ‘s’ and substitute using corresponding macro.
-
-
class
leo.extensions.asciidoc.
DelimitedBlocks
[source]¶ Bases:
leo.extensions.asciidoc.AbstractBlocks
List of delimited blocks.
-
BLOCK_TYPE
¶ alias of
DelimitedBlock
-
PREFIX
= 'blockdef-'¶
-
-
class
leo.extensions.asciidoc.
Document
[source]¶ Bases:
object
-
backend
¶
-
consume_attributes_and_comments
(comments_only=False, noblanks=False)[source]¶ Returns True if one or more attributes or comments were consumed. If ‘noblanks’ is True then consumation halts if a blank line is encountered.
-
doctype
¶
Return False if the author is malformed.
-
parse_header
(doctype, backend)[source]¶ Parses header, sets corresponding document attributes and finalizes document doctype and backend properties. Returns False if the document does not have a header. ‘doctype’ and ‘backend’ are the doctype and backend option values passed on the command-line, None if no command-line option was not specified.
Calculate any missing author related attributes.
-
-
class
leo.extensions.asciidoc.
FloatingTitle
[source]¶ Bases:
leo.extensions.asciidoc.Title
Floated titles are translated differently.
-
class
leo.extensions.asciidoc.
Header
[source]¶ Static methods and attributes only.
-
RCS_ID_RE
= '^\\$Id: \\S+ (?P<revnumber>\\S+) (?P<revdate>\\S+) \\S+ (?P<author>\\S+) (\\S+ )?\\$$'¶
-
REV_LINE_RE
= '^(\\D*(?P<revnumber>.*?),)?(?P<revdate>.*?)(:\\s*(?P<revremark>.*))?$'¶
-
-
class
leo.extensions.asciidoc.
InsensitiveDict
[source]¶ Bases:
dict
Like a dictionary except key access is case insensitive. Keys are stored in lower case.
-
class
leo.extensions.asciidoc.
Lex
[source]¶ Lexical analysis routines. Static methods and attributes only.
-
static
next
()[source]¶ Returns class of next element on the input (None if EOF). The reader is assumed to be at the first line following a previous element, end of file or line one. Exits with the reader pointing to the first line of the next element or EOF (leading blank lines are skipped).
-
prev_cursor
= None¶
-
prev_element
= None¶
-
static
set_margin
(margin=0)[source]¶ Utility routine that sets the left margin to ‘margin’ space in a block of non-blank lines.
-
static
-
class
leo.extensions.asciidoc.
List
[source]¶ Bases:
leo.extensions.asciidoc.AbstractBlock
-
NUMBER_STYLES
= ('arabic', 'loweralpha', 'upperalpha', 'lowerroman', 'upperroman')¶
-
static
calc_index
(style)[source]¶ Return the ordinal number of (1…) of the list item index for the given list style.
-
static
calc_style
()[source]¶ Return the numbered list style (‘arabic’…) of the list item index. Return None if unrecognized style.
-
check_index
()[source]¶ Check calculated self.ordinal (1,2,…) against the item number in the document (self.index) and check the number style is the same as the first item (self.number_style).
Check that all necessary tags are present.
-
-
class
leo.extensions.asciidoc.
Lists
[source]¶ Bases:
leo.extensions.asciidoc.AbstractBlocks
List of List objects.
-
PREFIX
= 'listdef-'¶
-
TAGS
= ('list', 'entry', 'item', 'text', 'label', 'term')¶
-
TYPES
= ('bulleted', 'numbered', 'labeled', 'callout')¶
Load listtags-* conf file sections to self.tags.
-
-
class
leo.extensions.asciidoc.
Macro
[source]¶ -
-
section_name
(name=None)[source]¶ Return macro markup template section name based on macro name and prefix. Return None section not found.
-
-
class
leo.extensions.asciidoc.
Macros
[source]¶ -
SYS_RE
= '(?u)^(?P<name>[\\\\]?\\w(\\w|-)*?)::(?P<target>\\S*?)(\\[(?P<attrlist>.*?)\\])$'¶
-
extract_passthroughs
(text, prefix='')[source]¶ Extract the passthrough text and replace with temporary placeholders.
-
match
(prefix, name, text)[source]¶ Return re match object matching ‘text’ with macro type ‘prefix’, macro name ‘name’.
-
-
class
leo.extensions.asciidoc.
Message
[source]¶ Message functions.
-
PROG
= 'asciidoc'¶
-
error
(msg, cursor=None, halt=False)[source]¶ Report fatal error. If halt=True raise EAsciiDoc exception. If halt=False don’t exit application, continue in the hope of reporting all fatal errors finishing with a non-zero exit code.
-
-
class
leo.extensions.asciidoc.
OrderedDict
(d=None, **kwargs)[source]¶ Bases:
dict
Dictionary ordered by insertion order. Python Cookbook: Ordered Dictionary, Submitter: David Benjamin. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747
-
popitem
() → (k, v), remove and return some (key, value) pair as a[source]¶ 2-tuple; but raise KeyError if D is empty.
-
-
class
leo.extensions.asciidoc.
Paragraphs
[source]¶ Bases:
leo.extensions.asciidoc.AbstractBlocks
List of paragraph definitions.
-
PREFIX
= 'paradef-'¶
-
-
class
leo.extensions.asciidoc.
Plugin
[source]¶ –filter and –theme option commands.
-
CMDS
= ('install', 'remove', 'list', 'build')¶
-
static
build
()[source]¶ Create plugin Zip file. args[0] is Zip file name. args[1] is plugin directory.
-
static
get_dir
()[source]¶ Return plugins path (.asciidoc/filters or .asciidoc/themes) in user’s home direcory or None if user home not defined.
-
static
install
()[source]¶ Install plugin Zip file. args[0] is plugin zip file path. args[1] is optional destination plugins directory.
-
static
remove
()[source]¶ Delete plugin directory. args[0] is plugin name. args[1] is optional plugin directory (defaults to ~/.asciidoc/<plugin_name>).
-
type
= None¶
-
-
class
leo.extensions.asciidoc.
Reader
[source]¶ Bases:
leo.extensions.asciidoc.Reader1
Wraps (well, sought of) Reader1 class and implements conditional text inclusion.
-
read_until
(terminators, same_file=False)[source]¶ Like read() but reads lines up to (but not including) the first line that matches the terminator regular expression, regular expression object or list of regular expression objects. If same_file is True then the terminating pattern must occur in the file the was being read when the routine was called.
-
-
class
leo.extensions.asciidoc.
Reader1
[source]¶ Line oriented AsciiDoc input file reader. Processes include and conditional inclusion system macros. Tabs are expanded and lines are right trimmed.
-
READ_BUFFER_MIN
= 10¶
-
-
class
leo.extensions.asciidoc.
Section
[source]¶ Static methods and attributes only.
-
static
gen_id
()[source]¶ The normalized value of the id attribute is an NCName according to the ‘Namespaces in XML’ Recommendation: NCName ::= NCNameStartChar NCNameChar* NCNameChar ::= NameChar - ‘:’ NCNameStartChar ::= Letter | ‘_’ NameChar ::= Letter | Digit | ‘.’ | ‘-‘ | ‘_’ | ‘:’
-
ids
= []¶
-
static
-
class
leo.extensions.asciidoc.
Table
[source]¶ Bases:
leo.extensions.asciidoc.AbstractBlock
-
ALIGN
= {'<': 'left', '>': 'right', '^': 'center'}¶
-
FORMATS
= ('psv', 'csv', 'dsv')¶
-
SEPARATORS
= {'csv': ',', 'dsv': ':|\\n', 'psv': '((?<!\\S)((?P<span>[\\d.]+)(?P<op>[*+]))?(?P<align>[<\\^>.]{,3})?(?P<style>[a-z])?)?\\|'}¶
-
VALIGN
= {'<': 'top', '>': 'bottom', '^': 'middle'}¶
-
static
parse_align_spec
()[source]¶ Parse AsciiDoc cell alignment specifier and return 2-tuple with horizonatal and vertical alignment names. Unspecified alignments set to None.
-
parse_cols
(cols, halign, valign)[source]¶ Build list of column objects from table ‘cols’, ‘halign’ and ‘valign’ attributes.
-
parse_csv
(text)[source]¶ Parse the table source text and return a list of rows, each row is a list of Cells.
-
parse_psv_dsv
(text)[source]¶ Parse list of PSV or DSV table source text lines and return a list of Cells.
-
parse_rows
(text)[source]¶ Parse the table source text into self.rows (a list of rows, each row is a list of Cells.
-
static
parse_span_spec
()[source]¶ Parse AsciiDoc cell span specifier and return 2-tuple with horizonatal and vertical span counts. Set default values (1,1) if not specified.
-
subs_row
(row, rowtype)[source]¶ Substitute the list of Cells using the data tag. Returns a list of marked up table cell elements.
-
-
class
leo.extensions.asciidoc.
Table_OLD
[source]¶ Bases:
leo.extensions.asciidoc.AbstractBlock
-
ALIGNMENTS
= {"'": 'right', '.': 'center', '`': 'left'}¶
-
COL_STOP
= "(`|'|\\.)"¶
-
FORMATS
= ('fixed', 'csv', 'dsv')¶
-
build_colspecs
()[source]¶ Generate colwidths and colspecs. This can only be done after the table arguments have been parsed since we use the table format.
-
parse_csv
(rows)[source]¶ Parse the list of source table rows. Each row item in the returned list contains a list of cell data elements.
-
parse_dsv
(rows)[source]¶ Parse the list of source table rows. Each row item in the returned list contains a list of cell data elements.
-
parse_fixed
(rows)[source]¶ Parse the list of source table rows. Each row item in the returned list contains a list of cell data elements.
-
parse_rows
(rows, rtag, dtag)[source]¶ Parse rows list using the row and data tags. Returns a substituted list of output lines.
-
split_rows
(rows)[source]¶ Return a two item tuple containing a list of lines up to but not including the next underline (continued lines are joined ) and the tuple of all lines after the underline.
-
-
class
leo.extensions.asciidoc.
Tables
[source]¶ Bases:
leo.extensions.asciidoc.AbstractBlocks
List of tables.
-
PREFIX
= 'tabledef-'¶
-
TAGS
= ('colspec', 'headrow', 'footrow', 'bodyrow', 'headdata', 'footdata', 'bodydata', 'paragraph')¶
Load tabletags-* conf file sections to self.tags.
-
-
class
leo.extensions.asciidoc.
Tables_OLD
[source]¶ Bases:
leo.extensions.asciidoc.AbstractBlocks
List of tables.
-
PREFIX
= 'old_tabledef-'¶
-
-
class
leo.extensions.asciidoc.
Title
[source]¶ Processes Header and Section titles. Static methods and attributes only.
-
attributes
= {}¶
-
dump_dict
= {}¶
-
level
= 0¶
-
linecount
= None¶
-
pattern
= None¶
-
section_numbers
= [0, 0, 0, 0, 0]¶
-
sectname
= None¶
-
static
setsectname
()[source]¶ Set Title section name: If the first positional or ‘template’ attribute is set use it, next search for section title in [specialsections], if not found use default ‘sect<level>’ name.
-
subs
= ()¶
-
static
translate
()[source]¶ Parse the Title.attributes and Title.level from the reader. The real work has already been done by parse().
-
underlines
= ('==', '--', '~~', '^^', '++')¶
-
-
class
leo.extensions.asciidoc.
Trace
[source]¶ Bases:
object
Used in conjunction with the ‘trace’ attribute to generate diagnostic output. There is a single global instance of this class named trace.
-
SUBS_NAMES
= ('specialcharacters', 'quotes', 'specialwords', 'replacements', 'attributes', 'macros', 'callouts', 'replacements2', 'replacements3')¶
-
-
class
leo.extensions.asciidoc.
Writer
[source]¶ Writes lines to output file.
-
open
(fname, bom=None)[source]¶ bom is optional byte order mark. http://en.wikipedia.org/wiki/Byte-order_mark
-
-
leo.extensions.asciidoc.
asciidoc
(backend, doctype, confiles, infile, outfile, options)[source]¶ Convert AsciiDoc document to DocBook document of type doctype The AsciiDoc document is read from file object src the translated DocBook file written to file object dst.
-
leo.extensions.asciidoc.
assign
(dst, src)[source]¶ Assign all attributes from ‘src’ object to ‘dst’ object.
-
leo.extensions.asciidoc.
create_zip
(zip_file, src, skip_hidden=False)[source]¶ Create Zip file. If src is a directory archive all contained files and subdirectories, if src is a file archive the src file. Files and directories names starting with . are skipped if skip_hidden is True. Throws exception if error occurs.
-
leo.extensions.asciidoc.
date_str
(t)[source]¶ Convert seconds since the Epoch to formatted local date string.
-
leo.extensions.asciidoc.
dovetail
(lines1, lines2)[source]¶ Append list or tuple of strings ‘lines2’ to list ‘lines1’. Join the last non-blank item in ‘lines1’ with the first non-blank item in ‘lines2’ into a single string.
Merge the end tag with the first content line and the last content line with the end tag. This ensures verbatim elements don’t include extraneous opening and closing line breaks.
-
leo.extensions.asciidoc.
dump_section
(name, dict, f=<open file '<stdout>', mode 'w'>)[source]¶ Write parameters in ‘dict’ as in configuration file section format with section ‘name’.
-
leo.extensions.asciidoc.
east_asian_widths
= {'A': 1, 'F': 2, 'H': 1, 'N': 1, 'Na': 1, 'W': 2}¶ Mapping of result codes from unicodedata.east_asian_width() to character column widths.
-
leo.extensions.asciidoc.
execute
(cmd, opts, args)[source]¶ Execute asciidoc with command-line options and arguments. cmd is asciidoc command or asciidoc.py path. opts and args conform to values returned by getopt.getopt(). Raises SystemExit if an error occurs.
Doctests:
Check execution:
>>> import StringIO >>> infile = StringIO.StringIO('Hello *{author}*') >>> outfile = StringIO.StringIO() >>> opts = [] >>> opts.append(('--backend','html4')) >>> opts.append(('--no-header-footer',None)) >>> opts.append(('--attribute','author=Joe Bloggs')) >>> opts.append(('--out-file',outfile)) >>> execute(__file__, opts, [infile]) >>> print outfile.getvalue() <p>Hello <strong>Joe Bloggs</strong></p>
>>>
-
leo.extensions.asciidoc.
extract_zip
(zip_file, destdir)[source]¶ Unzip Zip file to destination directory. Throws exception if error occurs.
-
leo.extensions.asciidoc.
file_in
(fname, directory)[source]¶ Return True if file fname resides inside directory.
-
leo.extensions.asciidoc.
filter_lines
(filter_cmd, lines, attrs={})[source]¶ Run ‘lines’ through the ‘filter_cmd’ shell command and return the result. The ‘attrs’ dictionary contains additional filter attributes.
-
leo.extensions.asciidoc.
is_attr_defined
(attrs, dic)[source]¶ Check if the sequence of attributes is defined in dictionary ‘dic’. Valid ‘attrs’ sequence syntax: <attr> Return True if single attrbiute is defined. <attr1>,<attr2>,… Return True if one or more attributes are defined. <attr1>+<attr2>+… Return True if all the attributes are defined.
-
leo.extensions.asciidoc.
is_name
(s)[source]¶ Return True if s is valid attribute, macro or tag name (starts with alpha containing alphanumeric and dashes only).
-
leo.extensions.asciidoc.
is_re
(s)[source]¶ Return True if s is a valid regular expression else return False.
-
leo.extensions.asciidoc.
join_lines_OLD
(lines)[source]¶ Return a list in which lines terminated with the backslash line continuation character are joined.
-
leo.extensions.asciidoc.
localapp
()[source]¶ Return True if we are not executing the system wide version i.e. the configuration is in the executable’s directory.
-
leo.extensions.asciidoc.
lstrip_list
(s)[source]¶ Return list with empty items from start of list removed.
-
leo.extensions.asciidoc.
parse_attributes
(attrs, dict)[source]¶ Update a dictionary with name/value attributes from the attrs string. The attrs string is a comma separated list of values and keyword name=value pairs. Values must preceed keywords and are named ‘1’,‘2’… The entire attributes list is named ‘0’. If keywords are specified string values must be quoted. Examples:
attrs: ‘’ dict: {}
attrs: ‘hello,world’ dict: {‘2’: ‘world’, ‘0’: ‘hello,world’, ‘1’: ‘hello’}
attrs: ‘“hello”, planet=”earth”’ dict: {‘planet’: ‘earth’, ‘0’: ‘“hello”,planet=”earth”’, ‘1’: ‘hello’}
-
leo.extensions.asciidoc.
parse_entries
(entries, dict, unquote=False, unique_values=False, allow_name_only=False, escape_delimiter=True)[source]¶ Parse name=value entries from from lines of text in ‘entries’ into dictionary ‘dict’. Blank lines are skipped.
-
leo.extensions.asciidoc.
parse_entry
(entry, dict=None, unquote=False, unique_values=False, allow_name_only=False, escape_delimiter=True)[source]¶ Parse name=value entry to dictionary ‘dict’. Return tuple (name,value) or None if illegal entry. If name= then value is set to ‘’. If name and allow_name_only=True then value is set to ‘’. If name! and allow_name_only=True then value is set to None. Leading and trailing white space is striped from ‘name’ and ‘value’. ‘name’ can contain any printable characters. If the ‘=’ delimiter character is allowed in the ‘name’ then it must be escaped with a backslash and escape_delimiter must be True. If ‘unquote’ is True leading and trailing double-quotes are stripped from ‘name’ and ‘value’. If unique_values’ is True then dictionary entries with the same value are removed before the parsed entry is added.
-
leo.extensions.asciidoc.
parse_list
(s)[source]¶ Parse comma separated string of Python literals. Return a tuple of of parsed values.
-
leo.extensions.asciidoc.
parse_named_attributes
(s, attrs)[source]¶ Update a attrs dictionary with name=”value” attributes from the s string. Returns False if invalid syntax. Example: attrs: ‘star=”sun”,planet=”earth”’ dict: {‘planet’:’earth’, ‘star’:’sun’}
-
leo.extensions.asciidoc.
parse_options
(options, allowed, errmsg)[source]¶ Parse comma separated string of unquoted option names and return as a tuple of valid options. ‘allowed’ is a list of allowed option values. If allowed=() then all legitimate names are allowed. ‘errmsg’ is an error message prefix if an illegal option error is thrown.
-
leo.extensions.asciidoc.
re_join
(relist)[source]¶ Join list of regular expressions re1,re2,… to single regular expression (re1)|(re2)|…
-
leo.extensions.asciidoc.
rstrip_list
(s)[source]¶ Return list with empty items from end of list removed.
-
leo.extensions.asciidoc.
safe_filename
(fname, parentdir)[source]¶ Return file name which must reside in the parent file directory. Return None if file is not safe.
-
leo.extensions.asciidoc.
strip_list
(s)[source]¶ Return list with empty items from start and end of list removed.
-
leo.extensions.asciidoc.
strip_quotes
(s)[source]¶ Trim white space and, if necessary, quote characters from s.
-
leo.extensions.asciidoc.
subs_attrs
(lines, dictionary=None)[source]¶ Substitute ‘lines’ of text with attributes from the global document.attributes dictionary and from ‘dictionary’ (‘dictionary’ entries take precedence). Return a tuple of the substituted lines. ‘lines’ containing undefined attributes are deleted. If ‘lines’ is a string then return a string.
- Attribute references are substituted in the following order: simple, conditional, system.
- Attribute references inside ‘dictionary’ entry values are substituted.
-
leo.extensions.asciidoc.
subs_quotes
(text)[source]¶ Quoted text is marked up and the resulting text is returned.
-
leo.extensions.asciidoc.
subs_tag
(tag, dict={})[source]¶ Perform attribute substitution and split tag string returning start, end tag tuple (c.f. Config.tag()).
-
leo.extensions.asciidoc.
system
(name, args, is_macro=False, attrs=None)[source]¶ Evaluate a system attribute ({name:args}) or system block macro (name::[args]). If is_macro is True then we are processing a system block macro otherwise it’s a system attribute. The attrs dictionary is updated by the counter and set system attributes. NOTE: The include1 attribute is used internally by the include1::[] macro and is not for public use.
-
leo.extensions.asciidoc.
time_str
(t)[source]¶ Convert seconds since the Epoch to formatted local time string.
colors
Module¶
Colors module provides a colors names database and functions to access it.
The database is a python dictionary with reduced colornames as keys and color data in the form ‘#RRGGBB’ as values.
The reudced color names are common color names with spaces and capitalization removed.
Functions to access the data base are:
This function will convert name and return it in ‘#RRGGBB’ format if possible otherwise it will do the sme for default.
If default can not be converted, None will be returned.
name and default are reduced by removing spaces and capitalization before looking them up in the database.
This function will first call getColor to convert name (or default) to ‘#RRGGBB’ format, then it will convert this and return it as a python tuple in the form (0-255, 0-255, 0-255).
Returns None if anything goes wrong.
patch_11_01
Module¶
Patch utility to apply unified diffs
Brute-force line-by-line non-recursive parsing
Copyright (c) 2008-2011 anatoly techtonik Available under the terms of MIT license
Project home: http://code.google.com/p/python-patch/
$Id: patch.py 117 2011-01-09 16:38:03Z techtonik $ $HeadURL: https://python-patch.googlecode.com/svn/trunk/patch.py $
-
class
leo.extensions.patch_11_01.
Hunk
[source]¶ Bases:
object
Parsed hunk data container (hunk starts with @@ -R +R @@)
-
startsrc
= None¶ line count starts with 1
-
-
class
leo.extensions.patch_11_01.
Patch
(stream=None)[source]¶ Bases:
object
-
can_patch
(filename)[source]¶ Check if specified filename can be patched. Returns None if file can not be found among source filenames. False if patch can not be applied clearly. True otherwise.
Returns: True, False or None
-
header
= None¶ headers for each file
-
hunkends
= None¶ file endings statistics for every hunk
-
hunks
= None¶ list of lists of hunks
-
patch_stream
(instream, hunks)[source]¶ Generator that yields stream patched with hunks iterable
Converts lineends in hunk lines to the best suitable format autodetected from input
-
source
= None¶ list of source filenames
-
type
= None¶ patch type - one of constants
-