Skip to content

Commit 4fd840f

Browse files
committed
Tweaked names so column is called COL_ID and not COL__ID
Signed-off-by: Jonas Kalderstam <jonas@kalderstam.se>
1 parent d60d860 commit 4fd840f

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

AndroidCodeGenerator/dbitem.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,19 @@ def __init__(self, sql_column):
9797

9898
@property
9999
def declare_const(self):
100-
return COL_CONST_TEMPLATE.format(self.column)
100+
return COL_CONST_TEMPLATE.format(self.const_name,
101+
self.var_name)
101102

102103
@property
103104
def var_name(self):
104105
return self.column.name
105106

106107
@property
107108
def const_name(self):
108-
return "COL_" + self.column.upper_name
109+
name = self.column.upper_name
110+
while name.startswith("_"):
111+
name = name[1:]
112+
return "COL_" + name
109113

110114
@property
111115
def java_type(self):
@@ -157,7 +161,7 @@ def declare_var(self):
157161
return "public {0.java_type} {0.var_name} {0.default_value}"\
158162
.format(self).strip() + ";"
159163

160-
COL_CONST_TEMPLATE = 'public static final String COL_{0.upper_name} = "{0.name}";'
164+
COL_CONST_TEMPLATE = 'public static final String {0} = "{1}";'
161165

162166
CLASS_TEMPLATE = '''package {pkg};
163167

AndroidCodeGenerator/generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Will print to the terminal what is needed to
33
be added to the Manifest.
44
5-
>>> g = Generator()
5+
>>> g = Generator(srcdir="./src", pkg="com.ex.app.db")
66
"""
77

88
import os, errno

0 commit comments

Comments
 (0)