def add_path(self, path): "Adds path to recent documents" recent = self.read_paths() # Make the path absolute, resolving any symlinks. path = self._resolved_if_possible(Path(path)) # Remove the existing occurrence of path, if present. # A linear scan is acceptable here because the list will always # be very short try: recent.remove(path) except ValueError: # path is not currently in recent pass # Prepend the path recent.insert(0, str(path)) # Limit to MAX_RECENT_DOCS recent = recent[:self.MAX_RECENT_DOCS] debug_print('Writing {0} recent document paths'.format(len(recent))) settings = QSettings() settings.beginWriteArray(self.KEY, len(recent)) try: for index, path in enumerate(recent): settings.setArrayIndex(index) settings.setValue('path', str(path)) finally: settings.endArray()
def run(self): settings = QSettings('Khertan Software', 'Khweeteur') statuses = [] logging.debug("Thread for '%s' running" % self.call) try: since = settings.value(self.account.token_key + '_' + self.call) logging.debug('%s running' % self.call) if self.call == 'HomeTimeline': statuses = self.account.api.GetHomeTimeline(since_id=since) elif self.call == 'Mentions': statuses = self.account.api.GetMentions(since_id=since) elif self.call == 'DMs': statuses = self.account.api.GetDirectMessages(since_id=since) elif self.call.startswith('Search:'): statuses = self.account.api.GetSearch(since_id=since, term=self.call.split(':', 1)[1]) elif self.call == 'RetrieveLists': # Get the list subscriptions lists = self.account.api.GetSubscriptions( user=self.account.me_user) settings.beginWriteArray('lists') for (index, list_instance) in enumerate(lists): settings.setArrayIndex(index) settings.setValue('id', list_instance.id) settings.setValue('user', list_instance.user.screen_name) settings.setValue('name', list_instance.name) settings.endArray() # Get the status of list settings.sync() elif self.call.startswith('List:'): user, id = self.call.split(':', 2)[1:] statuses = self.account.api.GetListStatuses( user=user, id=id, since_id=since) #Near GPS elif self.call.startswith('Near:'): geocode = self.call.split(':', 2)[1:] + ['1km'] logging.debug('geocode=(%s)', str(geocode)) statuses = self.account.api.GetSearch( since_id=since, term='', geocode=geocode) else: logging.error('Unknown call: %s' % (self.call, )) success = True except Exception, err: success = False logging.debug('Retriever %s: %s' % (self.call, str(err))) if settings.value('ShowInfos') == '2': self.error.emit('Khweeteur Error : %s' % str(err))
def mruSaveList(self): """ Saves the list of MRU files to the application settings file. """ qs = QSettings() qs.remove("mru") qs.beginWriteArray("mru") for i, m in enumerate(self.mru_list): (path, description) = m qs.setArrayIndex(i) qs.setValue("path", path) qs.setValue("description", description) qs.endArray()