File: base_utils.py

package info (click to toggle)
python-pbcommand 2.1.1%2Bgit20231020.28d1635-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,016 kB
  • sloc: python: 7,676; makefile: 220; sh: 73
file content (36 lines) | stat: -rw-r--r-- 790 bytes parent folder | download | duplicates (4)
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
27
28
29
30
31
32
33
34
35
36
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)


def pb_requirements(*reqs):
    """
    Method decorator for specifying linked JIRA issues.
    """
    def decorator(test_item):
        test_item.__pb_requirements__ = list(reqs)
        return test_item
    return decorator