From 654f9d5b9516ae7a6776f154b4752d257872e17e Mon Sep 17 00:00:00 2001 From: Christof Schulze Date: Mon, 21 Oct 2019 17:19:45 +0200 Subject: [PATCH] fixed problem with paths (None != 'None') --- git.py | 26 +++++++++++++++----------- path.py | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/git.py b/git.py index 22360a0..11f4651 100644 --- a/git.py +++ b/git.py @@ -3,7 +3,7 @@ import os import time import yaml -from ammsml.utils.path import unfrackpath +from ammsml.utils.path import unfrackpath, resolve_path __all__ = ['gitinfo'] @@ -59,10 +59,10 @@ def gitinfo(path=None): # for use in ammsml basedir = os.path.join(os.path.dirname(__file__)) else: - basedir = unfrackpath(path) - - repo_path = os.path.join(basedir, '.git') - print("repo_path", repo_path) + basedir = path + # print('basedir', basedir) + repo_path = unfrackpath(os.path.join(basedir, '.git')) + # print("repo_path", repo_path) result = _git_repo_info(repo_path) submodules = os.path.join(basedir, '.gitmodules') @@ -90,12 +90,16 @@ if __name__ == '__main__': """ print('Testing Git\n===========') print('None', __file__) + print('path', __file__) print(gitinfo(), '\n---------') - testdir = unfrackpath(os.path.join(os.path.dirname(__file__), '..', 'config')) - print('path', testdir) - print(gitinfo(testdir), '\n---------') + testdir1 = resolve_path(os.path.join(os.path.dirname(__file__), '..', 'config')) + print('path', os.path.join(os.path.dirname(__file__), '..', 'config')) + print('path', testdir1) + print(gitinfo(testdir1), '\n---------') - testdir = unfrackpath(os.path.join(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'file_utils'))) - print('path', testdir) - print(gitinfo(testdir), '\n---------') + testdir2 = resolve_path(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'python', 'file_utils')) + print(os.path.dirname(__file__)) + print('path', os.path.join(os.path.dirname(__file__), '..', '..', '..', 'python', 'file_utils')) + print('path', testdir2) + print(gitinfo(testdir2), '\n---------') diff --git a/path.py b/path.py index defe961..dbd47ae 100644 --- a/path.py +++ b/path.py @@ -50,7 +50,7 @@ def unfrackpath(path, follow=True, basedir=None): """ b_basedir = to_text(basedir) - if b_basedir is None: + if b_basedir == 'None': b_basedir = to_text(os.getcwd()) elif os.path.isfile(b_basedir): b_basedir = os.path.dirname(b_basedir) -- GitLab