#1 Declined
Deleted repository
default (d5afcfc7dea4)
another_thomas/tempdir tempdir

new tempdir features

  1. Krisztian Fekete avatarKrisztian Fekete

Hi Thomas,

I have created a new fork initially named tempdir2, then deleted the first patch queue version and renamed tempdir2 to tempdir - sorry for the mess, you can ignore all previous mails/notifications.

The result is - now you can get all three commits through this pull request/ the tempdir fork.

As a first step the tests has been cleaned up - all mock use has been removed (I had the feeling they are not entirely OK anyway), without this first change new functionality could not be tested easily.

The implemented new features are

  1. a function decorator (@within_temp_dir) and a context manager (in_temp_dir()) to change working directory to the temporary directory

  2. syntactic sugar for os.path.join on TempDir(): the expression TempDir() / "relpath" has the value of "relpath" added to the temporary directory as an absolute path.

The first feature is something I have not seen before, the / magic concatenation appears in some other modules as well.

Let me know what you think about the patches.

Kind regards, Krisztian

Comments (3)

  1. another_thomas repo owner

    Sorry about the delay. I think the convenience context manager and decorator are really good ideas. I do like my tests not touching the filesystem too much though :) I implemented the wrappers in a less intrusive way.

    Do you use the / magic a lot? I've mostly used the module to provide storage directories for external tools, so I haven't had any need, but if you can provide me with a smaller pull request just featuring that, I'll gladly merge it

  2. Krisztian Fekete author

    No problem, really!

    I used TempDir only in tests and needed relative-to-temp-dir names all the time.

    Function decorator, context manager and / magic are all conveniences for getting such a relative-to-temp-dir path:

    • by changing directory and using real relative paths
    • by using / - instead of os.path.join

    I do think / magic fits naturally to TempDir, but it is just a wrapped os.path,join, without a user (I have no need for it - function decorator itself is enough for me). So I'd skip / magic now.

    BTW, thanks for attributing to me the ideas, but apart from the function decorator, they are reinventions at best (I have also learned these after the fact):

    Cheers, Krisztian

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.