Skip to content

Commit

Permalink
specify only output extension on the Document tab
Browse files Browse the repository at this point in the history
Remove checks for given files extensions. The program will try the
conversions with any input files. Default document formats updated.
  • Loading branch information
ilstam committed Jun 20, 2016
1 parent c23602f commit 45f7530
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 57 deletions.
19 changes: 5 additions & 14 deletions ffmulticonverter/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,11 @@

#-----document data

document_formats = {
'doc' : ['odt', 'pdf'],
'html' : ['odt'],
'odp' : ['pdf', 'ppt'],
'ods' : ['pdf'],
'odt' : ['doc', 'html', 'pdf', 'rtf', 'sxw', 'txt','xml'],
'ppt' : ['odp'],
'rtf' : ['odt'],
'sdw' : ['odt'],
'sxw' : ['odt'],
'txt' : ['odt'],
'xls' : ['ods'],
'xml' : ['doc', 'odt', 'pdf']
}
document_formats = [
'bib', 'csv', 'dif', 'doc', 'docx', 'html', 'ltx', 'odp', 'ods', 'odt',
'pdf', 'ppt', 'pptx', 'rtf', 'sdc', 'sdw', 'txt', 'xls', 'xlsx', 'xml'
]


#-----misc
translators = [
Expand Down
38 changes: 8 additions & 30 deletions ffmulticonverter/documenttab.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,11 @@ def __init__(self, parent):
self.name = 'Documents'
self.formats = config.document_formats

flist = []
for i in self.formats:
for y in self.formats[i]:
flist.append(i + ' to ' + y)
flist.sort()

convertQL = QLabel(self.tr('Convert:'))
self.convertQCB = QComboBox()
self.convertQCB.addItems(flist)
convertQL = QLabel(self.tr('Convert to:'))
self.extQCB = QComboBox()
self.extQCB.addItems(sorted(self.formats))
final_layout = utils.add_to_layout(
'h', convertQL, self.convertQCB, None)
'h', convertQL, self.extQCB, None)
self.setLayout(final_layout)

def ok_to_continue(self):
Expand All @@ -51,27 +45,11 @@ def ok_to_continue(self):
Checks if:
- unoconv is missing.
- Given file extension is same with the declared extension.
Return True if all tests pass, else False.
"""
decl_ext = self.convertQCB.currentText().split(' ')[0]

try:
if not self.parent.unoconv:
raise ValidationError(
self.tr(
'Unocov is not installed.\nYou will not be able '
'to convert document files until you install it.')
)
for i in self.parent.fnames:
file_ext = os.path.splitext(i)[-1][1:]
if file_ext != decl_ext:
raise ValidationError(
self.trUtf8('{0} is not {1}!'.format(i, decl_ext)))
return True

except ValidationError as e:
QMessageBox.warning(self, 'FF Multi Converter - ' + \
self.tr('Error!'), str(e))
if not self.parent.unoconv:
QMessageBox.warning(self, 'FF Multi Converter - ' + self.tr('Error!'),
self.tr('Unocov is not installed!'))
return False
return True
15 changes: 2 additions & 13 deletions ffmulticonverter/ffmulticonverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,18 +398,6 @@ def ok_to_continue(self):
self, 'FF Multi Converter - ' + self.tr('Error!'), str(e))
return False

def get_output_extension(self):
"""Extract the desired output file extension from GUI and return it."""
tab = self.get_current_tab()
if tab.name == 'AudioVideo':
ext_to = self.audiovideo_tab.extQCB.currentText()
elif tab.name == 'Images':
ext_to = tab.extQCB.currentText()
else:
ext_to = tab.convertQCB.currentText().split()[-1]

return '.' + ext_to

def start_conversion(self):
"""
Extract the appropriate information from GUI and call the
Expand All @@ -419,11 +407,12 @@ def start_conversion(self):
return

tab = self.get_current_tab()
ext_to = '.' + tab.extQCB.currentText()

if tab.name == 'Documents' and not self.office_listener_started:
utils.start_office_listener()
self.office_listener_started = True

ext_to = self.get_output_extension()
_list = utils.create_paths_list(
self.fnames, ext_to, self.prefix, self.suffix,
self.toQLE.text(), self.origQCB.isChecked(),
Expand Down

0 comments on commit 45f7530

Please sign in to comment.