From 6a5f647e83145ab6d470469974c618511b458827 Mon Sep 17 00:00:00 2001 From: Michael 'Mickey' Lauer Date: Thu, 8 Sep 2005 13:11:53 +0000 Subject: parser: add function to update the mtime for one file, courtesy Justin Patrin parser: move import bb and import os out of the commands (import in a function that's called often has a performance penalty) lib: increase revision shell: add 'reparse' and 'fileReparse' commands, courtesy Justin Patrin --- lib/bb/parse/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/bb/parse/__init__.py') diff --git a/lib/bb/parse/__init__.py b/lib/bb/parse/__init__.py index b8839c09f..cb2741606 100644 --- a/lib/bb/parse/__init__.py +++ b/lib/bb/parse/__init__.py @@ -26,6 +26,8 @@ __all__ = [ 'ParseError', 'SkipPackage', 'cached_mtime', 'mark_dependency', 'supports', 'handle', 'init' ] handlers = [] +import bb, os + class ParseError(Exception): """Exception raised when parsing fails""" @@ -34,13 +36,14 @@ class SkipPackage(Exception): __mtime_cache = {} def cached_mtime(f): - import os if not __mtime_cache.has_key(f): - __mtime_cache[f] = os.stat(f)[8] + update_mtime(f) return __mtime_cache[f] +def update_mtime(f): + __mtime_cache[f] = os.stat(f)[8] + def mark_dependency(d, f): - import bb, os if f.startswith('./'): f = "%s/%s" % (os.getcwd(), f[2:]) deps = (bb.data.getVar('__depends', d) or "").split() -- cgit 1.2.3-korg