Skip to content

Commit

Permalink
Actually add the 'remove' command.
Browse files Browse the repository at this point in the history
  • Loading branch information
HerManNav committed Sep 15, 2022
1 parent 538a0b5 commit a370502
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions pypi_cache/cmd/remove.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import argparse
import os

from typing import List

from pypi_cache.pypiCacheManager import LocalPyPIController


class Remove:
@staticmethod
def init_subparser(parser: argparse.ArgumentParser):
parser.add_argument("packageNameList", type=str, nargs="+", default="", help="Python packages list to be removed from the local repository.")
parser.add_argument("-p", "--index-path", dest="pypiLocalPath", type=str, default=os.getenv("PYPICACHE_INDEX_PATH", default="./.pypi-cache/"), help="Local root path in which the specified package is expected to be.")

@staticmethod
def __fillUpNonUsedArguments(args: argparse.Namespace) -> argparse.Namespace:
argsResult: argparse.Namespace = args
argsResult.onlySources = None
argsResult.includeDevs = None
argsResult.includeRCs = None
argsResult.includePlatformSpecific = None

@staticmethod
def run(args: argparse.Namespace):
Remove.__fillUpNonUsedArguments(args)

listOfPackages: List[str] = args.packageNameList
for packageName in listOfPackages:

args.packageName = packageName
print("Removing '" + packageName + "' from the local index:")

controllerInstance = LocalPyPIController()
controllerInstance.parseScriptArguments(args)

if controllerInstance.isAlreadyAdded():
controllerInstance.removePackage()
else:
print("Package " + controllerInstance.packageName + " has not been added to the local repository yet. Run the 'add' command first.")

print()

0 comments on commit a370502

Please sign in to comment.