From fd34317642b256d389ffe2a38c0d05fc4ad7961d Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Sat, 28 Nov 2009 16:27:29 -0600 Subject: [PATCH] Add initial built_target support --- ChangeLog | 4 ++ modules/catalyst/target/__init__.py | 61 +++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4cafa434..4870a8b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,10 @@ # Distributed under the GPL v2 # $Id$ + 28 Nov 2009; Andrew Gaffney + modules/catalyst/target/__init__.py: + Add initial built_target support + 28 Nov 2009; Andrew Gaffney modules/catalyst/util.py: change os.path.is_dir() to isdir() diff --git a/modules/catalyst/target/__init__.py b/modules/catalyst/target/__init__.py index f39375e2..b9dcc7bc 100644 --- a/modules/catalyst/target/__init__.py +++ b/modules/catalyst/target/__init__.py @@ -30,4 +30,65 @@ def build_target_map(): target_map.update(targets[x].__target_map) return target_map +def find_built_targets(build_dir): + built_targets = [] + for root, dir, files in os.walk(build_dir): + for file in files: + try: + built_targets.append(built_target(root + '/' + file)) + except: + catalyst.output.warn("Failed to parse '%s' as a built target" % (file,)) + + return built_targets + +class built_target: + + _filename = None + _target = None + _version_stamp = None + _arch = None + _rel_type = None + _media = None + + def __init__(self, filename=None): + if filename: + self.parse_filename(filename) + + def parse_filename(self, filename): + self._filename = filename + + (rel_type, file) = filename.split('/')[-2:] + self._rel_type = rel_type + (target_full, media) = file.split('.', 1) + self._media = media + target_parts = target_full.split('-') + + if len(target_parts) != 3: + raise CatalystError("The file '%s' cannot be parsed as a built target" % (filename,)) + + (target, arch, version_stamp) = target_parts + + self._target = target + self._arch = arch + self._version_stamp = version_stamp + + def get_target(self): + return self._target + + def get_arch(self): + return self._arch + + def get_version_stamp(self): + return self._version_stamp + + def get_media(self): + return self._media + + def get_rel_type(self): + return self._rel_type + + def get_values(self): + foo = { 'target': self._target, 'arch': self._arch, 'version_stamp': self._version_stamp, 'rel_type': self._rel_type, 'media': self._media } + return foo + # vim: ts=4 sw=4 sta noet sts=4 ai -- 2.26.2