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

go-to-parent, disable no_network policy, maintenance #17

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion curseradio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__author__ = "Gordon Ball <gordon@chronitis.net>"
__version__ = "0.2"
__version__ = "0.3"

from .curseradio import OPMLBrowser
21 changes: 18 additions & 3 deletions curseradio/curseradio.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
'enter': 'KEY_ENTER',
'stop': 'k',
'exit': 'q',
'favourite': 'f'
'parent': 'h',
'favourite': 'f',
}
}

Expand All @@ -59,7 +60,8 @@ def from_xml(cls, url, text="", attr=None):
is currently discarded).
"""
if attr is None: attr = {}
tree = lxml.etree.parse(url)
parser = lxml.etree.XMLParser(dtd_validation=False, no_network=False)
tree = lxml.etree.parse(url, parser=parser)
result = cls(text=text, attr=attr)
result.children = [OPMLNode.from_element(o)
for o in tree.xpath('/opml/body/outline')]
Expand Down Expand Up @@ -311,7 +313,8 @@ def get_keymap(self):
else:
keysrc = self.config['keymap.default']
for key in ('up', 'down', 'start', 'end', 'pageup', 'pagedown',
'enter', 'stop', 'exit', 'favourite'):
'enter', 'stop', 'exit', 'favourite',
'parent'):
value = keysrc.get(key, self.config['keymap.default'][key])
if value.startswith('KEY_'):
keymap[key] = getattr(curses, value)
Expand Down Expand Up @@ -356,6 +359,16 @@ def move(self, rel=None, to=None):
target = 0
elif to == "end":
target = len(self.flat) - 1
elif to == "parent":
target = self.top + self.cursor
showobjs = self.flat[0:target]
cdepth = self.flat[target][1]
for i, (obj, depth) in tuple(reversed(list(enumerate(showobjs)))):
if target >= 0:
target = target - 1
if depth == cdepth - 1:
break

elif rel is not None:
target = self.top + self.cursor + rel

Expand Down Expand Up @@ -392,6 +405,8 @@ def interact(self):
self.move(rel=-self.maxy)
elif ch == self.keymap['pagedown']: # page down
self.move(rel=self.maxy)
elif ch == self.keymap['parent']:
self.move(to="parent")
elif ch == self.keymap['enter'] or ch == ord('\n'):
for msg in self.selected.activate():
if isinstance(msg, str):
Expand Down