MCPcopy Index your code
hub / github.com/beetbox/beets / export

Method export

beetsplug/export.py:222–238  ·  view source on GitHub ↗
(self, data, **kwargs)

Source from the content-addressed store, hash-verified

220 super().__init__(file_path, file_mode, encoding)
221
222 def export(self, data, **kwargs):
223 # Creates the XML file structure.
224 library = ElementTree.Element("library")
225 tracks = ElementTree.SubElement(library, "tracks")
226 if data and isinstance(data[0], dict):
227 for index, item in enumerate(data):
228 track = ElementTree.SubElement(tracks, "track")
229 for key, value in item.items():
230 track_details = ElementTree.SubElement(track, key)
231 track_details.text = value
232 # Depending on the version of python the encoding needs to change
233 try:
234 data = ElementTree.tostring(library, encoding="unicode", **kwargs)
235 except LookupError:
236 data = ElementTree.tostring(library, encoding="utf-8", **kwargs)
237
238 self.out_stream.write(data)

Callers

nothing calls this directly

Calls 2

itemsMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected