Пример #1
0
 def _create_template_roster_file(self, guild):
     roster_dir = os.path.join(self.tmp_dir, guild, 'roster')
     roster_path = os.path.join(roster_dir, 'roster.json')
     FileHandler().make_directory(roster_dir)
     roster = JSON(roster_path)
     roster.values = {'roster': []}
     roster.save_setting()
Пример #2
0
 def _update_saved_variables(self):
     spreadsheet = str(self.spreadsheet_line_edit.text())
     credentials = str(self.credentials_line_edit.text())
     saved_variables = JSON(self.saved_variables_path)
     saved_variables.load_setting()
     saved_variables.values['spreadsheet'] = spreadsheet
     saved_variables.values['credentials'] = credentials
     saved_variables.save_setting()
Пример #3
0
 def _save_info(self, dungeon_name, data, char_name, realm_slug):
     path = os.path.join(Path.home(), 'Kugar\'s Guild Management Tool',
                         self.guild, char_name + '_' + realm_slug,
                         'mythic_plus')
     FileHandler().make_directory(path)
     path = os.path.join(path, dungeon_name + '.json')
     file = JSON(path)
     file.values = data
     file.save_setting()
Пример #4
0
 def _get_url(self, category):
     url_path = ResourceHandler().get_resource('urls.json')
     url = JSON(url_path)
     url.load_setting()
     url_part = url.get_value(category)
     if url_part is not None:
         url_part += '?namespace=profile-eu&locale=en_GB'
         return self.base_url + url_part
     return None
Пример #5
0
 def _add_new_character(self, armory_link):
     guild = str(self.guild_comboBox.currentText())
     roster_path = os.path.join(self.tmp_dir, guild, 'roster',
                                'roster.json')
     if not os.path.isfile(roster_path):
         self._create_template_roster_file(guild)
     roster = JSON(roster_path)
     roster.load_setting()
     roster.values['roster'].append(armory_link)
     roster.save_setting()
Пример #6
0
 def _get_info(self, category, attribute_list):
     """
     Returns the character information given from the attribute list
     in the (category).json file.
     Requires the (category).json file to have already be downloaded.
     """
     path = os.path.join(self._tmp_dir, category + '.json')
     file = JSON(path)
     file.load_setting()
     return file.get_value(attribute_list)
Пример #7
0
 def download_data(self, category=None):
     """
     Downloads the data requested in the C://Users/currentuser/Imminent
     The folder Imminent and the individual character folders are created
     """
     if category is None:
         url_path = ResourceHandler().get_resource('urls.json')
         url = JSON(url_path)
         url.load_setting()
         for _ in url.values.keys():
             self.download_data(_)
         return
     FileHandler().make_directory(self._tmp_dir)
     path = os.path.join(self._tmp_dir, category + '.json')
     file = JSON(path)
     url = self._get_url(category)
     response = self._request_data(url)
     file.values = json.loads(response.text)
     file.save_setting()
Пример #8
0
 def _get_client_secret(self):
     try:
         client_path = ResourceHandler().get_resource('client.json')
         client = JSON(client_path)
         client.load_setting()
     except Exception as ex:
         _LOGGER.error(
             'Exception raised while trying to get the client secret.\n' +
             str(ex))
         raise ex
     return client.get_value('secret')
Пример #9
0
 def _get_char_list(self):
     char_list = []
     roster_path = os.path.join(Path.home(),
                                'Kugar\'s Guild Management Tool',
                                self.guild, 'roster', 'roster.json')
     roster = JSON(roster_path)
     roster.load_setting()
     for _ in roster.values['roster']:
         charname = _.split('/')[7]
         realm_slug = _.split('/')[6]
         region = _.split('/')[5]
         char_list.append((charname, realm_slug, region))
     return char_list
Пример #10
0
 def _update_mythic_plus_count_list(self, reset_list, filename):
     file = JSON(filename)
     file.load_setting()
     for _ in file.values['runs']:
         run_completion_time = datetime.strptime(
             _['summary']['completed_at'][:-5:],
             '%Y-%m-%dT%H:%M:%S').replace(
             tzinfo=pytz.UTC)
         run_completion_timestamp = datetime.timestamp(run_completion_time)
         counter = self._get_mythic_plus_week_from_timestamp(
             reset_list, run_completion_timestamp)
         if counter is not False:
             self._mythic_plus_count_list[counter] += 1
Пример #11
0
 def _delete_roster_entries(self, delete_list):
     guild = str(self.guild_comboBox.currentText())
     roster_path = os.path.join(self.tmp_dir, guild, 'roster',
                                'roster.json')
     roster = JSON(roster_path)
     roster.load_setting()
     for _ in delete_list:
         for link in roster.values['roster']:
             if _.lower() in link:
                 index = roster.values['roster'].index(link)
                 roster.values['roster'].pop(index)
                 break
     roster.save_setting()
     return True
Пример #12
0
 def _get_list_of_mythic_plus_per_dungeon(
         self, filename, reset_list, reset):
     file = JSON(filename)
     file.load_setting()
     completed_keys_list = []
     for _ in file.values['runs']:
         run_completion_time = datetime.strptime(
             _['summary']['completed_at'][:-5:],
             '%Y-%m-%dT%H:%M:%S').replace(
             tzinfo=pytz.UTC)
         run_completion_timestamp = datetime.timestamp(run_completion_time)
         if run_completion_timestamp > reset_list[reset]:
             completed_keys_list.append(_['summary']['mythic_level'])
     return completed_keys_list
Пример #13
0
 def _create_character_checkboxes(self):
     self.checkbox_list = []
     _translate = QtCore.QCoreApplication.translate
     guild = str(self.guild_comboBox.currentText())
     roster_path = os.path.join(self.tmp_dir, guild, 'roster',
                                'roster.json')
     roster_list = []
     if os.path.isfile(roster_path):
         roster = JSON(roster_path)
         roster.load_setting()
         roster_list = roster.values['roster']
     vertical_position_counter = 0
     for _ in roster_list:
         charname = _.split('/')[7].capitalize()
         setattr(self, 'char_checkbox' + charname,
                 QtWidgets.QCheckBox(self.scrollAreaWidgetContents_3))
         sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                            QtWidgets.QSizePolicy.Fixed)
         sizePolicy.setHorizontalStretch(0)
         sizePolicy.setVerticalStretch(0)
         sizePolicy.setHeightForWidth(
             getattr(self, 'char_checkbox' +
                     charname).sizePolicy().hasHeightForWidth())
         getattr(self, 'char_checkbox' + charname).setSizePolicy(sizePolicy)
         getattr(self, 'char_checkbox' +
                 charname).setObjectName('char_checkbox' + charname)
         self.scrollArea_gridLayout.addWidget(
             getattr(self, 'char_checkbox' + charname),
             vertical_position_counter, 0, 1, 1)
         self.checkbox_list.append(getattr(self,
                                           'char_checkbox' + charname))
         getattr(self, 'char_checkbox' + charname).setText(
             _translate("MainWindow", charname))
         vertical_position_counter += 1
     self.scrollArea.setWidget(self.scrollAreaWidgetContents_3)
     self.gridLayout.addWidget(self.scrollArea, 5, 0, 1, 4)
     self.main_window.setCentralWidget(self.centralwidget)
     self.guild_comboBox.currentTextChanged.connect(
         self._refresh_scrollArea_gridLayout)
Пример #14
0
 def _get_saved_spreadsheet_name(self):
     saved_variables = JSON(self.saved_variables_path)
     saved_variables.load_setting()
     return saved_variables.get_value(['spreadsheet'])
Пример #15
0
 def _get_saved_credentials_file(self):
     saved_variables = JSON(self.saved_variables_path)
     saved_variables.load_setting()
     return saved_variables.get_value(['credentials'])
Пример #16
0
 def _create_saved_variables_template(self):
     saved_variables = JSON(self.saved_variables_path)
     saved_variables.load_setting()
     saved_variables.values = {'spreadsheet': '', 'credentials': ''}
     saved_variables.save_setting()