Example #1
0
def unpart_metadata(spacer, schema, info, storage_info):
    return pd.DataFrame.from_records(
        list(
            toolz.concat(
                toolz.interpose([spacer], [schema, info, storage_info]))),
        columns=['name', 'type', 'comment'],
    )
Example #2
0
def capture_vl42(device='/dev/video0',
                 resolution='4k',
                 outname=None,
                 duration=None):
    if outname is None:
        _, device_name = device.rsplit('/', 1)
        outname = 'gstreamer-{}.mp4'.format(device_name)
    if duration is not None:
        print('WARNING: duration not implemented!')
    gst_pieces = list(
        interpose(
            '!',
            [
                'v4l2src device={}'.format(device),
                'image/jpeg,width=3840,height=2160,framerate=30/1',
                'queue',
                # 'vaapijpegdec',
                'jpegdec',
                'videoconvert',
                'queue',
                # 'vaapih264enc dct8x8=true',
                'avenc_h264_omx',
                'h264parse',
                'queue',
                'qtmux',
                'progressreport',
                'filesink location={}'.format(outname)
            ]))

    # I'd like to just pass a list to run, but I'm getting an error for some
    # reason
    gst_command = ' '.join(['gst-launch-1.0', '-e'] + gst_pieces)
    print(gst_command)
    run(gst_command, shell=True)
Example #3
0
def format_sudoku(sudoku):
    def format_row(row):
        return '| ' + ' | '.join(map(lambda s: str(s)
                                     if s else ' ', row)) + ' |'

    row_delim = '+---+---+---+---+---+---+---+---+---+'
    formatted_rows = map(format_row, sudoku)
    print_lines = (row_delim, *interpose(row_delim, formatted_rows), row_delim)
    return '\n'.join(print_lines)
def visit_infix_expression(node, operators={}):
    def interleave(*iterables):
        for values in itertools.zip_longest(*iterables, fillvalue=UnboundLocalError):
            for index, value in enumerate(values):
                if value != UnboundLocalError:
                    yield index, value

    tokens = [
        visit_node(operand_or_operator)
        if index == 0
        else operators.get(operand_or_operator, operand_or_operator)
        for index, operand_or_operator in interleave(node['operands'], node['operators'])
        ]
    # Transform product expressions into a lazy "and" expression in order to prevent a division by 0:
    if node['type'] == 'product_expression':
        tokens = concatv(
            interpose(
                el='and',
                seq=map(visit_node, node['operands']),
                ),
            ['and'],
            tokens,
            )
    return '({})'.format(' '.join(map(str, tokens)))
Example #5
0
def _string_join(t, expr):
    sep, elements = expr.op().args
    return functools.reduce(
        operator.add,
        toolz.interpose(t.translate(sep), map(t.translate, elements)),
    )
Example #6
0
def in_order(tree):
  if not isinstance(tree, list):
    return tree
  return list(flatten(list(t.interpose(tree[0], map(in_order, tree[1:])))))
Example #7
0
 def interpose_inner(seq):
     return toolz.interpose(el, seq)