Issue #1 new

add ability to retrieve propertyNames in the original order

Anonymous created an issue

This diff adds the ability to retrieve propertyNames in the original order:

{{{ --- pyjavaproperties.py.orig 2010-09-21 15:19:03.000000000 +0800 +++ pyjavaproperties.py 2010-09-21 15:20:39.000000000 +0800 @@ -157,7 +157,6 @@ key, value = line[:sepidx], line[sepidx+1:] else: key,value = line,'' - self._keyorder.append(key) self.processPair(key, value)

 def processPair(self, key, value):

@@ -259,11 +258,14 @@ else: raise TypeError,'both key and value should be strings!'

  • def propertyNames(self):
  • def propertyNames(self, ordered=False): """ Return an iterator over all the keys of the property dictionary, i.e the names of the properties """

  • return self._props.keys()

  • if ordered:
  • return self._keyorder
  • else:
  • return self._props.keys()

    def list(self, out=sys.stdout): """ Prints a listing of the properties to the }}}

I have to remove the self._keyorder.append(key) line, otherwise it will contain unformatted keys (e.g. with trailing white space).

Comments (0)

  1. Log in to comment