I'm trying to see if a file I input using sys.stdin has a .gz file extension. Usually I just use a file path directly but when I do sys.stdin it automatically opens it into an reading object.
Is there any way to get the file name from stdin without doing os.getcwd() or getting a full file path?
I was trying sys.stdin.endswith('.gz') but it doesn't work (obviously b/c it's not a string) but is there anything I can do with the sys.stdin object to just grab the extension before I proceed to process it?
import sys
file = sys.stdin
if file.endswith('.gz'):
print 'yup'