[turbine] Change the CamelCase logic to remove special cases
- From: Chris Lord <chrisl src gnome org>
- To: svn-commits-list gnome org
- Subject: [turbine] Change the CamelCase logic to remove special cases
- Date: Tue, 30 Jun 2009 13:33:23 +0000 (UTC)
commit a59b11030ca2348663a9ef0256ea9bac91b8df74
Author: Chris Lord <chris linux intel com>
Date: Tue Jun 30 14:31:29 2009 +0100
Change the CamelCase logic to remove special cases
Previously, GObject was special-cased, but other classes that use a
single capital letter as their prefix wouldn't work (such as
GInitiallyUnowned). This splits the logic for finding the prefix and the
class name, so that single-letter prefixes work as expected (hopefully).
src/turbine/__init__.py | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/src/turbine/__init__.py b/src/turbine/__init__.py
index 20419db..91cb05d 100755
--- a/src/turbine/__init__.py
+++ b/src/turbine/__init__.py
@@ -183,18 +183,16 @@ def guess_parent_params (entry, ui):
text = entry.get_text()
# special case GObject
- if (text == 'GObject'):
- s = 'G_TYPE_OBJECT'
- else:
+ s = ''
+ prefix = re.match ('[A-Z][a-z]*', text)
+ if (prefix):
+ prefix = prefix.group (0)
+ text = text.replace (prefix, '', 1)
m = re.findall ('[A-Z]+[a-z]*', text)
- s = ''
+ s = prefix + '_TYPE'
if (m):
- s = m[0] + '_TYPE'
- if (len(m) > 1):
- i = 1
- while (i < len(m)):
- s = s + "_" + m[i]
- i = i + 1
+ for i in m:
+ s = s + "_" + i
ui.get_object ('parent').set_text (s.upper())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]