def search_packages(args): """Display packages from remote index.""" available_packages = package.get_available_packages() for pkg in available_packages: if args.from_lang and args.from_lang != pkg.from_code: continue if args.to_lang and args.to_lang != pkg.to_code: continue print("{0}: {1.from_code} -> {1.to_code}".format( package.argospm_package_name(pkg), pkg))
def populate(self): packages = self.get_packages() self.setRowCount(len(packages)) for i, pkg in enumerate(packages): name = str(pkg) package_name = package.argospm_package_name(pkg) package_version = pkg.package_version from_code = pkg.from_code to_code = pkg.to_code pkg = packages[i] readme_button = QPushButton("view") bound_view_package_readme_function = partial(self.view_package_readme, pkg) readme_button.clicked.connect(bound_view_package_readme_function) row_index = 0 self.setCellWidget(i, row_index, readme_button) row_index += 1 self.setItem(i, row_index, QTableWidgetItem(name)) row_index += 1 self.setItem(i, row_index, QTableWidgetItem(package_name)) row_index += 1 self.setItem(i, row_index, QTableWidgetItem(from_code)) row_index += 1 self.setItem(i, row_index, QTableWidgetItem(to_code)) row_index += 1 self.setItem(i, row_index, QTableWidgetItem(package_version)) row_index += 1 if self.AvailableActions.UNINSTALL in self.available_actions: uninstall_button = QPushButton("🗑") bound_uninstall_function = partial( PackagesTable.uninstall_package, self, pkg ) uninstall_button.clicked.connect(bound_uninstall_function) self.setCellWidget(i, row_index, uninstall_button) row_index += 1 if self.AvailableActions.INSTALL in self.available_actions: if pkg not in self.installed_packages: bound_install_function = partial( PackagesTable.install_package, self, pkg ) install_button = WorkerStatusButton("⬇", bound_install_function) self.setCellWidget(i, row_index, install_button) else: self.setItem(i, row_index, QTableWidgetItem("Installed")) row_index += 1 # Resize table widget self.setMinimumSize(QSize(0, 0)) self.resizeColumnsToContents() self.adjustSize() # Set minimum width of packages_table that also limits size of packages window header_width = self.horizontalHeader().length() self.setMinimumSize( QSize(header_width + self.STRETCH_COLUMN_MIN_PADDING * 2, 0) )
def remove_package(args): """Remove installed package.""" installed_packages = package.get_installed_packages() package_name = args.name for installed_package in installed_packages: name = package.argospm_package_name(installed_package) if name == package_name: installed_package.remove() print(f"Removed package {name}") break else: print("Package not found")
def install_package(args): """Install package.""" available_packages = package.get_available_packages() package_name = args.name for available_package in available_packages: name = package.argospm_package_name(available_package) if name == package_name: download_path = available_package.download() package.install_from_path(download_path) print(f"Installed package to path {download_path}") break else: print("Package not found")
def install_package(args): """Install package.""" available_packages = get_available_packages() package_name = args.name if package_name == "translate": install_all_packages() else: for available_package in available_packages: name = package.argospm_package_name(available_package) if name == package_name: install_package_print_path(available_package) break else: print("Package not found") exit(1)
def list_packages(args): """List packages.""" installed_packages = package.get_installed_packages() for installed_package in installed_packages: print(package.argospm_package_name(installed_package))