plainbox.impl.secure.origin – origin objects¶
-
class
plainbox.impl.secure.origin.CommandLineTextSource(arg_name, arg_value)[source]¶ Bases:
plainbox.abc.ITextSourceA
ITextSourcedescribing text that originated arguments to main()Attr arg_name: The optional name of the argument that describes the arg_value Attr arg_value: The argument that was passed on command line (the actual text)
-
class
plainbox.impl.secure.origin.FileTextSource(filename)[source]¶ Bases:
plainbox.abc.ITextSourceA
ITextSourcesubclass indicating that text came from a file.Variables: filename – name of the file something comes from
-
class
plainbox.impl.secure.origin.JobOutputTextSource(job)[source]¶ Bases:
plainbox.abc.ITextSourceA
ITextSourcesubclass indicating that text came from job output.This class is used by
SessionState._gen_rfc822_records_from_io_log()to allow such (generated) jobs to be traced back to the job that generated them.Variables: job – plainbox.impl.job.JobDefinitioninstance that generated the text
-
class
plainbox.impl.secure.origin.Origin(source, line_start=None, line_end=None)[source]¶ Bases:
objectSimple class for tracking where something came from
This class supports “pinpointing” something in a block of text. The block is described by the source attribute. The actual range is described by line_start (inclusive) and line_end (exclusive).
Variables: - source – Something that describes where the text came frome. Technically it
should implement the
ITextSourceinterface. - line_start – The number of the line where the record begins. This can be None when the intent is to cover the whole file. This can also be equal to line_end (when not None) if the intent is to show a single line.
- 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.
-
just_file()[source]¶ create a new Origin that points to the whole file
Returns: A new Origin with line_end and line_start both set to None.
-
just_line()[source]¶ Create a new Origin that points to the start line
Returns: A new Origin with the end_line equal to start_line. This effectively makes the origin describe a single line.
-
line_end¶
-
line_start¶
-
mode()[source]¶ Compute the “mode” of this origin instance.
Returns: OriginMode.whole_file,OriginMode.single_lineorOriginMode.line_range.The mode tells if this instance is describing the whole file, a range of lines or just a single line. It is mostly used internally by the implementation.
-
relative_to(base_dir)[source]¶ Create a Origin with source relative to the specified base directory.
Parameters: base_dir – A base directory name Returns: A new Origin with source replaced by the result of calling relative_to(base_dir) on the current source iff the current source has that method, self otherwise. This method is useful for obtaining user friendly Origin objects that have short, understandable filenames.
-
source¶
- source – Something that describes where the text came frome. Technically it
should implement the
-
class
plainbox.impl.secure.origin.OriginMode[source]¶ Bases:
plainbox.impl.symbol.SymbolDefA symbol definition (which will become an enumeration in the near future) that describes all the possible “modes” an
Origincan operate in.-
classmethod
get_all_symbols()¶ Get all symbols defined by this symbol definition block
-
line_range= Symbol('line-range')¶
-
single_line= Symbol('single-line')¶
-
whole_file= Symbol('whole-file')¶
-
classmethod
-
class
plainbox.impl.secure.origin.PythonFileTextSource(filename)[source]¶ Bases:
plainbox.impl.secure.origin.FileTextSourceA
FileTextSourcesubclass 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 -
relative_to(base_dir)¶ Compute a FileTextSource with the filename being a relative path from the specified base directory.
Parameters: base_dir – A base directory name Returns: A new FileTextSource with filename relative to that base_dir
-
-
class
plainbox.impl.secure.origin.UnknownTextSource[source]¶ Bases:
plainbox.abc.ITextSourceA
ITextSourcesubclass 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
PythonFileTextSourcewith origin computed fromOrigin.get_caller_origin()