e fq@sdZddlZddlZddlZdddgZdddZiaddZddd Zdd dZ dd d Z dS) zCache lines from Python source files. This is intended to read lines from modules imported -- hence if a filename is not found, it will look down the module search path for a file by that name. Ngetline clearcache checkcachecCsEt||}d|ko,t|knr=||dSdSdS)N)getlineslen)filenamelinenomodule_globalslinesr ./opt/alt/python34/lib64/python3.4/linecache.pyrs" cCs iadS)zClear the cache entirely.N)cacher r r rrsc CsM|tkrt|dSyt||SWntk rHtgSYnXdS)zGet the lines for a Python source file from the cache. Update the cache if it doesn't contain an entry for this file already.N)r updatecache MemoryErrorr)r r r r rr"s   rc Cs|dkr!ttj}n|tkr9|g}ndSx|D]}t|\}}}}|dkrrqDnytj|}Wntk rt|=wDYnX||jks||jkrDt|=qDqDWdS)zUDiscard cache entries that are out of date. (This is not checked upon each call!)N)listrkeysosstatOSErrorst_sizest_mtime)r filenamessizemtimer fullnamerr r rr0s       c"Cs_|tkrt|=n| s;|jdr?|jdr?gS|}ytj|}Wnktk r|}|r3d|kr3|jd}|d}t|dd}|r3|r3y||}Wnttfk rYq0X|dkrgSt |ddd|j D|ft| __loader____name__ get_sourceNcSsg|]}|dqS) r ).0liner r r ks zupdatecache..rrr#r')r startswithendswithrrrgetgetattr ImportErrorr splitlinespathisabssysjoin TypeErrorAttributeErrortokenizeopen readlinesrr)r r rrbasenamenameloaderr"datadirnamefpr rrr r rrIs\  %     #     r) __doc__r0rr4__all__rrrrrrr r r rs