Exemplo n.º 1
0
def test_add_block_string():
    '''
    Add a plog block as as a string. This is converted to conform
    into a plog.line for a plog.block
    '''
    plog = Plog()
    plog.add_block('Device')
    assert len(plog.blocks) == 1
Exemplo n.º 2
0
def test_add_block():
    '''
    Add a basic empty block to the plog.blocks
    '''
    plog = Plog()
    block = PlogBlock()
    plog.add_block(block)
    assert len(plog.blocks) == 1
Exemplo n.º 3
0
def test_add_block_string():
    '''
    Add a plog block as as a string. This is converted to conform
    into a plog.line for a plog.block
    '''
    plog = Plog()
    plog.add_block('Device')
    assert len(plog.blocks) == 1
Exemplo n.º 4
0
def test_add_block():
    '''
    Add a basic empty block to the plog.blocks
    '''
    plog = Plog()
    block = PlogBlock()
    plog.add_block(block)
    assert len(plog.blocks) == 1
Exemplo n.º 5
0
block = PlogBlock('Device ID:', ref='Device')
block.header.ref = 'device_id'
block.footer = PlogLine('----------', ref='footer').anything()

lines = {}
lines['entry_address'] = PlogLine('IP address:')
lines['platform'] = PlogLine('Platform:')
lines['interface'] = PlogLine('Interface:')
lines['hold_time'] = PlogLine('Holdtime').maybe(' ').then(':')
lines['version'] = PlogLine('Version').maybe(' ').then(':').multiline()
lines['version'] = PlogLine('advertisement version:')
lines['duplex'] = PlogLine('Duplex:')
lines['power_drawn'] = PlogLine('Power drawn:')
lines['power_request_id'] = PlogLine('Power request id:')
lines['power_management_id'] = PlogLine('Power management id:')
lines['power_request_levels'] = PlogLine('Power request levels are:')
block.add_lines(**lines)

# new parser
f = open('test_data2.txt', 'r')
# plog = Plog(f, whitespace='|')
plog = Plog(f, whitespace='|', terminator=',')

# run it
plog.add_block(block)
blocks = plog.run()

for block in blocks:
    if block.valid():
        print block.as_dict()
Exemplo n.º 6
0

#
block = PlogBlock('Device ID:', ref='Device')
block.header.ref='device_id'

block.footer = PlogLine('----------', ref='footer').anything()

lines = {}
lines['entry_address'] = PlogLine('IP address:')
lines['platform'] = PlogLine('Platform:')
lines['interface'] = PlogLine('Interface:')
lines['hold_time'] = PlogLine('Holdtime').maybe(' ').then(':')
lines['version'] = PlogLine('Version').maybe(' ').then(':').multiline()
lines['ad_version'] = PlogLine('advertisement version:')

block.add_lines(**lines)


# new parser
f = open('test_data2.txt', 'r')
plog = Plog(f, whitespace='|')
# run it
plog.add_block(block)
blocks = plog.run()

for block in blocks:
	if block.valid():
		print block.as_dict()