Template
Templates for configuring program function
Every program definition must inherit from the ProgDef
class
-
class
Progs.template.
ProgDef
(*args, **kwargs)
Template for program definitions.
Program definitions should inherit from this class
and should define settings in the config dictionary
(see already written definitions for example implementation).
If a program definition needs special handling, you may
override the set()
method.
-
do_save
()
Save the file and run pre/post-save hooks.
-
find_rules
(key, rules)
Return an array of rule objects that contain key.
-
gen_diff
()
Generate and print a diff of the change in config file.
-
get_config
()
Returns the config rule tree.
Can be overridden if necessary
-
get_default_path
()
Return the path to use for configuration.
This method must be overridden.
-
get_file_buffer
()
Check if filebuffer exists. If not, one is created.
-
get_file_path
()
Get file path from Settings.
If not found there, get from default path.
-
get_name
()
Returns the name of the program. Class name by default.
Can be overridden if necessary
-
get_proper_buffer
(initial_buffer, rule_obj)
Return rule_objs scope portion of initial_buffer.
-
init
(*args, **kwargs)
Define rules for configuration.
This method must set the self.config variable, which must
be of type common.ConfigElement. Usage is defined under the
Common and Example sections.
This method must be overridden.
-
is_installed
()
Check if the program is installed on the target system.
Returns a boolean.
This method must be overridden.
-
mk_backup
()
Save the old contents to a backup file
-
narrow_buffer
(section_obj, initial_buffer, recur=False, recpos=0, recdepth=0, excludes=None)
Return a tuple for the start and end of the scope.
Returns a tuple the start and end positions of the scope
within the initial_buffer: (startpos, endpos).
Exclude rule format: (depth, startpos, endpos).
-
pre_init
()
Pre-init defaults.
If you absolutely have to override __init__
then you must at least include pre_init in __init__.
-
save
()
Save the file.
This method must be overridden.
-
set
(key, value, section)
Set value to key.
Can be overridden if there are specific needs.