Ejemplo n.º 1
0
        private bool ValueEqualsPythonDict(PythonDictionary pd, IEqualityComparer comparer)
        {
            List myKeys = keys();

            foreach (object o in myKeys)
            {
                object res;
                if (!pd.TryGetValueNoMissing(o, out res))
                {
                    return(false);
                }

                CompareUtil.Push(res);
                try {
                    if (comparer == null)
                    {
                        if (!PythonOps.EqualRetBool(res, this[o]))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if (!comparer.Equals(res, this[o]))
                        {
                            return(false);
                        }
                    }
                } finally {
                    CompareUtil.Pop(res);
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
 public static object get(PythonDictionary self, object key, object defaultValue = null)
 {
     if (self.TryGetValueNoMissing(key, out object ret))
     {
         return(ret);
     }
     return(defaultValue);
 }
Ejemplo n.º 3
0
 public static object setdefault(PythonDictionary self, object key, object defaultValue)
 {
     if (self.TryGetValueNoMissing(key, out object ret))
     {
         return(ret);
     }
     self.SetItem(key, defaultValue);
     return(defaultValue);
 }
Ejemplo n.º 4
0
        public static object setdefault(PythonDictionary self, object key, object defaultValue)
        {
            object ret;

            if (self.TryGetValueNoMissing(key, out ret))
            {
                return(ret);
            }
            self[key] = defaultValue;
            return(defaultValue);
        }
Ejemplo n.º 5
0
 public static object pop(PythonDictionary self, object key)
 {
     //??? perf won't match expected Python perf
     if (self.TryGetValueNoMissing(key, out object ret))
     {
         self.RemoveDirect(key);
         return(ret);
     }
     else
     {
         throw PythonOps.KeyError(key);
     }
 }
Ejemplo n.º 6
0
        public static object pop(PythonDictionary self, object key, object defaultValue)
        {
            //??? perf won't match expected Python perf
            object ret;

            if (self.TryGetValueNoMissing(key, out ret))
            {
                self.RemoveDirect(key);
                return(ret);
            }
            else
            {
                return(defaultValue);
            }
        }