changeset 31:4f9e701d76b4

core: expand now accepts extra arguments, which will be used in format
author Goffi <goffi@goffi.org>
date Sun, 21 Aug 2016 17:47:23 +0200
parents 8ea3f335307d
children fdaf914e2729
files src/cagou/core/cagou_main.py src/cagou/plugins/plugin_wid_chat.kv
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/cagou/core/cagou_main.py	Sun Aug 21 17:31:07 2016 +0200
+++ b/src/cagou/core/cagou_main.py	Sun Aug 21 17:47:23 2016 +0200
@@ -163,13 +163,16 @@
     def build(self):
         return CagouRootWidget(ProfileManager())
 
-    def expand(self, path):
+    def expand(self, path, *args, **kwargs):
         """expand path and replace known values
 
+        @param path(unicode): path to expand
+        @param *args: additional arguments used in format
+        @param **kwargs: additional keyword arguments used in format
         useful in kv. Values which can be used:
             - {media}: media dir
         """
-        return os.path.expanduser(path).format(media=self.host.media_dir)
+        return os.path.expanduser(path).format(*args, media=self.host.media_dir, **kwargs)
 
 
 class Cagou(QuickApp):
--- a/src/cagou/plugins/plugin_wid_chat.kv	Sun Aug 21 17:31:07 2016 +0200
+++ b/src/cagou/plugins/plugin_wid_chat.kv	Sun Aug 21 17:47:23 2016 +0200
@@ -61,7 +61,7 @@
                 Color:
                     rgba: 1, 1, 1, 1
                 BorderImage:
-                    source: app.expand("{media}") + "/misc/borders/{}.jpg".format("blue" if root.mess_data.own_mess else "gray")
+                    source: app.expand("{media}/misc/borders/{}.jpg", "blue" if root.mess_data.own_mess else "gray")
                     pos: self.pos
                     size: self.size
             id: mess_label