Menu

#774 simple calculations make URI completions more effective

open
nobody
None
5
2022-03-05
2022-02-26
No

For years I've been writing code with very long lines so that I can get completions in the getDataSet calls, like this:

ds= getDataSet( 'vap+cdf:https://cdaweb.gsfc.nasa.gov/pub/data/cluster/c4/pp/efw/2005/c4_pp_efw_20050130_v01.cdf?E_dusk__C4_PP_EFW' )

Then I'll have a series of things I'll read, all using the long address of the file. To reduce code and opportunities for mistakes, I would have a variable representing the file, like so:

file= 'https://cdaweb.gsfc.nasa.gov/pub/data/cluster/c4/pp/efw/2005/c4_pp_efw_20050130_v01.cdf'
ds= getDataSet( 'vap+cdf:+'file+'?E_dusk__C4_PP_EFW' )

but I don't do this because I loose completions.

Autoplot could do some simple calculations while interpretting the syntax tree (AST), putting together strings for example.

Discussion

  • Jeremy Faden

    Jeremy Faden - 2022-02-26

    A first go at this is in 20220226a. The version supports simple string calculations, and numbers are converted to strings. This is a good stopping point, but I can imagine interpolating strings by calling a Jython interpretter.

     

    Last edit: Jeremy Faden 2022-02-26
  • Jeremy Faden

    Jeremy Faden - 2022-02-26

    Here's a screenshot showing where it shows that the arg_0 parameter needs to be changed:

     
  • Jeremy Faden

    Jeremy Faden - 2022-02-26

    I've put in support for interpolation of strings containing %s and %d. This uses Java's String.format to simulate Python interpolation.

     
  • Jeremy Faden

    Jeremy Faden - 2022-03-05

    Also there's an action to enter the editor GUI for the URI, and this should be supported as well.