MOS Types
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 from_s3()
classmethod. See https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
MOS message classes
The following classes are used to parse and manage specific types of MOS messages.
RunningOrder
- class mosromgr.mostypes.RunningOrder[source]
Bases:
MosFileA
RunningOrderobject is created from aroCreateMOS file and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().Specification: Create Running Order
- __add__(other: MosFile)[source]
RunningOrderobjects can be merged with other MOS files which implement amergemethod by using the+operator, for example:ro = RunningOrder.from_file('roCreate.mos.xml') ss = StorySend.from_file('roStorySend.mos.xml') ro += ss
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property body: List[Union[Item, str]]
A list of elements found in the story bodies. Each item in the list is either a string (representing a
<p>tag) or anItemobject (representing an<item>tag). Unlikescript, this does not exclude empty paragraph tags.
- property completed: bool
Whether or not the running order has had a
RunningOrderEndmerged
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
StorySend
- class mosromgr.mostypes.StorySend[source]
Bases:
MosFileA
StorySendobject is created from aroStorySendMOS file and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().StorySendobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Send Story information, including Body of the Story
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
StoryReplace
- class mosromgr.mostypes.StoryReplace[source]
Bases:
MosFileA
StoryReplaceobject is created from aroStoryReplaceMOS file and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().StoryReplaceobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Replace a Story with Another in a Running Order
The roStoryReplace message replaces the referenced story with another story or stories. This messages also replaces all items associated with the original story or stories.
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
StoryInsert
- class mosromgr.mostypes.StoryInsert[source]
Bases:
MosFileA
StoryInsertobject is created from aroStoryInsertMOS file and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().StoryInsertobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Insert Stories in Running Order
This message inserts stories and all of their defined items before the referenced story in a Running Order.
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
StoryAppend
- class mosromgr.mostypes.StoryAppend[source]
Bases:
MosFileA
StoryAppendobject is created from aroStoryAppendMOS file and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().StoryAppendobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Append Stories to Running Order
The roStoryAppend message appends stories and all of their defined items at the end of a running order.
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
StoryMove
- class mosromgr.mostypes.StoryMove[source]
Bases:
MosFileA
StoryMoveobject is created from aroStoryMoveMOS file and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().StoryMoveobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Move a story to a new position in the Playlist
This message allows a story to be moved to a new location in a playlist. The first storyID is the ID of the story to be moved. The second storyID is the ID of the story above which the first story is to be moved.
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
StoryDelete
- class mosromgr.mostypes.StoryDelete[source]
Bases:
MosFileA
StoryDeleteobject is created from aroStoryDeleteMOS file and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().StoryDeleteobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Delete Stories from Running Order
The roStoryDelete message deletes the referenced Stories and all associated Items from the Running Order.
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
MetaDataReplace
- class mosromgr.mostypes.MetaDataReplace[source]
Bases:
MosFileA
MetaDataReplaceobject is created from aroMetadataReplaceMOS file and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().MetaDataReplaceobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Replace RO metadata without deleting the RO structure
If metadata tags in the roMetadataReplace message already exist in the target RO, values within the RO will be replaced by the values in the roMetadataReplace message.
If the metadata tags do not already exist in the target RO they will be added.
If a mosExternalMetadata block is included in the roMetadataReplace message, it will replace an existing mosExternalMetadata block only if the values of mosSchema in the two blocks match. Otherwise the mosExternalMetadata block will be added to the target RO.
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
ItemDelete
- class mosromgr.mostypes.ItemDelete[source]
Bases:
MosFileAn
ItemDeleteobject is created from aroItemDeleteMOS file and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().ItemDeleteobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Delete Items in Story
The roItemDelete message deletes one or more items in a story.
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
ItemInsert
- class mosromgr.mostypes.ItemInsert[source]
Bases:
MosFileAn
ItemInsertobject is created from aroItemInsertMOS file and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().ItemInsertobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Insert Items in Story
This message allows one or more items to be inserted before a referenced item in a story in the playlist. The first itemID is the ID of the item before which to insert the new items. If the first itemID is blank, the items are inserted at the end of the story.
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
ItemMoveMultiple
- class mosromgr.mostypes.ItemMoveMultiple[source]
Bases:
MosFileAn
ItemMoveMultipleobject is created from aroItemMoveMultipleMOS file and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().ItemMoveMultipleobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Move one or more Items to a specified position within a Story
The roItemMoveMultiple message allows one or more items in a story to be moved to a new location in the story. The last itemID is the ID of the item before which to insert the new items. All remaining itemIDs identify items to insert at that location. The resulting story has all the moved items appearing before the reference item in the order specified in the command. If the last itemID is blank, the items are moved to the end of the story.
There may be no duplicates in the list of itemIDs. This prevents the move from being ambiguous; if two itemIDs are the same, it is unclear where in the story the item with that ID must be placed.
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
ItemReplace
- class mosromgr.mostypes.ItemReplace[source]
Bases:
MosFileAn
ItemReplaceobject is created from aroItemReplaceMOS file and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().ItemReplaceobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Replace an Item with one or more Items in a Story
The roItemReplace message replaces the referenced item in a story with one or more items.
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
ReadyToAir
- class mosromgr.mostypes.ReadyToAir[source]
Bases:
MosFileA
ReadyToAirobject is created from aroReadyToAirMOS file and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().ReadyToAirobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Identify a Running Order as Ready to Air
The roReadyToAir message allows the NCS to signal the MOS that a Running Order has been editorially approved ready for air.
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.Currently unimplemented - has no effect on the running order. TODO: #18
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
EAStoryReplace
- class mosromgr.mostypes.EAStoryReplace[source]
Bases:
ElementActionAn
EAStoryReplaceobject is created from aroElementActionMOS file containing a story replacement, and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().EAStoryReplaceobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Replacing a story
In element_target: A storyID specifying the story to be replaced
In element_source: One or more stories to put in its place
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
EAItemReplace
- class mosromgr.mostypes.EAItemReplace[source]
Bases:
ElementActionAn
EAItemReplaceobject is created from aroElementActionMOS file containing an item replacement, and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().EAItemReplaceobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Replacing an item
In element_target: A storyID and itemID specifying the item to be replaced
In element_source: One or more items to put in its place
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
EAStoryDelete
- class mosromgr.mostypes.EAStoryDelete[source]
Bases:
ElementActionAn
EAStoryDeleteobject is created from aroElementActionMOS file containing a story deletion, and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().EAStoryDeleteobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Deleting stories
In element_target: Not needed, since deletes don’t happen relative to another story
In element_source: One or more storyIDs specifying the stories to be deleted
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
EAItemDelete
- class mosromgr.mostypes.EAItemDelete[source]
Bases:
ElementActionAn
EAItemDeleteobject is created from aroElementActionMOS file containing an item deletion, and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().EAItemDeleteobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Deleting items
In element_target: A storyID specifying the story containing the items to be deleted
In element_source: One or more itemIDs specifying the items in the story to be deleted
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
EAStoryInsert
- class mosromgr.mostypes.EAStoryInsert[source]
Bases:
ElementActionAn
EAStoryInsertobject is created from aroElementActionMOS file containing a story insertion, and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().EAStoryInsertobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Inserting stories
In element_target: A storyID specifying the story before which the source stories are inserted
In element_source: One or more stories to insert
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
EAItemInsert
- class mosromgr.mostypes.EAItemInsert[source]
Bases:
ElementActionAn
EAItemInsertobject is created from aroElementActionMOS file containing an item insertion, and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().EAItemInsertobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Inserting items
In element_target: A storyID and itemID specifying the item before which the source items are inserted
In element_source: One or more items to insert
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
EAStorySwap
- class mosromgr.mostypes.EAStorySwap[source]
Bases:
ElementActionAn
EAStorySwapobject is created from aroElementActionMOS file containing a story swap, and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().EAStorySwapobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Swapping stories
In element_target: An empty storyID tag, or the element_target tag itself is absent
In element_source: Exactly two storyIDs specifying the stories to be swapped
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
EAItemSwap
- class mosromgr.mostypes.EAItemSwap[source]
Bases:
ElementActionAn
EAItemSwapobject is created from aroElementActionMOS file containing an item swap, and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().EAItemSwapobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Swapping items
In element_target: A storyID specifying the story containing the items to be swapped
In element_source: Exactly two itemIDs specifying the items to be swapped
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
EAStoryMove
- class mosromgr.mostypes.EAStoryMove[source]
Bases:
ElementActionAn
EAStoryMoveobject is created from aroElementActionMOS file containing a story move, and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().EAStoryMoveobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Moving stories
In element_target: A storyID specifying the story before which the source stories are moved
In element_source: One or more storyIDs specifying the stories to be moved
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
EAItemMove
- class mosromgr.mostypes.EAItemMove[source]
Bases:
ElementActionAn
EAItemMoveobject is created from aroElementActionMOS file containing an item move, and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().EAItemMoveobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Moving items
In element_target: A storyID and itemID specifying the item before which the source items are moved
In element_source: One or more itemIDs specifying the items in the story to be moved
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
RunningOrderReplace
- class mosromgr.mostypes.RunningOrderReplace[source]
Bases:
RunningOrderAn
RunningOrderReplaceobject is created from aroReplaceMOS file and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().RunningOrderReplaceobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class.Specification: Replace Running Order
Replaces an existing Running Order definition in the MOS with another one sent from the NCS.
- __add__(other: MosFile)
RunningOrderobjects can be merged with other MOS files which implement amergemethod by using the+operator, for example:ro = RunningOrder.from_file('roCreate.mos.xml') ss = StorySend.from_file('roStorySend.mos.xml') ro += ss
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property body: List[Union[Item, str]]
A list of elements found in the story bodies. Each item in the list is either a string (representing a
<p>tag) or anItemobject (representing an<item>tag). Unlikescript, this does not exclude empty paragraph tags.
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
RunningOrderEnd
- class mosromgr.mostypes.RunningOrderEnd[source]
Bases:
MosFileA
RunningOrderEndobject is created from aroDeleteMOS file and can be constructed using classmethodsfrom_file(),from_string()orfrom_s3().RunningOrderEndobjects can be merged with aRunningOrderby using the+operator. This behaviour is defined in themerge()method in this class. Once aRunningOrderEndobject has been merged into aRunningOrder, the running order is considered “completed” and no further messages can be merged.Specification: Delete Running Order
- __lt__(other) bool
Sort by
message_idi.e.ro < ssorsorted([ro, ss])
- __str__()
The XML string of the MOS file
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- merge(ro: RunningOrder) RunningOrder[source]
Merge into the
RunningOrderobject provided.Adds a
mosromgrmetatag containing theroDeletetag from theroDeletemessage to theroCreatetag in the running order.
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
Base classes
Since some logic is shared between MOS file management, some inheritance is used in the implementation:
MosFile
- class mosromgr.mostypes.MosFile[source]
Base class for all MOS files
- classmethod from_file(mos_file_path: Union[Path, str])[source]
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_s3(bucket_name: str, mos_file_key: str)[source]
Construct from a MOS file in an S3 bucket
- classmethod from_string(mos_xml_string: str)[source]
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property base_tag_name
The base tag (
xml.etree.ElementTree.Element) within thexml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.
ElementAction
- class mosromgr.mostypes.ElementAction[source]
Base class for various
roElementActionMOS files.Specification: Performs specific Action on a Running Order
- classmethod from_file(mos_file_path: Union[Path, str])
Construct from a path to a MOS file
- Parameters
mos_file_path (Union[pathlib.Path, str]) – The MOS file path
- classmethod from_string(mos_xml_string: str)
Construct from an XML string of a MOS document
- Parameters
mos_xml_string (str) – The XML string of the MOS document
- property base_tag: Element
The base tag within the
xml, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodictlibrary. Useful for testing.