22import os
33import logging
44import base64
5+ import sys
56
67from com .vordel .es .xes import PortableESPKFactory
78from java .text import SimpleDateFormat
@@ -24,23 +25,40 @@ def __init__(self, field_key, value):
2425
2526class PropConfig :
2627 def __init__ (self , property_file_path_list ):
28+ stdin_loaded = False
2729 self .__properties = {}
2830 if not property_file_path_list :
2931 return
3032
3133 for property_file_path in property_file_path_list :
32- if not os .path .exists (property_file_path ):
33- raise ValueError ("Property file '%s' doesn't exist!" % (property_file_path ))
34+ properties = None
35+ if "-" == property_file_path :
36+ if stdin_loaded :
37+ # properties already loaded from stdin
38+ continue
39+ stdin_loaded = True
40+ logging .info ("Reading properties from stdin" )
41+ properties = json .load (sys .stdin )
42+ else :
43+ if not os .path .exists (property_file_path ):
44+ raise ValueError ("Property file '%s' doesn't exist!" % (property_file_path ))
3445
35- logging .info ("Reading property file '%s'" % (property_file_path ))
36- with open (property_file_path ) as property_file :
37- properties_json = json .load (property_file )
46+ logging .info ("Reading property file '%s'" % (property_file_path ))
47+ with open (property_file_path ) as property_file :
48+ properties_json = json .load (property_file )
3849
39- if "properties" not in properties_json :
40- raise ValueError ("File '%s' is not a valid property file; missing 'properties' attribute!" % (property_file_path ))
41-
42- for p in properties_json ["properties" ]:
43- self .__properties [p ] = properties_json ["properties" ][p ]
50+ if "properties" not in properties_json :
51+ raise ValueError ("File '%s' is not a valid property file; missing 'properties' attribute!" % (property_file_path ))
52+
53+ properties = properties_json ["properties" ]
54+
55+ # Add or overwrite properties
56+ for p in properties :
57+ if p not in self .__properties :
58+ logging .debug ("set property '%s' from '%s'" % (p , property_file_path ))
59+ else :
60+ logging .debug ("override property '%s' from '%s'" % (p , property_file_path ))
61+ self .__properties [p ] = properties [p ]
4462 return
4563
4664 def get_property (self , key ):
0 commit comments