[fix] suggestion to fix #22
allows to handle unicode in label and description text
walzer
6 years ago
1133 | 1133 | label = "" |
1134 | 1134 | help_text = "" |
1135 | 1135 | # This tag is found in some descriptions |
1136 | desc = str(desc).replace("#br#", " <br>") | |
1136 | # desc = str(desc).replace("#br#", " <br>") | |
1137 | if not isinstance(desc, basestring): | |
1138 | desc = str(desc) | |
1139 | desc = desc.encode("utf8").replace("#br#", " <br>") | |
1137 | 1140 | # Get rid of dots in the end |
1138 | 1141 | if desc.endswith("."): |
1139 | desc = desc.rstrip(".") | |
1142 | desc = desc.rstrip(".") | |
1140 | 1143 | # Check if first word is a normal word and make it uppercase |
1141 | 1144 | if str(desc).find(" ") > -1: |
1142 | 1145 | first_word, rest = str(desc).split(" ", 1) |
1143 | 1146 | if str(first_word).islower(): |
1144 | # check if label has a quotient of the form a/b | |
1147 | # check if label has a quotient of the form a/b | |
1145 | 1148 | if first_word.find("/") != 1 : |
1146 | 1149 | first_word.capitalize() |
1147 | 1150 | desc = first_word + " " + rest |
1148 | label = desc | |
1151 | label = desc.decode("utf8") | |
1149 | 1152 | |
1150 | 1153 | # Try to split the label if it is too long |
1151 | 1154 | if len(desc) > 50: |