예제 #1
0
def _get_output_stream(destination):
    if destination is None or destination == '-':
        return binary_stream(sys.stdout)
    elif destination.endswith('gz'):
        import gzip
        return gzip.open(destination, 'wb')
    else:
        return open(destination, 'wb')
예제 #2
0
파일: cmds.py 프로젝트: GymWenFLL/tpp_libs
def _get_source_stream(source):
    if source == '-' or source is None:
        import sys
        from fastimport import helpers
        stream = helpers.binary_stream(sys.stdin)
    elif source.endswith('.gz'):
        import gzip
        stream = gzip.open(source, "rb")
    else:
        stream = open(source, "rb")
    return stream