Did I find the right examples for you? yes no

All Samples(12)  |  Call(8)  |  Derive(0)  |  Import(4)
Unpacks a string on the form:

    "Title":URI:"Description"

Both title and description are optional. Single or double quotes
are allowed.

First, we demonstrate unpacking of URIs.

   >>> unpack(u"http://www.google.com")(more...)

        def unpack(u):
    """
    Unpacks a string on the form:

        "Title":URI:"Description"

    Both title and description are optional. Single or double quotes
    are allowed.

    First, we demonstrate unpacking of URIs.
    
       >>> unpack(u"http://www.google.com")
       (u'http://www.google.com', None, None)

       >>> unpack(u'www.google.com')
       (u'www.google.com', None, None)

       >>> unpack(u'"Google":http://www.google.com')
       (u'http://www.google.com', u'Google', None)
       
       >>> unpack(u'"Google":http://www.google.com:"Google is a search engine"')
       (u'http://www.google.com', u'Google', u'Google is a search engine')

       >>> unpack(u'"Google":http://www.google.com:8080:"Google is a search engine"')
       (u'http://www.google.com:8080', u'Google', u'Google is a search engine')

       >>> unpack(u'"Google":http://www.google.com:8080#bookmark-1:"Google is a search engine"')
       (u'http://www.google.com:8080#bookmark-1', u'Google', u'Google is a search engine')

       >>> unpack(u'"Google":http://www.google.com:8080')
       (u'http://www.google.com:8080', u'Google', None)

    We also support non-URI, i.e. internal links:

       >>> unpack(u'"Fruits and greens":fruits-and-greens')
       (u'fruits-and-greens', u'Fruits and greens', None)

       >>> unpack(u'"Fruits and greens":fruits-and-greens:"Healthy ingredients."')
       (u'fruits-and-greens', u'Fruits and greens', u'Healthy ingredients.')

       >>> unpack(u'"Fruits and greens":/fruits-and-greens')
       (u'/fruits-and-greens', u'Fruits and greens', None)
    """

    match = expression.match(u)

    if match is None:
        raise ValueError("Unable to parse %s" % u)

    uri = match.group('uri')
    title = match.group('title')
    description = match.group('description')
        
    return (uri, title, description)
        


src/d/p/dpark-HEAD/dpark/moosefs/cs.py   dpark(Download)
 
from consts import CHUNKSIZE, CUTOCS_READ, CSTOCU_READ_DATA, CSTOCU_READ_STATUS
from utils import uint64, pack, unpack
 
logger = logging.getLogger(__name__)
 
    while size > 0:
        cmd, l = unpack("II", recv(8))
 
        if cmd == CSTOCU_READ_STATUS:
            if l != 9:
                raise Exception("readblock: READ_STATUS incorrect message size")
            cid, code = unpack("QB", recv(l))
            if l < 20 :
                raise Exception("readblock; READ_DATA incorrect message size")
            cid, bid, boff, bsize, crc = unpack("QHHII", recv(20))
            if cid != chunkid:
                raise Exception("readblock; READ_STATUS incorrect chunkid")

src/c/o/collective.formlib.link-0.2/collective/formlib/link/field.py   collective.formlib.link(Download)
    def fromUnicode(self, u):
        uri, title, description = utils.unpack(u)
 
        m = utils.uri.match(uri)
        if m is not None and m.group('protocol'):