-
Notifications
You must be signed in to change notification settings - Fork 0
/
pymod.py
30 lines (27 loc) · 813 Bytes
/
pymod.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Python module to make other modules
class Program:
"""A python program"""
def __init__(self):
self.future_imports = []
self.imports = []
self.lines = []
def addImport(self,moduleName,futureImport):
if futureImport:
self.future_imports.append(moduleName)
return
self.imports.append(moduleName)
def addLine(self,line):
self.lines.append(line)
def fullcode(self,header):
if header:
ret = header
else:
ret = ["# code generated by PyMod - Python Modules made programmatically.","# PyMod by MineRobber9000"]
if self.future_imports != []:
ret.append("from __future__ import "+",".join(self.future_imports))
importStatement = "import "+",".join(self.imports)
ret.append(importStatement)
ret.append("")
for line in self.lines:
ret.append(line)
return "\n".join(ret)