@@ -303,27 +303,25 @@ def new_func(instance, arg):
303303 return option_setup
304304
305305
306- # Can we access the clipboard, always true on Windows and Mac, but only sometimes on Linux
307- can_clip = True
308- if sys . platform . startswith ( 'linux' ):
309- try :
310- pyperclip . paste ()
311- except pyperclip . exceptions . PyperclipException :
312- can_clip = False
306+ # Can we access the clipboard? Should always be true on Windows and Mac, but only sometimes on Linux
307+ try :
308+ pyperclip . paste ()
309+ except pyperclip . exceptions . PyperclipException :
310+ can_clip = False
311+ else :
312+ can_clip = True
313313
314314
315315def get_paste_buffer ():
316316 """Get the contents of the clipboard / paste buffer.
317317
318318 :return: str - contents of the clipboard
319319 """
320- pb_unicode = pyperclip .paste ()
320+ pb_str = pyperclip .paste ()
321321
322- if six .PY3 :
323- pb_str = pb_unicode
324- else :
322+ if six .PY2 :
325323 import unicodedata
326- pb_str = unicodedata .normalize ('NFKD' , pb_unicode ).encode ('ascii' , 'ignore' )
324+ pb_str = unicodedata .normalize ('NFKD' , pb_str ).encode ('ascii' , 'ignore' )
327325
328326 return pb_str
329327
@@ -368,16 +366,15 @@ def replace_with_file_contents(fname):
368366 """Action to perform when successfully matching parse element definition for inputFrom parser.
369367
370368 :param fname: str - filename
371- :return: str - contents of file "fname" or contents of the clipboard if fname is None or an empty string
369+ :return: str - contents of file "fname"
372370 """
373- if fname :
374- try :
375- with open (os .path .expanduser (fname [0 ])) as source_file :
376- result = source_file .read ()
377- except IOError :
378- result = '< %s' % fname [0 ] # wasn't a file after all
379- else :
380- result = get_paste_buffer ()
371+ try :
372+ with open (os .path .expanduser (fname [0 ])) as source_file :
373+ result = source_file .read ()
374+ except IOError :
375+ result = '< %s' % fname [0 ] # wasn't a file after all
376+
377+ # TODO: IF pyparsing input parser logic gets fixed to support empty file, add support to get from paste buffer
381378 return result
382379
383380
0 commit comments