Commits

4kir4 committed 296ab0a

python setup.py test && python3 setup.py test work

Comments (0)

Files changed (2)

pyjavaproperties.py

         
     def __str__(self):
         s='{'
-        for key,value in self._props.items():
+        for key,value in self._props.iteritems():
             s = ''.join((s,key,'=',value,', '))
 
         s=''.join((s[:-2],'}'))
         """ Load properties from an open file stream """
         
         # For the time being only accept file input streams
-        if type(stream) is not file:
-            raise TypeError,'Argument should be a file object!'
+        if not hasattr(stream, 'fileno'): # leave for backward compatibility
+            raise TypeError('Argument should be a file object!')
         # Check for the opened mode
         if stream.mode != 'r':
-            raise ValueError,'Stream should be opened in read-only mode!'
+            raise ValueError('Stream should be opened in read-only mode!')
 
         try:
             lines = stream.readlines()
         if type(key) is str and type(value) is str:
             self.processPair(key, value)
         else:
-            raise TypeError,'both key and value should be strings!'
+            raise TypeError('both key and value should be strings!')
 
     def propertyNames(self):
         """ Return an iterator over all the keys of the property
         dictionary, i.e the names of the properties """
 
-        return self._props.keys()
+        return self._props.iterkeys()
 
     def list(self, out=sys.stdout):
         """ Prints a listing of the properties to the
         stream 'out' which defaults to the standard output """
 
         out.write('-- listing properties --\n')
-        for key,value in self._props.items():
+        for key,value in self._props.iteritems():
             out.write(''.join((key,'=',value,'\n')))
 
     def store(self, out, header=""):
         with the optional 'header' """
 
         if out.mode[0] != 'w':
-            raise ValueError,'Steam should be opened in write mode!'
+            raise ValueError('Steam should be opened in write mode!')
 
         try:
             out.write(''.join(('#',header,'\n')))
 import os
 import sys
-try:
-    import ez_setup
-    ez_setup.use_setuptools()
-except ImportError:
-    pass
-from setuptools import setup
+
+from setuptools import setup # distribute
 
 # Use a cute trick to include the rest-style docs as the long_description
 # therefore having it self-doc'ed and hosted on pypi
         'Topic :: Software Development :: Libraries',
         'Topic :: Software Development :: Libraries :: Python Modules',
       ],
+    test_suite = 'pyjavaproperties_test',
+    use_2to3 = True,  # distribute
     py_modules=['pyjavaproperties'],
-    packages=[''],
     package_dir={'': '.'},
     )