27
Resu Documentation Release 0.0.0 Skyler Berg July 06, 2015

Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Resu DocumentationRelease 0.0.0

Skyler Berg

July 06, 2015

Page 2: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default
Page 3: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Contents

1 Introduction 1

2 Installation 32.1 Ubuntu Installation Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.2 Red Hat Based Installation Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.3 OS-X Installation Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.4 Windows Installation Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

3 Quick Start 53.1 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.2 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.3 Basic Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

4 Contributing 74.1 How to add an Extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

5 Command Line Reference 95.1 Specify Input File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95.2 Specify Output File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95.3 Specify Output Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95.4 Non-YAML Resume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105.5 Non-Default Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105.6 Include Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105.7 List Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

6 Python API Reference 116.1 resu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116.2 resu.io . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126.3 resu.parsers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136.4 resu.templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156.5 resu.template_engines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156.6 resu.converters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166.7 resu.exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

7 Indices and tables 19

Python Module Index 21

i

Page 4: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

ii

Page 5: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

CHAPTER 1

Introduction

Resu is an open source resume generator with a command line interface.

1

Page 6: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Resu Documentation, Release 0.0.0

2 Chapter 1. Introduction

Page 7: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

CHAPTER 2

Installation

2.1 Ubuntu Installation Guide

2.2 Red Hat Based Installation Guide

2.3 OS-X Installation Guide

2.4 Windows Installation Guide

3

Page 8: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Resu Documentation, Release 0.0.0

4 Chapter 2. Installation

Page 9: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

CHAPTER 3

Quick Start

3.1 Requirements

To install Resu with this guide you need Python, git, and pip. Most systems come with Python. To install git and pipon Ubuntu, enter the following commands:

sudo apt-get install gitsudo apt-get install python-pip

3.2 Installation

Currently Resu can only be installed from source.

git clone git://github.com/skylerberg/resu.gitcd resupython setup.py install

Resu will be on available Pypi after the initial 0.1.0 release.

3.3 Basic Usage

Resu provides a flag to generate a default resume.

resu -g

This creates a default resume data file called resu.yml. Now, to generate a resume and save it to a file calledresu.html, run:

resu

You can open the html file in your browser of choice. For example, on most Linux systems, you can use the command:

firefox resu.html

For more advanced usage see Command Line Reference.

5

Page 10: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Resu Documentation, Release 0.0.0

6 Chapter 3. Quick Start

Page 11: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

CHAPTER 4

Contributing

Giving feedback is one of the easiest and most useful ways to contribute. Any feature requests, bug reports, orsuggestions can be posted as issues on GitHub. To contribute code, fork the repository, commit your changes andissue a pull request. Every issue or pull request will receive a response from someone with commit access for Resu.

4.1 How to add an Extension

In this tutorial we will use Resu’s built in extension mechanism to integrate our code with the Resu command line tool.First we will create a new file called my_template.py and create a new template. This template will be a minimalversion of the default template.

Create a file called my_template.py with the following content.

from resu.templates import Template

Template(name='my_template',source=resu.io.PackageData('resu', 'examples/templates/default.html'))

Our new template has the same source as the default template, but has a different name. To include the extension whenrunning Resu, use the -e flag. Use the -l flag to list all of the available features:

resu -e my_template -l

You should now see my_template listed as one of the templates available.

4.1.1 Warnings

When including an extension, it must have a name that is not used by another Python module. If there is a namingconflict between your module and a built in module, your module will not be loaded.

When you include an extension, your code is simply imported before running the main Resu functions. This meansthat any code included in an extension will be executed.

7

Page 12: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Resu Documentation, Release 0.0.0

8 Chapter 4. Contributing

Page 13: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

CHAPTER 5

Command Line Reference

Resu is meant to be usable with just two commands:

resu -g

resu

resu -g will write a file called resu.yml which contains an example resume. By default, resu will look for afile called resu.yml, load this file and turn it into a pdf resume written to the file resu.pdf. To make a resumethat is actually useful, you can update resu.yml with your data.

Resu assumes that your data is YAML, that you want to use the default template, that you would like to save the outputto resu.pdf. All of these defaults can be overridden with command line options.

5.1 Specify Input File

The resu command takes one optional argument: the name of the file with your data. If you prefer the nameresume.yml, you can rename resu.yml that and then build your resume with the command:

resu resume.yml

5.2 Specify Output File

If you would like to save your file as something other than resu.pdf, you can use the -o or --output-fileoption. For example, to save your resume as resume.pdf you would run the command:

resu -o resume.pdf

5.3 Specify Output Format

To produce an html resume instead of a pdf, use the -f or --format option. For example, to produce an html filecalled resu.html, run:

resu -f html

Currently, all templates produce html files which are by default converted to pdf files. Specifying html as the formatto produce causes this conversion not to happen.

9

Page 14: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Resu Documentation, Release 0.0.0

5.4 Non-YAML Resume

The -p or --parser option allows you to specify an alternate format for your data. If you have your resume writtenin JSON in a file called resume.json, then can build your resume with the command:

resu -p json resume.json

Current JSON is the only format other than YAML supported.

5.5 Non-Default Template

If there was more than one template included with Resu, or if you have created template yourself, then you couldspecify it with the -t or --template option. Assuming you are using the default resu.yml file to store yourresume and that you had a template called fancy, then you could generate your resume with the fancy templatewith the command:

resu -t fancy

When paired with the -g or --generate option, Resu will save example input for the template. If we wanted to seehow to write a resume for the fancy template, then we would run the command:

resu -t fancy -g

5.6 Include Extensions

Resu includes a way to extend its functionality with your own Python modules. To include an extension, use the -eor --extensions option. To include a Python module called resu_ext, use the command:

resu -e resu_ext

To include multiple extensions, separate the module names with commas:

resu -e resu_ext1,resu_ext2

5.7 List Features

To see the various features supported by Resu, you may use the -l or --list-features option. This is particu-larly useful for designing extensions because it will list all of the features built into Resu as well as those included inextensions. The list is printed out in YAML.

resu -l

10 Chapter 5. Command Line Reference

Page 15: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

CHAPTER 6

Python API Reference

The resu module provides all of the functionality needed to create applications using resu. The submodules providean interface for adding additional functionality to Resu.

6.1 resu

This module contains core funtions for searching Resu’s capabilities and for generating documents using Resu’s fea-tures.

resu.build(input_provider=None, output_provider=None, input_format=’yaml’, output_format=’pdf’,template_name=’default’)

Use user data to create a document from a template. The user’s data is read from the source provided, parsedinto a dictionary, and used to render a template. The rendered template is then written to the specified location.

Parameters

• input_provider (resu.io.Provider or None) – A string indicating where to findthe resume data. If left as None, defaults to resu.io.File(’resu.yml’).

• output_provider (resu.io.Provider or None) – Path to the file to writethe resume to. If left as None, defaults to resu.io.File(’resu.’ +output_format).

• input_format (String) – The format of the resume data must be parsed from.

• template (String) – Name of the template for the resume.

Returns None

resu.get_example(output_provider=<resu.io.file.File object>, template_name=’default’)Write the example input for a template to the specified location. The data written by this command can be usedby build() to generate a document.

Parameters

• output_provider (resu.io.Provider) – Path to the file to save the example re-sume to.

• output_format (String) – The file type to produce. Currently, this is not implemented.

• template (String) – The name of the template to generate an example for.

Returns None

resu.render_template(name, context)Render a template with provided context.

11

Page 16: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Resu Documentation, Release 0.0.0

Parameters

• name (String) – Name of the template to render.

• context – Context to pass to the template.

Returns The template with data provided as its context.

Return type String

resu.find(class_, target, id_attr=’name’)Find an instance of or a subclass that can be identified by the value of a particular attribute of the instance orsubclass.

Parameters

• class (Class) – The class to find an instance or subclass of.

• target (Object) – The desired value of the id_attr for the instance.

• id_attr (String) – Attribute used to identify instances or subclasses of class_.

Returns An instance or subclass of class_ where id_attr == target.

Return type Class or class_

Raises FeatureNotFound if there is no class matching the parameters.

resu.available(class_, id_attr=’name’)List all instances or subclasses of a class that.

Parameters

• class (Class) – The class to find an instance or subclass of.

• id_attr (String) – Attribute used to identify instances or subclasses of a littl class_.

6.2 resu.io

Resu abstracts IO to read and write operations to allow developers to add IO providers to support IO for databases orrespond to API calls on a website without changing any code in Resu.

class resu.io.ProviderAbstract base class for for IO providers.

Providers are responsible for fetching and writing resources.

For example, if the user is loading a resume off of their local file system, then they can use the resu.io.Fileto read their files. After these files are read, they are ready to be parsed by a resu.Parser.

read()

Returns The contents stored in self.source.

Return type Object

Raises IOError if the source cannot be read.

write(content, force)

Parameters

• content (Object) – Content to write.

• force (Boolean) – Flag to specify whether or not to override existing resources.

12 Chapter 6. Python API Reference

Page 17: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Resu Documentation, Release 0.0.0

Returns None

Raises IOError when attempting to write over an existing resource while force is False orwhen attempting to write to a readonly resource.

class resu.io.File(path)Read and write to a file on the local file system.

Variables

• name – file

• return_type – str

read()

Returns Contents of the file specified in self.source.

Return type String

Raises IOError if the file does not exist.

return_typealias of str

write(content, force=False)

Parameters

• content (String) – The content to write to the file.

• force (Boolean) – Flag to write over existing file.

Returns None

Raises IOError When attempting to write over an existing file while force is False.

class resu.io.PackageData(package, path)Reads the contents of files stored in Python packages.

Variables

• name – ’package_data’

• return_type – str

read()

Parameters source (PackageDataSource) – The location of a file within a package.

Returns The contents stored in self.source.

Return type String

return_typealias of str

write(content, force=False)

Raises IOError when called. Writing to a Python package is not allowed.

6.3 resu.parsers

Resu expects IO to yield serialized data in need of parsing. To smooth out the differences between parsers, Resuprovides parsers with a uniform interface. For example, PyYAML provides a dump function while Python’s built in

6.3. resu.parsers 13

Page 18: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Resu Documentation, Release 0.0.0

json module provides a dumps function. Resu wraps both of these so that other functions can call dump withoutknowing what parser is being used.

class resu.parsers.ParserAbstract base class for data parsers.

Parser provides only the functions that resu needs to deserialize data.

Variables name – The format the parser parses.

dump(data)Return load data from string.

Parameters data (Object) – An object to serialize.

Returns Serialized data.

Return type String

load(data)Return load data from string.

Parameters data (String) – Serialized data in format.

Returns Deserialized data.

Return type Object

class resu.parsers.YamlParserParser for YAML files.

Variables name – ’yaml’

dump(data)

Parameters data (Object) – Data to serialize

Returns Data serialized as YAML.

Return type String

load(data)Deserialize YAML data.

Parameters data (String) – Serialized data in the YAML format.

Returns Deserialized data.

Return type Object

class resu.parsers.JsonParserParser for JSON files.

Variables name – ’json’

dump(data)Deserialize JSON data.

Parameters data (Object) – Data to serialize.

Returns Serialized JSON data.

Return type String

load(data)Deserialize JSON data.

Parameters data (String) – Serialized data in the JSON format.

14 Chapter 6. Python API Reference

Page 19: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Resu Documentation, Release 0.0.0

Returns Deserialized data.

Return type Object

6.4 resu.templates

This module stores the resu.templates.Template class and instantiates all templates included in Resu bydefault.

To add a template to Resu, one need only instantiate an instance of resu.templates.Template class. Theinstance will automatically be made available to the rest of Resu.

class resu.templates.Template(**kwargs)This modified namedtuple, contains metadata associated with a template. Most importantly, this includes thetemplates name and where to find the template. Other attributes are optional and default to sensible values,however, setting the location of an example of the input the resu.templates.Template expects is highlyrecommended.

Variables instances – Stores a list of all instances of resu.templates.Template thathave been instantiated.

static __new__(name, source, example=None, file_type=’html’, language=’jinja2’)This method is used to set default values for a namedtuple.

Parameters

• name (String) – Name of the template. Required.

• source (resu.io.Provider) – Location of the template. Required.

• example (resu.io.Provider) – Location of example input for the template. De-faults to None.

• file_type (String) – File type the template renders to. Defaults to ’html’.

• language (String) – Templating language used in the template. Defaults to ’jinja2’.

6.5 resu.template_engines

Resu provides a simple interface to support arbitrary templating languages.

class resu.template_engines.TemplateEngineAbstract base class for template engines.

Support for a templating engine should be added to Resu by implementing this class.

Variables name – The templating language that the engine can parse.

render(template, **kwargs)

Parameters

• template (str) – A template.

• kwargs (dict) – Context for the template.

Returns Rendered template.

Return type String.

6.4. resu.templates 15

Page 20: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Resu Documentation, Release 0.0.0

class resu.template_engines.Jinja2Engineresu.template_engines.TemplateEngine for Jinja2.

Variables name – ’jinja2’

render(template, **kwargs)

Parameters

• template (String) – A template.

• kwargs (Dictionary) – Context for the template.

Returns Template rendered with Jinja2.

Return type String

class resu.template_engines.MakoEngineresu.template_engines.TemplateEngine for Mako.

Variables name – ’mako’

render(template, **kwargs)

Parameters

• template (String) – A template.

• kwargs (Dictionary) – Context for the template.

Returns Template rendered with Mako.

Return type String

6.6 resu.converters

This module provides classes to convert between various file types.

class resu.converters.ConverterAbstract base class for file type converters.

Variables name – The name of the conversion provided. This must be a string in the form ‘<in-put_type> to <output_type>’.

convert(data)Take the contents of a file and return the equivalent in different file type.

Parameters data (String) – Contents of file in input format.

Returns Contents of file in output format.

Return type String

class resu.converters.HtmlToPdfConverts from HTML to PDF.

Variables name – html to pdf.

convert(data)Take the contents of an html file and return the pdf equivalent.

Parameters data (String) – Contents of the html file.

Returns Contents of file as a pdf.

Return type String

16 Chapter 6. Python API Reference

Page 21: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Resu Documentation, Release 0.0.0

6.7 resu.exceptions

Resu favors using exceptions from built into Python when there already exists an appropriately named excep-tion. For example, Resu will raise an IOError when asked to write data into an installed Python package, seeresu.io.PackageData. This module contains all exceptions that Resu needs to raise that are not included inPython.

class resu.exceptions.FeatureNotFoundThis exception should be raised whenever there is an attempt to access a feature that does not exist in Resu.Examples include trying to find a resu.parsers.Parser to parse an unsupported format like ini, or tryingto find a resu.io.Provider to save a document into a SQL database.

6.7. resu.exceptions 17

Page 22: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Resu Documentation, Release 0.0.0

18 Chapter 6. Python API Reference

Page 23: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

CHAPTER 7

Indices and tables

• genindex

• modindex

• search

19

Page 24: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Resu Documentation, Release 0.0.0

20 Chapter 7. Indices and tables

Page 25: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Python Module Index

rresu, 11resu.converters, 16resu.exceptions, 17resu.io, 12resu.parsers, 13resu.template_engines, 15resu.templates, 15

21

Page 26: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Resu Documentation, Release 0.0.0

22 Python Module Index

Page 27: Resu Documentation · Resu will be on available Pypi after the initial 0.1.0 release. 3.3Basic Usage Resu provides a flag to generate a default resume. resu -g This creates a default

Index

Symbols__new__() (resu.templates.Template static method), 15

Aavailable() (in module resu), 12

Bbuild() (in module resu), 11

Cconvert() (resu.converters.Converter method), 16convert() (resu.converters.HtmlToPdf method), 16Converter (class in resu.converters), 16

Ddump() (resu.parsers.JsonParser method), 14dump() (resu.parsers.Parser method), 14dump() (resu.parsers.YamlParser method), 14

FFeatureNotFound (class in resu.exceptions), 17File (class in resu.io), 13find() (in module resu), 12

Gget_example() (in module resu), 11

HHtmlToPdf (class in resu.converters), 16

JJinja2Engine (class in resu.template_engines), 15JsonParser (class in resu.parsers), 14

Lload() (resu.parsers.JsonParser method), 14load() (resu.parsers.Parser method), 14load() (resu.parsers.YamlParser method), 14

MMakoEngine (class in resu.template_engines), 16

PPackageData (class in resu.io), 13Parser (class in resu.parsers), 14Provider (class in resu.io), 12

Rread() (resu.io.File method), 13read() (resu.io.PackageData method), 13read() (resu.io.Provider method), 12render() (resu.template_engines.Jinja2Engine method),

16render() (resu.template_engines.MakoEngine method),

16render() (resu.template_engines.TemplateEngine

method), 15render_template() (in module resu), 11resu (module), 11resu.converters (module), 16resu.exceptions (module), 17resu.io (module), 12resu.parsers (module), 13resu.template_engines (module), 15resu.templates (module), 15return_type (resu.io.File attribute), 13return_type (resu.io.PackageData attribute), 13

TTemplate (class in resu.templates), 15TemplateEngine (class in resu.template_engines), 15

Wwrite() (resu.io.File method), 13write() (resu.io.PackageData method), 13write() (resu.io.Provider method), 12

YYamlParser (class in resu.parsers), 14

23