Input parsing routines for dmr.
Parse a document read from the given filehandle into a dmr.data.Document object.
The document must contain:
Parameters: | filehandle (file) – The file-like object to parse the document from. |
---|---|
Returns: | dmr.data.Document |
Bases: object
Base dmr output class. All dmr output format classes should inherit from this class.
Parameters: | document (dmr.data.Document) – The DMR document to output |
---|
The dmr.data.Document object to output
Get a list of options to parse from the config files and command line when this output class is selected.
Returns: | list - A list of dmr.config.DMROption objects |
---|
This module provides a dmr output format to write HTML output using the docutils HTML translator.
This is the default output format. Because a dmr document is already structured to look like a resume, this just uses the default docutils HTML translator – it’s basically equivalent to running rst2html on your reST resume.
Bases: dmr.output.base.BaseOutput
dmr output format class to write HTML output using the docutils HTML translator.
Parameters: | document (dmr.data.Document) – The DMR document to output |
---|
Get a list of options to parse from the config files and command line when this output class is selected.
Returns: | list - A list of dmr.config.DMROption objects |
---|
This module provides a JSON output format for dmr. This is useful if you want to get the data from a resume for use in other scripts or programs.
Note
N.B.! This output format is lossy! Text formatting (e.g., emphasis, etc.) is discarded, and only the actual text data is output.
Bases: dmr.output.base.BaseOutput
dmr output format class to write JSON output. Note that this output format is lossy; text formatting (e.g., emphasis, etc.) is discarded.
Dump a rendered namedtuple data class (dmr.data.Contact and dmr.data.Dates) to a dict in preparation for JSON serialization.
Dump a rendered namedtuple data class (dmr.data.Contact and dmr.data.Dates) to a dict in preparation for JSON serialization.
Dump a rendered dmr.data.Exception object to a list in preparation for JSON serialization.
Dump a rendered dmr.data.Job to a dict in preparation for JSON serialization.
Dump a rendered dmr.data.Section subclass object to a list in preparation for JSON serialization.
Dump a rendered namedtuple data class (dmr.data.Contact and dmr.data.Dates) to a dict in preparation for JSON serialization.
Dump a rendered dmr.data.Section subclass object to a list in preparation for JSON serialization.
Dump a rendered dmr.data.Section subclass object to a list in preparation for JSON serialization.
Dump a rendered dmr.data.Section subclass object to a list in preparation for JSON serialization.
Genshi helper output format for dmr. This helper output module should not be called by itself, but can be used by other output modules to easily add Genshi templating abilities.
Bases: dmr.output.base.BaseOutput
dmr output class that renders the data in the document with a Genshi template. This class is not a usable output format itself; child classes can inherit from it to implement their own Genshi templating.
The child class will use a docutils Writer to translate all of the doctrees in the dmr.data.Document that will be rendered.
Get a renderer for a doctree snippet. By default, this uses dmr.data.WriterRenderer, which passes the snippets through to a docutils Writer class.
A docutils.writers.Writer subclass that will be used to translate the snippets in the dmr document.
This module provides a dmr output format to write LaTeX files based on Genshi templates using dmr.output.genshi.
See Genshi output options for details on how the template is selected.
Bases: dmr.output.genshi.GenshiOutput
dmr output format to write LaTeX files using dmr.output.genshi.GenshiOutput.
Get a renderer for a doctree snippet. By default, this uses dmr.data.WriterRenderer, which passes the snippets through to a docutils Writer class.
The dmr data model.
Bases: dmr.data.ContactBase, dmr.data.RenderableNamedTuple, dmr.data.Parseable
An address block is a line block giving the contact information for a resume, an employer, a reference, or similar. It consists of six different types of lines:
If the address block describes a reference, then the first line must be that person’s name. Otherwise, the name will be taken from the title of the section the address block is in, and must not be included in the address block itself. (See below for examples to clarify this.)
Outside of the few ordering requirements listed, order is neither required nor respected; the order of address elements in the output document is specified by the output format class. The canonical output order is: name, address, phone, email, url, other. No output format is required to honor that.
Examples
So the start of a resume might look like:
============================
Dennis MacAlistair Ritchie
============================
| 1234 No. Such Ln.
| Berkeley Heights, NJ 07922
| (908) 555-5555
| dmr@lucent.com
Whereas a personal reference might look like:
References
==========
| Dennis MacAlistair Ritchie
| 1234 No. Such Ln.
| Berkeley Heights, NJ 07922
| (908) 555-5555
| dmr@lucent.com
Note the different ways the name is specified.
Physical address matching is greedy, so if you have several unrecognizable lines in a row, they will all become the physical address. Consider this example:
============================
Dennis MacAlistair Ritchie
============================
| 1234 No. Such Ln.
| Berkeley Heights, NJ 07922
| "I invented C."
| (908) 555-5555
| dmr@lucent.com
In this case, the physical address would have three lines – “1234 No. Such Ln.”, ‘Berkeley Heights, NJ 07922”, and “‘I invented C.’” In order to treat the final line as “other data” instead of as the physical address, it must be separated from the physical address by another data type. E.g.:
============================
Dennis MacAlistair Ritchie
============================
| 1234 No. Such Ln.
| Berkeley Heights, NJ 07922
| (908) 555-5555
| dmr@lucent.com
| "I invented C."
Alias for field number 4
Alias for field number 1
Alias for field number 3
Raises ValueError if the value is not present.
Alias for field number 0
Alias for field number 5
Parse a node into a dmr.data.Contact object. The node must either a) be a docutils.nodes.line_block; or b) contain a docutils.nodes.Titular and a docutils.nodes.line_block.
Parameters: | block (docutils.nodes.Node) – The line block to parse. |
---|---|
Returns: | dmr.data.Contact |
Alias for field number 2
Bases: tuple
ContactBase(name, address, phone, email, URL, other)
Alias for field number 4
Alias for field number 1
Alias for field number 3
Raises ValueError if the value is not present.
Alias for field number 0
Alias for field number 5
Alias for field number 2
Bases: tuple
DateBase(start, end)
Alias for field number 1
Raises ValueError if the value is not present.
Alias for field number 0
Bases: dmr.data.DateBase, dmr.data.RenderableNamedTuple, dmr.data.Parseable
A date range is a one-line paragraph giving a range of dates. The dates themselves are not parsed; only the start and end of the range are determined. The start and end may be separated:
In other words, the following are all valid:
1 February 2013 to 27 February 2013
2-1-2013 to 2-27-2013
2013-1-2 - 2013-27-2
1 Feb 2013-27 Feb 2013
1999-2004
Marceau, Nonidi 9 Ventôse an 221 - Présent
The following are invalid:
2013-1-2-2013-27-2
1 février 2013 à 27 février 2013
The latter invalid example is a localization problem, which someone should probably solve some day. However, it should be noted that the actual display of the separator between the dates is left to the output format; the separator used in the source file is not preserved. (I.e., non-English-language resumes can use the hyphen as a separator, and the appropriate word or separator in the output formatter.)
Alias for field number 1
Raises ValueError if the value is not present.
Alias for field number 0
Bases: list, dmr.data.Parseable
Every dmr resume must start with a top-level title that contains the full name of the person whose resume it is. For example:
============================
Dennis MacAlistair Ritchie
============================
Immediately after the title there should be an Address Block for the person whose resume it is, followed by any number of other Sections.
That’s it – a top title, an address block, and then other sections. All of the data is held in other sections.
Parameters: |
|
---|
L.append(object) – append object to end
The contact for the resume (i.e., the person whose resume it is), as a dmr.data.Contact.
L.extend(iterable) – extend list by appending elements from the iterable
L.insert(index, object) – insert object before index
Raises IndexError if list is empty or index is out of range.
L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.
L.reverse() – reverse IN PLACE
L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1
The docutils.nodes.document representing the original doctree.
Bases: dmr.data.Section
The Experience section is by far the most complex section. It is useful for job experience, education history, and anything that consists of multiple discrete items with dates and descriptions. It may take one of two formats:
With Positions
For most job experience sections, you’ll want to use the format that allows you to specify both employers and positions. In this case, the Experience section must consist only of any number of subsections, each of which describes an employer. Each employer section must itself contain:
Note
This makes it simple and efficient to specify multiple jobs you held at a single employer.
Each position subsection is a Job Section.
See the examples below.
Without Positions
In this format, you only specify employers, not positions. This is useful for education sections, where you often wish to list the school, but a “position” as such is nonsensical. (Of course, more complex education sections will likely wish to use the format with positions in order to present more data.)
The positionless format is simply the format with positions with one level of subsection removed. The Experience section must consist only of any number of subsections, each of which is a Job Section.
See the examples below.
Examples
This is an example of an Experience section with positions:
Experience
==========
Bell Labs
---------
| 600 Mountain Ave.
| New Providence, NJ 07974
Scientist
~~~~~~~~~
1967 - 1975
* Invented C.
* Invented C while inventing UNIX.
* Wrote *The C Programming Language*.
Research Fellow
~~~~~~~~~~~~~~~
1975 - 1996
* Developed ANSI C (C89).
* Won the Turing Award and the Hamming Medal.
Lucent Technologies
-------------------
Chair, System Software Research Department
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1996 - 2007
* Got about a zillion more awards for being the guy who
invented C.
This is an example of an Experience section without positions:
Education
=========
Harvard University
------------------
1959 - 1963
* B.S., Physics
* B.A., Applied Mathematics
Harvard University
------------------
1963 - 1967
* PhD, Applied Mathematics
* Dissertation: "Program Structure and Computational
Complexity"
Parameters: | name (docutils.nodes.Text) – The name (title) of the section |
---|
L.append(object) – append object to end
L.extend(iterable) – extend list by appending elements from the iterable
Raises ValueError if the value is not present.
L.insert(index, object) – insert object before index
Return True if the node contains a valid section of this type, False otherwise. Subclasses must not return false positives in any case, since dmr.input.parse() does not necessarily check sections in any particular order.
Parameters: | node (docutils.nodes.Node) – The node to check |
---|---|
Returns: | bool |
Raises IndexError if list is empty or index is out of range.
L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.
L.reverse() – reverse IN PLACE
L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1
Bases: _abcoll.MutableSequence, dmr.data.Renderable, dmr.data.Parseable
Representation of an element in a Experience section. We call it a “Job,” but it could be schooling or anything else with dates and a bullet list description. It contains:
Parameters: |
|
---|
The dates at this job, as a dmr.data.Dates
A list of things you did at the job.
The employer (or school, etc.) as a dmr.data.Contact
The end date of the position
Parameters: |
|
---|---|
Returns: |
The position at the employer, or None if not applicable.
The start date of the position
Bases: dmr.data.Section
A List section contains only a bulleted list – for example, a list of publications, or related experience.
Examples
Other Qualifications
====================
* Invented C.
* No seriously.
* Invented a lot of UNIX, too.
Parameters: | name (docutils.nodes.Text) – The name (title) of the section |
---|
L.append(object) – append object to end
L.extend(iterable) – extend list by appending elements from the iterable
Raises ValueError if the value is not present.
L.insert(index, object) – insert object before index
Return True if the node contains a valid section of this type, False otherwise. Subclasses must not return false positives in any case, since dmr.input.parse() does not necessarily check sections in any particular order.
Parameters: | node (docutils.nodes.Node) – The node to check |
---|---|
Returns: | bool |
Raises IndexError if list is empty or index is out of range.
L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.
L.reverse() – reverse IN PLACE
L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1
Bases: object
An abstract base class that provides a parse class method, which parses the given doctree and returns a new object of the given type from the data in it.
Bases: dmr.data.Section
A References section contains only a series of Address Blocks.
Examples
References
==========
| Dennis MacAlistair Ritchie
| 1234 No. Such Ln.
| Berkeley Heights, NJ 07922
| (908) 555-5555
| dmr@lucent.com
Parameters: | name (docutils.nodes.Text) – The name (title) of the section |
---|
L.append(object) – append object to end
L.extend(iterable) – extend list by appending elements from the iterable
Raises ValueError if the value is not present.
L.insert(index, object) – insert object before index
Return True if the node contains a valid section of this type, False otherwise. Subclasses must not return false positives in any case, since dmr.input.parse() does not necessarily check sections in any particular order.
Parameters: | node (docutils.nodes.Node) – The node to check |
---|---|
Returns: | bool |
Raises IndexError if list is empty or index is out of range.
L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.
L.reverse() – reverse IN PLACE
L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1
Bases: object
An abstract base class that provides a render method, which returns a new object of the given type with all internal data replaced by simple strings (as opposed to doctrees).
Bases: dmr.data.Renderable
An abstract base class to provide a working render method (as per dmr.data.Renderable.render() for namedtuple subclasses.
Bases: list, dmr.data.Renderable, dmr.data.Parseable
Abstract representation of a resume section
Parameters: | name (docutils.nodes.Text) – The name (title) of the section |
---|
L.append(object) – append object to end
L.extend(iterable) – extend list by appending elements from the iterable
Raises ValueError if the value is not present.
L.insert(index, object) – insert object before index
Return True if the node contains a valid section of this type, False otherwise. Subclasses must not return false positives in any case, since dmr.input.parse() does not necessarily check sections in any particular order.
Parameters: | node (docutils.nodes.Node) – The node to check |
---|---|
Returns: | bool |
Parse an object of this type out of the given node.
Parameters: | node (docutils.nodes.Node) – The doctree to parse |
---|---|
Returns: | An object of this type |
Raises IndexError if list is empty or index is out of range.
L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.
L.reverse() – reverse IN PLACE
L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1
This very simple descriptor class exists only to get the name of the owner class. This way, every section can have a type attribute that is in the __class__.__name__ attribute (lowercased), which can be used by output formats to determine the type of a section without needing to use __class__ magic.
Bases: dmr.data.Section
A Text section contains only freeform text – an objective, for instance. This is the simplest section.
A section header with no content (e.g., “References Available Upon Request”) will be treated as a Text section.
Examples
Objective
=========
To obtain a rewarding, high-level position inventing C.
References Available Upon Request
=================================
Parameters: | name (docutils.nodes.Text) – The name (title) of the section |
---|
L.append(object) – append object to end
L.extend(iterable) – extend list by appending elements from the iterable
Raises ValueError if the value is not present.
L.insert(index, object) – insert object before index
Return True if the node contains a valid section of this type, False otherwise. Subclasses must not return false positives in any case, since dmr.input.parse() does not necessarily check sections in any particular order.
Parameters: | node (docutils.nodes.Node) – The node to check |
---|---|
Returns: | bool |
Raises IndexError if list is empty or index is out of range.
L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.
L.reverse() – reverse IN PLACE
L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1
alias of References
Get the first child of parent that is a member of nodecls. This differs from docutils.node.Node.first_child_matching_class(), which only returns the index of the first child. This returns the actual child.
Parameters: |
|
---|---|
Returns: | docutils.node.Node instance or None |
Utilities for rendering doctrees.
Bases: docutils.nodes.GenericNodeVisitor
Node visitor that transforms docutils.nodes.reference nodes into plain-text representations of those references.
Call self.”depart_ + node class name” with node as parameter. If the depart_... method does not exist, call self.unknown_departure.
Call self.”visit_ + node class name” with node as parameter. If the visit_... method does not exist, call self.unknown_visit.
Called before exiting unknown Node types.
Raise exception unless overridden.
Called when entering unknown Node types.
Raise an exception unless overridden.
Bases: object
Get a renderer callable suitable for passing to dmr.data.Renderable.render().
Parameters: |
|
---|
Bases: dmr.render.Renderer
dmr.render.Renderer that removes newlines and duplicate whitespace.
Parameters: |
|
---|
Bases: dmr.render.Renderer
Get a renderer callable for the given docutils Writer, suitable for passing to dmr.data.Renderable.render().
dmr configuration parsing is done in several phases:
Each phase overwrites values that were read in the previous phase.
Some options can take multiple values --exclude. These are specified differently depending on where they are configured:
On the command line, give multiple option strings:
dmr --exclude foo --exclude "bar and baz"
In the config file, use a quoted, space-separated list:
.. code-block:: cfg
[global] exclude = foo “bar and baz”
In the document, give multiple option strings:
In-document options are specified as comments. For instance:
.. options
footer
exclude Experience
You can specify options for a specific output format thusly:
.. options=json
footer
exclude Experience
Output-specific options override generic in-document options.
See ConfigParser.RawConfigParser.getboolean() for acceptable values for boolean configuration options.
A module-level argparse.Namespace object that stores all configuration for dmr.
Parse command-line arguments and config file(s).
Parameters: | argv (list) – The argument list to parse, instead of sys.argv |
---|---|
Returns: | argparse.Namespace |
Get a list of core options. This is implemented as a function rather than as a module-level variable because it imports dmr.output, which itself imports dmr.config, so this list must be generated at run-time rather than at compile-time, or we get circular imports.
Bases: object
Representation of an option that can be specified on the command line or in a config file.
See argparse.ArgumentParser.add_argument() for a full list of accepted parameters.
In addition to supporting all arguments and keyword arguments from argparse.ArgumentParser.add_argument(), two additional keyword arguments are allowed.
Parameters: |
---|
Add this option to the given parser.
Parameters: | parser (argparse.ArgumentParser) – The parser to add the option to. |
---|---|
Returns: | argparse.Action |
Get the value of this option from the given ConfigParser.ConfigParser. If it is not found in the config file, the default is returned. (If there is no default, None is returned.)
Parameters: | cfp (ConfigParser.ConfigParser) – The config parser to get the option value from |
---|---|
Returns: | varies |
Logging for dmr.
logging.Logger object that all dmr modules should use for output.