Merge branch 'issue5' into devel
This commit is contained in:
commit
958fbb61d2
2 changed files with 16 additions and 14 deletions
|
|
@ -16,24 +16,15 @@ def _glymurrc_fname():
|
|||
if os.path.exists(fname):
|
||||
return fname
|
||||
|
||||
# environ var GLYMURCONFIGDIR
|
||||
if 'GLYMURCONFIGDIR' in os.environ:
|
||||
path = os.environ['GLYMURCONFIGDIR']
|
||||
if os.path.exists(path):
|
||||
fname = os.path.join(path, 'glymurrc')
|
||||
if os.path.exists(fname):
|
||||
return fname
|
||||
else:
|
||||
msg = "glymurrc file hinted at by GLYMURCONFIGDIR does not "
|
||||
msg += "exist."
|
||||
warnings.warn(msg, UserWarning)
|
||||
|
||||
# HOME/.glymur/glymurrc
|
||||
# Either GLYMURCONFIGDIR/glymurrc or $HOME/.glymur/glymurrc
|
||||
confdir = _get_configdir()
|
||||
if confdir is not None:
|
||||
fname = os.path.join(_get_configdir(), 'glymurrc')
|
||||
fname = os.path.join(confdir, 'glymurrc')
|
||||
if os.path.exists(fname):
|
||||
return fname
|
||||
else:
|
||||
msg = "Configuration file '{0}' does not exist.".format(confdir)
|
||||
warnings.warn(msg, UserWarning)
|
||||
|
||||
# didn't find a configuration file.
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -597,6 +597,17 @@ class TestJp2k(unittest.TestCase):
|
|||
with self.assertWarns(UserWarning) as cw:
|
||||
imp.reload(glymur)
|
||||
|
||||
@unittest.skipIf(sys.hexversion < 0x03020000,
|
||||
"Uses features introduced in 3.2.")
|
||||
def test_home_dir_missing_config_dir(self):
|
||||
# Verify no exception is raised if $HOME is missing .glymur directory.
|
||||
with tempfile.TemporaryDirectory() as tdir:
|
||||
with patch.dict('os.environ', {'HOME': tdir}):
|
||||
# Misconfigured new configuration file should
|
||||
# be rejected.
|
||||
with self.assertWarns(UserWarning) as cw:
|
||||
imp.reload(glymur)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue