Skip to main content

Python library for managing MOS running orders

Project description

Python library for managing MOS running orders. Pronounced mos-ro-manager.

https://mosromgr.readthedocs.io/en/latest/_images/mos.jpg

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 mosromgr 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.

Usage

Command line

Inspect a MOS file:

$ mosromgr inspect -f 53783448-roStoryReplace.mos.xml
53783448-roStoryReplace.mos.xml: StoryReplace
REPLACE STORY: OM_5.765650;OM_5.765654,5.765650.7 WITH:
    STORY: OM_5.765650;OM_5.765654,5.765650.7

Merge all MOS files in directory newsnight and save in FINAL.xml:

$ mosromgr merge -f newsnight/* -o FINAL.xml

Library

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 into a roCreate 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 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 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))

Documentation

Comprehensive documentation is provided at https://mosromgr.readthedocs.io/

The documentation follows the Diátaxis system, so is split between four modes of documentation: tutorials, how-to guides, technical reference and explanation.

Issues and questions

Questions can be asked on the discussion board, and issues can be raised on the issue tracker.

Contributing

Source code can be found on GitHub at github.com/bbc/mosromgr.

Contributions are welcome. Please refer to the contributing guidelines.

Contributors

Licence

Licensed under the Apache License, Version 2.0.

Contact

To get in touch with the maintainers, please contact the BBC News Labs team: bbcnewslabsteam@bbc.co.uk

https://mosromgr.readthedocs.io/en/latest/_images/bbcnewslabs.png

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mosromgr-0.10.0.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

mosromgr-0.10.0-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file mosromgr-0.10.0.tar.gz.

File metadata

  • Download URL: mosromgr-0.10.0.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.12.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

File hashes

Hashes for mosromgr-0.10.0.tar.gz
Algorithm Hash digest
SHA256 95b6eacc7e44335efb5bd8ffbc0ee005bc5c80bf49eea8ff1193aac2f04606f8
MD5 b9c1dc6571925c4e93f25c5c614195ea
BLAKE2b-256 096ae7d085600e4226398032862cef8482d5c7a176d06f06ae85038ec512d1d1

See more details on using hashes here.

Provenance

File details

Details for the file mosromgr-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: mosromgr-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.12.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

File hashes

Hashes for mosromgr-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ffc5eda172cfa352e07cdaadfeba9270ab6fc72c3b3a83dbd97a30c5b9183790
MD5 0043488dee55059e4562f36f99c2a430
BLAKE2b-256 ec9d153bb92e14798723daac88935ef1b393e559a8dd8827619cde241ae60cf9

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page