class_docstr: To implement your own bytecode cache you have to subclass this class
  and override :meth:`load_bytecode` and :meth:`dump_bytecode`.  Both of
  these methods are passed a :class:`~jinja2.bccache.Bucket`.
  
  A very basic bytecode cache that saves the bytecode on the file system::
  
      from os import path
  
      class MyCache(BytecodeCache):
  
          def __init__(self, directory):
              self.directory = directory
  
          def load_bytecode(self, bucket):
              filename = path.join(self.directory, bucket.key)
              if path.exists(filename):
                  with open(filename, 'rb') as f:
                      bucket.load_bytecode(f)
  
          def dump_bytecode(self, bucket):
              filename = path.join(self.directory, bucket.key)
              with open(filename, 'wb') as f:
                  bucket.write_bytecode(f)
  
  A more advanced version of a filesystem based bytecode cache is part of
  Jinja.
class_docstr_tok: ["To","implement","your","own","bytecode","cache","you","have","to","subclass","this","class","and","override",":","meth",":","`","load_bytecode","`","and",":","meth",":","`","dump_bytecode","`",".","Both","of","these","methods","are","passed","a",":","class",":","`","~jinja2.bccache.Bucket","`",".","A","very","basic","bytecode","cache","that","saves","the","bytecode","on","the","file","system",":",":","from","os","import","path","class","MyCache","(","BytecodeCache",")",":","def","__init__","(","self",",","directory",")",":","self.directory","=","directory","def","load_bytecode","(","self",",","bucket",")",":","filename","=","path.join","(","self.directory",",","bucket.key",")","if","path.exists","(","filename",")",":","with","open","(","filename",",","'rb","'",")","as","f",":","bucket.load_bytecode","(","f",")","def","dump_bytecode","(","self",",","bucket",")",":","filename","=","path.join","(","self.directory",",","bucket.key",")","with","open","(","filename",",","'wb","'",")","as","f",":","bucket.write_bytecode","(","f",")","A","more","advanced","version","of","a","filesystem","based","bytecode","cache","is","part","of","Jinja","."]
docstr: Return a cache bucket for the given template.  All arguments are
  mandatory but filename may be `None`.
docstr_tok: ["Return","a","cache","bucket","for","the","given","template",".","All","arguments","are","mandatory","but","filename","may","be","`","None","`","."]
code: def get_bucket(self, environment, name, filename, source):
      """Return a cache bucket for the given template.  All arguments are
      mandatory but filename may be `None`.
      """
      key = self.get_cache_key(name, filename)
      checksum = self.get_source_checksum(source)
      bucket = Bucket(environment, key, checksum)
      self.load_bytecode(bucket)
      return bucket
  
imports: import errno
  import fnmatch
  import os
  import stat
  import sys
  import tempfile
  from hashlib import sha1
  from os import listdir
  from os import path
  from ._compat import BytesIO
  from ._compat import marshal_dump
  from ._compat import marshal_load
  from ._compat import pickle
  from ._compat import text_type
  from .utils import open_if_exists
label_desc: Use image node_id 6 for calling the BytecodeCache obj's underlying member method code with example usage: obj.get_bucket(environment, name, filename, source) and returns: bucket