Example #1
0
        private void Print(PyObject data, StringBuilder ret, int indentment = 0)
        {
            string cls = "unknown";

            if (data.HasAttr("__class__"))
            {
                var clsobj = data.Get("__class__");
                cls = clsobj.GetString(clsobj.HasAttr("__guid__") ? "__guid__" : "__name__");
            }

            // TODO: print value
            ret.AppendLine(new string(' ', indentment * 2) + "[" + cls + "]");

            if (data.HasAttr("__getstate__"))
            {
                var state = data.Get("__getstate__").Call();
                foreach (var obj in state)
                {
                    Print(obj, ret, indentment + 1);
                }
            }
            else if (data.IsTuple || data.IsDict)
            {
                foreach (var obj in data)
                {
                    Print(obj, ret, indentment + 1);
                }
            }
            else if (cls == "MarshalStream" && data.HasAttr("Str"))
            {
                var str = data.Get("Str").Call();
                var unm = LoadFunc.Call(str);
                if (unm.IsValid)
                {
                    Print(unm, ret, indentment + 1);
                }
            }
        }
Example #2
0
        public bool Initialize(LaunchStage stage)
        {
            if (stage == LaunchStage.PostBlue)
            {
                Marshal  = Python.Import("blue").Get("marshal");
                LoadFunc = Marshal.Get("Load");
                Marshal.IncRef();
                LoadFunc.IncRef();
                if (Marshal.IsValid && LoadFunc.IsValid)
                {
                    Core.Log(LogSeverity.Minor, "initialized blue marshal functions");
                }
            }

            return(true);
        }
Example #3
0
        private static string PrintBall(PyObject ball)
        {
            string name = "?";

            if (ball.HasAttr("name"))
            {
                name = ball.GetString("name");
            }
            double x       = ball.GetFloat("x");
            double y       = ball.GetFloat("y");
            double z       = ball.GetFloat("z");
            double mass    = ball.GetFloat("mass");
            double radius  = ball.GetFloat("radius");
            var    builder = new StringBuilder();

            builder.AppendLine("ball id " + ball.Get("id"));
            builder.AppendLine("\tname: " + name + "\t mass: " + mass + "\t radius: " + radius);
            builder.AppendLine("\txyz: [" + Math.Round(x) + ", " + Math.Round(y) + ", " + Math.Round(z) + "]");
            return(builder.ToString());
        }
Example #4
0
 private static string PrintBall(PyObject ball)
 {
     string name = "?";
         if (ball.HasAttr("name"))
             name = ball.GetString("name");
         double x = ball.GetFloat("x");
         double y = ball.GetFloat("y");
         double z = ball.GetFloat("z");
         double mass = ball.GetFloat("mass");
         double radius = ball.GetFloat("radius");
     var builder = new StringBuilder();
     builder.AppendLine("ball id " + ball.Get("id"));
     builder.AppendLine("\tname: " + name + "\t mass: " + mass + "\t radius: " + radius);
     builder.AppendLine("\txyz: [" + Math.Round(x) + ", " + Math.Round(y) + ", " + Math.Round(z) + "]");
     return builder.ToString();
 }