Module cli :: Class z_gp_class
[hide private]
[frames] | no frames]

Class z_gp_class

source code


Global preferences saver class. Tuned for pybag using (handle roots).

Instance Methods [hide private]
 
__init__(self)
Initialize base class.
source code
 
load(self, path=None)
Load configuration file.
source code
 
save(self, path=None, patht=None)
Write configuration to file.
source code
list of str
getroots(self, only_default=False)
Get list of roots name registered in config [root] section.
source code
 
getrootsbag(self)
Get list of roots bag path registered in config [root] section.
source code
list or str
getrootspath(self, rs)
Return roots path relative to bag and os specific.
source code
list or str
getrootsflag(self, rs)
Return roots path.
source code
str
addroot(self)
Add root in roots list in [root] section.
source code
 
delroot(self, rn)
Remove root registration and its root section.
source code
str or None
findroot(self, bagpath)
Find root for bagpath.
source code
 
getrootbag(self, rootname)
Return root bag path in os specific.
source code
 
getopt(self, rn, opt, create=False, default=u'')
Get option opt in root name rn.
source code
 
setopt(self, rn, opt, value='')
Set option opt in root name rn.
source code
 
delopt(self, rn, opt)
Delete option opt.
source code
 
dumpstr(self)
Debug dump config to log.
source code
 
dump(self)
Debug dump config to log.
source code

Inherited from ConfigParser.SafeConfigParser: set

Inherited from ConfigParser.SafeConfigParser (private): _interpolate, _interpolate_some

Inherited from ConfigParser.ConfigParser: get, items

Inherited from ConfigParser.ConfigParser (private): _interpolation_replace

Inherited from ConfigParser.RawConfigParser: add_section, defaults, getboolean, getfloat, getint, has_option, has_section, options, optionxform, read, readfp, remove_option, remove_section, sections, write

Inherited from ConfigParser.RawConfigParser (private): _get, _read

Class Variables [hide private]

Inherited from ConfigParser.SafeConfigParser (private): _interpvar_re

Inherited from ConfigParser.ConfigParser (private): _KEYCRE

Inherited from ConfigParser.RawConfigParser: OPTCRE, OPTCRE_NV, SECTCRE

Inherited from ConfigParser.RawConfigParser (private): _boolean_states

Method Details [hide private]

__init__(self)
(Constructor)

source code 

Initialize base class.

Overrides: ConfigParser.RawConfigParser.__init__

load(self, path=None)

source code 

Load configuration file.

Load "pybag.cfg" from given path or from dir_cfg.

Parameters:
  • path (str = None) - Path to configuration file. If None (default) then use dir_cfg path.

save(self, path=None, patht=None)

source code 

Write configuration to file.

Also set "version" option in "root" section to current programm version.

Parameters:
  • path (str = None) - Path to save configuration file. If None (default) then use dir_cfg path.
  • patht (str = None) - Path to save backup configuration file. If None (default) then use "path"+"~".
Returns:
See z_r for result.

getroots(self, only_default=False)

source code 

Get list of roots name registered in config [root] section. Options with name "r####" in [root] section.

Parameters:
  • only_default (bool) - True for get only default.
Returns: list of str
List of registered roots.

getrootspath(self, rs)

source code 

Return roots path relative to bag and os specific.

If "rs" is list then return roots path in list. If "rs" is string (one root) then return path in string. Roots path return in OS specific, relative to pybagfiles. If no roots then return empty list or empty string.

Parameters:
  • rs (list or str) - Roots names in list or single root name in string.
Returns: list or str
Roots path in OS specific.

getrootsflag(self, rs)

source code 

Return roots path.

If "rs" is list then return roots flag in list. If "rs" is string (one root) then return flag in string.

Parameters:
  • rs (list or str) - Roots names in list or single root name in string.
Returns: list or str
Roots flag.

addroot(self)

source code 

Add root in roots list in [root] section. New root value set to empty string.

Returns: str
Name of new root.

delroot(self, rn)

source code 

Remove root registration and its root section. If no such root then do nothing.

Parameters:
  • rn (str) - Root name.

findroot(self, bagpath)

source code 

Find root for bagpath.

Parameters:
  • bagpath (str) - Bag path for syncronized files.
Returns: str or None
Root name or None if root not found.

getrootbag(self, rootname)

source code 

Return root bag path in os specific. Return empty string if no such root name.

getopt(self, rn, opt, create=False, default=u'')

source code 

Get option opt in root name rn. If option absent in rn section then try search in "root" section. If no option found and create == True then create new option (and section if need) and set value to default. If no option found and create == False then return default value.

Parameters:
  • rn (str) - Root name. May be "r####" or "root".
  • opt (str) - Option name.
  • create (bool = {False}) - If True then create new section and option if need. Default False.
  • default (str = { Empty string }) - Default value.
Returns:
Value if has or created option, overwise None. @rtype str or None

setopt(self, rn, opt, value='')

source code 

Set option opt in root name rn. If no such option then create new option (root must be registered) and set value.

Parameters:
  • rn (str) - Root name. May be "r####" or "root".
  • opt (str) - Option name.
  • value (str) - Value.

delopt(self, rn, opt)

source code 

Delete option opt.

Parameters:
  • rn (str) - Root name. May be "r####" or "root".
  • opt (str) - Option name.