From 6d996bf1aa15f082be8f8543bafa8f0fb92d5670 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 6 Sep 2018 08:11:56 +1000 Subject: [PATCH] tools: add get_svg_fd() to ratbagc Missing from 6000688c30396a1334c6068d889437c96f1446b3 Fixes #31 Signed-off-by: Peter Hutterer --- tools/ratbagc.py.in | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/ratbagc.py.in b/tools/ratbagc.py.in index 893a45a2..21fdd1de 100644 --- a/tools/ratbagc.py.in +++ b/tools/ratbagc.py.in @@ -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.