Esempio n. 1
0
def Header(*args, **kwargs):
    # XXX REDO THIS!!
    # NOTE: this has to extract an hname, if the hname is known, then call
    #   the real class, let it do the parsing
    #   if the hname is unknown, set it, and build a generic object
    #
    #   in all cases, pass hname as a seperate value
    if args:
        if len(args) == 1:  # args is a buf
            vals = args[0].split(':', 1)
            if len(vals) > 1:
                hname, buf = vals
            else:
                hname, buf = vals[0], ''
        else:
            hname = args[0]
            buf = args[1]

        hdr = _FactoryDict.get(headernames.normalise(hname), GenericHeader)
    else:
        buf = ''
        hdr = GenericHeader

    # requires updating above code, and headerbase.__init__()
    #return hdr(hname=hname, buf=buf, params=kwargs)
    return hdr(buf, params=kwargs)
Esempio n. 2
0
def Header(*args, **kwargs):
    # XXX REDO THIS!!
    # NOTE: this has to extract an hname, if the hname is known, then call
    #   the real class, let it do the parsing
    #   if the hname is unknown, set it, and build a generic object
    #   
    #   in all cases, pass hname as a seperate value
    if args:
        if len(args) == 1: # args is a buf
            vals = args[0].split(':', 1)
            if len(vals) > 1:
                hname, buf = vals
            else:
                hname, buf = vals[0], ''
        else:
            hname = args[0]
            buf = args[1]

        hdr = _FactoryDict.get( headernames.normalise( hname ), GenericHeader )
    else:
        buf = ''
        hdr = GenericHeader

    # requires updating above code, and headerbase.__init__()
    #return hdr(hname=hname, buf=buf, params=kwargs)
    return hdr(buf, params=kwargs)
Esempio n. 3
0
 def _get_key(self, key):
     if not isinstance(key, headerbases.HeaderBase):
         key = headernames.normalise(key)
     else:
         key = key.name
     return key
Esempio n. 4
0
 def _get_key(self, key):
     if not isinstance(key, headerbases.HeaderBase):
         key = headernames.normalise(key)
     else:
         key = key.name
     return key