Rename rtv to tuir
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
[run]
|
[run]
|
||||||
source = rtv
|
source = tuir
|
||||||
omit =
|
omit =
|
||||||
*/__main__.py
|
*/__main__.py
|
||||||
*/packages/praw/*
|
*/packages/praw/*
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -10,6 +10,6 @@
|
|||||||
*.log
|
*.log
|
||||||
build
|
build
|
||||||
dist
|
dist
|
||||||
rtv.egg-info
|
tuir.egg-info
|
||||||
tests/refresh-token
|
tests/refresh-token
|
||||||
venv/
|
venv/
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ A clear description of what the bug is and how to reproduce it.
|
|||||||
|
|
||||||
**Describe your environment**
|
**Describe your environment**
|
||||||
- If a stack trace was displayed on the command line, paste the entire output here.
|
- If a stack trace was displayed on the command line, paste the entire output here.
|
||||||
- Otherwise, run ``$rtv --debug-info`` and paste the entire output here.
|
- Otherwise, run ``$tuir --debug-info`` and paste the entire output here.
|
||||||
- Include any other information that might be relevant to the issue (For example, your operating system, your terminal emulator, how you installed rtv, etc.)
|
- Include any other information that might be relevant to the issue (For example, your operating system, your terminal emulator, how you installed tuir, etc.)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ install:
|
|||||||
- pip install .[test]
|
- pip install .[test]
|
||||||
- pip install .
|
- pip install .
|
||||||
script:
|
script:
|
||||||
- pylint --rcfile .pylintrc -E rtv/
|
- pylint --rcfile .pylintrc -E tuir/
|
||||||
- coverage run -m py.test -v
|
- coverage run -m py.test -v
|
||||||
after_success:
|
after_success:
|
||||||
- coveralls
|
- coveralls
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
================
|
================
|
||||||
RTV Contributors
|
RTV/TUIR Contributors
|
||||||
================
|
================
|
||||||
|
|
||||||
Thanks to the following people for their contributions to this project.
|
Thanks to the following people for their contributions to this project.
|
||||||
@@ -59,4 +59,4 @@ Thanks to the following people for their contributions to this project.
|
|||||||
* `Adam Talsma <https://github.com/a-tal>`_
|
* `Adam Talsma <https://github.com/a-tal>`_
|
||||||
* `geheimnisse <https://github.com/geheimnisse>`_
|
* `geheimnisse <https://github.com/geheimnisse>`_
|
||||||
* `Alexander Terry <https://github.com/mralext20>`_
|
* `Alexander Terry <https://github.com/mralext20>`_
|
||||||
* `peterpans01 <https://github.com/peterpans01>`_
|
* `peterpans01 <https://github.com/peterpans01>`_
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Contributor Guidelines
|
|||||||
Before you start
|
Before you start
|
||||||
================
|
================
|
||||||
|
|
||||||
- Post an issue on the `tracker <https://gitlab.com/ajak/rtv/issues>`_ describing the bug or feature you would like to add
|
- Post an issue on the `tracker <https://gitlab.com/ajak/tuir/issues>`_ describing the bug or feature you would like to add
|
||||||
- If an issue already exists, leave a comment to let others know that you intend to work on it
|
- If an issue already exists, leave a comment to let others know that you intend to work on it
|
||||||
|
|
||||||
Considerations
|
Considerations
|
||||||
@@ -70,36 +70,36 @@ This both speeds up the tests and helps to maintain consistency across runs.
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
$ pip install rtv[test]
|
$ pip install tuir[test]
|
||||||
|
|
||||||
2. Set your ``$PYTHONPATH`` to point to the directory of your RTV repository.
|
2. Set your ``$PYTHONPATH`` to point to the directory of your TUIR repository.
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
$ export PYTHONPATH=~/code/rtv/
|
$ export PYTHONPATH=~/code/tuir/
|
||||||
|
|
||||||
3. Run the tests using the existing cassettes
|
3. Run the tests using the existing cassettes
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
$ python -m pytest ~/code/rtv/tests/
|
$ python -m pytest ~/code/tuir/tests/
|
||||||
================================ test session starts ================================
|
================================ test session starts ================================
|
||||||
platform linux -- Python 3.4.0, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
|
platform linux -- Python 3.4.0, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
|
||||||
rootdir: ~/code/rtv/, inifile:
|
rootdir: ~/code/tuir/, inifile:
|
||||||
plugins: xdist-1.14, cov-2.2.0
|
plugins: xdist-1.14, cov-2.2.0
|
||||||
collected 113 items
|
collected 113 items
|
||||||
|
|
||||||
4. By default, the cassettes will act as read-only.
|
4. By default, the cassettes will act as read-only.
|
||||||
If you have written a new test and would like to record a cassette, you must provide your own refresh token.
|
If you have written a new test and would like to record a cassette, you must provide your own refresh token.
|
||||||
The easiest thing to do is to use the token generated by RTV when you log in.
|
The easiest thing to do is to use the token generated by TUIR when you log in.
|
||||||
This is usually stored as *~/.local/share/rtv/refresh-token*.
|
This is usually stored as *~/.local/share/tuir/refresh-token*.
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
$ python -m pytest ~/code/rtv/tests/ --record-mode once --refresh-token ~/.local/share/rtv/refresh-token
|
$ python -m pytest ~/code/tuir/tests/ --record-mode once --refresh-token ~/.local/share/tuir/refresh-token
|
||||||
================================ test session starts ================================
|
================================ test session starts ================================
|
||||||
platform linux -- Python 3.4.0, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
|
platform linux -- Python 3.4.0, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
|
||||||
rootdir: ~/code/rtv/, inifile:
|
rootdir: ~/code/tuir/, inifile:
|
||||||
plugins: xdist-1.14, cov-2.2.0
|
plugins: xdist-1.14, cov-2.2.0
|
||||||
collected 113 items
|
collected 113 items
|
||||||
|
|
||||||
|
|||||||
3
LICENSE
3
LICENSE
@@ -1,6 +1,7 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2015 michael-lazar
|
Portions Copyright (c) 2015 michael-lazar
|
||||||
|
Portions Copyright (c) 2019 John Helmert
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ include CHANGELOG.rst
|
|||||||
include AUTHORS.rst
|
include AUTHORS.rst
|
||||||
include README.md
|
include README.md
|
||||||
include LICENSE
|
include LICENSE
|
||||||
include rtv.1
|
include tuir.1
|
||||||
include rtv/templates/*
|
include tuir/templates/*
|
||||||
include rtv/themes/*
|
include tuir/themes/*
|
||||||
|
|||||||
69
README.md
69
README.md
@@ -1,34 +1,34 @@
|
|||||||
<h1 align="center">Reddit Terminal Viewer (RTV)</h1>
|
<h1 align="center">Terminal UI for Reddit (TUIR)</h1>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
A text-based interface (TUI) to view and interact with Reddit from your terminal.<br>
|
A text-based interface (TUI) to view and interact with Reddit from your terminal.<br>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<strong>This fork of rtv is currently maintained by John Helmert III (ajak) and was maintained by Michael Lazar in <a href="https://github.com/michael-lazar/rtv">this respository</a> until commit 7923890 on Jun 3, 2019.</strong><br>
|
<strong>TUIR is a fork of rtv, which was maintained by Michael Lazar in <a href="https://github.com/michael-lazar/rtv">this respository</a> until Jun 3, 2019.</strong><br>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="title image" src="resources/title_image.png"/>
|
<img alt="title image" src="resources/title_image.png"/>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<!-- <p align="center">
|
||||||
<a href="https://pypi.python.org/pypi/rtv/">
|
<a href="https://pypi.python.org/pypi/rtv/">
|
||||||
<img alt="pypi" src="https://img.shields.io/pypi/v/rtv.svg?label=version"/>
|
<img alt="pypi" src="https://img.shields.io/pypi/v/rtv.svg?label=version"/>
|
||||||
</a>
|
</a>
|
||||||
<!-- <a href="https://travis-ci.org/michael-lazar/rtv">
|
<a href="https://travis-ci.org/michael-lazar/rtv">
|
||||||
<img alt="travis-ci" src="https://travis-ci.org/michael-lazar/rtv.svg?branch=master"/>
|
<img alt="travis-ci" src="https://travis-ci.org/michael-lazar/rtv.svg?branch=master"/>
|
||||||
</a> -->
|
</a>
|
||||||
<a href="https://repology.org/project/rtv/versions">
|
<a href="https://repology.org/project/rtv/versions">
|
||||||
<img src="https://repology.org/badge/tiny-repos/rtv.svg" alt="Packaging status">
|
<img src="https://repology.org/badge/tiny-repos/rtv.svg" alt="Packaging status">
|
||||||
</a>
|
</a>
|
||||||
<!-- <a href="https://coveralls.io/github/michael-lazar/rtv?branch=master">
|
<a href="https://coveralls.io/github/michael-lazar/rtv?branch=master">
|
||||||
<img alt="coveralls" src="https://coveralls.io/repos/michael-lazar/rtv/badge.svg?branch=master&service=github"/>
|
<img alt="coveralls" src="https://coveralls.io/repos/michael-lazar/rtv/badge.svg?branch=master&service=github"/>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://saythanks.io/to/michael-lazar">
|
<a href="https://saythanks.io/to/michael-lazar">
|
||||||
<img alt="say-thanks" src="https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg"/>
|
<img alt="say-thanks" src="https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg"/>
|
||||||
</a> -->
|
</a>
|
||||||
</p>
|
</p> -->
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
@@ -88,21 +88,21 @@ $ pkg install rtv
|
|||||||
### From source
|
### From source
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ git clone https://gitlab.com/ajak/rtv.git
|
$ git clone https://gitlab.com/ajak/tuir.git
|
||||||
$ cd rtv
|
$ cd tuir
|
||||||
$ python setup.py install
|
$ python setup.py install
|
||||||
```
|
```
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
RTV is not supported on Windows, due to a lack of resources and interest. Sorry!
|
TUIR is not supported on Windows, due to a lack of resources and interest. Sorry!
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
To run the program, type:
|
To run the program, type:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ rtv --help
|
$ tuir --help
|
||||||
```
|
```
|
||||||
|
|
||||||
### Controls
|
### Controls
|
||||||
@@ -130,17 +130,17 @@ See [CONTROLS](CONTROLS.md) for the full list of commands.
|
|||||||
|
|
||||||
### Configuration File
|
### Configuration File
|
||||||
|
|
||||||
Configuration files are stored in the ``{HOME}/.config/rtv/`` directory.
|
Configuration files are stored in the ``{HOME}/.config/tuir/`` directory.
|
||||||
|
|
||||||
Check out [rtv.cfg](rtv/templates/rtv.cfg) for the full list of configurable options. You can clone this file into your home directory by running:
|
Check out [tuir.cfg](tuir/templates/tuir.cfg) for the full list of configurable options. You can clone this file into your home directory by running:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ rtv --copy-config
|
$ tuir --copy-config
|
||||||
```
|
```
|
||||||
|
|
||||||
### Viewing Media Links
|
### Viewing Media Links
|
||||||
|
|
||||||
You can use [mailcap](https://en.wikipedia.org/wiki/Media_type#Mailcap) to configure how RTV will open different types of links.
|
You can use [mailcap](https://en.wikipedia.org/wiki/Media_type#Mailcap) to configure how TUIR will open different types of links.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="title image" src="resources/mailcap.gif"/>
|
<img alt="title image" src="resources/mailcap.gif"/>
|
||||||
@@ -149,30 +149,30 @@ You can use [mailcap](https://en.wikipedia.org/wiki/Media_type#Mailcap) to confi
|
|||||||
A mailcap file allows you to associate different MIME media types, like ``image/jpeg`` or ``video/mp4``, with shell commands. This feature is disabled by default because it takes a few extra steps to configure. To get started, copy the default mailcap template to your home directory.
|
A mailcap file allows you to associate different MIME media types, like ``image/jpeg`` or ``video/mp4``, with shell commands. This feature is disabled by default because it takes a few extra steps to configure. To get started, copy the default mailcap template to your home directory.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ rtv --copy-mailcap
|
$ tuir --copy-mailcap
|
||||||
```
|
```
|
||||||
|
|
||||||
This template contains examples for common MIME types that work with popular reddit websites like *imgur*, *youtube*, and *gfycat*. Open the mailcap template and follow the [instructions](rtv/templates/mailcap) listed inside.
|
This template contains examples for common MIME types that work with popular reddit websites like *imgur*, *youtube*, and *gfycat*. Open the mailcap template and follow the [instructions](tuir/templates/mailcap) listed inside.
|
||||||
|
|
||||||
Once you've setup your mailcap file, enable it by launching rtv with the ``rtv --enable-media`` flag (or set it in your **rtv.cfg**)
|
Once you've setup your mailcap file, enable it by launching tuir with the ``tuir --enable-media`` flag (or set it in your **tuir.cfg**)
|
||||||
|
|
||||||
### Environment Variables
|
### Environment Variables
|
||||||
|
|
||||||
The default programs that RTV interacts with can be configured through environment variables:
|
The default programs that TUIR interacts with can be configured through environment variables:
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong>$RTV_EDITOR</strong></td>
|
<td><strong>$TUIR_EDITOR</strong></td>
|
||||||
<td>A program used to compose text submissions and comments, e.g. <strong>vim</strong>, <strong>emacs</strong>, <strong>gedit</strong>
|
<td>A program used to compose text submissions and comments, e.g. <strong>vim</strong>, <strong>emacs</strong>, <strong>gedit</strong>
|
||||||
<br/> <em>If not specified, will fallback to $VISUAL and $EDITOR in that order.</em></td>
|
<br/> <em>If not specified, will fallback to $VISUAL and $EDITOR in that order.</em></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong>$RTV_BROWSER</strong></td>
|
<td><strong>$TUIR_BROWSER</strong></td>
|
||||||
<td>A program used to open links to external websites, e.g. <strong>firefox</strong>, <strong>google-chrome</strong>, <strong>w3m</strong>, <strong>lynx</strong>
|
<td>A program used to open links to external websites, e.g. <strong>firefox</strong>, <strong>google-chrome</strong>, <strong>w3m</strong>, <strong>lynx</strong>
|
||||||
<br/> <em>If not specified, will fallback to $BROWSER, or your system's default browser.</em></td>
|
<br/> <em>If not specified, will fallback to $BROWSER, or your system's default browser.</em></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong>$RTV_URLVIEWER</strong></td>
|
<td><strong>$TUIR_URLVIEWER</strong></td>
|
||||||
<td>A tool used to extract hyperlinks from blocks of text, e.g. <a href=https://github.com/sigpipe/urlview>urlview</a>, <a href=https://github.com/firecat53/urlscan>urlscan</a>
|
<td>A tool used to extract hyperlinks from blocks of text, e.g. <a href=https://github.com/sigpipe/urlview>urlview</a>, <a href=https://github.com/firecat53/urlscan>urlscan</a>
|
||||||
<br/> <em>If not specified, will fallback to urlview if it is installed.</em></td>
|
<br/> <em>If not specified, will fallback to urlview if it is installed.</em></td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -180,12 +180,12 @@ The default programs that RTV interacts with can be configured through environme
|
|||||||
|
|
||||||
### Clipboard
|
### Clipboard
|
||||||
|
|
||||||
RTV supports copying submission links to the OS clipboard. On macOS this is supported out of the box.
|
TUIR supports copying submission links to the OS clipboard. On macOS this is supported out of the box.
|
||||||
On Linux systems you will need to install either [xsel](http://www.vergenet.net/~conrad/software/xsel/) or [xclip](https://sourceforge.net/projects/xclip/).
|
On Linux systems you will need to install either [xsel](http://www.vergenet.net/~conrad/software/xsel/) or [xclip](https://sourceforge.net/projects/xclip/).
|
||||||
|
|
||||||
## Themes
|
## Themes
|
||||||
|
|
||||||
Themes can be used to customize the look and feel of RTV
|
Themes can be used to customize the look and feel of TUIR
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -210,24 +210,24 @@ Themes can be used to customize the look and feel of RTV
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
You can list all installed themes with the ``--list-themes`` command, and select one with ``--theme``. You can save your choice permanently in your [rtv.cfg](rtv/templates/rtv.cfg) file. You can also use the <kbd>F2</kbd> & <kbd>F3</kbd> keys inside of RTV to cycle through all available themes.
|
You can list all installed themes with the ``--list-themes`` command, and select one with ``--theme``. You can save your choice permanently in your [tuir.cfg](tuir/templates/tuir.cfg) file. You can also use the <kbd>F2</kbd> & <kbd>F3</kbd> keys inside of TUIR to cycle through all available themes.
|
||||||
|
|
||||||
For instructions on writing and installing your own themes, see [THEMES.md](THEMES.md).
|
For instructions on writing and installing your own themes, see [THEMES.md](THEMES.md).
|
||||||
|
|
||||||
## FAQ
|
## FAQ
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Why am I getting an error during installation/when launching rtv?</summary>
|
<summary>Why am I getting an error during installation/when launching tuir?</summary>
|
||||||
|
|
||||||
> If your distro ships with an older version of python 2.7 or python-requests,
|
> If your distro ships with an older version of python 2.7 or python-requests,
|
||||||
> you may experience SSL errors or other package incompatibilities. The
|
> you may experience SSL errors or other package incompatibilities. The
|
||||||
> easiest way to fix this is to install rtv using python 3. If you
|
> easiest way to fix this is to install tuir using python 3. If you
|
||||||
> don't already have pip3, see http://stackoverflow.com/a/6587528 for setup
|
> don't already have pip3, see http://stackoverflow.com/a/6587528 for setup
|
||||||
> instructions. Then do
|
> instructions. Then do
|
||||||
>
|
>
|
||||||
> ```bash
|
> ```bash
|
||||||
> $ sudo pip uninstall rtv
|
> $ sudo pip uninstall tuir
|
||||||
> $ sudo pip3 install -U rtv
|
> $ sudo pip3 install -U tuir
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
@@ -237,7 +237,7 @@ For instructions on writing and installing your own themes, see [THEMES.md](THEM
|
|||||||
> This type of text usually shows up when python is unable to render
|
> This type of text usually shows up when python is unable to render
|
||||||
> unicode properly.
|
> unicode properly.
|
||||||
>
|
>
|
||||||
> 1. Try starting RTV in ascii-only mode with ``rtv --ascii``
|
> 1. Try starting TUIR in ascii-only mode with ``tuir --ascii``
|
||||||
> 2. Make sure that the terminal/font that you're using supports unicode
|
> 2. Make sure that the terminal/font that you're using supports unicode
|
||||||
> 3. Try [setting the LOCALE to utf-8](https://perlgeek.de/en/article/set-up-a-clean-utf8-environment)
|
> 3. Try [setting the LOCALE to utf-8](https://perlgeek.de/en/article/set-up-a-clean-utf8-environment)
|
||||||
> 4. Your python may have been built against the wrong curses library,
|
> 4. Your python may have been built against the wrong curses library,
|
||||||
@@ -250,11 +250,11 @@ For instructions on writing and installing your own themes, see [THEMES.md](THEM
|
|||||||
|
|
||||||
> This project is structured to be run as a python *module*. This means that
|
> This project is structured to be run as a python *module*. This means that
|
||||||
> you need to launch it using python's ``-m`` flag. See the example below, which
|
> you need to launch it using python's ``-m`` flag. See the example below, which
|
||||||
> assumes that you have cloned the repository into the directory **~/rtv_project**.
|
> assumes that you have cloned the repository into the directory **~/tuir_project**.
|
||||||
>
|
>
|
||||||
> ```bash
|
> ```bash
|
||||||
> $ cd ~/rtv_project
|
> $ cd ~/tuir_project
|
||||||
> $ python3 -m rtv
|
> $ python3 -m tuir
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
@@ -266,4 +266,3 @@ Before writing any code, please read the [Contributor Guidelines](CONTRIBUTING.r
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
This project is distributed under the [MIT](LICENSE) license.
|
This project is distributed under the [MIT](LICENSE) license.
|
||||||
|
|
||||||
|
|||||||
14
THEMES.md
14
THEMES.md
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
## Installing Themes
|
## Installing Themes
|
||||||
|
|
||||||
You can install custom themes by copying them into your **~/.config/rtv/themes/**
|
You can install custom themes by copying them into your **~/.config/tuir/themes/**
|
||||||
directory. The name of the theme will match the name of the file.
|
directory. The name of the theme will match the name of the file.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ cp my-custom-theme.cfg ~/.config/rtv/themes/
|
$ cp my-custom-theme.cfg ~/.config/tuir/themes/
|
||||||
$ rtv --theme my-custom-theme
|
$ tuir --theme my-custom-theme
|
||||||
```
|
```
|
||||||
|
|
||||||
If you've created a cool theme and would like to share it with the community,
|
If you've created a cool theme and would like to share it with the community,
|
||||||
@@ -31,7 +31,7 @@ Color support on modern terminals can be split into 4 categories:
|
|||||||
The 16 system colors, along with the default foreground and background,
|
The 16 system colors, along with the default foreground and background,
|
||||||
can usually be customized through your terminal's profile settings. The
|
can usually be customized through your terminal's profile settings. The
|
||||||
6x6x6 color palette and grayscale colors are constant RGB values across
|
6x6x6 color palette and grayscale colors are constant RGB values across
|
||||||
all terminals. RTV's default theme only uses the 8 primary system colors,
|
all terminals. TUIR's default theme only uses the 8 primary system colors,
|
||||||
which is why it matches the "look and feel" of the terminal that you're
|
which is why it matches the "look and feel" of the terminal that you're
|
||||||
running it in.
|
running it in.
|
||||||
|
|
||||||
@@ -62,9 +62,9 @@ it will be set automatically by you terminal. Often, problems with
|
|||||||
terminal colors can be traced back to somebody hardcoding
|
terminal colors can be traced back to somebody hardcoding
|
||||||
``TERM=xterm-256color`` in their .bashrc file.
|
``TERM=xterm-256color`` in their .bashrc file.
|
||||||
|
|
||||||
## Understanding RTV Themes
|
## Understanding TUIR Themes
|
||||||
|
|
||||||
Here's an example of what an RTV theme file looks like:
|
Here's an example of what an TUIR theme file looks like:
|
||||||
|
|
||||||
```
|
```
|
||||||
[theme]
|
[theme]
|
||||||
@@ -162,7 +162,7 @@ Attributes can be mixed together using the + symbol. For example,
|
|||||||
|
|
||||||
### Modifiers
|
### Modifiers
|
||||||
|
|
||||||
RTV themes use special "modifer" elements to define the default
|
TUIR themes use special "modifer" elements to define the default
|
||||||
application style. This allows you to do things like set the default
|
application style. This allows you to do things like set the default
|
||||||
background color without needing to set ``<background>`` on every
|
background color without needing to set ``<background>`` on every
|
||||||
single element. The three modifier elements are:
|
single element. The three modifier elements are:
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
r"""
|
|
||||||
________ __________________________
|
|
||||||
___ __ \__________ /_____ /__(_)_ /_
|
|
||||||
__ /_/ / _ \ __ /_ __ /__ /_ __/
|
|
||||||
_ _, _// __/ /_/ / / /_/ / _ / / /_
|
|
||||||
/_/ |_| \___/\__,_/ \__,_/ /_/ \__/
|
|
||||||
|
|
||||||
|
|
||||||
________ _____ ______
|
|
||||||
___ __/__________________ ______(_)____________ ___ /
|
|
||||||
__ / _ _ \_ ___/_ __ `__ \_ /__ __ \ __ `/_ /
|
|
||||||
_ / / __/ / _ / / / / / / _ / / / /_/ /_ /
|
|
||||||
/_/ \___//_/ /_/ /_/ /_//_/ /_/ /_/\__,_/ /_/
|
|
||||||
|
|
||||||
|
|
||||||
___ ______
|
|
||||||
__ | / /__(_)_______ ______________
|
|
||||||
__ | / /__ /_ _ \_ | /| / / _ \_ ___/
|
|
||||||
__ |/ / _ / / __/_ |/ |/ // __/ /
|
|
||||||
_____/ /_/ \___/____/|__/ \___//_/
|
|
||||||
|
|
||||||
|
|
||||||
(RTV)
|
|
||||||
"""
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from .__version__ import __version__
|
|
||||||
|
|
||||||
__title__ = 'Reddit Terminal Viewer'
|
|
||||||
__author__ = 'Michael Lazar'
|
|
||||||
__license__ = 'The MIT License (MIT)'
|
|
||||||
__copyright__ = '(c) 2016 Michael Lazar'
|
|
||||||
@@ -2,7 +2,7 @@ Release Checklist
|
|||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
1. Switch to the master branch and stash any uncommited changes.
|
1. Switch to the master branch and stash any uncommited changes.
|
||||||
2. Bump the version number in [rtv/\_\_version\_\_.py](rtv/__version__.py).
|
2. Bump the version number in [tuir/\_\_version\_\_.py](tuir/__version__.py).
|
||||||
3. Update the release notes in the [CHANGELOG.rst](CHANGELOG.rst).
|
3. Update the release notes in the [CHANGELOG.rst](CHANGELOG.rst).
|
||||||
4. Update the contributor list by running [``scripts/build_authors.py``](scripts/build_authors.py).
|
4. Update the contributor list by running [``scripts/build_authors.py``](scripts/build_authors.py).
|
||||||
5. Re-generate the manpage by running [``scripts/build_manpage.py``](scripts/build_manpage.py).
|
5. Re-generate the manpage by running [``scripts/build_manpage.py``](scripts/build_manpage.py).
|
||||||
@@ -11,7 +11,7 @@ Release Checklist
|
|||||||
8. Clean out any old build/release files by running [``scripts/pip_clean.py``](scripts/pip_clean.py).
|
8. Clean out any old build/release files by running [``scripts/pip_clean.py``](scripts/pip_clean.py).
|
||||||
9. Build the source tarball and binary wheel: ``$ python3 setup.py sdist bdist_wheel``
|
9. Build the source tarball and binary wheel: ``$ python3 setup.py sdist bdist_wheel``
|
||||||
10. Upload the packages to PyPI: ``$ twine upload dist/*``
|
10. Upload the packages to PyPI: ``$ twine upload dist/*``
|
||||||
11. Verify that the upload was successful: ``$ pip install rtv --upgrade --force-reinstall``
|
11. Verify that the upload was successful: ``$ pip install tuir --upgrade --force-reinstall``
|
||||||
12. Smoke test the new release on Python 2 and Python 3.
|
12. Smoke test the new release on Python 2 and Python 3.
|
||||||
12. Create a new release on Github and copy the release notes from the changelog.
|
12. Create a new release on Github and copy the release notes from the changelog.
|
||||||
13. Use Github to delete any old branches that have been merged.
|
13. Use Github to delete any old branches that have been merged.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Internal tool used to automatically generate an up-to-date version of the rtv
|
Internal tool used to automatically generate an up-to-date version of the tuir
|
||||||
man page. Currently this script should be manually ran after each version bump.
|
man page. Currently this script should be manually ran after each version bump.
|
||||||
In the future, it would be nice to have this functionality built into setup.py.
|
In the future, it would be nice to have this functionality built into setup.py.
|
||||||
|
|
||||||
@@ -17,8 +17,8 @@ _filepath = os.path.dirname(os.path.relpath(__file__))
|
|||||||
ROOT = os.path.abspath(os.path.join(_filepath, '..'))
|
ROOT = os.path.abspath(os.path.join(_filepath, '..'))
|
||||||
sys.path.insert(0, ROOT)
|
sys.path.insert(0, ROOT)
|
||||||
|
|
||||||
import rtv
|
import tuir
|
||||||
from rtv import config
|
from tuir import config
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -30,7 +30,7 @@ def main():
|
|||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
print('Fetching version')
|
print('Fetching version')
|
||||||
data['version'] = rtv.__version__
|
data['version'] = tuir.__version__
|
||||||
print('Fetching release date')
|
print('Fetching release date')
|
||||||
data['release_date'] = datetime.utcnow().strftime('%B %d, %Y')
|
data['release_date'] = datetime.utcnow().strftime('%B %d, %Y')
|
||||||
print('Fetching synopsis')
|
print('Fetching synopsis')
|
||||||
@@ -65,18 +65,18 @@ def main():
|
|||||||
options += '\n'.join(('.TP', flag, description, '\n'))
|
options += '\n'.join(('.TP', flag, description, '\n'))
|
||||||
data['options'] = options
|
data['options'] = options
|
||||||
print('Fetching license')
|
print('Fetching license')
|
||||||
data['license'] = rtv.__license__
|
data['license'] = tuir.__license__
|
||||||
print('Fetching copyright')
|
print('Fetching copyright')
|
||||||
data['copyright'] = rtv.__copyright__
|
data['copyright'] = tuir.__copyright__
|
||||||
# Escape dashes is all of the sections
|
# Escape dashes is all of the sections
|
||||||
data = {k: v.replace('-', r'\-') for k, v in data.items()}
|
data = {k: v.replace('-', r'\-') for k, v in data.items()}
|
||||||
print('Reading from %s/scripts/rtv.1.template' % ROOT)
|
print('Reading from %s/scripts/tuir.1.template' % ROOT)
|
||||||
with open(os.path.join(ROOT, 'scripts/rtv.1.template')) as fp:
|
with open(os.path.join(ROOT, 'scripts/tuir.1.template')) as fp:
|
||||||
template = fp.read()
|
template = fp.read()
|
||||||
print('Populating template')
|
print('Populating template')
|
||||||
out = template.format(**data)
|
out = template.format(**data)
|
||||||
print('Writing to %s/rtv.1' % ROOT)
|
print('Writing to %s/tuir.1' % ROOT)
|
||||||
with open(os.path.join(ROOT, 'rtv.1'), 'w') as fp:
|
with open(os.path.join(ROOT, 'tuir.1'), 'w') as fp:
|
||||||
fp.write(out)
|
fp.write(out)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ echo "$(wc -l tests/*.py)"
|
|||||||
echo -e "\nScripts: "
|
echo -e "\nScripts: "
|
||||||
echo "$(wc -l scripts/*)"
|
echo "$(wc -l scripts/*)"
|
||||||
echo -e "\nTemplates: "
|
echo -e "\nTemplates: "
|
||||||
echo "$(wc -l rtv/templates/*)"
|
echo "$(wc -l tuir/templates/*)"
|
||||||
echo -e "\nCode: "
|
echo -e "\nCode: "
|
||||||
echo "$(wc -l rtv/*.py)"
|
echo "$(wc -l tuir/*.py)"
|
||||||
echo -e "\nCombined: "
|
echo -e "\nCombined: "
|
||||||
echo "$(cat tests/*.py scripts/* rtv/templates/* rtv/*.py | wc -l) total lines"
|
echo "$(cat tests/*.py scripts/* tuir/templates/* tuir/*.py | wc -l) total lines"
|
||||||
|
|||||||
@@ -15,15 +15,15 @@ from collections import Counter
|
|||||||
from vcr import VCR
|
from vcr import VCR
|
||||||
from six.moves.urllib.parse import urlparse, parse_qs
|
from six.moves.urllib.parse import urlparse, parse_qs
|
||||||
|
|
||||||
from rtv.theme import Theme, ThemeList
|
from tuir.theme import Theme, ThemeList
|
||||||
from rtv.config import Config
|
from tuir.config import Config
|
||||||
from rtv.packages import praw
|
from tuir.packages import praw
|
||||||
from rtv.oauth import OAuthHelper
|
from tuir.oauth import OAuthHelper
|
||||||
from rtv.terminal import Terminal
|
from tuir.terminal import Terminal
|
||||||
from rtv.objects import curses_session
|
from tuir.objects import curses_session
|
||||||
from rtv.subreddit_page import SubredditPage
|
from tuir.subreddit_page import SubredditPage
|
||||||
from rtv.submission_page import SubmissionPage
|
from tuir.submission_page import SubmissionPage
|
||||||
from rtv.subscription_page import SubscriptionPage
|
from tuir.subscription_page import SubscriptionPage
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ Initialize an authenticated instance of PRAW to interact with.
|
|||||||
|
|
||||||
$ python -i initialize_session.py
|
$ python -i initialize_session.py
|
||||||
"""
|
"""
|
||||||
from rtv.docs import AGENT
|
from tuir.docs import AGENT
|
||||||
from rtv.packages import praw
|
from tuir.packages import praw
|
||||||
from rtv.content import RequestHeaderRateLimiter
|
from tuir.content import RequestHeaderRateLimiter
|
||||||
from rtv.config import Config
|
from tuir.config import Config
|
||||||
|
|
||||||
config = Config()
|
config = Config()
|
||||||
config.load_refresh_token()
|
config.load_refresh_token()
|
||||||
@@ -27,4 +27,4 @@ reddit.refresh_access_information(config.refresh_token)
|
|||||||
|
|
||||||
inbox = reddit.get_inbox()
|
inbox = reddit.get_inbox()
|
||||||
items = [next(inbox) for _ in range(20)]
|
items = [next(inbox) for _ in range(20)]
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ os.environ['BROWSER'] = 'firefox'
|
|||||||
# If we want to override the $BROWSER variable that the python webbrowser
|
# If we want to override the $BROWSER variable that the python webbrowser
|
||||||
# references, it needs to be done before the webbrowser module is imported
|
# references, it needs to be done before the webbrowser module is imported
|
||||||
# for the first time.
|
# for the first time.
|
||||||
RTV_BROWSER, BROWSER = os.environ.get('RTV_BROWSER'), os.environ.get('BROWSER')
|
TUIR_BROWSER, BROWSER = os.environ.get('TUIR_BROWSER'), os.environ.get('BROWSER')
|
||||||
if RTV_BROWSER:
|
if TUIR_BROWSER:
|
||||||
os.environ['BROWSER'] = RTV_BROWSER
|
os.environ['BROWSER'] = TUIR_BROWSER
|
||||||
|
|
||||||
print('RTV_BROWSER=%s' % RTV_BROWSER)
|
print('TUIR_BROWSER=%s' % TUIR_BROWSER)
|
||||||
print('BROWSER=%s' % BROWSER)
|
print('BROWSER=%s' % BROWSER)
|
||||||
|
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
.TH "RTV" "1" "{release_date}" "Version {version}" "Usage and Commands"
|
.TH "TUIR" "1" "{release_date}" "Version {version}" "Usage and Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
RTV - Reddit Terminal Viewer
|
TUIR - Terminal UI for Reddit
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
{synopsis}
|
{synopsis}
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
@@ -17,32 +17,32 @@ Press \fBright\fR to view the selected submission and \fBleft\fR to return.
|
|||||||
Press \fB?\fR to open the help screen.
|
Press \fB?\fR to open the help screen.
|
||||||
.SH FILES
|
.SH FILES
|
||||||
.TP
|
.TP
|
||||||
.BR $XDG_CONFIG_HOME/rtv/rtv.cfg
|
.BR $XDG_CONFIG_HOME/tuir/tuir.cfg
|
||||||
The configuration file can be used to customize default program settings.
|
The configuration file can be used to customize default program settings.
|
||||||
.TP
|
.TP
|
||||||
.BR $XDG_DATA_HOME/rtv/refresh-token
|
.BR $XDG_DATA_HOME/tuir/refresh-token
|
||||||
After you login to reddit, your most recent OAuth refresh token will be stored
|
After you login to reddit, your most recent OAuth refresh token will be stored
|
||||||
for future sessions.
|
for future sessions.
|
||||||
.TP
|
.TP
|
||||||
.BR $XDG_DATA_HOME/rtv/history.log
|
.BR $XDG_DATA_HOME/tuir/history.log
|
||||||
This file stores URLs that have been recently opened in order to
|
This file stores URLs that have been recently opened in order to
|
||||||
visually highlight them as "seen".
|
visually highlight them as "seen".
|
||||||
.SH ENVIRONMENT
|
.SH ENVIRONMENT
|
||||||
.TP
|
.TP
|
||||||
.BR RTV_EDITOR
|
.BR TUIR_EDITOR
|
||||||
Text editor to use when editing comments and submissions. Will fallback to
|
Text editor to use when editing comments and submissions. Will fallback to
|
||||||
\fI$EDITOR\fR.
|
\fI$EDITOR\fR.
|
||||||
.TP
|
.TP
|
||||||
.BR RTV_URLVIEWER
|
.BR TUIR_URLVIEWER
|
||||||
Url viewer to use to extract links from comments. Requires a compatible
|
Url viewer to use to extract links from comments. Requires a compatible
|
||||||
program to be installed.
|
program to be installed.
|
||||||
.TP
|
.TP
|
||||||
.BR RTV_BROWSER
|
.BR TUIR_BROWSER
|
||||||
Web browser to use when opening links. Will fallback to \fI$BROWSER\fR.
|
Web browser to use when opening links. Will fallback to \fI$BROWSER\fR.
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
Michael Lazar <lazar.michael22@gmail.com> (2017).
|
Michael Lazar <lazar.michael22@gmail.com> (2017).
|
||||||
John Helmert <jchelmertt3@gmail.com> (2019).
|
John Helmert III <jchelmertt3@gmail.com> (2019).
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report bugs to \fIhttps://gitlab.com/ajak/rtv/issues\fR
|
Report bugs to \fIhttps://gitlab.com/ajak/tuir/issues\fR
|
||||||
.SH LICENSE
|
.SH LICENSE
|
||||||
{license}
|
{license}
|
||||||
@@ -29,13 +29,13 @@ def main():
|
|||||||
commit = p.stdout.read().strip()
|
commit = p.stdout.read().strip()
|
||||||
print('Found commit %s' % commit)
|
print('Found commit %s' % commit)
|
||||||
regex = 's/^__praw_hash__ =.*$/__praw_hash__ = \'%s\'/g' % commit
|
regex = 's/^__praw_hash__ =.*$/__praw_hash__ = \'%s\'/g' % commit
|
||||||
packages_root = os.path.join(ROOT, 'rtv', 'packages', '__init__.py')
|
packages_root = os.path.join(ROOT, 'tuir', 'packages', '__init__.py')
|
||||||
print('Updating commit hash in %s' % packages_root)
|
print('Updating commit hash in %s' % packages_root)
|
||||||
subprocess.check_call(['sed', '-i', '', regex, packages_root])
|
subprocess.check_call(['sed', '-i', '', regex, packages_root])
|
||||||
|
|
||||||
# Overwrite the project files
|
# Overwrite the project files
|
||||||
src = os.path.join(tmpdir, 'praw')
|
src = os.path.join(tmpdir, 'praw')
|
||||||
dest = os.path.join(ROOT, 'rtv', 'packages', 'praw')
|
dest = os.path.join(ROOT, 'tuir', 'packages', 'praw')
|
||||||
print('Copying package files to %s' % dest)
|
print('Copying package files to %s' % dest)
|
||||||
shutil.rmtree(dest, ignore_errors=True)
|
shutil.rmtree(dest, ignore_errors=True)
|
||||||
shutil.copytree(src, dest)
|
shutil.copytree(src, dest)
|
||||||
|
|||||||
20
setup.py
20
setup.py
@@ -44,30 +44,30 @@ def long_description():
|
|||||||
|
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='rtv',
|
name='tuir',
|
||||||
version=version,
|
version=version,
|
||||||
description='A simple terminal viewer for Reddit (Reddit Terminal Viewer)',
|
description='A simple terminal viewer for Reddit (Terminal UI for Reddit)',
|
||||||
long_description=long_description(),
|
long_description=long_description(),
|
||||||
long_description_content_type='text/markdown',
|
long_description_content_type='text/markdown',
|
||||||
url='https://gitlab.com/ajak/rtv',
|
url='https://gitlab.com/ajak/tuir',
|
||||||
author='John Helmert III',
|
author='John Helmert III',
|
||||||
author_email='jchelmertt3@gmail.com',
|
author_email='jchelmertt3@gmail.com',
|
||||||
license='MIT',
|
license='MIT',
|
||||||
keywords='reddit terminal praw curses',
|
keywords='reddit terminal praw curses',
|
||||||
packages=[
|
packages=[
|
||||||
'rtv',
|
'tuir',
|
||||||
'rtv.packages',
|
'tuir.packages',
|
||||||
'rtv.packages.praw'
|
'tuir.packages.praw'
|
||||||
],
|
],
|
||||||
package_data={
|
package_data={
|
||||||
'rtv': ['templates/*', 'themes/*'],
|
'tuir': ['templates/*', 'themes/*'],
|
||||||
'rtv.packages.praw': ['praw.ini']
|
'tuir.packages.praw': ['praw.ini']
|
||||||
},
|
},
|
||||||
data_files=[("share/man/man1", ["rtv.1"])],
|
data_files=[("share/man/man1", ["tuir.1"])],
|
||||||
install_requires=install_requires,
|
install_requires=install_requires,
|
||||||
tests_require=tests_require,
|
tests_require=tests_require,
|
||||||
extras_require=extras_require,
|
extras_require=extras_require,
|
||||||
entry_points={'console_scripts': ['rtv=rtv.__main__:main']},
|
entry_points={'console_scripts': ['tuir=tuir.__main__:main']},
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Intended Audience :: End Users/Desktop',
|
'Intended Audience :: End Users/Desktop',
|
||||||
'Environment :: Console :: Curses',
|
'Environment :: Console :: Curses',
|
||||||
|
|||||||
@@ -11,15 +11,15 @@ import pytest
|
|||||||
from vcr import VCR
|
from vcr import VCR
|
||||||
from six.moves.urllib.parse import urlparse, parse_qs
|
from six.moves.urllib.parse import urlparse, parse_qs
|
||||||
|
|
||||||
from rtv.oauth import OAuthHelper, OAuthHandler, OAuthHTTPServer
|
from tuir.oauth import OAuthHelper, OAuthHandler, OAuthHTTPServer
|
||||||
from rtv.content import RequestHeaderRateLimiter
|
from tuir.content import RequestHeaderRateLimiter
|
||||||
from rtv.config import Config
|
from tuir.config import Config
|
||||||
from rtv.packages import praw
|
from tuir.packages import praw
|
||||||
from rtv.terminal import Terminal
|
from tuir.terminal import Terminal
|
||||||
from rtv.subreddit_page import SubredditPage
|
from tuir.subreddit_page import SubredditPage
|
||||||
from rtv.submission_page import SubmissionPage
|
from tuir.submission_page import SubmissionPage
|
||||||
from rtv.subscription_page import SubscriptionPage
|
from tuir.subscription_page import SubscriptionPage
|
||||||
from rtv.inbox_page import InboxPage
|
from tuir.inbox_page import InboxPage
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
@@ -40,7 +40,7 @@ for name in ['vcr.matchers', 'vcr.stubs']:
|
|||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
parser.addoption('--record-mode', dest='record_mode', default='none')
|
parser.addoption('--record-mode', dest='record_mode', default='none')
|
||||||
parser.addoption('--refresh-token', dest='refresh_token',
|
parser.addoption('--refresh-token', dest='refresh_token',
|
||||||
default='~/.local/share/rtv/refresh-token')
|
default='~/.local/share/tuir/refresh-token')
|
||||||
|
|
||||||
|
|
||||||
class MockStdscr(mock.MagicMock):
|
class MockStdscr(mock.MagicMock):
|
||||||
@@ -184,9 +184,9 @@ def reddit(vcr, request):
|
|||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
|
|
||||||
with vcr.use_cassette(cassette_name):
|
with vcr.use_cassette(cassette_name):
|
||||||
with patch('rtv.packages.praw.Reddit.get_access_information'):
|
with patch('tuir.packages.praw.Reddit.get_access_information'):
|
||||||
handler = RequestHeaderRateLimiter()
|
handler = RequestHeaderRateLimiter()
|
||||||
reddit = praw.Reddit(user_agent='rtv test suite',
|
reddit = praw.Reddit(user_agent='tuir test suite',
|
||||||
decode_html_entities=False,
|
decode_html_entities=False,
|
||||||
disable_update_check=True,
|
disable_update_check=True,
|
||||||
handler=handler)
|
handler=handler)
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from rtv.clipboard import copy
|
from tuir.clipboard import copy
|
||||||
from rtv.exceptions import ProgramError
|
from tuir.exceptions import ProgramError
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import os
|
|||||||
import codecs
|
import codecs
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
|
|
||||||
from rtv.config import Config, copy_default_config, copy_default_mailcap
|
from tuir.config import Config, copy_default_config, copy_default_mailcap
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
@@ -17,7 +17,7 @@ def test_copy_default_config():
|
|||||||
"""Make sure the default config file was included in the package"""
|
"""Make sure the default config file was included in the package"""
|
||||||
|
|
||||||
with NamedTemporaryFile(suffix='.cfg') as fp:
|
with NamedTemporaryFile(suffix='.cfg') as fp:
|
||||||
with mock.patch('rtv.config.six.moves.input', return_value='y'):
|
with mock.patch('tuir.config.six.moves.input', return_value='y'):
|
||||||
copy_default_config(fp.name)
|
copy_default_config(fp.name)
|
||||||
assert fp.read()
|
assert fp.read()
|
||||||
# Check that the permissions were changed
|
# Check that the permissions were changed
|
||||||
@@ -29,7 +29,7 @@ def test_copy_default_config_cancel():
|
|||||||
"""Pressing ``n`` should cancel the copy"""
|
"""Pressing ``n`` should cancel the copy"""
|
||||||
|
|
||||||
with NamedTemporaryFile(suffix='.cfg') as fp:
|
with NamedTemporaryFile(suffix='.cfg') as fp:
|
||||||
with mock.patch('rtv.config.six.moves.input', return_value='n'):
|
with mock.patch('tuir.config.six.moves.input', return_value='n'):
|
||||||
copy_default_config(fp.name)
|
copy_default_config(fp.name)
|
||||||
assert not fp.read()
|
assert not fp.read()
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ def test_copy_config_interrupt():
|
|||||||
"""Pressing ``Ctrl-C`` should cancel the copy"""
|
"""Pressing ``Ctrl-C`` should cancel the copy"""
|
||||||
|
|
||||||
with NamedTemporaryFile(suffix='.cfg') as fp:
|
with NamedTemporaryFile(suffix='.cfg') as fp:
|
||||||
with mock.patch('rtv.config.six.moves.input') as func:
|
with mock.patch('tuir.config.six.moves.input') as func:
|
||||||
func.side_effect = KeyboardInterrupt
|
func.side_effect = KeyboardInterrupt
|
||||||
copy_default_config(fp.name)
|
copy_default_config(fp.name)
|
||||||
assert not fp.read()
|
assert not fp.read()
|
||||||
@@ -48,7 +48,7 @@ def test_copy_default_mailcap():
|
|||||||
"""Make sure the example mailcap file was included in the package"""
|
"""Make sure the example mailcap file was included in the package"""
|
||||||
|
|
||||||
with NamedTemporaryFile() as fp:
|
with NamedTemporaryFile() as fp:
|
||||||
with mock.patch('rtv.config.six.moves.input', return_value='y'):
|
with mock.patch('tuir.config.six.moves.input', return_value='y'):
|
||||||
copy_default_mailcap(fp.name)
|
copy_default_mailcap(fp.name)
|
||||||
assert fp.read()
|
assert fp.read()
|
||||||
# Check that the permissions were changed
|
# Check that the permissions were changed
|
||||||
@@ -79,7 +79,7 @@ def test_config_interface():
|
|||||||
def test_config_get_args():
|
def test_config_get_args():
|
||||||
"""Ensure that command line arguments are parsed properly"""
|
"""Ensure that command line arguments are parsed properly"""
|
||||||
|
|
||||||
args = ['rtv',
|
args = ['tuir',
|
||||||
'https://reddit.com/permalink •',
|
'https://reddit.com/permalink •',
|
||||||
'-s', 'cfb',
|
'-s', 'cfb',
|
||||||
'--log', 'logfile.log',
|
'--log', 'logfile.log',
|
||||||
@@ -95,7 +95,7 @@ def test_config_get_args():
|
|||||||
'--no-flash',
|
'--no-flash',
|
||||||
'--no-autologin']
|
'--no-autologin']
|
||||||
|
|
||||||
with mock.patch('sys.argv', ['rtv']):
|
with mock.patch('sys.argv', ['tuir']):
|
||||||
config_dict = Config.get_args()
|
config_dict = Config.get_args()
|
||||||
config = Config(**config_dict)
|
config = Config(**config_dict)
|
||||||
assert config.config == {}
|
assert config.config == {}
|
||||||
@@ -124,14 +124,14 @@ def test_config_get_args():
|
|||||||
def test_config_link_deprecated():
|
def test_config_link_deprecated():
|
||||||
|
|
||||||
# Should still be able to specify the link using the old "-l"
|
# Should still be able to specify the link using the old "-l"
|
||||||
args = ['rtv', '-l', 'https://reddit.com/option']
|
args = ['tuir', '-l', 'https://reddit.com/option']
|
||||||
with mock.patch('sys.argv', args):
|
with mock.patch('sys.argv', args):
|
||||||
config_dict = Config.get_args()
|
config_dict = Config.get_args()
|
||||||
config = Config(**config_dict)
|
config = Config(**config_dict)
|
||||||
assert config['link'] == 'https://reddit.com/option'
|
assert config['link'] == 'https://reddit.com/option'
|
||||||
|
|
||||||
# But the positional argument should take preference
|
# But the positional argument should take preference
|
||||||
args = ['rtv', 'https://reddit.com/arg', '-l', 'https://reddit.com/option']
|
args = ['tuir', 'https://reddit.com/arg', '-l', 'https://reddit.com/option']
|
||||||
with mock.patch('sys.argv', args):
|
with mock.patch('sys.argv', args):
|
||||||
config_dict = Config.get_args()
|
config_dict = Config.get_args()
|
||||||
config = Config(**config_dict)
|
config = Config(**config_dict)
|
||||||
@@ -172,9 +172,9 @@ def test_config_from_file():
|
|||||||
assert config.config == {}
|
assert config.config == {}
|
||||||
assert config.keymap._keymap == default_keymap
|
assert config.keymap._keymap == default_keymap
|
||||||
|
|
||||||
# [rtv]
|
# [tuir]
|
||||||
rows = ['{0}={1}'.format(key, val) for key, val in args.items()]
|
rows = ['{0}={1}'.format(key, val) for key, val in args.items()]
|
||||||
data = '\n'.join(['[rtv]'] + rows)
|
data = '\n'.join(['[tuir]'] + rows)
|
||||||
fp.write(codecs.encode(data, 'utf-8'))
|
fp.write(codecs.encode(data, 'utf-8'))
|
||||||
|
|
||||||
# [bindings]
|
# [bindings]
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ from collections import OrderedDict
|
|||||||
import six
|
import six
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from rtv import exceptions
|
from tuir import exceptions
|
||||||
from rtv.packages import praw
|
from tuir.packages import praw
|
||||||
from rtv.content import (
|
from tuir.content import (
|
||||||
Content, SubmissionContent, SubredditContent, SubscriptionContent,
|
Content, SubmissionContent, SubredditContent, SubscriptionContent,
|
||||||
RequestHeaderRateLimiter)
|
RequestHeaderRateLimiter)
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from rtv.packages.praw.errors import InvalidUser
|
from tuir.packages.praw.errors import InvalidUser
|
||||||
|
|
||||||
from rtv import exceptions
|
from tuir import exceptions
|
||||||
from rtv.docs import FOOTER_INBOX
|
from tuir.docs import FOOTER_INBOX
|
||||||
from rtv.inbox_page import InboxPage
|
from tuir.inbox_page import InboxPage
|
||||||
from rtv.submission_page import SubmissionPage
|
from tuir.submission_page import SubmissionPage
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from collections import OrderedDict
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from rtv.mime_parsers import parsers, ImgurApiMIMEParser
|
from tuir.mime_parsers import parsers, ImgurApiMIMEParser
|
||||||
|
|
||||||
|
|
||||||
RegexpType = type(re.compile(''))
|
RegexpType = type(re.compile(''))
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from rtv.oauth import OAuthHelper, OAuthHandler
|
from tuir.oauth import OAuthHelper, OAuthHandler
|
||||||
from rtv.exceptions import InvalidRefreshToken
|
from tuir.exceptions import InvalidRefreshToken
|
||||||
from rtv.packages.praw.errors import OAuthException
|
from tuir.packages.praw.errors import OAuthException
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -128,8 +128,8 @@ def test_oauth_authorize(oauth, reddit, stdscr, refresh_token):
|
|||||||
# Because we use `from .helpers import open_browser` we have to patch the
|
# Because we use `from .helpers import open_browser` we have to patch the
|
||||||
# function in the destination oauth module and not the helpers module
|
# function in the destination oauth module and not the helpers module
|
||||||
with mock.patch('uuid.UUID.hex', new_callable=mock.PropertyMock) as uuid, \
|
with mock.patch('uuid.UUID.hex', new_callable=mock.PropertyMock) as uuid, \
|
||||||
mock.patch('rtv.terminal.Terminal.open_browser') as open_browser, \
|
mock.patch('tuir.terminal.Terminal.open_browser') as open_browser, \
|
||||||
mock.patch('rtv.oauth.OAuthHTTPServer') as http_server, \
|
mock.patch('tuir.oauth.OAuthHTTPServer') as http_server, \
|
||||||
mock.patch.object(oauth.reddit, 'user'), \
|
mock.patch.object(oauth.reddit, 'user'), \
|
||||||
mock.patch('time.sleep'):
|
mock.patch('time.sleep'):
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import pytest
|
|||||||
import requests
|
import requests
|
||||||
from six.moves import reload_module
|
from six.moves import reload_module
|
||||||
|
|
||||||
from rtv import exceptions
|
from tuir import exceptions
|
||||||
from rtv.objects import Controller, Navigator, Command, KeyMap, \
|
from tuir.objects import Controller, Navigator, Command, KeyMap, \
|
||||||
curses_session, patch_webbrowser
|
curses_session, patch_webbrowser
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from rtv import packages
|
from tuir import packages
|
||||||
|
|
||||||
|
|
||||||
def test_praw3_package():
|
def test_praw3_package():
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import curses
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from rtv.page import Page, PageController, logged_in
|
from tuir.page import Page, PageController, logged_in
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ from collections import OrderedDict
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from rtv.submission_page import SubmissionPage
|
from tuir.submission_page import SubmissionPage
|
||||||
from rtv.docs import FOOTER_SUBMISSION
|
from tuir.docs import FOOTER_SUBMISSION
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
@@ -262,9 +262,9 @@ def test_submission_vote(submission_page, refresh_token):
|
|||||||
submission_page.oauth.authorize()
|
submission_page.oauth.authorize()
|
||||||
|
|
||||||
# Test voting on the submission
|
# Test voting on the submission
|
||||||
with mock.patch('rtv.packages.praw.objects.Submission.upvote') as upvote, \
|
with mock.patch('tuir.packages.praw.objects.Submission.upvote') as upvote, \
|
||||||
mock.patch('rtv.packages.praw.objects.Submission.downvote') as downvote, \
|
mock.patch('tuir.packages.praw.objects.Submission.downvote') as downvote, \
|
||||||
mock.patch('rtv.packages.praw.objects.Submission.clear_vote') as clear_vote:
|
mock.patch('tuir.packages.praw.objects.Submission.clear_vote') as clear_vote:
|
||||||
|
|
||||||
data = submission_page.get_selected_item()
|
data = submission_page.get_selected_item()
|
||||||
data['object'].archived = False
|
data['object'].archived = False
|
||||||
@@ -338,8 +338,8 @@ def test_submission_save(submission_page, refresh_token):
|
|||||||
submission_page.oauth.authorize()
|
submission_page.oauth.authorize()
|
||||||
|
|
||||||
# Test save on the submission
|
# Test save on the submission
|
||||||
with mock.patch('rtv.packages.praw.objects.Submission.save') as save, \
|
with mock.patch('tuir.packages.praw.objects.Submission.save') as save, \
|
||||||
mock.patch('rtv.packages.praw.objects.Submission.unsave') as unsave:
|
mock.patch('tuir.packages.praw.objects.Submission.unsave') as unsave:
|
||||||
|
|
||||||
data = submission_page.content.get(submission_page.nav.absolute_index)
|
data = submission_page.content.get(submission_page.nav.absolute_index)
|
||||||
|
|
||||||
@@ -370,8 +370,8 @@ def test_submission_comment_save(submission_page, terminal, refresh_token):
|
|||||||
submission_page.controller.trigger('j')
|
submission_page.controller.trigger('j')
|
||||||
|
|
||||||
# Test save on the comment submission
|
# Test save on the comment submission
|
||||||
with mock.patch('rtv.packages.praw.objects.Comment.save') as save, \
|
with mock.patch('tuir.packages.praw.objects.Comment.save') as save, \
|
||||||
mock.patch('rtv.packages.praw.objects.Comment.unsave') as unsave:
|
mock.patch('tuir.packages.praw.objects.Comment.unsave') as unsave:
|
||||||
|
|
||||||
data = submission_page.content.get(submission_page.nav.absolute_index)
|
data = submission_page.content.get(submission_page.nav.absolute_index)
|
||||||
|
|
||||||
@@ -398,7 +398,7 @@ def test_submission_comment(submission_page, terminal, refresh_token):
|
|||||||
submission_page.oauth.authorize()
|
submission_page.oauth.authorize()
|
||||||
|
|
||||||
# Leave a comment
|
# Leave a comment
|
||||||
with mock.patch('rtv.packages.praw.objects.Submission.add_comment') as add_comment, \
|
with mock.patch('tuir.packages.praw.objects.Submission.add_comment') as add_comment, \
|
||||||
mock.patch.object(terminal, 'open_editor') as open_editor, \
|
mock.patch.object(terminal, 'open_editor') as open_editor, \
|
||||||
mock.patch('time.sleep'):
|
mock.patch('time.sleep'):
|
||||||
open_editor.return_value.__enter__.return_value = 'comment text'
|
open_editor.return_value.__enter__.return_value = 'comment text'
|
||||||
@@ -430,7 +430,7 @@ def test_submission_delete(submission_page, terminal, refresh_token):
|
|||||||
# Spoof the author and try to delete again
|
# Spoof the author and try to delete again
|
||||||
data = submission_page.content.get(submission_page.nav.absolute_index)
|
data = submission_page.content.get(submission_page.nav.absolute_index)
|
||||||
data['author'] = submission_page.reddit.user.name
|
data['author'] = submission_page.reddit.user.name
|
||||||
with mock.patch('rtv.packages.praw.objects.Comment.delete') as delete, \
|
with mock.patch('tuir.packages.praw.objects.Comment.delete') as delete, \
|
||||||
mock.patch.object(terminal.stdscr, 'getch') as getch, \
|
mock.patch.object(terminal.stdscr, 'getch') as getch, \
|
||||||
mock.patch('time.sleep'):
|
mock.patch('time.sleep'):
|
||||||
getch.return_value = ord('y')
|
getch.return_value = ord('y')
|
||||||
@@ -454,7 +454,7 @@ def test_submission_edit(submission_page, terminal, refresh_token):
|
|||||||
# Spoof the submission and try to edit again
|
# Spoof the submission and try to edit again
|
||||||
data = submission_page.content.get(submission_page.nav.absolute_index)
|
data = submission_page.content.get(submission_page.nav.absolute_index)
|
||||||
data['author'] = submission_page.reddit.user.name
|
data['author'] = submission_page.reddit.user.name
|
||||||
with mock.patch('rtv.packages.praw.objects.Submission.edit') as edit, \
|
with mock.patch('tuir.packages.praw.objects.Submission.edit') as edit, \
|
||||||
mock.patch.object(terminal, 'open_editor') as open_editor, \
|
mock.patch.object(terminal, 'open_editor') as open_editor, \
|
||||||
mock.patch('time.sleep'):
|
mock.patch('time.sleep'):
|
||||||
open_editor.return_value.__enter__.return_value = 'submission text'
|
open_editor.return_value.__enter__.return_value = 'submission text'
|
||||||
@@ -470,7 +470,7 @@ def test_submission_edit(submission_page, terminal, refresh_token):
|
|||||||
# Spoof the author and edit the comment
|
# Spoof the author and edit the comment
|
||||||
data = submission_page.content.get(submission_page.nav.absolute_index)
|
data = submission_page.content.get(submission_page.nav.absolute_index)
|
||||||
data['author'] = submission_page.reddit.user.name
|
data['author'] = submission_page.reddit.user.name
|
||||||
with mock.patch('rtv.packages.praw.objects.Comment.edit') as edit, \
|
with mock.patch('tuir.packages.praw.objects.Comment.edit') as edit, \
|
||||||
mock.patch.object(terminal, 'open_editor') as open_editor, \
|
mock.patch.object(terminal, 'open_editor') as open_editor, \
|
||||||
mock.patch('time.sleep'):
|
mock.patch('time.sleep'):
|
||||||
open_editor.return_value.__enter__.return_value = 'comment text'
|
open_editor.return_value.__enter__.return_value = 'comment text'
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ from collections import OrderedDict
|
|||||||
import six
|
import six
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from rtv import __version__
|
from tuir import __version__
|
||||||
from rtv.subreddit_page import SubredditPage
|
from tuir.subreddit_page import SubredditPage
|
||||||
from rtv.packages.praw.errors import NotFound, HTTPException
|
from tuir.packages.praw.errors import NotFound, HTTPException
|
||||||
from requests.exceptions import ReadTimeout
|
from requests.exceptions import ReadTimeout
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -103,13 +103,13 @@ def test_subreddit_title(subreddit_page, terminal, capsys):
|
|||||||
subreddit_page.draw()
|
subreddit_page.draw()
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert isinstance(out, six.text_type)
|
assert isinstance(out, six.text_type)
|
||||||
assert out == '\x1b]2;hello ? - rtv {}\x07'.format(__version__)
|
assert out == '\x1b]2;hello ? - tuir {}\x07'.format(__version__)
|
||||||
|
|
||||||
terminal.config['ascii'] = False
|
terminal.config['ascii'] = False
|
||||||
subreddit_page.draw()
|
subreddit_page.draw()
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert isinstance(out, six.text_type)
|
assert isinstance(out, six.text_type)
|
||||||
assert out == '\x1b]2;hello ❤ - rtv {}\x07'.format(__version__)
|
assert out == '\x1b]2;hello ❤ - tuir {}\x07'.format(__version__)
|
||||||
|
|
||||||
with mock.patch.dict('os.environ', {'DISPLAY': ''}):
|
with mock.patch.dict('os.environ', {'DISPLAY': ''}):
|
||||||
subreddit_page.draw()
|
subreddit_page.draw()
|
||||||
@@ -313,7 +313,7 @@ def test_subreddit_open(subreddit_page, terminal, config):
|
|||||||
assert terminal.open_link.called
|
assert terminal.open_link.called
|
||||||
config.history.add.assert_called_with(data['url_full'])
|
config.history.add.assert_called_with(data['url_full'])
|
||||||
|
|
||||||
# Open the selected link within rtv
|
# Open the selected link within tuir
|
||||||
data = subreddit_page.content.get(subreddit_page.nav.absolute_index)
|
data = subreddit_page.content.get(subreddit_page.nav.absolute_index)
|
||||||
with mock.patch.object(subreddit_page, 'open_submission'), \
|
with mock.patch.object(subreddit_page, 'open_submission'), \
|
||||||
mock.patch.object(config.history, 'add'):
|
mock.patch.object(config.history, 'add'):
|
||||||
@@ -404,7 +404,7 @@ def test_subreddit_open_subscriptions(subreddit_page, refresh_token):
|
|||||||
assert subreddit_page.selected_page
|
assert subreddit_page.selected_page
|
||||||
assert subreddit_page.active
|
assert subreddit_page.active
|
||||||
|
|
||||||
with mock.patch('rtv.page.Page.loop') as loop:
|
with mock.patch('tuir.page.Page.loop') as loop:
|
||||||
subreddit_page.handle_selected_page()
|
subreddit_page.handle_selected_page()
|
||||||
assert loop.called
|
assert loop.called
|
||||||
|
|
||||||
@@ -435,7 +435,7 @@ def test_subreddit_open_multireddits(subreddit_page, refresh_token):
|
|||||||
assert subreddit_page.selected_page
|
assert subreddit_page.selected_page
|
||||||
assert subreddit_page.active
|
assert subreddit_page.active
|
||||||
|
|
||||||
with mock.patch('rtv.page.Page.loop') as loop:
|
with mock.patch('tuir.page.Page.loop') as loop:
|
||||||
subreddit_page.handle_selected_page()
|
subreddit_page.handle_selected_page()
|
||||||
assert loop.called
|
assert loop.called
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import curses
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from rtv.subscription_page import SubscriptionPage
|
from tuir.subscription_page import SubscriptionPage
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
@@ -56,7 +56,7 @@ def test_subscription_page_construct(reddit, terminal, config, oauth,
|
|||||||
|
|
||||||
def test_subscription_refresh(subscription_page):
|
def test_subscription_refresh(subscription_page):
|
||||||
|
|
||||||
with mock.patch('rtv.terminal.Terminal.flash') as flash:
|
with mock.patch('tuir.terminal.Terminal.flash') as flash:
|
||||||
# Refresh content - invalid order
|
# Refresh content - invalid order
|
||||||
subscription_page.refresh_content(order='top')
|
subscription_page.refresh_content(order='top')
|
||||||
assert flash.called
|
assert flash.called
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ from textwrap import dedent
|
|||||||
import six
|
import six
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from rtv.theme import Theme
|
from tuir.theme import Theme
|
||||||
from rtv.docs import (HELP, REPLY_FILE, COMMENT_EDIT_FILE, TOKEN,
|
from tuir.docs import (HELP, REPLY_FILE, COMMENT_EDIT_FILE, TOKEN,
|
||||||
SUBMISSION_FILE, SUBMISSION_EDIT_FILE, MESSAGE_FILE)
|
SUBMISSION_FILE, SUBMISSION_EDIT_FILE, MESSAGE_FILE)
|
||||||
from rtv.exceptions import TemporaryFileError, BrowserError
|
from tuir.exceptions import TemporaryFileError, BrowserError
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
@@ -29,13 +29,13 @@ def test_terminal_properties(terminal, config):
|
|||||||
assert isinstance(terminal.gilded, six.text_type)
|
assert isinstance(terminal.gilded, six.text_type)
|
||||||
|
|
||||||
terminal._display = None
|
terminal._display = None
|
||||||
with mock.patch('rtv.terminal.sys') as sys, \
|
with mock.patch('tuir.terminal.sys') as sys, \
|
||||||
mock.patch.dict('os.environ', {'DISPLAY': ''}):
|
mock.patch.dict('os.environ', {'DISPLAY': ''}):
|
||||||
sys.platform = 'linux'
|
sys.platform = 'linux'
|
||||||
assert terminal.display is False
|
assert terminal.display is False
|
||||||
|
|
||||||
terminal._display = None
|
terminal._display = None
|
||||||
with mock.patch('rtv.terminal.sys') as sys, \
|
with mock.patch('tuir.terminal.sys') as sys, \
|
||||||
mock.patch('os.environ', {'DISPLAY': ''}), \
|
mock.patch('os.environ', {'DISPLAY': ''}), \
|
||||||
mock.patch('webbrowser._tryorder', new=[]):
|
mock.patch('webbrowser._tryorder', new=[]):
|
||||||
sys.platform = 'darwin'
|
sys.platform = 'darwin'
|
||||||
@@ -367,7 +367,7 @@ def test_terminal_open_link_mailcap(terminal):
|
|||||||
mock_mime_parser = MockMimeParser()
|
mock_mime_parser = MockMimeParser()
|
||||||
|
|
||||||
with mock.patch.object(terminal, 'open_browser'), \
|
with mock.patch.object(terminal, 'open_browser'), \
|
||||||
mock.patch('rtv.terminal.mime_parsers') as mime_parsers:
|
mock.patch('tuir.terminal.mime_parsers') as mime_parsers:
|
||||||
mime_parsers.parsers = [mock_mime_parser]
|
mime_parsers.parsers = [mock_mime_parser]
|
||||||
|
|
||||||
# Pass through to open_browser if media is disabled
|
# Pass through to open_browser if media is disabled
|
||||||
@@ -490,7 +490,7 @@ def test_terminal_open_browser_display(terminal):
|
|||||||
def test_terminal_open_browser_display_no_response(terminal):
|
def test_terminal_open_browser_display_no_response(terminal):
|
||||||
|
|
||||||
terminal._display = True
|
terminal._display = True
|
||||||
with mock.patch('rtv.terminal.Process', autospec=True) as Process:
|
with mock.patch('tuir.terminal.Process', autospec=True) as Process:
|
||||||
Process.return_value.is_alive.return_value = 1
|
Process.return_value.is_alive.return_value = 1
|
||||||
terminal.open_browser('http://www.test.com')
|
terminal.open_browser('http://www.test.com')
|
||||||
assert isinstance(terminal.loader.exception, BrowserError)
|
assert isinstance(terminal.loader.exception, BrowserError)
|
||||||
@@ -738,7 +738,7 @@ def test_terminal_get_link_page_text(terminal):
|
|||||||
{'href': 'https://www.reddit.com', 'text': 'Reddit Homepage'},
|
{'href': 'https://www.reddit.com', 'text': 'Reddit Homepage'},
|
||||||
{'href': 'https://www.duckduckgo.com', 'text': 'Search Engine'},
|
{'href': 'https://www.duckduckgo.com', 'text': 'Search Engine'},
|
||||||
{
|
{
|
||||||
'href': 'https://gitlab.com/ajak/rtv',
|
'href': 'https://gitlab.com/ajak/tuir',
|
||||||
'text': 'This project\'s homepage'
|
'text': 'This project\'s homepage'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -747,7 +747,7 @@ def test_terminal_get_link_page_text(terminal):
|
|||||||
assert text == dedent("""\
|
assert text == dedent("""\
|
||||||
[0] [Reddit Homepage](https://www.reddit.com)
|
[0] [Reddit Homepage](https://www.reddit.com)
|
||||||
[1] [Search Engine](https://www.duckduckgo.com)
|
[1] [Search Engine](https://www.duckduckgo.com)
|
||||||
[2] [This project's home…](https://gitlab.com/ajak/rtv)
|
[2] [This project's home…](https://gitlab.com/ajak/tuir)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ from tempfile import mkdtemp, NamedTemporaryFile
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from rtv.theme import Theme
|
from tuir.theme import Theme
|
||||||
from rtv.config import DEFAULT_THEMES
|
from tuir.config import DEFAULT_THEMES
|
||||||
from rtv.exceptions import ConfigError
|
from tuir.exceptions import ConfigError
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
.TH "RTV" "1" "June 08, 2019" "Version 1.27.0" "Usage and Commands"
|
.TH "TUIR" "1" "June 10, 2019" "Version 1.27.0" "Usage and Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
RTV - Reddit Terminal Viewer
|
TUIR - Terminal UI for Reddit
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
rtv [URL] [\-s SUBREDDIT]
|
tuir [URL] [\-s SUBREDDIT]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
RTV (Reddit Terminal Viewer) is a terminal interface to view and interact with reddit.
|
TUIR (Terminal UI for Reddit) is a terminal interface to view and interact with reddit.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
\fBURL\fR
|
\fBURL\fR
|
||||||
@@ -56,7 +56,7 @@ Remove any saved user data before launching
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-copy\-config\fR
|
\fB\-\-copy\-config\fR
|
||||||
Copy the default configuration to {HOME}/.config/rtv/rtv.cfg
|
Copy the default configuration to {HOME}/.config/tuir/tuir.cfg
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-copy\-mailcap\fR
|
\fB\-\-copy\-mailcap\fR
|
||||||
@@ -89,32 +89,32 @@ Press \fBright\fR to view the selected submission and \fBleft\fR to return.
|
|||||||
Press \fB?\fR to open the help screen.
|
Press \fB?\fR to open the help screen.
|
||||||
.SH FILES
|
.SH FILES
|
||||||
.TP
|
.TP
|
||||||
.BR $XDG_CONFIG_HOME/rtv/rtv.cfg
|
.BR $XDG_CONFIG_HOME/tuir/tuir.cfg
|
||||||
The configuration file can be used to customize default program settings.
|
The configuration file can be used to customize default program settings.
|
||||||
.TP
|
.TP
|
||||||
.BR $XDG_DATA_HOME/rtv/refresh-token
|
.BR $XDG_DATA_HOME/tuir/refresh-token
|
||||||
After you login to reddit, your most recent OAuth refresh token will be stored
|
After you login to reddit, your most recent OAuth refresh token will be stored
|
||||||
for future sessions.
|
for future sessions.
|
||||||
.TP
|
.TP
|
||||||
.BR $XDG_DATA_HOME/rtv/history.log
|
.BR $XDG_DATA_HOME/tuir/history.log
|
||||||
This file stores URLs that have been recently opened in order to
|
This file stores URLs that have been recently opened in order to
|
||||||
visually highlight them as "seen".
|
visually highlight them as "seen".
|
||||||
.SH ENVIRONMENT
|
.SH ENVIRONMENT
|
||||||
.TP
|
.TP
|
||||||
.BR RTV_EDITOR
|
.BR TUIR_EDITOR
|
||||||
Text editor to use when editing comments and submissions. Will fallback to
|
Text editor to use when editing comments and submissions. Will fallback to
|
||||||
\fI$EDITOR\fR.
|
\fI$EDITOR\fR.
|
||||||
.TP
|
.TP
|
||||||
.BR RTV_URLVIEWER
|
.BR TUIR_URLVIEWER
|
||||||
Url viewer to use to extract links from comments. Requires a compatible
|
Url viewer to use to extract links from comments. Requires a compatible
|
||||||
program to be installed.
|
program to be installed.
|
||||||
.TP
|
.TP
|
||||||
.BR RTV_BROWSER
|
.BR TUIR_BROWSER
|
||||||
Web browser to use when opening links. Will fallback to \fI$BROWSER\fR.
|
Web browser to use when opening links. Will fallback to \fI$BROWSER\fR.
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
Michael Lazar <lazar.michael22@gmail.com> (2017).
|
Michael Lazar <lazar.michael22@gmail.com> (2017).
|
||||||
John Helmert <jchelmertt3@gmail.com> (2019).
|
John Helmert III <jchelmertt3@gmail.com> (2019).
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report bugs to \fIhttps://gitlab.com/ajak/rtv/issues\fR
|
Report bugs to \fIhttps://gitlab.com/ajak/tuir/issues\fR
|
||||||
.SH LICENSE
|
.SH LICENSE
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
27
tuir/__init__.py
Normal file
27
tuir/__init__.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
r"""
|
||||||
|
|
||||||
|
______ _ __ __ ______ ____
|
||||||
|
/_ __/__ _________ ___ (_)___ ____ _/ / / / / / _/ / __/___ _____
|
||||||
|
/ / / _ \/ ___/ __ `__ \/ / __ \/ __ `/ / / / / // / / /_/ __ \/ ___/
|
||||||
|
/ / / __/ / / / / / / / / / / / /_/ / / / /_/ // / / __/ /_/ / /
|
||||||
|
/_/ \___/_/ /_/ /_/ /_/_/_/ /_/\__,_/_/ \____/___/ /_/ \____/_/
|
||||||
|
|
||||||
|
____ __ ___ __
|
||||||
|
/ __ \___ ____/ /___/ (_) /_
|
||||||
|
/ /_/ / _ \/ __ / __ / / __/
|
||||||
|
/ _, _/ __/ /_/ / /_/ / / /_
|
||||||
|
/_/ |_|\___/\__,_/\__,_/_/\__/
|
||||||
|
|
||||||
|
|
||||||
|
(TUIR)
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from .__version__ import __version__
|
||||||
|
|
||||||
|
__title__ = 'Terminal UI for Reddit'
|
||||||
|
__author__ = 'Michael Lazar'
|
||||||
|
__license__ = 'The MIT License (MIT)'
|
||||||
|
__copyright__ = '(c) 2016 Michael Lazar, portions (c) 2019 John Helmert III'
|
||||||
@@ -13,7 +13,7 @@ import warnings
|
|||||||
import six
|
import six
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
# Need to check for curses compatibility before performing the rtv imports
|
# Need to check for curses compatibility before performing the tuir imports
|
||||||
try:
|
try:
|
||||||
import curses
|
import curses
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -28,9 +28,9 @@ except ImportError:
|
|||||||
# references, it needs to be done before the webbrowser module is imported
|
# references, it needs to be done before the webbrowser module is imported
|
||||||
# for the first time.
|
# for the first time.
|
||||||
webbrowser_import_warning = ('webbrowser' in sys.modules)
|
webbrowser_import_warning = ('webbrowser' in sys.modules)
|
||||||
RTV_BROWSER, BROWSER = os.environ.get('RTV_BROWSER'), os.environ.get('BROWSER')
|
TUIR_BROWSER, BROWSER = os.environ.get('TUIR_BROWSER'), os.environ.get('BROWSER')
|
||||||
if RTV_BROWSER:
|
if TUIR_BROWSER:
|
||||||
os.environ['BROWSER'] = RTV_BROWSER
|
os.environ['BROWSER'] = TUIR_BROWSER
|
||||||
|
|
||||||
from . import docs
|
from . import docs
|
||||||
from . import packages
|
from . import packages
|
||||||
@@ -50,8 +50,8 @@ _logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
# Pycharm debugging note:
|
# Pycharm debugging note:
|
||||||
# You can use pycharm to debug a curses application by launching rtv in a
|
# You can use pycharm to debug a curses application by launching tuir in a
|
||||||
# console window (python -m rtv) and using pycharm to attach to the remote
|
# console window (python -m tuir) and using pycharm to attach to the remote
|
||||||
# process. On Ubuntu, you may need to allow ptrace permissions by setting
|
# process. On Ubuntu, you may need to allow ptrace permissions by setting
|
||||||
# ptrace_scope to 0 in /etc/sysctl.d/10-ptrace.conf.
|
# ptrace_scope to 0 in /etc/sysctl.d/10-ptrace.conf.
|
||||||
# http://blog.mellenthin.de/archives/2010/10/18/gdb-attach-fails
|
# http://blog.mellenthin.de/archives/2010/10/18/gdb-attach-fails
|
||||||
@@ -68,7 +68,7 @@ def main():
|
|||||||
|
|
||||||
# Set the terminal title
|
# Set the terminal title
|
||||||
if os.getenv('DISPLAY'):
|
if os.getenv('DISPLAY'):
|
||||||
title = 'rtv {0}'.format(__version__)
|
title = 'tuir {0}'.format(__version__)
|
||||||
sys.stdout.write('\x1b]2;{0}\x07'.format(title))
|
sys.stdout.write('\x1b]2;{0}\x07'.format(title))
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
@@ -150,8 +150,8 @@ def main():
|
|||||||
user_agent = docs.AGENT.format(version=__version__)
|
user_agent = docs.AGENT.format(version=__version__)
|
||||||
|
|
||||||
debug_info = [
|
debug_info = [
|
||||||
'rtv version: rtv {}'.format(__version__),
|
'tuir version: tuir {}'.format(__version__),
|
||||||
'rtv module path: {}'.format(os.path.abspath(__file__)),
|
'tuir module path: {}'.format(os.path.abspath(__file__)),
|
||||||
'python version: {}'.format(sys.version.replace('\n', ' ')),
|
'python version: {}'.format(sys.version.replace('\n', ' ')),
|
||||||
'python executable: {}'.format(sys.executable),
|
'python executable: {}'.format(sys.executable),
|
||||||
'praw version: {}'.format(praw_info),
|
'praw version: {}'.format(praw_info),
|
||||||
@@ -163,10 +163,10 @@ def main():
|
|||||||
('EDITOR', os.getenv('EDITOR')),
|
('EDITOR', os.getenv('EDITOR')),
|
||||||
('LANG', os.getenv('LANG')),
|
('LANG', os.getenv('LANG')),
|
||||||
('PAGER', os.getenv('PAGER')),
|
('PAGER', os.getenv('PAGER')),
|
||||||
('RTV_BROWSER', RTV_BROWSER),
|
('TUIR_BROWSER', TUIR_BROWSER),
|
||||||
('RTV_EDITOR', os.getenv('RTV_EDITOR')),
|
('TUIR_EDITOR', os.getenv('TUIR_EDITOR')),
|
||||||
('RTV_PAGER', os.getenv('RTV_PAGER')),
|
('TUIR_PAGER', os.getenv('TUIR_PAGER')),
|
||||||
('RTV_URLVIEWER', os.getenv('RTV_URLVIEWER')),
|
('TUIR_URLVIEWER', os.getenv('TUIR_URLVIEWER')),
|
||||||
('TERM', os.getenv('TERM')),
|
('TERM', os.getenv('TERM')),
|
||||||
('VISUAL', os.getenv('VISUAL')),
|
('VISUAL', os.getenv('VISUAL')),
|
||||||
('XDG_CONFIG_HOME', os.getenv('XDG_CONFIG_HOME')),
|
('XDG_CONFIG_HOME', os.getenv('XDG_CONFIG_HOME')),
|
||||||
@@ -263,8 +263,8 @@ def main():
|
|||||||
exit_message = '\n'.join([
|
exit_message = '\n'.join([
|
||||||
debug_text,
|
debug_text,
|
||||||
traceback.format_exc(),
|
traceback.format_exc(),
|
||||||
'rtv has crashed. Please report this traceback at:',
|
'tuir has crashed. Please report this traceback at:',
|
||||||
'https://gitlab.com/ajak/rtv/issues\n'])
|
'https://gitlab.com/ajak/tuir/issues\n'])
|
||||||
sys.stderr.write(exit_message)
|
sys.stderr.write(exit_message)
|
||||||
return 1 # General error exception code
|
return 1 # General error exception code
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
@@ -16,21 +16,21 @@ from .objects import KeyMap
|
|||||||
PACKAGE = os.path.dirname(__file__)
|
PACKAGE = os.path.dirname(__file__)
|
||||||
HOME = os.path.expanduser('~')
|
HOME = os.path.expanduser('~')
|
||||||
TEMPLATES = os.path.join(PACKAGE, 'templates')
|
TEMPLATES = os.path.join(PACKAGE, 'templates')
|
||||||
DEFAULT_CONFIG = os.path.join(TEMPLATES, 'rtv.cfg')
|
DEFAULT_CONFIG = os.path.join(TEMPLATES, 'tuir.cfg')
|
||||||
DEFAULT_MAILCAP = os.path.join(TEMPLATES, 'mailcap')
|
DEFAULT_MAILCAP = os.path.join(TEMPLATES, 'mailcap')
|
||||||
DEFAULT_THEMES = os.path.join(PACKAGE, 'themes')
|
DEFAULT_THEMES = os.path.join(PACKAGE, 'themes')
|
||||||
XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.join(HOME, '.config'))
|
XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.join(HOME, '.config'))
|
||||||
XDG_DATA_HOME = os.getenv('XDG_DATA_HOME', os.path.join(HOME, '.local', 'share'))
|
XDG_DATA_HOME = os.getenv('XDG_DATA_HOME', os.path.join(HOME, '.local', 'share'))
|
||||||
CONFIG = os.path.join(XDG_CONFIG_HOME, 'rtv', 'rtv.cfg')
|
CONFIG = os.path.join(XDG_CONFIG_HOME, 'tuir', 'tuir.cfg')
|
||||||
MAILCAP = os.path.join(HOME, '.mailcap')
|
MAILCAP = os.path.join(HOME, '.mailcap')
|
||||||
TOKEN = os.path.join(XDG_DATA_HOME, 'rtv', 'refresh-token')
|
TOKEN = os.path.join(XDG_DATA_HOME, 'tuir', 'refresh-token')
|
||||||
HISTORY = os.path.join(XDG_DATA_HOME, 'rtv', 'history.log')
|
HISTORY = os.path.join(XDG_DATA_HOME, 'tuir', 'history.log')
|
||||||
THEMES = os.path.join(XDG_CONFIG_HOME, 'rtv', 'themes')
|
THEMES = os.path.join(XDG_CONFIG_HOME, 'tuir', 'themes')
|
||||||
|
|
||||||
|
|
||||||
def build_parser():
|
def build_parser():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
prog='rtv', description=docs.SUMMARY,
|
prog='tuir', description=docs.SUMMARY,
|
||||||
epilog=docs.CONTROLS,
|
epilog=docs.CONTROLS,
|
||||||
usage=docs.USAGE,
|
usage=docs.USAGE,
|
||||||
formatter_class=argparse.RawDescriptionHelpFormatter)
|
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||||
@@ -72,7 +72,7 @@ def build_parser():
|
|||||||
help='Remove any saved user data before launching')
|
help='Remove any saved user data before launching')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--copy-config', dest='copy_config', action='store_const', const=True,
|
'--copy-config', dest='copy_config', action='store_const', const=True,
|
||||||
help='Copy the default configuration to {HOME}/.config/rtv/rtv.cfg')
|
help='Copy the default configuration to {HOME}/.config/tuir/tuir.cfg')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--copy-mailcap', dest='copy_mailcap', action='store_const', const=True,
|
'--copy-mailcap', dest='copy_mailcap', action='store_const', const=True,
|
||||||
help='Copy an example mailcap configuration to {HOME}/.mailcap')
|
help='Copy an example mailcap configuration to {HOME}/.mailcap')
|
||||||
@@ -80,7 +80,7 @@ def build_parser():
|
|||||||
'--enable-media', dest='enable_media', action='store_const', const=True,
|
'--enable-media', dest='enable_media', action='store_const', const=True,
|
||||||
help='Open external links using programs defined in the mailcap config')
|
help='Open external links using programs defined in the mailcap config')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-V', '--version', action='version', version='rtv ' + __version__)
|
'-V', '--version', action='version', version='tuir ' + __version__)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--no-flash', dest='flash', action='store_const', const=False,
|
'--no-flash', dest='flash', action='store_const', const=False,
|
||||||
help='Disable screen flashing')
|
help='Disable screen flashing')
|
||||||
@@ -99,7 +99,7 @@ def copy_default_mailcap(filename=MAILCAP):
|
|||||||
|
|
||||||
def copy_default_config(filename=CONFIG):
|
def copy_default_config(filename=CONFIG):
|
||||||
"""
|
"""
|
||||||
Copy the default rtv user configuration to the specified file.
|
Copy the default tuir user configuration to the specified file.
|
||||||
"""
|
"""
|
||||||
return _copy_settings_file(DEFAULT_CONFIG, filename, 'config')
|
return _copy_settings_file(DEFAULT_CONFIG, filename, 'config')
|
||||||
|
|
||||||
@@ -241,7 +241,7 @@ class Config(object):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_file(cls, filename=None):
|
def get_file(cls, filename=None):
|
||||||
"""
|
"""
|
||||||
Load settings from an rtv configuration file.
|
Load settings from an tuir configuration file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if filename is None:
|
if filename is None:
|
||||||
@@ -252,36 +252,36 @@ class Config(object):
|
|||||||
with codecs.open(filename, encoding='utf-8') as fp:
|
with codecs.open(filename, encoding='utf-8') as fp:
|
||||||
config.read_file(fp)
|
config.read_file(fp)
|
||||||
|
|
||||||
return cls._parse_rtv_file(config)
|
return cls._parse_tuir_file(config)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_rtv_file(config):
|
def _parse_tuir_file(config):
|
||||||
|
|
||||||
rtv = {}
|
tuir = {}
|
||||||
if config.has_section('rtv'):
|
if config.has_section('tuir'):
|
||||||
rtv = dict(config.items('rtv'))
|
tuir = dict(config.items('tuir'))
|
||||||
|
|
||||||
# convert non-string params to their typed representation
|
# convert non-string params to their typed representation
|
||||||
params = {
|
params = {
|
||||||
'ascii': partial(config.getboolean, 'rtv'),
|
'ascii': partial(config.getboolean, 'tuir'),
|
||||||
'monochrome': partial(config.getboolean, 'rtv'),
|
'monochrome': partial(config.getboolean, 'tuir'),
|
||||||
'persistent': partial(config.getboolean, 'rtv'),
|
'persistent': partial(config.getboolean, 'tuir'),
|
||||||
'autologin': partial(config.getboolean, 'rtv'),
|
'autologin': partial(config.getboolean, 'tuir'),
|
||||||
'clear_auth': partial(config.getboolean, 'rtv'),
|
'clear_auth': partial(config.getboolean, 'tuir'),
|
||||||
'enable_media': partial(config.getboolean, 'rtv'),
|
'enable_media': partial(config.getboolean, 'tuir'),
|
||||||
'history_size': partial(config.getint, 'rtv'),
|
'history_size': partial(config.getint, 'tuir'),
|
||||||
'oauth_redirect_port': partial(config.getint, 'rtv'),
|
'oauth_redirect_port': partial(config.getint, 'tuir'),
|
||||||
'oauth_scope': lambda x: rtv[x].split(','),
|
'oauth_scope': lambda x: tuir[x].split(','),
|
||||||
'max_comment_cols': partial(config.getint, 'rtv'),
|
'max_comment_cols': partial(config.getint, 'tuir'),
|
||||||
'max_pager_cols': partial(config.getint, 'rtv'),
|
'max_pager_cols': partial(config.getint, 'tuir'),
|
||||||
'hide_username': partial(config.getboolean, 'rtv'),
|
'hide_username': partial(config.getboolean, 'tuir'),
|
||||||
'flash': partial(config.getboolean, 'rtv'),
|
'flash': partial(config.getboolean, 'tuir'),
|
||||||
'force_new_browser_window': partial(config.getboolean, 'rtv')
|
'force_new_browser_window': partial(config.getboolean, 'tuir')
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, func in params.items():
|
for key, func in params.items():
|
||||||
if key in rtv:
|
if key in tuir:
|
||||||
rtv[key] = func(key)
|
tuir[key] = func(key)
|
||||||
|
|
||||||
bindings = {}
|
bindings = {}
|
||||||
if config.has_section('bindings'):
|
if config.has_section('bindings'):
|
||||||
@@ -290,7 +290,7 @@ class Config(object):
|
|||||||
for name, keys in bindings.items():
|
for name, keys in bindings.items():
|
||||||
bindings[name] = [key.strip() for key in keys.split(',')]
|
bindings[name] = [key.strip() for key in keys.split(',')]
|
||||||
|
|
||||||
return rtv, bindings
|
return tuir, bindings
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _ensure_filepath(filename):
|
def _ensure_filepath(filename):
|
||||||
@@ -1041,7 +1041,7 @@ class RequestHeaderRateLimiter(DefaultHandler):
|
|||||||
|
|
||||||
# In PRAW's convention, these variables were bound to the
|
# In PRAW's convention, these variables were bound to the
|
||||||
# class so the cache could be shared among all of the ``reddit``
|
# class so the cache could be shared among all of the ``reddit``
|
||||||
# instances. In RTV's use-case there is only ever a single reddit
|
# instances. In TUIR's use-case there is only ever a single reddit
|
||||||
# instance so it made sense to clean up the globals and transfer them
|
# instance so it made sense to clean up the globals and transfer them
|
||||||
# to method variables
|
# to method variables
|
||||||
self.cache = {}
|
self.cache = {}
|
||||||
@@ -1150,8 +1150,8 @@ class RequestHeaderRateLimiter(DefaultHandler):
|
|||||||
_cache_key = (url, (items[0], items[1], items[3], items[4]))
|
_cache_key = (url, (items[0], items[1], items[3], items[4]))
|
||||||
|
|
||||||
if kwargs['request'].method != 'GET':
|
if kwargs['request'].method != 'GET':
|
||||||
# I added this check for RTV, I have no idea why PRAW would ever
|
# I [michael-lazar] added this check for RTV, I have no idea
|
||||||
# want to cache POST/PUT/DELETE requests
|
# why PRAW would ever want to cache POST/PUT/DELETE requests
|
||||||
_cache_ignore = True
|
_cache_ignore = True
|
||||||
|
|
||||||
if _cache_ignore:
|
if _cache_ignore:
|
||||||
@@ -2,19 +2,19 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
AGENT = """\
|
AGENT = """\
|
||||||
desktop:https://github.com/ajak/rtv:{version}\
|
desktop:https://gitlab.com/ajak/tuir:{version}\
|
||||||
(by /u/civilization_phaze_3)\
|
(by /u/ajak__)\
|
||||||
"""
|
"""
|
||||||
|
|
||||||
SUMMARY = """
|
SUMMARY = """
|
||||||
RTV (Reddit Terminal Viewer) is a terminal interface to view and interact with reddit.
|
TUIR (Terminal UI for Reddit) is a terminal interface to view and interact with reddit.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
USAGE = """\
|
USAGE = """\
|
||||||
rtv [URL] [-s SUBREDDIT]
|
tuir [URL] [-s SUBREDDIT]
|
||||||
|
|
||||||
$ rtv https://www.reddit.com/r/programming/comments/7h9l31
|
$ tuir https://www.reddit.com/r/programming/comments/7h9l31
|
||||||
$ rtv -s linux
|
$ tuir -s linux
|
||||||
"""
|
"""
|
||||||
|
|
||||||
CONTROLS = """
|
CONTROLS = """
|
||||||
@@ -24,9 +24,9 @@ Press `?` to open the help screen.
|
|||||||
|
|
||||||
HELP = """\
|
HELP = """\
|
||||||
====================================
|
====================================
|
||||||
Reddit Terminal Viewer
|
Terminal UI for Reddit
|
||||||
|
|
||||||
https://github.com/ajak/rtv
|
https://github.com/ajak/tuir
|
||||||
====================================
|
====================================
|
||||||
|
|
||||||
[Basic Commands]
|
[Basic Commands]
|
||||||
@@ -196,7 +196,7 @@ Enter your message below this instruction block:
|
|||||||
|
|
||||||
OAUTH_ACCESS_DENIED = """\
|
OAUTH_ACCESS_DENIED = """\
|
||||||
<h1 style="color: red">Access Denied</h1><hr>
|
<h1 style="color: red">Access Denied</h1><hr>
|
||||||
<p><span style="font-weight: bold">Reddit Terminal Viewer</span> was
|
<p><span style="font-weight: bold">Terminal UI for Reddit</span> was
|
||||||
denied access and will continue to operate in unauthenticated mode,
|
denied access and will continue to operate in unauthenticated mode,
|
||||||
you can close this window.</p>
|
you can close this window.</p>
|
||||||
"""
|
"""
|
||||||
@@ -214,7 +214,7 @@ OAUTH_INVALID = """\
|
|||||||
|
|
||||||
OAUTH_SUCCESS = """\
|
OAUTH_SUCCESS = """\
|
||||||
<h1 style="color: green">Access Granted</h1><hr>
|
<h1 style="color: green">Access Granted</h1><hr>
|
||||||
<p><span style="font-weight: bold">Reddit Terminal Viewer</span>
|
<p><span style="font-weight: bold">Terminal UI for Reddit</span>
|
||||||
will now log in, you can close this window.</p>
|
will now log in, you can close this window.</p>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -10,23 +10,23 @@ class ConfigError(Exception):
|
|||||||
"There was a problem with the configuration"
|
"There was a problem with the configuration"
|
||||||
|
|
||||||
|
|
||||||
class RTVError(Exception):
|
class TUIRError(Exception):
|
||||||
"Base RTV error class"
|
"Base TUIR error class"
|
||||||
|
|
||||||
|
|
||||||
class AccountError(RTVError):
|
class AccountError(TUIRError):
|
||||||
"Could not access user account"
|
"Could not access user account"
|
||||||
|
|
||||||
|
|
||||||
class SubmissionError(RTVError):
|
class SubmissionError(TUIRError):
|
||||||
"Submission could not be loaded"
|
"Submission could not be loaded"
|
||||||
|
|
||||||
|
|
||||||
class SubredditError(RTVError):
|
class SubredditError(TUIRError):
|
||||||
"Subreddit could not be loaded"
|
"Subreddit could not be loaded"
|
||||||
|
|
||||||
|
|
||||||
class NoSubmissionsError(RTVError):
|
class NoSubmissionsError(TUIRError):
|
||||||
"No submissions for the given page"
|
"No submissions for the given page"
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
@@ -35,29 +35,29 @@ class NoSubmissionsError(RTVError):
|
|||||||
super(NoSubmissionsError, self).__init__(message)
|
super(NoSubmissionsError, self).__init__(message)
|
||||||
|
|
||||||
|
|
||||||
class SubscriptionError(RTVError):
|
class SubscriptionError(TUIRError):
|
||||||
"Content could not be fetched"
|
"Content could not be fetched"
|
||||||
|
|
||||||
|
|
||||||
class InboxError(RTVError):
|
class InboxError(TUIRError):
|
||||||
"Content could not be fetched"
|
"Content could not be fetched"
|
||||||
|
|
||||||
|
|
||||||
class ProgramError(RTVError):
|
class ProgramError(TUIRError):
|
||||||
"Problem executing an external program"
|
"Problem executing an external program"
|
||||||
|
|
||||||
|
|
||||||
class BrowserError(RTVError):
|
class BrowserError(TUIRError):
|
||||||
"Could not open a web browser tab"
|
"Could not open a web browser tab"
|
||||||
|
|
||||||
|
|
||||||
class TemporaryFileError(RTVError):
|
class TemporaryFileError(TUIRError):
|
||||||
"Indicates that an error has occurred and the file should not be deleted"
|
"Indicates that an error has occurred and the file should not be deleted"
|
||||||
|
|
||||||
|
|
||||||
class MailcapEntryNotFound(RTVError):
|
class MailcapEntryNotFound(TUIRError):
|
||||||
"A valid mailcap entry could not be coerced from the given url"
|
"A valid mailcap entry could not be coerced from the given url"
|
||||||
|
|
||||||
|
|
||||||
class InvalidRefreshToken(RTVError):
|
class InvalidRefreshToken(TUIRError):
|
||||||
"The refresh token is corrupt and cannot be used to login"
|
"The refresh token is corrupt and cannot be used to login"
|
||||||
@@ -202,9 +202,9 @@ class ImgurApiMIMEParser(BaseMIMEParser):
|
|||||||
page has an associated hash and can either contain an album, a gallery,
|
page has an associated hash and can either contain an album, a gallery,
|
||||||
or single image.
|
or single image.
|
||||||
|
|
||||||
The default client token for RTV is shared among users and allows a maximum
|
The default client token for TUIR is shared among users and allows a maximum
|
||||||
global number of requests per day of 12,500. If we find that this limit is
|
global number of requests per day of 12,500. If we find that this limit is
|
||||||
not sufficient for all of rtv's traffic, this method will be revisited.
|
not sufficient for all of tuir's traffic, this method will be revisited.
|
||||||
|
|
||||||
Reference:
|
Reference:
|
||||||
https://apidocs.imgur.com
|
https://apidocs.imgur.com
|
||||||
@@ -167,7 +167,7 @@ class OAuthHelper(object):
|
|||||||
else:
|
else:
|
||||||
if not autologin:
|
if not autologin:
|
||||||
# Only show the welcome message if explicitly logging
|
# Only show the welcome message if explicitly logging
|
||||||
# in, not when RTV first launches.
|
# in, not when TUIR first launches.
|
||||||
message = 'Welcome {}!'.format(self.reddit.user.name)
|
message = 'Welcome {}!'.format(self.reddit.user.name)
|
||||||
self.term.show_notification(message)
|
self.term.show_notification(message)
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ class LoadScreen(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
EXCEPTION_MESSAGES = [
|
EXCEPTION_MESSAGES = [
|
||||||
(exceptions.RTVError, '{0}'),
|
(exceptions.TUIRError, '{0}'),
|
||||||
(praw.errors.OAuthException, 'OAuth Error'),
|
(praw.errors.OAuthException, 'OAuth Error'),
|
||||||
(praw.errors.OAuthScopeRequired, 'Not logged in'),
|
(praw.errors.OAuthScopeRequired, 'Not logged in'),
|
||||||
(praw.errors.LoginRequired, 'Not logged in'),
|
(praw.errors.LoginRequired, 'Not logged in'),
|
||||||
@@ -21,6 +21,6 @@ except ImportError:
|
|||||||
|
|
||||||
if not praw.__version__.startswith('3.'):
|
if not praw.__version__.startswith('3.'):
|
||||||
raise RuntimeError('Invalid PRAW version ({0}) detected, '
|
raise RuntimeError('Invalid PRAW version ({0}) detected, '
|
||||||
'rtv requires PRAW version 3'.format(praw.__version__))
|
'tuir requires PRAW version 3'.format(praw.__version__))
|
||||||
sys.modules['%s.praw' % __name__] = praw
|
sys.modules['%s.praw' % __name__] = praw
|
||||||
__praw_bundled__ = False
|
__praw_bundled__ = False
|
||||||
@@ -237,7 +237,7 @@ class Page(object):
|
|||||||
Move the cursor to the last item on the page.
|
Move the cursor to the last item on the page.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# If the page is empty, don't try to go to the bottom, rtv will
|
# If the page is empty, don't try to go to the bottom, tuir will
|
||||||
# crash when rendering
|
# crash when rendering
|
||||||
if self.content.range[1] < 0:
|
if self.content.range[1] < 0:
|
||||||
return
|
return
|
||||||
@@ -725,7 +725,7 @@ class Page(object):
|
|||||||
# Setting the terminal title will break emacs or systems without
|
# Setting the terminal title will break emacs or systems without
|
||||||
# X window.
|
# X window.
|
||||||
if os.getenv('DISPLAY') and not os.getenv('INSIDE_EMACS'):
|
if os.getenv('DISPLAY') and not os.getenv('INSIDE_EMACS'):
|
||||||
title += ' - rtv {0}'.format(__version__)
|
title += ' - tuir {0}'.format(__version__)
|
||||||
title = self.term.clean(title)
|
title = self.term.clean(title)
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
# In py3 you can't write bytes to stdout
|
# In py3 you can't write bytes to stdout
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>RTV OAuth2 Helper</title>
|
<title>TUIR OAuth2 Helper</title>
|
||||||
<!-- style borrowed from http://bettermotherfuckingwebsite.com/ -->
|
<!-- style borrowed from http://bettermotherfuckingwebsite.com/ -->
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body {
|
body {
|
||||||
@@ -26,6 +26,6 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
${message}
|
${message}
|
||||||
<div id="footer">View the <a href="http://www.gitlab.com/ajak/rtv">Documentation</a></div>
|
<div id="footer">View the <a href="http://www.gitlab.com/ajak/tuir">Documentation</a></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
# Example mailcap file for Reddit Terminal Viewer
|
# Example mailcap file for Terminal UI for Reddit
|
||||||
# https://gitlab.com/ajak/rtv/
|
# https://gitlab.com/ajak/tuir/
|
||||||
#
|
#
|
||||||
# Copy the contents of this file to {HOME}/.mailcap, or point to it using $MAILCAPS
|
# Copy the contents of this file to {HOME}/.mailcap, or point to it using $MAILCAPS
|
||||||
# Then launch RTV using the --enable-media flag. All shell commands defined in
|
# Then launch TUIR using the --enable-media flag. All shell commands defined in
|
||||||
# this file depend on external programs that must be installed on your system.
|
# this file depend on external programs that must be installed on your system.
|
||||||
#
|
#
|
||||||
# HELP REQUESTED! If you come up with your own commands (especially for OS X)
|
# HELP REQUESTED! If you come up with your own commands (especially for OS X)
|
||||||
@@ -19,11 +19,11 @@
|
|||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Commands below this point will open media in a separate window without
|
# Commands below this point will open media in a separate window without
|
||||||
# pausing execution of RTV.
|
# pausing execution of TUIR.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# Feh is a simple and effective image viewer
|
# Feh is a simple and effective image viewer
|
||||||
# Note that rtv returns a list of urls for imgur albums, so we don't put quotes
|
# Note that tuir returns a list of urls for imgur albums, so we don't put quotes
|
||||||
# around the `%s`
|
# around the `%s`
|
||||||
image/x-imgur-album; feh -g 640x480 -. %s; test=test -n "$DISPLAY"
|
image/x-imgur-album; feh -g 640x480 -. %s; test=test -n "$DISPLAY"
|
||||||
image/gif; mpv '%s' --autofit 640x480 --loop=inf; test=test -n "$DISPLAY"
|
image/gif; mpv '%s' --autofit 640x480 --loop=inf; test=test -n "$DISPLAY"
|
||||||
@@ -56,10 +56,10 @@ image/x-imgur-album; echo
|
|||||||
# 256 color images using half-width unicode characters
|
# 256 color images using half-width unicode characters
|
||||||
# Much higher quality that img2txt, but must be built from source
|
# Much higher quality that img2txt, but must be built from source
|
||||||
# https://github.com/rossy/img2xterm
|
# https://github.com/rossy/img2xterm
|
||||||
image/*; curl -s '%s' | convert -resize 80x80 - jpg:/tmp/rtv.jpg && img2xterm /tmp/rtv.jpg; needsterminal; copiousoutput
|
image/*; curl -s '%s' | convert -resize 80x80 - jpg:/tmp/tuir.jpg && img2xterm /tmp/tuir.jpg; needsterminal; copiousoutput
|
||||||
|
|
||||||
# Display images in classic ascii using img2txt and lib-caca
|
# Display images in classic ascii using img2txt and lib-caca
|
||||||
image/*; curl -s '%s' | convert - jpg:/tmp/rtv.jpg && img2txt -f utf8 /tmp/rtv.jpg; needsterminal; copiousoutput
|
image/*; curl -s '%s' | convert - jpg:/tmp/tuir.jpg && img2txt -f utf8 /tmp/tuir.jpg; needsterminal; copiousoutput
|
||||||
|
|
||||||
# Full motion videos - requires a framebuffer to view
|
# Full motion videos - requires a framebuffer to view
|
||||||
video/x-youtube; mpv -vo drm -quiet '%s'; needsterminal
|
video/x-youtube; mpv -vo drm -quiet '%s'; needsterminal
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
; Reddit Terminal Viewer Configuration File
|
; Terminal UI for Reddit Configuration File
|
||||||
; https://gitlab.com/ajak/rtv
|
; https://gitlab.com/ajak/tuir
|
||||||
;
|
;
|
||||||
; This file should be placed in $XDG_CONFIG/rtv/rtv.cfg
|
; This file should be placed in $XDG_CONFIG/tuir/tuir.cfg
|
||||||
; If $XDG_CONFIG is not set, use ~/.config/rtv/rtv.cfg
|
; If $XDG_CONFIG is not set, use ~/.config/tuir/tuir.cfg
|
||||||
|
|
||||||
[rtv]
|
[tuir]
|
||||||
##################
|
##################
|
||||||
# General Settings
|
# General Settings
|
||||||
##################
|
##################
|
||||||
@@ -26,7 +26,7 @@ monochrome = False
|
|||||||
flash = True
|
flash = True
|
||||||
|
|
||||||
; Enable debugging by logging all HTTP requests and errors to the given file.
|
; Enable debugging by logging all HTTP requests and errors to the given file.
|
||||||
;log = /tmp/rtv.log
|
;log = /tmp/tuir.log
|
||||||
|
|
||||||
; Default subreddit that will be opened when the program launches.
|
; Default subreddit that will be opened when the program launches.
|
||||||
subreddit = front
|
subreddit = front
|
||||||
@@ -34,7 +34,7 @@ subreddit = front
|
|||||||
;subreddit = python+linux+programming
|
;subreddit = python+linux+programming
|
||||||
;subreddit = all
|
;subreddit = all
|
||||||
|
|
||||||
; Allow rtv to store reddit authentication credentials between sessions.
|
; Allow tuir to store reddit authentication credentials between sessions.
|
||||||
persistent = True
|
persistent = True
|
||||||
|
|
||||||
; Automatically log in on startup, if credentials are available.
|
; Automatically log in on startup, if credentials are available.
|
||||||
@@ -58,7 +58,7 @@ max_comment_cols = 120
|
|||||||
; Hide username if logged in, display "Logged in" instead
|
; Hide username if logged in, display "Logged in" instead
|
||||||
hide_username = False
|
hide_username = False
|
||||||
|
|
||||||
; Color theme, use "rtv --list-themes" to view a list of valid options.
|
; Color theme, use "tuir --list-themes" to view a list of valid options.
|
||||||
; This can be an absolute filepath, or the name of a theme file that has
|
; This can be an absolute filepath, or the name of a theme file that has
|
||||||
; been installed into either the custom of default theme paths.
|
; been installed into either the custom of default theme paths.
|
||||||
;theme = molokai
|
;theme = molokai
|
||||||
@@ -70,16 +70,16 @@ force_new_browser_window = False
|
|||||||
# OAuth Settings
|
# OAuth Settings
|
||||||
################
|
################
|
||||||
; This sections defines the paramaters that will be used during the OAuth
|
; This sections defines the paramaters that will be used during the OAuth
|
||||||
; authentication process. rtv is registered as an "installed app",
|
; authentication process. tuir is registered as an "installed app",
|
||||||
; see https://github.com/reddit/reddit/wiki/OAuth2 for more information.
|
; see https://github.com/reddit/reddit/wiki/OAuth2 for more information.
|
||||||
|
|
||||||
; These settings are defined at https://www.reddit.com/prefs/apps and should
|
; These settings are defined at https://www.reddit.com/prefs/apps and should
|
||||||
; not be altered unless you are defining your own developer application.
|
; not be altered unless you are defining your own developer application.
|
||||||
oauth_client_id = E2oEtRQfdfAfNQ
|
oauth_client_id = zjyhNI7tK8ivzQ
|
||||||
oauth_client_secret = praw_gapfill
|
oauth_client_secret = praw_gapfill
|
||||||
oauth_redirect_uri = http://127.0.0.1:65000/
|
oauth_redirect_uri = http://127.0.0.1:65000/
|
||||||
|
|
||||||
; Port that the rtv webserver will listen on. This should match the redirect
|
; Port that the tuir webserver will listen on. This should match the redirect
|
||||||
; uri defined above.
|
; uri defined above.
|
||||||
oauth_redirect_port = 65000
|
oauth_redirect_port = 65000
|
||||||
|
|
||||||
@@ -428,10 +428,10 @@ class Terminal(object):
|
|||||||
|
|
||||||
Most urls are parsed using their file extension, but special cases
|
Most urls are parsed using their file extension, but special cases
|
||||||
exist for websites that are prevalent on reddit such as Imgur and
|
exist for websites that are prevalent on reddit such as Imgur and
|
||||||
Gfycat. If there are no valid mailcap definitions, RTV will fall back
|
Gfycat. If there are no valid mailcap definitions, TUIR will fall back
|
||||||
to using the default webbrowser.
|
to using the default webbrowser.
|
||||||
|
|
||||||
RTV checks for certain mailcap fields to determine how to open a link:
|
TUIR checks for certain mailcap fields to determine how to open a link:
|
||||||
- If ``copiousoutput`` is specified, the curses application will
|
- If ``copiousoutput`` is specified, the curses application will
|
||||||
be paused and stdout will be piped to the system pager.
|
be paused and stdout will be piped to the system pager.
|
||||||
- If `needsterminal`` is specified, the curses application will
|
- If `needsterminal`` is specified, the curses application will
|
||||||
@@ -465,7 +465,7 @@ class Terminal(object):
|
|||||||
copious_output = 'copiousoutput' in entry
|
copious_output = 'copiousoutput' in entry
|
||||||
|
|
||||||
if needs_terminal or copious_output:
|
if needs_terminal or copious_output:
|
||||||
# Blocking, pause rtv until the process returns
|
# Blocking, pause tuir until the process returns
|
||||||
with self.suspend():
|
with self.suspend():
|
||||||
os.system('clear')
|
os.system('clear')
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
@@ -567,7 +567,7 @@ class Terminal(object):
|
|||||||
http://bugs.python.org/issue22277 for a better description of the
|
http://bugs.python.org/issue22277 for a better description of the
|
||||||
problem.
|
problem.
|
||||||
|
|
||||||
For console browsers (e.g. w3m), RTV will suspend and display the
|
For console browsers (e.g. w3m), TUIR will suspend and display the
|
||||||
browser window within the same terminal. This mode is triggered either
|
browser window within the same terminal. This mode is triggered either
|
||||||
when
|
when
|
||||||
|
|
||||||
@@ -587,7 +587,7 @@ class Terminal(object):
|
|||||||
# This used to be done using subprocess.Popen().
|
# This used to be done using subprocess.Popen().
|
||||||
# It was switched to multiprocessing.Process so that we
|
# It was switched to multiprocessing.Process so that we
|
||||||
# can re-use the webbrowser instance that has been patched
|
# can re-use the webbrowser instance that has been patched
|
||||||
# by RTV. It's also safer because it doesn't inject
|
# by TUIR. It's also safer because it doesn't inject
|
||||||
# python code through the command line.
|
# python code through the command line.
|
||||||
|
|
||||||
# Suppress stdout/stderr from the browser, see
|
# Suppress stdout/stderr from the browser, see
|
||||||
@@ -640,14 +640,14 @@ class Terminal(object):
|
|||||||
def open_pager(self, data, wrap=None):
|
def open_pager(self, data, wrap=None):
|
||||||
"""
|
"""
|
||||||
View a long block of text using an external pager / viewer. The setting
|
View a long block of text using an external pager / viewer. The setting
|
||||||
of the RTV_PAGER variable will be used if set, otherwise the system's
|
of the TUIR_PAGER variable will be used if set, otherwise the system's
|
||||||
default pager is chosen, finally defaulting to 'less' if both RTV_PAGER
|
default pager is chosen, finally defaulting to 'less' if both TUIR_PAGER
|
||||||
and PAGER is unset in the calling environment.
|
and PAGER is unset in the calling environment.
|
||||||
|
|
||||||
The data string will be piped directly to the pager.
|
The data string will be piped directly to the pager.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pager = os.getenv('RTV_PAGER')
|
pager = os.getenv('TUIR_PAGER')
|
||||||
if pager is None:
|
if pager is None:
|
||||||
pager = os.getenv('PAGER') or 'less'
|
pager = os.getenv('PAGER') or 'less'
|
||||||
command = shlex.split(pager)
|
command = shlex.split(pager)
|
||||||
@@ -687,7 +687,7 @@ class Terminal(object):
|
|||||||
text (str): The text that the user entered into the editor.
|
text (str): The text that the user entered into the editor.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
with NamedTemporaryFile(prefix='rtv_', suffix='.txt', delete=False) as fp:
|
with NamedTemporaryFile(prefix='tuir_', suffix='.txt', delete=False) as fp:
|
||||||
# Create a tempory file and grab the name, but close immediately so
|
# Create a tempory file and grab the name, but close immediately so
|
||||||
# we can re-open using the right encoding
|
# we can re-open using the right encoding
|
||||||
filepath = fp.name
|
filepath = fp.name
|
||||||
@@ -696,7 +696,7 @@ class Terminal(object):
|
|||||||
fp.write(data)
|
fp.write(data)
|
||||||
_logger.info('File created: %s', filepath)
|
_logger.info('File created: %s', filepath)
|
||||||
|
|
||||||
editor = (os.getenv('RTV_EDITOR') or
|
editor = (os.getenv('TUIR_EDITOR') or
|
||||||
os.getenv('VISUAL') or
|
os.getenv('VISUAL') or
|
||||||
os.getenv('EDITOR') or
|
os.getenv('EDITOR') or
|
||||||
'nano')
|
'nano')
|
||||||
@@ -740,7 +740,7 @@ class Terminal(object):
|
|||||||
web browser.
|
web browser.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
urlview = os.getenv('RTV_URLVIEWER') or 'urlview'
|
urlview = os.getenv('TUIR_URLVIEWER') or 'urlview'
|
||||||
command = shlex.split(urlview)
|
command = shlex.split(urlview)
|
||||||
try:
|
try:
|
||||||
with self.suspend():
|
with self.suspend():
|
||||||
@@ -912,7 +912,7 @@ class Terminal(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def strip_instructions(text):
|
def strip_instructions(text):
|
||||||
"""
|
"""
|
||||||
Remove instructional HTML comment tags inserted by RTV.
|
Remove instructional HTML comment tags inserted by TUIR.
|
||||||
|
|
||||||
We used to use # to annotate comments, but it conflicted with the
|
We used to use # to annotate comments, but it conflicted with the
|
||||||
header tag for markdown, which some people use to format their posts.
|
header tag for markdown, which some people use to format their posts.
|
||||||
@@ -134,10 +134,10 @@ class Theme(object):
|
|||||||
name (str): A unique string that describes the theme
|
name (str): A unique string that describes the theme
|
||||||
source (str): A string that describes the source of the theme:
|
source (str): A string that describes the source of the theme:
|
||||||
built-in - Should only be used when Theme() is called directly
|
built-in - Should only be used when Theme() is called directly
|
||||||
preset - Themes packaged with rtv
|
preset - Themes packaged with tuir
|
||||||
installed - Themes in ~/.config/rtv/themes/
|
installed - Themes in ~/.config/tuir/themes/
|
||||||
custom - When a filepath is explicitly provided, e.g.
|
custom - When a filepath is explicitly provided, e.g.
|
||||||
``rtv --theme=/path/to/theme_file.cfg``
|
``tuir --theme=/path/to/theme_file.cfg``
|
||||||
elements (dict): The theme's element map, should be in the same
|
elements (dict): The theme's element map, should be in the same
|
||||||
format as Theme.DEFAULT_THEME.
|
format as Theme.DEFAULT_THEME.
|
||||||
"""
|
"""
|
||||||
@@ -1 +1 @@
|
|||||||
rtv/__version__.py
|
tuir/__version__.py
|
||||||
Reference in New Issue
Block a user