Skip to content

Commit b7adba9

Browse files
author
eliad hershkovitz
committed
Get root dir with os.path.normpath instead of dedicated function
1 parent 1ceb5d5 commit b7adba9

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

backslash/contrib/slash_plugin.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
from ..exceptions import ParamsTooLarge
3333
from ..utils import ensure_dir
3434
from .keepalive_thread import KeepaliveThread
35-
from .utils import normalize_file_path, distill_slash_traceback, distill_object_attributes, \
36-
add_environment_variable_metadata, _ROOT_DIR
35+
from .utils import normalize_file_path, distill_slash_traceback, distill_object_attributes, add_environment_variable_metadata
3736
from ..lazy_query import LazyQuery
3837
from ..session import APPEND_UPCOMING_TESTS_STR
3938
from ..__version__ import __version__ as BACKSLASH_CLIENT_VERSION
@@ -399,7 +398,7 @@ def _calculate_file_hash(self, filename):
399398
def _get_git_repo(self, dirname):
400399
if not os.path.isabs(dirname):
401400
dirname = os.path.abspath(os.path.join(_PWD, dirname))
402-
while dirname != _ROOT_DIR:
401+
while dirname != os.path.normpath(os.path.abspath(os.path.sep)):
403402
if os.path.isdir(os.path.join(dirname, '.git')):
404403
return git.Repo(dirname)
405404
dirname = os.path.normpath(os.path.abspath(os.path.join(dirname, '..')))

backslash/contrib/utils.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import linecache
33
import os
44
import types
5-
import platform
65

76
from .._compat import PY2
87

@@ -30,25 +29,14 @@
3029
_MAX_VARIABLE_VALUE_LENGTH = 100
3130

3231

33-
def _get_root_dir():
34-
if platform.system() == 'Windows':
35-
root_dir, _ = os.path.splitdrive(os.getcwd())
36-
return os.path.join(root_dir, '\\')
37-
38-
return '/'
39-
40-
41-
_ROOT_DIR = _get_root_dir()
42-
43-
4432
def normalize_file_path(path):
4533
path = str(path)
4634
if path.endswith('.pyc'):
4735
path = path[:-1]
4836
if not os.path.isabs(path):
4937
path = os.path.abspath(os.path.join(_HERE, path))
5038
dirname = os.path.normpath(path)
51-
while dirname != _ROOT_DIR:
39+
while dirname != os.path.normpath(os.path.abspath(os.path.sep)):
5240
for special_dir in _SPECIAL_DIRS:
5341
if os.path.isdir(os.path.join(dirname, special_dir)):
5442
return os.path.normpath(os.path.relpath(path, dirname))

0 commit comments

Comments
 (0)