Reformated _reset method placement, Fixed pylint issues & reverted pylint ignore comment delete changes
This commit is contained in:
parent
4f9593a553
commit
a3dceb8b3e
|
@ -165,13 +165,6 @@ class BMConfigParser(SafeConfigParser):
|
||||||
but override the "raw" argument to always True"""
|
but override the "raw" argument to always True"""
|
||||||
return SafeConfigParser.items(self, section, True, variables)
|
return SafeConfigParser.items(self, section, True, variables)
|
||||||
|
|
||||||
if sys.version_info[0] == 3:
|
|
||||||
@staticmethod
|
|
||||||
def addresses(hidden=False):
|
|
||||||
"""Return a list of local bitmessage addresses (from section labels)"""
|
|
||||||
return [x for x in BMConfigParser().sections() if x.startswith('BM-') and (
|
|
||||||
hidden or not BMConfigParser().safeGetBoolean(x, 'hidden'))]
|
|
||||||
|
|
||||||
def _reset(self):
|
def _reset(self):
|
||||||
"""Reset current config. There doesn't appear to be a built in
|
"""Reset current config. There doesn't appear to be a built in
|
||||||
method for this"""
|
method for this"""
|
||||||
|
@ -179,6 +172,13 @@ class BMConfigParser(SafeConfigParser):
|
||||||
for x in sections:
|
for x in sections:
|
||||||
self.remove_section(x)
|
self.remove_section(x)
|
||||||
|
|
||||||
|
if sys.version_info[0] == 3:
|
||||||
|
@staticmethod
|
||||||
|
def addresses(hidden=False):
|
||||||
|
"""Return a list of local bitmessage addresses (from section labels)"""
|
||||||
|
return [x for x in BMConfigParser().sections() if x.startswith('BM-') and (
|
||||||
|
hidden or not BMConfigParser().safeGetBoolean(x, 'hidden'))]
|
||||||
|
|
||||||
def read(self, filenames):
|
def read(self, filenames):
|
||||||
self._reset()
|
self._reset()
|
||||||
SafeConfigParser.read(self, filenames)
|
SafeConfigParser.read(self, filenames)
|
||||||
|
@ -200,8 +200,9 @@ class BMConfigParser(SafeConfigParser):
|
||||||
except configparser.InterpolationError:
|
except configparser.InterpolationError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def readfp(self, file_obj):
|
def readfp(self, fp, filename=None):
|
||||||
SafeConfigParser.read_file(self, file_obj)
|
# pylint: no-member=ignore
|
||||||
|
SafeConfigParser.read_file(self, fp)
|
||||||
else:
|
else:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def addresses():
|
def addresses():
|
||||||
|
@ -209,13 +210,6 @@ class BMConfigParser(SafeConfigParser):
|
||||||
return [
|
return [
|
||||||
x for x in BMConfigParser().sections() if x.startswith('BM-')]
|
x for x in BMConfigParser().sections() if x.startswith('BM-')]
|
||||||
|
|
||||||
def _reset(self):
|
|
||||||
"""Reset current config. There doesn't appear to be a built in
|
|
||||||
method for this"""
|
|
||||||
sections = self.sections()
|
|
||||||
for x in sections:
|
|
||||||
self.remove_section(x)
|
|
||||||
|
|
||||||
def read(self, filenames):
|
def read(self, filenames):
|
||||||
"""Read config and populate defaults"""
|
"""Read config and populate defaults"""
|
||||||
self._reset()
|
self._reset()
|
||||||
|
|
|
@ -3,12 +3,8 @@
|
||||||
Various tests for config
|
Various tests for config
|
||||||
"""
|
"""
|
||||||
import unittest
|
import unittest
|
||||||
import tempfile
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
from six import StringIO
|
from six import StringIO
|
||||||
from pybitmessage import paths
|
|
||||||
from pybitmessage.bmconfigparser import BMConfigParser
|
from pybitmessage.bmconfigparser import BMConfigParser
|
||||||
|
|
||||||
test_config = """[bitmessagesettings]
|
test_config = """[bitmessagesettings]
|
||||||
|
@ -51,6 +47,7 @@ class TestConfig(unittest.TestCase):
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""restore to the backup of BMConfigparser"""
|
"""restore to the backup of BMConfigparser"""
|
||||||
|
# pylint: protected-access=ignore
|
||||||
BMConfigParser()._reset()
|
BMConfigParser()._reset()
|
||||||
BMConfigParser().readfp(self.configfile)
|
BMConfigParser().readfp(self.configfile)
|
||||||
|
|
||||||
|
@ -68,6 +65,7 @@ class TestConfig(unittest.TestCase):
|
||||||
False
|
False
|
||||||
)
|
)
|
||||||
# no arg for default
|
# no arg for default
|
||||||
|
# pylint: disable=too-many-function-args
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
BMConfigParser().safeGetBoolean(
|
BMConfigParser().safeGetBoolean(
|
||||||
'nonexistent', 'nonexistent', True)
|
'nonexistent', 'nonexistent', True)
|
||||||
|
@ -93,7 +91,7 @@ class TestConfig(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
BMConfigParser().safeGetInt('bitmessagesettings', 'maxaddrperstreamsend'), 100)
|
BMConfigParser().safeGetInt('bitmessagesettings', 'maxaddrperstreamsend'), 100)
|
||||||
|
# pylint: protected-access=ignore
|
||||||
BMConfigParser()._reset()
|
BMConfigParser()._reset()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
BMConfigParser().safeGetInt('bitmessagesettings', 'maxaddrperstreamsend'), 500)
|
BMConfigParser().safeGetInt('bitmessagesettings', 'maxaddrperstreamsend'), 500)
|
||||||
|
|
Reference in New Issue
Block a user