public static PyDict Dict(params object[] objs) { if (objs.Length % 2 == 1) throw new ArgumentException("Expected pair arguments"); var ret = new PyDict(new Dictionary<PyObject, PyObject>(objs.Length / 2)); for (int i = 0; i < (objs.Length/2); i++) { var key = objs[i]; var val = objs[i + 1]; if (!(key is string)) throw new ArgumentException("Expected string"); if (!(val is PyObject)) throw new ArgumentException("Expected PyObject"); ret.Dictionary.Add(new PyString(key as string), val as PyObject); } return ret; }
private PyRep analyseType2(PyObjectEx obj, out bool usedList, out bool usedDict) { usedDict = false; usedList = false; // type 2 PyTuple headerTuple = obj.Header as PyTuple; if (headerTuple != null && headerTuple.Items.Count > 1) { int headerCount = headerTuple.Items.Count; PyDict dict = headerTuple.Items[1] as PyDict; PyToken token = null; PyTuple tokenTuple = headerTuple.Items[0] as PyTuple; if (tokenTuple != null && tokenTuple.Items.Count == 1) { token = tokenTuple.Items[0] as PyToken; } if (token != null) { if (headerCount != 2) { unknown.AppendLine("PyObjectEx Type2: headerCount=" + headerCount + " token: " + token.Token); } if (headerCount == 2 && token.Token == "carbon.common.script.sys.crowset.CRowset") { usedList = true; if (dict.Dictionary.Count > 1) { unknown.AppendLine("PyObjectEx Type2: Extra parameters in dict for CRowset"); } return(new CRowSet(dict, obj.List)); } if (headerCount == 2 && token.Token == "carbon.common.script.sys.crowset.CIndexedRowset") { usedDict = true; if (dict.Dictionary.Count > 2) { unknown.AppendLine("PyObjectEx Type2: Extra parameters in dict for CIndexedRowset"); } return(new CIndexedRowset(dict, obj.Dictionary)); } if (token.Token == "eve.common.script.dogma.effect.BrainEffect") { return(obj); } if (token.Token == "industry.job.Location") { return(obj); } if (token.Token == "eve.common.script.sys.rowset.RowDict") { return(obj); } if (token.Token == "carbon.common.script.sys.crowset.CFilterRowset") { return(obj); } if (token.Token == "eve.common.script.sys.rowset.RowList") { return(obj); } if (token.Token == "eve.common.script.util.pagedCollection.PagedResultSet") { return(obj); } if (token.Token == "shipskins.storage.LicensedSkin") { return(obj); } if (token.Token == "seasons.common.challenge.Challenge") { return(obj); } unknown.AppendLine("Unknown Token type 2: " + token.Token); } } return(obj); }
private static string PrintDict(PyDict dict) { return "[PyDict " + dict.Dictionary.Count + " kvp]"; }