Replace sed with a small Python script to produce emote theme files.

Sun, 20 Dec 2020 05:30:08 -0600

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Sun, 20 Dec 2020 05:30:08 -0600
changeset 40665
865dddf7ccb8
parent 40664
52feb9438df4
child 40666
2d9bed1714c7

Replace sed with a small Python script to produce emote theme files.

Because sed may not be available on Windows.

Testing Done:
Compiled.

Reviewed at https://reviews.imfreedom.org/r/300/

meson.build file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/meson.build file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/gentheme.py file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/meson.build file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/meson.build file | annotate | diff | comparison | revisions
pidgin/pixmaps/meson.build file | annotate | diff | comparison | revisions
--- a/meson.build	Sun Dec 20 05:02:37 2020 -0600
+++ b/meson.build	Sun Dec 20 05:30:08 2020 -0600
@@ -82,8 +82,6 @@
 # Used for pkg-config files.
 pkgconfig = import('pkgconfig')
 
-sedpath = find_program('sed')
-
 # Storing build arguments
 meson.add_postconf_script('mkmesonconf.py')
 conf.set('HAVE_MESON_CONFIG', true)
--- a/pidgin/pixmaps/emotes/default/24/meson.build	Sun Dec 20 05:02:37 2020 -0600
+++ b/pidgin/pixmaps/emotes/default/24/meson.build	Sun Dec 20 05:30:08 2020 -0600
@@ -191,14 +191,9 @@
 	custom_target('default-theme',
 	    input : 'default.theme.in',
 	    output : 'theme',
-	    capture : true,
-	    command : [sedpath,
-	               '-e', 's/^_Name=/Name=/',
-	               '-e', 's/^_Description=/Description=/',
-	               '-e', 's/^_Author=/Author=/',
-	               '@INPUT@'],
-	   install : true,
-	   install_dir : pidginsmileypixdir)
+	    command : [smiley_theme_generator, '@INPUT@', '@OUTPUT@'],
+	    install : true,
+	    install_dir : pidginsmileypixdir)
 
 	install_data(SMILEYS, install_dir : pidginsmileypixdir)
 endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pixmaps/emotes/gentheme.py	Sun Dec 20 05:30:08 2020 -0600
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+#
+# Pidgin - Internet Messenger
+# Copyright (C) Pidgin Developers <devel@pidgin.im>
+#
+# Pidgin is the legal property of its developers, whose names are too numerous
+# to list here.  Please refer to the COPYRIGHT file distributed with this
+# source distribution.
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, see <https://www.gnu.org/licenses/>.
+
+import sys
+
+input = sys.argv[1]
+output = sys.argv[2]
+
+with open(input, 'rb') as r, open(output, 'wb') as w:
+    for line in r.readlines():
+        if line.startswith((b'_Name=', b'_Description=', b'_Author=')):
+            line = line[1:]
+        w.write(line)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pixmaps/emotes/meson.build	Sun Dec 20 05:30:08 2020 -0600
@@ -0,0 +1,4 @@
+smiley_theme_generator = find_program('gentheme.py')
+
+subdir('default/24')
+subdir('small/16')
--- a/pidgin/pixmaps/emotes/small/16/meson.build	Sun Dec 20 05:02:37 2020 -0600
+++ b/pidgin/pixmaps/emotes/small/16/meson.build	Sun Dec 20 05:30:08 2020 -0600
@@ -91,12 +91,7 @@
 	custom_target('small-theme',
 	    input : 'small.theme.in',
 	    output : 'theme',
-	    capture : true,
-	    command : [sedpath,
-	               '-e', 's/^_Name=/Name=/',
-	               '-e', 's/^_Description=/Description=/',
-	               '-e', 's/^_Author=/Author=/',
-	               '@INPUT@'],
+	    command : [smiley_theme_generator, '@INPUT@', '@OUTPUT@'],
 	    install : true,
 	    install_dir : pidginsmileypixdir)
 
--- a/pidgin/pixmaps/meson.build	Sun Dec 20 05:02:37 2020 -0600
+++ b/pidgin/pixmaps/meson.build	Sun Dec 20 05:30:08 2020 -0600
@@ -1,7 +1,6 @@
 pidginpixmapdir = get_option('datadir') / 'pixmaps/pidgin'
 
-subdir('emotes/default/24')
-subdir('emotes/small/16')
+subdir('emotes')
 
 if INSTALL_PIXMAPS
 	install_data('logo.png', 'arrow-down.xpm', 'arrow-left.xpm', 'arrow-right.xpm', 'arrow-up.xpm',

mercurial