333 packageName = "" |
333 packageName = "" |
334 internalPackages = [] |
334 internalPackages = [] |
335 needsRestart = False |
335 needsRestart = False |
336 pyqtApi = 0 |
336 pyqtApi = 0 |
337 doCompile = True |
337 doCompile = True |
|
338 |
|
339 separator = "=" # initialize for old-style header |
|
340 insideHeader = False |
338 for line in pluginSource.splitlines(): |
341 for line in pluginSource.splitlines(): |
339 if line.startswith("packageName"): |
342 line = line.strip() |
340 tokens = line.split("=") |
343 if line.startswith("# Start-Of-Header"): |
341 if ( |
344 insideHeader = True |
342 tokens[0].strip() == "packageName" |
345 continue |
343 and tokens[1].strip()[1:-1] != "__core__" |
346 |
344 ): |
347 if not insideHeader: |
345 if tokens[1].strip()[0] in ['"', "'"]: |
348 continue |
346 packageName = tokens[1].strip()[1:-1] |
349 |
347 else: |
350 if line.startswith("__header__"): |
348 if tokens[1].strip() == "None": |
351 # it is a new style header |
349 packageName = "None" |
352 separator = ":" |
350 elif line.startswith("internalPackages"): |
353 continue |
351 tokens = line.split("=") |
|
352 token = tokens[1].strip()[1:-1] |
|
353 # it is a comma separated string |
|
354 internalPackages = [p.strip() for p in token.split(",")] |
|
355 elif line.startswith("needsRestart"): |
|
356 tokens = line.split("=") |
|
357 needsRestart = tokens[1].strip() == "True" |
|
358 elif line.startswith("pyqtApi"): |
|
359 tokens = line.split("=") |
|
360 with contextlib.suppress(ValueError): |
|
361 pyqtApi = int(tokens[1].strip()) |
|
362 elif line.startswith("doNotCompile"): |
|
363 tokens = line.split("=") |
|
364 if tokens[1].strip() == "True": |
|
365 doCompile = False |
|
366 elif line.startswith("# End-Of-Header"): |
354 elif line.startswith("# End-Of-Header"): |
367 break |
355 break |
|
356 |
|
357 with contextlib.suppress(ValueError): |
|
358 key, value = line.split(separator) |
|
359 key = key.strip().strip("\"'") |
|
360 value = value.strip().rstrip(",") |
|
361 # get rid of trailing ',' in new-style header |
|
362 |
|
363 if key == "packageName": |
|
364 if value[1:-1] != "__core__": |
|
365 if value[0] in ['"', "'"]: |
|
366 packageName = value[1:-1] |
|
367 else: |
|
368 if value == "None": |
|
369 packageName = "None" |
|
370 elif key == "internalPackages": |
|
371 # it is a comma separated string |
|
372 internalPackages = [p.strip() for p in value[1:-1].split(",")] |
|
373 elif key == "needsRestart": |
|
374 needsRestart = value == "True" |
|
375 elif key == "pyqtApi": |
|
376 with contextlib.suppress(ValueError): |
|
377 pyqtApi = int(value) |
|
378 elif key == "doNotCompile" and value == "True": |
|
379 doCompile = False |
368 |
380 |
369 if not packageName: |
381 if not packageName: |
370 return ( |
382 return ( |
371 False, |
383 False, |
372 self.tr( |
384 self.tr( |