
    rh4                        S r SSKJr  SSKJrJr  SSKrSSKJr  SSKJ	r	  \" S/ SQ5      r
\" S	/ S
Q5      r " S S\	R                  5      r\S:X  a  SSKr\R                  " 5         gg)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                  .    \ rS rSrSrSS jrS rS rSrg)	DirectoryInformation   z|
returns information about a directory in a Corpus.  Called from corpus.corpora.Corpus

only tested with CoreCorpus so far.
Nc                r    Xl         X l        X0l        [        5       U l        X@l        U R                  5         g N)directoryNamedirectoryTitle
isComposerr   workscorpusObject	findWorks)selfdirNamedirTitler   r   s        M/home/james-whalen/.local/lib/python3.13/site-packages/music21/corpus/work.py__init__DirectoryInformation.__init__#   s,    $&$ ]
(    c                ,    [        U R                  5      $ r   )strr   )r   s    r!   _reprInternal"DirectoryInformation._reprInternal-   s    4%%&&r$   c           	        U R                   R                  5         U R                  R                  U R                  5      nU GH  n [        U5      R                  U R                  S5      u  p4UR                  [        R                  5      (       a  U[        [        R                  5      S nUR                  [        R                  5      n[        R                  " US   5      u  pgUc  M  Uc  US   nOUS   R                  US5      nXR                   ;  a<  [        R                   " U5      R#                  5       n	[%        U	/ SS	9U R                   U'   [        R                  " US   5      u  pg[        R&                  R)                  [        U R                  5      U5      n
US   nSn	U	c9  [        R                   " US   R                  US5      5      n	U	R#                  5       n	[+        XUXgS
9nU R                   U   R,                  R/                  U5        GM     U R                   $ ! [         a    [        SUSU R                  5         GM  f = f)ah  
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   DirectoryInformation.findWorks0   s    0 	

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

8$#55nR6HINI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   r   r   r   )r,   r,   TN)	__name__
__module____qualname____firstlineno____doc__r"   r'   r   __static_attributes__ r$   r!   r   r      s    'Kr$   r   __main__)rH   
__future__r   collectionsr   r   r3   music21r   r   r   r   ProtoM21Objectr   rD   mainTestrJ   r$   r!   <module>rQ      sj    # / 	   &CD
&TU
_711 _H z r$   