Commits

cthedot  committed 39f3b35

removed py2.4 refs and changes to run under py 2.3

  • Participants
  • Parent commits 0247727

Comments (0)

Files changed (3)

 import os
 import sys
 
-# For Python 2.4, 2.5
+# For Python 2.5
 try:
     next
 except NameError:
 is_ver_line = lambda line: line.startswith('VERSION = ')
 line = next(line for line in lines if is_ver_line(line))
 
-# For Python 2.4, 2.5
+# For Python 2.5
 try:
     exec(line, locals(), globals())
 except TypeError:
     download_url='http://code.google.com/p/cssutils/downloads/list',
     license='LGPL 2.1 or later, see also http://cthedot.de/cssutils/',
     keywords='CSS, Cascading Style Sheets, CSSParser, DOM Level 2 Stylesheets, DOM Level 2 CSS',
-    platforms='Python 2.4 and later.',
+    platforms='Python 2.5 and later.',
     cmdclass=dict(
         # specify the build_py command imported earlier
         build_py=build_py,

File src/cssutils/__init__.py

     for style in styleDeclarations(sheet):
         for p in style.getProperties(all=True):
             for v in p.propertyValue:
-                if v.type == u'URI':
+                if v.type == 'URI':
                     yield v.uri
 
 def replaceUrls(sheetOrStyle, replacer, ignoreImportRules=False):

File src/cssutils/codec.py

         return bytestring
 else:
     def chars(bytestring):
-        return ''.join(chr(byte) for byte in bytestring)
+        # TODO: does not work as expected?!
+        #return ''.join(chr(byte) for byte in bytestring)
+        return bytestring
 
 def detectencoding_str(input, final=False):
     """
             raise ValueError("css not allowed as encoding name")
         if (explicit and not force) or encoding is None: # Take the encoding from the input
             encoding = _encoding
-    (input, consumed) = codecs.getdecoder(encoding)(input, errors)
+            
+    if sys.version_info < (3,):
+        (input, consumed) = codecs.getdecoder(encoding)(input, errors)
+    else:
+        # TODO: does this make sense at all?
+        (input, consumed) = codecs.getdecoder(encoding)(bytes(input, encoding), errors)
+    
     return (_fixencoding(input, unicode(encoding), True), consumed)