Skip to content
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

Split file and directory cleaning patterns. #56

Merged
merged 3 commits into from Sep 4, 2018
Merged

Conversation

ktlim
Copy link
Contributor

@ktlim ktlim commented Aug 31, 2018

No description provided.

Copy link
Member

@timj timj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this. My main concern is there seems to be a lot of code duplication now.

(files_expr, file_action)
filesExpr += "-name %s" % re.sub(r"(^|[^\\])([\[*])", r"\1\\\2", filePattern)
action = "find %s" % directory
action += r" \( -name .svn -prune -o -name .git -prune -o -name \* \) "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of duplication in these two cases. Same pruning, same regex substitution. Can there be a little helper function that you can create here to reduce code duplication?

filesExpr += "-name %s" % re.sub(r"(^|[^\\])([\[*])", r"\1\\\2", filePattern)
action = "find %s" % directory
action += r" \( -name .svn -prune -o -name .git -prune -o -name \* \) "
action += r" \( %s \) -exec rm -f {} \;" % filesExpr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be safer to use -type f here and -type d below?

@ktlim
Copy link
Contributor Author

ktlim commented Sep 4, 2018

Better now? Should I add __pycache__ to the patterns?

Copy link
Member

@timj timj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Adding the python cache directory to the clean seems reasonable.

@ktlim ktlim merged commit 914fe58 into master Sep 4, 2018
@ktlim ktlim deleted the tickets/DM-15530 branch September 4, 2018 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants