| | |
| | | def __init__(self, text=None): |
| | | self.text = text.split("\n") |
| | | self.introduction = None |
| | | self.picture=None |
| | | self.parsedPicture=None |
| | | self.subproblems = [] |
| | | self.solutions = None |
| | | self.parsedSolutions = None |
| | |
| | | varlist.append("\n".join(self.text[start:end])) |
| | | return varlist |
| | | |
| | | def findPicture(self): |
| | | gen = self.findStartEndMarkers("Pic") |
| | | varlist = [] |
| | | for stat, end in gen: |
| | | varlist.append("\n".join(self.text[start:end])) |
| | | return varlist |
| | | |
| | | def parseSections(self): |
| | | self.introduction = self.findIntroduction() |
| | | self.subproblems = self.findSubproblems() |
| | |
| | | self.variables = self.findVariables() |
| | | self.parsedVariables = self.parseVariables() |
| | | self.variableGenerator = self.prepareGenerators() |
| | | self.picture = self.findPicture() |
| | | self.parsedPicture = self.parsePicture() |
| | | |
| | | def parsePicture(self): |
| | | parsedPictures = [] |
| | | for p in self.picture: |
| | | retval = {"filename": [], "size:": [], "position": []} |
| | | for r in p.split("\n"): |
| | | sp = r.split(":") |
| | | if sp[0].strip("\n\t'") == "ime": |
| | | retval["filename"].append(sp[1].strip("\n\t")) |
| | | elif sp[0].strip("\n\t'") == "sirina": |
| | | retval["size"].append(sp[1].strip("\n\t")) |
| | | elif sp[0].strip("\n\t'") == "polozaj": |
| | | retval["position"].append(sp[1].strip("\n\t")) |
| | | parsedPictures.append(retval) |
| | | return parsedPictures |
| | | |
| | | def parseSolutions(self): |
| | | parsedSolutions = [] |
| | |
| | | def get_parsed_sections(self): |
| | | return ( |
| | | self.introduction, |
| | | self.parsedPicture, |
| | | self.subproblems, |
| | | self.parsedVariables, |
| | | self.parsedSolutions, |
| | |
| | | def __init__(self, parser=None): |
| | | self.introduction = None |
| | | self.subproblems = None |
| | | self.picture= None |
| | | self.parsedSolutions = None |
| | | self.parsedVariables = None |
| | | self.variableGenerator = None |
| | | self.varDict = {} |
| | | if parser is not None: |
| | | self.introduction, self.subproblems, self.parsedVariables, self.parsedSolutions, self.variableGenerator = ( |
| | | self.introduction, self.picture, self.subproblems, self.parsedVariables, self.parsedSolutions, self.variableGenerator = ( |
| | | parser.get_parsed_sections() |
| | | ) |
| | | # self.generateVariables() |
| | |
| | | for p in self.subproblems: |
| | | sp.append(self.substitute_variables(p)) |
| | | sol = self.generateSolutions() |
| | | return {"introduction": intro, "subproblems": sp, "solutions": sol} |
| | | return {"introduction": intro, "subproblems": sp, "picture": self.picture, "solutions": sol} |