Comments (9)
Fount this in PRAW's code overview. May be helpful:
get_flair(subreddit, redditor)
Return the flair for a user on the given subreddit.
Requires the modflair oauth scope or user/password authentication as a mod of the subreddit.
Parameters:
•subreddit – Can be either a Subreddit object or the name of a subreddit.
•redditor – Can be either a Redditor object or the name of a redditor.
Returns:
None if the user doesn’t exist, otherwise a dictionary containing the keys flair_css_class, flair_text, and user.
from rtv.
I`m going to take a look at doing this.
from rtv.
Hey @michael-lazar, I've been looking at doing this but I'm having trouble finding where the comments and submission text are actually set / drawn to the screen. In the submissions.py module there are functions such as draw_submission and draw_comment. In these there are variables called text which seem to then be put into the curses screen. I've tried adding extra text to these text variables just to see what that would affect and it actually did nothing. Am I misunderstanding what this section of the code does?
from rtv.
That sounds like you're doing it correctly. Keep in mind that subreddit.py controls the main page, and submission.py controls the comments page. If you're trying to change the behavior of the main page, you need to look at subreddit.draw_item(). That being said, changing the text to something like
text = '{author} test_flair'.format(**data)
should produce a visible output. If it still doesn't, my guess is that python is grabbing files from a different location than you are expecting. If so let me know and we can walk through setting everything up.
from rtv.
Yeah I think Python must be grabbing files from a different place. Should I perhaps uninstall the system wide rtv that I installed via package manager? Or what would you suggest doing?
On Mar 9, 2015, at 18:22, michael-lazar [email protected] wrote:
That sounds like you're doing it correctly. Keep in mind that subreddit.py controls the main page, and submission.py controls the comments page. If you're trying to change the behavior of the main page, you need to look at subreddit.draw_item(). That being said, changing the text to something like
text = '{author} test_flair'.format(**data)
should produce a visible output. If it still doesn't, my guess is that python is grabbing files from a different location than you are expecting. If so let me know and we can walk through setting everything up.—
Reply to this email directly or view it on GitHub.
from rtv.
Here's what I've been doing lately. First make sure that your repo is up-to-date.
cd
into the top directory (the one withsetup.py
andREADME.rst
)- type
python -m rtv
Explanation:
The -m rtv
is shorthand for typing out python rtv/__main__.py
. When python sees the lines
from rtv.main import main
main()
inside of __main__.py
, it will search the current directory for valid packages first, and then if it doesn't find anything it will start searching through site-packages and pip installs. Since the current directory has a folder called rtv/
with an __init__.py
inside of it, that is the one that python will import.
from rtv.
Using python -m totally fixed my problem. I was running using python rtv/main.py before and for whatever reason it doesn't import from the correct place when running it that way. Thanks for giving me a hand on this, I'm going to continue working away on adding this feature.
from rtv.
I'm having an issue where as soon as I add a get_flair() call to content.py the program starts immediately crashing with the error message "Could not reach /r/front". My initial thought was that an exception was being thrown and getting caught by a block that does that but I haven't been able to figure out what's happening. get_flair documentation doesn't indicate that it would be throwing any exceptions and should just be returning None if the user or subreddit was not found. Do you have any idea why adding get_flair calls into the split_submission method in content.py would be causing it to crash with this message? (Note that even when get_flair is called for ANY subreddit, it always says "Could not reach /r/front")
Here is the rough block of code that I wrote for getting started with testing this out. (Note that the if condition for checking for "/r/front" is just because I had no idea what was causing the crash with that message and wanted to make sure it wasn't trying to use /r/front as an actual subreddit.)
if data['subreddit'] != "/r/front":
flair = get_flair(data['subreddit'][3:], data['author'])
if flair != None:
data['flair'] = flair['flair_text']
else:``
data['flair'] = ""
else:
data['flair'] = ""
The exception that it seems to be hitting is the one in main that catches SubredditNameErrors
from rtv.
You're correct that the exception is getting caught where it shouldn't be.
content.py, line 361
content = cls(display_name, submissions, loader)
try:
content.get(0)
except:
# TODO: Trap specific errors
raise SubredditNameError(display_name)
Try getting rid of this try-except block
content = cls(display_name, submissions, loader)
content.get(0)
and your error should propagate through.
from rtv.
Related Issues (20)
- add Twitch mime parser HOT 5
- Crash when hitting G on empty thread HOT 1
- RTV development is shutting down HOT 30
- Offering to help with the project HOT 1
- ConnectionError upon first launch
- no confirmation on exit HOT 1
- Program exited with status 127 HOT 1
- When you set $RTV_BROWSER variable to a program with options like "mybrowser -u" it basicly doesn't work HOT 1
- [1.2.7] Where is the configuration option to toggle whether to open web browser links in a new tab or a new window?
- Not being able to view remote image url via iTerm2's imgcat HOT 6
- How do I change it that rtv uses leafpad instead of nano as its default text editor?
- Save option for posts.
- Option to edit a posted comment.
- Where does rtv store the credentials or session/cookie file so I could just take a rtv install to another OS/new install and don’t have to reopen Firefox for allowing the app access?
- Version 1.27.0_1 (from brew) crashed when opening url HOT 5
- Fix incase mpv is not opening anymore
- When pressing < o > key on a reddit post rtv crashes, "Can't pickle local object" HOT 1
- Crash while trying to sign in HOT 1
- Crash while trying to open a submission link HOT 2
- Archiving Github Repository
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rtv.