<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
It is good to see these tests. So order does not fix it like Glynn implied. It also gives different results depending on order and capitalization.
<div><br>
</div>
<div>IMHO, this is a fairly serious problem. I’m OK with lower case being enforced but the way to do this that causes the least damage for porting scripts from GRASS 6 to GRASS 7 is for GRASS 7 to simply recognize all option names as lower case. That is option
= lower(option). </div>
<div><br>
</div>
<div>The reason we found this is because we are porting to GRASS 7 a script that has worked in GRASS 6. We started getting the misleading error messages that you documented below. </div>
<div><br>
</div>
<div>At the very least, the error generated needs to be something along the lines of “upper case characters are not allowed for option names in GRASS modules”</div>
<div><br>
</div>
<div>Michael<br>
<div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="orphans: 2; text-align: -webkit-auto; text-indent: 0px; widows: 2; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<span class="Apple-style-span" style="border-collapse: separate; orphans: 2; text-indent: 0px; widows: 2; border-spacing: 0px;">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<span class="Apple-style-span" style="border-collapse: separate; orphans: 2; text-indent: 0px; widows: 2; border-spacing: 0px;">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<span class="Apple-style-span" style="border-collapse: separate; orphans: 2; text-indent: 0px; widows: 2; border-spacing: 0px;">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<span class="Apple-style-span" style="border-collapse: separate; orphans: 2; text-indent: 0px; widows: 2; border-spacing: 0px;">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<span class="Apple-style-span" style="border-collapse: separate; orphans: 2; text-indent: 0px; widows: 2; border-spacing: 0px;">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<span class="Apple-style-span" style="border-collapse: separate; orphans: 2; text-indent: 0px; widows: 2; border-spacing: 0px;">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<span class="Apple-style-span" style="border-collapse: separate; orphans: 2; text-indent: 0px; widows: 2; border-spacing: 0px;">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<span class="Apple-style-span" style="border-collapse: separate; orphans: 2; text-indent: 0px; widows: 2; border-spacing: 0px;">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<span class="Apple-style-span" style="border-collapse: separate; orphans: 2; text-indent: 0px; widows: 2; border-spacing: 0px;">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<span class="Apple-style-span" style="border-collapse: separate; orphans: 2; text-indent: 0px; widows: 2; border-spacing: 0px;">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; -webkit-text-decorations-in-effect: none;">
<font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">______________________________</span></font></div>
<div style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; -webkit-text-decorations-in-effect: none;">
<font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">C. Michael Barton </span></font></div>
<div style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; -webkit-text-decorations-in-effect: none;">
<font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">Director, Center for Social Dynamics & Complexity</span></font></div>
<div style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; -webkit-text-decorations-in-effect: none;">
<font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">Professor of Anthropology, School of Human Evolution & Social Change</span></font></div>
<div style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; -webkit-text-decorations-in-effect: none;">
<font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">Head, Graduate Faculty in Complex Adaptive Systems Science</span></font></div>
<div style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; -webkit-text-decorations-in-effect: none;">
<span class="Apple-style-span" style="font-size: 12px; font-family: Helvetica;">Arizona State University</span></div>
<div style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; -webkit-text-decorations-in-effect: none;">
<font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">Tempe, AZ 85287-2402</span></font></div>
<div style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; -webkit-text-decorations-in-effect: none;">
<font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">USA</span></font></div>
<div style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; -webkit-text-decorations-in-effect: none;">
<font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br>
</span></font></div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<font class="Apple-style-span" face="Helvetica" size="3" style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><span class="Apple-style-span" style="font-size: 12px;">voice:<span class="Apple-converted-space"> </span><span class="Apple-tab-span" style="white-space: pre;">
</span>480-965-6262 (SHESC), 480-965-8130/</span></font><span style="font-size: 12px;">727-9746</span><span style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"> (CSDC)</span></div>
<div style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; -webkit-text-decorations-in-effect: none;">
<font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">fax: 480-965-7671(SHESC), 480-727-0709 (CSDC)</span></font></div>
<div style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; -webkit-text-decorations-in-effect: none;">
<font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">www: <span class="Apple-tab-span" style="white-space: pre;">
</span><a href="http://csdc.asu.edu">http://csdc.asu.edu</a>, <a href="http://shesc.asu.edu">
http://shesc.asu.edu</a></span></font></div>
<div style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; -webkit-text-decorations-in-effect: none;">
<font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;"><span class="Apple-tab-span" style="white-space: pre;"></span><a href="http://www.public.asu.edu/~cmbarton">http://www.public.asu.edu/~cmbarton</a></span></font></div>
</div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</div>
</div>
<br>
<div>
<div>On Sep 26, 2014, at 9:59 AM, Vaclav Petras <<a href="mailto:wenzeslaus@gmail.com">wenzeslaus@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Thu, Sep 25, 2014 at 11:56 PM, Michael Barton<span class="Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:Michael.Barton@asu.edu" target="_blank">Michael.Barton@asu.edu</a>></span><span class="Apple-converted-space"> </span>wrote:<br>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
Thanks for the explanation Glynn. So this is a byproduct of changes for other goals. It is good to learn that a work around can be simply re-odering the options.</blockquote>
<div><br>
</div>
<div>I would recommend not to work around thing like this. The behavior might be changed in the future and you will be in the same or worse situation then now.<br>
<br>
</div>
<div>More importantly, according to my understanding, reordering will not help you.<br>
<br>
</div>
<div>I created four scripts. Each has two parameters/options "elevation" and "slope". Script test_lower_lower has both options lowercase, test_upper_upper has both options with uppercase letter etc. The output of the script are the options (as Python dictionary).<br>
</div>
<div><br>
</div>
<div>Standard case:<br>
</div>
<div><br>
./test_lower_lower.py elevation=abc slope=cde<br>
{'slope': 'cde', 'elevation': 'abc'}<br>
<br>
</div>
<div>Both upper case, error reported for the second option. Error is not really informative but it fails.<br>
</div>
<div><br>
./test_upper_upper.py Elevation=abc Slope=cde<br>
ERROR: Sorry <Slope=cde> is not a valid option<br>
ERROR: Required parameter <Slope> not set:<br>
(Name for output slope raster map)<br>
<br>
</div>
<div>Same case as above, second option is not accepted (in this case the message at least applies to the first wrong option):<br>
</div>
<div><br>
./test_lower_upper.py elevation=abc Slope=cde<br>
ERROR: Sorry <Slope=cde> is not a valid option<br>
ERROR: Required parameter <Slope> not set:<br>
(Name for output slope raster map)<br>
<br>
</div>
<div>Only the first option is upper case and is accepted but the result is not what you would like to get:<br>
</div>
<div><br>
./test_upper_lower.py Elevation=abc slope=cde<br>
{'slope': 'cde', 'Elevation': 'Elevation=abc'}<br>
<br>
</div>
<div>However, this is what r.mapcalc benefits from, for maximum compatibility in the way the example above is showing and in standard cases in the way below:<br>
</div>
<div><br>
./test_upper_lower.py abc slope=cde<br>
{'slope': 'cde', 'Elevation': 'abc'}<br>
</div>
<div> </div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
This makes it easier to maintain chaining between scripts or calling modules from other programs.</blockquote>
<div><br>
</div>
<div>The changes are not more serious then changes in module parameters/options and flags or module names and there is a lot of these changes between 6 and 7. Sorry, I really don't see much difference between other API changes and this one.<br>
</div>
<div> </div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
This behavior is still a potential gotcha for anyone writing scripts, however. Sometimes it will give an ambiguous error and a similar script with a different order of options will not.<br>
<span class="im"><br>
</span></blockquote>
<div>And this is exactly the reason why the lowercase should be enforced as soon as possible in the parsing process or at least a better error message should be provided. It would be good to avoid tests which would slow down the correct scripts but I don't
know if it would actually make any difference.<br>
</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
<span class="im">Michael<br>
____________________<br>
C. Michael Barton<br>
Director, Center for Social Dynamics & Complexity<br>
Professor of Anthropology, School of Human Evolution & Social Change<br>
Head, Graduate Faculty in Complex Adaptive Systems Science<br>
Arizona State University<br>
<br>
voice: <span class="Apple-converted-space"> </span><a href="tel:480-965-6262" value="+14809656262">480-965-6262</a><span class="Apple-converted-space"> </span>(SHESC),<span class="Apple-converted-space"> </span><a href="tel:480-965-8130" value="+14809658130">480-965-8130</a>/727-9746
(CSDC)<br>
fax:<span class="Apple-converted-space"> </span><a href="tel:480-965-7671" value="+14809657671">480-965-7671</a><span class="Apple-converted-space"> </span>(SHESC), <span class="Apple-converted-space"> </span><a href="tel:480-727-0709" value="+14807270709">480-727-0709</a><span class="Apple-converted-space"> </span>(CSDC)<br>
www:<span class="Apple-converted-space"> </span><a href="http://www.public.asu.edu/~cmbarton" target="_blank">http://www.public.asu.edu/~cmbarton</a>,<span class="Apple-converted-space"> </span><a href="http://csdc.asu.edu/" target="_blank">http://csdc.asu.edu</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</span>
<div class="">
<div class="h5">On Sep 25, 2014, at 4:40 PM, Glynn Clements <<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>> wrote:<br>
<br>
><br>
> Michael Barton wrote:<br>
><br>
>> I just learned that using upper case characters for a GRASS 7 module<br>
>> option means that g.parser will not recognize it.<br>
><br>
> Technically, the change is to G_parser(); g.parser simply inherits the<br>
> behaviour.<br>
><br>
>> That is for module. �r.foo" with options �Abc� and �def�, the<br>
>> command<br>
>><br>
>> r.foo Abc=1 def=2<br>
>><br>
>> will return an error <Abd=1> is not a valid option.<br>
><br>
> No it won't.<br>
><br>
> However, this will produce that error:<br>
><br>
> r.foo def=2 Abc=1<br>
><br>
> If the first argument doesn't match the required syntax (e.g. because<br>
> of an upper-case character in the option name), it will be treated as<br>
> the value to the default (first) option. IOW, assuming that "Abc" is<br>
> the first option, your example:<br>
><br>
> r.foo Abc=1 def=2<br>
><br>
> will be treated as:<br>
><br>
> r.foo Abc=Abc=1 def=2<br>
><br>
>> GRASS 6 does not produce an error in this case. The module will run fine.<br>
>><br>
>> This breaks all kinds of existing scripts from GRASS6, as well as<br>
>> scripts that are designed to be chained together. I�ve never seen<br>
>> any discussion of this. Perhaps I missed it because I was in the<br>
>> field or something. Is there a reason for this significant change of<br>
>> g.parser behavior?<br>
><br>
> The changes in question are r32259 and r32261, from July 2008, and<br>
> r33576 from September 2008.<br>
><br>
> The rationale was related to changing r.mapcalc to use G_parser().<br>
><br>
> Following that change, if r.mapcalc is run as e.g.<br>
><br>
> r.mapcalc "map=expression"<br>
><br>
> G_parser() will complain that there is no option named "map".<br>
><br>
> The preferred way of avoiding this issue is to place spaces around the<br>
> "=" sign; a space before the "=" guarantees that the argument will not<br>
> be treated as having the option=value form, and will instead be<br>
> treated as the value to the default option (expression=).<br>
><br>
> In order to maximise compatibility with the previous version, the test<br>
> for whether an argument has the option=value form was restricted. Any<br>
> argument not conforming to the (newly-restricted) syntax will be<br>
> treated as the value of the expression= option. The more restrictive<br>
> the syntax, the fewer expressions will be mistaken for option=value.<br>
><br>
> Originally, any argument containing an "=" was considered as having<br>
> the option=value form.<br>
><br>
> r32259 changed this to require that the character immediately before<br>
> the first "=" was not a space or tab. r32261 refined it to require the<br>
> character to be a lower-case letter or a digit. r33576 further refined<br>
> this so that the entire portion before the first "=" must consist<br>
> solely of lower-case letters, digits and underscores, and the<br>
> character immediately before the "=" must not be an underscore.<br>
><br>
> With one exception; all option names used in GRASS' own modules and<br>
> scripts already satisfied the new restrictions. The sole exception was<br>
> r.terraflow, which had the STREAM_DIR= option renamed to stream_dir=<br>
> in r32260.<br>
><br>
> --<br>
> Glynn Clements <<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>><br>
<br>
_______________________________________________<br>
grass-dev mailing list<br>
<a href="mailto:grass-dev@lists.osgeo.org">grass-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-dev</a></div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
<span><test_upper_lower.py></span></div>
</blockquote>
</div>
<br>
</div>
</body>
</html>