Files
rfd/rfd/posts.py
dependabot[bot] 31ff0e480f Bump pylint from 2.9.6 to 2.11.1 (#108)
* Bump pylint from 2.9.6 to 2.11.1

Bumps [pylint](https://github.com/PyCQA/pylint) from 2.9.6 to 2.11.1.
- [Release notes](https://github.com/PyCQA/pylint/releases)
- [Changelog](https://github.com/PyCQA/pylint/blob/main/ChangeLog)
- [Commits](https://github.com/PyCQA/pylint/compare/v2.9.6...v2.11.1)

---
updated-dependencies:
- dependency-name: pylint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Use f strings everywhere

* Add black.yml

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dave G <davegallant@gmail.com>
2021-09-25 13:30:01 -04:00

36 lines
811 B
Python

# pylint: disable=old-style-class
import os
from colorama import Fore, Style
from .scores import get_vote_color
class Post:
def __init__(self, body, score, user):
self.body = body
self.score = score
self.user = user
def get_terminal_width():
_, columns = os.popen("stty size", "r").read().split()
return int(columns)
def generate_posts_output(posts):
output = ""
output += "-" * get_terminal_width()
for post in posts:
output += (
" -"
+ get_vote_color(post.score)
+ Fore.RESET
+ post.body
+ Fore.YELLOW
+ f" ({post.user})"
)
output += Style.RESET_ALL
output += "\n"
output += "-" * get_terminal_width()
output += "\n"
return output