Python library for managing MOS running orders. Pronounced mos-ro-manager.
The library provides functionality for classifying MOS file types, processing and inspecting MOS message files, as well as merging MOS files into a running order, and providing a "completed" programme including all additions and changes made between the first message (roCreate
) and the last (roDelete
).
This can be used as a library, using the utilities provided in the mosromgr module, and the command line command cli/index
can be used to process either a directory of MOS files, or a folder within an S3 bucket.
This library was developed by the BBC News Labs team.
Warning
Note that the library is currently in beta. The API and CLI are not yet stable and may change. Once the library reaches v1.0, it will be considered stable. Please consider giving feedback
to help stabilise the API.
Inspect the contents of a MOS file:
$ mosromgr inspect -f roCreate.mos.xml
roCreate.mos.xml: RunningOrder
RO: 22:30 NEWSNIGHT 54D CORE Tue, 09.11.2021
STORY: OPENMEDIA_NCS.W1.BBC.MOS;OM_4.15749118;OM_4.15749119,4.15749118.1
STORY: OPENMEDIA_NCS.W1.BBC.MOS;OM_4.15749118;OM_4.15749121,4.15749118.3
STORY: OPENMEDIA_NCS.W1.BBC.MOS;OM_4.15749118;OM_4.15749123,4.15749118.5
$ mosromgr inspect -f roElementAction.mos.xml
roElementAction.mos.xml: EAStoryReplace
REPLACE STORY: OPENMEDIA_NCS.W1.BBC.MOS;OM_4.15749118;OM_4.15749156,4.15749118.67 WITH:
STORY: OPENMEDIA_NCS.W1.BBC.MOS;OM_4.15749118;OM_4.15749156,4.15749118.67
Merge all MOS files in directory newsnight and save in FINAL.xml
:
$ mosromgr merge -f newsnight/* -o FINAL.xml
Load a roCreate
file and view its stories:
from mosromgr.mostypes import RunningOrder
ro = RunningOrder.from_file('roCreate.mos.xml')
for story in ro.stories:
print(story.slug)
Merge a single roStorySend
(~mosromgr.mostypes.StorySend
) into a roCreate
(~mosromgr.mostypes.RunningOrder
) and output the file to a new file:
from mosromgr.mostypes import RunningOrder, StorySend
ro = RunningOrder.from_file('roCreate.mos.xml')
ss = StorySend.from_file('roStorySend.mos.xml')
ro += ss
with open('final.mos.xml', 'w') as f:
f.write(str(ro))
If you're automating this process you won't necessarily know which MOS Type to use, so you can construct an object from the base class ~mosromgr.mostypes.MosFile
which will automatically classify your file:
>>> from mosromgr.mostypes import MosFile
>>> mf1 = MosFile.from_file('roCreate.mos.xml')
>>> mf1
<RunningOrder 1000>
>>> mf2 = MosFile.from_file('roStorySend.mos.xml')
>>> mf2
<StorySend 1001>
Using ~mosromgr.moscollection.MosCollection
will sort and classify multiple MOS types of all given files, allowing you to process a collection of MOS files within a complete or partially complete programme:
from mosromgr.moscollection import MosCollection
mos_files = ['roCreate.mos.xml', 'roStorySend.mos.xml', 'roDelete.mos.xml']
mc = MosCollection.from_files(mos_files)
mc.merge()
with open('final.mos.xml', 'w') as f:
f.write(str(mc))
This documentation follows the Diátaxis system, so is split between four modes of documentation: tutorials, how-to guides, technical reference and explanation.
getting_started intro howto api/index cli/index uses changelog development feedback
genindex
modindex
search
Questions can be asked on the discussion board, and issues can be raised on the issue tracker.
Source code can be found on GitHub at github.com/bbc/mosromgr.
Contributions are welcome. Please refer to the contributing guidelines.
Licensed under the Apache License, Version 2.0.
To get in touch with the maintainers, please contact the BBC News Labs team: bbcnewslabsteam@bbc.co.uk