33import zipfile
44import os
55import shutil
6+ import sys
67
78
8- def create_settings_template (product_location : str , include_comments : bool ) -> None :
9+ def create_settings_template (product_location : str , include_comments : bool , verbose : bool ) -> None :
910 """
1011 Create complete list of settings for settings.ini file
1112
1213 :param product_location: Location of the product jar files to check for *preferences.properties files
1314 :param include_comments: Option to include comments for each setting in output file
15+ :param verbose: Verbose operation
1416 """
1517 # find all jar files so we can unzip jar and find preference files
1618 jar_file_list = glob .glob (product_location + "/*.jar" )
19+ if len (jar_file_list ) <= 0 :
20+ sys .stderr .write ("No *.jar files found in '{}'\n " .format (product_location ))
21+ sys .stderr .write ("Need to build sources?\n " )
22+ sys .exit (- 1 )
1723
1824 # temp directory to hold unzipped jar file contents (deleted at end of script)
1925 tmp_zip_dir = "./tmp-zip"
@@ -25,6 +31,8 @@ def create_settings_template(product_location: str, include_comments: bool) -> N
2531 out_f .write ("# Complete List of Available Preference Properties (Created by create_settings_template.py)\n " )
2632
2733 for jar_file in jar_file_list :
34+ if verbose :
35+ print ("| {}" .format (jar_file ))
2836 if not os .path .isdir (tmp_zip_dir ):
2937 os .makedirs (tmp_zip_dir )
3038 with zipfile .ZipFile (jar_file , 'r' ) as zip_ref :
@@ -34,6 +42,8 @@ def create_settings_template(product_location: str, include_comments: bool) -> N
3442
3543 package_str = ""
3644 for prop_file in prop_files :
45+ if verbose :
46+ print ("+ {}/{}" .format (jar_file , prop_file ).replace ("/./tmp-zip/" , "/" ))
3747 with open (prop_file , 'r' ) as file :
3848 lines = file .readlines ()
3949 for line in lines :
@@ -45,6 +55,8 @@ def create_settings_template(product_location: str, include_comments: bool) -> N
4555 out_f .write ("\n {0}\n {1}\n {0}\n " .format ("#" * (len (line )), line ))
4656 else :
4757 out_f .write ("\n {0}\n {1}\n {0}\n \n " .format ("#" * (len (line )), line ))
58+ if verbose :
59+ print ("| {} ({})" .format (" " * len (jar_file ), package_str ))
4860 elif "--------" in line :
4961 continue
5062 # assume equal sign means this is a property
@@ -68,8 +80,9 @@ def create_settings_template(product_location: str, include_comments: bool) -> N
6880
6981parser = argparse .ArgumentParser (description = "Create template of settings.ini with all available settings" )
7082parser .add_argument ("product" , type = str , nargs = '?' , default = "./target/lib" , help = "Location of product jars. Defaults to ./target/lib" )
71- parser .add_argument ("-c" , "--comments" , action = "store_true" , help = "Include settting comments in file" )
83+ parser .add_argument ("-c" , "--comments" , action = "store_true" , help = "Include setting comments in file" )
84+ parser .add_argument ("-v" , "--verbose" , action = "store_true" , help = "Verbose operation" )
7285
7386args = parser .parse_args ()
7487
75- create_settings_template (args .product , args .comments )
88+ create_settings_template (args .product , args .comments , args . verbose )
0 commit comments