예제 #1
0
파일: combin.py 프로젝트: fredokun/pypretty
def happend(*args):
    '''Doc * Doc * ... -> Doc
    Concatenates argument (horizontaly)
    '''
    if not args:
        return empty()

    doc = args[-1]

    for arg in args[-2::-1]:
        doc = DocCat(arg, doc)

    return doc
예제 #2
0
파일: combin.py 프로젝트: fredokun/pypretty
def happend_with(sep, *args):
    '''Doc * Doc * Doc * ... -> Doc
    Concatenates the argument, each one separated
    by the sep document
    '''
    if not args:
        return empty()
    size = len(args)
    if size == 1:
        return args[0]
    # at least 2 arguments
    nargs = []
    count = 0
    for arg in args:
        nargs.append(arg)
        if count < size - 1:
            nargs.append(sep)
        count = count + 1
    return happend(*nargs)
예제 #3
0
파일: combin.py 프로젝트: fredokun/pypretty
 def f(n):
     if n > nb_spaces:
         return empty()
     else:
         return spaces(nb_spaces - n)