On 04/10/2020 11:26, Achim Gratz wrote:
ASSI writes:
SCALLYWAG="notest"

It seems that if I write something like

  SCALLYWAG="notest" # a comment

then the line actually gets ignored due to a somewhat restrictive regex:

match = re.search(r'^\s*SCALLYWAG=\s*"?(.*?)"?$', content, re.MULTILINE)

Something like this might work better:

match = re.search(r'^\s*SCALLYWAG=\s*"?(.*?)"?(\s*#.*)?$', content, 
re.MULTILINE)

(I hope :-).  Otherwise you'd first need to chop off any comments at the
end and then shove the result into the original regex.

It seems like there is a lot of ad-hoc code in that file that does
things slightly differently for various settings, so that seems like it
should get re-factored into something more general that is used
uniformly across all the things you want to extract from the cygport
file.

As noted elsewhere, trying to parse variables out of the .cygport like this isn't a good approach, and really I want to add something which gets cygport to execute the file and then output the variables of interest.

But I've tweaked things a bit so comments should get discarded before we start looking at the file contents, which hopefully helps this a bit.

Reply via email to