fabric/fabric — pull request #699 by focusaurus (2012-08-02 02:24:17+00:00)
Title: Allow get/put to use name attribute of StringIO/BytesIO objects in output

I am using StringIO heavily for files constructed in memory and then passed to `put`, and wanted log output with a nice meaningful name other than ``.

Here's some sample code to demonstrate this works as before with standard StringIO and BytesIO objects, but if they have a name attribute, use that for log output. Works for both get and put.

```
@task
def test_put():
from StringIO import StringIO as S1
from io import StringIO as S2
from io import BytesIO
from fabric.api import put, get
s1 = S1(u"foo bar")
put(s1, "/tmp/s1")
s1.seek(0)
s1.name = "s2"
put(s1, "/tmp/s1")

s2 = S2(u"s2")
put(s2, "/tmp/s2")
s2.seek(0)
s2.name = "s2"
put(s2, "/tmp/s2")

s3 = S1()
get("/tmp/s1", s3)
s3.seek(0)
s3.name = "s3"
get("/tmp/s1", s3)

s4 = BytesIO()
get("/tmp/s1", s4)
s4.seek(0)
s4.name = "s4"
get("/tmp/s1", s4)
```

and here's the output:

```
[50.57.172.47] Executing task 'test_put'
[50.57.172.47] put: -> /tmp/s1
[50.57.172.47] put: s2 -> /tmp/s1
[50.57.172.47] put: -> /tmp/s2
[50.57.172.47] put: s2 -> /tmp/s2
[50.57.172.47] download: <- /tmp/s1
[50.57.172.47] download: s3 <- /tmp/s1
[50.57.172.47] download: <- /tmp/s1
[50.57.172.47] download: s4 <- /tmp/s1

Done.
Disconnecting from 50.57.172.47... done.
```