Commit 4544378f authored by Bastian Blank's avatar Bastian Blank 🙊 Committed by Joerg Jaspert

Fix E226: Missing whitespace around arithmetic operator

parent 903e5be1
......@@ -126,7 +126,7 @@ def main():
if "Dinstall::MailWhiteList" in Cnf and Cnf["Dinstall::MailWhiteList"] != "":
f = utils.open_file(Cnf["Dinstall::MailWhiteList"], "a")
for mail in emails:
f.write(mail+'\n')
f.write(mail + '\n')
f.close()
print "Added:\nUid:\t %s (ID: %s)\nMaint:\t %s\nFP:\t %s" % (uid, uid_id, \
......@@ -145,7 +145,7 @@ def main():
Subst["__HOSTNAME__"] = Cnf["Dinstall::MyHost"]
Subst["__DISTRO__"] = Cnf["Dinstall::MyDistribution"]
Subst["__SUMMARY__"] = summary
new_add_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/add-user.added")
new_add_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"] + "/add-user.added")
utils.send_mail(new_add_message)
else:
......
......@@ -144,7 +144,7 @@ def send_email(commands, simulate=False):
"__DAK_ADDRESS__": Cnf["Dinstall::MyAdminAddress"]}
bts_mail_message = utils.TemplateSubst(
Subst,Cnf["Dir::Templates"]+"/bts-categorize")
Subst,Cnf["Dir::Templates"] + "/bts-categorize")
if simulate:
print bts_mail_message
......
......@@ -479,7 +479,7 @@ def chk_bd_process_dir(unused, dirname, filenames):
for name in filenames:
if not name.endswith(".dsc"):
continue
filename = os.path.abspath(dirname+'/'+name)
filename = os.path.abspath(dirname + '/' + name)
dsc = utils.parse_changes(filename, dsc_file=1)
for field_name in ["build-depends", "build-depends-indep"]:
field = dsc.get(field_name)
......
......@@ -76,7 +76,7 @@ def init(cnf):
now_date = datetime.now()
# Used for working out times
delete_date = int(time.time())-(int(Options["Days"])*84600)
delete_date = int(time.time()) - (int(Options["Days"]) * 84600)
morguedir = cnf.get("Dir::Morgue", os.path.join("Dir::Pool", 'morgue'))
morguesubdir = cnf.get("Clean-Queues::MorgueSubDir", 'queue')
......
......@@ -253,7 +253,7 @@ def process_file(file, suite, component, otype, mode, action, session):
session.commit()
if not cnf["Control-Overrides::Options::Quiet"]:
print "Done in %d seconds. [Updated = %d, Added = %d, Removed = %d, Skipped = %d, Errors = %d]" % (int(time.time()-start_time), c_updated, c_added, c_removed, c_skipped, c_error)
print "Done in %d seconds. [Updated = %d, Added = %d, Removed = %d, Skipped = %d, Errors = %d]" % (int(time.time() - start_time), c_updated, c_added, c_removed, c_skipped, c_error)
Logger.log(["set complete", c_updated, c_added, c_removed, c_skipped, c_error])
......
......@@ -693,7 +693,7 @@ def main():
###
if Options["Mode"] == "full":
print "="*75
print "=" * 75
print
if "nfu" in checks:
......
......@@ -198,7 +198,7 @@ def main():
# First see if we were invoked with/as the name of a module
cmdname = sys.argv[0]
cmdname = cmdname[cmdname.rfind("/")+1:]
cmdname = cmdname[cmdname.rfind("/") + 1:]
if cmdname in modules:
pass
# Otherwise the argument is the module
......
......@@ -169,7 +169,7 @@ def formatted_text(s, strip=False):
def output_row(s):
if use_html:
return """<tr><td>"""+s+"""</td></tr>"""
return """<tr><td>""" + s + """</td></tr>"""
else:
return s
......@@ -339,13 +339,13 @@ def read_changes_or_dsc(suite, filename, session=None):
if use_html:
dsc[k] = formatted_text(dsc[k], strip=True)
else:
dsc[k] = ('\n'+'\n'.join(map(lambda x: ' '+x, dsc[k].split('\n')))).rstrip()
dsc[k] = ('\n' + '\n'.join(map(lambda x: ' ' + x, dsc[k].split('\n')))).rstrip()
else:
dsc[k] = escape_if_needed(dsc[k])
keysinorder = filter(lambda x: not x.lower().startswith('checksums-'), keysinorder)
filecontents = '\n'.join(map(lambda x: format_field(x,dsc[x.lower()]), keysinorder))+'\n'
filecontents = '\n'.join(map(lambda x: format_field(x,dsc[x.lower()]), keysinorder)) + '\n'
return filecontents
......@@ -477,7 +477,7 @@ def output_deb_info(suite, filename, packagename, session=None):
field_value = escape_if_needed(desc)
else:
field_value = escape_if_needed(control.find(key))
to_print += " "+format_field(key,field_value)+'\n'
to_print += " " + format_field(key,field_value) + '\n'
return to_print
......@@ -534,7 +534,7 @@ def get_copyright(deb_filename):
(printed.copyrights[copyrightmd5]))
else:
printed.copyrights[copyrightmd5] = "%s (%s)" % (package, os.path.basename(deb_filename))
return res+formatted_text(cright)
return res + formatted_text(cright)
def get_readme_source(dsc_filename):
......
......@@ -219,10 +219,10 @@ class Updates:
cnt = len(l)
if cnt > self.max:
for h in l[:cnt-self.max]:
for h in l[:cnt - self.max]:
tryunlink("%s/%s.gz" % (self.readpath, h))
del hs[h]
l = l[cnt-self.max:]
l = l[cnt - self.max:]
self.history_order = l[:]
out.write("SHA1-History:\n")
......
......@@ -323,7 +323,7 @@ class ReleaseWriter(object):
if suite.validtime:
validtime = float(suite.validtime)
out.write("Valid-Until: %s\n" % (time.strftime("%a, %d %b %Y %H:%M:%S UTC", time.gmtime(time.time()+validtime))))
out.write("Valid-Until: %s\n" % (time.strftime("%a, %d %b %Y %H:%M:%S UTC", time.gmtime(time.time() + validtime))))
for key, dbfield in boolattrs:
if getattr(suite, dbfield, False):
......
......@@ -60,10 +60,10 @@ def graph(*args):
def deferred_colours():
colours = [0]*16
colours = [0] * 16
for i in range(0,16):
colours[i] = colorsys.hsv_to_rgb(i/16.0, 1.0, 0.5+i/32.0)
colours[i] = ''.join(['%02X' % (c*255) for c in colours[i]])
colours[i] = colorsys.hsv_to_rgb(i / 16.0, 1.0, 0.5 + i / 32.0)
colours[i] = ''.join(['%02X' % (c * 255) for c in colours[i]])
return colours
colours = deferred_colours()
......@@ -104,7 +104,7 @@ GPRINT:ld%i:cur\\: %%.0lf
GPRINT:mind%i:min\\: %%.0lf
GPRINT:maxd%i:max\\: %%.0lf
GPRINT:avgd%i:avg\\: %%.0lf\\j
""" % ((i, rrd_file, i, i, colours[i])+(i,)*13)).strip().split("\n")
""" % ((i, rrd_file, i, i, colours[i]) + (i,) * 13)).strip().split("\n")
rrd_args += extra_args
try:
......@@ -227,12 +227,12 @@ def main():
for name in names:
stdargs = [rrd_dir, image_dir, name, extra_rrdtool_args]
graph(*(stdargs+['day', 'day', 'now-1d']))
graph(*(stdargs+['week', 'week', 'now-1w']))
graph(*(stdargs+['month', 'month', 'now-1m']))
graph(*(stdargs+['year', 'year', 'now-1y']))
graph(*(stdargs+['5years', '5 years', 'now-5y', True]))
graph(*(stdargs+['10years', '10 years', 'now-10y', True]))
graph(*(stdargs + ['day', 'day', 'now-1d']))
graph(*(stdargs + ['week', 'week', 'now-1w']))
graph(*(stdargs + ['month', 'month', 'now-1m']))
graph(*(stdargs + ['year', 'year', 'now-1y']))
graph(*(stdargs + ['5years', '5 years', 'now-5y', True]))
graph(*(stdargs + ['10years', '10 years', 'now-10y', True]))
################################################################################
......
......@@ -82,7 +82,7 @@ def spawn(command):
def sudo(arg, fn, exit):
if Options["Sudo"]:
os.spawnl(os.P_WAIT, "/usr/bin/sudo", "/usr/bin/sudo", "-u", "dak", "-H",
"/usr/local/bin/dak", "new-security-install", "-"+arg)
"/usr/local/bin/dak", "new-security-install", "-" + arg)
else:
fn()
if exit:
......@@ -181,7 +181,7 @@ def main():
dbchange = get_dbchange(os.path.basename(change), session)
# strip epoch from version
version = dbchange.version
version = version[(version.find(':')+1):]
version = version[(version.find(':') + 1):]
# strip possible version from source (binNMUs)
source = dbchange.source.split(None, 1)[0]
acceptfilename = "%s/COMMENTS/ACCEPT.%s_%s" % (os.path.dirname(os.path.abspath(changes[0])), source, version)
......
......@@ -221,7 +221,7 @@ def edit_new(overrides, upload, session):
continue
s = line.split()
# Pad the list if necessary
s[len(s):3] = [None] * (3-len(s))
s[len(s):3] = [None] * (3 - len(s))
(pkg, priority, section) = s[:3]
if pkg.find(':') != -1:
type, pkg = pkg.split(':', 1)
......
......@@ -351,13 +351,13 @@ def update_graph_database(rrd_dir, type, n_source, n_binary):
if not rrd_dir:
return
rrd_file = os.path.join(rrd_dir, type.lower()+'.rrd')
rrd_file = os.path.join(rrd_dir, type.lower() + '.rrd')
update = [rrd_file, "N:%s:%s" % (n_source, n_binary)]
try:
rrdtool.update(*update)
except rrdtool.error:
create = [rrd_file]+"""
create = [rrd_file] + """
--step
300
--start
......@@ -449,7 +449,7 @@ def process_queue(queue, log, rrd_dir):
changedby = ""
sponsor = ""
filename = i[1]["list"][0].changes.changesname
last_modified = time.time()-i[1]["oldest"]
last_modified = time.time() - i[1]["oldest"]
source = i[1]["list"][0].changes.source
if len(source) > max_source_len:
max_source_len = len(source)
......@@ -568,10 +568,10 @@ def process_queue(queue, log, rrd_dir):
log.write("Queue: " + type + "\n")
(name, mail) = maint.split(":", 1)
log.write("Maintainer: " + name + " <"+mail+">" + "\n")
log.write("Maintainer: " + name + " <" + mail + ">" + "\n")
if changedby:
(name, mail) = changedby.split(":", 1)
log.write("Changed-By: " + name + " <"+mail+">" + "\n")
log.write("Changed-By: " + name + " <" + mail + ">" + "\n")
if sponsor:
log.write("Sponsored-By: %s@debian.org\n" % sponsor)
log.write("Distribution:")
......@@ -582,7 +582,7 @@ def process_queue(queue, log, rrd_dir):
if closes:
bug_string = ""
for bugs in closes:
bug_string += "#"+bugs+", "
bug_string += "#" + bugs + ", "
log.write("Closes: " + bug_string[:-2] + "\n")
log.write("Changes-File: " + os.path.basename(changes_file) + "\n")
log.write("\n")
......@@ -615,7 +615,7 @@ def process_queue(queue, log, rrd_dir):
if msg:
print type.upper()
print "-"*len(type)
print "-" * len(type)
print
print msg
print ("%s %s source package%s / %s %s package%s in total / %s %s package%s to be processed." %
......
......@@ -352,7 +352,7 @@ def main():
print summary
print "Maintainer: %s" % ", ".join(maintainer_list)
if Options["Done"]:
print "Will also close bugs: "+Options["Done"]
print "Will also close bugs: " + Options["Done"]
if carbon_copy:
print "Will also send CCs to: " + ", ".join(carbon_copy)
if Options["Do-Close"]:
......
......@@ -109,7 +109,7 @@ def table_row(changesname, delay, changed_by, closes, fingerprint):
global row_number
res = '<tr class="%s">'%((row_number%2) and 'odd' or 'even')
res += (2*'<td valign="top">%s</td>')%tuple(map(html_escape,(changesname,delay)))
res += (2 * '<td valign="top">%s</td>')%tuple(map(html_escape,(changesname,delay)))
res += '<td valign="top">%s<br><span class=\"deferredfp\">Fingerprint: %s</span></td>' % (html_escape(changed_by), fingerprint)
res += ('<td valign="top">%s</td>' %
''.join(map(lambda close: '<a href="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%s">#%s</a><br>' % (close, close),closes)))
......@@ -124,12 +124,12 @@ def update_graph_database(rrd_dir, *counts):
rrd_file = os.path.join(rrd_dir, 'deferred.rrd')
counts = [str(count) for count in counts]
update = [rrd_file, "N:"+":".join(counts)]
update = [rrd_file, "N:" + ":".join(counts)]
try:
rrdtool.update(*update)
except rrdtool.error:
create = [rrd_file]+"""
create = [rrd_file] + """
--step
300
--start
......@@ -179,8 +179,8 @@ def get_upload_data(changesfn):
m = re.match(r'([0-9]+)-day', delay)
if m:
delaydays = int(m.group(1))
remainingtime = (delaydays > 0)*max(0,24*60*60+os.stat(changesfn).st_mtime-time.time())
delay = "%d days %02d:%02d" % (max(delaydays-1,0), int(remainingtime/3600),int(remainingtime/60)%60)
remainingtime = (delaydays > 0) * max(0,24 * 60 * 60 + os.stat(changesfn).st_mtime - time.time())
delay = "%d days %02d:%02d" % (max(delaydays - 1,0), int(remainingtime / 3600),int(remainingtime / 60) % 60)
else:
delaydays = 0
remainingtime = 0
......@@ -211,7 +211,7 @@ def get_upload_data(changesfn):
if os.path.exists(qfn):
os.symlink(qfn,lfn)
os.chmod(qfn, 0o644)
return (max(delaydays-1,0)*24*60*60+remainingtime, changesname, delay, uploader, achanges.get('closes','').split(), fingerprint, achanges, delaydays)
return (max(delaydays - 1,0) * 24 * 60 * 60 + remainingtime, changesname, delay, uploader, achanges.get('closes','').split(), fingerprint, achanges, delaydays)
def list_uploads(filelist, rrd_dir):
......@@ -231,18 +231,18 @@ def list_uploads(filelist, rrd_dir):
fn = os.path.join(Cnf["Show-Deferred::LinkPath"],'.status.tmp')
f = open(fn,"w")
try:
counts = [0]*16
counts = [0] * 16
for u in uploads:
counts[u[7]] += 1
print >> f, "Changes-file: %s"%u[1]
fields = """Location: DEFERRED
Delayed-Until: %s
Delay-Remaining: %s
Fingerprint: %s"""%(time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(time.time()+u[0])),u[2], u[5])
Fingerprint: %s"""%(time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(time.time() + u[0])),u[2], u[5])
print >> f, fields
encoded = unicode(u[6]).encode('utf-8')
print >> f, encoded.rstrip()
open(os.path.join(Cnf["Show-Deferred::LinkPath"],u[1]),"w").write(encoded+fields+'\n')
open(os.path.join(Cnf["Show-Deferred::LinkPath"],u[1]),"w").write(encoded + fields + '\n')
print >> f
f.close()
os.rename(os.path.join(Cnf["Show-Deferred::LinkPath"],'.status.tmp'),
......
......@@ -197,23 +197,23 @@ def number_of_packages():
arch_list.sort()
longest_arch = longest(arch_list)
# Header
output = (" "*longest_arch) + " |"
output = (" " * longest_arch) + " |"
for suite in output_list:
output = output + suite.center(longest_suite)+" |"
output = output + "\n"+(len(output)*"-")+"\n"
output = output + suite.center(longest_suite) + " |"
output = output + "\n" + (len(output) * "-") + "\n"
# per-arch data
arch_list = arches.values()
arch_list.sort()
longest_arch = longest(arch_list)
for arch in arch_list:
arch_id = arch_ids[arch]
output = output + arch.center(longest_arch)+" |"
output = output + arch.center(longest_arch) + " |"
for suite_id in suite_id_list:
if arch in suite_arches[suite_id]:
count = "%d" % d[suite_id][arch_id]
else:
count = "-"
output = output + count.rjust(longest_suite)+" |"
output = output + count.rjust(longest_suite) + " |"
output = output + "\n"
print output
......
......@@ -235,7 +235,7 @@ def lock_file(f):
except OSError as e:
if e.errno in (errno.EACCES, errno.EEXIST):
print "Unable to get lock for %s (try %d of 10)" % \
(file, retry+1)
(file, retry + 1)
time.sleep(60)
else:
raise
......
......@@ -173,8 +173,8 @@ Updates dak's database schema to the lastest version. You should disable crontab
print "\nUpdates to be applied:"
for i in range(database_revision, required_database_schema):
i += 1
dakdb = __import__("dakdb", globals(), locals(), ['update'+str(i)])
update_module = getattr(dakdb, "update"+str(i))
dakdb = __import__("dakdb", globals(), locals(), ['update' + str(i)])
update_module = getattr(dakdb, "update" + str(i))
print "Update %d: %s" % (i, next(s for s in update_module.__doc__.split("\n") if s))
modules.append((update_module, i))
if not Config().find_b("Update-DB::Options::Yes", False):
......
......@@ -486,7 +486,7 @@ class BinaryTimestampCheck(Check):
def check(self, upload):
cnf = Config()
future_cutoff = time.time() + cnf.find_i('Dinstall::FutureTimeTravelGrace', 24*3600)
future_cutoff = time.time() + cnf.find_i('Dinstall::FutureTimeTravelGrace', 24 * 3600)
past_cutoff = time.mktime(time.strptime(cnf.find('Dinstall::PastCutoffYear', '1975'), '%Y'))
class TarTime(object):
......
......@@ -83,7 +83,7 @@ class Logger(object):
details = [str(i) for i in details]
fcntl.lockf(self.logfile, fcntl.LOCK_EX)
# Write out the log in TSV
self.logfile.write("|".join(details)+'\n')
self.logfile.write("|".join(details) + '\n')
# Flush the output to enable tail-ing
self.logfile.flush()
fcntl.lockf(self.logfile, fcntl.LOCK_UN)
......
......@@ -2571,7 +2571,7 @@ class DBConn(object):
mapper(VersionCheck, self.tbl_version_check,
properties=dict(
suite_id=self.tbl_version_check.c.suite,
suite =relation(Suite, primaryjoin=self.tbl_version_check.c.suite == self.tbl_suite.c.id),
suite=relation(Suite, primaryjoin=self.tbl_version_check.c.suite == self.tbl_suite.c.id),
reference_id=self.tbl_version_check.c.reference,
reference=relation(Suite, primaryjoin=self.tbl_version_check.c.reference == self.tbl_suite.c.id, lazy='joined')))
......
......@@ -134,7 +134,7 @@ def prod_maintainer(notes, upload):
Subst["__CC__"] = "Cc: " + cnf["Dinstall::MyEmailAddress"]
prod_mail_message = utils.TemplateSubst(
Subst,cnf["Dir::Templates"]+"/process-new.prod")
Subst,cnf["Dir::Templates"] + "/process-new.prod")
# Send the prod mail
utils.send_mail(prod_mail_message, whitelists=whitelists)
......
......@@ -521,9 +521,9 @@ def remove(session, reason, suites, removals,
for bug in done_bugs:
Subst_close_rm["__BUG_NUMBER__"] = bug
if close_related_bugs:
mail_message = utils.TemplateSubst(Subst_close_rm,cnf["Dir::Templates"]+"/rm.bug-close-with-related")
mail_message = utils.TemplateSubst(Subst_close_rm,cnf["Dir::Templates"] + "/rm.bug-close-with-related")
else:
mail_message = utils.TemplateSubst(Subst_close_rm,cnf["Dir::Templates"]+"/rm.bug-close")
mail_message = utils.TemplateSubst(Subst_close_rm,cnf["Dir::Templates"] + "/rm.bug-close")
utils.send_mail(mail_message, whitelists=whitelists)
# close associated bug reports
......@@ -583,7 +583,7 @@ def remove(session, reason, suites, removals,
logfile.write("\n")
logfile822.write("\n")
mail_message = utils.TemplateSubst(Subst_close_other, cnf["Dir::Templates"]+"/rm.bug-close-related")
mail_message = utils.TemplateSubst(Subst_close_other, cnf["Dir::Templates"] + "/rm.bug-close-related")
if Subst_close_other["__BUG_NUMBER_ALSO__"]:
utils.send_mail(mail_message)
......
......@@ -75,7 +75,7 @@ class UrgencyLog(object):
if self.log_file is None:
return
self.log_file.write(" ".join([source, version, urgency])+'\n')
self.log_file.write(" ".join([source, version, urgency]) + '\n')
self.log_file.flush()
self.writes += 1
......
......@@ -14,7 +14,6 @@ ignore =
E127,
E128,
E129,
E226,
E227,
E228,
E231,
......
......@@ -49,7 +49,7 @@ if m:
raise Exception("I don't like command line arguments including char '%s'"%m.group(0))
if args:
for l in os.popen('bzgrep -H "^Archive maintenance timestamp" "'+'" "'.join(args)+'"'):
for l in os.popen('bzgrep -H "^Archive maintenance timestamp" "' + '" "'.join(args) + '"'):
m = LINE.match(l)
if not m:
raise Exception("woops '%s'"%l)
......@@ -58,28 +58,28 @@ if args:
if olddt != dt:
oldsecs = 0
olddt = dt
dt2 = datetime.datetime(*(g[:3]+g[-3:]))
secs = (dt2-dt).seconds
dt2 = datetime.datetime(*(g[:3] + g[-3:]))
secs = (dt2 - dt).seconds
assert secs >= 0 # should add 24*60*60
k = g[6]
d.setdefault(str(dt),{})[k] = (secs-oldsecs)/60.0
d.setdefault(str(dt),{})[k] = (secs - oldsecs) / 60.0
oldsecs = secs
if k not in ks:
ks.add(k)
kl.append(k)
if (wantkeys-ks):
print >> sys.stderr, "warning, requested keys not found in any log: "+' '.join(wantkeys-ks)
if (wantkeys - ks):
print >> sys.stderr, "warning, requested keys not found in any log: " + ' '.join(wantkeys - ks)
datakeys = d.keys()
datakeys.sort()
f = open(CACHE_FILE+".tmp","w")
f = open(CACHE_FILE + ".tmp","w")
for dk in datakeys:
print >> f, dk+'\t'+'\t'.join(
print >> f, dk + '\t' + '\t'.join(
["%s:%s"%(k,str(d[dk][k])) for k in kl if k in d[dk]])
f.close()
os.rename(CACHE_FILE+".tmp", CACHE_FILE)
os.rename(CACHE_FILE + ".tmp", CACHE_FILE)
datakeys = datakeys[-ITEMS_TO_KEEP:]
......@@ -87,12 +87,12 @@ def dump_file(outfn,keystolist, showothers):
showothers = (showothers and 1) or 0
# careful, outfn is NOT ESCAPED
f = tempfile.NamedTemporaryFile()
otherkeys = ks-set(keystolist)
print >>f, '\t'.join(keystolist+showothers*['other'])
otherkeys = ks - set(keystolist)
print >>f, '\t'.join(keystolist + showothers * ['other'])
for k in datakeys:
v = d[k]
others = sum(map(lambda x: v.get(x,0),otherkeys))
print >>f, k+'\t'+'\t'.join(map(lambda x: str(v.get(x,0)), keystolist)+showothers*[str(others)])
print >>f, k + '\t' + '\t'.join(map(lambda x: str(v.get(x,0)), keystolist) + showothers * [str(others)])
f.flush()
n = f.name
......@@ -120,9 +120,9 @@ def dump_file(outfn,keystolist, showothers):
dev.off()
q()
"""%{'datafile':n,'outfile':outfn,
'title':((not showothers)*"partial ")+"dinstall times"})
'title':((not showothers) * "partial ") + "dinstall times"})
p.flush()
assert not p.close()
for afn,params in graphs.items():
dump_file(os.path.join(GRAPH_DIR,afn+'.png'), **params)
dump_file(os.path.join(GRAPH_DIR,afn + '.png'), **params)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment