9 examples of 'get parent directory python' in Python

Every line of 'get parent directory python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
33def parent_dir() -> str:
34 return _get_name_from_file("parent_dir")
151def get_parent(path):
152 return os.path.dirname(path)
102def DirectoryOfThisScript():
103 return os.path.dirname(os.path.abspath(__file__))
3def get_home_dir(file):
4 abspath = os.path.abspath(file)
5 parent, dir = None, None
6 if abspath.find('internal') != -1 or abspath.find('external') != -1:
7 parent, dir = os.path.split(os.path.dirname(os.path.dirname(os.path.abspath(file))))
8 else:
9 parent, dir = os.path.split(os.path.dirname(os.path.abspath(file)))
10 return parent
71def get_directory():
72 return os.path.abspath(os.path.join(os.getcwd(), 'python'))
5def get_script_dir(follow_symlinks=True):
6 if getattr(sys, 'frozen', False): # py2exe, PyInstaller, cx_Freeze
7 path = os.path.abspath(sys.executable)
8 else:
9 path = inspect.getabsfile(get_script_dir)
10 if follow_symlinks:
11 path = os.path.realpath(path)
12 return os.path.dirname(path)
29def get_model_python_path():
30 """
31 Returns the python path for a model
32 """
33 return os.path.dirname(__file__)
669def test_parent_directory_on_path_and_location_1(self):
670 test_dir = self.get_test_loc('fileutils/basename')
671 test_file = 'a/.a/file'
672 expected_name = 'a/.a/'
673 result = fileutils.parent_directory(test_file)
674 result = fileutils.as_posixpath(result)
675 assert expected_name == result
676
677 result = fileutils.parent_directory((os.path.join(test_dir, test_file)))
678 result = fileutils.as_posixpath(result)
679 assert result.endswith(expected_name)
206def get_original_dir():
207 return ORIGINAL_DIR

Related snippets