Every line of 'python basename without extension' 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.
41 def get_filename(path, with_ext=True): 42 """Returns file name from given file, with or without extension. 43 It finds last "os.sep" inside string and returns tail. 44 :param path: path with file name 45 :type path: str 46 :param with_ext: return file name with extension or not 47 :type with_ext: bool 48 :return: file name with or without extension 49 :rtype: str 50 """ 51 52 # find last separator; prefer os.sep otherwise search for normal slash 53 last_sep = path.rfind(os.sep) 54 if last_sep < 0: 55 last_sep = path.rfind("/") 56 57 new_path = path[last_sep + 1:] 58 if not with_ext and new_path.rfind(".") > 0: 59 new_path = new_path[:new_path.rfind(".")] 60 return new_path
21 def getBasename(filename): 22 name = os.path.split(filename)[-1] 23 for extension in EXTENSIONS_NXS: 24 name = name.replace(extension, '') 25 return name
18 def filenameWithoutExtension(file_name): 19 if '.' in file_name: 20 separator_index = file_name.rindex('.') 21 base_name = file_name[:separator_index] 22 return base_name 23 else: 24 return file_name
417 def basename(self, path): 418 """ Return the filename part of the given `path`. """ 419 if path == ROOT: 420 return '' 421 path = self.normalize(path) 422 return path.rsplit(PATH_SEPARATOR, 1)[1]
12 def basename(pathname): 13 return pathname.basename(pathname)
44 def basename(p): 45 return os.path.splitext(p)[0]
18 def get_filename(filename: str) -> str: 19 return ntpath.basename(filename).split('.')[0]
34 def basename(s): 35 if '.tml' in s: 36 s = os.path.basename(s[0:s.index(".tml")]) 37 if 'TE3input' in s: 38 s = os.path.basename(s[0:s.index(".TE3input")]) 39 return s
27 @overload 28 def basename(path: bytes) -> bytes: pass
212 def get_name_from_path(path: str) -> str: 213 """ 214 Get name from path to the file 215 :param path: path to the file 216 :return: name of the file 217 """ 218 return os.path.splitext(os.path.basename(path))[0]