The purpose of this function is to scrub the weird template mark-up out of strings that Veekun is using for their pokedex. Example: []{move:dragon-tail} will effect the opponents [HP]{mechanic:hp}. Becomes: dragon tail will effect the opponents HP. If you find t
(string)
| 130 | |
| 131 | |
| 132 | def scrub_str(string): |
| 133 | """ |
| 134 | The purpose of this function is to scrub the weird template mark-up out of strings |
| 135 | that Veekun is using for their pokedex. |
| 136 | Example: |
| 137 | []{move:dragon-tail} will effect the opponents [HP]{mechanic:hp}. |
| 138 | Becomes: |
| 139 | dragon tail will effect the opponents HP. |
| 140 | |
| 141 | If you find this results in weird strings please take a stab at improving or re-writing. |
| 142 | """ |
| 143 | groups = re.findall(GROUP_RGX, string) |
| 144 | for group in groups: |
| 145 | if group[0]: |
| 146 | sub = group[0] |
| 147 | else: |
| 148 | sub = group[1].split(":") |
| 149 | if len(sub) >= 2: |
| 150 | sub = sub[1] |
| 151 | else: |
| 152 | sub = sub[0] |
| 153 | sub = sub.replace("-", " ") |
| 154 | string = re.sub(SUB_RGX, sub, string, 1) |
| 155 | return string |
| 156 | |
| 157 | |
| 158 | ############## |
no outgoing calls
no test coverage detected