~bcurtiswx/ubuntu/precise/empathy/3.4.2.1-0ubuntu1

« back to all changes in this revision

Viewing changes to telepathy-yell/tools/glib-errors-enum-body-gen.py

  • Committer: Package Import Robot
  • Author(s): Ken VanDine
  • Date: 2012-03-05 15:14:36 UTC
  • mfrom: (1.1.87)
  • Revision ID: package-import@ubuntu.com-20120305151436-utnrdabb2ppp3kw1
Tags: 3.3.90.2-0ubuntu1
* New upstream release
* debian/control
  - added yelp-tools and libfarstream-0.1-dev build depends
  - bump build depends on libtelepathy-farstream-dev, and 
    libtelepathy-glib-dev
  - bumpded depends for telepathy-mission-control-5
  - removed telepathy-butterfly recommends, mission-control-5 ensures 
    telepathy-haze handles MSN now.
* debian/rules
  - enable empathy-av 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
 
3
 
import sys
4
 
import xml.dom.minidom
5
 
 
6
 
from libglibcodegen import NS_TP, camelcase_to_upper, get_docstring, \
7
 
        get_descendant_text
8
 
 
9
 
class Generator(object):
10
 
    def __init__(self, dom):
11
 
        self.dom = dom
12
 
        self.errors = self.dom.getElementsByTagNameNS(NS_TP, 'errors')[0]
13
 
 
14
 
    def do_header(self):
15
 
        print '/* Generated from the Telepathy spec\n'
16
 
        copyrights = self.errors.getElementsByTagNameNS(NS_TP, 'copyright')
17
 
        for copyright in copyrights:
18
 
            print get_descendant_text(copyright)
19
 
        license = self.errors.getElementsByTagNameNS(NS_TP, 'license')[0]
20
 
        print '\n' + get_descendant_text(license) + '\n*/'
21
 
 
22
 
    def do_enum_values(self):
23
 
        for error in self.errors.getElementsByTagNameNS(NS_TP, 'error'):
24
 
            print ''
25
 
            nick = error.getAttribute('name').replace(' ', '')
26
 
            name = camelcase_to_upper(nick.replace('.', ''))
27
 
            ns = error.parentNode.getAttribute('namespace')
28
 
            enum = 'TP_ERROR_' + name
29
 
            print '        /* ' + ns + '.' + name
30
 
            print '    ' + get_docstring(error)
31
 
            print '     */'
32
 
            print '        { %s, "%s", "%s" },' % (enum, enum, nick)
33
 
 
34
 
 
35
 
    def do_get_type(self):
36
 
        print """
37
 
#include <_gen/telepathy-errors.h>
38
 
 
39
 
GType
40
 
tp_error_get_type (void)
41
 
{
42
 
  static GType etype = 0;
43
 
  if (G_UNLIKELY (etype == 0))
44
 
    {
45
 
      static const GEnumValue values[] = {"""
46
 
        self.do_enum_values()
47
 
        print """\
48
 
      };
49
 
 
50
 
      etype = g_enum_register_static ("TpError", values);
51
 
    }
52
 
  return etype;
53
 
}
54
 
"""
55
 
 
56
 
    def __call__(self):
57
 
        self.do_header()
58
 
        self.do_get_type()
59
 
 
60
 
if __name__ == '__main__':
61
 
    argv = sys.argv[1:]
62
 
    Generator(xml.dom.minidom.parse(argv[0]))()