| 298 | return data |
| 299 | |
| 300 | def _handle_pack_options(self, src, options): |
| 301 | result = [] |
| 302 | for item in options: |
| 303 | for x in shell_split(item): |
| 304 | if x: |
| 305 | result.extend(x.split('=', 1) if x.find('=') > 0 else [x]) |
| 306 | i = 0 |
| 307 | n = len(result) |
| 308 | |
| 309 | def _quote_path(s): |
| 310 | if not os.path.isabs(s): |
| 311 | s = os.path.join(src, s) |
| 312 | s = s.replace('\\', '/') |
| 313 | return ("'%s'" % s) if s.find(' ') > -1 else s |
| 314 | |
| 315 | while i < n: |
| 316 | v = str(result[i]) |
| 317 | if v in ('--onefile', '-F', '--onefolder', '-D', '--name', '-N', |
| 318 | '--noconfirm', '-y', '--distpath', '--specpath'): |
| 319 | raise RuntimeError('Option "%s" could not be used here' % v) |
| 320 | if v in ('--add-data', '--add-binary'): |
| 321 | i += 1 |
| 322 | if result[i].find(os.pathsep) == -1: |
| 323 | result[i] += os.pathsep + '.' |
| 324 | result[i] = _quote_path(result[i]) |
| 325 | elif v in ('-i', '--icon', '-p', '--paths', '--runtime-hook', |
| 326 | '--additional-hooks-dir', '--version-file', |
| 327 | '-m', '--manifest', '-r', '--resource'): |
| 328 | i += 1 |
| 329 | result[i] = _quote_path(result[i]) |
| 330 | i += 1 |
| 331 | return result |
| 332 | |
| 333 | def _build_target(self, path, args, debug=False): |
| 334 | target = args.get('buildTarget') |