key for sorting completions This does several things: - Demote any completions starting with underscores to the end - Insert any %magic and %%cellmagic completions in the alphabetical order by their name
(word)
| 418 | |
| 419 | |
| 420 | def completions_sorting_key(word): |
| 421 | """key for sorting completions |
| 422 | |
| 423 | This does several things: |
| 424 | |
| 425 | - Demote any completions starting with underscores to the end |
| 426 | - Insert any %magic and %%cellmagic completions in the alphabetical order |
| 427 | by their name |
| 428 | """ |
| 429 | prio1, prio2 = 0, 0 |
| 430 | |
| 431 | if word.startswith('__'): |
| 432 | prio1 = 2 |
| 433 | elif word.startswith('_'): |
| 434 | prio1 = 1 |
| 435 | |
| 436 | if word.endswith('='): |
| 437 | prio1 = -1 |
| 438 | |
| 439 | if word.startswith('%%'): |
| 440 | # If there's another % in there, this is something else, so leave it alone |
| 441 | if "%" not in word[2:]: |
| 442 | word = word[2:] |
| 443 | prio2 = 2 |
| 444 | elif word.startswith('%'): |
| 445 | if "%" not in word[1:]: |
| 446 | word = word[1:] |
| 447 | prio2 = 1 |
| 448 | |
| 449 | return prio1, word, prio2 |
| 450 | |
| 451 | |
| 452 | class _FakeJediCompletion: |
no outgoing calls
no test coverage detected
searching dependent graphs…