Search tunings on instrument, strings, courses or a combination. The instrument is actually treated like a case-insensitive prefix. So asking for 'bass' yields the same tunings as 'Bass Guitar'; the string 'ba' yields all the instruments starting with 'ba'. Example: >>> get_tun
(instrument=None, nr_of_strings=None, nr_of_courses=None)
| 446 | |
| 447 | |
| 448 | def get_tunings(instrument=None, nr_of_strings=None, nr_of_courses=None): |
| 449 | """Search tunings on instrument, strings, courses or a combination. |
| 450 | |
| 451 | The instrument is actually treated like a case-insensitive prefix. So |
| 452 | asking for 'bass' yields the same tunings as 'Bass Guitar'; the string |
| 453 | 'ba' yields all the instruments starting with 'ba'. |
| 454 | |
| 455 | Example: |
| 456 | >>> get_tunings(nr_of_string = 4) |
| 457 | >>> get_tunings('bass') |
| 458 | """ |
| 459 | search = "" |
| 460 | if instrument is not None: |
| 461 | search = str.upper(instrument) |
| 462 | result = [] |
| 463 | keys = list(_known.keys()) |
| 464 | inkeys = search in keys |
| 465 | for x in keys: |
| 466 | if ( |
| 467 | instrument is None |
| 468 | or not inkeys |
| 469 | and x.find(search) == 0 |
| 470 | or inkeys |
| 471 | and search == x |
| 472 | ): |
| 473 | if nr_of_strings is None and nr_of_courses is None: |
| 474 | result += list(_known[x][1].values()) |
| 475 | elif nr_of_strings is not None and nr_of_courses is None: |
| 476 | result += [ |
| 477 | y |
| 478 | for y in six.itervalues(_known[x][1]) |
| 479 | if y.count_strings() == nr_of_strings |
| 480 | ] |
| 481 | elif nr_of_strings is None and nr_of_courses is not None: |
| 482 | result += [ |
| 483 | y |
| 484 | for y in six.itervalues(_known[x][1]) |
| 485 | if y.count_courses() == nr_of_courses |
| 486 | ] |
| 487 | else: |
| 488 | result += [ |
| 489 | y |
| 490 | for y in six.itervalues(_known[x][1]) |
| 491 | if y.count_strings() == nr_of_strings |
| 492 | and y.count_courses() == nr_of_courses |
| 493 | ] |
| 494 | return result |
| 495 | |
| 496 | |
| 497 | def get_instruments(): |
nothing calls this directly
no test coverage detected