pisi.purl -> pisi.URI
This commit is contained in:
@@ -14,7 +14,7 @@ import sys
|
|||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
import pisi
|
import pisi
|
||||||
from pisi.purl import PUrl
|
from pisi.purl import URI
|
||||||
from pisi.cli.common import *
|
from pisi.cli.common import *
|
||||||
|
|
||||||
|
|
||||||
@@ -352,6 +352,11 @@ source and binary packages.
|
|||||||
def name(self):
|
def name(self):
|
||||||
return ("index", "ix")
|
return ("index", "ix")
|
||||||
|
|
||||||
|
def options(self):
|
||||||
|
self.parser.add_option("-a", "--absolute-uris", action="store_true",
|
||||||
|
default=False,
|
||||||
|
help="store absolute links for indexed files.")
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
self.init()
|
self.init()
|
||||||
@@ -492,7 +497,7 @@ Lists currently tracked repositories.
|
|||||||
from pisi.repodb import repodb
|
from pisi.repodb import repodb
|
||||||
for repo in repodb.list():
|
for repo in repodb.list():
|
||||||
print repo
|
print repo
|
||||||
print ' ', repodb.get_repo(repo).indexuri.getUri()
|
print ' ', repodb.get_repo(repo).indexuri.get_uri()
|
||||||
self.finalize()
|
self.finalize()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ import sys
|
|||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
import pisi
|
import pisi
|
||||||
from pisi.purl import PUrl
|
from pisi.purl import URI
|
||||||
from pisi.cli.common import *
|
from pisi.cli.common import *
|
||||||
from pisi.cli.commands import *
|
from pisi.cli.commands import *
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -23,7 +23,7 @@ from base64 import encodestring
|
|||||||
# pisi modules
|
# pisi modules
|
||||||
import pisi
|
import pisi
|
||||||
import pisi.util as util
|
import pisi.util as util
|
||||||
from pisi.purl import PUrl
|
from pisi.purl import URI
|
||||||
from pisi.ui import ui
|
from pisi.ui import ui
|
||||||
|
|
||||||
|
|
||||||
@@ -44,8 +44,8 @@ class Fetcher:
|
|||||||
"""Fetcher can fetch a file from various sources using various
|
"""Fetcher can fetch a file from various sources using various
|
||||||
protocols."""
|
protocols."""
|
||||||
def __init__(self, url, dest):
|
def __init__(self, url, dest):
|
||||||
if not isinstance(url, PUrl):
|
if not isinstance(url, URI):
|
||||||
url = PUrl(url)
|
url = URI(url)
|
||||||
|
|
||||||
self.url = url
|
self.url = url
|
||||||
self.filedest = dest
|
self.filedest = dest
|
||||||
@@ -63,7 +63,7 @@ class Fetcher:
|
|||||||
if not os.access(self.filedest, os.W_OK):
|
if not os.access(self.filedest, os.W_OK):
|
||||||
self.err("no perm to write to dest dir")
|
self.err("no perm to write to dest dir")
|
||||||
|
|
||||||
if self.url.isLocalFile():
|
if self.url.is_local_file():
|
||||||
self.fetchLocalFile()
|
self.fetchLocalFile()
|
||||||
else:
|
else:
|
||||||
self.fetchRemoteFile()
|
self.fetchRemoteFile()
|
||||||
@@ -141,7 +141,7 @@ class Fetcher:
|
|||||||
self.doGrab(fileObj, dest, totalsize)
|
self.doGrab(fileObj, dest, totalsize)
|
||||||
|
|
||||||
def formatRequest(self, request):
|
def formatRequest(self, request):
|
||||||
authinfo = self.url.authInfo()
|
authinfo = self.url.auth_info()
|
||||||
if authinfo:
|
if authinfo:
|
||||||
enc = encodestring("%s:%s" % authinfo)
|
enc = encodestring("%s:%s" % authinfo)
|
||||||
request.add_header('Authorization', 'Basic %s' % enc)
|
request.add_header('Authorization', 'Basic %s' % enc)
|
||||||
|
|||||||
+10
-10
@@ -24,7 +24,7 @@ from pisi.ui import ui
|
|||||||
import pisi.util as util
|
import pisi.util as util
|
||||||
from pisi.config import config
|
from pisi.config import config
|
||||||
from pisi.constants import const
|
from pisi.constants import const
|
||||||
from pisi.purl import PUrl
|
from pisi.purl import URI
|
||||||
|
|
||||||
class Index(XmlFile):
|
class Index(XmlFile):
|
||||||
|
|
||||||
@@ -37,8 +37,8 @@ class Index(XmlFile):
|
|||||||
"""Read PSPEC file"""
|
"""Read PSPEC file"""
|
||||||
|
|
||||||
self.filepath = filename
|
self.filepath = filename
|
||||||
url = PUrl(filename)
|
url = URI(filename)
|
||||||
if url.isRemoteFile():
|
if url.is_remote_file():
|
||||||
from fetcher import fetchUrl
|
from fetcher import fetchUrl
|
||||||
|
|
||||||
dest = os.path.join(config.index_dir(), repo)
|
dest = os.path.join(config.index_dir(), repo)
|
||||||
@@ -86,13 +86,13 @@ class Index(XmlFile):
|
|||||||
|
|
||||||
md = metadata.MetaData()
|
md = metadata.MetaData()
|
||||||
md.read(os.path.join(config.install_dir(), const.metadata_xml))
|
md.read(os.path.join(config.install_dir(), const.metadata_xml))
|
||||||
# TODO: in the future we'll do all of this with purl/pfile/&helpers
|
if config.options and config.options.absolute_uris:
|
||||||
# After that, we'll remove the ugly repo_uri parameter from this
|
md.package.packageURI = os.path.realpath(path)
|
||||||
# function.
|
else: # create relative path by default
|
||||||
# FIXME: for now, do all paths absolute, support relative URIs
|
# TODO: in the future we'll do all of this with purl/pfile/&helpers
|
||||||
# in the future
|
# After that, we'll remove the ugly repo_uri parameter from this
|
||||||
#md.package.packageURI = util.removepathprefix(repo_uri, path)
|
# function.
|
||||||
md.package.packageURI = os.path.realpath(path)
|
md.package.packageURI = util.removepathprefix(repo_uri, path)
|
||||||
# check package semantics
|
# check package semantics
|
||||||
if md.has_errors():
|
if md.has_errors():
|
||||||
ui.error('Package ' + md.package.name + ': metadata corrupt\n')
|
ui.error('Package ' + md.package.name + ': metadata corrupt\n')
|
||||||
|
|||||||
+6
-8
@@ -16,7 +16,7 @@ import pisi
|
|||||||
from pisi.config import config
|
from pisi.config import config
|
||||||
from pisi.constants import const
|
from pisi.constants import const
|
||||||
from pisi.ui import ui
|
from pisi.ui import ui
|
||||||
from pisi.purl import PUrl
|
from pisi.purl import URI
|
||||||
import pisi.util as util
|
import pisi.util as util
|
||||||
import pisi.packagedb as packagedb
|
import pisi.packagedb as packagedb
|
||||||
|
|
||||||
@@ -53,11 +53,11 @@ def remove_single(package_name):
|
|||||||
|
|
||||||
def install_single(pkg, upgrade = False):
|
def install_single(pkg, upgrade = False):
|
||||||
"""install a single package from URI or ID"""
|
"""install a single package from URI or ID"""
|
||||||
url = PUrl(pkg)
|
url = URI(pkg)
|
||||||
# Check if we are dealing with a remote file or a real path of
|
# Check if we are dealing with a remote file or a real path of
|
||||||
# package filename. Otherwise we'll try installing a package from
|
# package filename. Otherwise we'll try installing a package from
|
||||||
# the package repository.
|
# the package repository.
|
||||||
if url.isRemoteFile() or os.path.exists(url.uri):
|
if url.is_remote_file() or os.path.exists(url.uri):
|
||||||
install_single_file(pkg, upgrade)
|
install_single_file(pkg, upgrade)
|
||||||
else:
|
else:
|
||||||
install_single_name(pkg, upgrade)
|
install_single_name(pkg, upgrade)
|
||||||
@@ -72,19 +72,17 @@ def install_single_name(name, upgrade = False):
|
|||||||
# find package in repository
|
# find package in repository
|
||||||
repo = packagedb.which_repo(name)
|
repo = packagedb.which_repo(name)
|
||||||
if repo:
|
if repo:
|
||||||
# TODO: Allright this is ugly, but works. Eventually, we'll
|
|
||||||
# change this...
|
|
||||||
from repodb import repodb
|
from repodb import repodb
|
||||||
repo = repodb.get_repo(repo)
|
repo = repodb.get_repo(repo)
|
||||||
pkg = packagedb.get_package(name)
|
pkg = packagedb.get_package(name)
|
||||||
|
|
||||||
if repo.indexuri.isLocalFile():
|
if repo.indexuri.is_local_file():
|
||||||
pkg_path = pkg.packageURI
|
pkg_path = pkg.packageURI
|
||||||
else:
|
else:
|
||||||
# FIXME: determine if we have relative paths in the index
|
# FIXME: determine if we have relative paths in the index
|
||||||
# rather than doing this. Requires the index to know about
|
# rather than doing this. Requires the index to know about
|
||||||
# that
|
# that
|
||||||
pkg_path = os.path.join(os.path.dirname(repo.indexuri.getUri()),
|
pkg_path = os.path.join(os.path.dirname(repo.indexuri.get_uri()),
|
||||||
os.path.basename(pkg.packageURI))
|
os.path.basename(pkg.packageURI))
|
||||||
|
|
||||||
ui.debug("Package URI: %s\n" % pkg_path)
|
ui.debug("Package URI: %s\n" % pkg_path)
|
||||||
@@ -92,7 +90,7 @@ def install_single_name(name, upgrade = False):
|
|||||||
# Package will handle remote file for us!
|
# Package will handle remote file for us!
|
||||||
install_single_file(pkg_path, upgrade)
|
install_single_file(pkg_path, upgrade)
|
||||||
else:
|
else:
|
||||||
ui.error("Package %s not found in the repository file.\n" % pkg)
|
ui.error("Package %s not found in any active repository.\n" % pkg)
|
||||||
|
|
||||||
# deneme, don't remove ulan
|
# deneme, don't remove ulan
|
||||||
class AtomicOperation(object):
|
class AtomicOperation(object):
|
||||||
|
|||||||
+3
-3
@@ -21,7 +21,7 @@ import pisi
|
|||||||
import pisi.archive as archive
|
import pisi.archive as archive
|
||||||
from pisi.constants import const
|
from pisi.constants import const
|
||||||
from pisi.config import config
|
from pisi.config import config
|
||||||
from pisi.purl import PUrl
|
from pisi.purl import URI
|
||||||
from pisi.metadata import MetaData
|
from pisi.metadata import MetaData
|
||||||
from pisi.files import Files
|
from pisi.files import Files
|
||||||
|
|
||||||
@@ -34,9 +34,9 @@ class Package:
|
|||||||
file)."""
|
file)."""
|
||||||
def __init__(self, packagefn, mode='r'):
|
def __init__(self, packagefn, mode='r'):
|
||||||
self.filepath = packagefn
|
self.filepath = packagefn
|
||||||
url = PUrl(packagefn)
|
url = URI(packagefn)
|
||||||
|
|
||||||
if url.isRemoteFile():
|
if url.is_remote_file():
|
||||||
from fetcher import fetchUrl
|
from fetcher import fetchUrl
|
||||||
from ui import ui
|
from ui import ui
|
||||||
dest = config.packages_dir()
|
dest = config.packages_dir()
|
||||||
|
|||||||
+12
-13
@@ -7,20 +7,19 @@
|
|||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
#
|
||||||
|
# Simplifies working with URLs, purl module provides common URL
|
||||||
# Simplifying working with URLs, PURL module provides common URL
|
# parsing and processing
|
||||||
# parsing interface
|
|
||||||
|
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
from os.path import basename
|
from os.path import basename
|
||||||
|
|
||||||
class PUrl(object):
|
class URI(object):
|
||||||
"""PUrl class provides a URL parser and simplifies working with
|
"""PUrl class provides a URL parser and simplifies working with
|
||||||
URLs."""
|
URLs."""
|
||||||
|
|
||||||
def __init__(self, uri=None):
|
def __init__(self, uri=None):
|
||||||
if uri:
|
if uri:
|
||||||
self.setUri(uri)
|
self.set_uri(uri)
|
||||||
else:
|
else:
|
||||||
self.__scheme = None
|
self.__scheme = None
|
||||||
self.__location = None
|
self.__location = None
|
||||||
@@ -33,12 +32,12 @@ class PUrl(object):
|
|||||||
|
|
||||||
self.__authinfo = None
|
self.__authinfo = None
|
||||||
|
|
||||||
def getUri(self):
|
def get_uri(self):
|
||||||
if self.__uri:
|
if self.__uri:
|
||||||
return self.__uri
|
return self.__uri
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def setUri(self, uri):
|
def set_uri(self, uri):
|
||||||
# (scheme, location, path, params, query, fragment)
|
# (scheme, location, path, params, query, fragment)
|
||||||
u = urlparse(uri, "file")
|
u = urlparse(uri, "file")
|
||||||
self.__scheme = u[0]
|
self.__scheme = u[0]
|
||||||
@@ -51,21 +50,21 @@ class PUrl(object):
|
|||||||
|
|
||||||
self.__uri = uri
|
self.__uri = uri
|
||||||
|
|
||||||
def isLocalFile(self):
|
def is_local_file(self):
|
||||||
if self.scheme() == "file":
|
if self.scheme() == "file":
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def isRemoteFile(self):
|
def is_remote_file(self):
|
||||||
return not self.isLocalFile()
|
return not self.is_local_file()
|
||||||
|
|
||||||
def setAuthInfo(self, authTuple):
|
def set_auth_info(self, authTuple):
|
||||||
if not isinstance(authTuple, tuple):
|
if not isinstance(authTuple, tuple):
|
||||||
raise Exception, "setAuthInfo needs a tuple (user, pass)"
|
raise Exception, "setAuthInfo needs a tuple (user, pass)"
|
||||||
self.__authinfo = authTuple
|
self.__authinfo = authTuple
|
||||||
|
|
||||||
def authInfo(self):
|
def auth_info(self):
|
||||||
return self.__authinfo
|
return self.__authinfo
|
||||||
|
|
||||||
def scheme(self):
|
def scheme(self):
|
||||||
@@ -90,6 +89,6 @@ class PUrl(object):
|
|||||||
return self.__fragment
|
return self.__fragment
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.getUri()
|
return self.get_uri()
|
||||||
|
|
||||||
uri = property(getUri, setUri)
|
uri = property(getUri, setUri)
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ import os, fcntl
|
|||||||
from pisi.config import config
|
from pisi.config import config
|
||||||
import pisi.packagedb as packagedb
|
import pisi.packagedb as packagedb
|
||||||
import pisi.util as util
|
import pisi.util as util
|
||||||
from pisi.purl import PUrl
|
from pisi.purl import URI
|
||||||
|
|
||||||
class RepoDB(object):
|
class RepoDB(object):
|
||||||
"""RepoDB maps repo ids to repository information"""
|
"""RepoDB maps repo ids to repository information"""
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ from os import access, R_OK
|
|||||||
# pisi modules
|
# pisi modules
|
||||||
import pisi
|
import pisi
|
||||||
from pisi.archive import Archive
|
from pisi.archive import Archive
|
||||||
from pisi.purl import PUrl
|
from pisi.purl import URI
|
||||||
from pisi.ui import ui
|
from pisi.ui import ui
|
||||||
from pisi.config import config
|
from pisi.config import config
|
||||||
from pisi.fetcher import fetchUrl
|
from pisi.fetcher import fetchUrl
|
||||||
@@ -36,7 +36,7 @@ class SourceArchive:
|
|||||||
and unpacking a source archive"""
|
and unpacking a source archive"""
|
||||||
def __init__(self, ctx):
|
def __init__(self, ctx):
|
||||||
self.ctx = ctx
|
self.ctx = ctx
|
||||||
self.url = PUrl(self.ctx.spec.source.archiveUri)
|
self.url = URI(self.ctx.spec.source.archiveUri)
|
||||||
self.archiveFile = join(config.archives_dir(), self.url.filename())
|
self.archiveFile = join(config.archives_dir(), self.url.filename())
|
||||||
self.archiveType = self.ctx.spec.source.archiveType
|
self.archiveType = self.ctx.spec.source.archiveType
|
||||||
self.archiveSHA1 = self.ctx.spec.source.archiveSHA1
|
self.archiveSHA1 = self.ctx.spec.source.archiveSHA1
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ from os.path import basename, dirname, join
|
|||||||
from pisi.ui import ui
|
from pisi.ui import ui
|
||||||
from pisi.config import config
|
from pisi.config import config
|
||||||
from pisi.constants import const
|
from pisi.constants import const
|
||||||
from pisi.purl import PUrl
|
from pisi.purl import URI
|
||||||
from pisi.specfile import SpecFile
|
from pisi.specfile import SpecFile
|
||||||
|
|
||||||
class SourceFetcher(object):
|
class SourceFetcher(object):
|
||||||
def __init__(self, url, authInfo=None):
|
def __init__(self, url, authInfo=None):
|
||||||
self.url = url
|
self.url = url
|
||||||
if authInfo:
|
if authInfo:
|
||||||
self.url.setAuthInfo(authInfo)
|
self.url.set_auth_info(authInfo)
|
||||||
self.location = dirname(self.url.uri)
|
self.location = dirname(self.url.uri)
|
||||||
|
|
||||||
pkgname = basename(dirname(self.url.path()))
|
pkgname = basename(dirname(self.url.path()))
|
||||||
|
|||||||
+5
-5
@@ -20,7 +20,7 @@ if ver[0] <= 2 and ver[1] < 4:
|
|||||||
from pisi.config import config
|
from pisi.config import config
|
||||||
from pisi.constants import const
|
from pisi.constants import const
|
||||||
from pisi.ui import ui
|
from pisi.ui import ui
|
||||||
from pisi.purl import PUrl
|
from pisi.purl import URI
|
||||||
import pisi.util as util
|
import pisi.util as util
|
||||||
import pisi.dependency as dependency
|
import pisi.dependency as dependency
|
||||||
import pisi.pgraph as pgraph
|
import pisi.pgraph as pgraph
|
||||||
@@ -357,7 +357,7 @@ class Repo:
|
|||||||
self.indexuri = indexuri
|
self.indexuri = indexuri
|
||||||
|
|
||||||
def add_repo(name, indexuri):
|
def add_repo(name, indexuri):
|
||||||
repo = Repo(PUrl(indexuri))
|
repo = Repo(URI(indexuri))
|
||||||
repodb.add_repo(name, repo)
|
repodb.add_repo(name, repo)
|
||||||
|
|
||||||
def remove_repo(name):
|
def remove_repo(name):
|
||||||
@@ -371,7 +371,7 @@ def update_repo(repo):
|
|||||||
|
|
||||||
ui.info('* Updating repository: %s\n' % repo)
|
ui.info('* Updating repository: %s\n' % repo)
|
||||||
index = Index()
|
index = Index()
|
||||||
index.read(repodb.get_repo(repo).indexuri.getUri(), repo)
|
index.read(repodb.get_repo(repo).indexuri.get_uri(), repo)
|
||||||
index.update_db(repo)
|
index.update_db(repo)
|
||||||
ui.info('* Package db updated.\n')
|
ui.info('* Package db updated.\n')
|
||||||
|
|
||||||
@@ -383,8 +383,8 @@ def prepare_for_build(pspecfile, authInfo=None):
|
|||||||
# makes it impossible to use build module directly.
|
# makes it impossible to use build module directly.
|
||||||
from build import PisiBuild
|
from build import PisiBuild
|
||||||
|
|
||||||
url = PUrl(pspecfile)
|
url = URI(pspecfile)
|
||||||
if url.isRemoteFile():
|
if url.is_remote_file():
|
||||||
from sourcefetcher import SourceFetcher
|
from sourcefetcher import SourceFetcher
|
||||||
fs = SourceFetcher(url, authInfo)
|
fs = SourceFetcher(url, authInfo)
|
||||||
url.uri = fs.fetch_all()
|
url.uri = fs.fetch_all()
|
||||||
|
|||||||
Reference in New Issue
Block a user