use os.path.commonprefix instead of custom function

This commit is contained in:
Ian Jauslin 2021-10-16 13:35:01 -04:00
parent e0f52a4b02
commit 2d9e816980
2 changed files with 1 additions and 16 deletions

View File

@ -4,8 +4,6 @@ from kivy.graphics import Color,Rectangle
import glob import glob
import os.path import os.path
from tools import common_substr
class Command_prompt(Label): class Command_prompt(Label):
def __init__(self,app,**kwargs): def __init__(self,app,**kwargs):
@ -272,4 +270,4 @@ class Command_prompt(Label):
name="\""+name+"\"" name="\""+name+"\""
self.app.status_bar.raw_text+=name+" " self.app.status_bar.raw_text+=name+" "
self.app.status_bar.draw() self.app.status_bar.draw()
return common_substr(paths)[end:] return os.path.commonprefix(paths)[end:]

View File

@ -9,16 +9,3 @@ def isint_nonzero(x):
if abs(x)<1e-11: if abs(x)<1e-11:
return False return False
return abs(round(x)-x)<1e-11 return abs(round(x)-x)<1e-11
# find the common substring in a list of strings
def common_substr(strings):
out=""
if len(strings)==0:
return out
for i in range(len(strings[0])):
for j in range(1,len(strings)):
if strings[j][i]!=strings[0][i]:
return out
out+=strings[0][i]
return out