-
Notifications
You must be signed in to change notification settings - Fork 3
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 #41 from pepkit/dev
Release v0.8.0
- Loading branch information
Showing
7 changed files
with
35 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
coveralls>=1.1 | ||
pytest-cov==2.6.1 | ||
veracitools | ||
mock |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import os | ||
import pytest | ||
from ubiquerg import expandpath, parse_registry_path | ||
from ubiquerg import expandpath, parse_registry_path, mkabs | ||
|
||
__author__ = "Vince Reuter" | ||
__email__ = "[email protected]" | ||
|
@@ -106,3 +106,12 @@ def test_parse_reg(): | |
def test_registry_path(registry_path, output): | ||
pvars = parse_registry_path(registry_path) | ||
assert pvars == output | ||
|
||
|
||
def test_mkabs(): | ||
relpath = "abc.txt" | ||
abspath = mkabs(relpath) | ||
print(f"Abspath: {abspath}") | ||
assert abspath == os.path.join(os.getcwd(), relpath) | ||
url = "http://example.com" | ||
assert mkabs(url) == url |
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 +1 @@ | ||
__version__ = "0.7.0" | ||
__version__ = "0.8.0" |
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 |
---|---|---|
|
@@ -2,8 +2,11 @@ | |
|
||
import os | ||
import re | ||
|
||
from typing import List, Tuple, Any, Union | ||
|
||
from .web import is_url | ||
|
||
__author__ = "Vince Reuter" | ||
__email__ = "[email protected]" | ||
|
||
|
@@ -78,10 +81,10 @@ def parse_registry_path( | |
return parsed_identifier | ||
|
||
|
||
def mkabs(path, reldir=None): | ||
def mkabs(path: str, reldir: str = None) -> str: | ||
""" | ||
Makes sure a path is absolute; if not already absolute, it's made absolute | ||
relative to a given directory. Also expands ~ and environment variables for | ||
relative to a given directory (or file). Also expands ~ and environment variables for | ||
kicks. | ||
:param str path: Path to make absolute | ||
|
@@ -94,10 +97,19 @@ def mkabs(path, reldir=None): | |
def xpand(path): | ||
return os.path.expandvars(os.path.expanduser(path)) | ||
|
||
if path is None: | ||
return path | ||
|
||
if is_url(path): | ||
return path | ||
|
||
if os.path.isabs(xpand(path)): | ||
return xpand(path) | ||
|
||
if not reldir: | ||
return os.path.abspath(xpand(path)) | ||
|
||
return os.path.join(xpand(reldir), xpand(path)) | ||
if os.path.isdir(reldir): | ||
return os.path.join(xpand(reldir), xpand(path)) | ||
else: | ||
return os.path.join(xpand(os.path.dirname(reldir)), xpand(path)) |
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