tee-ar-ex / trx-python

Python implementation of the TRX file format
https://tee-ar-ex.github.io/trx-python/
BSD 2-Clause "Simplified" License
22 stars 15 forks source link

Control tmpdir for files #44

Closed frheault closed 1 year ago

frheault commented 2 years ago

This PR is related to Issue #40

This requires PR #37 to be merged first, I needed the new module trx.io to exist to test some things.

Simply replaces all calls to tempfile.TemporaryDirectory by a new function below:

def get_trx_tmpdir():
    if os.getenv('TRX_TMPDIR') is not None:
        if os.getenv('TRX_TMPDIR') == 'use_working_dir':
            trx_tmp_dir = os.getcwd()
        else:
            trx_tmp_dir = os.getenv('TRX_TMPDIR')
    else:
        trx_tmp_dir = tempfile.gettempdir()

    return tempfile.TemporaryDirectory(dir=trx_tmp_dir, prefix='trx_')

3 options:

  1. Same behavior (to /tmp)
  2. Specify a new folder
  3. Use the working directory

I will add a check if the folder does not exist. But should I create it myself?

frheault commented 2 years ago

@anibalsolon What do you think?

anibalsolon commented 1 year ago

@frheault looks good- I'll follow the implementation on C++

arokem commented 1 year ago

When you get a chance, could you please rebase after the #37 merge?

arokem commented 1 year ago

LGTM. Still WIP?

frheault commented 1 year ago

It would need to be tested on a Mac, I am not sure how it behaves. I will ask Maxime D. to borrow one next week

arokem commented 1 year ago

Oh - I have a mac. Let me run the test suite and let you know.

arokem commented 1 year ago

Tests pass on a mac. Good to go?

arokem commented 1 year ago

Actually, could you please rebase on your end first? I tried to do this locally and see there are a couple of conflicts that would need resolution.