[recipes] Include segment titles when extracting recipe strings
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Include segment titles when extracting recipe strings
- Date: Thu, 4 May 2017 03:31:29 +0000 (UTC)
commit 3bc9d997d8919b7168a94d261ac8c56497cde023
Author: Matthias Clasen <mclasen redhat com>
Date: Wed May 3 22:36:17 2017 -0400
Include segment titles when extracting recipe strings
tools/recipe-extract.c | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/tools/recipe-extract.c b/tools/recipe-extract.c
index b40a284..e86c214 100644
--- a/tools/recipe-extract.c
+++ b/tools/recipe-extract.c
@@ -75,6 +75,28 @@ emit_ingredients (const char *s,
}
}
+static void
+emit_segments (const char *s)
+{
+ g_auto(GStrv) strv = NULL;
+ int i;
+
+ strv = g_strsplit (s, "\n", -1);
+
+ for (i = 0; strv[i]; i++) {
+ g_auto(GStrv) fields = NULL;
+
+ fields = g_strsplit (strv[i], "\t", -1);
+
+ if (g_strv_length (fields) != 4) {
+ g_printerr ("Wrong number of fields; ignoring line: %s\n", strv[i]);
+ continue;
+ }
+ if (fields[3][0] != 0)
+ g_print ("N_(\"%s\")\n", fields[3]);
+ }
+}
+
int
main (int argc, char *argv[])
{
@@ -93,7 +115,7 @@ main (int argc, char *argv[])
const char *optional_keys[] = {
"Notes",
NULL,
- };
+ };
const char *chef_keys[] = {
"Description",
NULL
@@ -174,6 +196,17 @@ main (int argc, char *argv[])
emit_string (s);
}
+ if (!extract_chefs) {
+ g_autofree char *s = NULL;
+ s = g_key_file_get_string (keyfile, groups[i], "Ingredients", &error);
+ if (!s) {
+ g_printerr ("Failed to get key '%s' for group '%s': %s\n",
"Ingredients", groups[i], error->message);
+ g_clear_error (&error);
+ }
+ else {
+ emit_segments (s);
+ }
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]