Support for translations.

This commit is contained in:
Kovid Goyal 2007-11-08 23:10:01 +00:00
parent 4138bd1e42
commit b11f63c322
24 changed files with 162 additions and 97 deletions

View File

@ -1,7 +1,11 @@
all : gui2
all : gui2 translations
clean :
${MAKE} -C src/libprs500/gui2 clean
cd src/libprs500/gui2 && python make.py clean
gui2 :
${MAKE} -C src/libprs500/gui2
cd src/libprs500/gui2 && python make.py
translations :
cd src/libprs500 && python translations/__init__.py

View File

@ -18,11 +18,17 @@ __docformat__ = "epytext"
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
__appname__ = 'libprs500'
import sys, os, logging, mechanize
import sys, os, logging, mechanize, locale, cStringIO
from gettext import GNUTranslations
iswindows = 'win32' in sys.platform.lower()
isosx = 'darwin' in sys.platform.lower()
islinux = not(iswindows or isosx)
# Default translation is NOOP
import __builtin__
__builtin__.__dict__['_'] = lambda s: s
class CommandLineError(Exception):
pass
@ -62,12 +68,12 @@ def extract(path, dir):
ext = os.path.splitext(path)[1][1:].lower()
extractor = None
if ext == 'zip':
from libprs500.libunzip import extract
extractor = extract
from libprs500.libunzip import extract as zipextract
extractor = zipextract
elif ext == 'rar':
from libprs500.libunrar import extract # In case the dll is not found
extractor = extract
if not extractor:
from libprs500.libunrar import extract as rarextract
extractor = rarextract
if extractor is None:
raise Exception('Unknown archive type')
extractor(path, dir)
@ -78,4 +84,16 @@ def browser():
opener.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; i686 Linux; en_US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4')]
return opener
def set_translator():
# To test different translations invoke as
# LC_ALL=de_DE.utf8 program
from libprs500.translations.data import translations
lang = locale.getdefaultlocale()[0]
if lang:
lang = lang[:2]
if translations.has_key(lang):
buf = cStringIO.StringIO(translations[lang])
t = GNUTranslations(buf)
t.install(unicode=True)

View File

@ -87,90 +87,91 @@ def font_family(option, opt_str, value, parser):
def option_parser(usage):
parser = OptionParser(usage=usage, version=__appname__+' '+__version__,
epilog='Created by '+__author__)
epilog=_('Created by ')+__author__)
metadata = parser.add_option_group('METADATA OPTIONS')
metadata.add_option("-t", "--title", action="store", type="string", default=None,\
dest="title", help="Set the title. Default: filename.")
dest="title", help=_("Set the title. Default: filename."))
metadata.add_option("-a", "--author", action="store", type="string", \
dest="author", help="Set the author(s). Multiple authors should be set as a comma separated list. Default: %default", default='Unknown')
dest="author", help=_("Set the author(s). Multiple authors should be set as a comma separated list. Default: %default"),
default=_('Unknown'))
metadata.add_option("--comment", action="store", type="string", \
dest="freetext", help="Set the comment.", default=' ')
dest="freetext", help=_("Set the comment."), default=' ')
metadata.add_option("--category", action="store", type="string", \
dest="category", help="Set the category", default=' ')
dest="category", help=_("Set the category"), default=' ')
metadata.add_option('--title-sort', action='store', default='', dest='title_sort',
help='Sort key for the title')
help=_('Sort key for the title'))
metadata.add_option('--author-sort', action='store', default='', dest='author_sort',
help='Sort key for the author')
help=_('Sort key for the author'))
metadata.add_option('--publisher', action='store', default='Unknown', dest='publisher',
help='Publisher')
help=_('Publisher'))
metadata.add_option('--cover', action='store', dest='cover', default=None, \
help='Path to file containing image to be used as cover')
help=_('Path to file containing image to be used as cover'))
metadata.add_option('--use-metadata-cover', action='store_true', default=False,
help='If there is a cover graphic detected in the source file, use that instead of the specified cover.')
help=_('If there is a cover graphic detected in the source file, use that instead of the specified cover.'))
parser.add_option('-o', '--output', action='store', default=None, \
help='Output file name. Default is derived from input filename')
help=_('Output file name. Default is derived from input filename'))
parser.add_option('--ignore-tables', action='store_true', default=False, dest='ignore_tables',
help='Render HTML tables as blocks of text instead of actual tables. This is neccessary if the HTML contains very large or complex tables.')
help=_('Render HTML tables as blocks of text instead of actual tables. This is neccessary if the HTML contains very large or complex tables.'))
laf = parser.add_option_group('LOOK AND FEEL')
laf.add_option('--font-delta', action='store', type='float', default=0., \
help="""Increase the font size by 2 * FONT_DELTA pts and """
help=_("""Increase the font size by 2 * FONT_DELTA pts and """
'''the line spacing by FONT_DELTA pts. FONT_DELTA can be a fraction.'''
"""If FONT_DELTA is negative, the font size is decreased.""",
"""If FONT_DELTA is negative, the font size is decreased."""),
dest='font_delta')
laf.add_option('--enable-autorotation', action='store_true', default=False,
help='Enable autorotation of images that are wider than the screen width.',
help=_('Enable autorotation of images that are wider than the screen width.'),
dest='autorotation')
laf.add_option('--wordspace', dest='wordspace', default=2.5, type='float',
help='Set the space between words in pts. Default is %default')
help=_('Set the space between words in pts. Default is %default'))
laf.add_option('--blank-after-para', action='store_true', default=False,
dest='blank_after_para', help='Separate paragraphs by blank lines.')
dest='blank_after_para', help=_('Separate paragraphs by blank lines.'))
laf.add_option('--header', action='store_true', default=False, dest='header',
help='Add a header to all the pages with title and author.')
help=_('Add a header to all the pages with title and author.'))
laf.add_option('--headerformat', default="%t by %a", dest='headerformat', type='string',
help='Set the format of the header. %a is replaced by the author and %t by the title. Default is %default')
help=_('Set the format of the header. %a is replaced by the author and %t by the title. Default is %default'))
laf.add_option('--override-css', default=None, dest='_override_css', type='string',
help='Override the CSS. Can be either a path to a CSS stylesheet or a string. If it is a string it is interpreted as CSS.')
help=_('Override the CSS. Can be either a path to a CSS stylesheet or a string. If it is a string it is interpreted as CSS.'))
laf.add_option('--use-spine', default=False, dest='use_spine', action='store_true',
help='Use the <spine> element from the OPF file to determine the order in which the HTML files are appended to the LRF. The .opf file must be in the same directory as the base HTML file.')
help=_('Use the <spine> element from the OPF file to determine the order in which the HTML files are appended to the LRF. The .opf file must be in the same directory as the base HTML file.'))
page = parser.add_option_group('PAGE OPTIONS')
profiles = profile_map.keys()
page.add_option('-p', '--profile', default=PRS500_PROFILE, dest='profile', type='choice',
choices=profiles, action='callback', callback=profile_from_string,
help='''Profile of the target device for which this LRF is '''
help=_('''Profile of the target device for which this LRF is '''
'''being generated. The profile determines things like the '''
'''resolution and screen size of the target device. '''
'''Default: %s Supported profiles: '''%(PRS500_PROFILE.name,)+\
'''Default: %s Supported profiles: ''')%(PRS500_PROFILE.name,)+\
', '.join(profiles))
page.add_option('--left-margin', default=20, dest='left_margin', type='int',
help='''Left margin of page. Default is %default px.''')
help=_('''Left margin of page. Default is %default px.'''))
page.add_option('--right-margin', default=20, dest='right_margin', type='int',
help='''Right margin of page. Default is %default px.''')
help=_('''Right margin of page. Default is %default px.'''))
page.add_option('--top-margin', default=10, dest='top_margin', type='int',
help='''Top margin of page. Default is %default px.''')
help=_('''Top margin of page. Default is %default px.'''))
page.add_option('--bottom-margin', default=0, dest='bottom_margin', type='int',
help='''Bottom margin of page. Default is %default px.''')
help=_('''Bottom margin of page. Default is %default px.'''))
link = parser.add_option_group('LINK PROCESSING OPTIONS')
link.add_option('--link-levels', action='store', type='int', default=sys.maxint, \
dest='link_levels',
help=r'''The maximum number of levels to recursively process '''
help=_(r'''The maximum number of levels to recursively process '''
'''links. A value of 0 means thats links are not followed. '''
'''A negative value means that <a> tags are ignored.''')
'''A negative value means that <a> tags are ignored.'''))
link.add_option('--link-exclude', dest='link_exclude', default='@',
help='''A regular expression. <a> tags whoose href '''
'''matches will be ignored. Defaults to %default''')
help=_('''A regular expression. <a> tags whoose href '''
'''matches will be ignored. Defaults to %default'''))
chapter = parser.add_option_group('CHAPTER OPTIONS')
chapter.add_option('--disable-chapter-detection', action='store_true',
default=False, dest='disable_chapter_detection',
help='''Prevent html2lrf from automatically inserting page breaks'''
''' before what it thinks are chapters.''')
help=_('''Prevent the automatic insertion of page breaks'''
''' before detected chapters.'''))
chapter.add_option('--chapter-regex', dest='chapter_regex',
default='chapter|book|appendix',
help='''The regular expression used to detect chapter titles.'''
''' It is searched for in heading tags (h1-h6). Defaults to %default''')
help=_('''The regular expression used to detect chapter titles.'''
''' It is searched for in heading tags (h1-h6). Defaults to %default'''))
chapter.add_option('--page-break-before-tag', dest='page_break', default='h[12]',
help='''If html2lrf does not find any page breaks in the '''
help=_('''If html2lrf does not find any page breaks in the '''
'''html file and cannot detect chapter headings, it will '''
'''automatically insert page-breaks before the tags whose '''
'''names match this regular expression. Defaults to %default. '''
@ -178,36 +179,36 @@ def option_parser(usage):
'''The purpose of this option is to try to ensure that '''
'''there are no really long pages as this degrades the page '''
'''turn performance of the LRF. Thus this option is ignored '''
'''if the current page has only a few elements.''')
'''if the current page has only a few elements.'''))
chapter.add_option('--force-page-break-before-tag', dest='force_page_break',
default='$', help='Force a page break before tags whoose names match this regular expression.')
default='$', help=_('Force a page break before tags whoose names match this regular expression.'))
chapter.add_option('--force-page-break-before-attr', dest='force_page_break_attr',
default='$,,$', help='Force a page break before an element having the specified attribute. The format for this option is tagname regexp,attribute name,attribute value regexp. For example to match all heading tags that have the attribute class="chapter" you would use "h\d,class,chapter". Default is %default''')
default='$,,$', help=_('Force a page break before an element having the specified attribute. The format for this option is tagname regexp,attribute name,attribute value regexp. For example to match all heading tags that have the attribute class="chapter" you would use "h\d,class,chapter". Default is %default'''))
prepro = parser.add_option_group('PREPROCESSING OPTIONS')
prepro.add_option('--baen', action='store_true', default=False, dest='baen',
help='''Preprocess Baen HTML files to improve generated LRF.''')
help=_('''Preprocess Baen HTML files to improve generated LRF.'''))
prepro.add_option('--pdftohtml', action='store_true', default=False, dest='pdftohtml',
help='''You must add this option if processing files generated by pdftohtml, otherwise conversion will fail.''')
help=_('''You must add this option if processing files generated by pdftohtml, otherwise conversion will fail.'''))
prepro.add_option('--book-designer', action='store_true', default=False, dest='book_designer',
help='''Use this option on html0 files from Book Designer.''')
help=_('''Use this option on html0 files from Book Designer.'''))
fonts = parser.add_option_group('FONT FAMILIES',
'''Specify trutype font families for serif, sans-serif and monospace fonts. '''
_('''Specify trutype font families for serif, sans-serif and monospace fonts. '''
'''These fonts will be embedded in the LRF file. Note that custom fonts lead to '''
'''slower page turns. Each family specification is of the form: '''
'''"path to fonts directory, family" '''
'''For example: '''
'''--serif-family "%s, Times New Roman"
''' % ('C:\Windows\Fonts' if iswindows else '/usr/share/fonts/corefonts'))
''') % ('C:\Windows\Fonts' if iswindows else '/usr/share/fonts/corefonts'))
fonts.add_option('--serif-family', action='callback', callback=font_family,
default=None, dest='serif_family', type='string',
help='The serif family of fonts to embed')
help=_('The serif family of fonts to embed'))
fonts.add_option('--sans-family', action='callback', callback=font_family,
default=None, dest='sans_family', type='string',
help='The sans-serif family of fonts to embed')
help=_('The sans-serif family of fonts to embed'))
fonts.add_option('--mono-family', action='callback', callback=font_family,
default=None, dest='mono_family', type='string',
help='The monospace family of fonts to embed')
help=_('The monospace family of fonts to embed'))
debug = parser.add_option_group('DEBUG OPTIONS')
debug.add_option('--verbose', dest='verbose', action='store_true', default=False,

View File

@ -30,8 +30,8 @@ def largest_file(files):
for f in files:
size = os.stat(f).st_size
if size > maxsize:
maxsize = size
file = f
maxsize = size
file = f
return file
def find_htmlfile(dir):
@ -105,13 +105,13 @@ def process_file(path, options, logger=None):
if 'htm' in ext:
convertor = html2lrf
elif 'lit' == ext:
convertor = lit2lrf
convertor = lit2lrf
elif 'pdf' == ext:
convertor = pdf2lrf
convertor = pdf2lrf
elif 'rtf' == ext:
convertor = rtf2lrf
convertor = rtf2lrf
elif 'txt' == ext:
convertor = txt2lrf
convertor = txt2lrf
if not convertor:
raise UnknownFormatError('Coverting from %s to LRF is not supported.')
convertor(path, options, logger)
@ -123,6 +123,9 @@ def process_file(path, options, logger=None):
def main(args=sys.argv, logger=None):
from libprs500 import set_translator
set_translator()
parser = option_parser('''\
any2lrf myfile

View File

@ -1754,6 +1754,8 @@ def option_parser():
'''%prog converts mybook.html to mybook.lrf''')
def main(args=sys.argv):
from libprs500 import set_translator
set_translator()
try:
parser = option_parser()
options, args = parser.parse_args(args)

View File

@ -96,6 +96,9 @@ def process_file(path, options, logger=None):
def main(args=sys.argv, logger=None):
from libprs500 import set_translator
set_translator()
parser = option_parser()
options, args = parser.parse_args(args)
if len(args) != 2:

View File

@ -588,34 +588,37 @@ def option_parser():
version=__appname__+' '+__version__,
epilog='Created by Kovid Goyal')
parser.add_option("-t", "--title", action="store", type="string", \
dest="title", help="Set the book title")
dest="title", help=_("Set the book title"))
parser.add_option('--title-sort', action='store', type='string', default=None,
dest='title_reading', help='Set sort key for the title')
dest='title_reading', help=_('Set sort key for the title'))
parser.add_option("-a", "--author", action="store", type="string", \
dest="author", help="Set the author")
dest="author", help=_("Set the author"))
parser.add_option('--author-sort', action='store', type='string', default=None,
dest='author_reading', help='Set sort key for the author')
dest='author_reading', help=_('Set sort key for the author'))
parser.add_option("-c", "--category", action="store", type="string", \
dest="category", help="The category this book belongs"+\
" to. E.g.: History")
dest="category", help=_("The category this book belongs"+\
" to. E.g.: History"))
parser.add_option("--thumbnail", action="store", type="string", \
dest="thumbnail", help="Path to a graphic that will be"+\
" set as this files' thumbnail")
dest="thumbnail", help=_("Path to a graphic that will be"+\
" set as this files' thumbnail"))
parser.add_option("--comment", action="store", type="string", \
dest="comment", help="Path to a txt file containing the "+\
"comment to be stored in the lrf file.")
dest="comment", help=_("Path to a txt file containing the "+\
"comment to be stored in the lrf file."))
parser.add_option("--get-thumbnail", action="store_true", \
dest="get_thumbnail", default=False, \
help="Extract thumbnail from LRF file")
help=_("Extract thumbnail from LRF file"))
parser.add_option('--bookid', action='store', type='string', default=None,
dest='book_id', help='Set book ID')
dest='book_id', help=_('Set book ID'))
parser.add_option("-p", "--page", action="store", type="string", \
dest="page", help="Don't know what this is for")
dest="page", help=_("Don't know what this is for"))
return parser
def main(args=sys.argv):
from libprs500 import set_translator
set_translator()
import os.path
parser = option_parser()
options, args = parser.parse_args(args)

View File

@ -77,6 +77,9 @@ def process_file(path, options, logger=None):
def main(args=sys.argv, logger=None):
from libprs500 import set_translator
set_translator()
parser = option_parser()
options, args = parser.parse_args(args)
if len(args) != 2:

View File

@ -100,6 +100,9 @@ def process_file(path, options, logger=None):
shutil.rmtree(tdir)
def main(args=sys.argv, logger=None):
from libprs500 import set_translator
set_translator()
parser = option_parser()
options, args = parser.parse_args(args)
if len(args) != 2:

View File

@ -93,6 +93,9 @@ def process_file(path, options, logger=None):
print open(htmlfile.name, 'rb').read()
def main(args=sys.argv, logger=None):
from libprs500 import set_translator
set_translator()
parser = option_parser()
options, args = parser.parse_args(args)
if len(args) != 2:

View File

@ -147,6 +147,9 @@ def process_profile(args, options, logger=None):
def main(args=sys.argv, logger=None):
from libprs500 import set_translator
set_translator()
parser = option_parser()
options, args = parser.parse_args(args)
if len(args) > 2:

View File

@ -130,6 +130,9 @@ def create_books(opts, args, logger=None):
return [ISBNDBMetadata(book) for book in fetch_metadata(url)]
def main(args=sys.argv):
from libprs500 import set_translator
set_translator()
parser = option_parser()
opts, args = parser.parse_args(args)
if len(args) != 2:

View File

@ -46,6 +46,9 @@ def get_metadata(stream):
def main(args=sys.argv):
from libprs500 import set_translator
set_translator()
if len(args) != 2:
print >>sys.stderr, 'Usage: pdf-meta file.pdf'
print >>sys.stderr, 'No filename specified.'

View File

@ -174,6 +174,9 @@ def set_metadata(stream, options):
def main(args=sys.argv):
from libprs500 import set_translator
set_translator()
parser = get_parser('rtf')
options, args = parser.parse_args(args)
if len(args) != 2:

View File

@ -15,13 +15,14 @@
""" The GUI for libprs500. """
import sys, os, re, StringIO, traceback
from PyQt4.QtCore import QVariant, QSettings, QFileInfo, QObject, SIGNAL, QBuffer, \
QByteArray
QByteArray, QLocale, QTranslator
from PyQt4.QtGui import QFileDialog, QMessageBox, QPixmap, QFileIconProvider, \
QIcon, QTableView
ORG_NAME = 'KovidsBrain'
APP_UID = 'libprs500'
from libprs500 import __author__, islinux
from libprs500.gui2.translations import translations
NONE = QVariant() #: Null value to return from the data function of item models
BOOK_EXTENSIONS = ['lrf', 'lrx', 'rar', 'zip', 'rtf', 'lit', 'txt', 'htm',
@ -298,3 +299,16 @@ def pixmap_to_data(pixmap, format='JPEG'):
pixmap.save(buf, format)
return str(ba.data())
def set_translator(app):
locale = QLocale.system().language()
locale = 'test'
if translations.has_key(locale):
data = translations[locale]
t = QTranslator()
open('yay.qm', 'wb').write(data)
t.load('yay.qm')
print t.isEmpty()
app.installTranslator(t)
os.unlink('yay.qm')

View File

@ -12,8 +12,6 @@
## You should have received a copy of the GNU General Public License along
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
''''''
from PyQt4.QtGui import QDialog
from libprs500.gui2.dialogs.conversion_error_ui import Ui_ConversionErrorDialog

View File

@ -12,5 +12,5 @@
## You should have received a copy of the GNU General Public License along
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
''''''

View File

@ -12,8 +12,6 @@
## You should have received a copy of the GNU General Public License along
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
''''''
import collections, itertools
from PyQt4.QtCore import Qt, QByteArray, SIGNAL

View File

@ -12,10 +12,7 @@
## You should have received a copy of the GNU General Public License along
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from libprs500.gui2 import choose_files
''''''
import sys, logging, os, traceback, time, cPickle, copy
import sys, logging, os, traceback, time, cPickle
from PyQt4.QtGui import QApplication, QKeySequence, QPainter, QDialog
from PyQt4.QtCore import Qt, QObject, SIGNAL, QCoreApplication, QThread, \
@ -24,7 +21,7 @@ from PyQt4.QtCore import Qt, QObject, SIGNAL, QCoreApplication, QThread, \
from libprs500 import __appname__, __version__, __author__, setup_cli_handlers, islinux
from libprs500.ebooks.lrf.parser import LRFDocument
from libprs500.gui2 import ORG_NAME, APP_UID, error_dialog
from libprs500.gui2 import ORG_NAME, APP_UID, error_dialog, choose_files
from libprs500.gui2.dialogs.conversion_error import ConversionErrorDialog
from libprs500.gui2.lrf_renderer.main_ui import Ui_MainWindow
from libprs500.gui2.lrf_renderer.config_ui import Ui_ViewerConfig
@ -285,6 +282,8 @@ def normalize_settings(parser, opts):
def main(args=sys.argv, logger=None):
from libprs500 import set_translator
set_translator()
parser = option_parser()
opts, args = parser.parse_args(args)
if hasattr(opts, 'help'):

View File

@ -12,8 +12,6 @@
## You should have received a copy of the GNU General Public License along
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
''''''
import sys, collections, operator, copy, re
from PyQt4.QtCore import Qt, QRectF, QString

View File

@ -20,7 +20,7 @@ from PyQt4.QtGui import QPixmap, QColor, QPainter, QMenu, QIcon, QMessageBox, \
QToolButton, QDialog
from PyQt4.QtSvg import QSvgRenderer
from libprs500 import __version__, __appname__, islinux
from libprs500 import __version__, __appname__, islinux, set_translator
from libprs500.ptempfile import PersistentTemporaryFile
from libprs500.ebooks.metadata.meta import get_metadata
from libprs500.ebooks.lrf.web.convert_from import main as web2lrf
@ -716,6 +716,7 @@ class Main(MainWindow, Ui_MainWindow):
def main(args=sys.argv):
set_translator()
from PyQt4.Qt import QApplication
pid = os.fork() if islinux else -1
if pid <= 0:

View File

@ -105,7 +105,7 @@
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">For help visit &lt;a href="https://libprs500.kovidgoyal.net/wiki/WikiStart#Usage">libprs500.kovidgoyal.net&lt;/a>&lt;br />&lt;br />&lt;span style=" font-weight:600;">libprs500&lt;/span>: %1 by &lt;span style=" font-weight:600;">Kovid Goyal&lt;/span> © 2007&lt;br />%2&lt;/p>&lt;/body>&lt;/html></string>
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">For help visit &lt;a href="https://libprs500.kovidgoyal.net/wiki/WikiStart#Usage">&lt;span style=" text-decoration: underline; color:#0000ff;">libprs500.kovidgoyal.net&lt;/span>&lt;/a>&lt;br />&lt;br />&lt;span style=" font-weight:600;">libprs500&lt;/span>: %1 by &lt;span style=" font-weight:600;">Kovid Goyal&lt;/span> &lt;br />%2&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="textFormat" >
<enum>Qt::RichText</enum>

View File

@ -16,7 +16,7 @@
Manage the PyQt build system pyrcc4, pylupdate4, lrelease and friends.
'''
import sys, os, subprocess, cStringIO, compiler
import sys, os, subprocess, cStringIO, compiler, re
from functools import partial
from PyQt4.uic import compileUi
@ -45,11 +45,13 @@ def build_forms(forms):
dat = buf.getvalue()
dat = dat.replace('import images_rc', 'from libprs500.gui2 import images_rc')
dat = dat.replace('from library import', 'from libprs500.gui2.library import')
dat = re.compile(r'QtGui.QApplication.translate\(.+?,\s+"(.+?)(?<!\\)",.+?\)', re.DOTALL).sub(r'_("\1")', dat)
open(compiled_form, 'wb').write(dat)
def build_images():
newest = 0
for root, dirs, files in os.walk('./images'):
for root, dirs, files in os.walk(os.path.join('.', 'images')):
for name in files:
newest = max(os.stat(os.path.join(root, name)).st_mtime, newest)
@ -62,7 +64,6 @@ def build_images():
os.utime('images_rc.py', None)
os.utime('images_rc.pyc', None)
def build(forms):
build_forms(forms)
build_images()
@ -86,7 +87,7 @@ def main(args=sys.argv):
if len(args) == 1:
args.append('all')
if args[1] == 'all':
if args[1] == 'all':
build(forms)
elif args[1] == 'clean':
clean(forms)
@ -95,7 +96,7 @@ def main(args=sys.argv):
print 'Running main.py'
subprocess.call('python main.py', shell=True)
else:
print 'Usage: %s [clean|test|all]'%(args[0])
print 'Usage: %s [all|clean|test]'%(args[0])
return 1
return 0

View File

@ -95,6 +95,7 @@ def main():
shutil.rmtree('docs')
os.mkdir('docs')
check_call("sudo python setup.py develop", shell=True)
check_call('make', shell=True)
upload_demo()
print 'Building OSX installer...'
dmg = build_osx()