mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 15:28:34 +01:00
This will make the structure of dvc more linear making it easier to read. Plus, these changes are needed in preparation for libdvc, as they move all cmdline parsing to one common place. This patch also refactors our settings system also make it more linear and remove abstraction levels that are not needed and only cause confusion. There is a lot more to be done in preparation for dvc lib and RFC overall, but this a first step in that long journey. Signed-off-by: Ruslan Kuprieiev <[email protected]>
66 lines
1.4 KiB
Python
66 lines
1.4 KiB
Python
import os
|
|
|
|
from dvc.git_wrapper import GitWrapperI, GitWrapper
|
|
from dvc.config import ConfigI, Config
|
|
from dvc.exceptions import DvcException
|
|
from dvc.path.factory import PathFactory
|
|
from dvc.cli import parse_args
|
|
|
|
class SettingsError(DvcException):
|
|
def __init__(self, msg):
|
|
DvcException.__init__(self, msg)
|
|
|
|
|
|
class Settings(object):
|
|
def __init__(self, argv=None, git=None, config=None):
|
|
self._args = None
|
|
args = None
|
|
|
|
if argv != None and len(argv) != 0:
|
|
args = parse_args(argv)
|
|
self._args = argv[2:]
|
|
|
|
if git == None:
|
|
git = GitWrapper()
|
|
|
|
if config == None:
|
|
if args != None and args.cmd != 'init':
|
|
config = Config()
|
|
else:
|
|
config = ConfigI()
|
|
|
|
self._git = git
|
|
self._config = config
|
|
self._path_factory = PathFactory(git, config)
|
|
self._parsed_args = args
|
|
|
|
@property
|
|
def args(self):
|
|
return self._args
|
|
|
|
def set_args(self, args):
|
|
self._args = args
|
|
|
|
@property
|
|
def parsed_args(self):
|
|
return self._parsed_args
|
|
|
|
def parse_args(self, args):
|
|
self._parsed_args = parse_args(args)
|
|
|
|
@property
|
|
def git(self):
|
|
return self._git
|
|
|
|
@property
|
|
def config(self):
|
|
return self._config
|
|
|
|
@property
|
|
def dvc_home(self):
|
|
return self._dvc_home
|
|
|
|
@property
|
|
def path_factory(self):
|
|
return self._path_factory
|