Permalink
Browse files

remove redundant parentheses

  • Loading branch information...
1 parent 62c4fc4 commit 8fac69ebbb27d82565bd98ded5d96fc50fb99535 @codewarrior0 committed Jan 10, 2012
Showing with 51 additions and 51 deletions.
  1. +2 −2 _nbt.pyx
  2. +2 −2 gprof2dot.py
  3. +1 −1 indev.py
  4. +10 −10 infiniteworld.py
  5. +8 −8 java.py
  6. +7 −7 level.py
  7. +1 −1 materials.py
  8. +3 −3 mce.py
  9. +7 −7 mclevel.py
  10. +1 −1 pocket.py
  11. +5 −5 pynbt.py
  12. +1 −1 tests.py
  13. +1 −1 yaml/emitter.py
  14. +2 −2 yaml/scanner.py
View
@@ -84,7 +84,7 @@ cdef class TAG_Value:
self._name = val
def __reduce__(self):
- return (self.__class__, (self.value, self._name))
+ return self.__class__, (self.value, self._name)
cdef class TAG_Number(TAG_Value):
pass
@@ -280,7 +280,7 @@ cdef class TAG_Short_Array(TAG_Array):
#cdef int needswap = (sys.byteorder == "little")
cdef swab(void * vbuf, int nbytes):
- cdef unsigned char * buf = <unsigned char *>(vbuf)
+ cdef unsigned char * buf = <unsigned char *> vbuf
#print "Swapping ", nbytes, "bytes"
#for i in range(nbytes): print buf[i],
#print "to",
View
@@ -808,7 +808,7 @@ def translate(self, mo):
value = int(value)
elif self._float_re.match(value):
value = float(value)
- attrs[name] = (value)
+ attrs[name] = value
return Struct(attrs)
_cg_header_re = re.compile(
@@ -2222,7 +2222,7 @@ def hsl_to_rgb(self, h, s, l):
g **= self.gamma
b **= self.gamma
- return (r, g, b)
+ return r, g, b
def _hue_to_rgb(self, m1, m2, h):
if h < 0.0:
View
@@ -248,7 +248,7 @@ def rotateLeft(self):
def decodePos(self, v):
b = 10;
- m = (1 << b) - 1; return (v & m, (v >> b) & m, (v >> (2 * b)))
+ m = (1 << b) - 1; return v & m, (v >> b) & m, (v >> (2 * b))
def encodePos(self, x, y, z):
b = 10;
return x + (y << b) + (z << (2 * b))
View
@@ -181,7 +181,7 @@ def checksumForVersion(self, v):
jf = self.jarfileForVersion(v)
with file(jf, "rb") as f:
import hashlib
- return (hashlib.md5(f.read()).hexdigest())
+ return hashlib.md5(f.read()).hexdigest()
broken_versions = ["Beta 1.9 Prerelease {0}".format(i) for i in (1,2,3)]
@@ -356,7 +356,7 @@ def tempWorldForLevel(self, level):
properties["server-port"] = int(32767 + random.random() * 32700)
saveProperties(propsFile, properties)
- return (tempWorld, tempDir)
+ return tempWorld, tempDir
def generateAtPosition(self, tempWorld, tempDir, cx, cz):
return exhaust(self.generateAtPositionIter(tempWorld, tempDir, cx, cz))
@@ -1220,7 +1220,7 @@ def unpackSectors(self, data):
length = struct.unpack_from(">I", data)[0]
format = struct.unpack_from("B", data, 4)[0]
data = data[5:length + 5]
- return (format, data)
+ return format, data
def _decompressSectors(self, format, data):
if format == self.VERSION_GZIP:
@@ -1253,7 +1253,7 @@ def _saveChunk(self, cx, cz, data, format):
sectorsNeeded = (len(data) + self.CHUNK_HEADER_SIZE) / self.SECTOR_BYTES + 1;
if sectorsNeeded >= 256: return
- if (sectorNumber != 0 and sectorsAllocated >= sectorsNeeded):
+ if sectorNumber != 0 and sectorsAllocated >= sectorsNeeded:
debug("REGION SAVE {0},{1} rewriting {2}b".format(cx, cz, len(data)))
self.writeSector(sectorNumber, data, format)
else:
@@ -1365,7 +1365,7 @@ def base36(n):
work = []
- while(n):
+ while n:
n, digit = divmod(n, 36)
work.append(base36alphabet[digit])
@@ -1510,7 +1510,7 @@ def setSkylightAt(self, x, y, z, lightValue):
def sourceMaskFunc(self, blocksToCopy):
if blocksToCopy is not None:
- typemask = zeros((256) , dtype='bool')
+ typemask = zeros(256, dtype='bool')
typemask[blocksToCopy] = 1;
def sourceMask(sourceBlocks):
return typemask[sourceBlocks]
@@ -2465,10 +2465,10 @@ def preloadChunkPaths(self):
self._allChunks = set()
for dirname in worldDirs:
- if(dirname in self.dirhashes):
+ if dirname in self.dirhashes:
subdirs = os.listdir(os.path.join(self.worldDir, dirname));
for subdirname in subdirs:
- if(subdirname in self.dirhashes):
+ if subdirname in self.dirhashes:
filenames = os.listdir(os.path.join(self.worldDir, dirname, subdirname));
#def fullname(filename):
#return os.path.join(self.worldDir, dirname, subdirname, filename);
@@ -2602,7 +2602,7 @@ def _dirhash(self):
n = self
n = n % 64;
s = u"";
- if(n >= 36):
+ if n >= 36:
s += u"1";
n -= 36;
s += u"0123456789abcdefghijklmnopqrstuvwxyz"[n]
@@ -2613,7 +2613,7 @@ def _dirhash(self):
def regionFilename(self, rx, rz):
s = os.path.join(self.regionDir,
- "r.%s.%s.mcr" % ((rx), (rz)));
+ "r.%s.%s.mcr" % (rx, rz));
return s;
def chunkFilename(self, x, z):
View
16 java.py
@@ -30,30 +30,30 @@ def Width(self):
def guessSize(self, data):
- if(data.shape[0] <= (32 * 32 * 64) * 2):
+ if data.shape[0] <= (32 * 32 * 64) * 2:
warn(u"Can't guess the size of a {0} byte level".format(data.shape[0]))
raise IOError, "MCJavaLevel attempted for smaller than 64 blocks cubed"
- if(data.shape[0] > (32 * 32 * 64) * 2):
+ if data.shape[0] > (32 * 32 * 64) * 2:
Width = 64
Length = 64
Height = 64
- if(data.shape[0] > (64 * 64 * 64) * 2):
+ if data.shape[0] > (64 * 64 * 64) * 2:
Width = 128
Length = 128
Height = 64
- if(data.shape[0] > (128 * 128 * 64) * 2):
+ if data.shape[0] > (128 * 128 * 64) * 2:
Width = 256
Length = 256
Height = 64
- if(data.shape[0] > (256 * 256 * 64) * 2): #could also be 256*256*256
+ if data.shape[0] > (256 * 256 * 64) * 2: #could also be 256*256*256
Width = 512
Length = 512
Height = 64
- if(data.shape[0] > 512 * 512 * 64 * 2): # just to load shadowmarch castle
+ if data.shape[0] > 512 * 512 * 64 * 2: # just to load shadowmarch castle
Width = 512
Length = 512
Height = 256
- return (Width, Length, Height)
+ return Width, Length, Height
@classmethod
def _isDataLevel(cls, data):
@@ -89,7 +89,7 @@ def __init__(self, filename, data):
blocks = data[blockOffset:blockOffset + blockCount]
maxBlockType = 64 #maximum allowed in classic
- while(max(blocks[-4096:]) > maxBlockType):
+ while max(blocks[-4096:]) > maxBlockType:
#guess the block array by starting at the end of the file
#and sliding the blockCount-sized window back until it
#looks like every block has a valid blockNumber
View
@@ -177,7 +177,7 @@ def displayName(self):
@property
def size(self):
"Returns the level's dimensions as a tuple (X,Y,Z)"
- return (self.Width, self.Height, self.Length)
+ return self.Width, self.Height, self.Length
@property
def bounds(self):
@@ -230,7 +230,7 @@ def getChunks(self, chunks=None):
def _getFakeChunkEntities(self, cx, cz):
"""Returns Entities, TileEntities"""
- return ([], [])
+ return [], []
def getChunk(self, cx, cz):
"""Synthesize a FakeChunk object representing the chunk at the given
@@ -453,7 +453,7 @@ def copyBlocksFromFiniteToFinite(self, sourceLevel, sourceBox, destinationPoint,
mask = slice(None, None)
if not (blocksToCopy is None):
- typemask = zeros((256) , dtype='bool')
+ typemask = zeros(256, dtype='bool')
typemask[blocksToCopy] = True;
mask = typemask[convertedSourceBlocks]
@@ -468,7 +468,7 @@ def copyBlocksFromInfinite(self, sourceLevel, sourceBox, destinationPoint, block
def copyBlocksFromInfiniteIter(self, sourceLevel, sourceBox, destinationPoint, blocksToCopy):
if blocksToCopy is not None:
- typemask = zeros((256) , dtype='bool')
+ typemask = zeros(256, dtype='bool')
typemask[blocksToCopy] = True;
@@ -564,7 +564,7 @@ def copyBlocksFromIter(self, sourceLevel, sourceBox, destinationPoint, blocksToC
info(u"Copying {0} blocks from {1} to {2}" .format (sourceBox.volume, sourceBox, destinationPoint))
- if not (sourceLevel.isInfinite):
+ if not sourceLevel.isInfinite:
self.copyBlocksFromFiniteToFinite(sourceLevel, sourceBox, destinationPoint, blocksToCopy)
else:
for i in self.copyBlocksFromInfiniteIter(sourceLevel, sourceBox, destinationPoint, blocksToCopy):
@@ -584,7 +584,7 @@ def setPlayerPosition(self, pos, player="Player"):
pass;
def getPlayerPosition(self, player="Player"):
- return (8, self.Height * 0.75, 8);
+ return 8, self.Height * 0.75, 8;
def getPlayerDimension(self, player="Player"): return 0;
def setPlayerDimension(self, d, player="Player"): return;
@@ -599,7 +599,7 @@ def setPlayerOrientation(self, yp, player="Player"):
pass
def getPlayerOrientation(self, player="Player"):
- return (-45., 0.)
+ return -45., 0.
# --- Dummy Lighting Methods ---
View
@@ -804,7 +804,7 @@ def conversionFunc(destMats, sourceMats):
return func
def convertBlocks(destMats, sourceMats, blocks, blockData):
- if sourceMats == destMats: return (blocks, blockData)
+ if sourceMats == destMats: return blocks, blockData
return conversionFunc(destMats, sourceMats)(blocks, blockData)
View
6 mce.py
@@ -187,7 +187,7 @@ def readPoint(self, command, isPoint=True):
except ValueError:
raise UsageError, "Error decoding point input (expected a number)."
- return (x, y, z)
+ return x, y, z
except IndexError:
raise UsageError, "Error decoding point input (expected more values)."
@@ -207,7 +207,7 @@ def readPoint(self, command, isPoint=True):
except IndexError:
raise UsageError, "Error decoding point input (expected more values)."
- return (x, y, z)
+ return x, y, z
def readBlockInfo(self, command):
keyword = command.pop(0)
@@ -638,7 +638,7 @@ def _region(self, command):
"""
level = self.level
assert(isinstance(level, mclevel.MCInfdevOldLevel))
- assert(level.version)
+ assert level.version
def getFreeSectors(rf):
runs = []
start = None
View
@@ -205,18 +205,18 @@ def fromFile(filename, loadInfinite=True):
if not os.path.exists(filename):
raise IOError, "File not found: " + filename
- if (ZipSchematic._isLevel(filename)):
+ if ZipSchematic._isLevel(filename):
info("Zipfile found, attempting zipped infinite level")
lev = ZipSchematic(filename);
info("Detected zipped Infdev level")
return lev
- if (PocketWorld._isLevel(filename)):
+ if PocketWorld._isLevel(filename):
return PocketWorld(filename)
- if (MCInfdevOldLevel._isLevel(filename)):
+ if MCInfdevOldLevel._isLevel(filename):
info(u"Detected Infdev level.dat")
- if (loadInfinite):
+ if loadInfinite:
return MCInfdevOldLevel(filename=filename);
else:
raise ValueError, "Asked to load {0} which is an infinite level, loadInfinite was False".format(os.path.basename(filename));
@@ -278,14 +278,14 @@ def fromFile(filename, loadInfinite=True):
raise LoadingError, ("Multiple errors encountered", e, e2), sys.exc_info()[2]
else:
- if(MCIndevLevel._isTagLevel(root_tag)):
+ if MCIndevLevel._isTagLevel(root_tag):
info(u"Detected Indev .mclevel")
return MCIndevLevel(root_tag, filename)
- if(MCSchematic._isTagLevel(root_tag)):
+ if MCSchematic._isTagLevel(root_tag):
info(u"Detected Schematic.")
return MCSchematic(root_tag=root_tag, filename=filename)
- if (INVEditChest._isTagLevel(root_tag)):
+ if INVEditChest._isTagLevel(root_tag):
info(u"Detected INVEdit inventory file")
return INVEditChest(root_tag=root_tag, filename=filename);
View
@@ -207,7 +207,7 @@ def saveChunk(self, chunk):
sectorsNeeded = (len(data) + self.CHUNK_HEADER_SIZE) / self.SECTOR_BYTES + 1;
if sectorsNeeded >= 256: return
- if (sectorNumber != 0 and sectorsAllocated >= sectorsNeeded):
+ if sectorNumber != 0 and sectorsAllocated >= sectorsNeeded:
debug("REGION SAVE {0},{1} rewriting {2}b".format(cx, cz, len(data)))
self.writeSector(sectorNumber, data, format)
else:
View
@@ -82,13 +82,13 @@ def pretty_string(self, indent=0):
def write_tag(self, buf):
buf.write(struct.pack(TAGfmt, self.tag))
def write_name(self, buf):
- if(self.name != None):
+ if self.name != None:
TAG_String(self.name).write_value(buf)
def write_value(self, buf):
buf.write(struct.pack(self.fmt, self.value))
def save(self, filename="", buf=None):
- if(filename):
+ if filename:
self.saveGzipped(filename);
return;
"Save the tagged element to a file."
@@ -313,7 +313,7 @@ def load_from(cls, data, data_cursor):
while data_cursor < len(data):
tag_type = data[data_cursor];
data_cursor += 1
- if(tag_type == 0):
+ if tag_type == 0:
break
tag, data_cursor = load_named(data, data_cursor, tag_type)
@@ -358,7 +358,7 @@ def __setitem__(self, k, v):
elif isinstance(v, basestring):
v = TAG_String(v)
- if not (v.__class__ in tag_classes.values()): raise TypeError("Invalid type %s for TAG_Compound" % (v.__class__))
+ if not (v.__class__ in tag_classes.values()): raise TypeError("Invalid type %s for TAG_Compound" % v.__class__)
"""remove any items already named "k". """
olditems = filter(lambda x:x.name == k, self.value)
for i in olditems: self.value.remove(i)
@@ -429,7 +429,7 @@ def __init__(self, value=[], name=None, list_type=TAG_Compound):
self.name = name
self.list_type = list_type.tag
- if(len(value)):
+ if len(value):
self.list_type = value[0].tag;
value = filter(lambda x:x.__class__ == value[0].__class__, value)
View
@@ -169,7 +169,7 @@ def testErrors(self):
newlevel = nbt.load(buf=sio.getvalue())
n = newlevel["Map"]["Spawn"][0].name
- if(n): print "Named list element failed: %s" % n;
+ if n: print "Named list element failed: %s" % n;
"""
attempt to delete non-existent TAG_Compound elements
View
@@ -141,7 +141,7 @@ def need_events(self, count):
level = -1
if level < 0:
return False
- return (len(self.events) < count+1)
+ return len(self.events) < count+1
def increase_indent(self, flow=False, indentless=False):
self.indents.append(self.indent)
Oops, something went wrong.

0 comments on commit 8fac69e

Please sign in to comment.