mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2026-01-02 01:40:42 +00:00
Added a punch of type annotations
For documentation
This commit is contained in:
@@ -1,11 +1,6 @@
|
|||||||
Broadcast WAV Extension
|
Broadcast WAV Extension
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
.. module:: wavinfo
|
|
||||||
|
|
||||||
.. autoclass:: wavinfo.wave_bext_reader.WavBextReader
|
|
||||||
:members:
|
|
||||||
|
|
||||||
|
|
||||||
Notes
|
Notes
|
||||||
-----
|
-----
|
||||||
@@ -63,3 +58,14 @@ Result:
|
|||||||
Originator Time: 12:40:00
|
Originator Time: 12:40:00
|
||||||
Time Reference: 2190940753
|
Time Reference: 2190940753
|
||||||
A=PCM,F=48000,W=24,M=stereo,R=48000,T=2 Ch
|
A=PCM,F=48000,W=24,M=stereo,R=48000,T=2 Ch
|
||||||
|
|
||||||
|
|
||||||
|
Class Reference
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. module:: wavinfo
|
||||||
|
|
||||||
|
.. autoclass:: wavinfo.wave_bext_reader.WavBextReader
|
||||||
|
:members:
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
INFO Metadata
|
INFO Metadata
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
|
||||||
.. module:: wavinfo
|
|
||||||
|
|
||||||
.. autoclass:: wavinfo.wave_info_reader.WavInfoChunkReader
|
|
||||||
:members:
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Notes
|
Notes
|
||||||
-----
|
-----
|
||||||
|
|
||||||
@@ -28,5 +20,14 @@ music library software.
|
|||||||
print("INFO Comment:", bullet.info.comment)
|
print("INFO Comment:", bullet.info.comment)
|
||||||
|
|
||||||
|
|
||||||
|
Class Reference
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. module:: wavinfo
|
||||||
|
|
||||||
|
.. autoclass:: wavinfo.wave_info_reader.WavInfoChunkReader
|
||||||
|
:members:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
iXML Production Recorder Metadata
|
iXML Production Recorder Metadata
|
||||||
=================================
|
=================================
|
||||||
|
|
||||||
|
|
||||||
.. module:: wavinfo
|
|
||||||
|
|
||||||
.. autoclass:: wavinfo.wave_ixml_reader.WavIXMLFormat
|
|
||||||
:members:
|
|
||||||
|
|
||||||
|
|
||||||
Notes
|
Notes
|
||||||
-----
|
-----
|
||||||
iXML allows an XML document to be embedded in a WAV file.
|
iXML allows an XML document to be embedded in a WAV file.
|
||||||
@@ -41,4 +34,12 @@ Result:
|
|||||||
iXML File Family UID: USSDVGR1112089007124001008206300
|
iXML File Family UID: USSDVGR1112089007124001008206300
|
||||||
|
|
||||||
|
|
||||||
|
Class Reference
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. module:: wavinfo
|
||||||
|
|
||||||
|
.. autoclass:: wavinfo.wave_ixml_reader.WavIXMLFormat
|
||||||
|
:members:
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from .riff_parser import parse_chunk, ListChunkDescriptor
|
from .riff_parser import parse_chunk, ListChunkDescriptor
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
class WavInfoChunkReader:
|
class WavInfoChunkReader:
|
||||||
|
|
||||||
@@ -14,40 +15,40 @@ class WavInfoChunkReader:
|
|||||||
self.info_chunk = next((chunk for chunk in list_chunks if chunk.signature == b'INFO'), None)
|
self.info_chunk = next((chunk for chunk in list_chunks if chunk.signature == b'INFO'), None)
|
||||||
|
|
||||||
#: 'ICOP' Copyright
|
#: 'ICOP' Copyright
|
||||||
self.copyright = self._get_field(f, b'ICOP')
|
self.copyright : Optional[str] = self._get_field(f, b'ICOP')
|
||||||
#: 'IPRD' Product
|
#: 'IPRD' Product
|
||||||
self.product = self._get_field(f, b'IPRD')
|
self.product : Optional[str]= self._get_field(f, b'IPRD')
|
||||||
self.album = self.product
|
self.album : Optional[str] = self.product
|
||||||
#: 'IGNR' Genre
|
#: 'IGNR' Genre
|
||||||
self.genre = self._get_field(f, b'IGNR')
|
self.genre : Optional[str] = self._get_field(f, b'IGNR')
|
||||||
#: 'ISBJ' Supject
|
#: 'ISBJ' Supject
|
||||||
self.subject = self._get_field(f, b'ISBJ')
|
self.subject : Optional[str] = self._get_field(f, b'ISBJ')
|
||||||
#: 'IART' Artist, composer, author
|
#: 'IART' Artist, composer, author
|
||||||
self.artist = self._get_field(f, b'IART')
|
self.artist : Optional[str] = self._get_field(f, b'IART')
|
||||||
#: 'ICMT' Comment
|
#: 'ICMT' Comment
|
||||||
self.comment = self._get_field(f, b'ICMT')
|
self.comment : Optional[str] = self._get_field(f, b'ICMT')
|
||||||
#: 'ISFT' Software, encoding application
|
#: 'ISFT' Software, encoding application
|
||||||
self.software = self._get_field(f, b'ISFT')
|
self.software : Optional[str] = self._get_field(f, b'ISFT')
|
||||||
#: 'ICRD' Created date
|
#: 'ICRD' Created date
|
||||||
self.created_date = self._get_field(f, b'ICRD')
|
self.created_date : Optional[str] = self._get_field(f, b'ICRD')
|
||||||
#: 'IENG' Engineer
|
#: 'IENG' Engineer
|
||||||
self.engineer = self._get_field(f, b'IENG')
|
self.engineer : Optional[str] = self._get_field(f, b'IENG')
|
||||||
#: 'ITCH' Technician
|
#: 'ITCH' Technician
|
||||||
self.technician = self._get_field(f, b'ITCH')
|
self.technician : Optional[str] = self._get_field(f, b'ITCH')
|
||||||
#: 'IKEY' Keywords, keyword list
|
#: 'IKEY' Keywords, keyword list
|
||||||
self.keywords = self._get_field(f, b'IKEY')
|
self.keywords : Optional[str] = self._get_field(f, b'IKEY')
|
||||||
#: 'INAM' Name, title
|
#: 'INAM' Name, title
|
||||||
self.title = self._get_field(f, b'INAM')
|
self.title : Optional[str] = self._get_field(f, b'INAM')
|
||||||
#: 'ISRC' Source
|
#: 'ISRC' Source
|
||||||
self.source = self._get_field(f, b'ISRC')
|
self.source : Optional[str] = self._get_field(f, b'ISRC')
|
||||||
#: 'TAPE' Tape
|
#: 'TAPE' Tape
|
||||||
self.tape = self._get_field(f, b'TAPE')
|
self.tape : Optional[str] = self._get_field(f, b'TAPE')
|
||||||
#: 'IARL' Archival Location
|
#: 'IARL' Archival Location
|
||||||
self.archival_location = self._get_field(f, b'IARL')
|
self.archival_location : Optional[str] = self._get_field(f, b'IARL')
|
||||||
#: 'ICSM' Commissioned
|
#: 'ICSM' Commissioned
|
||||||
self.commissioned = self._get_field(f, b'ICMS')
|
self.commissioned : Optional[str] = self._get_field(f, b'ICMS')
|
||||||
|
|
||||||
def _get_field(self, f, field_ident):
|
def _get_field(self, f, field_ident) -> Optional[str]:
|
||||||
search = next(((chunk.start, chunk.length) for chunk in self.info_chunk.children if chunk.ident == field_ident),
|
search = next(((chunk.start, chunk.length) for chunk in self.info_chunk.children if chunk.ident == field_ident),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from lxml import etree as ET
|
from lxml import etree as ET
|
||||||
import io
|
import io
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
IXMLTrack = namedtuple('IXMLTrack', ['channel_index', 'interleave_index', 'name', 'function'])
|
IXMLTrack = namedtuple('IXMLTrack', ['channel_index', 'interleave_index', 'name', 'function'])
|
||||||
|
|
||||||
@@ -20,10 +20,12 @@ class WavIXMLFormat:
|
|||||||
parser = ET.XMLParser(recover=True)
|
parser = ET.XMLParser(recover=True)
|
||||||
self.parsed = ET.parse(xml_bytes, parser=parser)
|
self.parsed = ET.parse(xml_bytes, parser=parser)
|
||||||
|
|
||||||
def _get_text_value(self, xpath):
|
def _get_text_value(self, xpath) -> Optional[str]:
|
||||||
e = self.parsed.find("./" + xpath)
|
e = self.parsed.find("./" + xpath)
|
||||||
if e is not None:
|
if e is not None:
|
||||||
return e.text
|
return e.text
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def raw_xml(self):
|
def raw_xml(self):
|
||||||
@@ -46,35 +48,35 @@ class WavIXMLFormat:
|
|||||||
function=track.xpath('string(FUNCTION/text())'))
|
function=track.xpath('string(FUNCTION/text())'))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def project(self):
|
def project(self) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
The project/film name entered for the recording.
|
The project/film name entered for the recording.
|
||||||
"""
|
"""
|
||||||
return self._get_text_value("PROJECT")
|
return self._get_text_value("PROJECT")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def scene(self):
|
def scene(self) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
Scene/slate.
|
Scene/slate.
|
||||||
"""
|
"""
|
||||||
return self._get_text_value("SCENE")
|
return self._get_text_value("SCENE")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def take(self):
|
def take(self) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
Take number.
|
Take number.
|
||||||
"""
|
"""
|
||||||
return self._get_text_value("TAKE")
|
return self._get_text_value("TAKE")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tape(self):
|
def tape(self) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
Tape name.
|
Tape name.
|
||||||
"""
|
"""
|
||||||
return self._get_text_value("TAPE")
|
return self._get_text_value("TAPE")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def family_uid(self):
|
def family_uid(self) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
The globally-unique ID for this file family. This may be in the format
|
The globally-unique ID for this file family. This may be in the format
|
||||||
of a GUID, or an EBU Rec 9 source identifier, or some other dumb number.
|
of a GUID, or an EBU Rec 9 source identifier, or some other dumb number.
|
||||||
@@ -82,7 +84,7 @@ class WavIXMLFormat:
|
|||||||
return self._get_text_value("FILE_SET/FAMILY_UID")
|
return self._get_text_value("FILE_SET/FAMILY_UID")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def family_name(self):
|
def family_name(self) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
The name of this file's file family.
|
The name of this file's file family.
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user