-
Notifications
You must be signed in to change notification settings - Fork 96
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
[WIP]: Use demo.py to implement tutorials #710
Conversation
remove import dependencies on old tutor module
- txt, htm, html, mov, wmv, avi, jpg, jpeg, png
Rather than subclassing, how much of this functionality can be merged into the Or alternatively, how much functionality can we drop from the tutor.py code? Also, I don't think we have any actual tutorials using videos or similar, so we can drop support for a lot of the file formats without losing anything. |
# Check if there is a corresponding .rst (restructured text) file: | ||
dir, base_name = os.path.split(path) | ||
rst = os.path.join(dir, os.path.splitext(base_name)[0] + '.rst') | ||
return self._parse_htm_file(path, name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just does infinite recursion? (it looks like the original version did as well)
I think we can just remove this.
No htm
vs. html
|
||
def _path_changed(self, path): | ||
""" Creates the appropriate section based on the value of the path. | ||
def _parse_avi_file(self, path, name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be safely removed.
|
||
def _add_mov_item(self, path): | ||
""" Creates a description item for a QuickTime movie file. | ||
def _parse_mov_file(self, path, name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed
|
||
def _add_jpg_item(self, path): | ||
""" Creates a description item for a JPEG image file. | ||
def _parse_mp3_file(self, path, name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed.
name, ext = os.path.splitext(name) | ||
|
||
# If we have a handler for the file type, invoke it: | ||
method = getattr( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you wanted to do a bit better of a refactor, replacing "magic method names" with a dictionary mapping file extensions to factory functions would likely make the code much cleaner, and might allow something like having a tutorial be the same base class as a demo but with a slightly different set of registered file handlers, assuming you can't get the codebases completely aligned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The factory functions could be class methods on the appropriate classes being created.
def _create_html_item(self, **traits): | ||
""" Creates a platform specific html item and adds it to the list of | ||
descriptions. | ||
def _parse_wmv_file(self, path, name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can safely be removed.
Or alternatively, how much functionality can we drop from the tutor.py code? Also, I don't think we have any actual tutorials using videos or similar, so we can drop support for a lot of the file formats without losing anything. I think it is possible to add this functionality to the demo without altering the demo functionality. |
closing in favor of #712` |
xref: #696
This is an implementation of
tutor.py
usingdemo.py
.The approach is to extend the
DemoPath
class to also parse file extensions other than.py
like.rst
,.htm
. However, this does not look clean. It is probably better to do this unification as outlined in issue #24 of ETS examples.Things that don't work:
.desc
,.swf
files.To do:
next
,previous
buttons in the UI to navigate the tutorial directory structure.