[Libreoffice-commits] core.git: postprocess/CustomTarget_images.mk solenv/bin

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Fri Sep 11 16:26:02 UTC 2020


 postprocess/CustomTarget_images.mk |    1 
 solenv/bin/image-sort.py           |   43 ++++++++++++++++++++-----------------
 2 files changed, 25 insertions(+), 19 deletions(-)

New commits:
commit 03c65d3ed080661430d4af2424d8f525bef67c62
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Fri Jul 17 23:05:15 2020 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Fri Sep 11 18:25:21 2020 +0200

    image-sort: add --quiet option for build-tools
    
    Otherwise you'll get many warnings for missing images, because the
    cross-toolset target just builds some small part of LO.
    
    This also converts the program to use argparse.
    
    Change-Id: I22adda23ab3a25bced871a87d38373543cd5ae72
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102478
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/postprocess/CustomTarget_images.mk b/postprocess/CustomTarget_images.mk
index 0d2db4f7b2bb..42ddfdadd8c7 100644
--- a/postprocess/CustomTarget_images.mk
+++ b/postprocess/CustomTarget_images.mk
@@ -115,6 +115,7 @@ $(packimages_DIR)/sorted.lst : \
 	$(call gb_Helper_abbreviate_dirs, \
 		$(call gb_ExternalExecutable_get_command,python) \
 			$(SRCDIR)/solenv/bin/image-sort.py \
+			$(if $(filter build,$(gb_Side)),--quiet) \
 			$< $(INSTROOT)/$(gb_UIConfig_INSTDIR) $@)
 	$(call gb_Trace_EndRange,$(subst $(WORKDIR)/,,$@),PRL)
 
diff --git a/solenv/bin/image-sort.py b/solenv/bin/image-sort.py
index ce69db3e64a4..d45037e25c7f 100644
--- a/solenv/bin/image-sort.py
+++ b/solenv/bin/image-sort.py
@@ -18,17 +18,19 @@
 #
 
 import sys, os, re
+import argparse
 
 global_list = []
 global_hash = {}
-base_path = None
+args = None
 
 def read_icons(fname):
-    global base_path
+    global args
     images = []
-    full_path = os.path.join(base_path, fname)
+    full_path = os.path.join(args.base_path, fname)
     if not os.path.exists(full_path):
-        print("Skipping non-existent {}\n".format(full_path))
+        if not args.quiet:
+            print("Skipping non-existent {}\n".format(full_path), file=sys.stderr)
         return images
     with open(full_path) as fp:
         for line in fp:
@@ -116,34 +118,37 @@ def chew_controlfile(ifile):
         else:
             filelist.append(line)
 
-if len(sys.argv) == 1:
-    print("image-sort <image-sort.lst> /path/to/OOOo/source/root\n")
-    sys.exit(1)
-
+parser = argparse.ArgumentParser()
 # where the control file lives
-control = sys.argv[1]
+parser.add_argument('control_file', metavar='image-sort.lst', type=open,
+                    help='the sort control file')
 # where the uiconfigs live
-base_path = sys.argv[2]
-# output
-if len(sys.argv) > 3:
-    output = open(sys.argv[3], 'w')
+parser.add_argument('base_path', metavar='directory',
+                    help='path to the UIConfigs directory')
+parser.add_argument('output', metavar='output file', type=argparse.FileType('w'),
+                    nargs='?', default=None, help='optionally write to this output file')
+parser.add_argument("-q", "--quiet", action="store_true",
+                    help="don't print status messages to stdout")
+
+args = parser.parse_args()
+
+if args.output is not None:
     close_output = True
 else:
-    output = sys.stdout
+    args.output = sys.stdout
     close_output = False
 
-with open(control) as controlfile:
-    chew_controlfile(controlfile)
+chew_controlfile(args.control_file)
 
 for icon in global_list:
     if not icon.startswith('sc_'):
-        output.write(icon + "\n")
+        args.output.write(icon + "\n")
 
 for icon in global_list:
     if icon.startswith('sc_'):
-        output.write(icon + "\n")
+        args.output.write(icon + "\n")
 
 if close_output:
-    output.close()
+    args.output.close()
 
 # dnl vim:set shiftwidth=4 softtabstop=4 expandtab:


More information about the Libreoffice-commits mailing list