Sddm

This expression is always true because of how you construct sddm_conf_path in the line immediately before: os.path.join only does string manipulations, not actual sanity checks. What you probably want, after constructing the path, is to check if the sddm_conf_path refers to an existing file.
Try `if os.path.isfile(sddm_conf_path):`