Commit 99e7030a authored by Rafael Monnerat's avatar Rafael Monnerat

move to python3

parent ed735991
...@@ -135,15 +135,15 @@ class task(_task): ...@@ -135,15 +135,15 @@ class task(_task):
return task_gen return task_gen
def __init__(self, run, depends, provides=(), def __init__(self, run, depends, provides=(),
__str_or_task = (basestring, _task)): __str_or_task = (str, _task)):
self.run = run self.run = run
self.depends = [] self.depends = []
f = [] f = []
for x in (depends,) if isinstance(depends, __str_or_task) else depends: for x in (depends,) if isinstance(depends, __str_or_task) else depends:
(f if isinstance(x, basestring) else self.depends).append(x) (f if isinstance(x, str) else self.depends).append(x)
f and self.depends.append(files(*f)) f and self.depends.append(files(*f))
self.provides = ((provides,) self.provides = ((provides,)
if isinstance(provides, basestring) or callable(provides) if isinstance(provides, str) or callable(provides)
else provides) else provides)
self.why = self, self.why = self,
...@@ -177,10 +177,10 @@ class task(_task): ...@@ -177,10 +177,10 @@ class task(_task):
if deps: if deps:
self.why = [dep for dep, itime in deps if _otime < itime] self.why = [dep for dep, itime in deps if _otime < itime]
if self.why: if self.why:
print "# Processing %s: %s -> %s" % (self, print("# Processing %s: %s -> %s" % (self,
", ".join(map(str, self.depends)), ", ".join(map(str, self.depends)),
", ".join("<%s>" % x.__name__ if callable(x) else x ", ".join("<%s>" % x.__name__ if callable(x) else x
for x in self.provides or "?")) for x in self.provides or "?")))
if not dry_run: if not dry_run:
try: try:
self.run(self) self.run(self)
...@@ -222,8 +222,8 @@ def main(): ...@@ -222,8 +222,8 @@ def main():
tasks = {"__file__": f.name} tasks = {"__file__": f.name}
exec(compile(f.read(), f.name, "exec"), tasks) exec(compile(f.read(), f.name, "exec"), tasks)
if args.list: if args.list:
print " ".join(sorted(k for k, v in tasks.iteritems() print(" ".join(sorted(k for k, v in tasks.iteritems()
if isinstance(v, _task))) if isinstance(v, _task))))
return return
for t in args.task: for t in args.task:
if not isinstance(tasks.get(t), _task): if not isinstance(tasks.get(t), _task):
......
...@@ -40,9 +40,9 @@ ...@@ -40,9 +40,9 @@
# If this way of packaging is reused for other software, postinst scripts # If this way of packaging is reused for other software, postinst scripts
# should be implemented. # should be implemented.
import os, rfc822, shutil, ssl, time, urllib import os, email, shutil, ssl, time, urllib.request
from glob import glob from glob import glob
from cStringIO import StringIO from io import StringIO
from subprocess import check_call from subprocess import check_call
from make import * from make import *
from debian.changelog import Changelog from debian.changelog import Changelog
...@@ -86,7 +86,7 @@ def bootstrap(task): ...@@ -86,7 +86,7 @@ def bootstrap(task):
try: try:
os.utime(task.outputs[1], None) os.utime(task.outputs[1], None)
except OSError: except OSError:
bootstrap = urllib.urlopen(BOOTSTRAP_URL).read() bootstrap = urllib.request.urlopen(BOOTSTRAP_URL).read()
mkdir(BUILD + "/download-cache") mkdir(BUILD + "/download-cache")
with cwd(BUILD): with cwd(BUILD):
rmtree("extends-cache") rmtree("extends-cache")
...@@ -205,7 +205,7 @@ def deb(task): ...@@ -205,7 +205,7 @@ def deb(task):
b["Conflicts"] = b["Provides"] = b["Replaces"] = "re6stnet" b["Conflicts"] = b["Provides"] = b["Replaces"] = "re6stnet"
patched_control = StringIO("%s\n%s" % (s, b)) patched_control = StringIO("%s\n%s" % (s, b))
open(task.outputs[1], "w").write(str(d)) open(task.outputs[1], "w").write(str(d))
date = rfc822.parsedate_tz(Changelog(open(dch.output)).date) date = email.utils.parsedate_tz(Changelog(open(dch.output)).date)
mtime = time.mktime(date[:9]) - date[9] mtime = time.mktime(date[:9]) - date[9]
# Unfortunately, OBS does not support symlinks. # Unfortunately, OBS does not support symlinks.
with make_tar_gz(task.outputs[0], mtime, dereference=True) as t: with make_tar_gz(task.outputs[0], mtime, dereference=True) as t:
......
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