[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] Bug in multiline append

From: Jeff Forcier
Subject: Re: [Fab-user] Bug in multiline append
Date: Fri, 22 May 2009 09:21:41 -0400

On Fri, May 22, 2009 at 9:04 AM, Christian Vest Hansen
<address@hidden> wrote:
> Why do you make that check in append in the first place?

The idea was to try and make things "repeatable" such that I could run
a setup fab task multiple times in a row, and it would not end up
with, say, 5 of the same line appended to a file. This stuff is taken
directly from abstracted personal subroutines, so right now it's
basically "my needs + some minor attempts to make things more
generic". Hence many of these edge cases coming out.

> "append" sounds like a procedure that does one thing: appending. Not
> checking if something is already in the file and then maybe adding it
> to the end. That sounds like something that could be called
> "ensureContains" or something.

Or we could simply expose that behavior to the user as an option, e.g.
append('mystring', check_existence=False) or whatnot.

Whether to do this or make a second function leveraging the first just
requires a bit of thought about the desired API. (Lately I've been
waffling on whether to try and minimize things or to allow some extra
functions that are simply convenience wrappers around existing ones,
for example.)

> Also, you could consider using fgrep or grep -F to get fixed-string
> matching instead of regexp - this is perhaps an extension you could
> make to "contains".

This could be another solution to the problem, yea; especially since
many of these functions are just wrappers around the command line
tools, the more options we add, the better.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]