Skip to content

Support passing in pathlib.Path into pygmt modules #1381

Closed
@weiji14

Description

@weiji14

Description of the desired feature

Originally posted by @liamtoney in #949 (comment)

I'd add Path objects if they're not already supported. :)

The pathlib.Path is a cross-platform way of handling filepaths. Currently PyGMT supports passing in filenames as a str, but it would be good to ensure that pathlib.Path works too.

What needs to be done ☑️

  1. This if-statement needs to be modified:

if isinstance(data, str):
kind = "file"

  1. Add some unit tests with pathlib.Path inputs, best placed in https://github.com/GenericMappingTools/pygmt/blob/master/pygmt/tests/test_info.py.

How to make the change 🧐

  1. First, read up our contributing guidelines at https://www.pygmt.org/v0.4.0/contributing.html#editing-the-documentation
  2. Leave a comment below, stating that you will tackle this issue. We will assign you to this issue and you can then start working on it.
  3. To edit the utils.py file, go to https://github.com/GenericMappingTools/pygmt/edit/master/pygmt/helpers/utils.py and make the change!. Or you may want to do this in your code editor locally.
  4. Submit a pull request, and be sure to fill it up with as much detail as possible.

Are you willing to help implement and maintain this feature? Happy to guide someone with some familiarity with Python Path objects to work on this. Will also be a great opportunity for someone wanting to learn how to write unit tests.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions