Skip to content

Commit

Permalink
PEP8: fix E226: missing whitespace around arithmetic operator
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Guo <[email protected]>
Reviewed-by: Andrew Bartlett <[email protected]>
Reviewed-by: Douglas Bagnall <[email protected]>
  • Loading branch information
catalyst-joe-guo authored and douglasbagnall committed Aug 24, 2018
1 parent 32266d2 commit 87bbc2d
Show file tree
Hide file tree
Showing 54 changed files with 186 additions and 186 deletions.
2 changes: 1 addition & 1 deletion lib/ldb-samba/tests/match_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ def setUp(self):
FLAG_MOD_ADD, "member")
self.ldb.modify(m)

self.question = 6*(9-2)
self.question = 6 * (9 -2)
self.answer = 42

def tearDown(self):
Expand Down
2 changes: 1 addition & 1 deletion lib/ldb/tests/python/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2097,7 +2097,7 @@ def test_add(self):

def test_remove_base_components(self):
x = ldb.Dn(self.ldb, "dc=foo24,dc=samba,dc=org")
x.remove_base_components(len(x)-1)
x.remove_base_components(len(x) - 1)
self.assertEqual("dc=foo24", str(x))

def test_parse_ldif(self):
Expand Down
2 changes: 1 addition & 1 deletion python/samba/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def check_all_substituted(text):
var_end = text.find("}", var_start)

raise Exception("Not all variables substituted: %s" %
text[var_start:var_end+1])
text[var_start:var_end + 1])


def read_and_sub_file(file_name, subst_vars):
Expand Down
2 changes: 1 addition & 1 deletion python/samba/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __init__(self, samdb, dnstring, syntax_oid=None):
raise RuntimeError("Invalid DN %s" % dnstring)
prefix_len = 4 + len(colons[1]) + int(colons[1])
self.prefix = dnstring[0:prefix_len]
self.binary = self.prefix[3+len(colons[1]):-1]
self.binary = self.prefix[3 + len(colons[1]):-1]
self.dnstring = dnstring[prefix_len:]
else:
self.dnstring = dnstring
Expand Down
2 changes: 1 addition & 1 deletion python/samba/dbchecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2485,7 +2485,7 @@ def check_rootdse(self):
# check that the dsServiceName is in GUID form
if not 'dsServiceName' in obj:
self.report('ERROR: dsServiceName missing in @ROOTDSE')
return error_count+1
return error_count + 1

if not obj['dsServiceName'][0].startswith('<GUID='):
self.report('ERROR: dsServiceName not in GUID form in @ROOTDSE')
Expand Down
4 changes: 2 additions & 2 deletions python/samba/gp_sec_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

class inf_to_kdc_tdb(gp_ext_setter):
def mins_to_hours(self):
return '%d' % (int(self.val)/60)
return '%d' % (int(self.val) / 60)

def days_to_hours(self):
return '%d' % (int(self.val)*24)
return '%d' % (int(self.val) * 24)

def set_kdc_tdb(self, val):
old_val = self.gp_db.gpostore.get(self.attribute)
Expand Down
6 changes: 3 additions & 3 deletions python/samba/gpclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def set_guid(self, guid):
prev = apply_log.find('guid[@value="%s"]' % guid)
if prev is None:
item = etree.SubElement(apply_log, 'guid')
item.attrib['count'] = '%d' % (len(apply_log)-1)
item.attrib['count'] = '%d' % (len(apply_log) - 1)
item.attrib['value'] = guid

def apply_log_pop(self):
Expand All @@ -155,7 +155,7 @@ def apply_log_pop(self):
user_obj = self.gpdb.find('user[@name="%s"]' % self.user)
apply_log = user_obj.find('applylog')
if apply_log is not None:
ret = apply_log.find('guid[@count="%d"]' % (len(apply_log)-1))
ret = apply_log.find('guid[@count="%d"]' % (len(apply_log) - 1))
if ret is not None:
apply_log.remove(ret)
return ret.attrib['value']
Expand Down Expand Up @@ -436,7 +436,7 @@ def cache_gpo_dir(conn, cache, sub_dir):
def check_safe_path(path):
dirs = re.split('/|\\\\', path)
if 'sysvol' in path:
dirs = dirs[dirs.index('sysvol')+1:]
dirs = dirs[dirs.index('sysvol') + 1:]
if not '..' in dirs:
return os.path.join(*dirs)
raise OSError(path)
Expand Down
2 changes: 1 addition & 1 deletion python/samba/hostconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __getitem__(self, name):

def __len__(self):
if "global" in self._lp.services():
return len(self._lp)-1
return len(self._lp) - 1
return len(self._lp)

def keys(self):
Expand Down
18 changes: 9 additions & 9 deletions python/samba/kcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2194,27 +2194,27 @@ def construct_intrasite_graph(self, site_local, dc_local,

# For each r(i) from (0 <= i < |R|-1)
i = 0
while i < (r_len-1):
while i < (r_len - 1):
# Add an edge from r(i) to r(i+1) if r(i) is a full
# replica or r(i+1) is a partial replica
if not r_list[i].is_partial() or r_list[i+1].is_partial():
graph_list[i+1].add_edge_from(r_list[i].rep_dsa_dnstr)
if not r_list[i].is_partial() or r_list[i +1].is_partial():
graph_list[i + 1].add_edge_from(r_list[i].rep_dsa_dnstr)

# Add an edge from r(i+1) to r(i) if r(i+1) is a full
# replica or ri is a partial replica.
if not r_list[i+1].is_partial() or r_list[i].is_partial():
graph_list[i].add_edge_from(r_list[i+1].rep_dsa_dnstr)
if not r_list[i + 1].is_partial() or r_list[i].is_partial():
graph_list[i].add_edge_from(r_list[i + 1].rep_dsa_dnstr)
i = i + 1

# Add an edge from r|R|-1 to r0 if r|R|-1 is a full replica
# or r0 is a partial replica.
if not r_list[r_len-1].is_partial() or r_list[0].is_partial():
graph_list[0].add_edge_from(r_list[r_len-1].rep_dsa_dnstr)
if not r_list[r_len - 1].is_partial() or r_list[0].is_partial():
graph_list[0].add_edge_from(r_list[r_len - 1].rep_dsa_dnstr)

# Add an edge from r0 to r|R|-1 if r0 is a full replica or
# r|R|-1 is a partial replica.
if not r_list[0].is_partial() or r_list[r_len-1].is_partial():
graph_list[r_len-1].add_edge_from(r_list[0].rep_dsa_dnstr)
if not r_list[0].is_partial() or r_list[r_len -1].is_partial():
graph_list[r_len - 1].add_edge_from(r_list[0].rep_dsa_dnstr)

DEBUG("r_list is length %s" % len(r_list))
DEBUG('\n'.join(str((x.rep_dsa_guid, x.rep_dsa_dnstr))
Expand Down
2 changes: 1 addition & 1 deletion python/samba/ms_forest_updates_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def read_ms_markdown(in_file, out_folder=None, out_dict={}):
for node in tree:
if node.text and node.text.startswith('|Operation'):
# Strip first and last |
updates = [x[1:len(x)-1].split('|') for x in
updates = [x[1:len(x) - 1].split('|') for x in
ET.tostring(node,method='text').splitlines()]
for update in updates[2:]:
output = re.match('Operation (\d+): {(.*)}', update[0])
Expand Down
4 changes: 2 additions & 2 deletions python/samba/netcmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Option(optparse.Option):
class PlainHelpFormatter(optparse.IndentedHelpFormatter):
def format_description(self,description=""):
desc_width = self.width - self.current_indent
indent = " "*self.current_indent
indent = " " * self.current_indent
paragraphs = description.split('\n')
wrapped_paragraphs = [
textwrap.fill(p,
Expand Down Expand Up @@ -137,7 +137,7 @@ def _create_parser(self, prog, epilog=None):
return parser, optiongroups

def message(self, text):
self.outf.write(text+"\n")
self.outf.write(text + "\n")

def _run(self, *argv):
parser, optiongroups = self._create_parser(argv[0])
Expand Down
2 changes: 1 addition & 1 deletion python/samba/netcmd/computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def run(self, computername, new_ou_dn, credopts=None, sambaopts=None,
if not full_new_ou_dn.is_child_of(domain_dn):
full_new_ou_dn.add_base(domain_dn)
new_computer_dn = ldb.Dn(samdb, str(computer_dn))
new_computer_dn.remove_base_components(len(computer_dn)-1)
new_computer_dn.remove_base_components(len(computer_dn) -1)
new_computer_dn.add_base(full_new_ou_dn)
try:
samdb.rename(computer_dn, new_computer_dn)
Expand Down
2 changes: 1 addition & 1 deletion python/samba/netcmd/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2385,7 +2385,7 @@ def get_password(name):
# 512 bytes and a 2 bytes confounder is required.
#
def random_trust_secret(length):
pw = samba.generate_random_machine_password(length//2, length//2)
pw = samba.generate_random_machine_password(length // 2, length // 2)
return string_to_byte_array(pw.encode('utf-16-le'))

if local_trust_info.trust_direction & lsa.LSA_TRUST_DIRECTION_INBOUND:
Expand Down
2 changes: 1 addition & 1 deletion python/samba/netcmd/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def run(self, groupname, new_parent_dn, credopts=None, sambaopts=None,
(new_parent_dn, e.message))

full_new_group_dn = ldb.Dn(samdb, str(group_dn))
full_new_group_dn.remove_base_components(len(group_dn)-1)
full_new_group_dn.remove_base_components(len(group_dn) - 1)
full_new_group_dn.add_base(full_new_parent_dn)

try:
Expand Down
66 changes: 33 additions & 33 deletions python/samba/netcmd/ldapcmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ def __init__(self, host, creds, lp,
# when compare content of two DCs. Uncomment for DEBUG purposes.
if self.two_domains and not self.quiet:
self.outf.write("\n* Place-holders for %s:\n" % self.host)
self.outf.write(4*" " + "${DOMAIN_DN} => %s\n" %
self.outf.write(4 * " " + "${DOMAIN_DN} => %s\n" %
self.base_dn)
self.outf.write(4*" " + "${DOMAIN_NETBIOS} => %s\n" %
self.outf.write(4 * " " + "${DOMAIN_NETBIOS} => %s\n" %
self.domain_netbios)
self.outf.write(4*" " + "${SERVER_NAME} => %s\n" %
self.outf.write(4 * " " + "${SERVER_NAME} => %s\n" %
self.server_names)
self.outf.write(4*" " + "${DOMAIN_NAME} => %s\n" %
self.outf.write(4 * " " + "${DOMAIN_NAME} => %s\n" %
self.domain_name)

def find_domain_sid(self):
Expand Down Expand Up @@ -303,9 +303,9 @@ def fix_sid(self, ace):
def diff_1(self, other):
res = ""
if len(self.dacl_list) != len(other.dacl_list):
res += 4*" " + "Difference in ACE count:\n"
res += 8*" " + "=> %s\n" % len(self.dacl_list)
res += 8*" " + "=> %s\n" % len(other.dacl_list)
res += 4 * " " + "Difference in ACE count:\n"
res += 8 * " " + "=> %s\n" % len(self.dacl_list)
res += 8 * " " + "=> %s\n" % len(other.dacl_list)
#
i = 0
flag = True
Expand Down Expand Up @@ -336,9 +336,9 @@ def diff_1(self, other):
def diff_2(self, other):
res = ""
if len(self.dacl_list) != len(other.dacl_list):
res += 4*" " + "Difference in ACE count:\n"
res += 8*" " + "=> %s\n" % len(self.dacl_list)
res += 8*" " + "=> %s\n" % len(other.dacl_list)
res += 4 * " " + "Difference in ACE count:\n"
res += 8 * " " + "=> %s\n" % len(self.dacl_list)
res += 8 * " " + "=> %s\n" % len(other.dacl_list)
#
common_aces = []
self_aces = []
Expand All @@ -356,9 +356,9 @@ def diff_2(self, other):
common_aces.append(ace)
self_aces = sorted(self_aces)
if len(self_aces) > 0:
res += 4*" " + "ACEs found only in %s:\n" % self.con.host
res += 4 *" " + "ACEs found only in %s:\n" % self.con.host
for ace in self_aces:
res += 8*" " + ace + "\n"
res += 8 * " " + ace + "\n"
#
for ace in other_dacl_list_fixed:
try:
Expand All @@ -369,15 +369,15 @@ def diff_2(self, other):
common_aces.append(ace)
other_aces = sorted(other_aces)
if len(other_aces) > 0:
res += 4*" " + "ACEs found only in %s:\n" % other.con.host
res += 4 *" " + "ACEs found only in %s:\n" % other.con.host
for ace in other_aces:
res += 8*" " + ace + "\n"
res += 8 * " " + ace + "\n"
#
common_aces = sorted(list(set(common_aces)))
if self.con.verbose:
res += 4*" " + "ACEs found in both:\n"
res += 4 *" " + "ACEs found in both:\n"
for ace in common_aces:
res += 8*" " + ace + "\n"
res += 8 * " " + ace + "\n"
return (self_aces == [] and other_aces == [], res)

class LDAPObject(object):
Expand Down Expand Up @@ -514,14 +514,14 @@ def log(self, msg):
Log on the screen if there is no --quiet option set
"""
if not self.quiet:
self.outf.write(msg+"\n")
self.outf.write(msg +"\n")

def fix_dn(self, s):
res = "%s" % s
if not self.two_domains:
return res
if res.upper().endswith(self.con.base_dn.upper()):
res = res[:len(res)-len(self.con.base_dn)] + "${DOMAIN_DN}"
res = res[:len(res) - len(self.con.base_dn)] + "${DOMAIN_DN}"
return res

def fix_domain_name(self, s):
Expand Down Expand Up @@ -575,29 +575,29 @@ def cmp_attrs(self, other):
other.unique_attrs = []
if self.attributes.keys() != other.attributes.keys():
#
title = 4*" " + "Attributes found only in %s:" % self.con.host
title = 4 * " " + "Attributes found only in %s:" % self.con.host
for x in self.attributes.keys():
if not x in other.attributes.keys() and \
not x.upper() in [q.upper() for q in other.ignore_attributes]:
if title:
res += title + "\n"
title = None
res += 8*" " + x + "\n"
res += 8 * " " + x + "\n"
self.unique_attrs.append(x)
#
title = 4*" " + "Attributes found only in %s:" % other.con.host
title = 4 *" " + "Attributes found only in %s:" % other.con.host
for x in other.attributes.keys():
if not x in self.attributes.keys() and \
not x.upper() in [q.upper() for q in self.ignore_attributes]:
if title:
res += title + "\n"
title = None
res += 8*" " + x + "\n"
res += 8 * " " + x + "\n"
other.unique_attrs.append(x)
#
missing_attrs = [x.upper() for x in self.unique_attrs]
missing_attrs += [x.upper() for x in other.unique_attrs]
title = 4*" " + "Difference in attribute values:"
title = 4 * " " + "Difference in attribute values:"
for x in self.attributes.keys():
if x.upper() in self.ignore_attributes or x.upper() in missing_attrs:
continue
Expand Down Expand Up @@ -667,9 +667,9 @@ def cmp_attrs(self, other):
res += title + "\n"
title = None
if p and q:
res += 8*" " + x + " => \n%s\n%s" % (p, q) + "\n"
res += 8 * " " + x + " => \n%s\n%s" % (p, q) + "\n"
else:
res += 8*" " + x + " => \n%s\n%s" % (self.attributes[x], other.attributes[x]) + "\n"
res += 8 * " " + x + " => \n%s\n%s" % (self.attributes[x], other.attributes[x]) + "\n"
self.df_value_attrs.append(x)
#
if self.unique_attrs + other.unique_attrs != []:
Expand Down Expand Up @@ -715,7 +715,7 @@ def __init__(self, connection, context, dn_list=None, filter_list=None,
while counter < len(self.dn_list) and self.two_domains:
# Use alias reference
tmp = self.dn_list[counter]
tmp = tmp[:len(tmp)-len(self.con.base_dn)] + "${DOMAIN_DN}"
tmp = tmp[:len(tmp) -len(self.con.base_dn)] + "${DOMAIN_DN}"
tmp = tmp.replace("CN=%s" % self.con.domain_netbios, "CN=${DOMAIN_NETBIOS}")
if len(self.con.server_names) == 1:
for x in self.con.server_names:
Expand All @@ -731,7 +731,7 @@ def log(self, msg):
Log on the screen if there is no --quiet option set
"""
if not self.quiet:
self.outf.write(msg+"\n")
self.outf.write(msg + "\n")

def update_size(self):
self.size = len(self.dn_list)
Expand All @@ -755,7 +755,7 @@ def __eq__(self, other):
self.log(title)
title = None
res = False
self.log(4*" " + x)
self.log(4 * " " + x)
self.dn_list[self.dn_list.index(x)] = ""
self.dn_list = [x for x in self.dn_list if x]
#
Expand All @@ -766,7 +766,7 @@ def __eq__(self, other):
self.log(title)
title = None
res = False
self.log(4*" " + x)
self.log(4 * " " + x)
other.dn_list[other.dn_list.index(x)] = ""
other.dn_list = [x for x in other.dn_list if x]
#
Expand Down Expand Up @@ -811,13 +811,13 @@ def __eq__(self, other):
self.log("\nComparing:")
self.log("'%s' [%s]" % (object1.dn, object1.con.host))
self.log("'%s' [%s]" % (object2.dn, object2.con.host))
self.log(4*" " + "OK")
self.log(4 * " " + "OK")
else:
self.log("\nComparing:")
self.log("'%s' [%s]" % (object1.dn, object1.con.host))
self.log("'%s' [%s]" % (object2.dn, object2.con.host))
self.log(object1.screen_output)
self.log(4*" " + "FAILED")
self.log(4 * " " + "FAILED")
res = False
self.summary = object1.summary
other.summary = object2.summary
Expand Down Expand Up @@ -871,11 +871,11 @@ def print_summary(self):
#
if self.summary["unique_attrs"]:
self.log("\nAttributes found only in %s:" % self.con.host)
self.log("".join([str("\n" + 4*" " + x) for x in self.summary["unique_attrs"]]))
self.log("".join([str("\n" + 4 * " " + x) for x in self.summary["unique_attrs"]]))
#
if self.summary["df_value_attrs"]:
self.log("\nAttributes with different values:")
self.log("".join([str("\n" + 4*" " + x) for x in self.summary["df_value_attrs"]]))
self.log("".join([str("\n" + 4 * " " + x) for x in self.summary["df_value_attrs"]]))
self.summary["df_value_attrs"] = []


Expand Down
2 changes: 1 addition & 1 deletion python/samba/netcmd/nettime.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ def run(self, server_name=None, credopts=None, sambaopts=None,
net = Net(creds, lp, server=credopts.ipaddress)
if server_name is None:
server_name = common.netcmd_dnsname(lp)
self.outf.write(net.time(server_name)+"\n")
self.outf.write(net.time(server_name) + "\n")
Loading

0 comments on commit 87bbc2d

Please sign in to comment.