Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
papersurfer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jacobsohn, Johann
papersurfer
Commits
e4972cc3
Commit
e4972cc3
authored
Aug 3, 2020
by
Johann Jacobsohn
Browse files
Options
Downloads
Patches
Plain Diff
open paper discussion thread in browser
parent
b735407c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
papersurfer.py
+16
-3
16 additions, 3 deletions
papersurfer.py
with
16 additions
and
3 deletions
papersurfer.py
+
16
−
3
View file @
e4972cc3
...
...
@@ -9,7 +9,9 @@ UI:
4. paper (open discussion) (open paper)
"""
import
subprocess
from
dataclasses
import
dataclass
from
functools
import
partial
from
mattermostdriver
import
Driver
import
urwid
import
configargparse
...
...
@@ -21,6 +23,7 @@ CHANNEL = "n5myem9yc7fyzb9am7ym5o41ry"
@dataclass
class
PostDTO
:
""""
Encapsulate Mattermost Posts.
"""
id
:
str
message
:
str
...
...
@@ -38,7 +41,8 @@ class Mattermost:
def
retrieve_all_messages
(
self
):
"""
Retrieve all messages from mattermost, unfiltered for papers.
"""
posts
=
self
.
mattermost
.
posts
.
get_posts_for_channel
(
CHANNEL
)
return
[
PostDTO
(
m
[
'
message
'
])
for
m
in
posts
[
'
posts
'
].
values
()]
return
[
PostDTO
(
m
[
'
id
'
],
m
[
'
message
'
])
for
m
in
posts
[
'
posts
'
].
values
()]
def
filter_incoming
(
self
,
posts
):
"""
Filter messages from mattermost to only papers.
"""
...
...
@@ -67,10 +71,12 @@ class Papersurfer:
div
=
urwid
.
Divider
(
u
'
-
'
)
self
.
mtm
=
Mattermost
(
username
,
password
)
papers
=
[
msg
.
message
for
msg
in
self
.
mtm
.
retrieve
()
]
papers
=
self
.
mtm
.
retrieve
()
body
=
[]
for
paper
in
papers
:
button
=
urwid
.
Button
(
paper
)
button
=
urwid
.
Button
(
paper
.
message
)
urwid
.
connect_signal
(
button
,
'
click
'
,
partial
(
self
.
handle_paper
,
paper
))
body
.
append
(
urwid
.
AttrMap
(
button
,
None
,
focus_map
=
'
reversed
'
))
self
.
listcontent
=
urwid
.
SimpleFocusListWalker
(
body
)
...
...
@@ -97,6 +103,13 @@ class Papersurfer:
"""
Handle exitbutton click and exit.
"""
raise
urwid
.
ExitMainLoop
()
def
handle_paper
(
self
,
post
,
_
):
self
.
open_post
(
post
)
def
open_post
(
self
,
post
):
link
=
f
"
https://mattermost.cen.uni-hamburg.de/ifg/pl/
{
post
.
id
}
"
subprocess
.
call
([
"
xdg-open
"
,
link
])
def
parse_args
():
"""
Parse command line arguments and config file.
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment