indexhelper.py'deki fonksiyonları operations'a taşıdım. Bu işlevler yalnızca cli içerisinde değil tüm arayüzlerde kullanılacak genel işlevler. Birazdan buildhelper'ı da taşıyacağım. Bunların ayrı ayrı durması gereksiz.

This commit is contained in:
Barış Metin
2005-07-18 18:54:32 +00:00
parent 026af532f0
commit fd249f7a6f
3 changed files with 26 additions and 30 deletions
+5 -5
View File
@@ -167,11 +167,11 @@ class Index(Command):
self.help() self.help()
return return
from pisi.cli import indexhelper from pisi.operations import index
if len(self.args)==1: if len(self.args)==1:
indexhelper.index(self.args[0]) index(self.args[0])
elif len(self.args)==0: elif len(self.args)==0:
indexhelper.index() index()
else: else:
print 'Indexing only a single directory supported' print 'Indexing only a single directory supported'
return return
@@ -186,8 +186,8 @@ class UpdateDB(Command):
self.help() self.help()
return return
from pisi.cli import indexhelper from pisi.operations import updatedb
indexfile = self.args[0] indexfile = self.args[0]
indexhelper.updatedb(indexfile) updatedb(indexfile)
-22
View File
@@ -1,22 +0,0 @@
# -*- coding: utf-8 -*-
from pisi.index import Index
from pisi.ui import ui
def index(repo_dir = '.'):
ui.info('* Building index of PISI files under ' + repo_dir + '\n')
index = Index()
index.index(repo_dir)
index.write('pisi-index.xml')
ui.info('* Index file written\n')
def updatedb(indexfile):
ui.info('* Updating DB from index file: ' + indexfile + '\n')
index = Index()
index.read(indexfile)
index.update_db()
ui.info('* Package db updated.\n')
+21 -3
View File
@@ -3,15 +3,14 @@ import os
from config import config from config import config
from constants import const from constants import const
from ui import ui from ui import ui
from package import Package
from installdb import installdb
from packagedb import packagedb
from purl import PUrl from purl import PUrl
# all package operation interfaces are here # all package operation interfaces are here
def remove(package_name): def remove(package_name):
"""Remove a goddamn package""" """Remove a goddamn package"""
from installdb import installdb
ui.info('Removing package %s\n' % package_name) ui.info('Removing package %s\n' % package_name)
if not installdb.is_installed(package_name): if not installdb.is_installed(package_name):
raise Exception('Trying to remove nonexistent package ' raise Exception('Trying to remove nonexistent package '
@@ -33,8 +32,27 @@ def install(pkg_location):
def info(package_name): def info(package_name):
from package import Package
package = Package(package_name) package = Package(package_name)
package.read() package.read()
return package.metadata, package.files return package.metadata, package.files
def index(repo_dir = '.'):
from index import Index
ui.info('* Building index of PISI files under %s\n' % repo_dir)
index = Index()
index.index(repo_dir)
index.write('pisi-index.xml')
ui.info('* Index file written\n')
def updatedb(indexfile):
from index import Index
ui.info('* Updating DB from index file: %s\n' % indexfile)
index = Index()
index.read(indexfile)
index.update_db()
ui.info('* Package db updated.\n')