| 32 | |
| 33 | |
| 34 | class 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 | |
| 67 | def build_target_bundle(directory, username, password, parent_test=None): |
no outgoing calls
no test coverage detected