This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Loads resources and symbols from a python package, whether installed as a directory, an egg, or in source form. Also provides some other package-related helper methods, including asset.version() and asset.caller().

TL;DR

Install:

$ pip install asset

Load symbols (e.g. functions, classes, or variables) from a package by name:

import asset

# load the 'mypackage.foo.myfunc' function and call it with some parameter
retval = asset.symbol('mypackage.foo.myfunc')(param='value')

Load data files from a package:

# load the file 'mypackage/templates/data.txt' into string
data = asset.load('mypackage:templates/data.txt').read()

# or as a file-like stream
stream = asset.load('mypackage:templates/data.txt').stream()
data   = stream.read()

Multiple files can be operated on at once by using globre style wildcards:

# concatenate all 'css' files into one string:
css = asset.load('mypackage:static/style/**.css').read()

# load all '.txt' files, XML-escaping the data and wrapping
# each file in an <node name="...">...</node> element.
import xml.etree.ElementTree as ET
data = ET.Element('nodes')
for item in asset.load('asset:**.txt'):
  cur = ET.SubElement(data, 'node', name=item.name)
  cur.text = item.read()
data = ET.tostring(data)

Query the installed version of a package:

asset.version('asset')
# ==> '0.0.5'

asset.version('python')
# ==> '2.7'

asset.version('no-such-package')
# ==> None

Find out what package is calling the current function:

# assuming the call stack is:
#   in package "zig" a function "x", which calls
#   in package "bar" a function "y", which calls
#   in package "foo" a function "callfoo" defined as:

def callfoo():

  asset.caller()
  # ==> 'bar'

  asset.caller(ignore='bar')
  # ==> 'zig'

  asset.caller(ignore=['bar', 'zig'])
  # ==> None

Call all the plugins for a given group:

for plugin in asset.plugins('mypackage.plugins'):
  plugin.handle()

Filter an object through all the plugins for a given group (if there are no plugins, this will simply return thing):

result = asset.plugins('mypackage.plugins').filter(thing)

Load all registered plugins, select the ones named foo and invoke them (this will fail if there is no foo plugin):

result = asset.plugins('mypackage.plugins').select('foo').handle(thing)

Testing

In order to run the unit tests correctly, the pxml package needs to be installed as a zipped package (i.e. an “egg”) and the globre package needs to be installed unzipped. To accomplish that, do:

$ easy_install --zip-ok pxml
$ easy_install --always-unzip globre

The reason is that the unit tests confirm that asset can load assets from both zipped and unzipped packages, and can also identify in which mode it is operating.

Details

TODO: add detailed docs…

  • Asset.filename:

    If the asset represents a file on the filesystem, is the absolute path to the specified file. Otherwise is None.

  • AssetGroupStream.readline():

    Returns the next line from the aggregate asset group stream, as if the assets had been concatenate into a single asset.

    IMPORTANT: if an asset ends with content that is not terminated by an EOL token, it is returned as-is, i.e. it does NOT append the first line from the next asset.

Note: because asset.load() does lazy-loading, it only throws a NoSuchAsset exception when you actually attempt to use the AssetGroup! If you need an immediate error, use the peek() method. Note that it returns itself, so you can do something like:

import asset

def my_function_that_returns_an_iterable():

  return asset.load(my_spec).peek()

  # this returns exactly the same thing as the following:
  #
  #   return asset.load(my_spec)
  #
  # but throws an exception early if there are no matching assets.
Release History

Release History

0.6.11

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6.10

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6.9

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6.8

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6.7

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6.6

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.5b3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.5b

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
asset-0.6.11.tar.gz (28.1 kB) Copy SHA256 Checksum SHA256 Source Aug 18, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting