| 112 | |
| 113 | |
| 114 | class Target(object): |
| 115 | |
| 116 | def __init__(self, name, hex_path=None, bin_path=None): |
| 117 | self._name = name |
| 118 | self._valid = False |
| 119 | self._hex_path = None |
| 120 | self._bin_path = None |
| 121 | if hex_path is not None: |
| 122 | self.set_hex_path(hex_path) |
| 123 | if bin_path is not None: |
| 124 | self.set_bin_path(bin_path) |
| 125 | self._valid = True |
| 126 | |
| 127 | def __str__(self): |
| 128 | return "Name=%s" % self.name |
| 129 | |
| 130 | def set_hex_path(self, path): |
| 131 | base_name = os.path.basename(path) |
| 132 | assert self._hex_path is None |
| 133 | assert base_name == self._name + '.hex' |
| 134 | path = os.path.abspath(path) |
| 135 | assert os.path.isfile(path) |
| 136 | self._hex_path = path |
| 137 | |
| 138 | def set_bin_path(self, path): |
| 139 | base_name = os.path.basename(path) |
| 140 | assert self._bin_path is None |
| 141 | assert base_name == self._name + '.bin' |
| 142 | path = os.path.abspath(path) |
| 143 | assert os.path.isfile(path) |
| 144 | self._bin_path = path |
| 145 | |
| 146 | @property |
| 147 | def valid(self): |
| 148 | hex_valid = self._hex_path is not None |
| 149 | bin_valid = self._bin_path is not None |
| 150 | return hex_valid and bin_valid and self._valid |
| 151 | |
| 152 | @property |
| 153 | def name(self): |
| 154 | return self._name |
| 155 | |
| 156 | @property |
| 157 | def hex_path(self): |
| 158 | return self._hex_path |
| 159 | |
| 160 | @property |
| 161 | def bin_path(self): |
| 162 | return self._bin_path |