本文整理汇总了Python中package.Package类的典型用法代码示例。如果您正苦于以下问题:Python Package类的具体用法?Python Package怎么用?Python Package使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Package类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _do_newest_filtering
def _do_newest_filtering(filelist):
'''
Only return the newest package for each name.arch
'''
newest = {}
for f in filelist:
pkg = Package(f)
key = (pkg.name, pkg.arch)
if key in newest:
# the current package is older
if pkg.verCMP(newest[key]) < 0:
continue
# the current package is the same version
if pkg.verCMP(newest[key]) == 0:
continue
# the current package is newer than what we have stored
del newest[key]
newest[key] = pkg
# get back the file list
filelist_new = []
for pkg in newest.values():
filelist_new.append(pkg.filename)
return filelist_new
示例2: build_tests
def build_tests(self):
package = self.package
package_root = os.getcwd()
self.build_package(package, package_root)
download_dependencies(package.test_dependencies)
dependencies = []
for dependency in package.test_dependencies:
path = path_for_dependency(dependency)
os.chdir(path)
sub_package = Package.open()
os.chdir(os.path.join('..', '..'))
self.build_package(sub_package, path)
dependencies.append(sub_package)
dependencies.append(package)
for dependency in package.dependencies:
path = path_for_dependency(dependency)
os.chdir(path)
sub_package = Package.open()
os.chdir(os.path.join('..', '..'))
dependencies.append(sub_package)
sources = collect_sources(os.path.join(package_root, 'Tests'))
has_main = len([s for s in sources if s.endswith('/main.swift')]) > 0
if has_main:
self.build_cli(package.name + 'Tests', sources, dependencies)
else:
raise Exception('Tests is missing a main.swift')
示例3: item
def item(id, item):
repository = open_repository(id)
pkg = Package(repository.root)
item = pkg.item_by_id(item)
if not item:
abort(404)
return redirect(url_for("view", id=id, relpath=item.relpath))
示例4: from_archive
def from_archive(cls, file, uploader):
"""Load a package version from a .tar.gz archive.
If the package specified in the archive already exists, it will be
loaded and assigned as the package version's package. If it doesn't, a
new package will be created.
Arguments:
file: An open file object containing a .tar.gz archive.
uploader: The user who uploaded this package archive.
Returns: Both the Package object and the PackageVersion object.
"""
try:
tar = tarfile.open(mode="r:gz", fileobj=file)
changelog = Readme.from_archive(tar, name='CHANGELOG')
readme = Readme.from_archive(tar)
pubspec = Pubspec.from_archive(tar)
name = pubspec.required('name')
package = Package.get_by_key_name(name)
if not package:
assert uploader is not None
package = Package.new(name=name, uploaders=[uploader])
libraries = sorted(name[4:] for name in tar.getnames()
if name.startswith('lib/') and
not name.startswith('lib/src/') and
name.endswith('.dart'))
return PackageVersion.new(
package=package, changelog=changelog, readme=readme,
pubspec=pubspec, libraries=libraries, uploader=uploader)
except (tarfile.TarError, KeyError) as err:
raise db.BadValueError(
"Error parsing package archive: %s" % err)
示例5: info_file
def info_file(package_fn):
from package import Package
if not os.path.exists(package_fn):
raise Error (_('File %s not found') % package_fn)
package = Package(package_fn)
package.read()
return package.metadata, package.files
示例6: __init__
def __init__(self, db_dict=None):
self.packages = [] #list of package objects
self.delivered = [] #list of packages that have been delivered
if db_dict:
print("Stuff in database...reading in")
for itm in db_dict:
pkg = Package(itm['tracking_num'], itm['sender'])
pkg.status = itm['status']
pkg.est_delivery = itm['est_delivery']
self.need_to_print = False
self.packages.append(pkg)
示例7: get_newest_build
def get_newest_build(self, branch, pkgname):
""" Returns the newest 'Package' for a given branch and package name """
builds = self.session.getLatestRPMS(branch, package=pkgname, arch='src')
if len(builds[0]) == 0:
return None
latest = builds[0][0]
pkg = Package()
pkg.name = latest['name']
pkg.version = latest['version']
pkg.release = latest['release']
return pkg
示例8: send
def send(self):
package = Package()
package.type = self._type_package
package.user = self._user
package.command = self._command
PACKAGE = package.getPackage()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(PACKAGE)
data = s.recv(BUFFER_SIZE)
s.close()
package = Package()
package.setPackage(data)
if package.type == 0:
pass
if package.type == 1:
message = str(package.data)
#message = message.split('$$NEWLINE$$ $$NEWLINE$$')
#message = '\n'.join(message)
#message = message.replace('$$NEWLINE$$','',1)
print message
if package.type == 2:
print "Status: {}".format(package.data)
if package.type == 3:
print "Data sending"
示例9: view
def view(id, relpath=None):
repository = open_repository(id)
pkg = Package(repository.root)
if "cmd" in request.args:
return repo(id, relpath or "/")
if relpath is None:
return redirect(url_for("view", id=id, relpath=pkg.spine[0].relpath))
doc = pkg.item_by_relpath(relpath)
if not doc:
abort(404)
if doc.is_content:
return render_page(id, pkg, doc)
return doc.fh().read()
示例10: sendFile
def sendFile(self, filename):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
package = Package(3)
package.command.variables = ' '.join([filename, 'wb'])
print "Starting sending file"
with open(filename,'rb') as file:
print 'Sending..'
data = file.read(2048)
package.command.name = 'send_file'
package.data = data.encode()
s.send(package.getPackage())
package.command.variables = '{} {}'.format(filename, 'a')
示例11: upgrade
def upgrade(self, config, force = False, packages = None,
exclude = None, dryrun = False):
if packages:
if isinstance(packages, str):
packages = packages.split(",")
elif not isinstance(packages, list):
packages = self.packages
else:
packages = self.packages
if exclude:
if isinstance(exclude, str):
exclude = exclude.split(",")
elif not isinstance(exclude, list):
exclude = list()
for e in exclude:
try:
packages.remove(e)
except:
pass
for package in packages:
if not config.package_exists(package):
log.error("%s: package upgrade failed: invalid package",
package)
return
cpkg = config.package_get(package)
pkg = Package(package, cpkg, self.path, dryrun)
version = config.versions.get(self.server, package)
version = pkg.upgrade(version, force)
config.versions.set(self.server, package, version)
if not dryrun:
config.versions.save()
return config
示例12: addPackage
def addPackage(self,name,dependencies = []): #may or may not have dependencies
#check if package already there
if name in self.packages: return False
#make sure dependencies already exist
for dependency in dependencies:
if dependency not in self.packages:
return False
#iterate through dependencies and make connection to current package
for dependency in dependencies:
self.packages[dependency].used_by.append(dependency)
#if all is well, add package
newPackage = Package(name)
canAdd = newPackage.addDependencies(dependencies)
if not canAdd:
return False
self.packages[name] = newPackage
return True
示例13: build_package
def build_package(self, package, package_root):
download_dependencies(package.dependencies)
dependencies = []
for dependency in package.dependencies:
path = path_for_dependency(dependency)
os.chdir(path)
sub_package = Package.open()
os.chdir(os.path.join('..', '..'))
self.build_package(sub_package, path)
dependencies.append(sub_package)
sources = collect_sources(os.path.join(package_root, 'Sources'))
has_main = len([s for s in sources if s.endswith('/main.swift')]) > 0
if has_main:
self.build_cli(package.name, sources, dependencies)
else:
self.build_library(package.name, sources, dependencies)
示例14: Run
def Run(self):
"""Run the application ...
We first need to read in all of our package.* files.
Then we simply write them out with the correct method.
We pass a flag to check for installed packages.
"""
files_list = [
"/etc/portage/package.use",
"/etc/portage/package.unmask",
"/etc/portage/package.mask",
"/etc/portage/package.keywords",
"/etc/portage/package.license"
]
for name in files_list:
if not os.access(name, os.F_OK): continue
file = Package(name, self._destructive, self._sort, self._debug)
file.open()
if self._pretend:
output.verbose("%s:", name)
output.verbose(file.__unicode__())
else: file.write(self._reorganize)
file.close()
示例15: open
##########################################
# Argv Parasing #
##########################################
for v in sys.argv:
if v == "-f" or v == "-force":
forceUpdate = True
if v == "-d" or v == "-debug":
debug = True
##########################################
# Main Loop #
##########################################
with open(CONFIG_FILE, "r") as f:
for name in f:
pack = Package() # create new Package Object
pack.name = name.strip()
respString = getHttpResponseString(pack.name)
pack.updateTime = parseDateString(getUpdateTime(respString))
pack.gitPath = AUR_CLONE_URL + pack.name + ".git"
pack.localPath = CLONE_PATH + pack.name + "/PKGBUILD"
if os.path.isfile(pack.localPath):
pack.installTime = os.path.getmtime(pack.localPath)
timeDif = pack.updateTime - pack.installTime
else:
clonePackage(pack)
exit()
if debug == True: