o ]Lb @sNddlmZddlZddlZddlZddlZddlmZddlm Z m Z ddl m Z ddl mZmZmZmZmZmZdd lmZmZmZmZmZm Z mZmZmZmZmZdd lm Z dd lm!Z!gZ"iZ#Gd d d e$Z%e%dddZ&e%dddZ'ddZ(e%dddZ)ddZ*e%ddRddZ+e%dd d!Z,e%d"d#d$Z-e%d%e-Z.d&d'Z/e%d(d)d*Z0e%d+d,d-Z1e%d.d/d0Z2e%d1d2d3Z3e%d4d5d6Z4e%d7d8d9Z5e%d:e5Z6e%d;dd?d@Z8e%dAdBdCZ9e%dDdEdFZ:e%dGdHdIZ;e%dJdKdLZe#?Z@dS)S)absolute_importN)_)hexshortgetattr) ErrorResponseHTTP_FORBIDDENHTTP_NOT_FOUND get_contact paritygen staticfile) archivaldagopencodingerrorgraphmodpycompatrevset revsetlangscmutilsmartset templateutil) stringutil)webutilc@s eZdZdZddZddZdS) webcommandaDecorator used to register a web command handler. The decorator takes as its positional arguments the name/path the command should be accessible under. When called, functions receive as arguments a ``requestcontext``, ``wsgirequest``, and a templater instance for generatoring output. The functions should populate the ``rctx.res`` object with details about the HTTP response. The function returns a generator to be consumed by the WSGI application. For most commands, this should be the result from ``web.res.sendresponse()``. Many commands will call ``web.sendtemplate()`` to render a template. Usage: @webcommand('mycommand') def mycommand(web): pass cCs ||_dSNname)selfr r"=/usr/lib/python3/dist-packages/mercurial/hgweb/webcommands.py__init__Is zwebcommand.__init__cCst|j|t|j<|Sr)__all__appendr commands)r!funcr"r"r#__call__Ls  zwebcommand.__call__N)__name__ __module__ __qualname____doc__r$r)r"r"r"r#r2s rslogcCs|jjdr t|St|S)a /log[/{revision}[/{path}]] -------------------------- Show repository or file history. For URLs of the form ``/log/{revision}``, a list of changesets starting at the specified changeset identifier is shown. If ``{revision}`` is not defined, the default is ``tip``. This form is equivalent to the ``changelog`` handler. For URLs of the form ``/log/{revision}/{file}``, the history for a specific file will be shown. This form is equivalent to the ``filelog`` handler. file)reqqsparamsgetfilelog changelogwebr"r"r#logRsr6srawfilec CsH|dd}t|j|jjdd}|st|Sz t|j|j}Wn"t j yE}zz t|WWYd}~St y@|wd}~ww| }| }d}|rptt|d}|durkt|rhd}nd}nt|}|dr||d tj7}||jjd <|d d d ddd}d||jjd<|j||jS)Nwebs guessmimer.sapplication/binaryrs text/plainstext/s; charset="%s" Content-Type/\s\\"s\"sinline; filename="%s"Content-Disposition) configboolr cleanpathrepor/r0r1manifestfilectxr LookupErrorr pathdata mimetypes guess_typerfsdecoderbinarysysbytes startswithrresheaders rpartitionreplace setbodybytes sendresponse)r5 guessmimerEfctxinsttextmtfilenamer"r"r#rawfileisB        rYc s|}|t|j||v}tr/t t t |dp)d}d|fdd}|j d|t|t|t|j|t|||t|dt t|j|S) Nrapplication/octet-stream (binary:%s)c3sBtdD]\}}|d|dd|dtdVqdS)NTl%dr % 6d)linelineid linenumberparity) enumerate splitlinesnext)contextlinenotparityrVr"r#liness   z_filerevision..lines filerevision)filerErVsymrevrename permissionsishead)rk)rErFr stripecountfilenoder2headsrrJrrKrGrHrI sendtemplateruprmappinggeneratorsymrevorshortnoder/ renamelinkrBflagsint strkwargs commonentryrA)r5rTfrprWrjr"rhr# _filerevisions0      r~r.c Cs|jjddkr t|St|j|jjdd}|s t|Sz t|t |j|jWSt j yN}zz t|WWYd}~St yI|wd}~ww)a5 /file/{revision}[/{path}] ------------------------- Show information about a directory or file in the repository. Info about the ``path`` given as a URL parameter will be rendered. If ``path`` is a directory, information about the entries in that directory will be rendered. This form is equivalent to the ``manifest`` handler. If ``path`` is a file, information about that file will be shown via the ``filerevision`` template. If ``path`` is not defined, information about the root directory will be rendered. stylesrawr.r8N) r/r0r1rYrr@rArBr~rCrrDr )r5rErUr"r"r#rls rlc sddddd}fdd}fdd }|d f|d f|d fi}fd d}fdd}jjd}jdjjvriztjjdtdjjdd<Wn tyhYnwt jjd}tdd|d<||d<t jjd} d| d<|| d<||\} djjvrd} || d} } |n| kr|d} nd} d} || j d} t j j d|| dtj|ddd| |d| | d S)Nrevskeywordsrevsetcss |VdSrr")ctxr"r"r# revsearchs z_search..revsearchc3stj}||}fdd}|D].}d}|D]!}|||vs:|||vs:||d|vs:d}nq|r>q|VqdS)Nc3sxjj}ttjdddD](}g}|td|d|D] }j|}||q ||D]}|Vq3qdS)Nr ric) rAr3rxrangelenrevsmaxr&reverse)cliljrer4r"r#revgens  z._search..keywordsearch..revgenr r )rlowersplituser descriptionjoinfiles)queryrqwrrmissqr4r"r# keywordsearchs"   z_search..keywordsearchc3s|D]}j|VqdSrrA)rrr4r"r# revsetsearchsz_search..revsetsearchsexact revision searchsliteral keyword searchsrevset expression searchc sz tj|}W|fStjtjfyYnwd|}zt|}Wntjy3|fYSwt |dkr?|fSt ddt |DrO|fSt |}| tjs^|fSztjjj|tjd}|j}|fWStjtjtjtfy|fYSw)Ns reverse(%s)rcss.|]\}}}||p dddfdkVqdS)r8N)sstringsre:r").0tokenvalueposr"r"r# s  z1_search..getsearchmode..)lookup)r revsymbolrAr RepoErrorrDrparse ParseErrordepthanytokenize funcsusedissubsetr safesymbolsmatchuilookupfnRepoLookupErrorAbort)rrrevdeftreermfuncr) MODE_KEYWORD MODE_REVISION MODE_REVSETr5r"r# getsearchmode sF      z_search..getsearchmodec3sd}dD]9}|d7}t|}tjd|}t||j}tj|}| t ||d|V|krBdSq dS)Nrr changelogtag)rarsfiles) rbinnodershowtagrA listfilediffsrmaxfilesr|updaterd)recountrnshowtagsrlm)funcargrirevcount searchfuncr5r"r# changelist;s& z_search..changelistrevcountr sessionvarsrsforcekwr8tipssearchs searchentryr) rnodermentriesarchivesmorevarslessvarsmodedesc showforcekw showunforcekw)r/r0 maxchangesrzr1rtmpldefaults ValueErrorcopyrArrqrtrrrv archivelist)r5rrr searchfuncsrrrrrmoderrtipr")rrrrrirrr5r#_searchsl  1           r changelogFcsd}djjvrtjj}tj|}ndjjvr"tSjd}d}fdd}|r7j}nj}djjvrczt jj d|}t |d}|j j d d<Wn tybYnwtj j d }t |d d|d<tj j d }|d |d<tj} |tjtj|| } t||d} | d d} t| |kr| d d } | d d } ng} j|rd nd| ||| t| t| t| d||||dS)a0 /changelog[/{revision}] ----------------------- Show information about multiple changesets. If the optional ``revision`` URL argument is absent, information about all changesets starting at ``tip`` will be rendered. If the ``revision`` argument is present, changesets will be shown starting from the specified revision. If ``revision`` is absent, the ``rev`` query string argument may be defined. This will perform a search for changesets. The argument for ``rev`` can be a single revision, a revision set, or a literal keyword to search for in changeset data (equivalent to :hg:`log -k`). The ``revcount`` query string argument defines the maximum numbers of changesets to render. For non-searches, the ``changelog`` template will be rendered. r8noderrc3s>g}dkrjjd}t||D]}|VqdS)Nr;r)rAr3rrchangelistentries)maxcountrentryrirr5r"r#rszchangelog..changelistrr rrNr;shortlogr) changenavrrevrm changesetsr latestentry nextentryrrrrr)r/r0r changectxrArwrmaxshortchangesrrzr1rrrrrrrrrqrevnavgenlistrtrr mappinglistr)r5shortlogrrrmrrrrrrrrrr"rr#r3sd             r3rcCs t|ddS)a  /shortlog --------- Show basic information about a set of changesets. This accepts the same parameters as the ``changelog`` handler. The only difference is the ``shortlog`` template will be rendered instead of the ``changelog`` template. T)r)r3r4r"r"r#rs r changesetcCs(t|j|j}|jdit||S)a /changeset[/{revision}] ----------------------- Show information about a single changeset. A URL path argument is the changeset identifier to show. See ``hg help revisions`` for possible values. If not defined, the ``tip`` changeset will be shown. The ``changeset`` template is rendered. Contents of the ``changesettag``, ``changesetbookmark``, ``filenodelink``, ``filenolink``, and the many templates related to diffs may all be used to produce the output. rN)r)rrrAr/rtchangesetentry)r5rr"r"r# changesetsrrcCs|S)zHook for mapping a path in the repository to a path in the working copy. Extensions (e.g., largefiles) can override this to remap files in the virtual file system presented by the manifest command below.r")rEr"r"r# decodepath srmanifestc sd|jjvrt|j|jt|j}n|jdd}t|j|jjdd}t }iit |j |rJ|dddkrJ|d7}t |}d|tD]J\}}t|}|d||krhqW||d}|d} t | dkr~||<qW} | d dD]} | | vri| | <| | } t | dkrnqd| d<qWrssttd |fd d } fd d} |j d|ttt| t| |t|dtt|jS)a /manifest[/{revision}[/{path}]] ------------------------------- Show information about a directory. If the URL path arguments are omitted, information about the root directory for the ``tip`` changeset will be shown. Because this handler can only show information for directories, it is recommended to use the ``file`` handler instead, as it can handle both directories and files. The ``manifest`` template will be rendered for this handler. rrr.r8r;Nr:r rspath not found: c 3sLtD]}|}|}|t||||dVqdS)N)r.rabasenamedatessizes permissions)sortedrCrddatesizery)rer}fullrT)rrmfrir"r#filelistOs   zmanifest..filelistc3stD]D}g}|}t|tr6t|dkr6tt|\}}|r)|||}t|tr6t|dksd|f}t|d||dVqdS)Nr s%s%sr:)rapaths emptydirsr) r isinstancedictrrditeritemsr&r)red emptydirshkvrE)abspathdirsrir"r#dirlist]s"    zmanifest..dirlistr)rmrEruupparityfentriesdentriesr)r)r/r0rrrArwr@r1rBrrrrqrr iteritemsrrr r rtrurdrrvrrr{r|)r5rmrErrrrr}remainelementsrelemrr r")rrr rrrir#rBsb             rBtagsc sjttjtjfdd}jdtjj t j |ddt j |ddt j |dddS) z /tags ----- Show information about tags. No arguments are accepted. The ``tags`` template is rendered. c3s\}|r ddD}|r|dd}|D]\}}t|j|t|dVqdS)NcSs g|] \}}|dkr||fqS)rr")rrrr"r"r# s z)tags..entries..r )ratagrrrdrArr)renotip latestonlyrgrrrrir5r"r#rs    ztags..entriesr)FFargs)TF)TT)rr entriesnotipr) rreversedrAtagslistrrqrtrr3rrrv)r5rr"rr#tagss    r bookmarksc sfddjjDfdd}t|ddtjfdd}r0d d }nd }j|}jd tjj t d |igt j |ddt j |dddS)z /bookmarks ---------- Show information about bookmarks. No arguments are accepted. The ``bookmarks`` template is rendered. cg|] }|djvr|qSr rrbr4r"r#rzbookmarks..cj|d|dfSNr rrArr#r4r"r#zbookmarks..Tkeyrc3sJ}|r dd}|D]\}}t|j|t|dVq dS)Nr rasbookmarkrrr)rerrgrrrr"r#rs    zbookmarks..entriesrr r;rrFr)T)r lastchangerr)rA _bookmarksrrrrqrrtrr3rrrrv)r5sortkeyr latestrevlastdater"rr# bookmarkss      r4branchescCs@t|j|j}t|j|jd}|jdt|jj||dS)z /branches --------- Show information about branches. All known branches are contained in the output, even closed branches. No arguments are accepted. The ``branches`` template is rendered. r r5)rrr)r branchentriesrArqrtrr3r)r5rrr"r"r#branchessr7summarycstjfdd}fdd}fdd}jd}tj}td|jt|jd d }|s@d }d d }j d |t jpPd | t j |ddt |tjjdt j |dd|ddt j|ddd S)z /summary -------- Show a summary of repository state. Information about the latest changesets, bookmarks, tags, and branches is captured by this handler. The ``summary`` template is rendered. c3sdtj}d}D]%\}}|dkrq |d7}|dkrdSt||t|j|dVq dS)Nrrr )rarrr)rrqrdrrAr)rerirrr)rr5r"r# tagentriess    zsummary..tagentriesc3s|tj}fddjjD}fdd}t||dd}|ddD]\}}t||j|t|dVq&dS) Ncr r!rr"r4r"r#r r$z.summary..bookmarks..cr%r&r'r(r4r"r#r)r*z,summary..bookmarks..Tr+r9r-) rrqrAr0rrrdrr)rerimarksr1rrr4r"r#r4 s    zsummary..bookmarksc3stjd}g}g}krjjd}|D]}j|}tj|}t||d<||qt |D]}|Vq.changelistrrr7s descriptionsunknownslabelsr8stagentryrr9s shortlogentryslabel) descownerr/rr4r7rrrmrlabels)rrArrrrminconfig configlistrtr rrrvrr6rqrr hybridlist)r5r:r4rrrr@rBr")r>rr?r5r#summarys8         rGfilediffc Csd\}}z t|j|j}Wn#ty1t|j|j}t|j|jjd}||vr/Ynw|dur>| }|}| }| dd}d|jjvrT|jjd}t ||||g|}|durjt |}|}ntg}|}|j d|t|j|||dtt|j|S) a /diff/{revision}/{path} ----------------------- Show how a file changed in a particular commit. The ``filediff`` template is rendered. This handler is registered under both the ``/diff`` and ``/filediff`` paths. ``/diff`` is used in modern code. )NNr.Nr7rrH)rlrmrndiff)rH)rrCrAr/rDrr@r0rrEp1rDdiffsrxrrrtrwrr{r|)r5rTrrEbasectxstylerKrnr"r"r#filediffCsB         rNdiffs comparisonc Csrt|j|j}d|jjvrttdt|j|jjd}dd}d|jjvr1||jjd}n||dd}dd }d }| }| }| } | } t |} ||vrp||}||} ||vrgd } n||}||} n d } | |}||} t|| | }|d urt|}|}ntg}|}|j d|t|j|||t| | t| |d tt|j|S)a /comparison/{revision}/{path} ----------------------------- Show a comparison between the old and new versions of a file from changes made on a particular revision. This is similar to the ``diff`` handler. However, this form features a split or side-by-side diff rather than a unified diff. The ``context`` query string argument can be used to control the lines of context in the diff. The ``filecomparison`` template is rendered. r.sfile not givencSs|dkrdp t|S)Nsfullr;)rz)rr"r"r#r)szcomparison..scontextr7scomparisoncontextcSsP|r"ttt|dpd}td|t| fgS| S)NrrZs(binary file %s, hash: %s)) isbinaryrrKrGrHrIrErrrrrFrc)r}rWr"r"r# fileliness zcomparison..filelinesNr"filecomparison)rlrmrnleftrevleftnoderightrev rightnode comparison)rR)rrrAr/r0r r r@rDrJrrrrcomparerxrrrtrwrrr{r|)r5rrE parsecontextrerQrTparentrSrTrUrV rightlines leftlinespfctxrWrnr"r"r#rWwsZ           rWannotatec stjj}tj v}ifddfdd}t jjj dfddj Dj d |t|t|tjt|t|td ttjS) a) /annotate/{revision}/{path} --------------------------- Show changeset information for each line in a file. The ``ignorews``, ``ignorewsamount``, ``ignorewseol``, and ``ignoreblanklines`` query string arguments have the same meaning as their ``[annotate]`` config equivalents. It uses the hgrc boolean parsing logic to interpret the value. e.g. ``0`` and ``false`` are false and ``1`` and ``true`` are true. If not defined, the server default settings are used. The ``fileannotate`` template is rendered. c3s`|}|vr$g|<|D]}||d}||q|D]}|Vq(dS)N)rr)rparentsrr&)rer}rpr) parentscacher"r#r_s  zannotate..parentsc 3sVr'tttdpd}tj dd|dg}n t j jj}d}td}t|D]m\}}|j}|}||krQd} t|} nd} |}idtd|d |d |d tj|fd d |d|d|d| d| d|jd|jd|ddd|ddd|dd|Vq;dS)NrrZr r[)rTrfrVTrarrsauthorsparentsrsdescsextrar.s blockheads blockparitys targetliner^slinenor_r\r`r]srevdate)rPrrKrGrHrIrEr annotatelinerCfilerevrannotater/rArrrbrTrrdrrrrvrextrarfrVr) rerWrj previousrevblockparitygenrfaliner}r blockhead blockparity)rTr_rir5r"r#rdsr         zannotate..annotater^csi|]}|t|qSr"r)rr)diffoptsr"r# zannotate.. fileannotate)rlrdrErmrnrorprkN)rn)rrCrAr/rErrqrrr2rsdifffeatureoptsrrrtrrvrurwrxrBryrz hybriddictrr{r|)r5r}rprdr")rkrTr_rarir5r#rds.  .   rdfilelogc!sPztjj}|}|}WnVtjyhtjjj d}j |}t |}|s2t jj }|d}||krF|d}|||kr\|d8}|||ksQj|||}Ynwj}djj vrztjj d|}t|d}|jjdd<Wn tyYnwtj} tjjd} t|dd| d<tjjd} |d| d<djj v} | rЈjj d| d<| d<djj v} | rjj d| d<| d<|d}td||}t|||}tj||d }j|fd d ||dD}g}d d d jj vr-jj d dfdd }d}| dur| dusCJtj| }t g}| rZt!j"|g| R}n t!j#|g| R}t$|dD]>\}\}}d}| ry|||d}|}t%|}|&t'|| ||tj|t gd|(|||krnqhtj| | d<| d| d<nE|D],}||}d}| r||}t%|}|&t'||||t)|d|(|q|*t+j|}|,|d||}|dd} j- d||t.j|t || | t | ||| | d t/0t%j|S)a) /filelog/{revision}/{path} -------------------------- Show information about the history of a file in the repository. The ``revcount`` query string argument can be defined to control the maximum number of entries to show. The ``filelog`` template will be rendered. r.rr rrrspatchsdescendr<csg|] }|vr|qSr")linkrev)rrc)r2rAr"r#ros zfilelog..r7rNc sB|}|}|}tj|||g|d|dddS)Ns%s- ) linerange lineidprefix)rrJrErrKr)rTrtrrLrE) diffstyler5r"r#rIzszfilelog..diff)rt)rafilerevr.rO linerangerenamerx)rarwr.rOryrq) rlnavrmrdescendpatchrrtrrrr)rq)1rrCrAr/rEr2rrDr@r0rlrrrrrrrzr1rrrrrtrrcrCrrqrrDformatlinerangerrrblockdescendantsblockancestorsrbr|rrdr&rxr filerevnavrrtrwrr{)!r5rTr}flnumrevsrfirstfrevrlrangerrr|r{rr?r>rirrrIrtrzitrclrrKrEriterfctxrrr")rvr2rAr5r#r2.s                          r2sarchivec s|jjd}|dd}|jjd}|tjvr$dt|}tt |||vs9| dd|s9d|}tt |t dd tj|j}|j|}|}||ksU|d krYt|}d ||f}t|j|j} t| g|jjd } | rd | g} tj| | dd| rfdd| D} | stt d| tj|\} }}}| |jjd<d||f|jjd<|r||jjd<|jt|jrt d|j!}t"j#|j||||| dddgS)a /archive/{revision}.{format}[/{path}] ------------------------------------- Obtain an archive of repository content. The content and type of the archive is defined by a URL path parameter. ``format`` is the file extension of the archive type to be generated. e.g. ``zip`` or ``tar.bz2``. Not all archive types may be allowed by your server configuration. The optional ``path`` URL parameter controls content to include in the archive. If omitted, every file in the specified revision is present in the archive. If included, only the specified file or contents of the specified directory will be included in the archive. No template is used for this handler. Raw, binary content is generated. styper7s allow-archiversUnsupported archive type: %ssallowsArchive type not allowed: %ss\W+-rs%s-%sr.spath:r)defaultcsg|]}|r|qSr"r")rr}rr"r#rrmzarchive..sfile(s) not found: %sr9sattachment; filename=%s%sr>sContent-Encodings4sendresponse() should not emit data if writing latersarchivesubrepos)prefixrsubrepos)$r/r0r1rEr archivespecsrpprintr r r?r resubosrEbasenamereponamerArrrrrrBkeysrMrNsetbodywillwriterrRrProgrammingError getbodyfilerarchive)r5type_allowedr,msgrcnode arch_versionr rrlpatsrmimetypeartype extensionrbodyfhr"rr#rsf               rstaticcCs8|jjd}|jdddd}t|j|||j|jS)Nr.r7rF) untrusted)r/r0rDr templatepathrMrR)r5fnamestaticr"r"r#r&s  rgraphcsdjjvrtjj}tj|}njd}d}|}d}j}djjvrOztjj d|}t |d}|j j dd<Wn t yNYnwtj j d}t |dd|d<tj j d}|d|d<jj d|tj j d}|d<tj} |} tt d | d||} t d ||} tj| || } gg}d | d kr jj| d }g}|D]}||t||dkrnqt||krtjj|d g}|d d }|d tjt|}td d t|jDfddfdd}fdd}t}j d&id|d|d|d| d|d|d| d|d|d|d| d t |d!t!|d"t!|d#|d$"dd%| S)'a /graph[/{revision}] ------------------- Show information about the graphical topology of the repository. Information rendered by this handler can be used to create visual representations of repository topology. The ``revision`` URL parameter controls the starting changeset. If it's absent, the default is ``tip``. The ``revcount`` query string argument can define the number of changesets to show information for. The ``graphtop`` query string argument can specify the starting changeset for producing ``jsdata`` variable that is used for rendering graph in JavaScript. By default it has the same value as ``revision``. This handler will render the ``graph`` template. rr'rr rrsgraphtoprr;Ncs"|] }|dtjkr|VqdSr Nr CHANGESETritemr"r"r#rzgraph..cs^j}g}|dkr-jj|}tjt|}tddt |jD}|S)Nr;csrrrrr"r"r#rrz*graph..fulltree..) rArr3rr dagwalkerrbasesetrcolored)rrrdag)graphtoplastrevr5r"r#fulltrees zgraph..fulltreec3s<D]\}}}}}t|tj|||dVqdS)N)rs graphnodesvertexedges)rbytestrr getgraphnoderA)reidtypervtxedges)rr5r"r#jsdatas  zgraph..jsdatac 3stj}tD]7\}\}}}}}tj|}dd|D} ||d|ddddt|t | ||dd|Vq dS)NcSs<g|]}|d|d|dddd|d|ddqS)rr rr)colsnextcolcolorswidthsbcolorr")redger"r"r#rsz(graph..nodes..rr r)rrrarsrowsnextrow) rrqrbrr|rArrdrr) rerirowrrrrrredgedata)rr5r"r#nodess$   zgraph..nodesrrrmruprevrrdownrev graphvarsrows bg_heightrrrrrrr)r)#r/r0rrrArwrrrzr1rrrrrrrrCrrr3rr&r|rrrrrrrtrrrvr)r5rrmrrrrrrrrrrrrallrevsrrrrrrr")rrrrr5r#graph0s                      rcCs0|dj}|rt|dd}|Std}|S)Nr s(no help text available))r-r partition)rdocr"r"r#_getdocs rhelpcsddlm}m|jjd}|s{fdd}ggdd}t|jD]-\}}t |}d|vs7| d r8q&||}t |d d d rL ||fq& ||fq&  fd d} fdd} |jdt|t| t| ddS|jvrg}j|D]\} } } | d|| d f| d | dq|jdt||ddStj}d|_d|vr|dd\}}|jvrttn|}d}z j||||d}Wn tjyttw|jd||dS)a /help[/{topic}] --------------- Render help documentation. This web command is roughly equivalent to :hg:`help`. If a ``topic`` is defined, that help topic will be rendered. If not, an index of available help topics will be rendered. The ``help`` template will be rendered when requesting help for a topic. ``helptopics`` will be rendered for the index of help topics. r)r'helprc3s4jD]}|dd\}}}|d|dVqdS)Nrrtopicr8) helptable)rerrrG_doc)helpmodr"r#topicss  zhelp..topicscSs|ddS)N|r)r)sr"r"r#r)szhelp..s DEPRECATEDsdebugr helpbasicFc3 D] \}}||dVqdSNrr"rerr)earlyr"r# earlycommands zhelp..earlycommandsc3rrr"r)otherr"r# othercommandsrzhelp..othercommandss helptopicssIndex)rrrtitles%s.%s)rrr8T)rrsubindex.r N)subtopicr)topicr)r'rr/r0r1rrtablerrLrr&sortrtrrv subtopicsrrwsgiuiloadverboserr r help_rr)r5r' topicnamerprimaryrrrcmdrrrrGrurrr")rrrr#rsn       rr.)A __future__rrrGrri18nrrrrrrcommonr r r r rrrrrrrrrrrrrutilsrrr%r'objectrr6rYr~rlrr3rrrrrBrr4r7rGrNrIrWrdr2rrrrrvalues i18nfunctionsr"r"r"r#s~    4    *# "+ ]    k % +  X  0 M h # T     a