caellion-python-commons
caellion.pycommons.stringutil.unixpassword.UnixPasswordText Class Reference

This class provides methods to read and write to linux-style passwd/shadow files, ability to parse shadow-style lines into dicts and identifying password hashing algorithms used in linux-style hash format. More...

Public Member Functions

def __init__ (self, line_format, separator=":", newline="\n")
 Initialize parser. More...
 
def parse_line (self, line)
 Parses line according to line_format. More...
 
def create_line (self, fields)
 Creates string line from fieldset and line_format. More...
 
def add_new_line (self, fields)
 Prepares and adds new line to internal buffer. More...
 
def add_line_from_text (self, line)
 Parsed line and adds appropriate dict to internal buffer. More...
 
def dump_text (self)
 Prepares and returns text block representing all lines in internal buffer. More...
 
def load_text (self, textblock)
 Parses text block and adds its lines to internal buffer. More...
 

Public Attributes

 line_format
 
 separator
 
 newline
 
 text_lines
 

Static Public Attributes

list text_lines = []
 
list line_format = []
 
string separator = ":"
 
string newline = "\n"
 

Detailed Description

This class provides methods to read and write to linux-style passwd/shadow files, ability to parse shadow-style lines into dicts and identifying password hashing algorithms used in linux-style hash format.

Definition at line 46 of file unixpassword.py.

Constructor & Destructor Documentation

◆ __init__()

def caellion.pycommons.stringutil.unixpassword.UnixPasswordText.__init__ (   self,
  line_format,
  separator = ":",
  newline = "\n" 
)

Initialize parser.

Parameters
line_formatList of field names, field names have to be unique and cannot be empty. Not all fields have to be in format list if dumping text.
separatorString to use to separate fields in line
newlineString to use as line separator

Definition at line 56 of file unixpassword.py.

Member Function Documentation

◆ add_line_from_text()

def caellion.pycommons.stringutil.unixpassword.UnixPasswordText.add_line_from_text (   self,
  line 
)

Parsed line and adds appropriate dict to internal buffer.

Parameters
lineString representation of a given line

Definition at line 137 of file unixpassword.py.

◆ add_new_line()

def caellion.pycommons.stringutil.unixpassword.UnixPasswordText.add_new_line (   self,
  fields 
)

Prepares and adds new line to internal buffer.

Parameters
fieldsDict of field values to add to internal buffer as a line

Definition at line 129 of file unixpassword.py.

◆ create_line()

def caellion.pycommons.stringutil.unixpassword.UnixPasswordText.create_line (   self,
  fields 
)

Creates string line from fieldset and line_format.

Parameters
fieldsDict of field values to fill line with
Returns
String representation of give line data

Definition at line 108 of file unixpassword.py.

◆ dump_text()

def caellion.pycommons.stringutil.unixpassword.UnixPasswordText.dump_text (   self)

Prepares and returns text block representing all lines in internal buffer.

Returns
String block representing internal buffer. Empty string when no lines in buffer.

Definition at line 145 of file unixpassword.py.

◆ load_text()

def caellion.pycommons.stringutil.unixpassword.UnixPasswordText.load_text (   self,
  textblock 
)

Parses text block and adds its lines to internal buffer.

Parameters
textblockString to load into internal buffer

Definition at line 157 of file unixpassword.py.

◆ parse_line()

def caellion.pycommons.stringutil.unixpassword.UnixPasswordText.parse_line (   self,
  line 
)

Parses line according to line_format.

Parameters
lineThe line to be parsed
Returns
The dict representation of given line

Definition at line 85 of file unixpassword.py.

Member Data Documentation

◆ line_format [1/2]

list caellion.pycommons.stringutil.unixpassword.UnixPasswordText.line_format = []
static

Definition at line 52 of file unixpassword.py.

◆ line_format [2/2]

caellion.pycommons.stringutil.unixpassword.UnixPasswordText.line_format

Definition at line 80 of file unixpassword.py.

◆ newline [1/2]

string caellion.pycommons.stringutil.unixpassword.UnixPasswordText.newline = "\n"
static

Definition at line 54 of file unixpassword.py.

◆ newline [2/2]

caellion.pycommons.stringutil.unixpassword.UnixPasswordText.newline

Definition at line 82 of file unixpassword.py.

◆ separator [1/2]

string caellion.pycommons.stringutil.unixpassword.UnixPasswordText.separator = ":"
static

Definition at line 53 of file unixpassword.py.

◆ separator [2/2]

caellion.pycommons.stringutil.unixpassword.UnixPasswordText.separator

Definition at line 81 of file unixpassword.py.

◆ text_lines [1/2]

list caellion.pycommons.stringutil.unixpassword.UnixPasswordText.text_lines = []
static

Definition at line 51 of file unixpassword.py.

◆ text_lines [2/2]

caellion.pycommons.stringutil.unixpassword.UnixPasswordText.text_lines

Definition at line 83 of file unixpassword.py.


The documentation for this class was generated from the following file: