5. Technical Documentation!
5.1. juniper
- class pyJuniper.juniper.Juniper(input_file, output_file=None)
Bases:
object
Juniper configuration file related class
- convert_to_hierarchy(to_file=True)
convert set configuration to hiearchical configuration
- Parameters:
to_file (bool, optional) – save output to file if True. Defaults to True.
- Returns:
list of output
- Return type:
lst
- convert_to_set(to_file=True)
convert configuration to set mode
- Parameters:
to_file (bool, optional) – save output to file if True. Defaults to True.
- Returns:
list of output
- Return type:
lst
- remove_remarks(to_file=True)
remove all remark lines from config
- Parameters:
to_file (bool, optional) – save output to file if True. Defaults to True.
- Returns:
list of output
- Return type:
lst
- pyJuniper.juniper.convert_to_set_from_captures(conf_file, output_file=None)
5.2. jset
- class pyJuniper.jset.JSet(input_file=None, input_list=None)
Bases:
Default
,STR
,Container
Juniper Standard to set converter
- property objVar
- read_input_file(input_file)
Reads input file and set input list –> None
- Parameters:
input_file (i/o) – input text file i/o
- read_input_list(input_list)
Reads input list as input list –> None
- Parameters:
input_list (list, tuple) – input in format of list or tuple
- set_input(input_file=None, input_list=None)
set input list from either provided input. –> None
- Parameters:
input_file (i/o) – input text file i/o
input_list (list, tuple) – input in format of list or tuple
- property to_set
reads juniper standard config and convert it to set, store it to output –> None
5.3. hierarchy
- class pyJuniper.hierarchy.Convert(dic, tabs, is_tailed=True, is_grouped=False, is_distributed=False, is_straight=False, is_straight_anyway=False, parent_prefix='', test=False)
Bases:
object
Converts Dicationary to Hierarchical config string
- add_to_str(s)
- property closure
Append Section closure to string
- clubbed_candidate_terminator_lines(dic_key, dic_value)
Clubbed candidates terminator words getting added to string
- property convert
start Converting dictionary to config string.
- Returns:
None
- Return type:
None
- distributed_candidate_terminator_lines(dic_key, dic_value)
Distributed terminator candidate words getting added to string
- exception(dic_key)
- property front_tabs
- grp_candidate_straight(dic_key, dic_value)
- grp_candidates_clubbed(dic_key, dic_value)
clubbed group config
- grp_candidates_distributed(dic_key, dic_value)
Distributed group config
- grp_has_suffix_candidate(dic_key, dic_value)
group config, which has suffix candidate.
- grp_nested(dic_key, dic_value)
nested group config
- grp_suffixes(dic_key, dic_value)
group config
- logic_groups(dic_key, dic_value)
section group selector logic
- Parameters:
dic_key (str) – string key to be pass on to selector logic
dic_value (dic) – dictionary for the key to be pass on to selector logic
- logic_terminators(dic_key, dic_value)
line terminators selector logic
- Parameters:
dic_key (str) – string key to be pass on to selector logic
dic_value (dic) – dictionary for the key to be pass on to selector logic
- Returns:
Returns True if any terminator logic matches found else None
- Return type:
bool
- property terminator_line
- update_front_tabs(n)
- update_prefix(k)
- class pyJuniper.hierarchy.Section(in_list, ordered=False)
Bases:
object
Configuration Section Creator
- add(ordered)
add the key value to self.dic go thru recursive lookup for dictionary tree
- Parameters:
ordered (bool) – dictionary to be ordered or not
- pyJuniper.hierarchy.excluded(dic, members, member_key)
Checks for matching key from provided dictionary (dic) in to members dictionary’s member_key, returns True if found any.
- Parameters:
dic ([type]) – input dictionary for which keys to be searched in to members dictinary members
members ([type]) – members dicationary to be looked in to.
member_key (str) – member key to be looked in to members dictionary
- Returns:
True if any excluded member found, None Else
- Return type:
bool
- pyJuniper.hierarchy.included(dic, members, member_key)
Checks for matching key from provided dictionary (dic) in to members dictionary’s member_key, returns True if found or member_key not found in members dict.
- Parameters:
dic ([type]) – input dictionary for which keys to be searched in to members dictinary members
members ([type]) – members dicationary to be looked in to.
member_key (str) – member key to be looked in to members dictionary
- Returns:
True if any excluded member found or member_key not in members, False Else
- Return type:
bool
- pyJuniper.hierarchy.li_li_words(in_str)
converts multiline string in to list of list of words.
- Parameters:
in_str (str) – Multiline string
- Returns:
list of list of words.
- Return type:
list
- pyJuniper.hierarchy.mysplit(line, by=' ')
split line by (default space), also retain the strings like descriptions as it is.
- Parameters:
line (str) – string line
by (character, optional) – Split by option. Defaults to ” “.
- Returns:
split line and return list
- Return type:
list
- pyJuniper.hierarchy.recursive_item_lookup(lili_words)
create and yields dictionary/list from provided list of list of words.
- Parameters:
lili_words (list) – input list of list of words
- Yields:
dict – yields dictionary item/value pairs
filter input list for the given word in index-0 position
- Parameters:
in_list (list) – input list of list
word (str) – word to be check in index-0 position.
- Returns:
filtered output list
- Return type:
list
- pyJuniper.hierarchy.section_dict(in_list, word, full_review=False)
create section dectionary from given input list for the selected word.
- Parameters:
in_list (list, str) – Input list or string
word (str) – selected word for which list to be search up on and generate dictionary
full_review (bool, optional) – go thru full list if set to true, else only check first match only. Defaults to False.
- Raises:
NotImplementedError – Unmatched input type for input.
- Returns:
dictionary with key equal input word and value as list of words from matched suffixes.
- Return type:
dict
- pyJuniper.hierarchy.zero_items(in_list)
Return all Zero (0) indexed Items from list of lists
- Parameters:
in_list (list) – input list of lists
- Returns:
all 0-index items from list of lists
- Return type:
list