本文整理匯總了Python中repository.Repository.populate方法的典型用法代碼示例。如果您正苦於以下問題:Python Repository.populate方法的具體用法?Python Repository.populate怎麽用?Python Repository.populate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類repository.Repository
的用法示例。
在下文中一共展示了Repository.populate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: CreepClient
# 需要導入模塊: from repository import Repository [as 別名]
# 或者: from repository.Repository import populate [as 別名]
#.........這裏部分代碼省略.........
def do_uninstall(self, args):
"""Uninstall a package (mod)
Usage: creep uninstall <packagename>
Example: creep uninstall thecricket/chisel2
"""
package = self.repository.fetch_package(args)
if not package:
print 'Unknown package {}'.format(args)
return 1
if package.installdir == 'mods':
savedir = self.minecraftdir + os.sep + package.installdir + os.sep + self.minecraft_target
else:
savedir = self.minecraftdir + os.sep + package.installdir
os.remove(savedir + os.sep + package.get_local_filename())
print "Removed mod '{0}' from '{1}'".format(package.name, savedir)
def do_purge(self, args):
"""Purge all installed packages (mods)
Usage: creep purge
"""
installdir = self.minecraftdir + os.sep + 'mods' + os.sep + self.minecraft_target
print "Purging all installed mods in {}...".format(installdir)
self.delete_path(installdir)
print "Done."
def do_refresh(self, args):
"""Force an refresh of the package repository"""
self.repository.clear_cache()
self.repository.populate()
print self.colortext("Repository updated to version {} ({}).".format(self.repository.version_hash, self.repository.version_date), self.terminal.C_GREEN)
print "Count: {} packages.".format(self.repository.count_packages())
def delete_path(self, rootdir):
files = os.listdir(rootdir)
for f in files:
if os.path.isdir(rootdir + os.sep + f):
self.delete_path(rootdir + os.sep + f)
os.rmdir(rootdir + os.sep + f)
else:
print self.colortext('Removing file {}'.format(f), self.terminal.C_RED)
try:
os.remove(rootdir + os.sep + f)
except OSError:
print 'opa'
continue
def createRepository(self):
self.repository = Repository(self.appdir)
self.repository.set_minecraft_target(self.minecraft_target)
# Check if local packages repository exists and load it too
if os.path.isfile(self.appdir + os.sep + 'local-packages.json'):
self.repository.populate('', False)
self.repository.populate(self.appdir + os.sep + 'local-packages.json')
else:
self.repository.populate('', True)
def updatePaths(self):
self.installdir = os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))))
self.appdir = self.getHomePath('.creep')