mirror of
https://github.com/davegallant/rfd.git
synced 2025-08-07 09:02:32 +00:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
83d583d2b0 | ||
|
2c65d29262 | ||
|
a5d1bb197d |
10
.github/PULL_REQUEST_TEMPLATE.md
vendored
10
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,9 +1 @@
|
|||||||
|
###### Motivation for this change
|
||||||
**What this PR does / why we need it:**
|
|
||||||
-
|
|
||||||
|
|
||||||
**Which issue(s) this PR fixes:**
|
|
||||||
-
|
|
||||||
|
|
||||||
**Additional Notes:**
|
|
||||||
-
|
|
||||||
|
27
.github/workflows/codeql-analysis.yml
vendored
Normal file
27
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
name: "Code scanning - action"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 4 * * 1'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
CodeQL-Build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
- run: git checkout HEAD^2
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v1
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v1
|
@@ -1,5 +1,5 @@
|
|||||||
language: python
|
language: python
|
||||||
dist: xenial
|
dist: bionic
|
||||||
sudo: false
|
sudo: false
|
||||||
cache: false
|
cache: false
|
||||||
stages:
|
stages:
|
||||||
@@ -18,15 +18,14 @@ script:
|
|||||||
jobs:
|
jobs:
|
||||||
include:
|
include:
|
||||||
- python: "2.7"
|
- python: "2.7"
|
||||||
|
|
||||||
- python: "3.5"
|
- python: "3.5"
|
||||||
|
|
||||||
- python: "3.6"
|
- python: "3.6"
|
||||||
|
|
||||||
- python: "3.7"
|
- python: "3.7"
|
||||||
|
- python: "3.8"
|
||||||
|
- python: "3.9-dev"
|
||||||
|
|
||||||
- stage: deploy
|
- stage: deploy
|
||||||
python: "3.7"
|
python: "3.8"
|
||||||
deploy:
|
deploy:
|
||||||
on:
|
on:
|
||||||
repo: davegallant/rfd
|
repo: davegallant/rfd
|
||||||
|
@@ -1 +1 @@
|
|||||||
0.3.5
|
0.3.6
|
||||||
|
46
rfd/cli.py
46
rfd/cli.py
@@ -43,6 +43,27 @@ def print_version(ctx, value):
|
|||||||
ctx.exit()
|
ctx.exit()
|
||||||
|
|
||||||
|
|
||||||
|
def display_thread(click, thread, count): # pylint: disable=redefined-outer-name
|
||||||
|
dealer = thread.dealer_name
|
||||||
|
if dealer and dealer is not None:
|
||||||
|
dealer = "[" + dealer + "] "
|
||||||
|
else:
|
||||||
|
dealer = ""
|
||||||
|
click.echo(
|
||||||
|
" "
|
||||||
|
+ str(count)
|
||||||
|
+ "."
|
||||||
|
+ get_vote_color(thread.score)
|
||||||
|
+ Fore.RESET
|
||||||
|
+ "%s%s" % (dealer, thread.title)
|
||||||
|
+ Fore.LIGHTYELLOW_EX
|
||||||
|
+ " (%d views)" % thread.total_views
|
||||||
|
+ Fore.RESET
|
||||||
|
)
|
||||||
|
click.echo(Fore.BLUE + " {}".format(thread.url))
|
||||||
|
click.echo(Style.RESET_ALL)
|
||||||
|
|
||||||
|
|
||||||
@click.group(invoke_without_command=True)
|
@click.group(invoke_without_command=True)
|
||||||
@click.option(
|
@click.option(
|
||||||
"-v",
|
"-v",
|
||||||
@@ -115,19 +136,7 @@ def threads(limit, forum_id):
|
|||||||
"""
|
"""
|
||||||
_threads = parse_threads(get_threads(forum_id, limit), limit)
|
_threads = parse_threads(get_threads(forum_id, limit), limit)
|
||||||
for count, thread in enumerate(_threads, 1):
|
for count, thread in enumerate(_threads, 1):
|
||||||
click.echo(
|
display_thread(click, thread, count)
|
||||||
" "
|
|
||||||
+ str(count)
|
|
||||||
+ "."
|
|
||||||
+ get_vote_color(thread.score)
|
|
||||||
+ Fore.RESET
|
|
||||||
+ "[%s] %s" % (thread.dealer_name, thread.title)
|
|
||||||
+ Fore.LIGHTYELLOW_EX
|
|
||||||
+ " (%d views)" % thread.total_views
|
|
||||||
+ Fore.RESET
|
|
||||||
)
|
|
||||||
click.echo(Fore.BLUE + " {}".format(thread.url))
|
|
||||||
click.echo(Style.RESET_ALL)
|
|
||||||
|
|
||||||
|
|
||||||
@cli.command(short_help="Search deals based on a regular expression.")
|
@cli.command(short_help="Search deals based on a regular expression.")
|
||||||
@@ -159,13 +168,4 @@ def search(num_pages, forum_id, regex):
|
|||||||
_threads = parse_threads(get_threads(forum_id, 100, page=page), limit=100)
|
_threads = parse_threads(get_threads(forum_id, 100, page=page), limit=100)
|
||||||
for thread in search_threads(threads=_threads, regex=regex):
|
for thread in search_threads(threads=_threads, regex=regex):
|
||||||
count += 1
|
count += 1
|
||||||
click.echo(
|
display_thread(click, thread, count)
|
||||||
" "
|
|
||||||
+ str(count)
|
|
||||||
+ "."
|
|
||||||
+ get_vote_color(thread.score)
|
|
||||||
+ Fore.RESET
|
|
||||||
+ "[%s] %s" % (thread.dealer_name, thread.title)
|
|
||||||
)
|
|
||||||
click.echo(Fore.BLUE + " {}".format(thread.url))
|
|
||||||
click.echo(Style.RESET_ALL)
|
|
||||||
|
@@ -7,6 +7,13 @@ def build_web_path(slug):
|
|||||||
return "{}{}".format(API_BASE_URL, slug)
|
return "{}{}".format(API_BASE_URL, slug)
|
||||||
|
|
||||||
|
|
||||||
|
def get_dealer(topic):
|
||||||
|
dealer = None
|
||||||
|
if topic.get("offer"):
|
||||||
|
dealer = topic.get("offer").get("dealer_name")
|
||||||
|
return dealer
|
||||||
|
|
||||||
|
|
||||||
def parse_threads(threads, limit):
|
def parse_threads(threads, limit):
|
||||||
"""parse topics list api response into digestible list.
|
"""parse topics list api response into digestible list.
|
||||||
|
|
||||||
@@ -26,7 +33,7 @@ def parse_threads(threads, limit):
|
|||||||
parsed_threads.append(
|
parsed_threads.append(
|
||||||
Thread(
|
Thread(
|
||||||
title=topic.get("title"),
|
title=topic.get("title"),
|
||||||
dealer_name=topic["offer"].get("dealer_name"),
|
dealer_name=get_dealer(topic),
|
||||||
score=calculate_score(topic),
|
score=calculate_score(topic),
|
||||||
url=build_web_path(topic.get("web_path")),
|
url=build_web_path(topic.get("web_path")),
|
||||||
total_views=topic.get("total_views"),
|
total_views=topic.get("total_views"),
|
||||||
|
Reference in New Issue
Block a user