[Mumps2Py:] [56] tweaks to Mf_data, and added Mc_merge for when it' s not a complete dictionary being copied into another complete dictionary. |
[ Thread Index |
Date Index
| More lists.mumps2py.org/discuss Archives
]
- To: discuss@xxxxxxxxxxxxxxxxxx
- Subject: [Mumps2Py:] [56] tweaks to Mf_data, and added Mc_merge for when it' s not a complete dictionary being copied into another complete dictionary.
- From: subversion@xxxxxxxxxxxxx
- Date: Sat, 26 Jan 2008 20:56:30 +0100
Revision: 56
Author: pgallot
Date: 2008-01-26 19:56:30 +0000 (Sat, 26 Jan 2008)
Log Message:
-----------
tweaks to Mf_data, and added Mc_merge for when it's not a complete dictionary being copied into another complete dictionary.
Modified Paths:
--------------
trunk/mumps2py/mumpsCL.py
Modified: trunk/mumps2py/mumpsCL.py
===================================================================
--- trunk/mumps2py/mumpsCL.py 2008-01-26 19:52:09 UTC (rev 55)
+++ trunk/mumps2py/mumpsCL.py 2008-01-26 19:56:30 UTC (rev 56)
@@ -36,7 +36,7 @@
return 1
else:
if indices_tuple == None:
- if the_var.has_key( (None) ):
+ if the_var.has_key( (None,) ):
return 11
else:
return 10
@@ -45,9 +45,46 @@
if not isinstance(the_var, DictType):
return 1
else:
- if the_var.has_key( (None) ):
+ if the_var.has_key( (None,) ):
return 11
else:
return 10
else:
return 0
+
+def Mc_merge(recipient, recipient_modifier, copy_item, copy_item_subset):
+ """merge a subset of one dictionary into a subset of another"""
+
+ new_keys = {}
+ if copy_item_subset != (None,):
+ len_subset = len(copy_item_subset)
+ subkeys = []
+ for key in copy_item.keys():
+ #print key,key[:len_subset],copy_item_subset
+ if key[:len_subset] == copy_item_subset:
+ #print "match!"
+ subkeys.append(key)
+
+ #print "**[", recipient_modifier,"]**"
+ if recipient_modifier != (None,):
+ for subkey in subkeys:
+ new_subkey = recipient_modifier + subkey[len_subset:]
+ new_keys[new_subkey] = subkey
+ #print subkey,new_subkey
+ else:
+ for subkey in subkeys:
+ new_subkey = subkey[len_subset:]
+ new_keys[new_subkey] = subkey
+ #print subkey,new_subkey
+ else:
+ subkeys = copy_item.keys()
+ if recipient_modifier != (None,):
+ for subkey in subkeys:
+ new_subkey = recipient_modifier + subkey
+ new_keys[new_subkey] = subkey
+ else:
+ for subkey in subkeys:
+ new_keys[subkey] = subkey
+
+ for (newkey, oldkey) in new_keys.items():
+ recipient[newkey] = copy_item[oldkey]