Ñò ˆ_‚Jc @ s° d Z d d k l Z d d k Z d d k Z d d k Z d d k l Z d „ Z d „ Z d „ Z d „ Z d „ Z d e f d „ ƒ YZ d „ Z d e f d „ ƒ YZ d S( t Utilitiesiÿÿÿÿ( t configN( t resource_filenamec C sN xG t i d ƒ D]6 } | i ƒ i d ƒ o t i i | | ƒ } | Sq Wd S( Ns ./s egg-info( t ost listdirt lowert endswitht patht join( t namet dirnamet fname( ( s+ /usr/lib/python2.6/site-packages/tg/util.pyt get_project_meta s c C s? t d ƒ } | o( t t | ƒ ƒ d d d !} | i ƒ Sd S( s get project name if exists PKG-INFOi i iÿÿÿÿN( R t listt opent strip( t pkg_infoR ( ( s+ /usr/lib/python2.6/site-packages/tg/util.pyt get_project_name s c C sÊ t i d ƒ } | o | Sd t i j o? t i t i i d ƒ d } t i | ƒ } | i d ƒ } n' t d ƒ } | o t | ƒ p g } x3 | D]+ } | i ƒ } | o | d j o | Sq— Wd S( s: Try to find out the package name of the current directory.t moduless --eggi s top_level.txtt localesN( R t gett syst argvt indext pkg_resourcest get_distributiont _get_metadataR R t rstrip( t packaget projectnamet eggt top_levelR ( ( s+ /usr/lib/python2.6/site-packages/tg/util.pyt get_package_name s c C sI t ƒ } | p d St | h h d g ƒ } t | d ƒ o | i Sd S( s return modelt modelN( R t Nonet __import__t hasattrR! ( t package_nameR ( ( s+ /usr/lib/python2.6/site-packages/tg/util.pyt get_model' s c C st | d } t g } | i ƒ D]4 } | i | ƒ o | | i | ƒ | | f q q ~ ƒ } | o | St ‚ d S( s Given a dictionary and a prefix, return a Bunch, with just items that start with prefix The returned dictionary will have 'prefix.' stripped so: get_partial_dict('prefix', {'prefix.xyz':1, 'prefix.zyx':2, 'xy':3}) would return: {'xyz':1,'zyx':2} t .N( t Buncht iterkeyst startswitht lstript AttributeError( t prefixt dictionaryt matcht _[1]t keyt new_dict( ( s+ /usr/lib/python2.6/site-packages/tg/util.pyt get_partial_dict3 s :R( c B s2 e Z d Z d „ Z d „ Z e i Z d „ Z RS( s2 A dictionary that provides attribute-style access.c C s t i | | ƒ S( N( t dictt __getitem__( t selfR1 ( ( s+ /usr/lib/python2.6/site-packages/tg/util.pyR5 M s c C s0 y | | SWn t j o t | | ƒ SXd S( N( t KeyErrorR3 ( R6 R ( ( s+ /usr/lib/python2.6/site-packages/tg/util.pyt __getattr__P s c C s1 y | | =Wn t j o t | ƒ ‚ n Xd S( N( R7 R, ( R6 R ( ( s+ /usr/lib/python2.6/site-packages/tg/util.pyt __delattr__X s ( t __name__t __module__t __doc__R5 R8 R4 t __setitem__t __setattr__R9 ( ( ( s+ /usr/lib/python2.6/site-packages/tg/util.pyR( J s c s- | d ‰ | d ‰ ‡ ‡ ‡ f d † } | S( Ni i c s0 ˆ | } ˆ i ƒ } | i | ƒ ˆ | | Ž S( N( t copyt update( t call_time_argst call_time_kwdst argst kwds( t create_time_argst funct create_time_kwds( s+ /usr/lib/python2.6/site-packages/tg/util.pyt curried_functionb s ( ( RC RG RH ( ( RG RE RF s+ /usr/lib/python2.6/site-packages/tg/util.pyt partial_ s t DottedFileNameFinderc B s# e Z d Z d „ Z d d „ Z RS( su this class implements a cache system above the get_dotted_filename function and is designed to be stuffed inside the app_globals. It exposes a method named get_dotted_filename with the exact same signature as the function of the same name in this module. The reason is that is uses this function itself and just adds caching mechanism on top. c C s t ƒ | _ d S( N( R4 t _DottedFileNameFinder__cache( R6 ( ( s+ /usr/lib/python2.6/site-packages/tg/util.pyt __init__t s s .htmlc C sˆ y | i | SWnr t j of | i d ƒ } | d j o/ | | } | | d | } t | | ƒ } n | } | | i | <| SXd S( sa this helper function is designed to search a template or any other file by python module name. Given a string containing the file/template name passed to the @expose decorator we will return a resource useable as a filename even if the file is in fact inside a zipped egg. The actual implementation is a revamp of the Genshi buffet support plugin, but could be used with any kind a file inside a python package. @param template_name: the string representation of the template name as it has been given by the user on his @expose decorator. Basically this will be a string in the form of: "genshi:myapp.templates.somename" @type template_name: string @param template_extension: the extension we excpect the template to have, this MUST be the full extension as returned by the os.path.splitext function. This means it should contain the dot. ie: '.html' This argument is optional and the default value if nothing is provided will be '.html' @type template_extension: string R' i i N( RK R7 t rfindR ( R6 t template_namet template_extensiont dividerR t basenamet result( ( s+ /usr/lib/python2.6/site-packages/tg/util.pyt get_dotted_filenamew s ( R: R; R<