-
Notifications
You must be signed in to change notification settings - Fork 224
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
Use uuid.uuid4 to generate unique names #274
Conversation
pygmt/helpers/tempfile.py
Outdated
# Use the tempfile module to generate a unique name. | ||
with NamedTemporaryFile(prefix="gmt-python-") as tmpfile: | ||
return os.path.split(tmpfile.name)[-1] | ||
return "gmt-python-" + uuid.uuid4().hex |
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'm not sure how to deal with the prefix gmt-python
. Possible ways:
- No prefix at all
- Change
gmt-python-
topygmt-
- Add arguments
prefix
andsuffix
tounique_name
.
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 we can remove that prefix. Not sure why I added it but it really doesn't make a difference.
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.
Thanks @seisman! Just need a few small changes.
pygmt/helpers/tempfile.py
Outdated
# Use the tempfile module to generate a unique name. | ||
with NamedTemporaryFile(prefix="gmt-python-") as tmpfile: | ||
return os.path.split(tmpfile.name)[-1] | ||
return "gmt-python-" + uuid.uuid4().hex |
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 we can remove that prefix. Not sure why I added it but it really doesn't make a difference.
The failure is because of #276. Will rerun the checks after that is fixed. |
Description of proposed changes
Use
uuid.uuid4().hex
to generate unique names.Fixes #273
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.