Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to output mpd as a string, and associated test #22

Merged
merged 5 commits into from
Apr 30, 2019

Conversation

davemevans
Copy link
Collaborator

I'm using python-mpegdash to do some simple transformation of a manifest before forwarding elsewhere for consumption. Currently python-mpegdash can only output to a file, but it seems overkill for me to create a temporary file for writing the output, only to immediately re-read the contents.

This patch adds xml string output to the parser.

The test is convoluted and a bit pointless, but proves the output is reversable and repeatable.

@sangwonl
Copy link
Owner

@davemevans thanks for your endless contribution.

The ci test result in this PR is saying. It's because python2.6 test limitation on max diff string of assertEqual. You can add self.maxDiff = None for the test case class.

======================================================================
FAIL: test_mpd2xmlstr (test_mpdtoxml.MPD2XMLTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/caststack/python-mpegdash/tests/test_mpdtoxml.py", line 42, in test_mpd2xmlstr
    self.assertEqual(xmlstrout, xmlstrout2)
AssertionError: '<?xm[188 chars]     ad/\n        </BaseURL>\n        <Adaptat[3031 chars]D>\n' != '<?xm[188 chars]     \n            ad/\n        \n        </Ba[3303 chars]D>\n'
Diff is 3640 characters long. Set self.maxDiff to None to see it.

@davemevans
Copy link
Collaborator Author

I'll take a look when I have a minute, though I don't have a Python 2.6 env to test in.

To be honest, the test is fairly pointless so the answer may just be to remove it 😉

@davemevans
Copy link
Collaborator Author

Hmm, so it looks like there is some additional whitespace added around text content in Python 2.6 only. I'll have a think.

@davemevans
Copy link
Collaborator Author

minidom's writexml changed between 2.6 and 2.7 - compare https://github.com/python/cpython/blob/2.6/Lib/xml/dom/minidom.py#L814 and https://github.com/python/cpython/blob/2.7/Lib/xml/dom/minidom.py#L806 - causing this behaviour.

I'll try to figure out some workaround ...

@davemevans
Copy link
Collaborator Author

OK, tests now pass! 🎉 Please take a look.

Apologies for the large number of commits - might be worth squashing on commit 😉

@sangwonl sangwonl merged commit cf24ec8 into sangwonl:master Apr 30, 2019
@davemevans davemevans deleted the AddPrettyStringOutput branch April 30, 2019 02:35
masantiago pushed a commit to masantiago/python-mpegdash that referenced this pull request Aug 17, 2021
* Add UTCTiming support

* Add messageData attribute to Event

* Add method to output mpd as a string, and associated test (sangwonl#22)

* Add method to output mpd as a string, and associated test

* Add debugging option in test to see whats happening on Python2.6

* provide own xml prettyprint work round bug in minidom 2.6

* import xml_utils correctly

* Rename xml_utils to something more sensible

* Fix sangwonl#24 - support elements which only contain basic text contents

* Fix sangwonl#25 - use correct case for xsboolean (sangwonl#26)

* Set release version to 0.2.0

change repository for maintenance

* Update README.md

* Fix travis and readme as restructuredtext

* Support non-standard label attribute

Fix sangwonl#32

* clarifies profile vs profiles (sangwonl#37)

* clarifies profile vs profiles

* added profiles attribute to an AdaptationSet

* moved AdaptationSet @profiles for mergability

* Added @selectionPriority to AdaptationSet (sangwonl#35)

* added selection priority to AdaptationSet

* added selectionPriority to first AdaptationSet for identity test

* Add KID attribute to the Descriptor class (sangwonl#38)

Added the KID attribute to the Descriptor class to identify KID in the manifests of DRM encrypted content.

* Improve ignored files and folders (sangwonl#42)

This has the previous ignores and the common ones provided by GitHub.

I also added in the JetBrains project settings ignore.

* Dont use a Bare except on urllib import (sangwonl#43)

* Replace single char re alternation with char class (sangwonl#44)

* Use ImportError, Swap unittest import order (sangwonl#46)

These are swapped since unittest2 is intended to be used if you're on Python 2. More people will be using Python 3 at this point so it's best to import the Python 3 module and if unable to, it will use the backport.

Most people will be using Python 3 so this will also speed things up somewhat as one less unnecessary (almost expected) try catch will be prevented.

* Optimize README (sangwonl#51)

This change cleans up the Markdown to follow typical markdown linting rules (think of it as following PEP 8 for Markdown).

I also added a License Badge, and a section at the bottom.

* Prettyprinter clean up, typos, redundancy (sangwonl#45)

* Prettyprinter clean up, typos, redundancy

Spacing, Unnecessary Lines, Typos, Unnecessary characters, missing r'' for regex strings and unnecessary character escaping.

* Fix typo in prettyprinter

* Use GitHub Actions CI (sangwonl#50)

* Create Build Status GitHub Actions CI

* Create Release Packager GitHub Actions CI

* Use GitHub Actions CI Build Status Badge

* Use 2.7,3.x versions for Build Status

 2.6 and 2.8 isn't available. The Build Status Badge will assume 2.6+ is works if this passes. I don't think there's any smoother solution without diving into dodgy 3rd party GitHub actions.

* add install requirements

* update install requires

* using temporary if/else for requirements

* parsing datetimes

Co-authored-by: davemevans <dave.evans@m2amedia.tv>
Co-authored-by: Sangwon Lee <gamzabaw@gmail.com>
Co-authored-by: David Evans <5390145+davemevans@users.noreply.github.com>
Co-authored-by: bvc3at <thecapslockman@ya.ru>
Co-authored-by: thenewguy <wgordonw1@gmail.com>
Co-authored-by: Jayapraveen AR <jayapraveen.ar.2015.cse@rajalakshmi.edu.in>
Co-authored-by: PHOENiX <pragma.exe@gmail.com>
Co-authored-by: PHOENiX <rlaphoenix@pm.me>
Co-authored-by: Pedro Martin <p.martin@tvup.media>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants