Last active
February 15, 2024 16:16
-
-
Save skimtiyaz/66befb07892b9e879028014744bae93c to your computer and use it in GitHub Desktop.
Revisions
-
skimtiyaz revised this gist
Feb 15, 2024 . No changes.There are no files selected for viewing
-
skimtiyaz created this gist
Feb 15, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,92 @@ [app] # (str) Title of your application title = Phrase searcher # (str) Package name package.name = phrasesearcher # (str) Package domain (needed for android/ios packaging) package.domain = org.kivymd # (str) Source code where the main.py live source.dir = . # (list) Source files to include (let empty to include all the files) source.include_exts = py,png,jpg,jpeg,ttf,kv # (list) List of inclusions using pattern matching source.include_patterns = assets/* # (str) Application versioning (method 2) version.regex = __version__ = ['"](.*)['"] version.filename = %(source.dir)s/../../kivymd/__init__.py android.numeric_version = 1 # (list) Application requirements # comma separated e.g. requirements = sqlite3,kivy requirements = python3,kivy==2.0.0,https://github.com/kivymd/KivyMD/archive/master.zip,sdl2_ttf==2.0.15 # (str) Custom source folders for requirements # Sets custom source for any requirements with recipes requirements.source.kivymd = ../../kivymd # (str) Presplash of the application presplash.filename = %(source.dir)s/assets/images/presplash.png # (str) Icon of the application icon.filename = %(source.dir)s/assets/images/search_icon.png # (str) Supported orientation (one of landscape, sensorLandscape, portrait or all) orientation = portrait # (bool) Indicate if the application should be fullscreen or not fullscreen = 0 # (string) Presplash background color (for new android toolchain) android.presplash_color = #ebcfe1 # (list) Permissions #android.permissions = INTERNET # (int) Target Android API, should be as high as possible. android.api = 28 # (int) Minimum API your APK will support. android.minapi = 21 # (str) Android NDK version to use android.ndk = 19b # (bool) If True, then skip trying to update the Android sdk # This can be useful to avoid excess Internet downloads or save time # when an update is due and you just want to test/build your package android.skip_update = False # (bool) If True, then automatically accept SDK license # agreements. This is intended for automation only. If set to False, # the default, you will be shown the license when first running # buildozer. android.accept_sdk_license = True # (str) Android logcat filters to use # android.logcat_filters = *:S python:D # (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64 android.arch = armeabi-v7a [buildozer] # (int) Log level (0 = error only, 1 = info, 2 = debug (with command output)) log_level = 2 # (int) Display warning if buildozer is run as root (0 = False, 1 = True) warn_on_root = 0 # (str) Path to build artifact storage, absolute or relative to spec file build_dir = /home/alex/.buildozer # (str) Path to build output (i.e. .apk, .ipa) storage bin_dir = ./bin This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,90 @@ import timeit from kivy.lang import Builder from kivy.uix.boxlayout import BoxLayout from kivy.properties import ObjectProperty from kivy.core.window import Window from kivymd.app import MDApp from ggnumber import PHRASE_FOR_SEARCH, SAMPLE_TEXT_FOR_BENCH, count_occurences_in_text from kivymd.toast import toast from kivymd.uix.filemanager import MDFileManager class ContentNavigationDrawer(BoxLayout): screen_manager = ObjectProperty() nav_drawer = ObjectProperty() class SearchTextNavigationDrawer(MDApp): def __init__(self, **kwargs): super().__init__(**kwargs) self.screen = Builder.load_file('main.kv') # Window.bind(on_keyboard=self.events) # self.manager_open = False # self.file_manager = MDFileManager( # exit_manager=self.exit_manager, # select_path=self.select_path, # previous=True, # ) def build(self): # return Builder.load_string(KV) # return Builder.load_file() # self.screen.ids.onSearch.on_release = self.on_search # self.screen.ids.file_manager.on_release = self.file_manager_open # load defaulting text into MDTextField with id var1 self.screen.ids.var1.text = SAMPLE_TEXT_FOR_BENCH # load defaulting searching phrase into MDTextField with id var2 self.screen.ids.var2.text = PHRASE_FOR_SEARCH # self.screen.ids.text_field_error.bind( # on_text_validate=self.set_error_message, # on_focus=self.set_error_message, # ) return self.screen def on_search(self): # var1 = self.screen.ids.var1.text var1 = self.screen.ids.var1.text var2 = self.screen.ids.var2.text execution_time = timeit.default_timer() # in nanoseconds ncount = count_occurences_in_text(var2, var1) execution_time = timeit.default_timer() - execution_time self.screen.ids.out.text = f"There is(are) {ncount} occurence(s). Execution time = {execution_time*1e6:.2f} ms"; # def file_manager_open(self): # self.file_manager.show('/') # output manager to the screen # self.manager_open = True # # def select_path(self, path): # '''It will be called when you click on the file name # or the catalog selection button. # # :type path: str; # :param path: path to the selected directory or file; # ''' # # self.exit_manager() # toast(path) # # def exit_manager(self, *args): # '''Called when the user reaches the root of the directory tree.''' # # self.manager_open = False # self.file_manager.close() # # def events(self, instance, keyboard, keycode, text, modifiers): # '''Called when buttons are pressed on the mobile device.''' # # if keyboard in (1001, 27): # if self.manager_open: # self.file_manager.back() # return True SearchTextNavigationDrawer().run() This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,90 @@ import timeit from kivy.lang import Builder from kivy.uix.boxlayout import BoxLayout from kivy.properties import ObjectProperty from kivy.core.window import Window from kivymd.app import MDApp from ggnumber import PHRASE_FOR_SEARCH, SAMPLE_TEXT_FOR_BENCH, count_occurences_in_text from kivymd.toast import toast from kivymd.uix.filemanager import MDFileManager class ContentNavigationDrawer(BoxLayout): screen_manager = ObjectProperty() nav_drawer = ObjectProperty() class SearchTextNavigationDrawer(MDApp): def __init__(self, **kwargs): super().__init__(**kwargs) self.screen = Builder.load_file('main.kv') # Window.bind(on_keyboard=self.events) # self.manager_open = False # self.file_manager = MDFileManager( # exit_manager=self.exit_manager, # select_path=self.select_path, # previous=True, # ) def build(self): # return Builder.load_string(KV) # return Builder.load_file() # self.screen.ids.onSearch.on_release = self.on_search # self.screen.ids.file_manager.on_release = self.file_manager_open # load defaulting text into MDTextField with id var1 self.screen.ids.var1.text = SAMPLE_TEXT_FOR_BENCH # load defaulting searching phrase into MDTextField with id var2 self.screen.ids.var2.text = PHRASE_FOR_SEARCH # self.screen.ids.text_field_error.bind( # on_text_validate=self.set_error_message, # on_focus=self.set_error_message, # ) return self.screen def on_search(self): # var1 = self.screen.ids.var1.text var1 = self.screen.ids.var1.text var2 = self.screen.ids.var2.text execution_time = timeit.default_timer() # in nanoseconds ncount = count_occurences_in_text(var2, var1) execution_time = timeit.default_timer() - execution_time self.screen.ids.out.text = f"There is(are) {ncount} occurence(s). Execution time = {execution_time*1e6:.2f} ms"; # def file_manager_open(self): # self.file_manager.show('/') # output manager to the screen # self.manager_open = True # # def select_path(self, path): # '''It will be called when you click on the file name # or the catalog selection button. # # :type path: str; # :param path: path to the selected directory or file; # ''' # # self.exit_manager() # toast(path) # # def exit_manager(self, *args): # '''Called when the user reaches the root of the directory tree.''' # # self.manager_open = False # self.file_manager.close() # # def events(self, instance, keyboard, keycode, text, modifiers): # '''Called when buttons are pressed on the mobile device.''' # # if keyboard in (1001, 27): # if self.manager_open: # self.file_manager.back() # return True SearchTextNavigationDrawer().run() This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,90 @@ import timeit from kivy.lang import Builder from kivy.uix.boxlayout import BoxLayout from kivy.properties import ObjectProperty from kivy.core.window import Window from kivymd.app import MDApp from ggnumber import PHRASE_FOR_SEARCH, SAMPLE_TEXT_FOR_BENCH, count_occurences_in_text from kivymd.toast import toast from kivymd.uix.filemanager import MDFileManager class ContentNavigationDrawer(BoxLayout): screen_manager = ObjectProperty() nav_drawer = ObjectProperty() class SearchTextNavigationDrawer(MDApp): def __init__(self, **kwargs): super().__init__(**kwargs) self.screen = Builder.load_file('main.kv') # Window.bind(on_keyboard=self.events) # self.manager_open = False # self.file_manager = MDFileManager( # exit_manager=self.exit_manager, # select_path=self.select_path, # previous=True, # ) def build(self): # return Builder.load_string(KV) # return Builder.load_file() # self.screen.ids.onSearch.on_release = self.on_search # self.screen.ids.file_manager.on_release = self.file_manager_open # load defaulting text into MDTextField with id var1 self.screen.ids.var1.text = SAMPLE_TEXT_FOR_BENCH # load defaulting searching phrase into MDTextField with id var2 self.screen.ids.var2.text = PHRASE_FOR_SEARCH # self.screen.ids.text_field_error.bind( # on_text_validate=self.set_error_message, # on_focus=self.set_error_message, # ) return self.screen def on_search(self): # var1 = self.screen.ids.var1.text var1 = self.screen.ids.var1.text var2 = self.screen.ids.var2.text execution_time = timeit.default_timer() # in nanoseconds ncount = count_occurences_in_text(var2, var1) execution_time = timeit.default_timer() - execution_time self.screen.ids.out.text = f"There is(are) {ncount} occurence(s). Execution time = {execution_time*1e6:.2f} ms"; # def file_manager_open(self): # self.file_manager.show('/') # output manager to the screen # self.manager_open = True # # def select_path(self, path): # '''It will be called when you click on the file name # or the catalog selection button. # # :type path: str; # :param path: path to the selected directory or file; # ''' # # self.exit_manager() # toast(path) # # def exit_manager(self, *args): # '''Called when the user reaches the root of the directory tree.''' # # self.manager_open = False # self.file_manager.close() # # def events(self, instance, keyboard, keycode, text, modifiers): # '''Called when buttons are pressed on the mobile device.''' # # if keyboard in (1001, 27): # if self.manager_open: # self.file_manager.back() # return True SearchTextNavigationDrawer().run()