@@ -26,6 +26,17 @@ public Converter(ProgrammingLanguage language)
2626 Language = language ;
2727 }
2828 public ImportAndDefine Import = new ImportAndDefine ( ) ;
29+ public ProgramFile [ ] ProgramFiles = Array . Empty < ProgramFile > ( ) ;
30+ public class ProgramFile
31+ {
32+ public string Name { get ; set ; }
33+ public string Content { get ; set ; }
34+ public ProgramFile ( string name , string content )
35+ {
36+ Name = name ;
37+ Content = content ;
38+ }
39+ }
2940 public class ImportAndDefine
3041 {
3142 // contains
@@ -136,8 +147,16 @@ public bool WheelState
136147 public readonly string AVERAGE = "def average(*args):\r \n if not args:\r \n return 0\r \n return sum(args) / len(args)" ;
137148 }
138149 public List < EZCodeObject > objects = new List < EZCodeObject > ( ) ;
150+ public string Convert ( ) => Convert ( Code , Language ) ;
139151 public string Convert ( string code ) => Convert ( code , Language ) ;
140152 public string Convert ( ProgrammingLanguage language ) => Convert ( Code , language ) ;
153+ public string Convert ( string code , ProgrammingLanguage language , out ProgramFile [ ] programFiles )
154+ {
155+ Converter con = new Converter ( code , language ) ;
156+ string ret = con . Convert ( ) ;
157+ programFiles = con . ProgramFiles ;
158+ return ret ;
159+ }
141160 public string Convert ( string code , ProgrammingLanguage language )
142161 {
143162 Import = new ImportAndDefine ( ) ;
@@ -159,12 +178,20 @@ public string Convert(string code, ProgrammingLanguage language)
159178 converted += con + Environment . NewLine ;
160179 }
161180
162- if ( language == ProgrammingLanguage . Python && Import . ContainsMethod )
181+ if ( language == ProgrammingLanguage . Python )
163182 {
164- int ttab = 0 ;
165- string firstMethod = lines . FirstOrDefault ( x => getAction ( x , objects ) == Actions . Method , "method Start" ) ;
166- firstMethod = ConvertLinePython ( Actions . Method , firstMethod , objects , ref ttab ) . Split ( " " ) . Select ( x=> x . Trim ( ) ) . ToArray ( ) [ 1 ] . Replace ( ":" , "" ) ;
167- converted += Environment . NewLine + firstMethod + Environment . NewLine ;
183+ ProgramFiles = new ProgramFile [ ]
184+ {
185+ new ProgramFile ( "Main.py" , converted ) ,
186+ new ProgramFile ( "Main.py2" , PreRequisites ( ) )
187+ } ;
188+ if ( Import . ContainsMethod )
189+ {
190+ int ttab = 0 ;
191+ string firstMethod = lines . FirstOrDefault ( x => getAction ( x , objects ) == Actions . Method , "method Start" ) ;
192+ firstMethod = ConvertLinePython ( Actions . Method , firstMethod , objects , ref ttab ) . Split ( " " ) . Select ( x=> x . Trim ( ) ) . ToArray ( ) [ 1 ] . Replace ( ":" , "" ) ;
193+ converted += Environment . NewLine + firstMethod + Environment . NewLine ;
194+ }
168195 }
169196
170197 converted = "# Your converted python code" + Environment . NewLine + converted ;
0 commit comments