(class_, option_description)
| 193 | |
| 194 | @classmethod |
| 195 | def parse(class_, option_description): |
| 196 | short, long, argcount, value = None, None, 0, False |
| 197 | options, _, description = option_description.strip().partition(' ') |
| 198 | options = options.replace(',', ' ').replace('=', ' ') |
| 199 | for s in options.split(): |
| 200 | if s.startswith('--'): |
| 201 | long = s |
| 202 | elif s.startswith('-'): |
| 203 | short = s |
| 204 | else: |
| 205 | argcount = 1 |
| 206 | if argcount: |
| 207 | matched = re.findall('\[default: (.*)\]', description, flags=re.I) |
| 208 | value = matched[0] if matched else None |
| 209 | return class_(short, long, argcount, value) |
| 210 | |
| 211 | def single_match(self, left): |
| 212 | for n, p in enumerate(left): |
no outgoing calls