Get the first tuning that satisfies the constraints. The instrument and description arguments are treated like case-insensitive prefixes. So search for 'bass' is the same is 'Bass Guitar'. Example: >>> get_tuning('guitar', 'standard')
(instrument, description, nr_of_strings=None, nr_of_courses=None)
| 407 | |
| 408 | |
| 409 | def get_tuning(instrument, description, nr_of_strings=None, nr_of_courses=None): |
| 410 | """Get the first tuning that satisfies the constraints. |
| 411 | |
| 412 | The instrument and description arguments are treated like |
| 413 | case-insensitive prefixes. So search for 'bass' is the same is |
| 414 | 'Bass Guitar'. |
| 415 | |
| 416 | Example: |
| 417 | >>> get_tuning('guitar', 'standard') |
| 418 | <StringTuning instance at 0x139ac20> |
| 419 | """ |
| 420 | searchi = str.upper(instrument) |
| 421 | searchd = str.upper(description) |
| 422 | keys = list(_known.keys()) |
| 423 | for x in keys: |
| 424 | if ( |
| 425 | searchi not in keys |
| 426 | and x.find(searchi) == 0 |
| 427 | or searchi in keys |
| 428 | and x == searchi |
| 429 | ): |
| 430 | for (desc, tun) in six.iteritems(_known[x][1]): |
| 431 | if desc.find(searchd) == 0: |
| 432 | if nr_of_strings is None and nr_of_courses is None: |
| 433 | return tun |
| 434 | elif nr_of_strings is not None and nr_of_courses is None: |
| 435 | if tun.count_strings() == nr_of_strings: |
| 436 | return tun |
| 437 | elif nr_of_strings is None and nr_of_courses is not None: |
| 438 | if tun.count_courses() == nr_of_courses: |
| 439 | return tun |
| 440 | else: |
| 441 | if ( |
| 442 | tun.count_courses() == nr_of_courses |
| 443 | and tun.count_strings() == nr_of_strings |
| 444 | ): |
| 445 | return tun |
| 446 | |
| 447 | |
| 448 | def get_tunings(instrument=None, nr_of_strings=None, nr_of_courses=None): |
nothing calls this directly
no test coverage detected