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_dev.txt
include rfd/__version__.py

View File

@@ -13,7 +13,7 @@ pip install rfd
## 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

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 -*-
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")
# 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:
_posts = _posts[start_post - 1 :]
else:

View File

@@ -3,29 +3,34 @@ from os import path
from setuptools import setup, find_packages
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__))
REQUIREMENTS = load_requirements("requirements.txt")
TEST_REQUIREMENTS = load_requirements("requirements_dev.txt")
# Get long description from README.md
with io.open(path.join(WORKING_DIR, "README.md"), encoding="utf-8") as f:
long_description = f.read()
setup(
author="Dave Gallant",
description="CLI for RedFlagDeals.com",
entry_points={"console_scripts": ["rfd = rfd.rfd_cli:cli"]},
install_requires=[
"beautifulsoup4>=4.6.0",
"click>=7.0",
"colorama>=0.3.9",
"requests>=2.18.0",
],
install_requires=REQUIREMENTS,
keywords="cli redflagdeals",
license="Apache License, Version 2.0",
long_description=long_description,
long_description_content_type="text/markdown",
name="rfd",
packages=find_packages(),
url="https://github.com/davegallant/rfd_cli",
url="https://github.com/davegallant/rfd",
version=version,
)

View File

@@ -6,47 +6,74 @@ def test_build_web_path():
def test_extract_post_id():
assert extract_post_id(
"https://forums.redflagdeals.com/targeted-bob-2173603/120") == '2173603'
assert extract_post_id(
"http://forums.redflagdeals.com/targeted-2173604/120") == '2173604'
assert (
extract_post_id("https://forums.redflagdeals.com/targeted-bob-2173603/120")
== "2173603"
)
assert (
extract_post_id("http://forums.redflagdeals.com/targeted-2173604/120")
== "2173604"
)
def test_parse_threads(threads_api_response):
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',
'url': 'https://forums.redflagdeals.com/carrytel-sponsored-3-months-free-cable-75m-unlimited-internet-34-99-30-days-free-installation-modem-rental-2197859/'},
{'score': 92,
'title': 'WyzeCam 1080p HD Wireless Smart Home Camera v2 $37.49',
'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',
'url': 'https://forums.redflagdeals.com/best-buy-jabra-elite-65t-169-99-2197916/'},
{'score': 1,
'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,
'title': 'Firman 3300 inverter generator $599',
'url': 'https://forums.redflagdeals.com/costco-firman-3300-inverter-generator-599-2195171/'},
{'score': 3,
'title': 'HOT - KitchenAid Stand Mixer - $199',
'url': 'https://forums.redflagdeals.com/walmart-hot-kitchenaid-stand-mixer-199-2198199/'},
{'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/'}])
[
{
"score": 0,
"title": "[Sponsored] 3 Months Free, Cable 75M, Unlimited Internet $34.99/30 "
"Days, Free Installation/Modem Rental",
"url": "https://forums.redflagdeals.com/carrytel-sponsored-3-months-free-cable-75m-unlimited-internet-34-99-30-days-free-installation-modem-rental-2197859/",
},
{
"score": 92,
"title": "WyzeCam 1080p HD Wireless Smart Home Camera v2 $37.49",
"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",
"url": "https://forums.redflagdeals.com/best-buy-jabra-elite-65t-169-99-2197916/",
},
{
"score": 1,
"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,
"title": "Firman 3300 inverter generator $599",
"url": "https://forums.redflagdeals.com/costco-firman-3300-inverter-generator-599-2195171/",
},
{
"score": 3,
"title": "HOT - KitchenAid Stand Mixer - $199",
"url": "https://forums.redflagdeals.com/walmart-hot-kitchenaid-stand-mixer-199-2198199/",
},
{
"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