MCPcopy Index your code
hub / github.com/PDFMathTranslate/PDFMathTranslate / parse_user_passwd

Function parse_user_passwd

pdf2zh/gui.py:771–798  ·  view source on GitHub ↗

Parse the user name and password from the file. Inputs: - file_path: The file path to read. Outputs: - tuple_list: The list of tuples of user name and password. - content: The content of the file

(file_path: str)

Source from the content-addressed store, hash-verified

769
770
771def parse_user_passwd(file_path: str) -> tuple:
772 """
773 Parse the user name and password from the file.
774
775 Inputs:
776 - file_path: The file path to read.
777 Outputs:
778 - tuple_list: The list of tuples of user name and password.
779 - content: The content of the file
780 """
781 tuple_list = []
782 content = ""
783 if not file_path:
784 return tuple_list, content
785 if len(file_path) == 2:
786 try:
787 with open(file_path[1], "r", encoding="utf-8") as file:
788 content = file.read()
789 except FileNotFoundError:
790 print(f"Error: File '{file_path[1]}' not found.")
791 try:
792 with open(file_path[0], "r", encoding="utf-8") as file:
793 tuple_list = [
794 tuple(line.strip().split(",")) for line in file if line.strip()
795 ]
796 except FileNotFoundError:
797 print(f"Error: File '{file_path[0]}' not found.")
798 return tuple_list, content
799
800
801def setup_gui(

Callers 1

setup_guiFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected