Esempio n. 1
0
def main():
    args = parser.parse_args()
    msgs = io.messages(sys.stdin)
    if not args.no_stamp:
        msgs = stamp(msgs)
    if args.tags:
        msgs = tag(msgs, args.tags)
    for msg in msgs:
        print(json.dumps(msg))
Esempio n. 2
0
def test_tag_copies():
    data = [{"@message": "one"}]

    tags = ["foobar", "baz"]
    out = tag(data, tags)

    res = next(out)

    tags.append("bat")
    assert_equal(res, {"@message": "one", "@tags": ["foobar", "baz"]})
Esempio n. 3
0
def main():
    args = parser.parse_args()
    shpr = shipper.get_shipper(args.shipper)(args)

    msgs = io.messages(sys.stdin)
    if not args.no_stamp:
        msgs = stamp(msgs)
    if args.tags:
        msgs = tag(msgs, args.tags)
    for msg in msgs:
        payload = json.dumps(msg)
        if args.bulk:
            command = json.dumps({"index": {"_index": args.bulk_index, "_type": args.bulk_type}})
            payload = "{0}\n{1}\n".format(command, payload)
        shpr.ship(payload)
Esempio n. 4
0
def main():
    args = parser.parse_args()
    shpr = shipper.get_shipper(args.shipper)(args)

    msgs = io.messages(sys.stdin)
    if not args.no_stamp:
        msgs = stamp(msgs)
    if args.tags:
        msgs = tag(msgs, args.tags)
    if args.fields:
        msgs = fields(msgs, args.fields)
    for msg in msgs:
        payload = json.dumps(msg)
        if args.bulk:
            command = json.dumps({'index': {'_index': args.bulk_index, '_type': args.bulk_type}})
            payload = '{0}\n{1}\n'.format(command, payload)
        shpr.ship(payload)
Esempio n. 5
0
def test_tag_replaces_nonextendable_value():
    data = [{"@message": "one", "@tags": "a string"}]
    out = tag(data, ["foobar", "baz"])

    assert_equal(next(out), {"@message": "one", "@tags": ["foobar", "baz"]})
Esempio n. 6
0
def test_tag_no_tags():
    data = [{"@message": "one"}, {"@message": "two"}]
    out = tag(data, ["foobar", "baz"])

    assert_equal(next(out), {"@message": "one", "@tags": ["foobar", "baz"]})
    assert_equal(next(out), {"@message": "two", "@tags": ["foobar", "baz"]})
Esempio n. 7
0
def test_dont_tag():
    data = [{"@message": "one"}, {"@message": "two"}]
    out = tag(data)

    assert_equal(next(out), {"@message": "one"})
    assert_equal(next(out), {"@message": "two"})
Esempio n. 8
0
def test_tag_append_tags():
    data = [{"@message": "one", "@tags": ["wibble"]}, {"@message": "two", "@tags": []}]
    out = tag(data, ["foobar", "baz"])

    assert_equal(next(out), {"@message": "one", "@tags": ["wibble", "foobar", "baz"]})
    assert_equal(next(out), {"@message": "two", "@tags": ["foobar", "baz"]})
Esempio n. 9
0
def test_tag_custom_key():
    data = [{"msg": "one"}, {"msg": "two"}]
    out = tag(data, ["foobar", "baz"], key="tags")

    assert_equal(next(out), {"msg": "one", "tags": ["foobar", "baz"]})
    assert_equal(next(out), {"msg": "two", "tags": ["foobar", "baz"]})