§
    ƒØjÞ)  ã                  óÚ   — d Z ddlmZ g d¢ZddlmZ ddlZddlZej	        rddl
mZ g d¢Zg d¢Zg d	¢Zdd„Zd„ Zedd„¦   «         Zd„ Zd„ Zd„ Zedk    rddlZ ej        ¦   «          dS dS )zQ
Utilities for working with file formats.

almost everything here is deprecated.
é    )Úannotations)	ÚfindSubConverterForFormatÚ
findFormatÚfindInputExtensionÚfindFormatFileÚfindFormatExtFileÚfindFormatExtURLÚVALID_SHOW_FORMATSÚVALID_WRITE_FORMATSÚVALID_AUTO_DOWNLOAD)ÚcacheN)ÚSubConverter)ÚmusicxmlÚlilypondÚtextÚtextlineÚmidiÚpngÚpdfÚsvgúlily.pdfúlily.pngúlily.svgÚbrailleÚvexflowúvexflow.htmlú
vexflow.jsÚipythonúipython.pngúipython.midiúmusicxml.pngúmusicxml.pdf)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   Úrntxt)ÚaskÚdenyÚallowÚfmtÚstrÚreturnútype[SubConverter] | Nonec                óÒ   — |                       ¦   «                              ¦   «         } ddlm} |                     ¦   «                              ¦   «         }|D ]}|j        }| |v r|c S ŒdS )a–  
    return a converter.subConverter.SubConverter subclass
    for a given format -- this is a music21 format name,
    not a file extension. Or returns None

    >>> common.findSubConverterForFormat('musicxml')
    <class 'music21.converter.subConverters.ConverterMusicXML'>

    >>> common.findSubConverterForFormat('text')
    <class 'music21.converter.subConverters.ConverterText'>

    >>> common.findSubConverterForFormat('romantext')
    <class 'music21.converter.subConverters.ConverterRomanText'>

    Some subConverters have format aliases

    >>> common.findSubConverterForFormat('t')
    <class 'music21.converter.subConverters.ConverterText'>

    r   ©Ú	converterN)ÚlowerÚstripÚmusic21r-   Ú	ConverterÚsubConvertersListÚregisterFormats)r'   r-   ÚsclÚscÚformatss        ú‹/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/music21/common/formats.pyr   r   ;   s   € ð* �)Š)‰+Œ+×
Ò
Ñ
Ô
€CØ!Ð!Ð!Ð!Ð!Ð!Ø
×
Ò
Ñ
Ô
×
1Ò
1Ñ
3Ô
3€CØð ð ˆØÔ$ˆØ�'ˆ>ˆ>ØˆIˆIˆIð àˆ4ó    c                ó  — ddl m} |                     ¦   «         }|                     | ¦  «        }|€dS |                     ¦   «         }||         }|j        rd|j        d         z   }n|j        rd|j        d         z   }nd}||fS )a‘  
    Given a format defined either by a format name, abbreviation, or
    an extension, return the regularized format name as well as
    the output extensions.

    DEPRECATED May 2014 -- moving to converter

    All but the first element of the tuple are deprecated for use, since
    the extension can vary by subConverter (e.g., lily.png)

    >>> common.findFormat('.mxl')
    ('musicxml', '.musicxml')
    >>> common.findFormat('musicxml')
    ('musicxml', '.musicxml')
    >>> common.findFormat('lily')
    ('lilypond', '.ly')
    >>> common.findFormat('lily.png')
    ('lilypond', '.ly')
    >>> common.findFormat('humdrum')
    ('humdrum', '.krn')
    >>> common.findFormat('txt')
    ('text', '.txt')
    >>> common.findFormat('textline')
    ('textline', '.txt')
    >>> common.findFormat('midi')
    ('midi', '.mid')
    >>> common.findFormat('abc')
    ('abc', '.abc')
    >>> common.findFormat('scl')
    ('scala', '.scl')
    >>> common.findFormat('braille')
    ('braille', '.txt')
    >>> common.findFormat('vexflow')
    ('vexflow', '.html')
    >>> common.findFormat('capx')
    ('capella', '.capx')

    Works the same whether you have a leading dot or not:

    >>> common.findFormat('md')
    ('musedata', '.md')
    >>> common.findFormat('.md')
    ('musedata', '.md')

    If you give something we can't deal with, returns a Tuple of None, None:

    >>> common.findFormat('wpd')
    (None, None)
    r   r,   N©NNú.)r0   r-   r1   ÚregularizeFormatÚgetSubConverterFormatsÚregisterOutputExtensionsÚregisterInputExtensions)r'   r-   ÚcÚ
fileFormatÚscfr5   ÚfirstOutputs          r7   r   r   [   s®   € ð~ "Ð!Ð!Ð!Ð!Ð!Ø×ÒÑÔ€AØ×#Ò# CÑ(Ô(€JØÐØˆ|Ø
×
"Ò
"Ñ
$Ô
$€CØ	ˆZŒ€Bà	Ô"ð Ø˜BÔ7¸Ô:Ñ:ˆˆØ	Ô	#ð Ø˜BÔ6°qÔ9Ñ9ˆˆàˆà�{Ð"Ð"r8   útuple[str, ...]c                ón  — ddl m} |                      ¦   «                              ¦   «         } |                      d¦  «        r
| dd…         } t          | ¦  «        }|€�g }|                     ¦   «                              ¦   «         D ]X}| |j        vrŒ|j        D ]1}|                     d¦  «        sd|z   }| 	                    |¦  «         Œ2|rt          |¦  «        c S ŒYt          |¦  «        S g }|j        D ]1}|                     d¦  «        sd|z   }| 	                    |¦  «         Œ2t          |¦  «        S )ab  
    Will be fully deprecated when there's an exact equivalent in converter.

    Given an input format or music21 format, find and return all possible
    input extensions.

    >>> a = common.findInputExtension('musicxml')
    >>> a
    ('.xml', '.mxl', '.musicxml')
    >>> a = common.findInputExtension('humdrum')
    >>> a
    ('.krn',)
    >>> common.findInputExtension('musedata')
    ('.md', '.musedata', '.zip')

    Leading dots don't matter:

    >>> common.findInputExtension('.mxl')
    ('.xml', '.mxl', '.musicxml')

    Blah is not a format

    >>> common.findInputExtension('blah')
    ()
    r   r,   r;   é   N)r0   r-   r.   r/   Ú
startswithr   r1   r2   r?   ÚappendÚtuple)r'   r-   r5   ÚpostÚexts        r7   r   r   ­   se  € ð6 "Ð!Ð!Ð!Ð!Ð!Ø
�)Š)‰+Œ+×
Ò
Ñ
Ô
€CØ
‡~‚~�cÑÔð Ø�!�"�"Œgˆå	" 3Ñ	'Ô	'€BØ	€zàˆØ×%Ò%Ñ'Ô'×9Ò9Ñ;Ô;ð 	#ð 	#ˆBØ˜"Ô4Ð4Ð4ØØÔ1ð !ð !�Ø—~’~ cÑ*Ô*ð $Ø ™)�CØ—’˜CÑ Ô Ð Ð Øð #Ý˜T‘{”{Ð"Ð"Ð"ð#å�T‰{Œ{Ðð ˆØÔ-ð 	ð 	ˆCØ—>’> #Ñ&Ô&ð  Ø˜C‘i�Ø�KŠK˜ÑÔÐÐÝ�T‰{Œ{Ðr8   c                ó�   — t          | t          j        ¦  «        st          j        | ¦  «        } t          | j        ¦  «        \  }}|S )aÓ  
    Given a file path (relative or absolute) return the format

    DEPRECATED May 2014 -- moving to converter

    >>> common.findFormatFile('test.xml')
    'musicxml'
    >>> common.findFormatFile('long/file/path/test-2009.03.02.xml')
    'musicxml'
    >>> common.findFormatFile('long/file/path.intermediate.png/test-2009.03.xml')
    'musicxml'

    On a windows networked filesystem
    >>> common.findFormatFile(r'\\long\file\path\test.krn')
    'humdrum'
    ©Ú
isinstanceÚpathlibÚPathr   Úsuffix)Úfpr'   Ú
unused_exts      r7   r   r   ç   s?   € õ" �b�'œ,Ñ'Ô'ð ÝŒ\˜"ÑÔˆÝ  ¤Ñ+Ô+�O€CˆØ€Jr8   c                ó¦   — t          | t          j        ¦  «        st          j        | ¦  «        } t          | j        ¦  «        \  }}|€dS || j        fS )aÙ  
    Given a file path (relative or absolute)
    find format and extension used (not the output extension)

    DEPRECATED May 2014 -- moving to converter

    >>> common.findFormatExtFile('test.mxl')
    ('musicxml', '.mxl')
    >>> common.findFormatExtFile('long/file/path/test-2009.03.02.xml')
    ('musicxml', '.xml')
    >>> common.findFormatExtFile('long/file/path.intermediate.png/test-2009.03.xml')
    ('musicxml', '.xml')

    >>> common.findFormatExtFile('test')
    (None, None)

    Windows drive
    >>> common.findFormatExtFile('d:/long/file/path/test.xml')
    ('musicxml', '.xml')

    On a windows networked filesystem
    >>> common.findFormatExtFile(r'\\long\file\path\test.krn')
    ('humdrum', '.krn')
    Nr:   rM   )rR   rA   Úunused_extOuts      r7   r   r      sS   € õ2 �b�'œ,Ñ'Ô'ð ÝŒ\˜"ÑÔˆå *¨2¬9Ñ 5Ô 5Ñ€J�ØÐØˆ|à˜BœIÐ&Ð&r8   c                ó   — ddl m} d}d| v rd}nfd| v rd}n_d| v sd	| v rd
}nT|                     ¦   «                              ¦   «         D ]-}|j        }|D ]!}|                      d|z   ¦  «        rd|z   } nŒ"Œ.|�t          |¦  «        \  }}||fS dS )aN  
    Given a URL, attempt to find the extension.
    This may scrub arguments in a URL, or simply look at the last characters.

    DEPRECATED May 2014 -- moving to converter

    >>> urlA = 'http://somesite.com/?l=cc/schubert/piano/d0576&file=d0576-06.krn&f=xml'
    >>> urlB = 'http://somesite.com/cgi-bin/ksdata?l=cc/schubert/d0576&file=d0576-06.krn&f=kern'
    >>> urlC = 'http://somesite.com/cgi-bin/ksdata?l=cc/bach/cello&file=bwv1007-01.krn&f=xml'
    >>> urlF = 'https://junk'
    >>> urlM = 'http://somesite.com/files/mid001.mid'

    >>> common.findFormatExtURL(urlA)
    ('musicxml', '.xml')
    >>> common.findFormatExtURL(urlB)
    ('humdrum', '.krn')
    >>> common.findFormatExtURL(urlC)
    ('musicxml', '.xml')
    >>> common.findFormatExtURL(urlF)
    (None, None)
    >>> common.findFormatExtURL(urlM)
    ('midi', '.mid')
    r   r,   Nz=xmlz.xmlz=kernz.krnzformat=stage2zformat=stage1z.mdr;   r:   )r0   r-   r1   r2   r?   Úendswithr   )Úurlr-   rK   r5   Ú
inputTypesÚ	extSamplerA   Úunused_junks           r7   r	   r	   %  sç   € ð0 "Ð!Ð!Ð!Ð!Ð!Ø
€Cà�€}€}ØˆˆØ	�CˆˆØˆˆà	˜CÐ	Ð	 ?°cÐ#9Ð#9Øˆˆà×%Ò%Ñ'Ô'×9Ò9Ñ;Ô;ð 	ð 	ˆBØÔ3ˆJØ'ð ð �	Ø—<’<  i¡Ñ0Ô0ð Ø 	™/�CØ�Eðøð
 €Ý",¨S¡/¤/Ñˆ
�KØ˜3ˆÐàˆzr8   Ú__main__)r'   r(   r)   r*   )r'   r(   r)   rD   )Ú__doc__Ú
__future__r   Ú__all__Ú	functoolsr   rO   ÚtypingÚtÚTYPE_CHECKINGÚmusic21.converter.subConvertersr   r
   r   r   r   r   r   r   r   r	   Ú__name__r0   ÚmainTest© r8   r7   ú<module>rh      sZ  ððð ð
 #Ð "Ð "Ð "Ð "Ð "ð
ð 
ð 
€ð Ð Ð Ð Ð Ð Ø €€€Ø Ð Ð Ð ð „?ð =Ø<Ð<Ð<Ð<Ð<Ð<ð
6ð 6ð 6Ð ð ð  ð  Ð ð /Ð.Ð.Ð ð
ð ð ð ð@N#ð N#ð N#ðd ð4ð 4ð 4ñ „ð4ðrð ð ð2 'ð  'ð  'ðJ/ð /ð /ðd ˆzÒÐØ€N€N€NØ€GÔÑÔÐÐÐð Ðr8   