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, see <http://www.gnu.org/licenses/>.
20 # Author: David Zeuthen <davidz@redhat.com>
22 import distutils
.version
38 def dots_to_hyphens(s
):
39 return s
.replace('.', '-')
41 def camel_case_to_uscore(s
):
44 prev_was_lower
= False
47 # Keep initial underscores in camel case
48 if initial
and c
== '_':
56 prev_was_lower
= False
66 if s
and s
.find('_') > 0:
70 def lookup_annotation(annotations
, key
):
77 def lookup_docs(annotations
):
78 s
= lookup_annotation(annotations
, 'org.gtk.GDBus.DocString')
84 def lookup_since(annotations
):
85 s
= lookup_annotation(annotations
, 'org.gtk.GDBus.Since')
91 def lookup_brief_docs(annotations
):
92 s
= lookup_annotation(annotations
, 'org.gtk.GDBus.DocString.Short')
98 def version_cmp_key(key
):
99 # If the 'since' version is 'UNRELEASED', compare higher than anything else
100 # If it is empty put a 0 in its place as this will
101 # allow LooseVersion to work and will always compare lower.
102 if key
[0] == 'UNRELEASED':
108 return (distutils
.version
.LooseVersion(v
), key
[1])