Skip to content

get_track should check that the track exists #193

Description

@KB1RD

Describe the bug
get_track does no checks to ensure the track exists (in the XML file), so if the track cannot be found, an error with an unclear explanation will be thrown

To Reproduce
Steps to reproduce the behavior:

from pyrekordbox.rbxml import RekordboxXml
xml = RekordboxXml()
xml.get_track(Location="/does/not/exist")
...

The resulting error is:

TypeError: SubElement() argument 1 must be xml.etree.ElementTree.Element, not None

Expected behavior
Probably should just return None if there's no track found, or raise an error. The following inserted here should fix it:

return None if el is None else Track(element=el)

Environment

  • Pyrekordbox version: 0.4.4
  • Rekordbox version: N/A (not installed on my current computer)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions