[Secure-testing-commits] r14634 - lib/python/sectracker
Florian Weimer
fw at alioth.debian.org
Fri May 7 21:23:23 UTC 2010
Author: fw
Date: 2010-05-07 21:23:22 +0000 (Fri, 07 May 2010)
New Revision: 14634
Modified:
lib/python/sectracker/xpickle.py
Log:
sectracker.xpickle: hide non-exported names
Modified: lib/python/sectracker/xpickle.py
===================================================================
--- lib/python/sectracker/xpickle.py 2010-05-07 21:19:19 UTC (rev 14633)
+++ lib/python/sectracker/xpickle.py 2010-05-07 21:23:22 UTC (rev 14634)
@@ -17,10 +17,10 @@
from __future__ import with_statement
-import errno
-import os.path
-import cPickle as pickle
-import tempfile
+import errno as _errno
+import os as _os
+import cPickle as _pickle
+import tempfile as _tempfile
EXTENSION = '.xpck'
@@ -28,9 +28,9 @@
"""Removes the file.
No exception is thrown if the file does not exist."""
try:
- os.unlink(path)
+ _os.unlink(path)
except OSError, e:
- if e.errno != errno.ENOENT:
+ if e.errno != _errno.ENOENT:
raise e
def replacefile(path, action):
@@ -40,14 +40,14 @@
file, and an open file object for that temporary file. On success,
the temporary file is renmaed as the original file, atomically
replacing it. The return value is the value returned by the action."""
- t_fd, t_name = tempfile.mkstemp(suffix='.tmp', dir=os.path.dirname(path))
+ t_fd, t_name = _tempfile.mkstemp(suffix='.tmp', dir=_os.path.dirname(path))
try:
- t = os.fdopen(t_fd, "w")
+ t = _os.fdopen(t_fd, "w")
try:
result = action(t_name, t)
finally:
t.close()
- os.rename(t_name, path)
+ _os.rename(t_name, path)
t_name = None
finally:
if t_name is not None:
@@ -64,8 +64,8 @@
def safeload(path):
try:
with file(path + EXTENSION) as f:
- return (pickle.load(f), True)
- except (EOFError, IOError, pickle.PickleError):
+ return (_pickle.load(f), True)
+ except (EOFError, IOError, _pickle.PickleError):
return (None, False)
def check(data, st):
@@ -80,13 +80,13 @@
def reparse(path, st):
with file(path) as f:
obj = parser(path, f)
- data = pickle.dumps(
+ data = _pickle.dumps(
((typ, st.st_size, st.st_mtime, st.st_ino), obj), -1)
replacefile(path + EXTENSION, lambda name, f: f.write(data))
return obj
def loader(path):
- st = os.stat(path)
+ st = _os.stat(path)
xpck = path + EXTENSION
data, success = safeload(path)
if success:
@@ -105,7 +105,7 @@
return lambda f: _wraploader(file_type, f)
def _test():
- with tempfile.NamedTemporaryFile() as t:
+ with _tempfile.NamedTemporaryFile() as t:
try:
data = "foo bar baz\n"
t.write(data)
More information about the Secure-testing-commits
mailing list