Ejemplo n.º 1
0
def mkFieldMap(fields, args=[], kwargs={}, default=None):
    base = dict(zip(fields, repeat(default)))
    if isinstance(args, Mapping):
        args = [args]
    if args:
        if len(args) == 1:
            first = args[0]
            if isinstance(first, Mapping):
                return merge(base, kwargs, first)
            elif isinstance(first, basestring):
                args = first.strip().split()
            else:
                args = first
        base.update(zip(fields, args)[:len(args)])
    return merge(base, kwargs)
Ejemplo n.º 2
0
def mkFieldMap(fields, args=[], kwargs={}, default=None):
    base = dict(zip(fields, repeat(default)))
    if isinstance(args, Mapping):
        args = [args]
    if args:
        if len(args) == 1:
            first = args[0]
            if isinstance(first, Mapping):
                return merge(base, kwargs, first)
            elif isinstance(first, basestring):
                args = first.strip().split()
            else:
                args = first
        base.update( zip(fields, args)[:len(args)] )
    return merge(base, kwargs)
Ejemplo n.º 3
0
 def format(self, args=[], kwargs={}, maxlens=0, default=None):
     maxlens = self.mkMaxLens(maxlens)
     values = self.mkFieldMap(args, kwargs, default)
     return self.fmt.format(**merge(maxlens, values))
Ejemplo n.º 4
0
 def format(self, args=[], kwargs={}, maxlens=0, default=None):
     maxlens = self.mkMaxLens(maxlens)
     values  = self.mkFieldMap(args, kwargs, default)
     return self.fmt.format(**merge(maxlens, values))