forked from Github/guess-filename.py
finished config file loader
This commit is contained in:
parent
87831ddf11
commit
184f397df1
2 changed files with 15 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Time-stamp: <2016-03-06 18:43:17 vk>
|
||||
# Time-stamp: <2016-03-06 18:57:59 vk>
|
||||
|
||||
# TODO:
|
||||
# * fix parts marked with «FIXXME»
|
||||
|
|
@ -30,7 +30,6 @@ PROG_VERSION_NUMBER = u"0.1"
|
|||
PROG_VERSION_DATE = u"2016-03-04"
|
||||
INVOCATION_TIME = time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime())
|
||||
|
||||
|
||||
USAGE = u"\n\
|
||||
" + sys.argv[0] + u" [<options>] <list of files>\n\
|
||||
\n\
|
||||
|
|
@ -357,10 +356,12 @@ def main():
|
|||
|
||||
logging.debug("%s filenames found: [%s]" % (str(len(files)), '], ['.join(files)))
|
||||
|
||||
CONFIGDIR = os.path.join(os.path.expanduser("~"), ".config/guessfilename")
|
||||
sys.path.insert(0, CONFIGDIR) # add CONFIGDIR to Python path in order to find config file
|
||||
try:
|
||||
import guessfilenameconfig
|
||||
except ImportError:
|
||||
print "Could not find \"guessfilenameconfig.py\".\nPlease take a look at \"guessfilenameconfig-TEMPLATE.py\" and configure accordingly."
|
||||
print "Could not find \"guessfilenameconfig.py\" in directory \"" + CONFIGDIR + "\".\nPlease take a look at \"guessfilenameconfig-TEMPLATE.py\", copy it, and configure accordingly."
|
||||
sys.exit(1)
|
||||
|
||||
guess_filename = GuessFilename(guessfilenameconfig, logging.getLogger())
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8; mode: python; -*-
|
||||
# Time-stamp: <2016-03-06 18:37:15 vk>
|
||||
# Time-stamp: <2016-03-06 18:58:52 vk>
|
||||
|
||||
import unittest
|
||||
import logging
|
||||
import tempfile
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
from guessfilename import GuessFilename
|
||||
|
||||
|
||||
|
|
@ -30,7 +31,15 @@ class TestGuessFilename(unittest.TestCase):
|
|||
def setUp(self):
|
||||
verbose = True
|
||||
quiet = False
|
||||
import guessfilenameconfig
|
||||
|
||||
CONFIGDIR = os.path.join(os.path.expanduser("~"), ".config/guessfilename")
|
||||
sys.path.insert(0, CONFIGDIR) # add CONFIGDIR to Python path in order to find config file
|
||||
try:
|
||||
import guessfilenameconfig
|
||||
except ImportError:
|
||||
print "Could not find \"guessfilenameconfig.py\" in directory \"" + CONFIGDIR + "\".\nPlease take a look at \"guessfilenameconfig-TEMPLATE.py\", copy it, and configure accordingly."
|
||||
sys.exit(1)
|
||||
|
||||
self.handle_logging(verbose, quiet)
|
||||
self.guess_filename = GuessFilename(guessfilenameconfig, logging)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue