export_clipboard_to_file

This commit is contained in:
chrys
2017-06-03 23:24:37 +02:00
parent 64e96f3a54
commit 7dee80f20f
7 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,46 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
class command():
def __init__(self):
pass
def initialize(self, environment, scriptPath=''):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return _('export the current fenrir clipboard to a file')
def run(self):
clipboardFilePath = self.env['runtime']['settingsManager'].getSetting('general', 'clipboardExportPath')
clipboardFilePath = clipboardFilePath.replace('$user',self.env['general']['currUser'])
clipboardFilePath = clipboardFilePath.replace('$USER',self.env['general']['currUser'])
clipboardFilePath = clipboardFilePath.replace('$User',self.env['general']['currUser'])
clipboardFile = open(clipboardFilePath,'w')
try:
currClipboard = self.env['commandBuffer']['currClipboard']
if currClipboard < 0:
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
if not self.env['commandBuffer']['clipboard']:
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
if not self.env['commandBuffer']['clipboard'][currClipboard]:
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
if self.env['commandBuffer']['clipboard'][currClipboard] == '':
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
clipboardFile.write(self.env['commandBuffer']['clipboard'][currClipboard])
clipboardFile.close()
self.env['runtime']['outputManager'].presentText(_('clipboard exported to file'), interrupt=True)
except Exception as e:
self.env['runtime']['debug'].writeDebugOut('export_clipboard_to_file:run: Filepath:'+ clipboardFile +' trace:' + str(e),debug.debugLevel.ERROR)
def setCallback(self, callback):
pass