Bug #82
fabric.contrib.files.append checks beginning of lines rather than discrete lines
| Status: | Done | Start: | 11/08/2009 | |
| Priority: | Quick | Due date: | ||
| Assigned to: | % 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
Add partial kwarg to contrib.files.append.
Fixes #82.
History
Updated by Jeff Forcier 304 days ago
- 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
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
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 104 days ago
- Status changed from Assigned to Done
- % Done changed from 0 to 100
Applied in changeset e50ec507661a1445d6857242804eeaebc452f071.
Also available in: Atom