
    <iD                         S r SSKr SSKJr  SSKrSSKr " S S\R                  5      r
SS jrSS jrg! \ a	    SSKJr   N6f = f)	ag  
Toolkit for exporting descriptors to other formats.

**Module Overview:**

::

  export_csv - Exports descriptors to a CSV
  export_csv_file - Writes exported CSV output to a file

.. deprecated:: 1.7.0

   This module will likely be removed in Stem 2.0 due to lack of usage. If you
   use this modle please `let me know <https://www.atagar.com/contact/>`_.
    N)StringIOc                       \ rS rSrSrSrg)_ExportDialect   
 N)__name__
__module____qualname____firstlineno__lineterminator__static_attributes__r       P/home/james-whalen/.local/lib/python3.13/site-packages/stem/descriptor/export.pyr   r      s    .r   r   c                 P    [        5       n[        X@XU5        UR                  5       $ )aB  
Provides a newline separated CSV for one or more descriptors. If simply
provided with descriptors then the CSV contains all of its attributes,
labeled with a header row. Either 'included_fields' or 'excluded_fields' can
be used for more granular control over its attributes and the order.

:param Descriptor,list descriptors: either a
  :class:`~stem.descriptor.Descriptor` or list of descriptors to be exported
:param list included_fields: attributes to include in the csv
:param list excluded_fields: attributes to exclude from the csv
:param bool header: if **True** then the first line will be a comma separated
  list of the attribute names (**only supported in python 2.7 and higher**)

:returns: **str** of the CSV for the descriptors, one per line
:raises: **ValueError** if descriptors contain more than one descriptor type
)r   export_csv_filegetvalue)descriptorsincluded_fieldsexcluded_fieldsheaderoutput_buffers        r   
export_csvr   #   s'    $ *--oPVW				!!r   c           
         [        U[        R                  R                  5      (       a  U4nU(       d  g[	        US   5      nUR
                  n[        U5      n[        [        US   5      R                  5       5      nU(       a4  U H-  nX;  d  M
  [        U< SU< SSR                  U5      < 35      e   O)U V	s/ s H  oR                  S5      (       a  M  U	PM     nn	U H  n UR                  U5        M     [        R                  " X[!        5       SS9n
U(       a3  [        R"                  R%                  5       (       d  U
R'                  5         U H  n[        U[        R                  R                  5      (       d!  [        S	[	        U5      R
                  -  5      eU[	        U5      :w  a  [        S
U< S[	        U5      < S35      eU
R)                  [        U5      5        M     gs  sn	f ! [         a     GM  f = f)a  
Similar to :func:`stem.descriptor.export.export_csv`, except that the CSV is
written directly to a file.

:param file output_file: file to be written to
:param Descriptor,list descriptors: either a
  :class:`~stem.descriptor.Descriptor` or list of descriptors to be exported
:param list included_fields: attributes to include in the csv
:param list excluded_fields: attributes to exclude from the csv
:param bool header: if **True** then the first line will be a comma separated
  list of the attribute names (**only supported in python 2.7 and higher**)

:returns: **str** of the CSV for the descriptors, one per line
:raises: **ValueError** if descriptors contain more than one descriptor type
Nr   z does not have a 'z' attribute, valid fields are: z, _ignore)dialectextrasactionz?Unable to export a descriptor CSV since %s is not a descriptor.zcTo export a descriptor CSV all of the descriptors must be of the same type. First descriptor was a z but we later got a .)
isinstancestem
descriptor
Descriptortyper	   listsortedvarskeys
ValueErrorjoin
startswithremovecsv
DictWriterr   prereq_is_python_26writeheaderwriterow)output_filer   r   r   r   descriptor_typedescriptor_type_label	desc_attrfieldattrwriterdescs               r   r   r   :   s   " T__7788.K	
Q(/)22)/ T+a.)..01) 		Vkmrtxt}t}  H  uI  J  K  	K ! )2N	9Mt	ONeU#  >>+.BRaij&DKK--//
ddDOO6677X[_`d[e[n[nnoo	DJ	&  Zo  qu  vz  q{  |  }  }
OODJ  O
  
s   >G0G0)G55
HH)r   r   T)__doc__r-   	cStringIOr   ImportErroriostem.descriptorr!   stem.prereqexcelr   r   r   r   r   r   <module>rB      sN        SYY ".9 E  s   6 AA