forked from openlp/openlp
Merged in from remote branch.
This commit is contained in:
commit
bfda149552
@ -50,16 +50,24 @@ media_manager_style = """
|
|||||||
QToolBox::tab:selected {
|
QToolBox::tab:selected {
|
||||||
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||||
stop: 0 palette(light), stop: 1.0 palette(button));
|
stop: 0 palette(light), stop: 1.0 palette(button));
|
||||||
border-color: palette(dark);
|
border-color: palette(button);
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
class versionThread(QtCore.QThread):
|
class VersionThread(QtCore.QThread):
|
||||||
|
"""
|
||||||
|
A special Qt thread class to fetch the version of OpenLP from the website.
|
||||||
|
This is threaded so that it doesn't affect the loading time of OpenLP.
|
||||||
|
"""
|
||||||
def __init__(self, parent, app_version, generalConfig):
|
def __init__(self, parent, app_version, generalConfig):
|
||||||
QtCore.QThread.__init__(self, parent)
|
QtCore.QThread.__init__(self, parent)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.app_version = app_version
|
self.app_version = app_version
|
||||||
self.generalConfig = generalConfig
|
self.generalConfig = generalConfig
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
"""
|
||||||
|
Run the thread.
|
||||||
|
"""
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
version = check_latest_version(self.generalConfig, self.app_version)
|
version = check_latest_version(self.generalConfig, self.app_version)
|
||||||
#new version has arrived
|
#new version has arrived
|
||||||
@ -586,7 +594,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
def versionThread(self):
|
def versionThread(self):
|
||||||
app_version = self.applicationVersion[u'full']
|
app_version = self.applicationVersion[u'full']
|
||||||
vT = versionThread(self, app_version, self.generalConfig)
|
vT = VersionThread(self, app_version, self.generalConfig)
|
||||||
vT.start()
|
vT.start()
|
||||||
|
|
||||||
def onHelpAboutItemClicked(self):
|
def onHelpAboutItemClicked(self):
|
||||||
|
@ -42,7 +42,6 @@ class ServiceManagerList(QtGui.QTreeWidget):
|
|||||||
def __init__(self, parent=None, name=None):
|
def __init__(self, parent=None, name=None):
|
||||||
QtGui.QTreeWidget.__init__(self,parent)
|
QtGui.QTreeWidget.__init__(self,parent)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.setExpandsOnDoubleClick(False)
|
|
||||||
|
|
||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
if type(event) == QtGui.QKeyEvent:
|
if type(event) == QtGui.QKeyEvent:
|
||||||
@ -250,6 +249,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
if self.serviceItemNoteForm.exec_():
|
if self.serviceItemNoteForm.exec_():
|
||||||
self.serviceItems[item][u'service_item'].notes = \
|
self.serviceItems[item][u'service_item'].notes = \
|
||||||
self.serviceItemNoteForm.textEdit.toPlainText()
|
self.serviceItemNoteForm.textEdit.toPlainText()
|
||||||
|
self.repaintServiceList(item, 0)
|
||||||
|
|
||||||
def nextItem(self):
|
def nextItem(self):
|
||||||
"""
|
"""
|
||||||
@ -429,8 +429,22 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
for itemcount, item in enumerate(self.serviceItems):
|
for itemcount, item in enumerate(self.serviceItems):
|
||||||
serviceitem = item[u'service_item']
|
serviceitem = item[u'service_item']
|
||||||
treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList)
|
treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList)
|
||||||
treewidgetitem.setText(0,serviceitem.title)
|
if len(serviceitem.notes) > 0:
|
||||||
|
icon = QtGui.QImage(serviceitem.icon)
|
||||||
|
icon = icon.scaled(80, 80, QtCore.Qt.KeepAspectRatio,
|
||||||
|
QtCore.Qt.SmoothTransformation)
|
||||||
|
|
||||||
|
overlay = QtGui.QImage(':/services/service_item_notes.png')
|
||||||
|
overlay = overlay.scaled(80, 80, QtCore.Qt.KeepAspectRatio,
|
||||||
|
QtCore.Qt.SmoothTransformation)
|
||||||
|
painter = QtGui.QPainter(icon)
|
||||||
|
painter.drawImage(0, 0, overlay)
|
||||||
|
painter.end()
|
||||||
|
treewidgetitem.setIcon(0, build_icon(icon))
|
||||||
|
else:
|
||||||
treewidgetitem.setIcon(0, serviceitem.iconic_representation)
|
treewidgetitem.setIcon(0, serviceitem.iconic_representation)
|
||||||
|
treewidgetitem.setText(0, serviceitem.title)
|
||||||
|
treewidgetitem.setToolTip(0, serviceitem.notes)
|
||||||
treewidgetitem.setData(0, QtCore.Qt.UserRole,
|
treewidgetitem.setData(0, QtCore.Qt.UserRole,
|
||||||
QtCore.QVariant(item[u'order']))
|
QtCore.QVariant(item[u'order']))
|
||||||
treewidgetitem.setExpanded(item[u'expanded'])
|
treewidgetitem.setExpanded(item[u'expanded'])
|
||||||
@ -594,12 +608,12 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.serviceItems = []
|
self.serviceItems = []
|
||||||
self.isNew = True
|
self.isNew = True
|
||||||
for item in tempServiceItems:
|
for item in tempServiceItems:
|
||||||
self.addServiceItem(item[u'service_item'], True)
|
self.addServiceItem(item[u'service_item'], False, item[u'expanded'])
|
||||||
#Set to False as items may have changed rendering
|
#Set to False as items may have changed rendering
|
||||||
#does not impact the saved song so True may aslo be valid
|
#does not impact the saved song so True may aslo be valid
|
||||||
self.parent.serviceChanged(False, self.serviceName)
|
self.parent.serviceChanged(False, self.serviceName)
|
||||||
|
|
||||||
def addServiceItem(self, item, rebuild=False):
|
def addServiceItem(self, item, rebuild=False, expand=True):
|
||||||
"""
|
"""
|
||||||
Add a Service item to the list
|
Add a Service item to the list
|
||||||
|
|
||||||
@ -619,12 +633,12 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
if sitem == -1:
|
if sitem == -1:
|
||||||
self.serviceItems.append({u'service_item': item,
|
self.serviceItems.append({u'service_item': item,
|
||||||
u'order': len(self.serviceItems) + 1,
|
u'order': len(self.serviceItems) + 1,
|
||||||
u'expanded':True})
|
u'expanded':expand})
|
||||||
self.repaintServiceList(len(self.serviceItems) + 1, 0)
|
self.repaintServiceList(len(self.serviceItems) + 1, 0)
|
||||||
else:
|
else:
|
||||||
self.serviceItems.insert(sitem + 1, {u'service_item': item,
|
self.serviceItems.insert(sitem + 1, {u'service_item': item,
|
||||||
u'order': len(self.serviceItems)+1,
|
u'order': len(self.serviceItems)+1,
|
||||||
u'expanded':True})
|
u'expanded':expand})
|
||||||
self.repaintServiceList(sitem + 1, 0)
|
self.repaintServiceList(sitem + 1, 0)
|
||||||
#if rebuilding list make sure live is fixed.
|
#if rebuilding list make sure live is fixed.
|
||||||
if rebuild:
|
if rebuild:
|
||||||
|
@ -81,13 +81,12 @@ class AppLocation(object):
|
|||||||
def check_latest_version(config, current_version):
|
def check_latest_version(config, current_version):
|
||||||
version_string = current_version
|
version_string = current_version
|
||||||
#set to prod in the distribution confif file.
|
#set to prod in the distribution confif file.
|
||||||
environment = config.get_config(u'run environment', u'dev')
|
|
||||||
last_test = config.get_config(u'last version test', datetime.now().date())
|
last_test = config.get_config(u'last version test', datetime.now().date())
|
||||||
this_test = unicode(datetime.now().date())
|
this_test = unicode(datetime.now().date())
|
||||||
config.set_config(u'last version test', this_test)
|
config.set_config(u'last version test', this_test)
|
||||||
if last_test != this_test:
|
if last_test != this_test:
|
||||||
version_string = u''
|
version_string = u''
|
||||||
req = urllib2.Request(u'http://www.openlp.org/files/%s_version.txt' % environment)
|
req = urllib2.Request(u'http://www.openlp.org/files/version.txt')
|
||||||
req.add_header(u'User-Agent', u'OpenLP/%s' % current_version)
|
req.add_header(u'User-Agent', u'OpenLP/%s' % current_version)
|
||||||
try:
|
try:
|
||||||
handle = urllib2.urlopen(req, None)
|
handle = urllib2.urlopen(req, None)
|
||||||
|
@ -76,7 +76,7 @@ class AlertsManager(QtCore.QObject):
|
|||||||
display text
|
display text
|
||||||
"""
|
"""
|
||||||
log.debug(u'display alert called %s' % text)
|
log.debug(u'display alert called %s' % text)
|
||||||
self.parent.maindisplay.parent.StatusBar.showMessage(self.trUtf8(u''))
|
self.parent.maindisplay.parent.StatusBar.showMessage(u'')
|
||||||
self.alertList.append(text)
|
self.alertList.append(text)
|
||||||
if self.timer_id != 0 or self.parent.maindisplay.mediaLoaded:
|
if self.timer_id != 0 or self.parent.maindisplay.mediaLoaded:
|
||||||
self.parent.maindisplay.parent.StatusBar.showMessage(\
|
self.parent.maindisplay.parent.StatusBar.showMessage(\
|
||||||
|
@ -61,7 +61,7 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
self.OnNewPrompt = self.trUtf8('Select Image(s)')
|
self.OnNewPrompt = self.trUtf8('Select Image(s)')
|
||||||
self.OnNewFileMasks = \
|
self.OnNewFileMasks = \
|
||||||
self.trUtf8('Images (*.jpg *jpeg *.gif *.png *.bmp)')
|
self.trUtf8('Images (*.jpg *jpeg *.gif *.png *.bmp);; All files (*)')
|
||||||
|
|
||||||
def requiredIcons(self):
|
def requiredIcons(self):
|
||||||
MediaManagerItem.requiredIcons(self)
|
MediaManagerItem.requiredIcons(self)
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
# OOo API documentation:
|
# OOo API documentation:
|
||||||
# http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/XSlideShowController.html
|
# http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/XSlideShowController.html
|
||||||
|
# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Basic/Getting_Information_about_UNO_Objects#Inspecting_interfaces_during_debugging
|
||||||
# http://docs.go-oo.org/sd/html/classsd_1_1SlideShow.html
|
# http://docs.go-oo.org/sd/html/classsd_1_1SlideShow.html
|
||||||
# http://www.oooforum.org/forum/viewtopic.phtml?t=5252
|
# http://www.oooforum.org/forum/viewtopic.phtml?t=5252
|
||||||
# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Working_with_Presentations
|
# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Working_with_Presentations
|
||||||
@ -62,7 +63,8 @@ class ImpressController(PresentationController):
|
|||||||
"""
|
"""
|
||||||
log.debug(u'Initialising')
|
log.debug(u'Initialising')
|
||||||
PresentationController.__init__(self, plugin, u'Impress')
|
PresentationController.__init__(self, plugin, u'Impress')
|
||||||
self.supports = [u'.odp', u'.ppt', u'.pps', u'.pptx', u'.ppsx']
|
self.supports = [u'.odp']
|
||||||
|
self.alsosupports = [u'.ppt', u'.pps', u'.pptx', u'.ppsx']
|
||||||
self.process = None
|
self.process = None
|
||||||
self.desktop = None
|
self.desktop = None
|
||||||
|
|
||||||
@ -145,10 +147,17 @@ class ImpressController(PresentationController):
|
|||||||
doc.close_presentation()
|
doc.close_presentation()
|
||||||
if os.name != u'nt':
|
if os.name != u'nt':
|
||||||
desktop = self.get_uno_desktop()
|
desktop = self.get_uno_desktop()
|
||||||
|
else:
|
||||||
|
desktop = self.get_com_desktop()
|
||||||
|
docs = desktop.getComponents()
|
||||||
|
if docs.hasElements():
|
||||||
|
log.debug(u'OpenOffice not terminated')
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
desktop.terminate()
|
desktop.terminate()
|
||||||
|
log.debug(u'OpenOffice killed')
|
||||||
except:
|
except:
|
||||||
pass
|
log.exception(u'Failed to terminate OpenOffice')
|
||||||
|
|
||||||
def add_doc(self, name):
|
def add_doc(self, name):
|
||||||
log.debug(u'Add Doc OpenOffice')
|
log.debug(u'Add Doc OpenOffice')
|
||||||
|
@ -56,7 +56,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
# be instanced by the base MediaManagerItem
|
# be instanced by the base MediaManagerItem
|
||||||
self.ListViewWithDnD_class = PresentationListView
|
self.ListViewWithDnD_class = PresentationListView
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
self.message_listener = MessageListener(controllers)
|
self.message_listener = MessageListener(self)
|
||||||
|
|
||||||
def initPluginNameVisible(self):
|
def initPluginNameVisible(self):
|
||||||
self.PluginNameVisible = self.trUtf8('Presentation')
|
self.PluginNameVisible = self.trUtf8('Presentation')
|
||||||
@ -66,7 +66,8 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
fileType = u''
|
fileType = u''
|
||||||
for controller in self.controllers:
|
for controller in self.controllers:
|
||||||
if self.controllers[controller].enabled:
|
if self.controllers[controller].enabled:
|
||||||
for type in self.controllers[controller].supports:
|
types = self.controllers[controller].supports + self.controllers[controller].alsosupports
|
||||||
|
for type in types:
|
||||||
if fileType.find(type) == -1:
|
if fileType.find(type) == -1:
|
||||||
fileType += u'*%s ' % type
|
fileType += u'*%s ' % type
|
||||||
self.OnNewFileMasks = self.trUtf8('Presentations (%s)' % fileType)
|
self.OnNewFileMasks = self.trUtf8('Presentations (%s)' % fileType)
|
||||||
@ -106,6 +107,9 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
#load the drop down selection
|
#load the drop down selection
|
||||||
if self.controllers[item].enabled:
|
if self.controllers[item].enabled:
|
||||||
self.DisplayTypeComboBox.addItem(item)
|
self.DisplayTypeComboBox.addItem(item)
|
||||||
|
if self.DisplayTypeComboBox.count() > 1:
|
||||||
|
self.DisplayTypeComboBox.insertItem(0, u'Automatic')
|
||||||
|
self.DisplayTypeComboBox.setCurrentIndex(0)
|
||||||
|
|
||||||
def loadList(self, list):
|
def loadList(self, list):
|
||||||
currlist = self.getFileList()
|
currlist = self.getFileList()
|
||||||
@ -145,10 +149,16 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
return False
|
return False
|
||||||
service_item.title = unicode(self.DisplayTypeComboBox.currentText())
|
service_item.title = unicode(self.DisplayTypeComboBox.currentText())
|
||||||
service_item.shortname = unicode(self.DisplayTypeComboBox.currentText())
|
service_item.shortname = unicode(self.DisplayTypeComboBox.currentText())
|
||||||
controller = self.controllers[service_item.shortname]
|
shortname = service_item.shortname
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
bitem = self.ListView.item(item.row())
|
bitem = self.ListView.item(item.row())
|
||||||
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
|
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
|
||||||
|
if shortname==u'Automatic':
|
||||||
|
service_item.shortname = self.findControllerByType(filename)
|
||||||
|
if not service_item.shortname:
|
||||||
|
return False
|
||||||
|
controller = self.controllers[service_item.shortname]
|
||||||
(path, name) = os.path.split(filename)
|
(path, name) = os.path.split(filename)
|
||||||
doc = controller.add_doc(filename)
|
doc = controller.add_doc(filename)
|
||||||
if doc.get_slide_preview_file(1) is None:
|
if doc.get_slide_preview_file(1) is None:
|
||||||
@ -161,3 +171,17 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
img = doc.get_slide_preview_file(i)
|
img = doc.get_slide_preview_file(i)
|
||||||
controller.remove_doc(doc)
|
controller.remove_doc(doc)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def findControllerByType(self, filename):
|
||||||
|
filetype = os.path.splitext(filename)[1]
|
||||||
|
if not filetype:
|
||||||
|
return None
|
||||||
|
for controller in self.controllers:
|
||||||
|
if self.controllers[controller].enabled:
|
||||||
|
if filetype in self.controllers[controller].supports:
|
||||||
|
return controller
|
||||||
|
for controller in self.controllers:
|
||||||
|
if self.controllers[controller].enabled:
|
||||||
|
if filetype in self.controllers[controller].alsosupports:
|
||||||
|
return controller
|
||||||
|
return None
|
||||||
|
@ -154,8 +154,9 @@ class MessageListener(object):
|
|||||||
"""
|
"""
|
||||||
log.info(u'Message Listener loaded')
|
log.info(u'Message Listener loaded')
|
||||||
|
|
||||||
def __init__(self, controllers):
|
def __init__(self, mediaitem):
|
||||||
self.controllers = controllers
|
self.controllers = mediaitem.controllers
|
||||||
|
self.mediaitem = mediaitem
|
||||||
self.previewHandler = Controller(False)
|
self.previewHandler = Controller(False)
|
||||||
self.liveHandler = Controller(True)
|
self.liveHandler = Controller(True)
|
||||||
# messages are sent from core.ui.slidecontroller
|
# messages are sent from core.ui.slidecontroller
|
||||||
@ -188,6 +189,12 @@ class MessageListener(object):
|
|||||||
"""
|
"""
|
||||||
log.debug(u'Startup called with message %s' % message)
|
log.debug(u'Startup called with message %s' % message)
|
||||||
self.handler, file, isLive = self.decodeMessage(message)
|
self.handler, file, isLive = self.decodeMessage(message)
|
||||||
|
filetype = os.path.splitext(file)[1][1:]
|
||||||
|
if self.handler==u'Automatic':
|
||||||
|
self.handler = self.mediaitem.findControllerByType(file)
|
||||||
|
if not self.handler:
|
||||||
|
return
|
||||||
|
|
||||||
if isLive:
|
if isLive:
|
||||||
self.liveHandler.addHandler(self.controllers[self.handler], file)
|
self.liveHandler.addHandler(self.controllers[self.handler], file)
|
||||||
else:
|
else:
|
||||||
|
@ -52,7 +52,7 @@ class PowerpointController(PresentationController):
|
|||||||
"""
|
"""
|
||||||
log.debug(u'Initialising')
|
log.debug(u'Initialising')
|
||||||
PresentationController.__init__(self, plugin, u'Powerpoint')
|
PresentationController.__init__(self, plugin, u'Powerpoint')
|
||||||
self.supports = [u'.ppt', u'.pps']
|
self.supports = [u'.ppt', u'.pps', u'.pptx', u'.ppsx']
|
||||||
self.process = None
|
self.process = None
|
||||||
|
|
||||||
def check_available(self):
|
def check_available(self):
|
||||||
@ -100,6 +100,8 @@ class PowerpointController(PresentationController):
|
|||||||
doc.close_presentation()
|
doc.close_presentation()
|
||||||
if self.process is None:
|
if self.process is None:
|
||||||
return
|
return
|
||||||
|
if self.process.Presentations.Count > 0:
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
self.process.Quit()
|
self.process.Quit()
|
||||||
except:
|
except:
|
||||||
|
@ -49,7 +49,7 @@ class PptviewController(PresentationController):
|
|||||||
log.debug(u'Initialising')
|
log.debug(u'Initialising')
|
||||||
self.process = None
|
self.process = None
|
||||||
PresentationController.__init__(self, plugin, u'Powerpoint Viewer')
|
PresentationController.__init__(self, plugin, u'Powerpoint Viewer')
|
||||||
self.supports = [u'.ppt', u'.pps']
|
self.supports = [u'.ppt', u'.pps', u'.pptx', u'.ppsx']
|
||||||
|
|
||||||
def check_available(self):
|
def check_available(self):
|
||||||
"""
|
"""
|
||||||
|
@ -93,6 +93,7 @@ class PresentationController(object):
|
|||||||
Name of the application, to appear in the application
|
Name of the application, to appear in the application
|
||||||
"""
|
"""
|
||||||
self.supports = []
|
self.supports = []
|
||||||
|
self.alsosupports = []
|
||||||
self.docs = []
|
self.docs = []
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
self.name = name
|
self.name = name
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -78,6 +78,7 @@
|
|||||||
<qresource prefix="services">
|
<qresource prefix="services">
|
||||||
<file>service_edit.png</file>
|
<file>service_edit.png</file>
|
||||||
<file>service_notes.png</file>
|
<file>service_notes.png</file>
|
||||||
|
<file>service_item_notes.png</file>
|
||||||
<file>service_bottom.png</file>
|
<file>service_bottom.png</file>
|
||||||
<file>service_down.png</file>
|
<file>service_down.png</file>
|
||||||
<file>service_top.png</file>
|
<file>service_top.png</file>
|
||||||
|
BIN
resources/images/service_item_notes.png
Normal file
BIN
resources/images/service_item_notes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 876 B |
@ -24,6 +24,7 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from cgi import escape
|
||||||
from ast import parse, NodeVisitor, Str
|
from ast import parse, NodeVisitor, Str
|
||||||
|
|
||||||
ts_file = u"""<?xml version="1.0" encoding="utf-8"?>
|
ts_file = u"""<?xml version="1.0" encoding="utf-8"?>
|
||||||
@ -45,7 +46,8 @@ ts_message = u""" <message>
|
|||||||
|
|
||||||
class StringExtractor(NodeVisitor):
|
class StringExtractor(NodeVisitor):
|
||||||
|
|
||||||
def __init__(self, strings, filename):
|
def __init__(self, strings, filename, base_path):
|
||||||
|
self.base_path = base_path
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
self.classname = 'unknown'
|
self.classname = 'unknown'
|
||||||
@ -58,10 +60,10 @@ class StringExtractor(NodeVisitor):
|
|||||||
if hasattr(node.func, 'attr') and node.func.attr == 'trUtf8' and isinstance(node.args[0], Str):
|
if hasattr(node.func, 'attr') and node.func.attr == 'trUtf8' and isinstance(node.args[0], Str):
|
||||||
string = node.args[0].s
|
string = node.args[0].s
|
||||||
key = '%s-%s' % (self.classname, string)
|
key = '%s-%s' % (self.classname, string)
|
||||||
self.strings[key] = [self.classname, self.filename, node.lineno, string]
|
self.strings[key] = [self.classname, self.filename[len(self.base_path) + 1:], node.lineno, escape(string)]
|
||||||
self.generic_visit(node)
|
self.generic_visit(node)
|
||||||
|
|
||||||
def parse_file(filename, strings):
|
def parse_file(base_path, filename, strings):
|
||||||
file = open(filename, u'r')
|
file = open(filename, u'r')
|
||||||
try:
|
try:
|
||||||
ast = parse(file.read())
|
ast = parse(file.read())
|
||||||
@ -70,7 +72,7 @@ def parse_file(filename, strings):
|
|||||||
return
|
return
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
StringExtractor(strings, filename).visit(ast)
|
StringExtractor(strings, filename, base_path).visit(ast)
|
||||||
|
|
||||||
def write_file(filename, strings):
|
def write_file(filename, strings):
|
||||||
translation_file = u''
|
translation_file = u''
|
||||||
@ -94,15 +96,18 @@ def write_file(filename, strings):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
strings = {}
|
strings = {}
|
||||||
start_dir = os.path.abspath(u'.')
|
start_dir = os.path.abspath(u'..')
|
||||||
for root, dirs, files in os.walk(start_dir):
|
for root, dirs, files in os.walk(start_dir):
|
||||||
for file in files:
|
for file in files:
|
||||||
if file.endswith(u'.py'):
|
if file.endswith(u'.py'):
|
||||||
print u'Parsing "%s"' % file
|
print u'Parsing "%s"' % file
|
||||||
parse_file(os.path.join(root, file), strings)
|
parse_file(start_dir, os.path.join(root, file), strings)
|
||||||
print u'Generating TS file...',
|
print u'Generating TS file...',
|
||||||
write_file(os.path.join(start_dir, u'i18n', u'openlp_en.ts'), strings)
|
write_file(os.path.join(start_dir, u'resources', u'i18n', u'openlp_en.ts'), strings)
|
||||||
print u'done.'
|
print u'done.'
|
||||||
|
|
||||||
if __name__ == u'__main__':
|
if __name__ == u'__main__':
|
||||||
|
if os.path.split(os.path.abspath(u'.'))[1] != u'scripts':
|
||||||
|
print u'You need to run this script from the scripts directory.'
|
||||||
|
else:
|
||||||
main()
|
main()
|
@ -1 +1 @@
|
|||||||
1.9.0-723
|
1.9.0-725
|
||||||
|
Loading…
Reference in New Issue
Block a user