File: pipes.py

package info (click to toggle)
python-clint 0.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 328 kB
  • sloc: python: 1,815; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 509 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# -*- coding: utf-8 -*-

"""
clint.pipes
~~~~~~~~~~~

This module contains the helper functions for dealing with unix pipes.

"""

from __future__ import absolute_import
from __future__ import with_statement

import sys


__all__ = ('piped_in', )



def piped_in():
    """Returns piped input via stdin, else None."""
    with sys.stdin as stdin:
        # TTY is only way to detect if stdin contains data
        if not stdin.isatty():
            return stdin.read()  
        else:
            return None