-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from bbglab/dev/21-add-env-variable-for-plugins
Add environment variable `OPENVAR_PLUGIN`
- Loading branch information
Showing
6 changed files
with
30 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
import re | ||
import os | ||
from appdirs import user_data_dir | ||
from fnmatch import fnmatch | ||
from os.path import basename | ||
|
||
|
||
ENV_VAR = { | ||
'OPENVAR_PLUGIN': user_data_dir('openvariant', 'bbglab') | ||
} | ||
|
||
def loadEnvironmentVariables() -> None: | ||
"""Load environment variable into the environment.""" | ||
|
||
missing_vars = set(ENV_VAR.keys()).difference(set(os.environ)) | ||
|
||
for env_var in missing_vars: | ||
os.environ[env_var] = ENV_VAR[env_var] | ||
os.makedirs(ENV_VAR[env_var], exist_ok=True) | ||
|
||
return | ||
|
||
def check_extension(ext: str, path: str) -> bool: | ||
"""Check if file matches with the annotation pattern""" | ||
return fnmatch(basename(path), ext) if ext[0] == '*' else re.match(ext, basename(path)) is not None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from openvariant.utils.utils import loadEnvironmentVariables | ||
|
||
loadEnvironmentVariables() |