2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Remove some redundant code. Related to #86

This commit is contained in:
Dan 2018-06-24 18:54:47 +02:00
parent 55ef4abb27
commit 9a012077cc

View File

@ -864,55 +864,18 @@ class Client(Methods, BaseClient):
"More info: https://docs.pyrogram.ml/start/ProjectSetup#configuration"
)
# TODO: Woah! Some redundant code down here
for option in {"app_version", "device_model", "system_version", "system_lang_code", "lang_code"}:
if getattr(self, option):
pass
else:
setattr(self, option, Client.APP_VERSION)
if self.app_version:
pass
else:
self.app_version = Client.APP_VERSION
if parser.has_section("pyrogram"):
self.app_version = parser.get(
"pyrogram",
"app_version",
fallback=Client.APP_VERSION
)
if self.device_model:
pass
else:
self.device_model = Client.DEVICE_MODEL
if parser.has_section("pyrogram"):
self.device_model = parser.get(
"pyrogram",
"device_model",
fallback=Client.DEVICE_MODEL
)
if self.system_version:
pass
else:
self.system_version = Client.SYSTEM_VERSION
if parser.has_section("pyrogram"):
self.system_version = parser.get(
"pyrogram",
"system_version",
fallback=Client.SYSTEM_VERSION
)
if self.system_lang_code:
pass
else:
self.system_lang_code = Client.SYSTEM_LANG_CODE
if parser.has_section("pyrogram"):
self.system_lang_code = parser.get(
"pyrogram",
"system_lang_code",
fallback=Client.SYSTEM_LANG_CODE
)
if parser.has_section("pyrogram"):
setattr(self, option, parser.get(
"pyrogram",
option,
fallback=getattr(Client, option.upper())
))
if self.lang_code:
pass