mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-04 15:28:27 +01:00
37 lines
705 B
Python
37 lines
705 B
Python
import logging
|
|
import os
|
|
from abc import ABC, abstractmethod
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class CmdBase(ABC):
|
|
UNINITIALIZED = False
|
|
|
|
def __init__(self, args):
|
|
from dvc.repo import Repo
|
|
|
|
os.chdir(args.cd)
|
|
|
|
self.repo: "Repo" = Repo(uninitialized=self.UNINITIALIZED)
|
|
self.config = self.repo.config
|
|
self.args = args
|
|
|
|
def do_run(self):
|
|
with self.repo:
|
|
return self.run()
|
|
|
|
@abstractmethod
|
|
def run(self):
|
|
pass
|
|
|
|
|
|
class CmdBaseNoRepo(CmdBase):
|
|
def __init__(self, args): # pylint: disable=super-init-not-called
|
|
self.args = args
|
|
|
|
os.chdir(args.cd)
|
|
|
|
def do_run(self):
|
|
return self.run()
|