04-06-2025_large_update #35
@@ -81,6 +81,57 @@ class LxTools(tk.Tk):
 | 
			
		||||
    def __init__(self, *args: Any, **kwargs: Any) -> None:
 | 
			
		||||
        super().__init__(*args, **kwargs)
 | 
			
		||||
 | 
			
		||||
    @staticmethod
 | 
			
		||||
    def ckeck_key_is_exist(
 | 
			
		||||
        directorys: list[str], search_string: str = None
 | 
			
		||||
    ) -> bool | None:
 | 
			
		||||
        """
 | 
			
		||||
        Check if the key is exist in the file
 | 
			
		||||
        Args:
 | 
			
		||||
            directorys (list[str]): list of directories to search in
 | 
			
		||||
            search_string (str): string to search for
 | 
			
		||||
        Returns:
 | 
			
		||||
            bool: True if the key is found, False otherwise
 | 
			
		||||
        """
 | 
			
		||||
 | 
			
		||||
        if search_string:
 | 
			
		||||
            result = False
 | 
			
		||||
 | 
			
		||||
            for directory in directorys:
 | 
			
		||||
 | 
			
		||||
                in_paths = Path(directory)
 | 
			
		||||
 | 
			
		||||
                if not in_paths.exists() or not in_paths.is_dir():
 | 
			
		||||
                    continue
 | 
			
		||||
 | 
			
		||||
                # Get a list of all files in the directorys
 | 
			
		||||
                files = [file for file in in_paths.iterdir() if file.is_file()]
 | 
			
		||||
                if not files:
 | 
			
		||||
                    continue
 | 
			
		||||
 | 
			
		||||
            # Search for the string in the files
 | 
			
		||||
            for file in files:
 | 
			
		||||
                try:
 | 
			
		||||
                    with open(file, "r", errors="ignore") as f:
 | 
			
		||||
                        for line in f:
 | 
			
		||||
                            if search_string in line:
 | 
			
		||||
                                # Set the result to True if the string is found
 | 
			
		||||
                                result = True
 | 
			
		||||
                                break
 | 
			
		||||
 | 
			
		||||
                    # If the string is found, stop searching for the string in other files
 | 
			
		||||
                    if result:
 | 
			
		||||
                        break
 | 
			
		||||
 | 
			
		||||
                except Exception:
 | 
			
		||||
                    # Ignore errors and continue to the next file
 | 
			
		||||
                    continue
 | 
			
		||||
 | 
			
		||||
        else:
 | 
			
		||||
            result = None
 | 
			
		||||
        print(result)
 | 
			
		||||
        return result
 | 
			
		||||
 | 
			
		||||
    @staticmethod
 | 
			
		||||
    def center_window_cross_platform(window, width, height):
 | 
			
		||||
        """
 | 
			
		||||
 
 | 
			
		||||
@@ -57,6 +57,13 @@ class AppConfig:
 | 
			
		||||
        "pkey_path": "/usr/local/etc/ssl/pwgk.pem",
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    # Lists of searches
 | 
			
		||||
    DIRECTORYS: list[str] = [
 | 
			
		||||
        "/etc/netplan/",
 | 
			
		||||
        "/etc/NetworkManager/system-connections/",
 | 
			
		||||
        "/var/lib/NetworkManager/user-connections/",
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    # Images and icons paths
 | 
			
		||||
    IMAGE_PATHS: Dict[str, str] = {
 | 
			
		||||
        "icon_vpn": "/usr/share/icons/lx-icons/48/wg_vpn.png",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user