mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 22:00:22 -07:00
parent
2f33c1a1a1
commit
5553b20828
206 changed files with 1853 additions and 1870 deletions
|
@ -92,13 +92,20 @@ class ConfigLine(object):
|
|||
assert isinstance(obj, ConfigLine), 'child must be of type `ConfigLine`'
|
||||
self._children.append(obj)
|
||||
|
||||
|
||||
def ignore_line(text, tokens=None):
|
||||
for item in (tokens or DEFAULT_COMMENT_TOKENS):
|
||||
if text.startswith(item):
|
||||
return True
|
||||
|
||||
_obj_to_text = lambda x: [o.text for o in x]
|
||||
_obj_to_raw = lambda x: [o.raw for o in x]
|
||||
|
||||
def _obj_to_text(x):
|
||||
return [o.text for o in x]
|
||||
|
||||
|
||||
def _obj_to_raw(x):
|
||||
return [o.raw for o in x]
|
||||
|
||||
|
||||
def _obj_to_block(objects, visited=None):
|
||||
items = list()
|
||||
|
@ -110,6 +117,7 @@ def _obj_to_block(objects, visited=None):
|
|||
items.append(child)
|
||||
return _obj_to_raw(items)
|
||||
|
||||
|
||||
def dumps(objects, output='block', comments=False):
|
||||
if output == 'block':
|
||||
items = _obj_to_block(objects)
|
||||
|
@ -130,6 +138,7 @@ def dumps(objects, output='block', comments=False):
|
|||
|
||||
return '\n'.join(items)
|
||||
|
||||
|
||||
class NetworkConfig(object):
|
||||
|
||||
def __init__(self, indent=1, contents=None):
|
||||
|
@ -328,7 +337,7 @@ class NetworkConfig(object):
|
|||
offset = 0
|
||||
obj = None
|
||||
|
||||
## global config command
|
||||
# global config command
|
||||
if not parents:
|
||||
for line in lines:
|
||||
item = ConfigLine(line)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue