blob: e4d06dde3a4037d4831e8eb8ab98233c9def5536 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/usr/bin/python
#
# Copyright 2011, Infoblox, All Rights Reserved
#
# Open Source, see LICENSE
#
def attr(attributes):
"""
attr creates an XML string for any attribute that has a value
attr({'session-id': '2345', 'validation':'metadata'})
"""
if attributes and (type(attributes) == type({})): # check if it is a dictionary
__xml = ""
for label, value in attributes.items():
if value != None:
__xml += label + '="' + value + '" '
return __xml
else:
return ''
def link_ids(id1, id2):
"""
Takes two id arguments.
Returns XML for id1 or links id1 and id2 together
"""
if id1 and id2: # Both exist, so link them
#return '<link>' + id1 + id2 + '</link>'
return id1 + id2
else:
return id1
|