Przeglądaj źródła

It prints, and that's something

Petra Lamborn 4 lat temu
rodzic
commit
4246839318
1 zmienionych plików z 11 dodań i 5 usunięć
  1. 11
    5
      fedicurses.py

+ 11
- 5
fedicurses.py Wyświetl plik

5
 class PostParser(HTMLParser):
5
 class PostParser(HTMLParser):
6
     def __init__(self, ncwin, defncatt):
6
     def __init__(self, ncwin, defncatt):
7
         HTMLParser.__init__(self)
7
         HTMLParser.__init__(self)
8
-        self.win = ncwin,
8
+        self.win = ncwin
9
         self.defncatt = defncatt
9
         self.defncatt = defncatt
10
         self.curatt = defncatt
10
         self.curatt = defncatt
11
 
11
 
15
         elif tag == 'strong':
15
         elif tag == 'strong':
16
             self.curatt = self.curatt ^ curses.A_BOLD
16
             self.curatt = self.curatt ^ curses.A_BOLD
17
 
17
 
18
-    def handle_endtag(self, tag, attrs):
18
+    def handle_endtag(self, tag):
19
         if tag == 'p':
19
         if tag == 'p':
20
             cy, cx = self.win.getyx()
20
             cy, cx = self.win.getyx()
21
             self.win.move(cy + 2, 0)
21
             self.win.move(cy + 2, 0)
37
     posts = mastodon.timeline()
37
     posts = mastodon.timeline()
38
     parser = PostParser(stdscr, 0)
38
     parser = PostParser(stdscr, 0)
39
     stdscr.clear()
39
     stdscr.clear()
40
-    stdscr.addstr("test")
41
-    stdscr.refresh()
40
+    # stdscr.addstr("test")
42
     curses.halfdelay(10)
41
     curses.halfdelay(10)
43
-    # parser.feed(posts[0]["content"])
42
+    try:
43
+        for post in posts:
44
+            stdscr.addstr(post["account"]["acct"])
45
+            stdscr.addstr(": ")
46
+            parser.feed(post["content"])
47
+    except:
48
+        pass
49
+    stdscr.refresh()
44
     i = 'c'
50
     i = 'c'
45
     q = 0
51
     q = 0
46
     con = True
52
     con = True