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:
MosFile
A
RunningOrder
object is created from aroCreate
MOS file and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.Specification: Create Running Order
- __add__(other: MosFile)[source]
RunningOrder
objects can be merged with other MOS files which implement amerge
method 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_id
i.e.ro < ss
orsorted([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 anItem
object (representing an<item>
tag). Unlikescript
, this does not exclude empty paragraph tags.
- property completed: bool
Whether or not the running order has had a
RunningOrderEnd
merged
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
StorySend
- class mosromgr.mostypes.StorySend[source]
Bases:
MosFile
A
StorySend
object is created from aroStorySend
MOS file and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.StorySend
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
StoryReplace
- class mosromgr.mostypes.StoryReplace[source]
Bases:
MosFile
A
StoryReplace
object is created from aroStoryReplace
MOS file and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.StoryReplace
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
StoryInsert
- class mosromgr.mostypes.StoryInsert[source]
Bases:
MosFile
A
StoryInsert
object is created from aroStoryInsert
MOS file and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.StoryInsert
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
StoryAppend
- class mosromgr.mostypes.StoryAppend[source]
Bases:
MosFile
A
StoryAppend
object is created from aroStoryAppend
MOS file and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.StoryAppend
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
StoryMove
- class mosromgr.mostypes.StoryMove[source]
Bases:
MosFile
A
StoryMove
object is created from aroStoryMove
MOS file and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.StoryMove
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
StoryDelete
- class mosromgr.mostypes.StoryDelete[source]
Bases:
MosFile
A
StoryDelete
object is created from aroStoryDelete
MOS file and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.StoryDelete
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
MetaDataReplace
- class mosromgr.mostypes.MetaDataReplace[source]
Bases:
MosFile
A
MetaDataReplace
object is created from aroMetadataReplace
MOS file and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.MetaDataReplace
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
ItemDelete
- class mosromgr.mostypes.ItemDelete[source]
Bases:
MosFile
An
ItemDelete
object is created from aroItemDelete
MOS file and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.ItemDelete
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
ItemInsert
- class mosromgr.mostypes.ItemInsert[source]
Bases:
MosFile
An
ItemInsert
object is created from aroItemInsert
MOS file and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.ItemInsert
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
ItemMoveMultiple
- class mosromgr.mostypes.ItemMoveMultiple[source]
Bases:
MosFile
An
ItemMoveMultiple
object is created from aroItemMoveMultiple
MOS file and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.ItemMoveMultiple
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
ItemReplace
- class mosromgr.mostypes.ItemReplace[source]
Bases:
MosFile
An
ItemReplace
object is created from aroItemReplace
MOS file and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.ItemReplace
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
ReadyToAir
- class mosromgr.mostypes.ReadyToAir[source]
Bases:
MosFile
A
ReadyToAir
object is created from aroReadyToAir
MOS file and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.ReadyToAir
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object 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
xmltodict
library. Useful for testing.
EAStoryReplace
- class mosromgr.mostypes.EAStoryReplace[source]
Bases:
ElementAction
An
EAStoryReplace
object is created from aroElementAction
MOS file containing a story replacement, and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.EAStoryReplace
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
EAItemReplace
- class mosromgr.mostypes.EAItemReplace[source]
Bases:
ElementAction
An
EAItemReplace
object is created from aroElementAction
MOS file containing an item replacement, and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.EAItemReplace
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
EAStoryDelete
- class mosromgr.mostypes.EAStoryDelete[source]
Bases:
ElementAction
An
EAStoryDelete
object is created from aroElementAction
MOS file containing a story deletion, and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.EAStoryDelete
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
EAItemDelete
- class mosromgr.mostypes.EAItemDelete[source]
Bases:
ElementAction
An
EAItemDelete
object is created from aroElementAction
MOS file containing an item deletion, and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.EAItemDelete
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
EAStoryInsert
- class mosromgr.mostypes.EAStoryInsert[source]
Bases:
ElementAction
An
EAStoryInsert
object is created from aroElementAction
MOS file containing a story insertion, and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.EAStoryInsert
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
EAItemInsert
- class mosromgr.mostypes.EAItemInsert[source]
Bases:
ElementAction
An
EAItemInsert
object is created from aroElementAction
MOS file containing an item insertion, and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.EAItemInsert
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
EAStorySwap
- class mosromgr.mostypes.EAStorySwap[source]
Bases:
ElementAction
An
EAStorySwap
object is created from aroElementAction
MOS file containing a story swap, and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.EAStorySwap
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
EAItemSwap
- class mosromgr.mostypes.EAItemSwap[source]
Bases:
ElementAction
An
EAItemSwap
object is created from aroElementAction
MOS file containing an item swap, and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.EAItemSwap
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
EAStoryMove
- class mosromgr.mostypes.EAStoryMove[source]
Bases:
ElementAction
An
EAStoryMove
object is created from aroElementAction
MOS file containing a story move, and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.EAStoryMove
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
EAItemMove
- class mosromgr.mostypes.EAItemMove[source]
Bases:
ElementAction
An
EAItemMove
object is created from aroElementAction
MOS file containing an item move, and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.EAItemMove
objects can be merged with aRunningOrder
by 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.
- property base_tag: Element
The base tag within the
xml
, as determined bybase_tag_name
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
RunningOrderReplace
- class mosromgr.mostypes.RunningOrderReplace[source]
Bases:
RunningOrder
An
RunningOrderReplace
object is created from aroReplace
MOS file and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.RunningOrderReplace
objects can be merged with aRunningOrder
by 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)
RunningOrder
objects can be merged with other MOS files which implement amerge
method 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object 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 anItem
object (representing an<item>
tag). Unlikescript
, this does not exclude empty paragraph tags.
- property dict: OrderedDict
Convert XML to dictionary using
xmltodict
library. Useful for testing.
RunningOrderEnd
- class mosromgr.mostypes.RunningOrderEnd[source]
Bases:
MosFile
A
RunningOrderEnd
object is created from aroDelete
MOS file and can be constructed using classmethodsfrom_file()
,from_string()
orfrom_s3()
.RunningOrderEnd
objects can be merged with aRunningOrder
by using the+
operator. This behaviour is defined in themerge()
method in this class. Once aRunningOrderEnd
object 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_id
i.e.ro < ss
orsorted([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
RunningOrder
object provided.Adds a
mosromgrmeta
tag containing theroDelete
tag from theroDelete
message to theroCreate
tag 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
xmltodict
library. 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
xmltodict
library. Useful for testing.
ElementAction
- class mosromgr.mostypes.ElementAction[source]
Base class for various
roElementAction
MOS 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
xmltodict
library. Useful for testing.