Commit 5cce5688 by Vasyl Nakvasiuk Committed by Valera Rozuvan

add docstrings in videoalpha_module.py

parent 4f08d96c
...@@ -54,9 +54,10 @@ class VideoAlphaModule(XModule): ...@@ -54,9 +54,10 @@ class VideoAlphaModule(XModule):
if 'position' in state: if 'position' in state:
self.position = int(float(state['position'])) self.position = int(float(state['position']))
def _get_source(self, xmltree, extension=['mp4', 'ogv', 'avi', 'webm']): def _get_source(self, xmltree, extensions=['mp4', 'ogv', 'avi', 'webm']):
# find the first valid source """Find the first valid source, which ends with one of
condition = lambda src: any([src.endswith(ext) for ext in extension]) `extensions`."""
condition = lambda src: any([src.endswith(ext) for ext in extensions])
return self._get_first_external(xmltree, 'source', condition) return self._get_first_external(xmltree, 'source', condition)
def _get_track(self, xmltree): def _get_track(self, xmltree):
...@@ -64,10 +65,8 @@ class VideoAlphaModule(XModule): ...@@ -64,10 +65,8 @@ class VideoAlphaModule(XModule):
return self._get_first_external(xmltree, 'track') return self._get_first_external(xmltree, 'track')
def _get_first_external(self, xmltree, tag, condition=bool): def _get_first_external(self, xmltree, tag, condition=bool):
""" """Will return the first 'valid' element of the given tag.
Will return the first valid element 'valid' means that `condition('src' attribute) == True`
of the given tag.
'valid' means has a non-empty 'src' attribute
""" """
result = None result = None
for element in xmltree.findall(tag): for element in xmltree.findall(tag):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment