-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-write of Search and Replace #19796
Conversation
Added some options: - Replace the 'First Instance Only' of the Search term. - Limit the Search to a layer range. - 'Ignore StartUp G-code' and 'Ignore Ending G-code'
Thanks, we will take a look when we are not overbusy 😊 |
Update a description Update SearchAndReplace.py Fixed the "descriptions". Cura didn't like the dashes or backslashes.
146f2f9
to
349c528
Compare
} | ||
} | ||
}""" | ||
|
||
def execute(self, data): | ||
curaApp = Application.getInstance().getGlobalContainerStack() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style: cura_app
instead of curaApp
.
Or better, since you are actually getting the global container stack: global_stack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
for layer_number, layer in enumerate(data): | ||
data[layer_number] = re.sub(search_regex, replace_string, layer) #Replace all. | ||
#Find the raft and layer:0 indexes-------------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange comment style. Please use the same style of comments as the rest of Cura.
I am somewhat surprised Python does not complain about the indentation; strictly speaking this indentation ends the previous codeblock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
replaceone = True | ||
break | ||
if replaceone: break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see, this condition is never met because we're already broken out of the for loop. As a matter of fact, it seems to me that the whole replaceone
variable is useless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that was vestigial code. There may have been a second "for" in there and I used the second 'break' to back all the way out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There seems to be a lot of unnecessary code duplication after line 170 |
Update SearchAndReplace.py Changed comments. Revised code below line 170. Changed 'curaApp' to 'cura_app'
fbe4c39
to
be509b6
Compare
Thanks @fieldOfView. A quick squash and all the changes are in that last commit. |
Change variable name from cura_app to global_stack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @GregValiant, the code looks overall good and I do like the new settings very much, this is a real improvement 🙂
I do have some questions, and a few nitpicking code-style remarks but nothing serious
Much simpler. |
Replaced the complex method of dealing with rafts to something simpler. Update SearchAndReplace.py Update
a2208a3
to
36141b0
Compare
I made slight adjustments to the settings descriptions, @GregValiant tell me if this is ok for you, if yes it's all good to me. |
Looks good. "\n" eh? Thanks. |
That's ok, I have faced similar issues A LOT of times, within different languages/encodings/file types/... so I know how annoying it can be 🙂 |
Added some options:
Description
Added flexibility to the script. The options still allow a full Search and Replace as well as a limited Search and Replace.
Type of change
How Has This Been Tested?
I have been using this version for a year with multiple Cura versions.
Test Configuration:
Win10 Pro on a laptop.
UM Cura 4.13.1 to 5.9beta.
Checklist: