On Thu, Oct 28, 2010 at 4:46 PM, Dan Craig <
address@hidden> wrote:
> Hello all,
>
> I'm new to Fabric, but have enjoyed learning it and look forward to using it
> for automating deployments. Thanks for writing it.
>
> In the process, I got hung up on the behavior of contrib.files.comment and
> uncomment. I want to be able to uncomment and then later recomment a line
> from an Apache conf file. The lines themselves contain regular expressions,
> so I passed them through re.escape() first before uncomment()/comment().
> This works just fine on uncomment(), but fails on comment(). I traced the
> cause of this down contrib.files.sed's escaping of the before and after
> arguments, but not the limit. In uncomment(), the line to uncomment is
> passed to sed as the limit, and thus not escaped, but in comment, the line
> is passed to sed as the before, which is escaped.
>
> My workaround is to call uncomment like normal::
>
> uncomment(myfilename, re.escape("MyReContainingLine"))
>
> but call comment like so::
>
> comment(myfilename, re.escape("MyReContainingLine").replace(r"\/", "/"))
>
> This works, but seems wrong. I'd expect uncomment and comment to be called
> in the same way. OTOH, the escaping in sed is a nice convenience. Thought
> I'd throw this out there in case it might be worth addressing.
>
> Regards,
> Dan Craig
>