MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / ReadFromFile

Method ReadFromFile

scintilla/include/Face.py:45–113  ·  view source on GitHub ↗
(self, name)

Source from the content-addressed store, hash-verified

43 self.events = {}
44
45 def ReadFromFile(self, name):
46 currentCategory = ""
47 currentComment = []
48 currentCommentFinished = 0
49 file = open(name)
50 for line in file.readlines():
51 line = sanitiseLine(line)
52 if line:
53 if line[0] == "#":
54 if line[1] == " ":
55 if currentCommentFinished:
56 currentComment = []
57 currentCommentFinished = 0
58 currentComment.append(line[2:])
59 else:
60 currentCommentFinished = 1
61 featureType, featureVal = line.split(" ", 1)
62 if featureType in ["fun", "get", "set"]:
63 try:
64 retType, name, value, param1, param2 = decodeFunction(featureVal)
65 except ValueError:
66 print("Failed to decode %s" % line)
67 raise
68 p1 = decodeParam(param1)
69 p2 = decodeParam(param2)
70 self.features[name] = {
71 "FeatureType": featureType,
72 "ReturnType": retType,
73 "Value": value,
74 "Param1Type": p1[0], "Param1Name": p1[1], "Param1Value": p1[2],
75 "Param2Type": p2[0], "Param2Name": p2[1], "Param2Value": p2[2],
76 "Category": currentCategory, "Comment": currentComment
77 }
78 if value in self.values:
79 raise Exception("Duplicate value " + value + " " + name)
80 self.values[value] = 1
81 self.order.append(name)
82 elif featureType == "evt":
83 retType, name, value = decodeEvent(featureVal)
84 self.features[name] = {
85 "FeatureType": featureType,
86 "ReturnType": retType,
87 "Value": value,
88 "Category": currentCategory, "Comment": currentComment
89 }
90 if value in self.events:
91 raise Exception("Duplicate event " + value + " " + name)
92 self.events[value] = 1
93 self.order.append(name)
94 elif featureType == "cat":
95 currentCategory = featureVal
96 elif featureType == "val":
97 try:
98 name, value = featureVal.split("=", 1)
99 except ValueError:
100 print("Failure %s" % featureVal)
101 raise Exception()
102 self.features[name] = {

Callers 1

HFacer.pyFile · 0.80

Calls 4

sanitiseLineFunction · 0.85
decodeFunctionFunction · 0.85
decodeParamFunction · 0.85
decodeEventFunction · 0.85

Tested by

no test coverage detected