diff options
author | Johan Dahlin <johan@gnome.org> | 2010-09-02 17:36:09 -0300 |
---|---|---|
committer | Johan Dahlin <johan@gnome.org> | 2010-09-02 17:36:09 -0300 |
commit | 9c7ced784f00b2953a118cd9a695ba5beac69638 (patch) | |
tree | 6979f46f0d0d066ca459881a2036db0067768d3d /giscanner/scannermain.py | |
parent | 3b46e416a52e65feeb5e279001c76a483eddadff (diff) | |
download | gobject-introspection-9c7ced784f00b2953a118cd9a695ba5beac69638.tar.gz |
[scannermain] Use mkstemp
Since the delete parameter of NamedTemporaryFile is only
available on python 2.6
Diffstat (limited to 'giscanner/scannermain.py')
-rw-r--r-- | giscanner/scannermain.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py index 9b6d6751..42f74b7d 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 |