-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |