Code cleanup

- Removal of useless prints
 - writeU* code cleanup
This commit is contained in:
LeMagnesium 2016-02-09 08:12:09 +00:00
parent 20d51a325c
commit c64b27d1de
4 changed files with 9 additions and 17 deletions

View File

@ -5,3 +5,4 @@ A library to use on Minetest's files
ßÿ Mg/LeMagnesium
License : WTFPL (so far)
Note: Still unstable to use

4
map.py
View File

@ -482,7 +482,6 @@ class MapVessel:
#self.cur.execute("COMMIT")
except _sql.OperationalError as err:
raise MapError(err)
print(self.cur.fetchall())
self.conn.commit()
def load(self, blockID):
@ -490,7 +489,6 @@ class MapVessel:
raise EmptyMapVesselError()
if not self.cache.get(blockID):
#return False, "notread"
res, code = self.read(blockID)
if not res and code == "notfound":
return
@ -586,4 +584,4 @@ class MapInterface:
def save(self):
for blockID in self.mod_cache:
self.saveMapBlock(blockID)
self.saveMapBlock(blockID)

View File

@ -48,7 +48,6 @@ def findTheShelves():
def buildPic(mapy, size):
im = Image.new("RGBA", (size*16, size*16))
hsize = int(size*8)
print(mapy)
for x in range(-hsize, hsize):
for z in range(-hsize, hsize):
im.putpixel((z+hsize, x+hsize), mapy[x * z*4096])
@ -102,4 +101,4 @@ if __name__ == "__main__":
#testMapBlockLoad()
#testSignedEndians()
#testGetNode()
testSetNode()
testSetNode()

View File

@ -83,7 +83,7 @@ class Pos:
self.dict = {'x': self.x, 'y': self.y, 'z': self.z}
return self
# Thanks to @gravgun for those
# Thanks to @gravgun/elementW for those
# Big-endian!!!
def readU8(strm):
return (ord(strm.read(1)))
@ -124,24 +124,18 @@ def writeU16(strm, val):
vals = []
for _ in range(2):
k = val % 256
vals.insert(0, k)
vals.insert(0, int(k))
val -= k
val = int(val/256)
val /= 256
strm.write(bytes(vals))
# strm.write(bytes(chr(val >> 8), encoding = 'utf8'))
# strm.write(bytes(chr(val), encoding = 'utf8'))
def writeU32(strm, val):
vals = []
for _ in range(4):
k = val % 256
vals.insert(0, k)
vals.insert(0, int(k))
val -= k
val = int(val/256)
val /= 256
strm.write(bytes(vals))
# strm.write(bytes(chr(val >> 24), encoding = 'utf8'))
# strm.write(bytes(chr(val >> 16), encoding = 'utf8'))
# strm.write(bytes(chr(val >> 8), encoding = 'utf8'))
# strm.write(bytes(chr(val), encoding = 'utf8'))
strm.write(bytes(vals))