Ejemplo n.º 1
0
        //自动生成方法字典
        public Dictionary <String, String> createFunctionDic(String testPagePath)
        {
            List <String> list  = new DirectoryManager().getAllFiles(testPagePath, "py");
            List <String> list2 = new List <string>();

            foreach (String str in list)
            {
                if (!str.Contains("__init__"))
                {
                    list2.Add(str);
                }
            }

            Dictionary <String, String> dicAll = new Dictionary <string, string>();

            foreach (String filePath in list2)
            {
                Dictionary <String, String> dic = getFunctionFromPythonFile(filePath);

                foreach (KeyValuePair <String, String> kv in dic)
                {
                    if (!dicAll.Keys.Contains(kv.Key))
                    {
                        dicAll.Add(kv.Key, kv.Value);
                    }
                    else
                    {
                        dicAll.Add(kv.Key + "X", kv.Value);
                    }
                }
            }
            return(dicAll);
        }
Ejemplo n.º 2
0
        //自动生成 import 代码
        private String createImportCode(String testPagePath)
        {
            List <String> list  = new DirectoryManager().getAllFiles(testPagePath, "py");
            List <String> list2 = new List <string>();

            foreach (String str in list)
            {
                if (!str.Contains("__init__"))
                {
                    String codeLine = path2ImportCode(str);
                    list2.Add(codeLine);
                }
            }
            StringBuilder sb = new StringBuilder();

            foreach (String str in list2)
            {
                //////Console.WriteLine(str);
                sb.Append(str + "\r\n");
            }
            sb.Append("\r\n");
            return(sb.ToString());
        }