mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 11:49:01 +08:00
Somewhat better documentation
Just some stuff that I saw and thought were missing.
This commit is contained in:
parent
8525131849
commit
91ab53e49c
@ -190,7 +190,7 @@ class PostProcessingPlugin(QObject, Extension):
|
|||||||
## When the global container stack is changed, swap out the list of active
|
## When the global container stack is changed, swap out the list of active
|
||||||
# scripts.
|
# scripts.
|
||||||
def _onGlobalContainerStackChanged(self):
|
def _onGlobalContainerStackChanged(self):
|
||||||
self.loadAllScripts()
|
self.loadAllScripts() #Make sure we have all scripts if we didn't have them yet.
|
||||||
new_stack = Application.getInstance().getGlobalContainerStack()
|
new_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
self._script_list.clear()
|
self._script_list.clear()
|
||||||
if not new_stack.getMetaDataEntry("post_processing_scripts"): #Missing or empty.
|
if not new_stack.getMetaDataEntry("post_processing_scripts"): #Missing or empty.
|
||||||
@ -202,7 +202,7 @@ class PostProcessingPlugin(QObject, Extension):
|
|||||||
for script_str in scripts_list_strs.split("\n"): #Encoded config files should never contain three newlines in a row. At most 2, just before section headers.
|
for script_str in scripts_list_strs.split("\n"): #Encoded config files should never contain three newlines in a row. At most 2, just before section headers.
|
||||||
if not script_str: #There were no scripts in this one (or a corrupt file caused more than 3 consecutive newlines here).
|
if not script_str: #There were no scripts in this one (or a corrupt file caused more than 3 consecutive newlines here).
|
||||||
continue
|
continue
|
||||||
script_str = script_str.replace("\\n", "\n").replace("\\\\", "\\")
|
script_str = script_str.replace("\\n", "\n").replace("\\\\", "\\") #Unescape escape sequences.
|
||||||
script_parser = configparser.ConfigParser(interpolation = None)
|
script_parser = configparser.ConfigParser(interpolation = None)
|
||||||
script_parser.read_string(script_str)
|
script_parser.read_string(script_str)
|
||||||
for script_name, settings in script_parser.items(): #There should only be one, really! Otherwise we can't guarantee the order or allow multiple uses of the same script.
|
for script_name, settings in script_parser.items(): #There should only be one, really! Otherwise we can't guarantee the order or allow multiple uses of the same script.
|
||||||
@ -231,10 +231,10 @@ class PostProcessingPlugin(QObject, Extension):
|
|||||||
parser.write(serialized)
|
parser.write(serialized)
|
||||||
serialized.seek(0)
|
serialized.seek(0)
|
||||||
script_str = serialized.read()
|
script_str = serialized.read()
|
||||||
script_str = script_str.replace("\\", "\\\\").replace("\n", "\\n")
|
script_str = script_str.replace("\\", "\\\\").replace("\n", "\\n") #Escape newlines because configparser sees those as section delimiters.
|
||||||
script_list_strs.append(script_str)
|
script_list_strs.append(script_str)
|
||||||
|
|
||||||
script_list_strs = "\n".join(script_list_strs) #ConfigParser should never output three newlines in a row when serialised, so it's a safe delimiter (and very human-readable).
|
script_list_strs = "\n".join(script_list_strs) #ConfigParser should never output three newlines in a row when serialised, so it's a safe delimiter.
|
||||||
|
|
||||||
global_stack = Application.getInstance().getGlobalContainerStack()
|
global_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if "post_processing_scripts" not in global_stack.getMetaData():
|
if "post_processing_scripts" not in global_stack.getMetaData():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user