Created
April 15, 2017 15:24
-
-
Save Fulgen301/72143c6ee08f0994a65e57569d350fe4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import configparser | |
import os.path | |
class ClonkSection(configparser.SectionProxy): | |
def __getitem__(self, item): | |
try: | |
return super(ClonkSection, self)[item] | |
except KeyError: | |
return None | |
configparser.SectionProxy = ClonkSection | |
class ObjectConverter(object): | |
def __init__(self, path): | |
self.path = path | |
self.lines = [] | |
with open(os.path.join(path, "Objects.txt"), "r") as fobj: | |
lines = fobj.read().replace("\r\n", "\n").split("\n\n") | |
for l in lines: | |
x = configparser.ConfigParser() | |
x.read_string(l) | |
self.lines.append(x["Object"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment