łň .ß8c@sIdZddkZddkZddkTddkTddd„ƒYZdS(sqpathmap.py: Objects to represent the PathMap file $Revision: 1.9 $ $Date: 2000/03/27 08:09:18 $ i˙˙˙˙N(t*tPathMapcBsAeZdZd„Zd„ZeidƒZd„Zd„Z RS(sYRepresents the PathMap file. Exports: PathMap ( fileName ): [ if fileName is a string -> if fileName names a readable, valid PathMap file -> return a new PathMap object representing that file else -> Log() +:= error message(s) raise IOError ] .rootURL: [ the root URL from self as a string (read-only) ] .expandShortName(name): [ if name is a string -> if name is a valid short name in self -> return the corresponding path name relative to the starting directory else -> return None ] State/Invariants: .__shortPathMap: [ a dictionary that maps each short name |-> the corresponding full path name ] cCsWtƒiƒ}|i|ƒ|tƒiƒjo!tƒid|ƒtd‚ndS(s+Constructor for the PathMap object s4Execution terminated due to errors in the `%s' file.s&There were errors in the PathMap file.N(tLogtcountt_PathMap__readFileterrortIOError(tselftfileNameterrCount((s$/u/john/projects/pystyler/pathmap.pyt__init__(s   cCs/tƒiƒ}h|_yt|ƒ}Wn+tj otƒid|ƒdSnX|iotƒidƒdSnti|i dƒƒ|_ |i ƒd}t |i ƒt |ƒjp|i dt |ƒ!|jotƒid|ƒdSnx&|ip|i |ƒ|i ƒqűW|iƒdS(s;Read the source file for self. [ if fileName is a string -> if fileName names a readable, valid PathMap file -> self.rootURL := the root URL name from that file self.__shortPathMap := a dictionary that maps each short name from that file |-> corresponding full path name else -> self := self with valid entries from that file added Log() +:= error message(s) ] s!Can't open file `%s' for reading.NsIThe path map file must contain at least one line specifying the root URL.i˙˙˙˙shttp://is9The first line of the path map file must start with `%s'.(RRt_PathMap__shortPathMaptScanRRt atEndFiletstringtrstripttabtrootURLtnextLinetlent_PathMap__readPathLinetclose(RRR tscantprefix((s$/u/john/projects/pystyler/pathmap.pyt __readFileEs,      s#^(?P\S+)\s+(?P\S+)\s*$cCs‡|i|iƒ}|djo|idƒnT|idƒ}|idƒ}|ii|ƒo|id|ƒn||i| if the line in scan is a valid path map line -> self.__shortPathMap +:= entry mapping short name |-> corresponding full path name else -> Log() +:= error message(s) ] sYValid path map lines must start with the short name, then whitespace, then the full path.tshorttfullsDuplicate short name: `%s'N(t tabReMatchtlinePattNoneRtgroupR thas_key(RRtmRR((s$/u/john/projects/pystyler/pathmap.pyt__readPathLine–s cCssti|ddƒ}t|ƒdjo|Sn |\}}yd|i||fSWntj o dSnXdS(s˛Expand a short name into a relative pathname. [ if (s has the form "spath/sfile[#anchor]") and (spath is a key in self.__shortPathMap) -> return self.__shortPathMap[spath] + "/" + sfile[#anchor] else if (s has the form "spath/sfile[#anchor]") and (spath is not a key in self.__shortPathMap) -> return None else -> return s ] t/iis%s/%sN(RtsplitRR tKeyErrorR(Rtstpiecest shortPathtfilePart((s$/u/john/projects/pystyler/pathmap.pytexpandShortNameÁs ( t__name__t __module__t__doc__R RtretcompileRRR)(((s$/u/john/projects/pystyler/pathmap.pyR s   J +((R,RR-RtlogR(((s$/u/john/projects/pystyler/pathmap.pyss