Added Filpath autocompletion so that it is easier to enter a filepath!
This commit is contained in:
75
bin/autocomplete.py
Normal file
75
bin/autocomplete.py
Normal file
@@ -0,0 +1,75 @@
|
||||
import bin.csv_parsers
|
||||
import os
|
||||
|
||||
cvr = bin.csv_parsers.CsvRead()
|
||||
|
||||
|
||||
class AutoComplete:
|
||||
def __init__(self):
|
||||
self.__length_command_completion = 0
|
||||
self.__command_list = []
|
||||
self.__possible_completion = []
|
||||
self.item = ""
|
||||
self.items = ""
|
||||
self.__return_value = []
|
||||
self.__return_value_assembly = ""
|
||||
self.__command_count = 0
|
||||
self.text = ""
|
||||
self.path = ""
|
||||
self.check = ""
|
||||
self.check_in = ""
|
||||
|
||||
def autocomplete(self, text):
|
||||
self.text = str(text)
|
||||
print(self.text, "TEXT")
|
||||
if self.text[len(self.text) - 2:] == "\t\n":
|
||||
self.text = self.text[:len(self.text) - 2]
|
||||
elif self.text[len(self.text) - 1:] == "\t":
|
||||
self.text = self.text[:len(self.text) - 1]
|
||||
print(self.text, "T2")
|
||||
if self.text == "":
|
||||
self.text = "/"
|
||||
self.path = "/"
|
||||
elif self.text[len(self.text) - 1:] == "/":
|
||||
self.path = self.text
|
||||
else:
|
||||
self.path = self.text[:len(self.text) - 1]
|
||||
while self.path[len(self.path) - 1:] != "/":
|
||||
self.path = self.path[:len(self.path) - 1]
|
||||
print(self.path, "PATH")
|
||||
self.__command_list = os.listdir(self.path)
|
||||
print(self.__command_list)
|
||||
self.__return_value = []
|
||||
self.__return_value_assembly = ""
|
||||
self.__possible_completion = []
|
||||
self.__command_count = 0
|
||||
self.check = ""
|
||||
self.check_in = self.text
|
||||
print("refactoring")
|
||||
while self.check_in[len(self.check_in) - 1:] != "/":
|
||||
self.check += str(self.check_in[len(self.check_in) - 1:])
|
||||
self.check_in = self.check_in[:len(self.check_in) - 1]
|
||||
self.check = self.check[::-1]
|
||||
print(self.check, "CHECK")
|
||||
for self.item in self.__command_list:
|
||||
print(self.check, self.item[:len(self.check)])
|
||||
if self.check == self.item[:len(self.check)]:
|
||||
self.__possible_completion.append(f'{self.path}{self.item}/')
|
||||
else:
|
||||
pass
|
||||
print(self.__possible_completion)
|
||||
if len(self.__possible_completion) < 1:
|
||||
self.__return_value = ["No such file or directory", self.text[:len(self.text)]]
|
||||
elif len(self.__possible_completion) == 1:
|
||||
self.__return_value = ["", str(self.__possible_completion.pop(0))]
|
||||
else:
|
||||
for self.items in self.__possible_completion:
|
||||
self.__return_value_assembly += f"{str(self.items)} "
|
||||
if self.__command_count > 2:
|
||||
self.__return_value_assembly += "\n"
|
||||
self.__command_count = 0
|
||||
else:
|
||||
self.__command_count += 1
|
||||
self.__return_value.append(self.__return_value_assembly)
|
||||
self.__return_value.append(self.text[:len(self.text)])
|
||||
return self.__return_value
|
||||
@@ -87,7 +87,14 @@ RootScreen:
|
||||
hint_text: "Path to Folder containing the Music files"
|
||||
pos_hint: {"x":0.2, "y":0.5}
|
||||
size_hint_x: 0.6
|
||||
text: "/home/janis/Downloads/KB"
|
||||
text: ""
|
||||
on_text: root.autocomplete()
|
||||
Label:
|
||||
text: ""
|
||||
pos_hint: {"x": 0.2, "y":1}
|
||||
size_hint: 0.6, 0.3
|
||||
text_size: self.size
|
||||
id: cmd_output
|
||||
Button:
|
||||
text: "Start"
|
||||
color: app.theme_cls.primary_color
|
||||
|
||||
@@ -1 +1 @@
|
||||
0,songlist.csv
|
||||
1,songlist.csv
|
||||
|
||||
|
@@ -1,3 +1,3 @@
|
||||
2
|
||||
Tennessee Waltz - New 101 Strings Orchestra | Slow Walz (Langsam),Morning has broken - Cat Stevens | Walzer (Mittel),Magia - Alvaro Soler | Flashmob (Mittel),Say So - Doja Cat | Discofox (Langsam),Save Your Tears (Remix) - The Weeknd & Ariana Grande | Discofox (Langsam),Shivers - Ed Sheeran | Jive/ Rocknroll (Mittel),I feel good - Ray Charles | Jive/Rocknroll (Mittel),Muevelo - Rey Ruiz | Cha cha cha (Mittel),Suelta la cintura - Ruben leon | Cha cha cha (Mittel),Como Volver a Ser Feliz - Luis Enrique | Salsa (Mittel),Mas que nada - black eyed peas | Salsa/Discofox (Mittel),Moon River - Henry Mancini | Slow Walz (Langsam),Dancing Queen - ABBA | Discofox (Langsam),Don't Call Me Up - Mabel | Discofox (Mittel),Magia - Alvaro Soler | Flashmob (Mittel),Lets have a Party - Wanda Jackson | Jive (mittel),Crazy Little Thing Called Love - Queen | Jive / Rocknroll (Schnell),El Diablo Anda Suelto - Rey Ruiz | Cha cha cha (Mittel),Lets get loud - Jennifer Lopez | Cha cha cha (Schnell),Enamorame - Somos del Barrio | Salsa (Mittel),Something Stupid (feat. Reese Witherspoon) - Michael Bublé | Rumba/cha cha cha (Langsam),When a man loves a woman - Percy Sledge | (Langsam),Scharlachrot - Patent Ochsner | Walzer (Langsam),Ily (i love you baby) [feat. Emilee] - Surf Mesa | Discofox (Mittel),Like a sex machine - James Brown | Discofox (Mittel),Uptown Funk (feat. Bruno Mars) - Discofox | Discofox (Schnell),Tutti Frutti - Little Richard | Jive / Rocknroll (Mittel),Jailhouse Rock - Elvis Presley | Jive / Rocknroll (Schnell),Are you lonesome - Elvis Presley | Slow Walz (Langsam),Ay Mujer - Rey Ruiz | Cha cha cha (Mittel),Rico Vacilon - Pedro Garcia & His Del Prado Orchestra | Cha cha cha (Mittel),Jeepers creepers - Benny Goodmann | Foxtrott (Mittel),An der schönen blauen Donau - New 101 Strings Orchestra | Wiener Walzer (Schnell),The Last Waltz - Engelbert Humperdinck | Walzer (Mittel),Stand by me - Sam Brown | Cha cha cha (Lansam),Stayin' Alive - Bee Gees | Discofox (Mittel),Easy On Me - Adele | (Langsam),Magia - Alvaro Soler | Flashmob (Mittel),Friday (feat. Mufasa & Hypeman) [Dopamine Re-Edit] - Riton & Nightcrawlers | Party (Mittel),YMCA - Village People | Party (Mittel),Cotton eyed Joe (Hennustall zermatt mix) - Rednex | Party (Mittel),Gangnam style - PSY | Party (Mittel),Take On Me - a-ha | Jive (Schnell),Rock Around the Clock - Bill Haley & His Comets | Jive / Rocknroll (Schnell),Satisfaction - Rolling Stones | Party (Mittel),"Un, dos, tres - Ricky Martin | Party (Mittel)",Party Rock anthem - LFMBQ | Party (Mittel),I don't care - Icona Pop | Party (Mittel),Love tonight - Shouse & David Guetta | Party (Mittel),Insomnia - Faithless | Party (Mittel),Angels - Robbie Williams | Slow (Langsam),Nothing compares to you - Sinead O'Connor | Slow (Langsam)
|
||||
191.33242797851562
|
||||
1
|
||||
Ancient.mp3,Arm_Candy.mp3,Beach_Disco.mp3,Beach_Walk.mp3,Bird_Therapist.mp3,Carol_of_the_Bells.mp3,Castlevania.mp3,Cats_Searching_for_the_Truth.mp3,Classique.mp3,Cloud_Chaser.mp3,Dragonfly.mp3,Easy_Seas.mp3,Entire.mp3,Eyes_of_Glory.mp3,Finding_Me.mp3,Forgiveness.mp3,Fun_in_the_Sun.mp3,Half_Measures.mp3,Happy_Sixth.mp3,Hear_the_Noise.mp3,Hi_Q.mp3,Hot_Coffee.mp3,How_it_Began.mp3,I_ll_Follow_You.mp3,If_I_Had_a_Chicken.mp3,Jal_Edge_of_Water.mp3,Juno_In_The_Space_Maze.mp3,Ladybug.mp3,Late_Night_Drive.mp3,Meteor.mp3,Modern_Situations.mp3,Move_Out.mp3,Official_National_Anthem.mp3,Plenty_Step.mp3,Point_Green_Getdown.mp3,Retrograde.mp3,Right_Here_Beside_You.mp3,Safety_Net.mp3,Same_Time.mp3,Static.mp3,Stranger_Danger.mp3,Subharmonic_Bliss.mp3,Sun_Machine_One.mp3,The_Computer_Has_Feelings.mp3,Thinking_Of_Us.mp3,This_is_Not_IDM.mp3,This_is_Not_Jazz.mp3,This_is_Not_a_Ballad.mp3,Time_s_Up.mp3,Triumph.mp3,Unstoppable.mp3,Western_Spaghetti.mp3,Zameen_Movement_of_Earth.mp3,bensound-clearday.mp3,bensound-endlessmotion.mp3,bensound-energy.mp3,bensound-happyrock.mp3
|
||||
176.2394561767578
|
||||
|
||||
|
@@ -1 +1 @@
|
||||
/home/janis/Downloads/KB
|
||||
/mnt/DATA/Music/Videos/Songs/
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import multiprocessing
|
||||
import os
|
||||
import signal
|
||||
os.environ["KIVY_NO_CONSOLELOG"] = "1"
|
||||
# os.environ["KIVY_NO_CONSOLELOG"] = "1"
|
||||
from kivy.core.window import Window, Config
|
||||
from kivy.uix.screenmanager import ScreenManager
|
||||
from kivymd.uix.screen import MDScreen
|
||||
@@ -13,12 +13,14 @@ import bin.csv_parsers
|
||||
import bin.filepathanalysis
|
||||
import bin.player
|
||||
import math
|
||||
import bin.autocomplete
|
||||
|
||||
|
||||
pl = bin.player.Player()
|
||||
pa = bin.filepathanalysis.PathAnalysis()
|
||||
cvr = bin.csv_parsers.CsvRead()
|
||||
cvw = bin.csv_parsers.CsvWrite()
|
||||
ac = bin.autocomplete.AutoComplete()
|
||||
|
||||
|
||||
###########
|
||||
@@ -82,6 +84,17 @@ class Home(MDScreen):
|
||||
self.ivppu = invalidpathPU()
|
||||
self.ivppu.open()
|
||||
|
||||
def autocomplete(self):
|
||||
self.text = self.ids.filepath.text
|
||||
self.input = self.text[len(self.text) - 1:]
|
||||
if self.input == "\t":
|
||||
self.__ac = ac.autocomplete(self.text)
|
||||
self.ids.cmd_output.text = self.__ac.pop(0)
|
||||
self.ids.filepath.text = self.__ac.pop(0)
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class Main(MDScreen):
|
||||
def __init__(self, **kwargs):
|
||||
@@ -89,8 +102,6 @@ class Main(MDScreen):
|
||||
self.instructions = multiprocessing.Value('i', 0)
|
||||
self.others = multiprocessing.Value('i', 0)
|
||||
self.backfeed = multiprocessing.Value('f', 0)
|
||||
self.keyboard = Window.request_keyboard(None, self)
|
||||
self.keyboard.bind(on_key_down=self.key_pressed)
|
||||
self.quit_requests = 0
|
||||
|
||||
def key_pressed(self, keyboard, keycode, text, modifiers):
|
||||
|
||||
Reference in New Issue
Block a user