Bug #82

avatar

fabric.contrib.files.append checks beginning of lines rather than discrete lines

Added by Jonas Nockert 305 days ago. Updated 104 days ago.

Status:Done Start:11/08/2009
Priority:Quick Due date:
Assigned to:avatarJeff Forcier % Done:

100%

Category:Contrib
Target version:0.9.1

Description

The documentation for 0.9 states that:

If text is already found as a discrete line in filename, the append is not run, and None is returned immediately. Otherwise, the given text is appended to the end of the given filename via e.g. echo ‘$text’ >> $filename.

However, it seems that’s not the case. See the following pseudo code:

$ echo "hello world" > test.txt
$ fab fabric.contrib.files.append("hello", "test.txt")
$ cat test.txt
hello world

Related issues

related to Support #172 Make default function arg values more sensible New 05/27/2010

Associated revisions

Revision e50ec507661a1445d6857242804eeaebc452f071
Added by Jeff Forcier 104 days ago

Add partial kwarg to contrib.files.append.

Fixes #82.

History

Updated by Jeff Forcier 304 days ago

avatar
  • Assigned to set to Jeff Forcier
  • Target version set to 0.9.1

Good catch. I don’t recall why I left off the EOL marker in the regex, I know I used the BOL marker to avoid “finding” commented out versions of the line to append — but you’re right that either the docstring needs to change or I should throw in an EOL.

I assume you ran into this while using it in some real-world situation — in your particular case(s), does it make sense to add the EOL so the docstring is accurate and it does literally find exact matches?

Or would it be better/easier if we made this more configurable via kwargs, e.g. partial=True or something like that?

Updated by Jonas Nockert 304 days ago

avatar

No real-world situation, I'm afraid. I was just going through the contrib functionality while writing a presentation on using Fabric for deployment. I like the idea of partial=True as I think both use cases could exist.

One use case for leaving out the EOL marker would be to append some setting in the form “setting = value” unless the setting is already being set. However, it fails completely if there are multiple settings with the same “stem” (e.g. “NAME” and “NAMESPACE”).

Updated by Jeff Forcier 304 days ago

avatar
  • Category set to Contrib

Updated by Jeff Forcier 304 days ago

avatar

Ah, gotcha. And yes — it gets tricky. In using this and related tools I've become very irritated with any config file format that cannot be easily modified via sed.

Anyway, my general philosophy is “make things as configurable as is reasonably possible”, so I’ll probably opt to put that partial or similar kwarg in place.

Updated by Jeff Forcier 301 days ago

avatar
  • Target version changed from 0.9.1 to 0.9.2

Updated by Jeff Forcier 245 days ago

avatar
  • Status changed from New to Assigned

Updated by Jeff Forcier 245 days ago

avatar
  • Priority changed from Normal to Quick

Updated by Jeff Forcier 104 days ago

avatar
  • Target version changed from 0.9.2 to 0.9.1

Updated by Jeff Forcier 104 days ago

avatar
  • Status changed from Assigned to Done
  • % Done changed from 0 to 100

Also available in: Atom