Skip to content

Commit cbea92d

Browse files
author
Grant Bakker
committed
Remove unused tmp files from past translation
1 parent 39a066e commit cbea92d

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

src/past/translation/__init__.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
>>> from past.translation import remove_hooks
2929
>>> remove_hooks()
3030
31-
Author: Ed Schofield.
31+
Author: Ed Schofield.
3232
Inspired by and based on ``uprefix`` by Vinay M. Sajip.
3333
"""
3434

@@ -219,22 +219,9 @@ def detect_python2(source, pathname):
219219
if source != str(tree)[:-1]: # remove added newline
220220
# The above fixers made changes, so we conclude it's Python 2 code
221221
logger.debug('Detected Python 2 code: {0}'.format(pathname))
222-
with open('/tmp/original_code.py', 'w') as f:
223-
f.write('### Original code (detected as py2): %s\n%s' %
224-
(pathname, source))
225-
with open('/tmp/py2_detection_code.py', 'w') as f:
226-
f.write('### Code after running py3 detection (from %s)\n%s' %
227-
(pathname, str(tree)[:-1]))
228222
return True
229223
else:
230224
logger.debug('Detected Python 3 code: {0}'.format(pathname))
231-
with open('/tmp/original_code.py', 'w') as f:
232-
f.write('### Original code (detected as py3): %s\n%s' %
233-
(pathname, source))
234-
try:
235-
os.remove('/tmp/futurize_code.py')
236-
except OSError:
237-
pass
238225
return False
239226

240227

@@ -359,15 +346,15 @@ def load_module(self, fullname):
359346
# Is the test in the next line more or less robust than the
360347
# following one? Presumably less ...
361348
# ispkg = self.pathname.endswith('__init__.py')
362-
349+
363350
if self.kind == imp.PKG_DIRECTORY:
364351
mod.__path__ = [ os.path.dirname(self.pathname) ]
365352
mod.__package__ = fullname
366353
else:
367354
#else, regular module
368355
mod.__path__ = []
369356
mod.__package__ = fullname.rpartition('.')[0]
370-
357+
371358
try:
372359
cachename = imp.cache_from_source(self.pathname)
373360
if not os.path.exists(cachename):
@@ -395,9 +382,6 @@ def load_module(self, fullname):
395382

396383
if detect_python2(source, self.pathname):
397384
source = self.transform(source)
398-
with open('/tmp/futurized_code.py', 'w') as f:
399-
f.write('### Futurized code (from %s)\n%s' %
400-
(self.pathname, source))
401385

402386
code = compile(source, self.pathname, 'exec')
403387

@@ -457,7 +441,7 @@ def detect_hooks():
457441
class hooks(object):
458442
"""
459443
Acts as a context manager. Use like this:
460-
444+
461445
>>> from past import translation
462446
>>> with translation.hooks():
463447
... import mypy2module
@@ -477,7 +461,7 @@ def __exit__(self, *args):
477461
class suspend_hooks(object):
478462
"""
479463
Acts as a context manager. Use like this:
480-
464+
481465
>>> from past import translation
482466
>>> translation.install_hooks()
483467
>>> import http.client
@@ -495,4 +479,3 @@ def __enter__(self):
495479
def __exit__(self, *args):
496480
if self.hooks_were_installed:
497481
install_hooks()
498-

0 commit comments

Comments
 (0)