# Path: src/artifactcli/operation/baseoperation.py
# class BaseOperation(CaseClass):
#     __metaclass__ = ABCMeta
# 
#     def __init__(self, group_id=None, args=None, optional_params=None):
#         optional_params = optional_params or {}
#         super(BaseOperation, self).__init__(['group_id', 'args'] + list(optional_params.keys()))
# 
#         self.group_id = group_id
#         self.args = args
# 
#         for k in optional_params:
#             setattr(self, k, optional_params[k])
# 
#     def _get_arg(self, index, name):
#         try:
#             return self.args[index]
#         except IndexError:
#             logging.error('Argument <%s> is required.' % name)
#             raise AssertionError
# 
#     @abstractmethod
#     def run(self, repo):
#         """abstract method"""


import logging
from .baseoperation import BaseOperation
from artifactcli.artifact import BasicInfo


class DeleteOperation(BaseOperation):
    def __init__(self, group_id, args, print_only):
        super(DeleteOperation, self).__init__(group_id, args, {'print_only': print_only})
        self.file_name = self._get_arg(0, 'FILE_NAME')
        self.revision = self._get_arg(1, 'REVISION')
        assert self.revision.isdigit()

    def run(self, repo):
        revision = int(self.revision)

        try:

# Path: src/artifactcli/operation/baseoperation.py
# class BaseOperation(CaseClass):
#     __metaclass__ = ABCMeta
# 
#     def __init__(self, group_id=None, args=None, optional_params=None):
#         optional_params = optional_params or {}
#         super(BaseOperation, self).__init__(['group_id', 'args'] + list(optional_params.keys()))
# 
#         self.group_id = group_id
#         self.args = args
# 
#         for k in optional_params:
#             setattr(self, k, optional_params[k])
# 
#     def _get_arg(self, index, name):
#         try:
#             return self.args[index]
#         except IndexError:
#             logging.error('Argument <%s> is required.' % name)
#             raise AssertionError
# 
#     @abstractmethod
#     def run(self, repo):
#         """abstract method"""


# Path: src/artifactcli/operation/delete.py
import logging
from .baseoperation import BaseOperation
from artifactcli.artifact import BasicInfo



class DeleteOperation(BaseOperation):
    def __init__(self, group_id, args, print_only):
        super(DeleteOperation, self).__init__(group_id, args, {'print_only': print_only})
        self.file_name = self._get_arg(0, 'FILE_NAME')
        self.revision = self._get_arg(1, 'REVISION')
        assert self.revision.isdigit()

    def run(self, repo):
        revision = int(self.revision)

        try:

            artifact_id = BasicInfo.from_path(self.group_id, self.file_name).artifact_id