Cache all available man pages
338954
def cache_all(self):
        """"""

        respond = input(
              'By default, cppman fetches pages on-the-fly if corresponding '
              'page is not found in the cache. The "cache-all" option is only '
              'useful if you want to view man pages offline. '
              'Caching all contents will take several minutes, '
              'do you want to continue [y/N]? ')
        if not (respond and 'yes'.startswith(respond.lower())):
            raise KeyboardInterrupt

        try:
            os.makedirs(environ.cache_dir)
        except:
            pass

        self.success_count = 0
        self.failure_count = 0

        if not os.path.exists(environ.index_db):
            raise RuntimeError("can't find index.db")

        conn = sqlite3.connect(environ.index_db)
        cursor = conn.cursor()

        source = environ.config.source
        print('Caching manpages from %s ...' % source)
        data = cursor.execute('SELECT * FROM "%s"' % source).fetchall()

        for name, url, _ in data:
            print('Caching %s ...' % name)
            retries = 3
            while retries > 0:
                try:
                    self.cache_man_page(source, url, name)
                except Exception:
                    print('Retrying ...')
                    retries -= 1
                else:
                    self.success_count += 1
                    break
            else:
                print('Error caching %s ...' % name)
                self.failure_count += 1

        conn.close()

        print('\n%d manual pages cached successfully.' % self.success_count)
        print('%d manual pages failed to cache.' % self.failure_count)
        self.update_mandb(False)
548941
def cache_package
      dir = File.join(page_cache_directory, Jammit.package_path)
      Jammit.packager.cache(@package, @extension, @contents, dir, @variant, @mtime)
    end
1136487
def prepare_page(self, *args, **kwargs):
        '''
        
        '''
        super(BaseBackend, self).prepare_page(*args, **kwargs)
950818
def each_page(indices)
      unless block_given?
        enum_for(:each_page,indices)
      else
        indices.map { |index| yield page_cache[index] }
      end
    end
980848
def all(self):
        
        return self.pages(self.url.page, self.url.max_page)
469165
def get_cached_files(url, server_name="", document_root=None):
    
    import glob
    url_info = process_url(url, server_name, document_root, check_security=False)

    # get path to cache directory with basename of file (no extension)
    filedir = os.path.dirname(url_info['requested_file'])
    fileglob = '{0}*{1}'.format(url_info['base_filename'], url_info['ext'])
    return glob.glob(os.path.join(filedir, fileglob))
1344415
def _save_cache(self, filename, section_number_of_pages, page_references):
        """"""
        cache_path = Path(filename).with_suffix(self.CACHE_EXTENSION)
        with cache_path.open('wb') as file:
            cache = (section_number_of_pages, page_references)
            pickle.dump(cache, file)
737056
def do_GET(self):
        """"""
        self.do_HEAD()
        template = pkg_resources.resource_string(__name__, "static/splash.html")
        page = template.decode('utf-8').format(self.headers.get("User-Agent"), self.cache)
        self.wfile.write(page.encode('utf-8'))
1256645
def write_cache(self):
        """"""
        doc = {
            '__format__': 1,
            'dependencies': self._cache,
        }
        with open(self._cache_file, 'w') as f:
            json.dump(doc, f, sort_keys=True)
711557
def _load_cache(self):
        """"""
        if not self._disable_cache and os.path.exists(self._cache_path):
            _LOGGER.debug("Cache found at: %s", self._cache_path)
            loaded_cache = UTILS.load_cache(self._cache_path)

            UTILS.update(self._cache, loaded_cache)

        self._save_cache()
1317903
function UpdateCachedOndemandAssets() {

      var files = glob.sync('**/*.js', {cwd: path.join(ss.root,options.dirs.code)}); //TODO need root *.js as well
      files.forEach(function(rel) {
        ss.http.cached.route('assets/ondemand/'+ (rel.replace('\\','/')), null, path.join(ss.root, options.dirs.code, rel) );
      },this);

      files = glob.sync('**/*.js', {cwd: path.join(ss.root,options.dirs.workers)}); //TODO need root *.js as well
      files.forEach(function(rel) {
        ss.http.cached.route('assets/workers/'+ (rel.replace('\\','/')), null, path.join(ss.root, options.dirs.workers, rel) );
      },this);
    }
1078831
function pullAllPages() {
        // 1. Pull one page
        // 2. Check if Pull is complete
        // 3. If it is complete, go to 5. If not, update the query to fetch the next page.
        // 4. Go to 1
        // 5. DONE
        return pullPage().then(function(pulledRecords) {
            if (!isPullComplete(pulledRecords)) {
                // update query and continue pulling the remaining pages
                return updateQueryForNextPage(pulledRecords).then(function() {
                    return pullAllPages();
                });
            }
        });
    }
408603
def page_list(cls, pages, base_url='/'):
        """"""
        plist = []
        for page in pages:
            url = "<a href=\"{}{}\">{}</a>".format(base_url, cls.slugify(page), page)
            plist.append(url)
        return plist
1028399
def cached_items(self):
        
        for item in six.iteritems(self._page_cache):
            yield item
        for item in six.iteritems(self._direct_lookup_cache):
            yield item
1158575
public function index()
    {
        $page = $this->request->getQuery('page', 1);

        //Sets the cache name
        $cache = sprintf('index_limit_%s_page_%s', $this->paginate['limit'], $page);

        //Tries to get data from the cache
        list($posts, $paging) = array_values(Cache::readMany(
            [$cache, sprintf('%s_paging', $cache)],
            $this->Posts->getCacheName()
        ));

        //If the data are not available from the cache
        if (empty($posts) || empty($paging)) {
            $posts = $this->paginate($this->Posts->find('active')->find('forIndex'));

            //Writes on cache
            Cache::writeMany([
                $cache => $posts,
                sprintf('%s_paging', $cache) => $this->request->getParam('paging'),
            ], $this->Posts->getCacheName());
        //Else, sets the paging parameter
        } else {
            $this->request = $this->request->withParam('paging', $paging);
        }

        $this->set(compact('posts'));
    }
734072
def all(self):
        
        page = self._load(self.href)
        while True:
            try:
                for item in page._items:
                    yield item
                page = page.next_page()
            except PaginationError:
                break
1297952
def mkmanpage(name):
    """"""
    mod_name, class_name = name.rsplit('.', 1)
    mod = __import__(mod_name)
    inst = getattr(mod, class_name)()
    sections = cmdln.man_sections_from_cmdln(inst)
    sys.stdout.write(''.join(sections))