;ò : äCc@sÛdkZdkZdkZdkZdkZdkZdkZdklZl Z l Z l Z dkl Z l Z dkTdkZdklZdkTdklZdkZdkTd„Zd„Zd„Zd „Zd „Zd „Zd d „Zd„Zd„Zd„Z d„Z!d„Z"d„Z#d„Z$d„Z%e&ddd„Z'hddd„Z(dd„Z)d„Z*d„Z+e&e&e&d„Z,de&d„Z-d„Z.d „Z/d!„Z0d"„Z1d#„Z2d$„Z3d%„Z4d&„Z5d'„Z6e&d(„Z7e&d)„Z8d*„Z9d+„Z:d,„Z;d-„Z<hgggd.d/„Z=e&d0„Z>e&d1„Z?e&a@d2„ZAe&aBd3„ZCd4„ZDdkEZEdd5„ZFde&d6„ZGd7„ZHd8„ZId d d d9„ZJd d:„ZKdS(;N(s str2dictlistslist2strs dictlist2strs listitem2str(sdictlist_expands parse_attr(s*(s recipe_error(sgetworkcCs}t|ƒ}ti|ddƒ}ti|ddƒ}ti|ddƒ}ti|ddƒ}ti|d d ƒ}|Sd S( síUsed to turn the result of a Python expression into a string. For a list the elements are separated with a space. "None" is changed to an empty string. Dollars are doubled to avoid them being recognized as variables.s$s$$s#s$#s>s$(gt)s}|d}tii|ƒ otii |ƒ|d|id ƒ} | o#d kl}||d|ƒ} q¿n| o!ti| ƒd ||g} n |g} x„| D]|} |id| ƒo|d| }Pn|o|iid| ƒo|id| }Pnt || ƒ}|oPq÷q÷W|tjotgtdƒ|ƒq©nd}ti|dƒ} | djo/| ti|dƒjo| ti|dƒjo|| |} n ||} |idƒo9t i it i i | ƒ|dt i i!| ƒƒ} n| SdS(s¤ Turn one file name to its object file name: Prepend $BDIR and add "sufname". If "attrdict" is specified, use "var_" attributes for the variables. svar_BDIRsBDIRiis..s/sposixs\s_ssuffixsfiletypes filetypehint(s ft_detectsrecdictsvar_ssrcitem2obj(): $%s not setss.sprefixN("sgetworksrecdicts find_nodesnamesnodesattrdictshas_keysbdirs attributessget_var_val_intsislensosspathsjoinsobjsufssufnamesautosNonesfts get_ftypesgetsFiletypes ft_detectsstringsupperslssns recipe_errors_srfindsnsdirnamesbasename(srecdictsnamesattrdictssufnamesautosobjsufs ft_detectsbdirsnodesftsislsnssn((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys srcitem2objsfe  !   ? !cCsÔtdtiddƒ}dtdtiddƒ}t|ƒ}xK|D]C}|d}|i |ƒdjot i i ||ƒ|dsN(smapsdictlist_expands str2dictlists var2stringsl(sl((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys expand2list scCstgt|ƒƒSdS(s4Turn a variable with a string value into a dictlist.N(s str2dictlists var2stringsl(sl((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys var2dictlistscCsttgt|ƒƒƒSdS(s.Like var2dictlist() but also expand wildcards.N(sdictlist_expands str2dictlists var2stringsl(sl((s./mnt/gmirror/ports/devel/aap/work/RecPython.pysexpand2dictlistscCsUd}xD|D]<}|dddgjo|d|d}q ||}q W|SdS(s@Escape wildcard characters in "l" so that they are not expanded.ss*s?s[s]N(sresslsc(slsressc((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys wildescapescCsd}yttii|ƒƒ}Wn6tj o*}t |t dƒ|t |ƒƒn¥Xg}y|iƒ}Wn6tj o*}t |t dƒ|t |ƒƒnX|iƒxG|D]?}ti|ƒ}|o|ddjo|d|}q»q»Wti|ƒ}|SdS(sN Read a file, remove comment lines and turn the result into one line. ssCannot open "%s": sError reading "%s": is#s N(sressopensosspaths expandusersfnamesfs StandardErrorses msg_errorsrecdicts_sstrsliness readlinesscloseslsstringsstripslstrip(sfnamesrecdictsesfslinesslsres((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys file2string&s&&& cCs~|o|}|}nti}|}t|ƒ}|i|ƒ}|o.|i ƒodSn|i ƒodSqvndSdS(smReturn zero if target "arg1" has no dependencies, one if it has and two if it also has build commands.iiiN( sarg2sarg1srecdictstargetsGlobalsglobalssgetworksworks find_nodesnodesget_build_dependenciessget_dependencies(sarg1sarg2snodesrecdictstargetswork((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys has_targetCs      cCs^ti}ttd|ddƒƒ}t|ƒ}x#|D]}||jodSq7q7WdSdS(se Return non-zero if an entry in "targetlist" is one of the targets Aap was started with. is_nos TARGETARGiN( sGlobalsglobalssrecdictsvar2lists get_var_valslstargetsstlistsx(stargetssrecdictslsxstlist((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys has_targetargYs    cCsbtii}t|ƒdjodSnx0|D](}|ddddgj odSq.q.WdSdS(s Return non-zero if there is a build target. Return zero if there are only fetch or cleanup targets, no need to run configure. iiscleans cleanmorescleanALLsfetchN(sGlobalscmd_argsstargetsslslensi(sisl((s./mnt/gmirror/ports/devel/aap/work/RecPython.pyshas_build_targetjs  cCstiƒSdS(s=Return the name of a temporary file which is for private use.N(stempfilesmktemp(((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys tempfnameyscCsKt|ƒdjo|ddjodkl}|d|jSndSdS(s: Return non-zero if "arg" is a supported feature. iis:(s aap_cmd_namesN(slensargsProcesss aap_cmd_names(sargs aap_cmd_names((s./mnt/gmirror/ports/devel/aap/work/RecPython.pysaap_hass $ sc CsÄdkl} ti}d|} |o| dtd„|ƒ} n|o| dtd„|ƒ} nt i | | ƒg|||d|d|d|d |ƒ} t i|| ƒ|| _| Sd S( s Define an action. (sRecPossdefine_action(%s)s from %scCs |d|S(Ns,(sxsy(sxsy((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys˜ss to %ssintypessouttypessdefer_var_namess outfilenameN(sRecPossGlobalsglobalssrecdictsactionsssintypessreducesouttypessActionsattrscommandssdefer_var_namess outfilenamesactsaction_add_to_dictsprimary( sactionsprimaryscommandssattrsintypessouttypessdefer_var_namess outfilenamesrecdictsRecPossssact((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys define_action‹s      cCsti|dd|ƒSdS(sˆ Find action object(s) by name and return a list of the supported input types. Restrict to actions that support "outtype". isouttypeN(sActions get_ftypessnamesouttype(snamesouttype((s./mnt/gmirror/ports/devel/aap/work/RecPython.pysaction_in_types¤scCsti|dd|ƒSdS(sˆ Find action object(s) by name and return a list of the supported output types. Restrict to actions that support "intype". isintypeN(sActions get_ftypessnamesintype(snamesintype((s./mnt/gmirror/ports/devel/aap/work/RecPython.pysaction_out_types«sc Cs­ti}d|}y#ti|tiƒ odSnWn dSnXt|joti|ti ƒ oPt d|dƒ}| p|ddjo|ddjot adSq¸nt ati ƒ} yti|ƒWn:tj o.}t|tdƒ|t|ƒƒdSnXd|}zltid ti ƒo!d kl}|d||ƒn2t|g|ƒ}| ottd ƒ|‚nWd ti| ƒX|ad Sd S(sÙ Try using the BSD port system for the package "name". "target" is "install" to install and "all" to build only. Will ask the user when root permissions are required. Returns non-zero for success. s /usr/ports/%sis The %s port appears to exist. s3Do you want to become root and use the port? (y/n) sysYsCannot cd to %ssmake %ss/(s aap_systems %s failedNi(sGlobalsglobalssrecdictsnamesdirnamesossaccesssR_OKs lastportnamesW_OKs raw_inputsrsNonesgetcwdscwdschdirs StandardErrorses msg_errors_sstrstargetscmdsCommandss aap_systems do_as_rootsress UserError( snamestargetsrecdictscmdsesrsress aap_systemsdirnamescwd((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys do_BSD_port¶sB   $*  !   cCsti}xQ|D]I}t|ƒdjpt|ƒdjotdƒ||fGHdSqqWy6tii dƒ odSnt dƒ odSnWn dSnXt |joti dti ƒ oPtdd |ƒ}| p|dd jo|dd jota dSqnta |d joZd |}ti dti ƒo!dkl}|d||ƒnt|g|ƒdGHn|a dSdS(så Try using the Debian apt-get command for the package "name". "target" is "install" to install and "all" to, eh, do nothing. Will ask the user when root permissions are required. Returns non-zero for success. i is+Illegal character '%s' in package name '%s'is/etc/debian_versionsapt-gets/s: This appears to be a Debian system and apt-get is found. s=Do you want to become root and install the %s package? (y/n) sysYsinstallsapt-get install %s(s aap_systemsapt-get finishediN(sGlobalsglobalssrecdictsnamescsords_sosspathsisfiles program_paths lastpkgnamesaccesssW_OKs raw_inputsrsNonestargetscmdsCommandss aap_systems do_as_root(snamestargetsrecdictscscmdsrs aap_system((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys do_Debian_pkgðs< &  $*     cCs!tidtiƒoddfSntƒ}|otii|ƒ}nttdƒ|tdƒtdƒtdƒ|tdƒtd ƒtd ƒƒ}|ol|d d jp|d d jot gtdƒƒn|d djp|d djocttdƒƒ}x8|o|ddjp|ddjo|d }qWtii |ƒ}nA|d djo d}n&|d djo |}n d dfS|ddjo|ddjo|d}n|d djp|d djod|fSnd |fSnd dfSdS(s˜ Ask the user where to install package "name". Return a boolean, indicating whether ":asroot" is to be used, and the prefix to be used. s/is /usr/local/s Select where to install %s: s+1. become root and install in "/usr/local" s32. become root and install in a specified location s'3. install in your home directory "%s" s#4. install in a specified location sq. quit schoice: isqsQsask_prefix() aborteds2s4sEnter directory name: iÿÿÿÿs s s1s3ss\N(sossaccesssW_OKshome_dirshomespathsdirnames raw_inputs_snamesrs recipe_errorsadirs expanduser(snamesadirsrshome((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys ask_prefix$s6 V"")   ""c Csidtifd„ƒY}dk}||iƒƒ}t|ƒti j o dk l }|g|ƒ}nxí|D]å}yt |ƒ}Wn8tj o,}tgtdƒ|t|ƒfƒnXyO|o|itii|ƒƒn|i|iƒƒ|iƒ|iƒWn8tj o,}tgtdƒ|t|ƒfƒnX|iƒqrW|iƒSdS(sÈ Function to extract a list of image file names from HTML files. Only relative file names are supported, because a relative file name means the file can be found when testing locally. s ImgHTMLParsercBs/tZdd„Zd„Zd„Zd„ZRS(NicCs#tii|||ƒg|_dS(N(shtmllibs HTMLParsers__init__sselfs formattersverbosesimg_list(sselfs formattersverbose((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys__init__]scCs ||_dS(N(sdirsselfsimg_dir(sselfsdir((s./mnt/gmirror/ports/devel/aap/work/RecPython.pysset_dir`sc GsŸ|o”dkl}||ƒ\}}}|djotii|ƒ oMtiitii |i |ƒƒ}||i j o|i i|ƒq—q›ndS(N(s url_split3s(ssrcsRemotes url_split3sschemesmachspathsossisabssnormpathsjoinsselfsimg_dirsnsimg_listsappend( sselfssrcsaltsargss url_split3snspathsschemesmach((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys handle_imagecs !$cCs |iSdS(N(sselfsimg_list(sself((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys get_img_listms(s__name__s __module__s__init__sset_dirs handle_images get_img_list(((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys ImgHTMLParser\s   N(sstr2lists,get_html_images(): Cannot open file "%s": %ss.get_html_images(): Error parsing file "%s": %s(shtmllibs HTMLParsers ImgHTMLParsers formatters NullFormattersparserstypesfilesstypessListTypesDictlistsstr2listsfnamesopensfs StandardErrorses recipe_errors_sstrsadd_dirsset_dirsosspathsdirnamesfeedsreadsclosesresets get_img_list( sfilessadd_dirsesfsparsersfnames ImgHTMLParsers formattersstr2list((s./mnt/gmirror/ports/devel/aap/work/RecPython.pysget_html_imagesVs.  ( (cCsztg|ƒ} | dd}tg|ƒ} | dd}t|tdƒ|ƒht |ƒd<}g} |t jot|dƒ}nxŒt|dƒt|dƒ|gD]i}tg|ƒ} xQ| D]I}|d} t| ƒdjo| d djo| i| dƒqÊqÊWq®Wd d g} d }xh|o`d}xS|iƒD]E}||djo.d }d ||. When "flags" is given use this instead of $CFLAGS. Use $CXXFLAGS for C++. isnamesScanning "%s" for dependenciessCFLAGSsCPPFLAGSsINCLUDEis-Is/usr/local/includes /usr/includeisws$Cannot create dependency file "%s": s%s : s s&Cannot write to dependency file "%s": N(&s str2dictlists sourcestrsdlssources targetstrstargetsmsg_infosrecdicts_s full_fnamesscanneds localpathlistsflagssNonesget_var_val_intsnsalsaslensappendsglobalpathlistsfoundskeyssfnames _scan_c_fileslocalsopensfsIOErrorses msg_errorsstrswrites fname_foldsks listitem2strs shorten_namesclose(srecdicts sourcestrs targetstrslocalsflagssalsscannedssourcesfnames localpathlistsdlsglobalpathlistsasestargetsfsksnsfound((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys aap_depend_csV " $    & !cCsld„} d„}y(tii|ƒ oJdkl}y|d||ƒWqst |t d|ƒƒdSqsXntii |ƒ}|djo d}nt |ƒ}t |t d ƒ|ƒxwnoo|iƒ}| oPnd}t|ƒd } x>|| jo||d jp||d jo|d }qûW|| jo||djoÝ|d }x>|| jo||d jp||d jo|d }qdW|||d!djovt||dƒ}t|ƒ} || joF||} | djp| djo| o| djo d} n|d }|}x-|| jo||| jo|d }q<W|| jo||| jot|||!ƒ}| djo|g||}n ||}| ||ƒ} | o|t|ƒ||ƒ} n| o|i!| ƒ o| || . Use the paths in "localpathlist" and "globalpathlist" to find included files. cCsjtii|ƒo|SnxD|D]<}tii||ƒ}tii|ƒot |ƒSq"q"Wt SdS(s<Search for included file "fname" in list of dirs "pathlist".N( sosspathsisabssfnamespathlistsadirsjoinsfsexistss full_fnamesNone(spathlistsfnamesadirsf((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys search_pathÖscCs°|i|ƒ}|o|iidƒp |iƒo|Snxg|D]_}t i i ||ƒ}|i|ƒ}|o|iidƒp |iƒot |ƒSqEqEWtSdS(s· Search for included file "fname" in the list of nodes. Accept a node only if it has a "fetch" attribute or dependencies. Use "pathlist" if necessary. sfetchN(sworks find_nodesfnamesns attributessgetsget_dependenciesspathlistsadirsosspathsjoinsfs full_fnamesNone(sworkspathlistsfnamesadirsfsn((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys search_targetàs''(s aap_updateisCannot find included file "%s"Nss.sScanning "%s" for dependenciesii s s s#isincludes"s($s search_paths search_targetsosspathsexistssfnamesCommandss aap_updatesrecdicts msg_extras_sdirnamesmypathsopensfsreadlineslinesislensmin_lens skip_whitesline_lensquoteslocalsss fname_foldsnames localpathlistsglobalpathlistspathlistsfnsgetworksscannedshas_keysIOErrorsclose(srecdictsfnamesscannedslocals localpathlistsglobalpathlists search_targetspathlistsisfnsline_lensmin_lensquotes search_pathslinesnamesfs aap_updatesssmypath((s./mnt/gmirror/ports/devel/aap/work/RecPython.pys _scan_c_fileÏsx       / /   "      ,cCs'dkl}|tƒ|ddƒSdS(s¢Get the md5 checksum as a hexdigest for file "file". Used in the recipe generated with ":mkdownload". Returns "unknown" when the file can't be read.(s check_md5smsgiN(sSigns check_md5sglobalssfname(sfnames check_md5((s./mnt/gmirror/ports/devel/aap/work/RecPython.pysget_md5=s c Cs½dkl}dkl} dkl} ti}|o| dƒg}nO| dƒg}|o8t d|ddƒ}| ot |td ƒƒq˜nt d|dd ƒ}| o d }nt||ƒ}t|ƒd jotgtd ƒ|ƒntiitii|ƒ|ddƒ}t d|ddƒ}|oHx |ddjo|d }qDWtiitii|ƒ|ƒ}nx-t||ƒD]}|d}|o!t|ƒdjo|ddjo!tii|d|dƒ}n|}|i dƒoMtii||i dƒƒ}|i dƒot |tdƒ|ƒqn6|i dƒo%tii|tii!|ƒƒ}n|i dƒo"tii||i dƒƒ} n"tii|tii#|ƒƒ} | | ƒ\}}}|oÉ|djot |tdƒ| ƒqµtii&| ƒoŠt'ƒot(|tdƒ| ƒqÁy(t(|tdƒ| ƒti)| ƒWqÁt*j o*}t |tdƒ| t,|ƒƒqÁXqµq™|djo|otii&|ƒ o€t'ƒot(|tdƒ|ƒqmt(|td ƒ|ƒyti-|ƒWqmt*j o }tgtd!ƒ|ƒqmXn|i d"ƒo d}n6|i d#ƒot/|i d#ƒƒ}n t/|ƒ}|o|o|i d$ƒ } t'ƒoqt(|td%ƒ|| fƒ| ot(|td&ƒ| ƒn|djo!t(|td'ƒ|| fƒqµq™|djp| o |djoœt2ƒ} |||d hd|