bg .dZddlmZddlZddlZddlZddlZddlZddlm Z m Z m Z m Z m Z mZddlZddlmZddlmZe rEddlmZmZe ejgee ee eefdffZe e ee efZdZd-d Zd.d ZejdZejdZejdZd/dZ d0dZ!d0dZ"dZ#dZ$dZ%de#e$ze%ze#e$e%zdZ&e#e$e%ddZ'GddZ(Gd d!Z)d1d$Z*d2d'Z+d3d)Z,d.d*Z-d4d,Z.dS)5z8Generic classes/functions for pyreverse core/extensions.) annotationsN) TYPE_CHECKINGAnyCallableOptionalTupleUnion)nodes)InferenceResult) ClassDiagramPackageDiagramz .pyreversercreturn list[str]cZg}tjdd}|rtj|t } t |d5}|}dddn #1swxYwYn#t$rYnwxYw|S)z,Read config file and return list of options.HOMEutf-8)encodingN) osenvirongetpathjoinRCFILEopenreadsplitOSError)optionshomercfile file_handles g/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pylint/pyreverse/utils.pyget_default_optionsr$!sG :>>&" % %D dF++ fw/// 5;%**,,2244 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5    D  Ns6 B'B BBBBB B('B(Nonect}||D]"}tjd|#dS)z#Insert default options to sys.argv.N)r$reversesysargvinsert)rargs r#insert_default_optionsr-/sO!##G OO   3  z^__([^\W_]_*)+__$z^__(_*[^\W_])+_?$z^_\w*$namestrct|rd}ncjtt|d|}|jt|z S)z*Return true if the node should be treated.r/)r;getattrrYVIS_MOD)rZr<r:s r# show_attrzFilterMixIn.show_attrus0#GD&$$?$?@@ ;!4444r.N)rQr0rr%)r<r^rr>)__name__ __module__ __qualname____doc__r]rbr.r#rPrPhsBAA555555r.rPc*eZdZdZd dZd dZdd Zd S) LocalsVisitora Visit a project by traversing the locals dictionary. * visit_ on entering a node, where class name is the class of the node in lower case * leave_ on leaving a node, where class name is the class of the node in lower case rr%c:i|_t|_dS)N)_cacheset_visited)rZs r#r]zLocalsVisitor.__init__sAC +.55 r.r< nodes.NodeNG_CallbackTupleTc 2|j}|j|}|l|j}t |d|t |dd}t |d|t |dd}||f|j|<n|\}}||fS)z0Get callbacks from handler for the visited node.Nvisit_ visit_defaultleave_ leave_default) __class__rkrrclowerr`)rZr<klassmethodskide_methodl_methods r# get_callbackszLocalsVisitor.get_callbackss+//%(( ?.&&((CnsnngdOT&J&JHnsnngdOT&J&JH#+H!5DK  !( Hh!!r.rcV||jvrdS|j|||}|d|d|t|dr,|D]}|||d|d|SdS)z.Launch the visit starting from the given node.Nrlocalsr')rmaddr|hasattrvaluesvisit)rZr<rx local_nodes r#rzLocalsVisitor.visits 4= 4 $$$T** 1: ! GAJt    4 " " '"kkmm ' '  :&&&& 1: !71:d## #tr.Nrr%)r<rnrro)r<rnrr)rcrdrerfr]r|rrgr.r#riri{sZ1111"""""r.riannnodes.Name | nodes.NodeNGct|tjr|j|jSt|tjr|SdS)Nr) isinstancer Namer/NodeNG as_string)rs r#get_annotation_labelrsK#uz""sx';x#u|$$}} 2r.#nodes.AssignAttr | nodes.AssignName#nodes.Name | nodes.Subscript | NonecZd}t|jtjr |jj}nt|tjri|jj} t t|j|j j }|j |jj j }n#t$rYnwxYw|S |^}}n#t j$rd}YnwxYwt%|}|r.t'|dd|dsd|dn|}|r||_ |S)z!Return the annotation for `node`.Nrvaluerz Optional[])rparentr AnnAssign annotation AssignAttrdictzipr~argsrrrr/AttributeErrorinferastroidInferenceErrorrr` startswith)r<r init_methodrdefault_labels r#get_annotationrsd C$+u// k$ D%* + +k(  s;#5{7G7STTUUK!+/$+"3"899CC    D  jjll !!  ! ! % %E  w119$$Z00: " ! ! ! !    Js%A B"" B/.B/5C C C set[InferenceResult]c~t|} |rct|tjs%t|tjr|jdkr|hSt |St |S#tj $r|r|hn t cYSwxYw)zReturn a set containing the node annotation if it exists otherwise return a set of the inferred types using the NodeNG.infer method. |) rrr SubscriptBinOpoprlrrr)r<rs r# infer_noders   C '  $#u// 3 ,, 143u syy{{## #4::<<    !'''&uu&&&'sAB B6 B"B<;B<cxtjd%tdtjddSdS)zCheck if the ``dot`` command is available on the machine. This is needed if image output is desired and ``dot`` is used to convert from *.dot or *.gv into the final output format. dotNz?'Graphviz' needs to be installed for your chosen output format. )shutilwhichrWr)exitrgr.r#check_graphviz_availabilityrs< |E" OPPP  #"r. output_formatcftjddgddd}tjd|j}|st d d S|d }||vr+t d |d |tj dd Sd S)zCheck if the ``dot`` command supports the requested output format. This is needed if image output is desired and ``dot`` is used to convert from *.gv into the final output format. rz-T?TFr)capture_outputcheckrz$.*Use one of: (?P(\S*\s?)+))patternstringzUnable to determine Graphviz supported output formats. Pyreverse will continue, but subsequent error messages regarding the output format may come from Graphviz directly.NformatszFormat z, is not supported by Graphviz. It supports: r) subprocessrunrer7rXstriprWgrouprr)r)r dot_outputr7supported_formatss r#!check_if_graphviz_supports_formatrs  t57J H7 &&((   E   K    I..-335555 dm d dQb d d     65r.)rrr)r/r0rr0)r<r=rr>)rrrr0)r<rrr)r<rrr)rr0rr%)/rf __future__rrrrrr)typingrrrrrr rr astroid.typingr pylint.pyreverse.diagramsr r r _CallbackTrorr$r-compiler6r8r9r;rDrH_SPECIAL _PROTECTED_PRIVATErUrarPrirrrrrrgr.r#rs ?>""""""  GGGGGGGGGGGGGGGG******HFFFFFFFF  eL!5)E#FLM OJHZ0(:2FFGO          "*) * * "*) * * BJy ! !     $$$$ $$$$    :%0 ( "      55555555&--------`    F''''$r.