python-modernize -f libmodernize.fixes.fix_file
This commit is contained in:
parent
5ad9027320
commit
d92fa1fa9c
5 changed files with 15 additions and 15 deletions
|
|
@ -259,7 +259,7 @@ class BuildRoot(object):
|
|||
output = koji.genMockConfig(self.name, self.br_arch, managed=True, **opts)
|
||||
|
||||
#write config
|
||||
fo = file(configfile,'w')
|
||||
fo = open(configfile,'w')
|
||||
fo.write(output)
|
||||
fo.close()
|
||||
|
||||
|
|
@ -359,7 +359,7 @@ class BuildRoot(object):
|
|||
</settings>
|
||||
"""
|
||||
settings = settings % locals()
|
||||
fo = file(self.rootdir() + destfile, 'w')
|
||||
fo = open(self.rootdir() + destfile, 'w')
|
||||
fo.write(settings)
|
||||
fo.close()
|
||||
|
||||
|
|
@ -1869,7 +1869,7 @@ class WrapperRPMTask(BaseBuildTask):
|
|||
contents = contents.encode('utf-8')
|
||||
|
||||
specfile = spec_template[:-5]
|
||||
specfd = file(specfile, 'w')
|
||||
specfd = open(specfile, 'w')
|
||||
specfd.write(contents)
|
||||
specfd.close()
|
||||
|
||||
|
|
@ -5044,7 +5044,7 @@ class CreaterepoTask(BaseTaskHandler):
|
|||
if external_repos:
|
||||
self.merge_repos(external_repos, arch, groupdata)
|
||||
elif pkglist is None:
|
||||
fo = file(os.path.join(self.datadir, "EMPTY_REPO"), 'w')
|
||||
fo = open(os.path.join(self.datadir, "EMPTY_REPO"), 'w')
|
||||
fo.write("This repo is empty because its tag has no content for this arch\n")
|
||||
fo.close()
|
||||
|
||||
|
|
@ -5622,7 +5622,7 @@ enabled=1
|
|||
|
||||
def write_kojipkgs(self):
|
||||
filename = os.path.join(self.repodir, 'kojipkgs')
|
||||
datafile = file(filename, 'w')
|
||||
datafile = open(filename, 'w')
|
||||
try:
|
||||
json.dump(self.kojipkgs, datafile, indent=4, sort_keys=True)
|
||||
finally:
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ class RepoMerge(object):
|
|||
include_srpms[srpm_name] = (pkg.sourcerpm, pkg.repoid)
|
||||
|
||||
pkgorigins = os.path.join(self.yumbase.conf.cachedir, 'pkgorigins')
|
||||
origins = file(pkgorigins, 'w')
|
||||
origins = open(pkgorigins, 'w')
|
||||
|
||||
seen_rpms = {}
|
||||
for repo in repos:
|
||||
|
|
@ -284,7 +284,7 @@ def main(args):
|
|||
opts = parse_args(args)
|
||||
|
||||
if opts.blocked:
|
||||
blocked_fo = file(opts.blocked)
|
||||
blocked_fo = open(opts.blocked)
|
||||
blocked_list = blocked_fo.readlines()
|
||||
blocked_fo.close()
|
||||
blocked = dict([(b.strip(), 1) for b in blocked_list])
|
||||
|
|
|
|||
|
|
@ -737,7 +737,7 @@ def read_policies(fn=None):
|
|||
The expected format as follows
|
||||
test [params] [&& test [params] ...] :: (keep|untag|skip)
|
||||
"""
|
||||
fo = file(fn, 'r')
|
||||
fo = open(fn, 'r')
|
||||
tests = koji.policy.findSimpleTests(globals())
|
||||
ret = koji.policy.SimpleRuleSet(fo, tests)
|
||||
fo.close()
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ class TrackedBuild(object):
|
|||
fsrc = urllib2.urlopen(url)
|
||||
fn = "%s/%s.src.rpm" % (options.workpath, self.nvr)
|
||||
koji.ensuredir(os.path.dirname(fn))
|
||||
fdst = file(fn, 'w')
|
||||
fdst = open(fn, 'w')
|
||||
shutil.copyfileobj(fsrc, fdst)
|
||||
fsrc.close()
|
||||
fdst.close()
|
||||
|
|
@ -889,7 +889,7 @@ class BuildTracker(object):
|
|||
os.chown(os.path.dirname(dst), 48, 48) #XXX - hack
|
||||
log ("Downloading %s to %s" % (url, dst))
|
||||
fsrc = urllib2.urlopen(url)
|
||||
fdst = file(fn, 'w')
|
||||
fdst = open(fn, 'w')
|
||||
shutil.copyfileobj(fsrc, fdst)
|
||||
fsrc.close()
|
||||
fdst.close()
|
||||
|
|
@ -902,7 +902,7 @@ class BuildTracker(object):
|
|||
dst = "%s/%s" % (options.workpath, fn)
|
||||
log ("Downloading %s to %s..." % (url, dst))
|
||||
fsrc = urllib2.urlopen(url)
|
||||
fdst = file(dst, 'w')
|
||||
fdst = open(dst, 'w')
|
||||
shutil.copyfileobj(fsrc, fdst)
|
||||
fsrc.close()
|
||||
fdst.close()
|
||||
|
|
|
|||
|
|
@ -689,7 +689,7 @@ class VMExecTask(BaseTaskHandler):
|
|||
f.close()
|
||||
|
||||
|
||||
return file(localpath, 'r')
|
||||
return open(localpath, 'r')
|
||||
|
||||
def getFile(self, buildinfo, archiveinfo, offset, length, type):
|
||||
"""
|
||||
|
|
@ -718,7 +718,7 @@ class VMExecTask(BaseTaskHandler):
|
|||
if offset == 0:
|
||||
if os.path.exists(local_path):
|
||||
raise koji.BuildError('cannot overwrite %s' % local_path)
|
||||
fobj = file(local_path, 'w')
|
||||
fobj = open(local_path, 'w')
|
||||
else:
|
||||
if not os.path.isfile(local_path):
|
||||
raise koji.BuildError('% does not exist' % local_path)
|
||||
|
|
@ -726,7 +726,7 @@ class VMExecTask(BaseTaskHandler):
|
|||
if offset != size:
|
||||
raise koji.BuildError('cannot write to %s at offset %s, size is %s' % \
|
||||
(local_path, offset, size))
|
||||
fobj = file(local_path, 'r+')
|
||||
fobj = open(local_path, 'r+')
|
||||
fobj.seek(offset)
|
||||
data = base64.b64decode(contents)
|
||||
fobj.write(data)
|
||||
|
|
@ -756,7 +756,7 @@ class VMExecTask(BaseTaskHandler):
|
|||
else:
|
||||
raise koji.BuildError('unsupported checksum algorithm: %s' % algo)
|
||||
|
||||
fobj = file(local_path, 'r')
|
||||
fobj = open(local_path, 'r')
|
||||
while True:
|
||||
data = fobj.read(1048576)
|
||||
if not data:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue