1 def is_camel_case(name):
2 for (i,char) in enumerate(name):
3 if (i>=1) and (name[i-1].islower()) and (char.isupper()):
7 def is_missing_underscore(fieldName):
8 if (fieldName == "kuser_id"):
12 {% for model in generator.all %}
13 pos = fieldName.find("{{ model }}")
14 if (pos > 0) and (fieldName[pos-1] != "_"):
20 def stylecheck_model_name(name):
21 if name.endswith("s"):
22 print "model '%s' name ends with 's'" % name
24 def stylecheck_field_name(modelName, fieldName):
25 if is_camel_case(fieldName):
26 print "field '%s.%s' has camelcase" % (modelName, fieldName)
27 if is_missing_underscore(fieldName):
28 print "field '%s.%s' is missing underscore" % (modelName, fieldName)
30 def stylecheck_field_plural(modelName, fieldName):
31 if is_camel_case(fieldName):
32 print "m2m field '%s.%s' has camelcase" % (modelName, fieldName)
33 if is_missing_underscore(fieldName):
34 print "m2m field '%s.%s' is missing underscore" % (modelName, fieldName)
37 {% for obj in generator.all %}
38 stylecheck_model_name("{{ obj.camel }}");
39 {% for ref in obj.refs %}
40 stylecheck_field_plural("{{ obj.camel }}", "{{ ref.plural }}");
42 {% for prop in obj.props %}
43 stylecheck_field_name("{{ obj.camel }}", "{{ prop }}");