~ubuntu-branches/ubuntu/precise/gst-plugins-bad0.10/precise-proposed

« back to all changes in this revision

Viewing changes to common/gst-xmlinspect.py

Tags: upstream-0.10.5.3
Import upstream version 0.10.5.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
INDENT_SIZE = 2
16
16
 
17
17
# all templates
 
18
 
 
19
PAD_TEMPLATE = """<caps>
 
20
  <name>%(name)s</name>
 
21
  <direction>%(direction)s</direction>
 
22
  <presence>%(presence)s</presence>
 
23
  <details>%(details)s</details>
 
24
</caps>"""
 
25
 
18
26
ELEMENT_TEMPLATE = """<element>
19
27
  <name>%(name)s</name>
20
28
  <longname>%(longname)s</longname>
21
29
  <class>%(class)s</class>
22
30
  <description>%(description)s</description>
23
31
  <author>%(author)s</author>
 
32
  <pads>
 
33
%(pads)s
 
34
  </pads>
24
35
</element>"""
25
36
 
26
37
PLUGIN_TEMPLATE = """<plugin>
50
61
def get_offset(indent):
51
62
    return " " * INDENT_SIZE * indent
52
63
 
 
64
def output_pad_template(pt, indent=0):
 
65
    print  "PAD TEMPLATE", pt.name_template
 
66
    paddir = ("unknown","source","sink")
 
67
    padpres = ("always","sometimes","request")
 
68
    
 
69
    d = {
 
70
      'name':        xmlencode(pt.name_template),
 
71
      'direction':   xmlencode(paddir[pt.direction]),
 
72
      'presence':    xmlencode(padpres[pt.presence]),
 
73
      'details':     xmlencode(pt.static_caps.string),
 
74
    }
 
75
    block = PAD_TEMPLATE % d
 
76
 
 
77
    offset = get_offset(indent)
 
78
    return offset + ("\n" + offset).join(block.split("\n"))
 
79
    
53
80
def output_element_factory(elf, indent=0):
54
81
    print  "ELEMENT", elf.get_name()
 
82
 
 
83
    padsoutput = []
 
84
    padtemplates = elf.get_static_pad_templates()
 
85
    for padtemplate in padtemplates:
 
86
        padsoutput.append(output_pad_template(padtemplate, indent))
 
87
 
55
88
    d = {
56
89
        'name':        xmlencode(elf.get_name()),
57
90
        'longname':    xmlencode(elf.get_longname()),
58
91
        'class':       xmlencode(elf.get_klass()),
59
92
        'description': xmlencode(elf.get_description()),
60
93
        'author':      xmlencode(elf.get_author()),
 
94
        'pads': "\n".join(padsoutput),
61
95
    }
62
96
    block = ELEMENT_TEMPLATE % d
63
 
    
 
97
 
64
98
    offset = get_offset(indent)
65
99
    return offset + ("\n" + offset).join(block.split("\n"))
66
100