Author: Reinis Danne <rei4dan@gmail.com>
Description: Fix python string exceptions
Origin: upstream, http://gitorious.org/bkchem/piddle/commit/73c84c7e08dbb237f66ae78200780beade7a442c?format=patch
Bug-Debian: http://bugs.debian.org/585233
Last-Update: bkchem (0.13.0-3) unstable

--- a/bkchem/oasa/oasa/chem_vertex.py
+++ b/bkchem/oasa/oasa/chem_vertex.py
@@ -67,7 +67,7 @@
     elif len( coords) == 3:
       self.x, self.y, self.z = coords
     else:
-      raise "wrong number of coordinates"
+      raise Exception("wrong number of coordinates")
 
   def _get_coords( self):
     return self.x, self.y, self.z
--- a/bkchem/oasa/oasa/coords_generator.py
+++ b/bkchem/oasa/oasa/coords_generator.py
@@ -296,7 +296,7 @@
       ring = self.mol.sort_vertices_in_path( ring, start_from=v)
       base_neighs = [a for a in v.get_neighbors() if a in base]
       if len( base_neighs) < 2:
-        raise "this should not happen"
+        raise Exception("this should not happen")
       d1 = base_neighs[0] 
       d2 = base_neighs[1]
       ca1 = geometry.clockwise_angle_from_east( v.x-d1.x, v.y-d1.y)
@@ -339,7 +339,7 @@
       # there are more than 2 atoms common
       if len( ring) == len( base):
         out += self._process_multi_anelated_ring( ring, angle_shift=15)
-        #raise( "i don't how to handle this yet")
+        #raise Exception( "i don't how to handle this yet")
       else:
         out += self._process_multi_anelated_ring( ring)
     return out
@@ -355,7 +355,7 @@
     if not sorted_back:
       # the already set atoms are not in one path - we have to process it "per partes"
       # it should not happen with the construction method we use
-      raise( "i am not able to handle this, it should normaly not happen. please send me the input.")
+      raise Exception( "i am not able to handle this, it should normaly not happen. please send me the input.")
     else:
       v1 = sorted_back[0]
       v2 = sorted_back[-1]
--- a/bkchem/oasa/oasa/graph/vertex.py
+++ b/bkchem/oasa/oasa/graph/vertex.py
@@ -65,14 +65,14 @@
     if to_del:
       del self._neighbors[ to_del]
     else:
-      raise "cannot remove non-existing neighbor"
+      raise Exception("cannot remove non-existing neighbor")
 
   def remove_edge_and_neighbor( self, e):
     self._clean_cache()
     if e in self._neighbors.keys():
       del self._neighbors[ e]
     else:
-      raise "cannot remove non-existing edge", e
+      raise Exception("cannot remove non-existing edge", e)
 
 
   def get_neighbors( self):
--- a/bkchem/oasa/oasa/inchi.py
+++ b/bkchem/oasa/oasa/inchi.py
@@ -95,14 +95,14 @@
       return layers
     structs = doc.getElementsByTagName( 'structure')
     if not structs:
-      raise "no structures found in xml string %s" % text
+      raise Exception("no structures found in xml string %s" % text)
     struct = structs[0]
     layers = []
     for name in ('version','formula','connections','H'):
       try:
         layer = struct.getElementsByTagName( name)[0]
       except IndexError:
-        raise "no '%s' tag found in xml string" % name
+        raise Exception("no '%s' tag found in xml string" % name)
       layers.append( dom_extensions.getTextFromElement( layer))
     return layers
 
@@ -249,7 +249,7 @@
         try:
           i = int( c)
         except:
-          raise ValueError, "unexpected character %s in the connectivity layer" % c 
+          raise ValueError("unexpected character %s in the connectivity layer" % c)
         # atom
         if last_atom:
           self.structure.add_edge( last_atom-1, i-1)
--- a/bkchem/oasa/oasa/molfile.py
+++ b/bkchem/oasa/oasa/molfile.py
@@ -107,7 +107,7 @@
   def write_file( self, file):
     """file should be a writable file object"""
     if not self.structure:
-      raise "No structure to write"
+      raise Exception("No structure to write")
     self._write_header( file)
     self._write_counts_line( file)
     self._write_body( file)
--- a/bkchem/oasa/oasa/smiles.py
+++ b/bkchem/oasa/oasa/smiles.py
@@ -430,7 +430,7 @@
       start, end = filter( lambda x: x.get_degree() == 1, mol.vertices)
     except:
       #print filter( lambda x: x.get_degree() == 1, mol.vertices)
-      raise "shit"
+      raise Exception("shit")
     if start_from == end:
       start, end = end, start
     v = start
@@ -567,7 +567,7 @@
               the_right_branch_atom,
               the_right_branch)
     #print mol, mol.is_connected()
-    raise "fuck, how comes!?"
+    raise Exception("fuck, how comes!?")
 
 
 
@@ -612,7 +612,7 @@
           v = (v1 in p1.vertices) and v1 or v2
           return e, p1, v, p2
     print mol, mol.is_connected(), ',', map( len, mol.get_connected_components()), ',', start_from
-    raise "fuck, how comes!?"
+    raise Exception("fuck, how comes!?")
 
   @staticmethod
   def _create_ring_join_smiles( index):
--- a/bkchem/plugins/piddle/PixMapWrapper.py
+++ b/bkchem/plugins/piddle/PixMapWrapper.py
@@ -93,7 +93,7 @@
 
 	def __setattr__(self, attr, val):
 		if attr == 'baseAddr':
-			raise 'UseErr', "don't assign to .baseAddr -- assign to .data instead"
+			raise Exception('UseErr', "don't assign to .baseAddr -- assign to .data instead")
 		elif attr == 'data':
 			self.__dict__['data'] = val
 			self._stuff('baseAddr', id(self.data) + MacOS.string_id_to_buffer)
@@ -186,7 +186,7 @@
 		# so convert if necessary
 		if format != imgformat.macrgb and format != imgformat.macrgb16:
 			# (LATER!)
-			raise "NotImplementedError", "conversion to macrgb or macrgb16"
+			raise NotImplementedError("conversion to macrgb or macrgb16")
 		self.data = s
 		self.bounds = (0,0,width,height)
 		self.cmpCount = 3
@@ -207,7 +207,7 @@
 			return self.data
 		# otherwise, convert to the requested format
 		# (LATER!)
-			raise "NotImplementedError", "data format conversion"
+			raise NotImplementedError("data format conversion")
 
 	def fromImage(self,im):
 		"""Initialize this PixMap from a PIL Image object."""
--- a/bkchem/plugins/piddle/pdfgen.py
+++ b/bkchem/plugins/piddle/pdfgen.py
@@ -707,7 +707,7 @@
 		    image.seek(2, 1)		#skip segment length
 		    x = struct.unpack('B', image.read(1)) #data precision
 		    if x[0] != 8:
-			raise 'PDFError', ' JPEG must have 8 bits per component'
+			raise Exception('PDFError', ' JPEG must have 8 bits per component')
 		    y = struct.unpack('BB', image.read(2))
 		    height = (y[0] << 8) + y[1] 
 		    y = struct.unpack('BB', image.read(2))
@@ -717,7 +717,7 @@
 		    return width, height, color
 		    done = 1
 		elif x[0] in unsupportedMarkers:
-		    raise 'PDFError', ' Unsupported JPEG marker: %0.2x' % x[0]
+		    raise Exception('PDFError', ' Unsupported JPEG marker: %0.2x' % x[0])
 		elif x[0] not in noParamMarkers:
 		    #skip segments with parameters
 		    #read length and skip the data
@@ -764,17 +764,17 @@
         if direction in [0,90,180,270]:
             direction_arg = '/Di /%d' % direction
         else:
-            raise 'PDFError', ' directions allowed are 0,90,180,270'
+            raise Exception('PDFError', ' directions allowed are 0,90,180,270')
         
         if dimension in ['H', 'V']:
             dimension_arg = '/Dm /%s' % dimension
         else:
-            raise'PDFError','dimension values allowed are H and V'
+            raise Exception('PDFError','dimension values allowed are H and V')
         
         if motion in ['I','O']:
             motion_arg = '/M /%s' % motion
         else:
-            raise'PDFError','motion values allowed are I and O'
+            raise Exception('PDFError','motion values allowed are I and O')
 
 
         # this says which effects require which argument types from above
@@ -790,7 +790,7 @@
         try:
             args = PageTransitionEffects[effectname]
         except KeyError:
-            raise 'PDFError', 'Unknown Effect Name "%s"' % effectname
+            raise Exception('PDFError', 'Unknown Effect Name "%s"' % effectname)
             self._pageTransitionString = ''
             return
         
--- a/bkchem/plugins/piddle/piddle.py
+++ b/bkchem/plugins/piddle/piddle.py
@@ -749,9 +749,9 @@
                         if hasattr(file, "write"):
                                 fileobj = file
                         else:
-                                raise 'Invalid file argument to save'
+                                raise Exception('Invalid file argument to save')
         else:
-                raise 'Invalid file argument to save'
+                raise Exception('Invalid file argument to save')
         
         return fileobj
 
--- a/bkchem/plugins/piddle/piddlePIL.py
+++ b/bkchem/plugins/piddle/piddlePIL.py
@@ -344,7 +344,7 @@
         temppen = ImageDraw.ImageDraw(tempimg)
         temppen.setink( (255,255,255) )
         pilfont = _pilFont(font)
-        if not pilfont: raise "bad font!", font
+        if not pilfont: raise Exception("bad font!", font)
         temppen.setfont( pilfont )
         pos = [4, int(tempsize/2 - self.fontAscent(font)) - self.fontDescent(font)]
         temppen.text( pos, s )
--- a/bkchem/plugins/piddle/piddlePS.py
+++ b/bkchem/plugins/piddle/piddlePS.py
@@ -190,7 +190,7 @@
        elif PostScriptLevel == 2 :
            self.drawImage = self._drawImageLevel2
        else :
-           raise 'PostScriptLevelException'
+           raise Exception('PostScriptLevelException')
 
 
        self.code = []
--- a/bkchem/plugins/piddle/piddleWxDc.py
+++ b/bkchem/plugins/piddle/piddleWxDc.py
@@ -56,7 +56,7 @@
           if default_color is not None:
             return self._getWXbrush(default_color)
           else:
-            raise "WXcanvas error:  Cannot create brush."
+            raise Exception("WXcanvas error:  Cannot create brush.")
 
         return wxBrush(wxcolor)
 
@@ -75,7 +75,7 @@
           if default_color is not None:
             return self._getWXpen(width, default_color)
           else:
-            raise "WXcanvas error:  Cannot create pen."
+            raise Exception("WXcanvas error:  Cannot create pen.")
 
         return wxPen(wxcolor, width)
 
@@ -264,7 +264,7 @@
             try:
                 import Image
             except ImportError:
-                raise "PIL not available!"
+                raise Exception("PIL not available!")
 
         if (x2 and y2 and x2>x1 and y2>y1):
             imgPil = image.resize((x2-x1,y2-y1))
--- a/bkchem/plugins/piddle/piddletest.py
+++ b/bkchem/plugins/piddle/piddletest.py
@@ -274,7 +274,7 @@
 		drawRotstring(tkcanvas)
         else :
                 print "Illegal testfunc handed to tkTest"
-                raise "Unsupported testfunc"
+                raise Exception("Unsupported testfunc")
 
         tkcanvas.flush() 
 	
