Runs a prompt to change the state of books.

    Registers `Event`s with `mgr` as they are requested.

    Args:
        mgr: A `KindleProgressMgr` object with the `books` and `progress`
            fields populated.
487296
def _change_state_prompt(mgr):
    
    cmd = ''
    book_range = range(1, len(mgr.books) + 1)
    ind_to_book = dict(zip(book_range, mgr.books))
    get_book = lambda cmd_str: ind_to_book[int(cmd_str.split()[1])]
    while cmd != 'q':
        print 'Books:'
        for i in book_range:
            print '\t%d: %s' % (i, ind_to_book[i])
        print 'Commands:'
        print '| start {#}   | Start reading book with index {#}'
        print '| finish {#}  | Finish reading book with index {#}'
        print '| q           | Quit'
        cmd = safe_raw_input('> ')
        if cmd is None or cmd == 'q':
            break
        elif cmd.startswith('start '):
            book = get_book(cmd)
            initial_progress = mgr.progress[book.asin].locs[1]
            event = SetReadingEvent(book.asin, initial_progress)
        elif cmd.startswith('finish '):
            event = SetFinishedEvent(get_book(cmd).asin)
        else:
            print 'Invalid command'
            event = None
        if event is not None:
            print
            print 'REGISTERED EVENT:'
            print '  ' + str(event)
            mgr.register_events((event))
        print
966101
def refresh(self, *args, **kwargs):
        
        self.prjbrws.set_model(self.create_prj_model())
        if self.get_current_file():
            self.set_to_current()
        else:
            self.init_selection()
754238
protected void publishProgress(final Progress progress) {
        if (!isCanceled()) {
            sUiHandler.post(new Runnable() {
                @Override
                public void run() {
                    onProgressUpdate(progress);
                }
            });
        }
    }
1089187
def perform(self, store, count):
        
        self.count = count

        try:
            self.upgradeStore(store)
            print 'Upgrade complete'
        except errors.ItemUpgradeError as e:
            print 'Upgrader error:'
            e.originalFailure.printTraceback(file=sys.stdout)
            print self.errorMessageFormat % (
                e.oldType.typeName, e.storeID, e.oldType.schemaVersion,
                e.newType.schemaVersion)
804168
public function onMetaParsing()
    {
        // make sure to trigger the onMetaHeaders event
        $this->getMetaHeaders();

        if ($this->triggersApiEvents(self::API_VERSION_0_9, self::API_VERSION_1_0)) {
            $headersFlipped = array_flip($this->metaHeaders);

            $this->triggerEvent(self::API_VERSION_0_9, 'before_read_file_meta', array(&$headersFlipped));
            $this->triggerEvent(self::API_VERSION_1_0, 'onMetaParsing', array(&$this->rawContent, &$headersFlipped));

            $this->updateFlippedMetaHeaders($headersFlipped);
        }
    }
1037591
def interactive(renderer):
    
    _import_readline()
    _print_heading(renderer)
    contents = []
    more = False
    while True:
        try:
            prompt, more = ('... ', True) if more else ('>>> ', True)
            contents.append(input(prompt) + '\n')
        except EOFError:
            print('\n' + mistletoe.markdown(contents, renderer), end='')
            more = False
            contents = []
        except KeyboardInterrupt:
            print('\nExiting.')
            break
941588
def _set_book_view(self, session):
        """"""
        if self._book_view == FEDERATED:
            try:
                session.use_federated_book_view()
            except AttributeError:
                pass
        else:
            try:
                session.use_isolated_book_view()
            except AttributeError:
                pass
1124361
function (books, context, options) {
      kb.fetcher.load(books).then(function (xhr) {
        renderThreeColumnBrowser2(books, context, options)
      }).catch(function (err) { complain(err) })
    }
1203058
def dispatch(self, receiver):
        ''' 

        '''
        super(ModelChangedEvent, self).dispatch(receiver)
        if hasattr(receiver, '_document_model_changed'):
            receiver._document_model_changed(self)
1223848
public void setProgress(int progress) {
        if (mProgress != progress) {
            mProgress = progress;
            if (mOnCircularSeekBarChangeListener != null) {
                mOnCircularSeekBarChangeListener.onProgressChanged(this, progress, false);
            }

            recalculateAll();
            invalidate();
        }
    }
1098981
def process_event(self, event):
        
        if not isinstance(event, KindleEvent):
            pass
        elif isinstance(event, AddEvent):
            self._data[event.asin] = BookSnapshot(event.asin)
        elif isinstance(event, SetReadingEvent):
            self._data[event.asin].status = ReadingStatus.CURRENT
            self._data[event.asin].progress = event.initial_progress
        elif isinstance(event, ReadEvent):
            self._data[event.asin].progress += event.progress
        elif isinstance(event, SetFinishedEvent):
            self._data[event.asin].status = ReadingStatus.COMPLETED
        else:
            raise TypeError
250832
function () {      
      if (document.body) {        
        // make sure all resources are loaded on first activation
        if (!loaded) Live.loadresources();
        Live.checkForChanges();
      }
      setTimeout(Live.heartbeat, interval);
    }
286723
def publish_for_collection(self, collection_name):
        
        self.revisions = BaseAsyncMotorDocument("%s_revisions" % collection_name, self.settings)

        changes = yield self.__get_pending_revisions()

        if len(changes) > 0:

            self.logger.info("%s revisions will be actioned" % len(changes))

            for change in changes:
                try:
                    self.logger.info("Applying %s action %s - %s to document: %s/%s" % (change.get("action"), change.get("id"), change.get("meta",{}).get("comment", "No Comment"), change.get("collection"), change.get("master_id")))

                    stack = AsyncSchedulableDocumentRevisionStack(
                        change.get("collection"),
                        self.settings,
                        master_id=change.get("master_id")
                    )

                    revision = yield stack.pop()

                    self.logger.debug(revision)

                except Exception as ex:
                    self.logger.error(ex)
474976
async def trigger(self, event, kwargs):
        
        await self._queue.put((event, kwargs))
        self._resume_processing.set()
1342228
private void showProgress() {

        removeContent();
        displayDialogInfo(
            org.opencms.gwt.client.Messages.get().key(org.opencms.gwt.client.Messages.GUI_UPLOAD_INFO_UPLOADING_0),
            false);
        m_selectionSummary.removeFromParent();
        List<String> files = new ArrayList<String>(getFilesToUpload().keySet());
        Collections.sort(files, String.CASE_INSENSITIVE_ORDER);
        m_progressInfo = new CmsUploadProgressInfo(files);
        m_progressInfo.setContentLength(m_contentLength);
        m_contentWrapper.add(m_progressInfo);
        m_updateProgressTimer.scheduleRepeating(UPDATE_PROGRESS_INTERVALL);
        startLoadingAnimation(Messages.get().key(Messages.GUI_UPLOAD_CLIENT_LOADING_0), 0);
        setHeight();
        changeHeight();
    }
78980
protected void fireStateChange() {
		if (this.listeners != null) {
			final ProgressionEvent event = new ProgressionEvent(this, isRootModel());
			for (final ProgressionListener listener : this.listeners.getListeners(ProgressionListener.class)) {
				listener.onProgressionStateChanged(event);
			}
		}
	}
683531
public void setProgress(CmsUploadProgessInfo info) {

        int currFile = info.getCurrentFile();

        int currFileIndex = 0;
        if (currFile == 0) {
            // no files read so far
        } else {
            currFileIndex = currFile - 1;
            if (currFileIndex >= m_orderedFilenamesToUpload.size()) {
                currFileIndex = m_orderedFilenamesToUpload.size() - 1;
            }
        }

        if (m_contentLength == 0) {
            m_contentLength = info.getContentLength();
        }

        String currFilename = m_orderedFilenamesToUpload.get(currFileIndex);
        String contentLength = CmsUploadButton.formatBytes(m_contentLength);
        int fileCount = m_orderedFilenamesToUpload.size();
        String readBytes = CmsUploadButton.formatBytes(getBytesRead(info.getPercent()));

        m_bar.setValue(info.getPercent());

        if (!m_started) {
            m_started = true;
            m_fileinfo.setHTML(0, 0, "<b>" + Messages.get().key(Messages.GUI_UPLOAD_PROGRESS_CURRENT_FILE_0) + "</b>");
            m_fileinfo.setHTML(1, 0, "<b>" + Messages.get().key(Messages.GUI_UPLOAD_PROGRESS_UPLOADING_0) + "</b>");
            m_fileinfo.setHTML(2, 0, "");

            m_fileinfo.setText(0, 1, "");
            m_fileinfo.setText(1, 1, "");
            m_fileinfo.setText(2, 1, "");

            m_fileinfo.getColumnFormatter().setWidth(0, "100px");
        }

        m_fileinfo.setText(0, 1, currFilename);
        m_fileinfo.setText(
            1,
            1,
            Messages.get().key(
                Messages.GUI_UPLOAD_PROGRESS_CURRENT_VALUE_3,
                new Integer(currFileIndex + 1),
                new Integer(fileCount),
                getFileText()));
        m_fileinfo.setText(
            2,
            1,
            Messages.get().key(Messages.GUI_UPLOAD_PROGRESS_UPLOADING_VALUE_2, readBytes, contentLength));
    }