Skip to content

Commit

Permalink
Fix unused code
Browse files Browse the repository at this point in the history
Removes unused code.
Removes unused and redundent imports.
Adds newline to increase consistency
across files.

Fixes NITDgpOS#281
  • Loading branch information
nemani authored and abh3po committed Dec 25, 2016
1 parent 2398f0e commit acd93e5
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .coafile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ default_actions =
SpaceConsistencyBear: ApplyPatchAction

[Python]
bears = PEP8Bear
bears = PEP8Bear, PyUnusedCodeBear
files = *.py, uiplib/**/*.py, tests/**/*.py
default_actions =
PEP8Bear: ApplyPatchAction
Expand Down
1 change: 0 additions & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import unittest
import sys
from unittest.mock import patch
from uiplib import settings

Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import shutil
import unittest
import time

from uiplib.utils import setupUtils, utils
from uiplib.settings import DEFAULT_PICS_FOLDER, NUMBER_OF_IMAGES_TO_PARSE


class UtilsTest(unittest.TestCase):
Expand Down
6 changes: 4 additions & 2 deletions uiplib/UIP.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import sys
import os
import shutil

from daemoniker import Daemonizer, send, SIGTERM

from uiplib.settings import ParseSettings, HOME_DIR
from uiplib.scheduler import scheduler
from uiplib.Wallpaper import Wallpaper
from uiplib.utils.setupUtils import make_dir
from daemoniker import Daemonizer, send, SIGTERM


def main():
Expand All @@ -26,7 +28,7 @@ def main():
if is_setup:
print("UIP will now run as a serice.")
try:
is_parent = daemonizer(pid_file)
daemonizer(pid_file)
except SystemExit:
print("UIP service already, running "
"Close previous app by running UIP --service stop")
Expand Down
1 change: 1 addition & 0 deletions uiplib/Wallpaper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module that gets and sets Wallpaper."""

import sys


Expand Down
1 change: 1 addition & 0 deletions uiplib/gui/gallery.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The module houses the class that displays wallpapers in the app."""

from tkinter import *
from PIL import Image, ImageTk

Expand Down
3 changes: 0 additions & 3 deletions uiplib/gui/generalTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ def create_general_tab(appObj):
nextButton.pack(side=RIGHT, padx=5, pady=5)
prevButton.pack(side=LEFT, padx=5, pady=5)

downloadBtn = Button(footerFrame,
text="Download",
command=appObj.download)
setWallpaperBtn = Button(footerFrame,
text="Set Wallpaper",
command=appObj.set_wallpaper)
Expand Down
18 changes: 4 additions & 14 deletions uiplib/gui/mainGui.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
"""Module that builds the Graphical User Interface."""

from uiplib.scheduler import scheduler
from uiplib.utils.utils import update_settings, check_sites
from uiplib.gui.gallery import Gallery
from uiplib.gui import generalTab, settingsTab


import os
from queue import Queue
from tkinter import *
from tkinter import messagebox
from tkinter.ttk import *
from PIL import Image, ImageTk
from queue import Queue
import os

from uiplib.gui import generalTab, settingsTab


class MainWindow:
Expand Down Expand Up @@ -88,10 +82,6 @@ def set_wallpaper(self):
image = self.images[self.index]
self.wallpaper.set(image)

def download(self):
"""Method to start download."""
pass

def flush(self):
"""Method to flush all images."""
print("Flush Clicked!")
Expand Down
3 changes: 1 addition & 2 deletions uiplib/gui/settingsTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from tkinter import *
from tkinter import filedialog
from tkinter import messagebox
from uiplib.settings import DEFAULT_SETTINGS

from uiplib.settings import DEFAULT_SETTINGS
from uiplib.utils.utils import check_sites, update_settings


Expand Down Expand Up @@ -44,7 +44,6 @@ def create_settings_tab(appObj):
appObj.reddit.set(False)
sites_label = Label(mainFrame, text="Where to download from:")
sites_label.grid(row=1, padx=10, pady=1, sticky=W)
sites = ('unsplash', 'reddit', 'desktoppr')
unsplash_radio = Checkbutton(mainFrame,
text="Unsplash",
var=appObj.unsplash)
Expand Down
10 changes: 4 additions & 6 deletions uiplib/scheduler.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
"""Module that schedules the wallpaper change."""

from uiplib.utils.utils import get_percentage
from uiplib.scrape.onlineFetch import onlineFetch

import os
import time
from uiplib.scrape.scrape import get_images
from threading import Thread
import sys
from select import select
import random

from uiplib.utils.utils import get_percentage
from uiplib.scrape.onlineFetch import onlineFetch
from uiplib.scrape.scrape import get_images

try:
import msvcrt
except ImportError:
Expand Down Expand Up @@ -85,7 +84,6 @@ def getch(self):
Should not be called in the same program as getarrow().
"""
s = ''
if os.name == 'nt':
return msvcrt.getch().decode('utf-8')
else:
Expand Down
3 changes: 2 additions & 1 deletion uiplib/scrape/onlineFetch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Module to fetch wallpapers."""

from uiplib.scrape.scrape import get_images
from threading import Thread

from uiplib.scrape.scrape import get_images


class onlineFetch(Thread):
"""Generic thread module to download images."""
Expand Down
7 changes: 4 additions & 3 deletions uiplib/scrape/scrape.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""Module that scrapes the wallpapers."""

from bs4 import BeautifulSoup
import requests
from urllib.request import urlretrieve, getproxies
import os
import sys
import json
from urllib.request import urlretrieve, getproxies

import requests
from bs4 import BeautifulSoup


def make_soup(url): # pragma: no cover
Expand Down
1 change: 1 addition & 0 deletions uiplib/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module that configures the settings for UIP."""

import os
import json
import argparse
Expand Down
2 changes: 1 addition & 1 deletion uiplib/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""UIP Main utility module."""

import os
import sys
import time
import json

from uiplib.settings import HOME_DIR


Expand Down

0 comments on commit acd93e5

Please sign in to comment.