From 2d9e816980c264282187d2925636c7df5aabd1de Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Sat, 16 Oct 2021 13:35:01 -0400 Subject: [PATCH] use os.path.commonprefix instead of custom function --- command_prompt.py | 4 +--- tools.py | 13 ------------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/command_prompt.py b/command_prompt.py index f935a8c..23342dc 100644 --- a/command_prompt.py +++ b/command_prompt.py @@ -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:] diff --git a/tools.py b/tools.py index 06e36a0..a9ef4e9 100644 --- a/tools.py +++ b/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