File: base_utils.py

package info (click to toggle)
python-pbcommand 0.2.17-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 556 kB
  • sloc: python: 3,451; makefile: 200
file content (26 lines) | stat: -rwxr-xr-x 561 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
import tempfile

HAS_PBCORE = False

try:
    import pbcore
    HAS_PBCORE = True
except ImportError:
    HAS_PBCORE = False


def pbcore_skip_msg(msg=None):
    msg = "" if msg is None else msg
    return "" if HAS_PBCORE else "pbcore is not installed. {m}".format(m=msg)


def get_temp_file(suffix, dir_):
    t = tempfile.NamedTemporaryFile(suffix=suffix, delete=False, dir=dir_)
    t.close()
    return t.name


def get_temp_dir(suffix=""):
    """This will make subdir in the root tmp dir"""
    return tempfile.mkdtemp(dir=None, suffix=suffix)