Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
ó
¦‹EYc@s	dZddlZddlZddlZddlmZddlmZdefd„ƒYZ	de	fd„ƒYZ
d	e	fd
„ƒYZed„Z
d„Zd
„Zd„Zd„Zdefd„ƒYZd„Zd„Zdd„Zdd„Zd„ZdS(sÛUtility functions for use in templates / controllers

*PLEASE NOTE*: Many of these functions expect an initialized RequestConfig
object. This is expected to have been initialized for EACH REQUEST by the web
framework.

iÿÿÿÿN(turllib(trequest_configtRoutesExceptioncBseZdZRS(sTossed during Route exceptions(t__name__t
__module__t__doc__(((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyRstMatchExceptioncBseZdZRS(s%Tossed during URL matching exceptions(RRR(((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyRstGenerationExceptioncBseZdZRS(s'Tossed during URL generation exceptions(RRR(((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyRsc	Cs©|j}xEtj|ƒD]4\}}t|tjƒr|j|ƒ||<qqW|jrz|jrz|rzt|||ƒS|jrŽ|rŽ|St	|j
dƒ|ƒ}|rÑ|jdƒrÑ|dd|d<|S|rðd|krðd|d<n|j
dƒ}|r|djƒ}	ni}	gtj|ƒD]\}}
|
dkr.|^q.}x%|D]}||=|	j|dƒqYW|	j|ƒ|jr¥t|	||ƒ}	n|	S(sÝ
    Private function that takes a dict, and screens it against the current
    request dict to determine what the dict should look like that is used.
    This is responsible for the requests "memory" of the current.
    t
controllert/itactiontindexswsgiorg.routing_argsN(tencodingtsixt	iteritemst
isinstancet	text_typetencodetexplicittsub_domainst_subdomain_checkt
as_unicodetgett
startswithtcopytNonetpoptupdate(tkargstmappertenvirontforce_explicitRtkeytvaltcontroller_namet
route_argstmemory_kargstvaluet
empty_keys((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyt_screenargss4	
4

	cCsw|jro|jddƒ}t|tjƒr<t|ƒ}n|jdƒpW|jdƒ}|sd|S|jdƒ}|d}d}t	|ƒdkrª|d|d7}nt
jd|j|ƒ}|rÕ|j
ƒn	d|f\}	}
t||jƒ}|r3|	|kr3||jkr3|d	|
||d
<n8||jksN|dkrk|
|krk|
||d
<n|S|SdS(srScreen the kargs for a subdomain and alter it appropriately depending
    on the current subdomain or lack therof.t
sub_domaint	HTTP_HOSTtSERVER_NAMEt:itis
^(.+?)\.(%s)$t.t_hostN(RRRRR
RtstrRtsplittlentretmatchtdomain_matchtgroupsRRtsub_domains_ignore(RRRt	subdomaintfullhostt	hostmatchthosttportR3thost_subdomaintdomain((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyRMs.	
$cCs|r`t|tjƒr*|j|ƒ}qlt|tjƒrE|}qltj|ƒj|ƒ}nt|ƒ}tjj|dƒS(s+A Unicode handling version of urllib.quote.R	(RR
RRR/Rtparsetquote(tstringRts((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyt
_url_quoteps	cCsd|r`t|tjƒr*|j|ƒ}q`t|tjƒrE|}q`tj|ƒj|ƒ}n|S(N(RR
RR(R@RRA((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyt_str_encodes	cOs|jdƒ}|jdƒ}|jddƒ}|jddƒ}xWddgD]I}|j|ƒrn||=n|d|krO|j|dƒ||<qOqOWd|krµ||d<ntƒ}d}t}	|jj}
d}t|ƒdkr|jjj|dƒ}|s t	}	|d}n|j
d	ƒrit|d
ƒri|jjdƒri|jjdƒ|}n|	r|r|d7}g}xìt
j|ƒD]Û\}}
t|
ttfƒrx·|
D]Y}|jd
tjjt
j|ƒj|
ƒƒtjjt
j|ƒj|
ƒƒfƒq½Wq•|jd
tjjt
j|ƒj|
ƒƒtjjt
j|
ƒj|
ƒƒfƒq•W|dj|ƒ7}qqnt|d
iƒ}d|kr|jƒ}t|ddƒ}|dk	rç|jƒ}ni}d|f|d<n|	søg}|r‰|jjr.|j|ƒn|jjƒ}|j|ƒ|jre|j|ƒ}n|jsžt ||j|ƒ}qžnt!||j|ƒ}|jddƒp³|}|jddƒpË|}|jd|ƒ}|jj"||Ž}n|dk	r|dt#||
ƒ7}n|s6|dk	s6|rÄ|r]|r]|j$j%dƒd}n|so|j$}n|dkr‡|j&}n|dkr |d7}n|dk	rÄ|d||}qÄnt'|ƒrð|dk	rðt(d|ƒ‚n|dkrt(d||fƒ‚n|S(s£Generates a URL

    All keys given to url_for are sent to the Routes Mapper instance for
    generation except for::

        anchor          specified the anchor name to be appened to the path
        host            overrides the default (current) host if provided
        protocol        overrides the default (current) protocol if provided
        qualified       creates the URL with the host/port information as
                        needed

    The URL is generated based on the rest of the keys. When generating a new
    URL, values will be used from the current request's parameters (if
    present). The following rules are used to determine when and how to keep
    the current requests parameters:

    * If the controller is present and begins with '/', no defaults are used
    * If the controller is changed, action is set to 'index' unless otherwise
      specified

    For example, if the current request yielded a dict of
    {'controller': 'blog', 'action': 'view', 'id': 2}, with the standard
    ':controller/:action/:id' route, you'd get the following results::

        url_for(id=4)                    =>  '/blog/view/4',
        url_for(controller='/admin')     =>  '/admin',
        url_for(controller='admin')      =>  '/admin/view/2'
        url_for(action='edit')           =>  '/blog/edit/2',
        url_for(action='list', id=None)  =>  '/blog/list'

    **Static and Named Routes**

    If there is a string present as the first argument, a lookup is done
    against the named routes table to see if there's any matching routes. The
    keyword defaults used with static routes will be sent in as GET query
    arg's if a route matches.

    If no route by that name is found, the string is assumed to be a raw URL.
    Should the raw URL begin with ``/`` then appropriate SCRIPT_NAME data will
    be added if present, otherwise the string will be used as the url with
    keyword args becoming GET query args.

    tanchorR:tprotocolt	qualifiedt_t	protocol_R,iR	RtSCRIPT_NAMEt?s%s=%st&swsgiorg.routing_argstmapper_dictt_anchorR.t	_protocolt#R+s//s9url_for can only return a string, got unicode instead: %ss7url_for could not generate URL. Called with args: %s %sN(()RRRRtFalseRRR1t_routenamestTrueRthasattrRR
RRtlistttupletappendRR>R?RRtjointgetattrRthardcode_namestdefaultsRtfiltertstaticRR'tgenerateRBR:R0REtascii_charactersR(targsRRDR:RERFR tconfigtrouteR\Rturlt
query_argsR!R%RRLt
match_dictR#tnewargs((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyturl_for‹s¦,

	


	!0	!-
		

tURLGeneratorcBs)eZdZd„Zd„Zd„ZRS(sThe URL Generator generates URL's

    It is automatically instantiated by the RoutesMiddleware and put
    into the ``wsgiorg.routing_args`` tuple accessible as::

        url = environ['wsgiorg.routing_args'][0][0]

    Or via the ``routes.url`` key::

        url = environ['routes.url']

    The url object may be instantiated outside of a web context for use
    in testing, however sub_domain support and fully qualified URL's
    cannot be generated without supplying a dict that must contain the
    key ``HTTP_HOST``.

    cCs/||_d|kr"d|d<n||_dS(sInstantiate the URLGenerator

        ``mapper``
            The mapper object to use when generating routes.
        ``environ``
            The environment dict used in WSGI, alternately, any dict
            that contains at least an ``HTTP_HOST`` value.

        RIR,N(RR(tselfRR((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyt__init__1s
	
cOs®|jdƒ}|jdƒ}|jddƒ}|jddƒ}xWddgD]I}|j|ƒrn||=n|d|krO|j|dƒ||<qOqOWd|krµ||d<nd}d|koÓ|jdƒ}	t}
|jj}d}t|ƒd	k}
|
r"|jjj|d	ƒ}n|r |
r t}
|d	}|j	d
ƒry|j
jdƒry|j
jdƒ|}n|
r |r|d7}g}xìtj|ƒD]Û\}}t
|ttfƒr-x·|D]Y}|jd
tjjtj|ƒj|ƒƒtjjtj|ƒj|ƒƒfƒqÍWq¥|jd
tjjtj|ƒj|ƒƒtjjtj|ƒj|ƒƒfƒq¥W|dj|ƒ7}qq n|
s8g}|rn|jjrÎ|j|ƒn|jjƒ}|j|ƒ|jr|j|ƒ}n|js"|jrÂ|jrÂ|jddƒ}t||j|j
ƒ}d|jkrk||d<qkqÂnT|	r•t||j|j
dtƒ}n-d|kr¼t||j|j
ƒ}n|}|p×|jddƒ}|pï|jddƒ}|dkr|jddƒ}n|j
|d<|jj ||Ž}n|dk	r^|dt!||ƒ7}n|sv|dk	sv|rYd|j
kr•t"|j
ƒn|j
d}|rÊ|rÊ|dj#dƒd	}n|sÝ|d}n|dkrö|d}n|dkr|d7}n|dk	rY|dd
kr8|d
7}n|d||j$d
ƒ}qYnt%|ƒr…|dk	r…t&d|ƒ‚n|dkrªt&d||fƒ‚n|S(sçGenerates a URL

        All keys given to url_for are sent to the Routes Mapper instance for
        generation except for::

            anchor          specified the anchor name to be appened to the path
            host            overrides the default (current) host if provided
            protocol        overrides the default (current) protocol if provided
            qualified       creates the URL with the host/port information as
                            needed

        RDR:RERFRGRHt_use_currentR,iR	RIRJs%s=%sRKR(RRMR.RNt_environROsroutes.cached_hostinfoR+iÿÿÿÿs//s1Can only return a string, got unicode instead: %ss/Could not generate URL. Called with args: %s %sN('RRRRPRRR1RQRRRRR
RRRTRURVRR>R?RRRWRYRZRRR[R\texternalRR'R]RBtcache_hostinfoR0tlstripR^R(RhR_RRDR:RERFR Ratuse_currentR\RRbt	more_argsRcR!R%R#Retsubthostinfo((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyt__call__@s´




!

	!0	!-
	!





!
cOs|dt||ŽS(s8Generate a route that includes params used on the current
        request

        The arguments for this method are identical to ``__call__``
        except that arguments set to None will remove existing route
        matches of the same name from the set of arguments used to
        construct a URL.
        Rj(RR(RhR_tkwargs((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pytcurrent½s	(RRRRiRsRu(((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyRgs		}cOs%t||Ž}tƒ}|j|ƒS(s6Issues a redirect based on the arguments.

    Redirect's *should* occur as a "302 Moved" header, however the web
    framework may utilize a different method.

    All arguments are passed to url_for to retrieve the appropriate URL, then
    the resulting URL it sent to the redirect function as the URL.
    (RfRtredirect(R_RttargetR`((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pytredirect_toÉs		cCs<i}|jdƒsK|jdƒdksKd|jddƒjdƒkrXd|d<n
d|d<|jd	ƒr’|d	jdd
ƒd|d<nœ|jd
ƒr²|d
|d<n||d|d<|jdƒdkr|ddkr.|dcd|d7<q.n+|ddkr.|dcd|d7<n||d<|S(sdProcesses the host information and stores a copy

    This work was previously done but wasn't stored in environ, nor is
    it guaranteed to be setup in the future (Routes 2 and beyond).

    cache_hostinfo processes environ keys that may be present to
    determine the proper host, protocol, and port information to use
    when generating routes.

    tHTTPSswsgi.url_schemethttpstHTTP_X_FORWARDED_PROTOR,s, REthttptHTTP_X_FORWARDED_HOSTiiR:R)R*tSERVER_PORTt443R+t80sroutes.cached_hostinfo(RR0(RRr((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyRm×s"$!

!
csH|dkrgSd‡fd†‰ˆ|ƒ}|jdtdtƒ|S(s=Scan a directory for python files and use them as controllersR,cs«g}xžtj|ƒD]}tjj||ƒ}tjj|ƒrmtjd|ƒrm|j||d ƒqtjj|ƒr|j	ˆ|d||dƒƒqqW|S(s!Locate controllers in a directorys^[^_]{1,1}.*\.py$iýÿÿÿtprefixR	(
tostlistdirtpathRWtisfileR2R3RVtisdirtextend(tdirnameRtcontrollerstfnametfilename(tfind_controllers(s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyRŒýsR treverseN(RtsortR1RR(t	directoryR‰((RŒs@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pytcontroller_scanøststrictcCs/|dk	r+t|tƒr+|j||ƒS|S(N(RRtbytestdecode(R%Rterrors((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyRscCs$|dkrtStd„|DƒƒS(Ncss!|]}t|ƒdkVqdS(i€N(tord(t.0tc((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pys	<genexpr>s(RRRtall(R@((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyR^s(RR‚R2R
t	six.movesRtroutesRt	ExceptionRRRRPR'RRBRCRftobjectRgRxRmRRRR^(((s@/home/tvault/.virtenv/lib/python2.7/site-packages/routes/util.pyt<module>s&0	#			”ª		!