plainbox.impl.secure.rfc822 – RFC822 parser

Implementation of rfc822 serializer and deserializer.

Warning

THIS MODULE DOES NOT HAVE STABLE PUBLIC API

class plainbox.impl.secure.rfc822.FileTextSource(filename)[source]

A ITextSource subclass indicating that text came from a file.

Variables:filename – name of the file something comes from
class plainbox.impl.secure.rfc822.Origin(source, line_start, line_end)[source]

Simple class for tracking where something came from

Variables:
  • source – something that describes where the text came frome, technically it should be a ITextSource subclass but that interface defines just the intent, not any concrete API.
  • line_start – the number of the line where the record begins
  • line_end – the number of the line where the record ends
classmethod get_caller_origin(back=0)[source]

Create an Origin instance pointing at the call site of this method.

line_end
line_start
source
class plainbox.impl.secure.rfc822.PythonFileTextSource(filename)[source]

A FileTextSource subclass indicating the file was a python file.

It implements no differences but in some context it might be helpful to differentiate on the type of the source field in the origin of a job definition record.

Variables:filename – name of the python filename that something comes from
class plainbox.impl.secure.rfc822.RFC822Record(data, origin=None)[source]

Class for tracking RFC822 records

This is a simple container for the dictionary of data. Each instance also holds the origin of the data

data[source]

The data set (dictionary)

dump(stream)[source]

Dump this record to a stream

origin[source]

The origin of the record.

exception plainbox.impl.secure.rfc822.RFC822SyntaxError(filename, lineno, msg)[source]

SyntaxError subclass for RFC822 parsing functions

class plainbox.impl.secure.rfc822.UnknownTextSource[source]

A ITextSource subclass indicating that the source of text is unknown.

This instances of this class are constructed by gen_rfc822_records() when no explicit source is provided and the stream has no name. The serve as non-None values to prevent constructing PythonFileTextSource with origin computed from Origin.get_caller_origin()

plainbox.impl.secure.rfc822.gen_rfc822_records(stream, data_cls=<class 'dict'>, source=None)[source]

Load a sequence of rfc822-like records from a text stream.

Parameters:
  • stream – A file-like object from which to load the rfc822 data
  • data_cls – The class of the dictionary-like type to hold the results. This is mainly there so that callers may pass collections.OrderedDict.
  • source – A plainbox.abc.ITextSource subclass instance that describes where stream data is coming from. If None, it will be inferred from the stream (if possible). Specialized callers should provider a custom source object to allow developers to accurately keep track of where (possibly problematic) RFC822 data is coming from. If this is None and inferring fails then all of the loaded records will have a None origin.

Each record consists of any number of key-value pairs. Subsequent records are separated by one blank line. A record key may have a multi-line value if the line starts with whitespace character.

Returns a list of subsequent values as instances RFC822Record class. If the optional data_cls argument is collections.OrderedDict then the values retain their original ordering.

plainbox.impl.secure.rfc822.load_rfc822_records(stream, data_cls=<class 'dict'>, source=None)[source]

Load a sequence of rfc822-like records from a text stream.

Parameters:
  • stream – A file-like object from which to load the rfc822 data
  • data_cls – The class of the dictionary-like type to hold the results. This is mainly there so that callers may pass collections.OrderedDict.
  • source – A plainbox.abc.ITextSource subclass instance that describes where stream data is coming from. If None, it will be inferred from the stream (if possible). Specialized callers should provider a custom source object to allow developers to accurately keep track of where (possibly problematic) RFC822 data is coming from. If this is None and inferring fails then all of the loaded records will have a None origin.

Each record consists of any number of key-value pairs. Subsequent records are separated by one blank line. A record key may have a multi-line value if the line starts with whitespace character.

Returns a list of subsequent values as instances RFC822Record class. If the optional data_cls argument is collections.OrderedDict then the values retain their original ordering.

Previous topic

plainbox.impl.secure.qualifiers – Job Qualifiers

Next topic

plainbox.impl.session – session handling

This Page