Anonymous avatar Anonymous committed 45b66b9

Python3 support.

Comments (0)

Files changed (1)

smart-live-rebuild.py

 
 	@classmethod
 	def opentmp(self):
-		self.envtmpf = tempfile.NamedTemporaryFile()
+		self.envtmpf = tempfile.NamedTemporaryFile('w+b')
 
 	@classmethod
 	def closetmp(self):
 		f.seek(0, 0)
 		f.truncate(0)
 		shutil.copyfileobj(envf, f)
-		f.write(envf.read())
 		f.flush()
 
 		script = 'source "%s"||exit 1;%s' % (f.name,
 		self.cpv = [cpv]
 		self.env = self.bashparse(envf, self.reqenv + self.optenv)
 
-		missingvars = filter(lambda v: self.env[v] == '', self.reqenv)
+		missingvars = [v for v in self.reqenv if self.env[v] == '']
 		if len(missingvars) > 0:
 			raise KeyError('Environment does not declare: %s' % self.reqenv)
 
 
 	@staticmethod
 	def call(cmd):
-		return subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
+		return subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0].decode('utf8')
 
 	def getupdatecmd(self):
 		raise NotImplementedError('VCS class needs to override getupdatecmd(), doupdate() or update()')
 		pass
 
 	def update(self):
-		out.s2(unicode(self))
+		out.s2(str(self))
 		os.chdir(self.getpath())
 
 		oldrev = self.getrev(Shared.opts.localrev)
 				out.s3('update from %s%s%s to %s%s%s' % (out.green, oldrev, out.reset, out.lime, newrev, out.reset))
 				return True
 
-	def __unicode__(self):
+	def __str__(self):
 		return self.cpv
 
 class GitSupport(VCSSupport):
 			raise NotImplementedError('Submodules are not supported')
 
 	def getpath(self):
-		return u'%s/%s' % (self.env['EGIT_STORE_DIR'], self.env['EGIT_PROJECT'])
+		return '%s/%s' % (self.env['EGIT_STORE_DIR'], self.env['EGIT_PROJECT'])
 
-	def __unicode__(self):
+	def __str__(self):
 		return self.env['EGIT_REPO_URI'] or self.cpv
 
 	def getrev(self, localrev = True):
 
 		return '%s/hg-src/%s/%s' % (dd, self.env['EHG_PROJECT'], bn)
 
-	def __unicode__(self):
+	def __str__(self):
 		return self.env['EHG_REPO_URI'] or self.cpv
 
 	def getrev(self, localrev = True):
 	def getpath(self):
 		return self.env['ESVN_WC_PATH']
 
-	def __unicode__(self):
+	def __str__(self):
 		return self.env['ESVN_REPO_URI'] or self.cpv
 
 	def getrev(self, localrev = True):
 ''' % argv[0])
 		return 1
 	if opts.types:
-		vcslf = filter(lambda x: x.inherit in opts.types, vcsl)
+		vcslf = [x for x in vcsl if x.inherit in opts.types]
 	else:
 		vcslf = vcsl
 
 
 				for vcs in vcslf:
 					if vcs.match(inherits):
-						env = bz2.BZ2File(u'%s/environment.bz2' % db.getpath(cpv), 'r')
+						env = bz2.BZ2File('%s/environment.bz2' % db.getpath(cpv), 'r')
 						vcs = vcs(cpv, env)
 						env.close()
 						dir = vcs.getpath()
 	elif opts.pretend:
 		out.s1('Printing list of updated packages ...')
 		for p in packages:
-			print p
+			print(p)
 	else:
 		out.s1('Calling emerge to rebuild %s%d%s packages ...' % (out.white, len(packages), out.s1reset))
 		if opts.offline:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.