
    3j                        d Z ddlmZ ddlmZmZ ddlZddlmZ ddlm	Z	  edg d      Z
 ed	g d
      Z G d de	j                        Zedk(  rddlZ ej                          yy)zU
This is a lightweight module that stores information about individual corpus works.
    )annotations)
namedtupleOrderedDictN)common)prebase
CorpusWorktitlefilesvirtual
CorpusFilepathr
   filenameformatextc                  $    e Zd ZdZddZd Zd Zy)DirectoryInformationz
    returns information about a directory in a Corpus.  Called from corpus.corpora.Corpus

    only tested with CoreCorpus so far.
    Nc                z    || _         || _        || _        t               | _        || _        | j                          y N)directoryNamedirectoryTitle
isComposerr   workscorpusObject	findWorks)selfdirNamedirTitler   r   s        @/DATA/.local/lib/python3.12/site-packages/music21/corpus/work.py__init__zDirectoryInformation.__init__"   s4    $&$ ]
(    c                ,    t        | j                        S r   )strr   )r   s    r    _reprInternalz"DirectoryInformation._reprInternal,   s    4%%&&r"   c                   | j                   j                          | j                  j                  | j                        }|D ]  }	 t        |      j                  | j                  d      \  }}|j                  t        j                        r|t        t        j                        d }|j                  t        j                        }t        j                  |d         \  }}|||d   }n|d   j                  |d      }|| j                   vr>t        j                   |      j#                         }	t%        |	g d	      | j                   |<   t        j                  |d         \  }}t        j&                  j)                  t        | j                        |      }
|d   }d}	|	8t        j                   |d   j                  |d            }	|	j#                         }	t+        |
|	|||
      }| j                   |   j,                  j/                  |        | j                   S # t        $ r t        d|d| j                         Y w xY w)a  
        Populate other information about the directory such as
        files and filenames.

        >>> di = corpus.work.DirectoryInformation('schoenberg',
        ...             corpusObject=corpus.corpora.CoreCorpus())
        >>> di.findWorks()
        OrderedDict([('opus19', CorpusWork(title='Opus 19',
                                    files=[CorpusFile(path='schoenberg...opus19...movement2.mxl',
                                                        title='Movement 2',
                                                        filename='movement2.mxl',
                                                        format='musicxml',
                                                        ext='.mxl'),
                                            CorpusFile(path='schoenberg...opus19...movement6.mxl',
                                                        title='Movement 6',
                                                        filename='movement6.mxl',
                                                        format='musicxml',
                                                        ext='.mxl')],
                                    virtual=False))])

        (The ellipses in the documentation above represent '/' on Mac/Unix systems and
        '\' on Windows.)
           zError in processing path:zdirectoryName:Nr    Fr	   r   )r   clearr   getComposerr   r$   split
ValueErrorprint
startswithosseplenr   findFormatExtFilereplacespaceCamelCaser
   r   r   joinr   r   append)r   r   r   junkfileStubfileComponents	m21Formatr   workStubr
   
corpusPathcorpusFileName	fileTuples                r    r   zDirectoryInformation.findWorks/   s	   0 	

!!--d.@.@AD!$T1C1CQ!Gh
 ""266*#CKL1%^^BFF3N $55nR6HINIs{  )!,)!,44S"=tzz)--h7==?'1RQV'W

8$#55nR6HINIsc$*<*<&=xHJ+B/NE }--"2&..sB79"
%.*3>IJJx &&--i8] ` zzU  149I4K]K]^s   (H&&!I
I)r)   r)   TN)__name__
__module____qualname____doc__r!   r%   r    r"   r    r   r      s    'Kr"   r   __main__)rC   
__future__r   collectionsr   r   r0   music21r   r   r   r   ProtoM21Objectr   r@   mainTestrD   r"   r    <module>rK      sl    # / 	   &CD
&TU
_711 _H zG r"   