MCPcopy
hub / github.com/pyload/pyload / load

Method load

module/network/HTTPChunk.py:82–111  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

80
81 @staticmethod
82 def load(name):
83 fs_name = fs_encode("%s.chunks" % name)
84 if not os.path.exists(fs_name):
85 raise IOError()
86 fh = codecs.open(fs_name, "r", "utf_8")
87 name = fh.readline()[:-1]
88 size = fh.readline()[:-1]
89 if name.startswith("name:") and size.startswith("size:"):
90 name = name[5:]
91 size = size[5:]
92 else:
93 fh.close()
94 raise WrongFormat()
95 ci = ChunkInfo(name)
96 ci.loaded = True
97 ci.setSize(size)
98 while True:
99 if not fh.readline(): # skip line
100 break
101 name = fh.readline()[1:-1]
102 range = fh.readline()[1:-1]
103 if name.startswith("name:") and range.startswith("range:"):
104 name = name[5:]
105 range = range[6:].split("-")
106 else:
107 raise WrongFormat()
108
109 ci.addChunk(name, (int(range[0]), int(range[1])))
110 fh.close()
111 return ci
112
113 def remove(self):
114 fs_name = fs_encode("%s.chunks" % self.name)

Callers

nothing calls this directly

Calls 9

setSizeMethod · 0.95
addChunkMethod · 0.95
fs_encodeFunction · 0.90
WrongFormatClass · 0.85
ChunkInfoClass · 0.85
splitMethod · 0.80
openMethod · 0.45
readlineMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected