[gobject-introspection] [scannermain] Use mkstemp
- From: Johan Dahlin <johan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] [scannermain] Use mkstemp
- Date: Thu, 2 Sep 2010 20:36:45 +0000 (UTC)
commit 9c7ced784f00b2953a118cd9a695ba5beac69638
Author: Johan Dahlin <johan gnome org>
Date: Thu Sep 2 17:36:09 2010 -0300
[scannermain] Use mkstemp
Since the delete parameter of NamedTemporaryFile is only
available on python 2.6
giscanner/scannermain.py | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index 9b6d675..42f74b7 100644
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -353,22 +353,24 @@ def scanner_main(args):
if options.output == "-":
output = sys.stdout
elif options.reparse_validate_gir:
- main_f = tempfile.NamedTemporaryFile(suffix='.gir', delete=False)
+ main_f, main_f_name = tempfile.mkstemp(suffix='.gir')
+ main_f = os.fdopen(main_f, 'w')
main_f.write(data)
main_f.close()
- temp_f = tempfile.NamedTemporaryFile(suffix='.gir', delete=False)
- passthrough_gir(main_f.name, temp_f)
+ temp_f, temp_f_name = tempfile.mkstemp(suffix='.gir')
+ temp_f = os.fdopen(temp_f, 'w')
+ passthrough_gir(main_f_name, temp_f)
temp_f.close()
- if not files_are_identical(main_f.name, temp_f.name):
+ if not files_are_identical(main_f_name, temp_f_name):
_error("Failed to re-parse gir file; scanned=%r passthrough=%r" % (
- main_f.name, temp_f.name))
- os.unlink(temp_f.name)
+ main_f_name, temp_f_name))
+ os.unlink(temp_f_name)
try:
- shutil.move(main_f.name, options.output)
+ shutil.move(main_f_name, options.output)
except OSError, e:
if e.errno == errno.EPERM:
- os.unlink(main_f.name)
+ os.unlink(main_f_name)
return 0
raise
return 0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]