tools: add get_svg_fd() to ratbagc

Missing from 6000688c30

Fixes #31

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2018-09-06 08:11:56 +10:00
committed by Benjamin Tissoires
parent 34fbfe105c
commit 6d996bf1aa

View File

@@ -284,6 +284,18 @@ class RatbagdDevice(metaclass=MetaRatbag):
"""
return os.path.join(LIBRATBAG_DATA_DIR, theme, libratbag.ratbag_device_get_svg_name(self._device))
def get_svg_fd(self, theme):
"""Returns a File-like object to the SVG for the given theme, or
raises FileNotFoundError if the file is not available.
The theme must be one of org.freedesktop.ratbag1.Manager.Themes. The
theme 'default' is guaranteed to be available (but the file itself
may not be).
@param theme The theme from which to retrieve the SVG, as str
"""
return open(self.get_svg(theme))
def commit(self, callback=None):
"""Commits all changes made to the device.