[game-data-packager] 04/07: Factor out recursive_utime function
Simon McVittie
smcv at debian.org
Wed Oct 21 11:00:46 UTC 2015
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch master
in repository game-data-packager.
commit b674c4a79756be2af75ee80f64b7992454e2b55c
Author: Simon McVittie <smcv at debian.org>
Date: Wed Oct 21 08:39:41 2015 +0100
Factor out recursive_utime function
---
game_data_packager/build.py | 10 +++-------
game_data_packager/util.py | 14 ++++++++++++++
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/game_data_packager/build.py b/game_data_packager/build.py
index 46e0718..285788a 100644
--- a/game_data_packager/build.py
+++ b/game_data_packager/build.py
@@ -51,6 +51,7 @@ from .util import (AGENT,
lang_score,
mkdir_p,
rm_rf,
+ recursive_utime,
which)
from .version import GAME_PACKAGE_VERSION
@@ -1081,10 +1082,9 @@ class PackagingTask(object):
cwd=tmpdir)
# this format doesn't store a timestamp, so the extracted
# files will instead inherit the archive's timestamp
- orig_time = os.stat(found_name).st_mtime
+ recursive_utime(tmpdir, os.stat(found_name).st_mtime)
for f in to_unpack:
tmp = os.path.join(tmpdir, f)
- os.utime(tmp, (orig_time, orig_time))
self.consider_file(tmp, True)
elif fmt == 'cabextract':
to_unpack = provider.unpack.get('unpack', provider.provides)
@@ -1211,11 +1211,7 @@ class PackagingTask(object):
# this format doesn't store a timestamp, so the extracted
# files will instead inherit the archive's timestamp
- orig_time = os.stat(found_name).st_mtime
- for dirpath, dirnames, filenames in os.walk(tmpdir):
- for fn in filenames:
- full = os.path.join(dirpath, fn)
- os.utime(full, (orig_time, orig_time))
+ recursive_utime(tmpdir, os.stat(found_name).st_mtime)
self.consider_file_or_dir(tmpdir, provider=provider)
elif fmt == 'arj':
to_unpack = provider.unpack.get('unpack', provider.provides)
diff --git a/game_data_packager/util.py b/game_data_packager/util.py
index 03d124a..76a662a 100644
--- a/game_data_packager/util.py
+++ b/game_data_packager/util.py
@@ -238,3 +238,17 @@ def check_output(command, *args, **kwargs):
"""Like subprocess.check_output, but log what we will do first."""
logger.debug('%r', command)
return subprocess.check_output(command, *args, **kwargs)
+
+def recursive_utime(directory, orig_time):
+ """Recursively set the access and modification times of everything
+ in directory to orig_time.
+
+ orig_time may be a tuple (atime, mtime), or a single int or float.
+ """
+ if isinstance(orig_time, (int, float)):
+ orig_time = (orig_time, orig_time)
+
+ for dirpath, dirnames, filenames in os.walk(directory):
+ for fn in filenames:
+ full = os.path.join(dirpath, fn)
+ os.utime(full, orig_time)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git
More information about the Pkg-games-commits
mailing list