[eit.commands.add] implement "eit add" (and eit add --to, was eit addto)
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
|
||||
@author: Fabio Erculiani <lxnay@sabayon.org>
|
||||
@contact: lxnay@sabayon.org
|
||||
@copyright: Fabio Erculiani
|
||||
@license: GPL-2
|
||||
|
||||
B{Entropy Infrastructure Toolkit}.
|
||||
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
|
||||
from entropy.const import etpConst
|
||||
from entropy.i18n import _
|
||||
from entropy.exceptions import PermissionDenied
|
||||
from entropy.output import print_error, darkgreen, \
|
||||
teal, brown, darkred, bold, purple, blue
|
||||
|
||||
from text_tools import print_table
|
||||
|
||||
import entropy.tools
|
||||
|
||||
from eit.commands.descriptor import EitCommandDescriptor
|
||||
from eit.commands.commit import EitCommit
|
||||
|
||||
|
||||
class EitAdd(EitCommit):
|
||||
"""
|
||||
Main Eit add command.
|
||||
"""
|
||||
|
||||
NAME = "add"
|
||||
|
||||
def parse(self):
|
||||
""" Overridden from EitCommit """
|
||||
descriptor = EitCommandDescriptor.obtain_descriptor(
|
||||
EitAdd.NAME)
|
||||
parser = argparse.ArgumentParser(
|
||||
description=descriptor.get_description(),
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
prog="%s %s" % (sys.argv[0], EitAdd.NAME))
|
||||
|
||||
parser.add_argument("packages", nargs='+', metavar="<package>",
|
||||
help=_("package names"))
|
||||
parser.add_argument("--to", metavar="<repository>",
|
||||
help=_("add to given repository"),
|
||||
default=None)
|
||||
|
||||
try:
|
||||
nsargs = parser.parse_args(self._args)
|
||||
except IOError as err:
|
||||
return parser.print_help, []
|
||||
|
||||
# setup atoms variable before spawning commit
|
||||
self._packages = nsargs.packages[:]
|
||||
return self._commit, [nsargs.to]
|
||||
|
||||
EitCommandDescriptor.register(
|
||||
EitCommandDescriptor(
|
||||
EitAdd,
|
||||
EitAdd.NAME,
|
||||
_('commit to repository the provided packages'))
|
||||
)
|
||||
@@ -43,7 +43,7 @@ class EitCommit(EitCommand):
|
||||
# list of package dependencies to re-package, if any
|
||||
self._repackage = []
|
||||
# execute actions only for given atoms, if any
|
||||
self._atoms = []
|
||||
self._packages = []
|
||||
|
||||
def parse(self):
|
||||
descriptor = EitCommandDescriptor.obtain_descriptor(
|
||||
@@ -54,7 +54,7 @@ class EitCommit(EitCommand):
|
||||
prog="%s %s" % (sys.argv[0], EitCommit.NAME))
|
||||
|
||||
parser.add_argument("repo", nargs='?', default=None,
|
||||
metavar="<repo>", help="repository id")
|
||||
metavar="<repo>", help=_("repository"))
|
||||
parser.add_argument("--interactive", action="store_true",
|
||||
default=False,
|
||||
help=_("selectively pick changes"))
|
||||
@@ -157,12 +157,12 @@ class EitCommit(EitCommand):
|
||||
return 1
|
||||
to_be_added |= myadded
|
||||
|
||||
if self._atoms:
|
||||
if self._packages:
|
||||
to_be_removed.clear()
|
||||
to_be_injected.clear()
|
||||
tba = dict(((x[0], x,) for x in to_be_added))
|
||||
tb_added_new = set()
|
||||
for myatom in self._atoms:
|
||||
for myatom in self._packages:
|
||||
if myatom in tba:
|
||||
tb_added_new.add(tba.get(myatom))
|
||||
continue
|
||||
|
||||
@@ -20,6 +20,7 @@ import entropy.tools
|
||||
from eit.commands.status import EitStatus
|
||||
from eit.commands.help import EitHelp
|
||||
from eit.commands.commit import EitCommit
|
||||
from eit.commands.add import EitAdd
|
||||
|
||||
|
||||
def handle_exception(exc_class, exc_instance, exc_tb):
|
||||
@@ -52,6 +53,7 @@ def main():
|
||||
"--help": EitHelp,
|
||||
EitStatus.NAME: EitStatus,
|
||||
EitCommit.NAME: EitCommit,
|
||||
EitAdd.NAME: EitAdd,
|
||||
}
|
||||
|
||||
args = sys.argv[1:]
|
||||
|
||||
Reference in New Issue
Block a user