From 1c34cbd6278594ed6df9fad4ab1bcb3a2a9c4eaf Mon Sep 17 00:00:00 2001 From: Brian Warner <warner@lothar.com> Date: Tue, 26 May 2015 08:06:06 -0700 Subject: [PATCH] refactor scripts/common.py: move _default_nodedir out to its own file --- src/allmydata/scripts/common.py | 16 +--------------- src/allmydata/scripts/default_nodedir.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 src/allmydata/scripts/default_nodedir.py diff --git a/src/allmydata/scripts/common.py b/src/allmydata/scripts/common.py index 55cb3f08..2894d3dd 100644 --- a/src/allmydata/scripts/common.py +++ b/src/allmydata/scripts/common.py @@ -5,21 +5,7 @@ from twisted.python import usage from allmydata.util.assertutil import precondition from allmydata.util.encodingutil import unicode_to_url, quote_output, \ quote_local_unicode_path, argv_to_abspath -from allmydata.util.fileutil import abspath_expanduser_unicode - - -_default_nodedir = None -if sys.platform == 'win32': - from allmydata.windows import registry - path = registry.get_base_dir_path() - if path: - precondition(isinstance(path, unicode), path) - _default_nodedir = abspath_expanduser_unicode(path) - -if _default_nodedir is None: - path = abspath_expanduser_unicode(u"~/.tahoe") - precondition(isinstance(path, unicode), path) - _default_nodedir = path +from allmydata.scripts.default_nodedir import _default_nodedir def get_default_nodedir(): return _default_nodedir diff --git a/src/allmydata/scripts/default_nodedir.py b/src/allmydata/scripts/default_nodedir.py new file mode 100644 index 00000000..4f390dd9 --- /dev/null +++ b/src/allmydata/scripts/default_nodedir.py @@ -0,0 +1,17 @@ + +import sys +from allmydata.util.assertutil import precondition +from allmydata.util.fileutil import abspath_expanduser_unicode + +_default_nodedir = None +if sys.platform == 'win32': + from allmydata.windows import registry + path = registry.get_base_dir_path() + if path: + precondition(isinstance(path, unicode), path) + _default_nodedir = abspath_expanduser_unicode(path) + +if _default_nodedir is None: + path = abspath_expanduser_unicode(u"~/.tahoe") + precondition(isinstance(path, unicode), path) + _default_nodedir = path -- 2.45.2