Moved configobj lib into its own folder and fixed imports for our config class to reflect the new path of the lib.

This commit is contained in:
echel0n 2014-04-12 15:24:51 -07:00
parent cea3e96274
commit aa86f74c32
6 changed files with 10 additions and 8 deletions

View file

@ -0,0 +1 @@
from .configobj import *

View file

@ -0,0 +1 @@
__version__ = '5.0.4'

View file

@ -20,6 +20,7 @@ import sys
from codecs import BOM_UTF8, BOM_UTF16, BOM_UTF16_BE, BOM_UTF16_LE from codecs import BOM_UTF8, BOM_UTF16, BOM_UTF16_BE, BOM_UTF16_LE
import six import six
from _version import __version__
# imported lazily to avoid startup performance hit if it isn't used # imported lazily to avoid startup performance hit if it isn't used
compiler = None compiler = None
@ -1233,7 +1234,7 @@ class ConfigObj(Section):
self.filename = infile self.filename = infile
if os.path.isfile(infile): if os.path.isfile(infile):
with open(infile, 'rb') as h: with open(infile, 'rb') as h:
content = h.read() or [] content = h.readlines() or []
elif self.file_error: elif self.file_error:
# raise an error if the file doesn't exist # raise an error if the file doesn't exist
raise IOError('Config file not found: "%s".' % self.filename) raise IOError('Config file not found: "%s".' % self.filename)

View file

@ -1,7 +1,7 @@
import os import os
import shutil import shutil
import nzbtomedia import nzbtomedia
import lib.configobj from lib.configobj import *
from itertools import chain from itertools import chain
class Sections(dict): class Sections(dict):
@ -34,7 +34,7 @@ class Sections(dict):
to_return.update({section:{key:dict.__getitem__(subsection, key)}}) to_return.update({section:{key:dict.__getitem__(subsection, key)}})
return to_return return to_return
class Section(lib.configobj.Section): class Section(configobj.Section):
def isenabled(section): def isenabled(section):
# checks if subsection enabled, returns true/false if subsection specified otherwise returns true/false in {} # checks if subsection enabled, returns true/false if subsection specified otherwise returns true/false in {}
if section: if section:
@ -60,11 +60,11 @@ class Section(lib.configobj.Section):
result.update({section: subsection}) result.update({section: subsection})
return result return result
class ConfigObj(lib.configobj.ConfigObj, Section): class ConfigObj(configobj.ConfigObj, Section):
def __init__(self, *args, **kw): def __init__(self, *args, **kw):
if len(args) == 0: if len(args) == 0:
args = (nzbtomedia.CONFIG_FILE,) args = (nzbtomedia.CONFIG_FILE,)
super(lib.configobj.ConfigObj, self).__init__(*args, **kw) super(configobj.ConfigObj, self).__init__(*args, **kw)
self.interpolation = False self.interpolation = False
@staticmethod @staticmethod
@ -331,7 +331,6 @@ class ConfigObj(lib.configobj.ConfigObj, Section):
CFG_NEW.write() CFG_NEW.write()
CFG_NEW.clear() CFG_NEW.clear()
configobj.Section = Section
lib.configobj.Section = Section configobj.ConfigObj = ConfigObj
lib.configobj.ConfigObj = ConfigObj
config = ConfigObj config = ConfigObj