MCPcopy Create free account
hub / github.com/ARMmbed/DAPLink / TargetBundle

Class TargetBundle

test/target.py:34–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32
33
34class TargetBundle(object):
35
36 def __init__(self, directory):
37 dir_contents = os.listdir(directory)
38 name_to_target = {}
39 for name in dir_contents:
40 base_name, extension = os.path.splitext(name)
41 path = directory + os.sep + name
42 if os.path.isdir(path):
43 # Directories are unused
44 pass
45 elif os.path.isfile(path):
46 if extension not in ('.bin', '.hex'):
47 continue
48 if base_name not in name_to_target:
49 name_to_target[base_name] = Target(base_name)
50 if extension == '.bin':
51 name_to_target[base_name].set_bin_path(path)
52 elif extension == '.hex':
53 name_to_target[base_name].set_hex_path(path)
54 else:
55 # Unsupported file type
56 pass
57 else:
58 assert False
59 all_targets = list(name_to_target.values())
60 self._target_list = [target for target in all_targets if target.valid]
61
62 def get_target_list(self):
63 """Return the target objects associated with this bundle"""
64 return self._target_list
65
66
67def build_target_bundle(directory, username, password, parent_test=None):

Callers 1

load_target_bundleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected