Skip to content

Commit

Permalink
Example change for AppOpener v1.6 (#8)
Browse files Browse the repository at this point in the history
* Example change for AppOpener v1.6

Update open_closest and close_closest attributes is now match_closest attribute in OPEN and CLOSE functions respectively v1.6

* Example change for AppOpener v1.6

Update open_closest and close_closest attributes is now match_closest attribute in OPEN and CLOSE functions respectively v1.6
  • Loading branch information
Guleri24 committed Jan 17, 2023
1 parent 9f66888 commit c413c2d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
14 changes: 8 additions & 6 deletions Examples/CLI-AUTOCOMPLETE.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from AppOpener import open, close, give_appnames
import readline


class MyCompleter(object):
def __init__(self, options):
self.options = sorted(options)

def complete(self, text, state):
if state == 0:
if text:
Expand All @@ -15,7 +17,8 @@ def complete(self, text, state):
except IndexError:
return None

tags = give_appnames() # FETCH ALL APPNAMES AS DICTIONARY

tags = give_appnames() # FETCH ALL APPNAMES AS DICTIONARY

completer = MyCompleter(tags)

Expand All @@ -30,9 +33,8 @@ def complete(self, text, state):
while True:
inp = input("ENTER APPNAME: ").strip()
if "open " in inp:
app_name = inp.replace("open ","")
open(app_name,output=False,match_closest=True)
app_name = inp.replace("open ", "")
open(app_name, output=False, match_closest=True)
if "close " in inp:
app_name = inp.replace("close ","")
close(app_name,output=False)

app_name = inp.replace("close ", "")
close(app_name, output=False)
5 changes: 4 additions & 1 deletion Examples/CLI-CLOSE.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Closing application via AppOpener
from AppOpener import close


def main():
while True:
inp = input("ENTER APP TO CLOSE: ")
close(inp, output=False, close_closest=True) # Output text will be not printed <output=False> & closest the most matching application
close(inp, output=False,
match_closest=True) # Output text will be not printed <output=False> & closest the most matching application


if __name__ == "__main__":
main()
11 changes: 7 additions & 4 deletions Examples/CLI.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from AppOpener import open, close


def main():
print()
print("1. Open <any_name> TO OPEN APPLICATIONS")
Expand All @@ -10,11 +11,13 @@ def main():
while True:
inp = input("ENTER APPLICATION TO OPEN / CLOSE: ").lower()
if "close " in inp:
app_name = inp.replace("close ","").strip()
close(app_name, close_closest=True, output=False) # App will be close be it matches little bit too (Without printing context (like CLOSING <app_name>))
app_name = inp.replace("close ", "").strip()
close(app_name, match_closest=True,
output=False) # App will be close be it matches little bit too (Without printing context (like CLOSING <app_name>))
if "open " in inp:
app_name = inp.replace("open ","")
open(app_name, match_closest=True) # App will be open be it matches little bit too
app_name = inp.replace("open ", "")
open(app_name, match_closest=True) # App will be open be it matches little bit too


if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pip install AppOpener
``` python
from AppOpener import open, close, mklist
open("telegram, whatsapp")
close("telgrm", close_closest=True) # Closes telegram as "telgrm" is closest to "telegram"
close("telgrm", match_closest=True) # Closes telegram as "telgrm" is closest to "telegram"
mklist(name="app_data.json")
```

Expand Down

0 comments on commit c413c2d

Please sign in to comment.