Skip to content

Commit be12f11

Browse files
committed
* more linting cleanup
1 parent 7f1e701 commit be12f11

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

index.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from urllib.parse import parse_qs
1111

1212
from bs4 import BeautifulSoup
13-
from bottle import request, get, response
13+
from bottle import request, response
1414
import psycopg2
1515
import psycopg2.extras
1616

@@ -74,7 +74,6 @@ def header0():
7474
def do_tags():
7575
"""Show bookmarks associated with a tag."""
7676
user_num_bmarks = 15
77-
num_bmarks_menu_offset = 53
7877
return_data = ''
7978
tag_id = ''
8079
tag_get = ''
@@ -87,7 +86,6 @@ def do_tags():
8786
username = request.get_cookie('tasti_username').lower()
8887
if request.query.get('mine') and request.query.get('mine') == 'yes':
8988
show_mine = "AND owner='{}'".format(username)
90-
num_bmarks_menu_offset = 60
9189
if tag_id:
9290
tags_sql += "WHERE id='{t}' {m} LIMIT 1".format(t=tag_id,
9391
m=show_mine)
@@ -329,6 +327,7 @@ def show_bmarks():
329327
url_get_base = 'bmarks?{u}'.format(u=request.environ.get('QUERY_STRING'))
330328
bmarks_sql_base = '''SELECT distinct ON (url) url, id, date(last_update) AS last_update, notes, name, owner
331329
FROM bmarks'''
330+
username = '%'
332331
if hash_check():
333332
username = request.get_cookie('tasti_username').lower()
334333
if request.query.get('whose') and request.query.get('whose') == mine and hash_check():
@@ -561,6 +560,7 @@ def edit_bmarks():
561560
def edit_bmarks_process(username):
562561
"""process POST'd bookmark edit data."""
563562
return_data = ''
563+
bmark_tags_list = []
564564
bmark_id = request.forms.get('id')
565565
bmark_name = request.forms.get('name').strip()
566566
bmark_url = request.forms.get('url').strip()
@@ -837,7 +837,6 @@ def bmark_import_file(username, bmark_file_data):
837837
import_tag = request.forms.get('import_tag')
838838
if import_tag:
839839
use_import_tag = ['imported']
840-
bmark_filename = bmark_file_data.filename
841840
# parse bookmark data into urls and names
842841
soup = BeautifulSoup(bmark_file_data.file.read(), 'lxml')
843842
parsed_bmark_file_data = soup.find_all('a')
@@ -957,7 +956,7 @@ def show_bmarklet():
957956
sc=request.environ.get('SCRIPT_NAME'))
958957
bmarklet_url = '{}add?url='.format(base_url)
959958
bmarklet_string = """javascript:(function(){f='""" + bmarklet_url + """'+encodeURIComponent(window.location.href)+'&name='+encodeURIComponent(document.title)+'&notes='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text));a=function(){if(!window.open(f+'noui=1&jump=doclose','d','location=yes,links=no,scrollbars=no,toolbar=no,width=550,height=550'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"""
960-
return_data += '''<BR><span class="huge">&nbsp;A bookmarklet is a link that you add to your browser's Toolbar.
959+
return_data += '''<BR><span class="huge">&nbsp;A bookmarklet is a link that you add to your browser's Toolbar.
961960
It makes it easy to add a new bookmark to <B>Tasti</B>.</span><BR><BR>
962961
Drag the link below to your toolbar, and then you can click that link when viewing any web
963962
page to quickly & easily add it as a bookmark.<BR><BR><BR>
@@ -1021,7 +1020,7 @@ def account_mgmt():
10211020
else:
10221021
return_data += '<BR>Unknown function<BR><BR>'
10231022
else:
1024-
return_data += '''<BR>This page is only accessible to users who have
1023+
return_data += '''<BR>This page is only accessible to users who have
10251024
<A HREF="login?do=0">logged in</a>.<BR><BR>'''
10261025
return return_data
10271026

@@ -1121,7 +1120,7 @@ def register():
11211120
return_data += register_form()
11221121
return return_data
11231122
# success
1124-
return_data += '''Your account ( {u} ) has been successfully created.
1123+
return_data += '''Your account ( {u} ) has been successfully created.
11251124
You may now login below or <A HREF="login?do=0">HERE</a>.
11261125
<BR><BR>'''.format(u=username)
11271126
return_data += login_form()
@@ -1206,7 +1205,7 @@ def hash_check():
12061205

12071206
hash_sql = "SELECT id FROM users WHERE username='{u}' AND password='{p}'".format(u=username, p=password_hash)
12081207
hash_qry = db_qry([hash_sql, None], 'select')
1209-
if len(hash_qry) and hash_qry[0]:
1208+
if len(hash_qry) > 0 and hash_qry[0]:
12101209
return hash_qry
12111210

12121211

@@ -1220,13 +1219,12 @@ def db_qry(sql_pl, operation):
12201219
conn = psycopg2.connect(CONN_STRING)
12211220
conn.autocommit = True
12221221
except Exception as err:
1223-
print('Database connection failed due to error:\t{}'.format(err))
1222+
print(f'Database connection failed due to error:\t{err}')
12241223
return ''
12251224
cursor = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
12261225
# invoke the SQL
12271226
try:
12281227
cursor.execute(sql, sql_vals)
1229-
row_count = cursor.rowcount
12301228
except Exception as err:
12311229
# query failed
12321230
print('SQL ( {} )\t failed due to error:\t{}'.format(cursor.query, err))

0 commit comments

Comments
 (0)