mirror of
				https://github.com/zokradonh/kopano-docker
				synced 2025-10-31 02:17:47 +00:00 
			
		
		
		
	New: KCCONF_ now allows (un)commenting
This commit is contained in:
		
							parent
							
								
									89b0351e0b
								
							
						
					
					
						commit
						d8852d46da
					
				| @ -14,7 +14,14 @@ def configkopano(configs): | |||||||
|         f.close() |         f.close() | ||||||
| 
 | 
 | ||||||
|         for key, newvalue in config.items(): |         for key, newvalue in config.items(): | ||||||
|             contents = re.sub(r"^\s*#?\s*{}\s*=.*".format(key), r"{} = {}".format(key, newvalue), contents, 0, re.MULTILINE) |             if key == "kccomment": | ||||||
|  |                 for line in newvalue: | ||||||
|  |                     contents = re.sub(r"^\s*" + re.escape(line), r"#{}".format(line), contents, 0, re.MULTILINE) | ||||||
|  |             elif key == "kcuncomment": | ||||||
|  |                 for line in newvalue: | ||||||
|  |                     contents = re.sub(r"^\s*#\s*" + re.escape(line) , line, contents, 0, re.MULTILINE) | ||||||
|  |             else: | ||||||
|  |                 contents = re.sub(r"^\s*#?\s*{}\s*=.*".format(key), r"{} = {}".format(key, newvalue), contents, 0, re.MULTILINE) | ||||||
| 
 | 
 | ||||||
|         with open(filename, "w") as f: |         with open(filename, "w") as f: | ||||||
|             f.write(contents) |             f.write(contents) | ||||||
| @ -22,6 +29,7 @@ def configkopano(configs): | |||||||
| 
 | 
 | ||||||
| def parseenvironmentvariables(prependingpath): | def parseenvironmentvariables(prependingpath): | ||||||
|     configs = dict() |     configs = dict() | ||||||
|  | 
 | ||||||
|     for name, value in os.environ.items(): |     for name, value in os.environ.items(): | ||||||
|         namematch = re.match(r"^KCCONF_([A-Z]+)_([A-Z0-9_]+)$", name) |         namematch = re.match(r"^KCCONF_([A-Z]+)_([A-Z0-9_]+)$", name) | ||||||
|         if namematch != None: |         if namematch != None: | ||||||
| @ -30,4 +38,20 @@ def parseenvironmentvariables(prependingpath): | |||||||
|                 configs[prependingpath + filename] = dict() |                 configs[prependingpath + filename] = dict() | ||||||
|             confkey = namematch.group(2).lower() |             confkey = namematch.group(2).lower() | ||||||
|             configs[prependingpath + filename][confkey] = value |             configs[prependingpath + filename][confkey] = value | ||||||
|  |         commentmatch = re.match(r"^KCCOMMENT_([A-Z]+)_([A-Z0-9_]+)$", name) | ||||||
|  |         if commentmatch != None: | ||||||
|  |             filename = commentmatch.group(1).lower() + ".cfg" | ||||||
|  |             try:  | ||||||
|  |                 configs[prependingpath + filename]["kccomment"].append(value) | ||||||
|  |             except IndexError: | ||||||
|  |                 configs[prependingpath + filename]["kccomment"] = [] | ||||||
|  |                 configs[prependingpath + filename]["kccomment"].append(value) | ||||||
|  |         uncommentmatch = re.match(r"^KCUNCOMMENT_([A-Z]+)_([A-Z0-9_]+)$", name) | ||||||
|  |         if uncommentmatch != None: | ||||||
|  |             filename = uncommentmatch.group(1).lower() + ".cfg" | ||||||
|  |             try:  | ||||||
|  |                 configs[prependingpath + filename]["kunccomment"].append(value) | ||||||
|  |             except IndexError: | ||||||
|  |                 configs[prependingpath + filename]["kunccomment"] = [] | ||||||
|  |                 configs[prependingpath + filename]["kunccomment"].append(value) | ||||||
|     return configs |     return configs | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user