[@sdZddlZddlZddlZdddgZdddZiaddZddd Zdd dZ dd d Z dS) zCache lines from 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 /usr/lib/python3.4/linecache.pyrs" cCs iadS)zClear the cache entirely.N)cacher r r rrscCs)|tkrt|dSt||SdS)zsGet the lines for a file from the cache. Update the cache if it doesn't contain an entry for this file already.N)r updatecache)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 rr,s       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 gs zupdatecache..rrr"r&)r startswithendswithrrrgetgetattr ImportErrorr splitlinespathisabssysjoin TypeErrorAttributeErrortokenizeopen readlinesrr)r r rrbasenamenameloaderr!datadirnamefpr rrr r rrEs\  %     #     r) __doc__r/rr3__all__rrrrrrr r r rs