get_venv_basedir()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0185

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 5
cts 6
cp 0.8333
rs 9.4285
cc 2
crap 2.0185
1 1
import os
2 1
from distutils.sysconfig import get_config_vars
3
4
5 1
def get_venv_basedir():
6
    """Returns the base directory of the virtualenv, useful to read configuration and plugins"""
7
8 1
    try:
9 1
        import virtualenv
0 ignored issues
show
Unused Code introduced by
The variable virtualenv seems to be unused.
Loading history...
10
        raise EnvironmentError("You must be in a virtual environment")
11 1
    except Exception:
12
        return os.path.abspath(get_config_vars()['exec_prefix'] + '/../')
13