use os.path.commonprefix instead of custom function
This commit is contained in:
parent
e0f52a4b02
commit
2d9e816980
@ -4,8 +4,6 @@ from kivy.graphics import Color,Rectangle
|
||||
import glob
|
||||
import os.path
|
||||
|
||||
from tools import common_substr
|
||||
|
||||
class Command_prompt(Label):
|
||||
|
||||
def __init__(self,app,**kwargs):
|
||||
@ -272,4 +270,4 @@ class Command_prompt(Label):
|
||||
name="\""+name+"\""
|
||||
self.app.status_bar.raw_text+=name+" "
|
||||
self.app.status_bar.draw()
|
||||
return common_substr(paths)[end:]
|
||||
return os.path.commonprefix(paths)[end:]
|
||||
|
13
tools.py
13
tools.py
@ -9,16 +9,3 @@ def isint_nonzero(x):
|
||||
if abs(x)<1e-11:
|
||||
return False
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user