def changeLanguage(language): if language == Parameters.language_spanish: Strings.dictionary = loadData( Parameters.FOLDER_FILES + Parameters.FOLDER_DICTIONARIES + Parameters.filename_dictionary_spanish) Strings.actual_language = "Español" elif language == Parameters.language_english: Strings.dictionary = loadData( Parameters.FOLDER_FILES + Parameters.FOLDER_DICTIONARIES + Parameters.filename_dictionary_english) Strings.actual_language = "English" else: print("Idioma no soportado, no se pudo cambiar al idioma ", language)
def loadDataChatGroups(cls): return loadData(Parameters.dir_relative_files_groups_chat + Parameters.filename_groups_chat)
class ChatGroup: __chats_created_counter = loadData( Parameters.dir_relative_files_groups_chat + Parameters.filename_chats_created ) if loadData(Parameters.dir_relative_files_groups_chat + Parameters.filename_chats_created) != dict() else 0 def __init__(self, chat_id, name_group, capacity_maximun=100, date_creation=str(datetime.datetime.today()).split()[0], active=True, delay=11.1): self.chat_id = chat_id # integer self.name_group = name_group # string self.capacity_maximun = capacity_maximun # integer self.date_creation = date_creation # string self.active = active # Boolean self.delay = delay self.integrants = [] ChatGroup.__chats_created_counter += 1 # CRUD Operations # create ya es el constructor def read(self): output_integrants = "" if len(self.integrants) == 0: output_integrants = s.dictionary['string_none'] for integrant in self.integrants: output_integrants += s.dictionary['format_id_user_integrant'] % ( integrant.user_name, integrant.integrant_id) return s.dictionary['format_summary_chat_group'] % \ (self.chat_id, self.name_group, self.capacity_maximun, self.date_creation, s.dictionary['string_yes'] if self.active else s.dictionary['string_no'], self.delay, output_integrants) def update_chat_id(self, new_chat_id): self.chat_id = new_chat_id # integer def update_name_group(self, new_name_group): self.name_group = new_name_group # string def update_capacity_maximun(self, new_capacity_maximun): self.capacity_maximun = new_capacity_maximun # integer def update_date_creation(self, new_date_creation): self.date_creation = new_date_creation # string def update_state_active(self, new_state_active): self.active = new_state_active # Boolean # Delete se hace desde ejecución # Operaciones sobre la lista def add_integrant(self, integrant): self.integrants.append(integrant) def remove_integrant(self, integrant): self.integrants.remove(integrant) @staticmethod def generateNewId(): return ChatGroup.__chats_created_counter + 1 @classmethod def saveDataChatGroups(cls, groups_chat): storeData( groups_chat, Parameters.dir_relative_files_groups_chat + Parameters.filename_groups_chat) storeData( ChatGroup.__chats_created_counter, Parameters.dir_relative_files_groups_chat + Parameters.filename_chats_created) @classmethod def loadDataChatGroups(cls): return loadData(Parameters.dir_relative_files_groups_chat + Parameters.filename_groups_chat)
class Integrant: __integrants_created_counter = loadData( Parameters.dir_relative_files_total_integrants + Parameters.filename_total_integrants_created) if loadData( Parameters.dir_relative_files_total_integrants + Parameters.filename_total_integrants_created) != dict() else 0 states = { Parameters.key_state_connected: 1, Parameters.key_state_disconnected: 2 } def __init__(self, integrant_id, user_name, state, date_creation=str(datetime.today()).split()[0], allowed_to_talk=True): self.integrant_id = integrant_id # integer self.user_name = user_name # string self.date_creation = date_creation # string self.state = state # Integer. Definido en el diccionario de arriba self.allowed_to_talk = allowed_to_talk # Boolean self.participation_score = random() # Float Integrant.__integrants_created_counter += 1 # Operaciones CRUD # Create es el constructor def read(self): return s.dictionary['format_summary_integrant'] % \ (self.integrant_id, self.user_name, self.date_creation, self.readStateInWords(), s.dictionary['string_yes'] if self.allowed_to_talk else s.dictionary['string_no'], self.participation_score) def readStateInWords(self): if self.state == 1: return s.dictionary['string_connected'] elif self.state == 2: return s.dictionary['string_disconnected'] else: return s.dictionary['string_unknown'] def update_user_id(self, new_user_id): self.integrant_id = new_user_id # integer def update_user_name(self, new_user_name): self.user_name = new_user_name # string def update_new_date_creation(self, new_date_creation): self.date_creation = new_date_creation # string def update_state(self, new_state): self.state = new_state # Definido en el diccionario de arriba. Number def update_allowed_to_talk(self, new_allowed_to_talk): self.allowed_to_talk = new_allowed_to_talk # Boolean # Delete se hace desde ejecución @staticmethod def generateNewId(): return Integrant.__integrants_created_counter + 1 @classmethod def saveDataIntegrants(cls, total_integrants): storeData( total_integrants, Parameters.dir_relative_files_total_integrants + Parameters.filename_total_integrants) storeData( Integrant.__integrants_created_counter, Parameters.dir_relative_files_total_integrants + Parameters.filename_total_integrants_created) @classmethod def loadDataIntegrants(cls): return loadData(Parameters.dir_relative_files_total_integrants + Parameters.filename_total_integrants)
def loadDataIntegrants(cls): return loadData(Parameters.dir_relative_files_total_integrants + Parameters.filename_total_integrants)