3 Commits

Author SHA1 Message Date
Dave Gallant
83d583d2b0 Make a display thread function for re-use (#74) 2020-07-15 21:48:58 -04:00
Dave Gallant
2c65d29262 Add python3.8 and python3.9-dev to travis-ci (#73)
* Add python38 to travis

* Add python39-dev
2020-07-04 17:29:17 -04:00
Dave Gallant
a5d1bb197d Create codeql-analysis.yml (#71)
* Create codeql-analysis.yml

* Update .github/PULL_REQUEST_TEMPLATE.md
2020-07-01 18:54:52 -04:00
6 changed files with 64 additions and 39 deletions

View File

@@ -1,9 +1 @@
**What this PR does / why we need it:**
-
**Which issue(s) this PR fixes:**
-
**Additional Notes:**
-
###### Motivation for this change

27
.github/workflows/codeql-analysis.yml vendored Normal file
View 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

View File

@@ -1,5 +1,5 @@
language: python
dist: xenial
dist: bionic
sudo: false
cache: false
stages:
@@ -18,15 +18,14 @@ script:
jobs:
include:
- python: "2.7"
- python: "3.5"
- python: "3.6"
- python: "3.7"
- python: "3.8"
- python: "3.9-dev"
- stage: deploy
python: "3.7"
python: "3.8"
deploy:
on:
repo: davegallant/rfd

View File

@@ -1 +1 @@
0.3.5
0.3.6

View File

@@ -43,6 +43,27 @@ def print_version(ctx, value):
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.option(
"-v",
@@ -115,19 +136,7 @@ def threads(limit, forum_id):
"""
_threads = parse_threads(get_threads(forum_id, limit), limit)
for count, thread in enumerate(_threads, 1):
click.echo(
" "
+ 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)
display_thread(click, thread, count)
@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)
for thread in search_threads(threads=_threads, regex=regex):
count += 1
click.echo(
" "
+ 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)
display_thread(click, thread, count)

View File

@@ -7,6 +7,13 @@ def build_web_path(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):
"""parse topics list api response into digestible list.
@@ -26,7 +33,7 @@ def parse_threads(threads, limit):
parsed_threads.append(
Thread(
title=topic.get("title"),
dealer_name=topic["offer"].get("dealer_name"),
dealer_name=get_dealer(topic),
score=calculate_score(topic),
url=build_web_path(topic.get("web_path")),
total_views=topic.get("total_views"),