Coder Social home page Coder Social logo

fso's People

Contributors

metagriffin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

pombredanne

fso's Issues

`name` property in file object

When opening a file with or without fso the file name property is stored differently:

import fso

with open('/tmp/test.txt', 'w') as file:
  print file
  print file.name # <----

with fso.push() as overlay:
  with open('/tmp/test.txt', 'w') as file:
    print file
    print file.path # <----

In Ubuntu 16.4 returns:

<open file '/tmp/test.txt', mode 'w' at 0x7f09d6b61540>
/tmp/test.txt
<fso.filesystemoverlay.OverlayFileStream instance at 0x7f09d6a295a8>
/tmp/test.txt

In MacOS High Sierra returns:

<open file '/tmp/test.txt', mode 'w' at 0x10ae3f390>
/tmp/test.txt
<fso.filesystemoverlay.OverlayFileStream instance at 0x10ae5bd40>
/private/tmp/test.txt

Without fso we can use file.name. Can you make fso also allow for the name property? In addition can you make sure the paths match in macos?

Your library is very nice, thank you!
Kind regards.

tempfile.mkdtemp sometimes fails under fso?

I'm not 100% convinced that this is an issue with fso, but it looks like a call to tempfile.mkdtemp will fail if the fso is active and tempfile.mkdtemp hasn't been called.

simplest repro for me:

[ted@localhost]$ venv/bin/python
>>> import tempfile, fso
>>> fso.push()
<fso.filesystemoverlay.FileSystemOverlay object at 0x7f7279b26490>
>>> tempfile.mkdtemp()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/tempfile.py", line 331, in mkdtemp
    dir = gettempdir()
  File "/usr/lib64/python2.7/tempfile.py", line 275, in gettempdir
    tempdir = _get_default_tempdir()
  File "/usr/lib64/python2.7/tempfile.py", line 200, in _get_default_tempdir
    with _io.open(fd, 'wb', closefd=False) as fp:
TypeError: coercing to Unicode: need string or buffer, int found

And all subsequent calls while the fso remains active will fail.

But when I went to confirm that mkdtemp was working at all I found this:

[ted@localhost]$ venv/bin/python
>>> import tempfile, fso
>>> tempfile.mkdtemp()
'/tmp/tmpPPE6VM'
>>> fso.push()
<fso.filesystemoverlay.FileSystemOverlay object at 0x7f219ac07490>
>>> tempfile.mkdtemp()
'/tmp/tmpWrHhoT'

I can even fso.push(), see it fail, fso.pop(), see it succeed, fso.push(), see it continue succeeding.

Started to look at the tempfile code to see if I could track this down, but don't have the time at this moment, and have a workaround ^.

Even a confirmation that this couldn't possibly be fso's fault would be helpful. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.