| 281 | |
| 282 | |
| 283 | def choose_category(fn): |
| 284 | possible_known_categories = [] |
| 285 | for k, v in known_categories.items(): |
| 286 | if k in fn: |
| 287 | possible_known_categories.append(k) |
| 288 | |
| 289 | if len(possible_known_categories) > 0: |
| 290 | close_matches = difflib.get_close_matches(fn, possible_known_categories, n=1, cutoff=0.1) |
| 291 | if len(close_matches) > 0: |
| 292 | return known_categories[close_matches[0]] |
| 293 | else: |
| 294 | return known_categories[possible_known_categories[0]] |
| 295 | raise Exception('Need to add a category for %s to %s:known_categories' % |
| 296 | (fn, __file__)) |
| 297 | |
| 298 | |
| 299 | for f in sys.argv: |