Tblue/python-jproperties

Escape Character before a colon in properties file

97arushisharma opened this issue · 2 comments

When I try to store the properties file using the store function I have some extra escape() character added before every colon( : ) present in the values. Below is my properties file and the script I used :

job.properties :

#Mon Nov 04 07:08:00 UTC 2019
nameNode=hdfs://abcdefghijk
jobTracker=abcdefghijk:8050
startTime=2019-11-04T07:9Z
endTime=2219-09-24T08:10Z

Below is the script I used :

#!/usr/bin/python3

import os
from jproperties import Properties
import time

if name == "main":
with open("job.properties", "r+b") as f:
p = Properties()
p.load(f, "utf-8")
for value in p:
print(value)
ts = time.gmtime()
p["startTime"]=time.strftime("%Y-%m-%dT%H:{}Z", ts).format(ts.tm_min+1)
f.seek(0)
f.truncate(0)
p.store(f, encoding="utf-8")

Kindly let me know if I have done something wrong and how can I prevent it?

Tblue commented

Please see #3 for an explanation of this behaviour and a way to disable escape sequences in property values.

Got it. Thank you.