File: test_hdfs.py

package info (click to toggle)
smart-open 7.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 980 kB
  • sloc: python: 8,054; sh: 90; makefile: 14
file content (21 lines) | stat: -rw-r--r-- 615 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# -*- coding: utf-8 -*-
#
# Copyright (C) 2019 Radim Rehurek <me@radimrehurek.com>
#
# This code is distributed under the terms and conditions
# from the MIT License (MIT).
#
"""
Sample code for HDFS integration tests.
Requires hadoop to be running on localhost, at the moment.
"""
import smart_open

with smart_open.smart_open("hdfs://user/root/input/core-site.xml") as fin:
    print(fin.read())

with smart_open.smart_open("hdfs://user/root/input/test.txt") as fin:
    print(fin.read())

with smart_open.smart_open("hdfs://user/root/input/test.txt?user.name=root", 'wb') as fout:
    fout.write(b'hello world')