From: Roland Mechler Date: Fri, 15 Apr 2016 23:35:09 +0000 (+0000) Subject: pybind: removed unneccesary parentheses from if statements X-Git-Tag: v11.0.0~870^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F8623%2Fhead;p=ceph.git pybind: removed unneccesary parentheses from if statements Signed-off-by: Roland Mechler --- diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py index 021c53d8bcd..96af31f4025 100644 --- a/src/pybind/ceph_argparse.py +++ b/src/pybind/ceph_argparse.py @@ -256,7 +256,7 @@ class CephIPAddr(CephArgtype): type = 4 if type == 4: port = s.find(':') - if (port != -1): + if port != -1: a = s[:port] p = s[port + 1:] if int(p) > 65535: @@ -540,7 +540,7 @@ class CephPrefix(CephArgtype): self.val = s return else: - if (s == self.prefix): + if s == self.prefix: self.val = s return @@ -980,7 +980,7 @@ def validate_command(sigdict, args, verbose=False): for cmdtag, cmd in sigdict.iteritems(): sig = cmd['sig'] matched = matchnum(args, sig, partial=True) - if (matched > best_match_cnt): + if matched > best_match_cnt: if verbose: print >> sys.stderr, \ "better match: {0} > {1}: {2}:{3} ".\ diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index d3b581b8157..ef505053f81 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -433,11 +433,11 @@ cdef class LibCephFS(object): ret_buf = realloc_chk(ret_buf, length) with nogil: ret = ceph_conf_get(self.cluster, _option, ret_buf, length) - if (ret == 0): + if ret == 0: return decode_cstr(ret_buf) - elif (ret == -errno.ENAMETOOLONG): + elif ret == -errno.ENAMETOOLONG: length = length * 2 - elif (ret == -errno.ENOENT): + elif ret == -errno.ENOENT: return None else: raise make_ex(ret, "error calling conf_get") @@ -455,7 +455,7 @@ cdef class LibCephFS(object): with nogil: ret = ceph_conf_set(self.cluster, _option, _val) - if (ret != 0): + if ret != 0: raise make_ex(ret, "error calling conf_set") def init(self): diff --git a/src/pybind/rados/rados.pyx b/src/pybind/rados/rados.pyx index 84f0e33a020..ac24a8297ba 100644 --- a/src/pybind/rados/rados.pyx +++ b/src/pybind/rados/rados.pyx @@ -627,7 +627,7 @@ Rados object in state %s." % self.state) char *_path = opt_str(path) with nogil: ret = rados_conf_read_file(self.cluster, _path) - if (ret != 0): + if ret != 0: raise make_ex(ret, "error calling conf_read_file") def conf_parse_argv(self, args): @@ -678,7 +678,7 @@ Rados object in state %s." % self.state) char *_var = var with nogil: ret = rados_conf_parse_env(self.cluster, _var) - if (ret != 0): + if ret != 0: raise make_ex(ret, "error calling conf_parse_env") @requires(('option', str_type)) @@ -704,11 +704,11 @@ Rados object in state %s." % self.state) ret_buf = realloc_chk(ret_buf, length) with nogil: ret = rados_conf_get(self.cluster, _option, ret_buf, length) - if (ret == 0): + if ret == 0: return decode_cstr(ret_buf) - elif (ret == -errno.ENAMETOOLONG): + elif ret == -errno.ENAMETOOLONG: length = length * 2 - elif (ret == -errno.ENOENT): + elif ret == -errno.ENOENT: return None else: raise make_ex(ret, "error calling conf_get") @@ -736,7 +736,7 @@ Rados object in state %s." % self.state) with nogil: ret = rados_conf_set(self.cluster, _option, _val) - if (ret != 0): + if ret != 0: raise make_ex(ret, "error calling conf_set") def ping_monitor(self, mon_id): @@ -781,7 +781,7 @@ Rados object in state %s." % self.state) # for now and remove it later with nogil: ret = rados_connect(self.cluster) - if (ret != 0): + if ret != 0: raise make_ex(ret, "error connecting to the cluster") self.state = "connected" @@ -837,9 +837,9 @@ Rados object in state %s." % self.state) with nogil: ret = rados_pool_lookup(self.cluster, _pool_name) - if (ret >= 0): + if ret >= 0: return True - elif (ret == -errno.ENOENT): + elif ret == -errno.ENOENT: return False else: raise make_ex(ret, "error looking up pool '%s'" % pool_name) @@ -862,9 +862,9 @@ Rados object in state %s." % self.state) with nogil: ret = rados_pool_lookup(self.cluster, _pool_name) - if (ret >= 0): + if ret >= 0: return int(ret) - elif (ret == -errno.ENOENT): + elif ret == -errno.ENOENT: return None else: raise make_ex(ret, "error looking up pool '%s'" % pool_name) @@ -1329,7 +1329,7 @@ cdef class OmapIterator(object): with nogil: ret = rados_omap_get_next(self.ctx, &key_, &val_, &len_) - if (ret != 0): + if ret != 0: raise make_ex(ret, "error iterating over the omap") if key_ == NULL: raise StopIteration() @@ -1427,7 +1427,7 @@ cdef class XattrIterator(object): with nogil: ret = rados_getxattrs_next(self.it, &name_, &val_, &len_) - if (ret != 0): + if ret != 0: raise make_ex(ret, "error iterating over the extended attributes \ in '%s'" % self.oid) if name_ == NULL: @@ -1462,10 +1462,10 @@ cdef class SnapIterator(object): with nogil: ret = rados_ioctx_snap_list(ioctx.io, self.snaps, num_snaps) - if (ret >= 0): + if ret >= 0: self.max_snap = ret break - elif (ret != -errno.ERANGE): + elif ret != -errno.ERANGE: raise make_ex(ret, "error calling rados_snap_list for \ ioctx '%s'" % self.ioctx.name) num_snaps = num_snaps * 2 @@ -1481,7 +1481,7 @@ ioctx '%s'" % self.ioctx.name) :raises: :class:`Error`, StopIteration :returns: Snap - next snapshot """ - if (self.cur_snap >= self.max_snap): + if self.cur_snap >= self.max_snap: raise StopIteration cdef: @@ -1494,9 +1494,9 @@ ioctx '%s'" % self.ioctx.name) name = realloc_chk(name, name_len) with nogil: ret = rados_ioctx_snap_get_name(self.ioctx.io, snap_id, name, name_len) - if (ret == 0): + if ret == 0: break - elif (ret != -errno.ERANGE): + elif ret != -errno.ERANGE: raise make_ex(ret, "rados_snap_get_name error") else: name_len = name_len * 2 @@ -1537,7 +1537,7 @@ cdef class Snap(object): with nogil: ret = rados_ioctx_snap_get_stamp(self.ioctx.io, self.snap_id, &snap_time) - if (ret != 0): + if ret != 0: raise make_ex(ret, "rados_ioctx_snap_get_stamp error") return datetime.fromtimestamp(snap_time) @@ -2507,7 +2507,7 @@ returned %d, but should return zero on success." % (self.name, ret)) ret_buf = realloc_chk(ret_buf, ret_length) with nogil: ret = rados_getxattr(self.io, _key, _xattr_name, ret_buf, ret_length) - if (ret == -errno.ERANGE): + if ret == -errno.ERANGE: ret_length *= 2 elif ret < 0: raise make_ex(ret, "Failed to get xattr %r" % xattr_name) @@ -2629,7 +2629,7 @@ returned %d, but should return zero on success." % (self.name, ret)) with nogil: ret = rados_ioctx_snap_create(self.io, _snap_name) - if (ret != 0): + if ret != 0: raise make_ex(ret, "Failed to create snap %s" % snap_name) @requires(('snap_name', str_type)) @@ -2649,7 +2649,7 @@ returned %d, but should return zero on success." % (self.name, ret)) with nogil: ret = rados_ioctx_snap_remove(self.io, _snap_name) - if (ret != 0): + if ret != 0: raise make_ex(ret, "Failed to remove snap %s" % snap_name) @requires(('snap_name', str_type)) @@ -2672,7 +2672,7 @@ returned %d, but should return zero on success." % (self.name, ret)) with nogil: ret = rados_ioctx_snap_lookup(self.io, _snap_name, &snap_id) - if (ret != 0): + if ret != 0: raise make_ex(ret, "Failed to lookup snap %s" % snap_name) return Snap(self, snap_name, int(snap_id)) @@ -2698,7 +2698,7 @@ returned %d, but should return zero on success." % (self.name, ret)) with nogil: ret = rados_ioctx_snap_rollback(self.io, _oid, _snap_name) - if (ret != 0): + if ret != 0: raise make_ex(ret, "Failed to rollback %s" % oid) def get_last_version(self):