def _get_context(self, environ, dav_res):
assert dav_res.is_collection<EOL>is_readonly = environ["<STR_LIT>"].is_readonly()<EOL>context = {<EOL>"<STR_LIT>": (self.config.get("<STR_LIT>") or "<STR_LIT>") + ASSET_SHARE,<EOL>"<STR_LIT>": [],<EOL>"<STR_LIT:version>": __version__,<EOL>"<STR_LIT>": compat.unquote(dav_res.get_href()),<EOL>"<STR_LIT:url>": dav_res.get_href(),  <EOL>"<STR_LIT>": util.get_uri_parent(dav_res.get_href()),<EOL>"<STR_LIT>": self.dir_config,<EOL>"<STR_LIT>": is_readonly,<EOL>"<STR_LIT>": "<STR_LIT>" if is_readonly else "<STR_LIT>",<EOL>"<STR_LIT>": False,<EOL>}<EOL>trailer = self.dir_config.get("<STR_LIT>")<EOL>if trailer is True:<EOL><INDENT>trailer = "<STR_LIT>"<EOL><DEDENT>if trailer:<EOL><INDENT>trailer = trailer.replace(<EOL>"<STR_LIT>",<EOL>"<STR_LIT>".format(<EOL>__version__<EOL>),<EOL>)<EOL>trailer = trailer.replace("<STR_LIT>", util.get_rfc1123_time())<EOL><DEDENT>context["<STR_LIT>"] = trailer<EOL>rows = context["<STR_LIT>"]<EOL>dirInfoList = dav_res.get_directory_info()<EOL>if dirInfoList is None:<EOL><INDENT>dirInfoList = []<EOL>childList = dav_res.get_descendants(depth="<STR_LIT:1>", add_self=False)<EOL>for res in childList:<EOL><INDENT>di = res.get_display_info()<EOL>href = res.get_href()<EOL>ofe_prefix = None<EOL>tr_classes = []<EOL>a_classes = []<EOL>if res.is_collection:<EOL><INDENT>tr_classes.append("<STR_LIT>")<EOL><DEDENT>if not is_readonly and not res.is_collection:<EOL><INDENT>ext = os.path.splitext(href)[<NUM_LIT:1>].lstrip("<STR_LIT:.>").lower()<EOL>officeType = msOfficeExtToTypeMap.get(ext)<EOL>if officeType:<EOL><INDENT>if self.dir_config.get("<STR_LIT>"):<EOL><INDENT>ofe_prefix = "<STR_LIT>".format(officeType)<EOL>a_classes.append("<STR_LIT>")<EOL><DEDENT><DEDENT><DEDENT>entry = {<EOL>"<STR_LIT>": href,<EOL>"<STR_LIT>": ofe_prefix,<EOL>"<STR_LIT>": "<STR_LIT:U+0020>".join(a_classes),<EOL>"<STR_LIT>": "<STR_LIT:U+0020>".join(tr_classes),<EOL>"<STR_LIT>": res.get_display_name(),<EOL>"<STR_LIT>": res.get_last_modified(),<EOL>"<STR_LIT>": res.is_collection,<EOL>"<STR_LIT>": res.get_content_length(),<EOL>"<STR_LIT>": di.get("<STR_LIT:type>"),<EOL>"<STR_LIT>": di.get("<STR_LIT>"),<EOL>}<EOL>dirInfoList.append(entry)<EOL><DEDENT><DEDENT>ignore_patterns = self.dir_config.get("<STR_LIT:ignore>", [])<EOL>if compat.is_basestring(ignore_patterns):<EOL><INDENT>ignore_patterns = ignore_patterns.split("<STR_LIT:U+002C>")<EOL><DEDENT>ignored_list = []<EOL>for entry in dirInfoList:<EOL><INDENT>ignore = False<EOL>for pat in ignore_patterns:<EOL><INDENT>if fnmatch(entry["<STR_LIT>"], pat):<EOL><INDENT>ignored_list.append(entry["<STR_LIT>"])<EOL>ignore = True<EOL>break<EOL><DEDENT><DEDENT>if ignore:<EOL><INDENT>continue<EOL><DEDENT>last_modified = entry.get("<STR_LIT>")<EOL>if last_modified is None:<EOL><INDENT>entry["<STR_LIT>"] = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>entry["<STR_LIT>"] = util.get_rfc1123_time(last_modified)<EOL><DEDENT>entry["<STR_LIT>"] = "<STR_LIT:->"<EOL>if not entry.get("<STR_LIT>"):<EOL><INDENT>content_length = entry.get("<STR_LIT>")<EOL>if content_length is not None:<EOL><INDENT>entry["<STR_LIT>"] = util.byte_number_string(content_length)<EOL><DEDENT><DEDENT>rows.append(entry)<EOL><DEDENT>if ignored_list:<EOL><INDENT>_logger.debug(<EOL>"<STR_LIT>".format(<EOL>len(ignored_list), ignored_list<EOL>)<EOL>)<EOL><DEDENT>sort = "<STR_LIT:name>"<EOL>if sort == "<STR_LIT:name>":<EOL><INDENT>rows.sort(<EOL>key=lambda v: "<STR_LIT>".format(<EOL>not v["<STR_LIT>"], v["<STR_LIT>"].lower()<EOL>)<EOL>)<EOL><DEDENT>if "<STR_LIT>" in environ:<EOL><INDENT>context.update(<EOL>{<EOL>"<STR_LIT>": True,<EOL>"<STR_LIT>": (environ.get("<STR_LIT>") or "<STR_LIT>"),<EOL>"<STR_LIT>": environ.get("<STR_LIT>"),<EOL>"<STR_LIT>": "<STR_LIT:U+002CU+0020>".join(environ.get("<STR_LIT>") or []),<EOL>"<STR_LIT>": "<STR_LIT:U+002CU+0020>".join(<EOL>environ.get("<STR_LIT>") or []<EOL>),<EOL>}<EOL>)<EOL><DEDENT>return context<EOL>
@see: http://www.webdav.org/specs/rfc4918.html#rfc.section.9.4