cleanup setup.py (#16)

* cleanup setup.

* fix pylint.
This commit is contained in:
Dave Gallant
2019-09-08 23:26:42 -04:00
committed by GitHub
parent f4852722bb
commit 0965aa0507
8 changed files with 89 additions and 48 deletions

View File

@@ -1,2 +1,3 @@
include requirements.txt include requirements.txt
include requirements_dev.txt
include rfd/__version__.py include rfd/__version__.py

View File

@@ -13,7 +13,7 @@ pip install rfd
## Usage ## Usage
![rfd_demo_gif](https://user-images.githubusercontent.com/4519234/47625817-d3375500-dafd-11e8-9d86-491d4a4fb225.gif) ![rfd_demo_gif](https://user-images.githubusercontent.com/4519234/64501455-64836600-d28f-11e9-8381-3fbfda910230.gif)
```bash ```bash

4
requirements.txt Normal file
View File

@@ -0,0 +1,4 @@
beautifulsoup4>=4.6.0
click>=7.0
colorama>=0.3.9
requests>=2.18.0

4
requirements_dev.txt Normal file
View File

@@ -0,0 +1,4 @@
rope
black
pylint
pytest

View File

@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
version = '0.1.8' version = '0.1.9'

View File

@@ -180,7 +180,7 @@ def get_posts(post, count=5, tail=False, per_page=40):
_posts = response.json().get("posts") _posts = response.json().get("posts")
# Determine which post to start with (for --tail) # Determine which post to start with (for --tail)
if page == start_page and not start_post == 0: if page == start_page and start_post != 0:
if tail: if tail:
_posts = _posts[start_post - 1 :] _posts = _posts[start_post - 1 :]
else: else:

View File

@@ -3,29 +3,34 @@ from os import path
from setuptools import setup, find_packages from setuptools import setup, find_packages
from rfd.__version__ import version from rfd.__version__ import version
def load_requirements(file_name):
""" Reads and returns requirements """
with io.open(path.join(WORKING_DIR, file_name)) as handle:
raw_reqs = handle.read().strip().split("\n")
reqs = [req for req in raw_reqs]
return reqs
WORKING_DIR = path.abspath(path.dirname(__file__)) WORKING_DIR = path.abspath(path.dirname(__file__))
REQUIREMENTS = load_requirements("requirements.txt")
TEST_REQUIREMENTS = load_requirements("requirements_dev.txt")
# Get long description from README.md # Get long description from README.md
with io.open(path.join(WORKING_DIR, "README.md"), encoding="utf-8") as f: with io.open(path.join(WORKING_DIR, "README.md"), encoding="utf-8") as f:
long_description = f.read() long_description = f.read()
setup( setup(
author="Dave Gallant", author="Dave Gallant",
description="CLI for RedFlagDeals.com", description="CLI for RedFlagDeals.com",
entry_points={"console_scripts": ["rfd = rfd.rfd_cli:cli"]}, entry_points={"console_scripts": ["rfd = rfd.rfd_cli:cli"]},
install_requires=[ install_requires=REQUIREMENTS,
"beautifulsoup4>=4.6.0",
"click>=7.0",
"colorama>=0.3.9",
"requests>=2.18.0",
],
keywords="cli redflagdeals", keywords="cli redflagdeals",
license="Apache License, Version 2.0", license="Apache License, Version 2.0",
long_description=long_description, long_description=long_description,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
name="rfd", name="rfd",
packages=find_packages(), packages=find_packages(),
url="https://github.com/davegallant/rfd_cli", url="https://github.com/davegallant/rfd",
version=version, version=version,
) )

View File

@@ -6,47 +6,74 @@ def test_build_web_path():
def test_extract_post_id(): def test_extract_post_id():
assert extract_post_id( assert (
"https://forums.redflagdeals.com/targeted-bob-2173603/120") == '2173603' extract_post_id("https://forums.redflagdeals.com/targeted-bob-2173603/120")
assert extract_post_id( == "2173603"
"http://forums.redflagdeals.com/targeted-2173604/120") == '2173604' )
assert (
extract_post_id("http://forums.redflagdeals.com/targeted-2173604/120")
== "2173604"
)
def test_parse_threads(threads_api_response): def test_parse_threads(threads_api_response):
assert len(parse_threads(threads_api_response, 10)) == len( assert len(parse_threads(threads_api_response, 10)) == len(
[{'score': 0, [
'title': '[Sponsored] 3 Months Free, Cable 75M, Unlimited Internet $34.99/30 ' {
'Days, Free Installation/Modem Rental', "score": 0,
'url': 'https://forums.redflagdeals.com/carrytel-sponsored-3-months-free-cable-75m-unlimited-internet-34-99-30-days-free-installation-modem-rental-2197859/'}, "title": "[Sponsored] 3 Months Free, Cable 75M, Unlimited Internet $34.99/30 "
{'score': 92, "Days, Free Installation/Modem Rental",
'title': 'WyzeCam 1080p HD Wireless Smart Home Camera v2 $37.49', "url": "https://forums.redflagdeals.com/carrytel-sponsored-3-months-free-cable-75m-unlimited-internet-34-99-30-days-free-installation-modem-rental-2197859/",
'url': 'https://forums.redflagdeals.com/amazon-ca-wyzecam-1080p-hd-wireless-smart-home-camera-v2-37-49-2191108/'}, },
{'score': 8, {
'title': 'Jabra Elite 65T $169.99', "score": 92,
'url': 'https://forums.redflagdeals.com/best-buy-jabra-elite-65t-169-99-2197916/'}, "title": "WyzeCam 1080p HD Wireless Smart Home Camera v2 $37.49",
{'score': 1, "url": "https://forums.redflagdeals.com/amazon-ca-wyzecam-1080p-hd-wireless-smart-home-camera-v2-37-49-2191108/",
'title': 'Glad Cling Wrap Plastic Wrap, 300 Metre Roll - best price $9.47', },
'url': 'https://forums.redflagdeals.com/amazon-ca-glad-cling-wrap-plastic-wrap-300-metre-roll-best-price-9-47-2198211/'}, {
{'score': 17, "score": 8,
'title': 'Firman 3300 inverter generator $599', "title": "Jabra Elite 65T $169.99",
'url': 'https://forums.redflagdeals.com/costco-firman-3300-inverter-generator-599-2195171/'}, "url": "https://forums.redflagdeals.com/best-buy-jabra-elite-65t-169-99-2197916/",
{'score': 3, },
'title': 'HOT - KitchenAid Stand Mixer - $199', {
'url': 'https://forums.redflagdeals.com/walmart-hot-kitchenaid-stand-mixer-199-2198199/'}, "score": 1,
{'score': -1, "title": "Glad Cling Wrap Plastic Wrap, 300 Metre Roll - best price $9.47",
'title': 'Seagate Expansion 4TB Portable External Hard Drive USB 3.0 ' "url": "https://forums.redflagdeals.com/amazon-ca-glad-cling-wrap-plastic-wrap-300-metre-roll-best-price-9-47-2198211/",
'(STEA4000400) $119.92', },
'url': 'https://forums.redflagdeals.com/amazon-ca-seagate-expansion-4tb-portable-external-hard-drive-usb-3-0-stea4000400-119-92-2198164/'}, {
{'score': 0, "score": 17,
'title': 'WORKSHOP Wet Dry Vacs Ash Vacuum Cleaner WS0500ASH, 5-Gallon Ash ' "title": "Firman 3300 inverter generator $599",
'Vac 65% Off, Now: $48.54', "url": "https://forums.redflagdeals.com/costco-firman-3300-inverter-generator-599-2195171/",
'url': 'https://forums.redflagdeals.com/workshop-wet-dry-vacs-ash-vacuum-cleaner-ws0500ash-5-gallon-ash-vac-65-off-now-48-54-2198212/'}, },
{'score': 4, {
'title': 'NBA 2K18 (Nintendo Switch) -$19.99 or $16.99 PM', "score": 3,
'url': 'https://forums.redflagdeals.com/the-source-nba-2k18-nintendo-switch-19-99-16-99-pm-2198191/'}, "title": "HOT - KitchenAid Stand Mixer - $199",
{'score': 5, "url": "https://forums.redflagdeals.com/walmart-hot-kitchenaid-stand-mixer-199-2198199/",
'title': 'CROCS.CA 40%OFF Select style - at checkout', },
'url': 'https://forums.redflagdeals.com/crocs-crocs-ca-40-off-select-style-checkout-2198145/'}]) {
"score": -1,
"title": "Seagate Expansion 4TB Portable External Hard Drive USB 3.0 "
"(STEA4000400) $119.92",
"url": "https://forums.redflagdeals.com/amazon-ca-seagate-expansion-4tb-portable-external-hard-drive-usb-3-0-stea4000400-119-92-2198164/",
},
{
"score": 0,
"title": "WORKSHOP Wet Dry Vacs Ash Vacuum Cleaner WS0500ASH, 5-Gallon Ash "
"Vac 65% Off, Now: $48.54",
"url": "https://forums.redflagdeals.com/workshop-wet-dry-vacs-ash-vacuum-cleaner-ws0500ash-5-gallon-ash-vac-65-off-now-48-54-2198212/",
},
{
"score": 4,
"title": "NBA 2K18 (Nintendo Switch) -$19.99 or $16.99 PM",
"url": "https://forums.redflagdeals.com/the-source-nba-2k18-nintendo-switch-19-99-16-99-pm-2198191/",
},
{
"score": 5,
"title": "CROCS.CA 40%OFF Select style - at checkout",
"url": "https://forums.redflagdeals.com/crocs-crocs-ca-40-off-select-style-checkout-2198145/",
},
]
)
assert len(parse_threads(None, 10)) == 0 assert len(parse_threads(None, 10)) == 0