From 8c02821fd8f79442e80134e8a954d78401d5d1d2 Mon Sep 17 00:00:00 2001 From: walon Date: Wed, 17 Nov 2021 10:15:31 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E9=87=8D=E6=9E=84=E3=80=91=E5=B0=86py?= =?UTF-8?q?thon=5Fjson=E7=94=9F=E6=88=90=E4=BB=A3=E7=A0=81=E4=B8=ADimport?= =?UTF-8?q?=E5=92=8Cvector=E5=AE=9A=E4=B9=89=E9=83=A8=E5=88=86=E7=A7=BB?= =?UTF-8?q?=E5=88=B0=20include.tpl=EF=BC=8C=E6=96=B9=E4=BE=BF=E5=AE=9A?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/Generate/PythonCodeRenderBase.cs | 8 ++++---- src/Luban.Server/Luban.Server.csproj | 3 +++ .../Templates/config/python_json/include.tpl} | 16 +++------------- 3 files changed, 10 insertions(+), 17 deletions(-) rename src/{Luban.Job.Common/Source/Utils/PythonStringTemplates.cs => Luban.Server/Templates/config/python_json/include.tpl} (85%) diff --git a/src/Luban.Job.Cfg/Source/Generate/PythonCodeRenderBase.cs b/src/Luban.Job.Cfg/Source/Generate/PythonCodeRenderBase.cs index 83b8726..0b9f558 100644 --- a/src/Luban.Job.Cfg/Source/Generate/PythonCodeRenderBase.cs +++ b/src/Luban.Job.Cfg/Source/Generate/PythonCodeRenderBase.cs @@ -16,8 +16,9 @@ namespace Luban.Job.Cfg.Generate var lines = new List(10000); static void PreContent(List fileContent) { - fileContent.Add(PythonStringTemplates.ImportTython3Enum); - fileContent.Add(PythonStringTemplates.PythonVectorTypes); + //fileContent.Add(PythonStringTemplates.ImportTython3Enum); + //fileContent.Add(PythonStringTemplates.PythonVectorTypes); + fileContent.Add(StringTemplateUtil.GetTemplateString("config/python_json/include")); } GenerateCodeMonolithic(ctx, RenderFileUtil.GetFileOrDefault(ctx.GenArgs.OutputCodeMonolithicFile, "Types.py"), lines, PreContent, null); @@ -31,8 +32,7 @@ namespace Luban.Job.Cfg.Generate public override string RenderService(string name, string module, List tables) { var template = StringTemplateUtil.GetTemplate("config/python_json/tables"); - var result = template.RenderCode(new - { + var result = template.RenderCode(new { Name = name, Namespace = module, Tables = tables, diff --git a/src/Luban.Server/Luban.Server.csproj b/src/Luban.Server/Luban.Server.csproj index f0541ef..97fa148 100644 --- a/src/Luban.Server/Luban.Server.csproj +++ b/src/Luban.Server/Luban.Server.csproj @@ -167,6 +167,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/src/Luban.Job.Common/Source/Utils/PythonStringTemplates.cs b/src/Luban.Server/Templates/config/python_json/include.tpl similarity index 85% rename from src/Luban.Job.Common/Source/Utils/PythonStringTemplates.cs rename to src/Luban.Server/Templates/config/python_json/include.tpl index 4ea269b..008ee4d 100644 --- a/src/Luban.Job.Common/Source/Utils/PythonStringTemplates.cs +++ b/src/Luban.Server/Templates/config/python_json/include.tpl @@ -1,8 +1,6 @@ -namespace Luban.Job.Common.Utils -{ - public class PythonStringTemplates - { - public const string PythonVectorTypes = @" +from enum import Enum +import abc + class Vector2: def __init__(self, x, y): self.x = x @@ -54,11 +52,3 @@ class Vector4: raise Exception() return Vector4(x, y, z, w) -"; - - public const string ImportTython3Enum = @" -from enum import Enum -import abc -"; - } -}