Files
dvc/dvc/settings.py
T
Ruslan Kuprieiev ee34fdfa31 RFC: move cmdline parsing to cli.py and settings RFC
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]>
2017-07-31 01:39:32 +03:00

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