Closed HPotter closed 9 years ago
Oh, sorry, I missed the fact that you're using pyjavaproperties. So it looks like it isn't a bug of anyconfig, but a bug of pyjavaproperties
Thanks for your report!
Since 0.2.0, python-anyconfig supports properties files w/o pyjavaproperties. So if any issues exist when parsing .properties files, it's possible bug in python-anyconfig itself, not pyjavaproperties.
Anyway, it looks worked as far as I tested like the followings. Could you please let me know the details of you problem?
In [1]: import anyconfig
In [2]: open("/tmp/t.properties", 'w').write("""
...: agent.work.dir=D\:\\BuildAgent\\work
...: """)
In [3]: cat /tmp/t.properties
agent.work.dir=D\:\BuildAgent\work
In [4]: f="/tmp/t.properties"
In [5]: d = anyconfig.load(f)
In [6]: d
Out[6]: {'agent.work.dir': 'D\\:\\BuildAgent\\work'}
In [7]: d["agent.work.dir"]
Out[7]: 'D\\:\\BuildAgent\\work'
In [8]: print d["agent.work.dir"]
D\:\BuildAgent\work
In [9]:
I've tried your code sample, and I've got same results. But my Java "test" code for file /tmp/t.properties
prints this:
agent.work.dir -> D:BuildAgentwork
I suggest that your test's step №2 probably must be like this:
In [2]: open("/tmp/t.properties", 'w').write(r"""
...: agent.work.dir=D\:\\BuildAgent\\work
...: """)
(note the raw string)
UPD my version is 0.3.0, but I have pyjavaproperties installed in the same virtualenv, does it matters? UPD2 uninstalled pyjavaproperties, got same results
oh, I see. The value parsed from .properties files must be un-escaped. Wait for a while, please. I try to fix it until the next weekend if I have some time.
Excuse me to very late response. I could spend time to look into this and pushed possible fixes a minute ago. Could you please take a look at it ? I think I could fix it but I want to make sure that.
Here is a test session log:
In [1]: import sys,os
In [2]: sys.path.insert(0, os.curdir)
In [3]: import anyconfig
In [4]: fn = "/tmp/test.properties"
In [5]: open(fn, 'w').write(r"""
...: agent.work.dir=D\:\\BuildAgent\\work
...: """)
In [6]: cat /tmp/test.properties
agent.work.dir=D\:\\BuildAgent\\work
In [7]: d = anyconfig.load(fn)
In [8]: d
Out[8]: {'agent.work.dir': 'D:\\BuildAgent\\work'}
In [9]: d["agent.work.dir"]
Out[9]: 'D:\\BuildAgent\\work'
In [10]: print(d["agent.work.dir"])
D:\BuildAgent\work
In [11]: print(anyconfig.dumps(d, ac_parser="properties"))
agent.work.dir = D\:\\BuildAgent\\work
In [12]:
Oh, sorry, I've missed a letter from github with your comments.
It looks like the problem is resolved - all my test files are parsed correctly. I'm looking forward to get the latest module version from pypi.
Thank you very much for your help!
Thanks for your confirmation! Now I've started for the next release.
Hello!
[sorry for my bad english]
I'm going to use python-anyconfig for parsing teamcity properties file
It has, e.g., line:
I wrote sample Java script:
, and it outputs
But anyconfig script
outputs