#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (C) 2006-2014 Derrick Moser # Copyright (C) 2015-2016 Romain Failliot # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the licence, or (at your option) any later # version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # this program. You may also obtain a copy of the GNU General Public License # from the Free Software Foundation by visiting their web site # (http://www.fsf.org/) or by writing to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import codecs import gettext import locale import os import sys # use the program's location as a starting place to search for supporting files # such as icon and help documentation if hasattr(sys, 'frozen'): app_path = sys.executable else: app_path = os.path.realpath(sys.argv[0]) bin_dir = os.path.dirname(app_path) # platform test def isWindows(): return os.name == 'nt' # translation location: '../share/locale//LC_MESSAGES/diffuse.mo' # where '' is the language key lang = locale.getdefaultlocale()[0] if isWindows(): # gettext looks for the language using environment variables which # are normally not set on Windows so we try setting it for them for v in 'LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG': if v in os.environ: lang = os.environ[v] # remove any additional languages, encodings, or modifications for v in ':.@': lang = lang.split(v)[0] break else: if lang is not None: os.environ['LANG'] = lang del v locale_dir = 'locale' else: locale_dir = '../share/locale' locale_dir = os.path.join(bin_dir, locale_dir) gettext.bindtextdomain('diffuse', locale_dir) gettext.textdomain('diffuse') _ = gettext.gettext APP_NAME = 'Diffuse' VERSION = '0.4.8' COPYRIGHT = _('Copyright © 2006-2014 Derrick Moser') WEBSITE = 'http://diffuse.sourceforge.net/' # process help options if __name__ == '__main__': args = sys.argv argc = len(args) if argc == 2 and args[1] in [ '-v', '--version' ]: print('%s %s\n%s' % (APP_NAME, VERSION, COPYRIGHT)) sys.exit(0) if argc == 2 and args[1] in [ '-h', '-?', '--help' ]: print(_('''Usage: diffuse [ [OPTION...] [FILE...] ]... diffuse ( -h | -? | --help | -v | --version ) Diffuse is a graphical tool for merging and comparing text files. Diffuse is able to compare an arbitrary number of files side-by-side and gives users the ability to manually adjust line matching and directly edit files. Diffuse can also retrieve revisions of files from Bazaar, CVS, Darcs, Git, Mercurial, Monotone, RCS, Subversion, and SVK repositories for comparison and merging. Help Options: ( -h | -? | --help ) Display this usage information ( -v | --version ) Display version and copyright information Configuration Options: --no-rcfile Do not read any resource files --rcfile Specify explicit resource file General Options: ( -c | --commit ) File revisions and ( -D | --close-if-same ) Close all tabs with no differences ( -e | --encoding ) Use to read and write files ( -L | --label )