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
Python script to set parameters for ksonnet prototypes #769
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
scripts/update_prototype.py
Outdated
v = r"\g<1>" + value + r"\2" | ||
regexps[param] = (r, v, value) | ||
|
||
prototype = open(args.file).read().split("\n") |
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.
Can you use with open()
to open a file so that opened files are closed.
scripts/update_prototype.py
Outdated
if "=" not in pair: | ||
raise Exception("Malformed --values") | ||
param, value = pair.split("=") | ||
r = re.compile(r"([ \t]*" + param + ":+ ?\"?)[^\",]+(\"?,?)") |
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.
Can you add a comment explaining this.
scripts/update_prototype.py
Outdated
temp_file = args.file + ".tmp" | ||
open(temp_file, "w").write("\n".join(prototype)) | ||
os.rename(temp_file, args.file) | ||
print("Successfully made %d replacements" % replacements) |
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.
Can you define a main() function with all this code and invoke it using:
if __name__ == '__main__':
main()
@@ -0,0 +1,47 @@ | |||
import re |
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.
Can you add a docstring to explain what this does with an example?
/ok-to-test |
CLAs look good, thanks! |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ankushagarwal The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
* Added script for updating prototypes' parameters * Added docstring, comments, with open, main function.
* feat: Add doc Signed-off-by: Ce Gao <gaoce@caicloud.io> * feat: Update Signed-off-by: Ce Gao <gaoce@caicloud.io> * feat: Update Signed-off-by: Ce Gao <gaoce@caicloud.io> * fix: Update Signed-off-by: Ce Gao <gaoce@caicloud.io> * fix: Address comments Signed-off-by: Ce Gao <gaoce@caicloud.io>
Closes #322
This change is