mosromgr.mostypes
This part of the module provides the classes required for classifying and managing MOS files.
MOS Type classes are typically imported like so:
from mosromgr.mostypes import MosFile
MOS objects are constructed using one of three classmethods. Either from a file path:
ro = RunningOrder.from_file('roCreate.mos.xml')
from an XML string:
with open('roCreate.mos.xml') as f:
xml = f.read()
ro = RunningOrder.from_string(xml)
or from an S3 file key:
ro = RunningOrder.from_s3(bucket_name='newsnight', mos_file_key='20200101/roCreate.mos.xml')
Similarly, objects constructed using these classmethods on the MosFile
base class will be automatically classified and an instance of the relevant class will be created:
>>> ro = MosFile.from_file('roCreate.mos.xml')
>>> ro
<RunningOrder 1000>
>>> ss = MosFile.from_file('roStorySend.mos.xml')
>>> ss
<StorySend 1001>
>>> ro = MosFile.from_string(xml1)
>>> ro
<RunningOrder 1000>
>>> ss = MosFile.from_string(xml2)
>>> ss
<StorySend 1001>
Even roElementAction
files, which require a number of different subclasses, can be classified this way:
>>> ea1 = MosFile.from_file('roElementAction1.mos.xml')
>>> ea1
<EAStorySwap 1012>
>>> ea2 = MosFile.from_string(xml)
>>> ea2
<EAItemMove 1013>
Note
Your AWS credentials must be configured to construct using the ~MosFile.from_s3
classmethod. See https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
The following classes are used to parse and manage specific types of MOS messages.
RunningOrder()
StorySend()
StoryReplace()
StoryInsert()
StoryAppend()
StoryMove()
StoryDelete()
MetaDataReplace()
ItemDelete()
ItemInsert()
ItemMoveMultiple()
ItemReplace()
ReadyToAir()
EAStoryReplace()
EAItemReplace()
EAStoryDelete()
EAItemDelete()
EAStoryInsert()
EAItemInsert()
EAStorySwap()
EAItemSwap()
EAStoryMove()
EAItemMove()
RunningOrderReplace()
RunningOrderEnd()
Since some logic is shared between MOS file management, some inheritance is used in the implementation:
MosFile()
ElementAction()