File Split-out-UI_ShowFile-from-UI_Changes.patch of Package apparmor.15509

From bb3803b931683c841768ba6256c29e16bebd2eeb Mon Sep 17 00:00:00 2001
From: Christian Boltz <apparmor@cboltz.de>
Date: Wed, 6 May 2020 23:16:47 +0200
Subject: [PATCH] Split off UI_ShowFile() from UI_Changes

UI_ShowFile() is more generic and can be used to display various (text)
files, not only diffs.

---
 utils/apparmor/ui.py |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

--- a/utils/apparmor/ui.py
+++ b/utils/apparmor/ui.py
@@ -254,13 +254,16 @@
     else:
       difftemp = generate_diff_with_comments(oldprofile, newprofile)
       header = 'View Changes with comments'
+    UI_ShowFile(header, difftemp.name)
+    difftemp.close()
+
+def UI_ShowFile(header, filename):
     if UI_mode == 'json':
-        jsonout = {'dialog': 'changes', 'header':header, 'filename': difftemp.name}
+        jsonout = {'dialog': 'changes', 'header':header, 'filename': filename}
         write_json(jsonout)
         json_response('changes')["response"]  # wait for response to delay deletion of difftemp (and ignore response content)
     else:
-      subprocess.call('less %s' % difftemp.name, shell=True)
-    difftemp.close()
+      subprocess.call(['less',filename])
 
 CMDS = {'CMD_ALLOW': _('(A)llow'),
         'CMD_OTHER': _('(M)ore'),
openSUSE Build Service is sponsored by