Skip to content

Arguments with spaces in strings #247

Description

@seisman

Description of the problem

Full code that generated the error

I tried to plot a basemap with an axis labelled as "Crust Age". I tried in three different ways:

importgmtfig=gmt.Figure()
# 1st way: FAILfig.basemap(R=[0, 100, 0, 50], J="X10c/5c", B='x20+lCrust Age')
# 2nd way: SUCCEEDfig.basemap(R=[0, 100, 0, 50], J="X10c/5c", B='x20+l"Crust Age"')
# 3rd way: FAILfig.basemap(R=[0, 100, 0, 50], J="X10c/5c", B="x20+l'Crust Age'")
fig.savefig("map.pdf")

Full error message

psbasemap [ERROR]: Unrecognized option -<
Traceback (most recent call last):
File "test.sh", line 6, in <module>
fig.basemap(R=[0, 100, 0, 50], J="X10c/5c", B="x20+l'Crust Age'")
File "/Users/seisman/Gits/gmt/gmt-python/gmt/helpers/decorators.py", line 199, in new_module
return module_func(*args, **kwargs)
File "/Users/seisman/Gits/gmt/gmt-python/gmt/helpers/decorators.py", line 294, in new_module
return module_func(*args, **kwargs)
File "/Users/seisman/Gits/gmt/gmt-python/gmt/base_plotting.py", line 472, in basemap
lib.call_module("basemap", build_arg_string(kwargs))
File "/Users/seisman/Gits/gmt/gmt-python/gmt/clib/session.py", line 490, in call_module
module, status, self._error_message
gmt.exceptions.GMTCLibError: Module 'basemap' failed with status code 71:
psbasemap [ERROR]: Unrecognized option -<

The 1st way is equivalent to command line

gmt basemap -R0/100/0/50 -JX10c/5c -Bx20+lCrust Age 

The command fails because "Age" is thought to be a file. However, the error message is almost useless to help users find the error. Do you think it's technically possible to automatically add quotes around strings with spaces if users forget to do that?

The 2nd way works as expected. However, I don't understand why the 3rd way fails? The equivalent cmd version works:

gmt basemap -R0/100/0/50 -JX10c/5c -Bx20+l'Crust Age' -pdf map

System information

  • Operating system: macOS
  • Python installation (Anaconda, system, ETS): Anaconda
  • Version of GMT: 6.0.0_15a9160
  • Version of Python: 3.7.0
  • Version of this package: latest

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedHelping hands are appreciated

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions