mirror of
https://github.com/nikdoof/tvorganise.git
synced 2025-12-21 22:09:25 +00:00
PEP8 cleanup.
This commit is contained in:
@@ -16,6 +16,7 @@ import shutil
|
|||||||
import ConfigParser
|
import ConfigParser
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
def same_partition(path1, path2):
|
def same_partition(path1, path2):
|
||||||
"""
|
"""
|
||||||
Checks to see if two paths are on the same device, returns a
|
Checks to see if two paths are on the same device, returns a
|
||||||
@@ -23,13 +24,14 @@ def same_partition(path1, path2):
|
|||||||
"""
|
"""
|
||||||
return os.stat(path1).st_dev == os.stat(path2).st_dev
|
return os.stat(path1).st_dev == os.stat(path2).st_dev
|
||||||
|
|
||||||
|
|
||||||
def find_files(args):
|
def find_files(args):
|
||||||
"""
|
"""
|
||||||
Take a singular path or a list of paths and provides a list of all files in
|
Take a singular path or a list of paths and provides a list of all files in
|
||||||
that directory structure.
|
that directory structure.
|
||||||
"""
|
"""
|
||||||
filelist = []
|
filelist = []
|
||||||
|
|
||||||
if isinstance(args, list):
|
if isinstance(args, list):
|
||||||
for path in args:
|
for path in args:
|
||||||
for root, dirs, files in os.walk(path, topdown=False):
|
for root, dirs, files in os.walk(path, topdown=False):
|
||||||
@@ -68,7 +70,7 @@ class TvOrganiser():
|
|||||||
"""
|
"""
|
||||||
Parses the TVOrganiser style config file and produces a dict
|
Parses the TVOrganiser style config file and produces a dict
|
||||||
with all the elements contained within.
|
with all the elements contained within.
|
||||||
|
|
||||||
Also, all regex specified in the file are compiled
|
Also, all regex specified in the file are compiled
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -167,7 +169,8 @@ class TvOrganiser():
|
|||||||
if os.path.exists(opts.config):
|
if os.path.exists(opts.config):
|
||||||
cfile = opts.config
|
cfile = opts.config
|
||||||
else:
|
else:
|
||||||
for path in [ os.path.expanduser('~/.tvorganise.cfg'), '/etc/tvorganise.cfg']:
|
for path in [os.path.expanduser('~/.tvorganise.cfg'),
|
||||||
|
'/etc/tvorganise.cfg']:
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
cfile = path
|
cfile = path
|
||||||
break
|
break
|
||||||
@@ -175,7 +178,7 @@ class TvOrganiser():
|
|||||||
if not cfile:
|
if not cfile:
|
||||||
self._logger.error('Unable to find configuration file!')
|
self._logger.error('Unable to find configuration file!')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
self._logger.info('Using config file: %s' % cfile)
|
self._logger.info('Using config file: %s' % cfile)
|
||||||
config = self._get_config(cfile)
|
config = self._get_config(cfile)
|
||||||
|
|
||||||
@@ -209,24 +212,28 @@ class TvOrganiser():
|
|||||||
try:
|
try:
|
||||||
os.rename(oldfile, newfile)
|
os.rename(oldfile, newfile)
|
||||||
except OSError, errormsg:
|
except OSError, errormsg:
|
||||||
self._logger.error("Error moving file! %s" % errormsg)
|
self._logger.error("Error moving file! %s"
|
||||||
|
% errormsg)
|
||||||
else:
|
else:
|
||||||
self._logger.info("Copying file")
|
self._logger.info("Copying file")
|
||||||
try:
|
try:
|
||||||
shutil.copy(oldfile, newfile)
|
shutil.copy(oldfile, newfile)
|
||||||
except IOError, errormsg:
|
except IOError, errormsg:
|
||||||
self._logger.error("Error copying file! %s" % errormsg)
|
self._logger.error("Error copying file! %s"
|
||||||
|
% errormsg)
|
||||||
else:
|
else:
|
||||||
self._logger.info("done")
|
self._logger.info("done")
|
||||||
else:
|
else:
|
||||||
self._logger.warning("Skipping file: %s" % filename)
|
self._logger.warning("Skipping file: %s" % filename)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""
|
"""
|
||||||
Start a stand alone instance of TvOrganise
|
Start a stand alone instance of TvOrganise
|
||||||
"""
|
"""
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO,format="%(name)s:%(levelname)s: %(message)s")
|
logging.basicConfig(level=logging.INFO,
|
||||||
|
format="%(name)s:%(levelname)s: %(message)s")
|
||||||
|
|
||||||
tvorg = TvOrganiser()
|
tvorg = TvOrganiser()
|
||||||
tvorg.main()
|
tvorg.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user