diff --git a/Logement-Isep/main.py b/Logement-Isep/main.py new file mode 100644 index 0000000..2583275 --- /dev/null +++ b/Logement-Isep/main.py @@ -0,0 +1,3 @@ +from selenium import webdriver + +webdriver('Chrome') diff --git a/Tests/test-menu-2.py b/Tests/test-menu-2.py new file mode 100644 index 0000000..e92ac88 --- /dev/null +++ b/Tests/test-menu-2.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 + +import os +from simple_term_menu import TerminalMenu + + +def list_files(directory="."): + return (file for file in os.listdir(directory) if os.path.isfile(os.path.join(directory, file))) + + +def main(): + terminal_menu = TerminalMenu(list_files(), preview_command="cat {}", preview_size=0.75) + terminal_menu.show() + + +if __name__ == "__main__": + main() diff --git a/Tests/test-menu-3.py b/Tests/test-menu-3.py new file mode 100644 index 0000000..0f95f29 --- /dev/null +++ b/Tests/test-menu-3.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import os +from pygments import formatters, highlight, lexers +from pygments.util import ClassNotFound +from simple_term_menu import TerminalMenu + + +def highlight_file(filepath): + with open(filepath, "r") as f: + file_content = f.read() + try: + lexer = lexers.get_lexer_for_filename(filepath, stripnl=False, stripall=False) + except ClassNotFound: + lexer = lexers.get_lexer_by_name("text", stripnl=False, stripall=False) + formatter = formatters.TerminalFormatter(bg="dark") # dark or light + highlighted_file_content = highlight(file_content, lexer, formatter) + return highlighted_file_content + + +def list_files(directory="."): + return (file for file in os.listdir(directory) if os.path.isfile(os.path.join(directory, file))) + + +def main(): + terminal_menu = TerminalMenu(list_files(), preview_command=highlight_file, preview_size=0.75) + terminal_menu.show() + + +if __name__ == "__main__": + main() diff --git a/Tests/test-menu.py b/Tests/test-menu.py new file mode 100644 index 0000000..40ba335 --- /dev/null +++ b/Tests/test-menu.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +from simple_term_menu import TerminalMenu + + +def main(): + terminal_menu = TerminalMenu(["entry 1", "entry 2", "entry 3"]) + terminal_menu.show() + + +if __name__ == "__main__": + main() diff --git a/logement-isep.py b/logement-isep.py new file mode 100644 index 0000000..2e60dc0 --- /dev/null +++ b/logement-isep.py @@ -0,0 +1,25 @@ +"""Find locations in issy-les-moulineaux and keep me informed of new offers.""" + +import os + +from selenium import webdriver + +URL = "https://logement.isep.fr/" +URL_SORTED_BY_CHEAPEST = "https://logement.isep.fr/listelogement.php?tri=n|loyer" + +driver = webdriver.Chrome() +driver.get(URL) + +id_value, password_value = os.environ['ISEP_ID'], os.environ['ISEP_PASSWORD'] +id_field, password_field, submit_field = driver.find_elements_by_tag_name('input') + +id_field.click() +id_field.send_keys(id_value) + +password_field.click() +password_field.send_keys(password_value) + +submit_field.click() + + +driver.get(URL_SORTED_BY_CHEAPEST) diff --git a/logement_isep.py b/logement_isep.py new file mode 100644 index 0000000..743e134 --- /dev/null +++ b/logement_isep.py @@ -0,0 +1,24 @@ +"""Find locations in issy-les-moulineaux and keep me informed of new offers.""" +import os + +from selenium import webdriver + +URL = "https://logement.isep.fr/" +URL_SORTED_BY_CHEAPEST = "https://logement.isep.fr/listelogement.php?tri=n|loyer" + +driver = webdriver.Chrome() +driver.get(URL) + +id_value, password_value = os.environ['ISEP_ID'], os.environ['ISEP_PASSWORD'] +id_field, password_field, submit_field = driver.find_elements_by_tag_name('input') + +id_field.click() +id_field.send_keys(id_value) + +password_field.click() +password_field.send_keys(password_value) + +submit_field.click() + + +driver.get(URL_SORTED_BY_CHEAPEST)