ó >ìˆUc@sÞddlZddlZddlZddljZddlZdefd„ƒYZdefd„ƒYZ de fd„ƒYZ de fd „ƒYZ d e fd „ƒYZ d „Zdddd „Zd„Zd„ZdS(iÿÿÿÿNt LintExceptioncBseZdZd„ZRS(sSAn exception thrown when something fatal has gone wrong during the linting.cCs t|ƒS(N(tstr(tself((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyt __unicode__%s(t__name__t __module__t__doc__R(((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyR"stDuplicateLintedAttrExceptioncBseZdZd„ZRS(s@An exception thrown when we've found duplicate pkg.linted* keys.cCs t|ƒS(N(R(R((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyR-s(RRRR(((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyR+stCheckercBs>eZdZdZdZd„Zd„Zd„Zd„ZRS(s!A base class for all lint checks. pkg.lint.engine discovers classes to create these objects according to a configuration file. Methods that implement lint checks within each Checker object must be given a 'pkglint_id' keyword argument so that the system can discover and invoke these methods during lint runs. The 'pkglint_id' is used as a short-form identifier for the lint check implemented by each method when paired with the checker 'name' attribute. Subclasses define the method signature for the check(..) method called from pkg.lint.engine.LintEngine.execute() on instances of that subclass. Subclasses not implementing a new type of lint Checker, likely those outside this base module, should not override check(..) defined in ActionChecker or ManifestChecker. Attributes for each Checker subclass include: 'name' is an abbreviated name used by the checker 'description' is a short (one sentence) description of the class.sunnamed.checkersNo description.cCs ||_g|_g|_d„}|jjddƒ}|d krNd}n |jƒ}x©tj|tjƒD]’}|d}dtj |ƒdkrpd|j |j j |j f}||ƒ}||kré|jj ||fƒq|jj ||fƒqpqpWd S( s}'config' is a ConfigParser object, see pkg.lint.engine for documentation on the keys we expect it to contain.cSsv|jj}tj|ƒ}t|jƒd}y|jjdƒ}Wntk r\d|SXd||j||fS(syInspects a given checker method to find the 'pkglint_id' keyword argument default and returns it.it pkglint_ids%s.?s%s%s( tim_classtnametinspectt getargspectlentargstindext ValueErrortdefaults(tmethodR targ_spectcti((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pytget_pkglint_idRs   tpkglintspkglint.excludetiR is%s.%s.%sN(tconfigtincluded_checkstexcluded_checkstgettNonetsplitR t getmemberstismethodR Rt __class__Rtappend(RRRtexcltitemRtvalueR ((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyt__init__Is(            cCsdS(sOCalled to initialise a given checker using the supplied engine.N((Rtengine((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pytstartup}scCsdS(N((RR(((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pytshutdown‚scCsbtƒ}tƒ}t|ƒ}x1tdt|ƒƒD]}||}|jƒ}t|ƒdkrr|j|ƒntj|tƒ} xÇt|dt|ƒƒD]¬} || } tj| jƒtƒ} | j | ƒrž| j | ƒ} | j |dt ƒ|j|ƒ|j| ƒx6| j D](}t|ƒdkr|j|ƒqqWqžqžWq4W|t|ƒfS(súGiven a set of actions, determine that none of the actions have matching variant values for any variant. We return a list of variants that conflict, and a list of the actions involved. iitassert_on_different_domains(tsettlisttrangeRtget_variant_templatetaddtvarianttVariantCombinationstTruet intersectst intersectiontsimplifytFalsetsat_set(Rtactionstpkg_varst conflict_varstconflict_actionst action_listRtactiontvartvctjt cmp_actiontcmp_varR5tk((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pytconflicting_variants…s.          ( RRRR t descriptionR'R)R*RE(((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyR0s 4  t ActionCheckercBseZdZd„ZRS(s$A class to check individual actions.cCsx|jD]õ\}}|jd|d|ƒy||||ƒWq tk rþ}|jd|d|d|ƒr©|jdi|d6|d6|jd6|d6dd ƒqÿ|jd i|d6|d6|jd6|d6dd ƒ|jtj |ƒdd ƒq Xq Wd S( sg'action' is a pkg.actions.generic.Action subclass 'manifest' is a pkg.manifest.ManifestR>tmanifesttlint_idsWChecker exception ignored from %(check)s on linted action %(action)s in %(mf)s: %(err)stchecktmfterrtmsgids pkglint001.3sHChecker exception from %(check)s on action %(action)s in %(mf)s: %(err)ss lint.errorN( Rtadvise_loggerst Exceptiontlintedtinfotfmriterrortdebugt tracebackt format_exc(RR>RHR(tfuncR RL((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyRJ°s(        (RRRRJ(((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyRG­stManifestCheckercBs eZdZd„Zd„ZRS(sJA class to check manifests. In order for proper 'pkg.linted.*' functionality, checker methods that examine individual manifest attributes, should obtain the original 'set' action that was the origin of the manifest attribute, advising the logging system of the attributes being examined, then examining the attribute, before advising the logging system that subsequent lint errors on other attributes are no longer related to that action. For example, when looking at the pkg.summary attribute, a checker method would do: action = engine.get_attr_action("pkg.summary", manifest) engine.advise_loggers(action=action, manifest=manifest) . . [ perform checks on the attribute ] . engine.advise_loggers(manifest=manifest) cCsëd|_|jddƒ|_t|_tdƒ|j|_tj j |jƒr»y,t j ƒ|_|jj t|jƒƒWqÑtk r·}tdƒi|jd6|d6|_qÑXntdƒ|j|_tt|ƒj|ƒdS(NRtinfo_classification_paths!no sections found in data file %ss+unable to parse data file %(path)s: %(err)stpathRLsmissing file %s(Rtclassification_dataRtclassification_pathR7tskip_classification_checkt_tbad_classification_datatosRZtexistst ConfigParsertSafeConfigParsertreadfptopenROtsuperRXR'(RRRL((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyR'ês(        cCsêxã|jD]Ø\}}|jd|ƒy|||ƒWq tk rá}|jd|d|ƒr“|jdi|d6|jd6|d6ddƒqâ|jd i|d6|jd6|d6dd ƒ|jtj |ƒdd ƒq Xq Wd S( s%'manifest' is a pkg.manifest.ManifestRHRIsKChecker exception ignored from %(check)s on linted manifest %(mf)s: %(err)sRJRKRLRMs pkglint001.3s3Checker exception from %(check)s on %(mf)s: %(err)ss lint.errorN( RRNRORPRQRRRSRTRURV(RRHR(RWR RL((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyRJ s$         (RRRR'RJ(((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyRXÔs "c Csßg}g}|jddƒ}|dkr3d}n |jƒ}x“tj|tjƒD]|}|d}t|tƒrU||ƒ}d|j|j f}||kp®|j|ksÁ|j |ƒqÑ|j |ƒqUqUW||fS(sµReturn a tuple of a list of Checker objects found in module, instantiating each object with the 'config' ConfigParser object, and a list of excluded Checker objects.Rspkglint.excludeRis%s.%sN( RRRR R tisclasst issubclassRRRR#( tmoduleRtcheckerstexcluded_checkerstexcludetcltmyclasstobjR ((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyt get_checkers(s       cCsR|r(|r(t||ƒp't||ƒS|r;t||ƒS|rNt||ƒStS(sÌDetermine whether a given action or manifest is marked as linted. We check for manifest or action attributes set to "true" where the attribute starts with "pkg.linted" and is a substring of pkg.linted. anchored at the start of the string. So, pkg.linted.foo matches checks for foo, foo001 foo004.5, etc. pkglint Checker methods should use pkg.lint.engine..linted() instead of this method.(t_linted_actiont_linted_manifestR7(RHR>RI((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyRPBs    cCs°d|}xŸ|jjƒD]Ž}|jdƒr|j|ƒr|jj|dƒ}t|tƒr{|jƒdkr¥tSq¨tt dƒi|d6t |ƒd6ƒ‚qqWt S(s4Determine whether a given action is marked as linteds pkg.linted.%ss pkg.lintedtfalsettrues*Multiple values for %(key)s in %(actions)stkeyR>( tattrstkeyst startswithRt isinstancet basestringtlowerR3RR^RR7(R>RIRPRutval((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyRqVs   cCs­d|}xœ|jjƒD]‹}|jdƒr|j|ƒr|jj|dƒ}t|tƒr{|jƒdkr¢tSq¥tt dƒi|d6|j d6ƒ‚qqWt S(s6Determine whether a given manifest is marked as linteds pkg.linted.%ss pkg.lintedRsRts+Multiple values for %(key)s in %(manifest)sRuRH( t attributesRwRxRRyRzR{R3RR^RRR7(RHRIRPRuR|((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyRrfs   (R tos.pathR`Rbt pkg.variantR1RURORRtobjectRRGRXRpRRPRqRr(((s3/usr/lib/python2.7/vendor-packages/pkg/lint/base.pyts     }'T