3 # GDBus - GLib D-Bus Library
5 # Copyright (C) 2008-2011 Red Hat, Inc.
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General
18 # Public License along with this library; if not, write to the
19 # Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 # Boston, MA 02111-1307, USA.
22 # Author: David Zeuthen <davidz@redhat.com>
24 import distutils
.version
40 def dots_to_hyphens(s
):
41 return s
.replace('.', '-')
43 def camel_case_to_uscore(s
):
46 prev_was_lower
= False
49 # Keep initial underscores in camel case
50 if initial
and c
== '_':
58 prev_was_lower
= False
68 if s
and s
.find('_') > 0:
72 def lookup_annotation(annotations
, key
):
79 def lookup_docs(annotations
):
80 s
= lookup_annotation(annotations
, 'org.gtk.GDBus.DocString')
86 def lookup_since(annotations
):
87 s
= lookup_annotation(annotations
, 'org.gtk.GDBus.Since')
93 def lookup_brief_docs(annotations
):
94 s
= lookup_annotation(annotations
, 'org.gtk.GDBus.DocString.Short')
100 def version_cmp_key(key
):
101 # If the 'since' version is empty put a 0 in its place as this will
102 # allow LooseVersion to work and will always compare lower.
103 v
= key
[0] if key
[0] else '0'
104 return (distutils
.version
.LooseVersion(v
), key
[1])