pep8 changes

This commit is contained in:
Nemo 2017-12-24 18:55:20 +05:30
parent e34d767ef0
commit 3afba6f3eb
7 changed files with 43 additions and 28 deletions

View File

@ -31,11 +31,13 @@ from .firefox import Firefox
from .version import Version
from .analytics import Analytics
class HackerNewsApp:
HN_URL_PREFIX = "https://news.ycombinator.com/item?id="
UPDATE_URL = "https://github.com/captn3m0/hackertray#upgrade"
ABOUT_URL = "https://github.com/captn3m0/hackertray"
MIXPANEL_TOKEN = "51a04e37dad59393c7371407e84a8050"
def __init__(self, args):
# Load the database
home = expanduser("~")
@ -122,7 +124,6 @@ class HackerNewsApp:
self.menu.remove(widget)
self.tracker.visit(HackerNewsApp.UPDATE_URL)
def showAbout(self, widget):
"""Handle the about btn"""
webbrowser.open(HackerNewsApp.ABOUT_URL)
@ -184,7 +185,6 @@ class HackerNewsApp:
i.show()
def refresh(self, widget=None, no_timer=False, chrome_data_directory=None, firefox_data_directory=None):
"""Refreshes the menu """
try:
# Create an array of 20 false to denote matches in History
@ -223,6 +223,7 @@ class HackerNewsApp:
original[index] = original[index] or patch[index]
return original
def main():
parser = argparse.ArgumentParser(description='Hacker News in your System Tray')
parser.add_argument('-v', '--version', action='version', version=Version.current())

View File

@ -1,9 +1,11 @@
from mixpanel import Mixpanel
class Analytics:
# Setup analytics.
# dnt - do not track. Disables tracking if True
# token - The mixpanel token
def __init__(self, dnt, token):
self.dnt = dnt
self.tracker = Mixpanel(token)
@ -12,6 +14,7 @@ class Analytics:
# Track an event
# event - string containing the event name
# data - data related to the event, defaults to {}
def track(self, event, data={}):
if(self.dnt == False):
# All events are tracked anonymously
@ -19,5 +22,6 @@ class Analytics:
# Track a visit to a URL
# The url maybe an HN submission or
# some meta-url pertaining to hackertray
def visit(self, url):
self.track('visit', {"link": url})

View File

@ -35,6 +35,7 @@ def get_icon_filename(icon_name):
# The main class
class Indicator:
# Constructor
def __init__(self, unknown, icon, category):
# Store the settings
self.inactive_icon = get_icon_filename(icon)

View File

@ -4,8 +4,10 @@ import shutil
import os
import sys
class Chrome:
HISTORY_TMP_LOCATION = '/tmp/hackertray.chrome'
@staticmethod
def search(urls, config_folder_path):
Chrome.setup(config_folder_path)
@ -20,6 +22,7 @@ class Chrome:
result.append(True)
os.remove(Chrome.HISTORY_TMP_LOCATION)
return result
@staticmethod
def setup(config_folder_path):
file_name = os.path.abspath(config_folder_path+'/History')

View File

@ -4,9 +4,11 @@ import shutil
import os
import sys
class Firefox:
HISTORY_TMP_LOCATION = '/tmp/hackertray.firefox'
HISTORY_FILE_NAME = '/places.sqlite'
@staticmethod
def search(urls, config_folder_path):
Firefox.setup(config_folder_path)
@ -21,6 +23,7 @@ class Firefox:
result.append(True)
os.remove(Firefox.HISTORY_TMP_LOCATION)
return result
@staticmethod
def setup(config_folder_path):
file_name = os.path.abspath(config_folder_path+Firefox.HISTORY_FILE_NAME)

View File

@ -7,6 +7,7 @@ urls = [
class HackerNews:
@staticmethod
def getHomePage():
random.shuffle(urls)

View File

@ -1,8 +1,10 @@
import requests
import pkg_resources
class Version:
PYPI_URL = "https://pypi.python.org/pypi/hackertray/json"
@staticmethod
def latest():
res = requests.get(Version.PYPI_URL).json()