[Mumps2Py:] [90] refactored Mf_data to get rid of a pyLint refactoring warning.

[ Thread Index | Date Index | More lists.mumps2py.org/discuss Archives ]


Revision: 90
Author:   pgallot
Date:     2008-02-12 00:10:34 +0000 (Tue, 12 Feb 2008)

Log Message:
-----------
refactored Mf_data to get rid of a pyLint refactoring warning.  Added Mf_find, to handle the no substring found case.

Modified Paths:
--------------
    trunk/mumps2py/mumpsCL.py


Modified: trunk/mumps2py/mumpsCL.py
===================================================================
--- trunk/mumps2py/mumpsCL.py	2008-02-11 21:33:45 UTC (rev 89)
+++ trunk/mumps2py/mumpsCL.py	2008-02-12 00:10:34 UTC (rev 90)
@@ -27,31 +27,37 @@
     """Python-equivalent of the Mumps $Data intrinsic
 NOTE: not yet designed to work with Mumps Global variables."""
 
-    if not loc_adr_space.has_key(name):
-        return 0
-    else:
+    val = 0
+    if loc_adr_space.has_key(name):
         the_var = loc_adr_space[name]
 
         if not isinstance(the_var, DictType):
-            return 1
+            val = 1
         else:
             if indices_tuple == None:
                 if the_var.has_key( (None,) ):
-                    return 11
+                    val = 11
                 else:
-                    return 10
+                    val = 10
             elif the_var.has_key(indices_tuple):
                 the_var = the_var[indices_tuple]
                 if not isinstance(the_var, DictType):
-                    return 1
+                    val = 1
                 else:
                     if the_var.has_key( (None,) ):
-                        return 11
+                        val = 11
                     else:
-                        return 10
-            else:
-                return 0
+                        val = 10
+    return val
 
+def Mf_find(searchstr, substr, startpos = 0):
+    """Python-equivalen of the Mumps $Find intrinsic"""
+    val = searchstr.find(substr, startpos)
+    if val == -1:
+        return 0
+    else:
+        return val + len(substr) + 1
+
 def Mc_merge(recipient, recipient_modifier, copy_item, copy_item_subset):
     """merge a subset of one dictionary into a subset of another"""
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/