From e0a7b674972386fd591b4a4060b7b44e9eb04f3d Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Wed, 10 Jan 2007 04:24:36 +0000 Subject: [PATCH] Partially revert changeset 16635. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16636 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/scripts/fen2ascii.py | 18 +++--------------- lib/scripts/fig_copy.py | 23 ++++++++--------------- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/lib/scripts/fen2ascii.py b/lib/scripts/fen2ascii.py index 6a60964a97..96bd6e0e1c 100644 --- a/lib/scripts/fen2ascii.py +++ b/lib/scripts/fen2ascii.py @@ -1,5 +1,4 @@ #! /usr/bin/env python -# -*- coding: utf-8 -*- # file fen2ascii.py # This file is part of LyX, the document processor. @@ -12,23 +11,12 @@ # This script will convert a chess position in the FEN # format to an ascii representation of the position. -import sys, string, os, locale - -# We expect two args, the names of the input and output files. -if len(sys.argv) != 3: - sys.exit(1) - -language, output_encoding = locale.getdefaultlocale() -if output_encoding == None: - output_encoding = 'latin1' - -input = unicode(sys.argv[1], 'utf8').encode(output_encoding) -output = unicode(sys.argv[2], 'utf8').encode(output_encoding) +import sys,string,os os.close(0) os.close(1) -sys.stdin = open(input, "r") -sys.stdout = open(output, "w") +sys.stdin = open(sys.argv[1],"r") +sys.stdout = open(sys.argv[2],"w") line = sys.stdin.readline() if line[-1] == '\n': diff --git a/lib/scripts/fig_copy.py b/lib/scripts/fig_copy.py index ac2948b5f7..16ae154a4e 100644 --- a/lib/scripts/fig_copy.py +++ b/lib/scripts/fig_copy.py @@ -18,31 +18,24 @@ # picture files that are stored as relative paths are replaced # with the absolute path. -import os, sys, locale +import os, sys if len(sys.argv) != 3: print >> sys.stderr, "Usage: fig_copy.py " sys.exit(1) -language, output_encoding = locale.getdefaultlocale() -if output_encoding == None: - output_encoding = 'latin1' - -from_file = unicode(sys.argv[1], 'utf8').encode(output_encoding) -to_file = unicode(sys.argv[2], 'utf8').encode(output_encoding) - -if not os.path.isfile(from_file): - print >> sys.stderr, "Unable to read", from_file +if not os.path.isfile(sys.argv[1]): + print >> sys.stderr, "Unable to read", sys.argv[1] sys.exit(1) -from_dir = os.path.split(os.path.realpath(from_file))[0] -to_dir = os.path.split(os.path.realpath(to_file))[0] +from_dir = os.path.split(os.path.realpath(sys.argv[1]))[0] +to_dir = os.path.split(os.path.realpath(sys.argv[2]))[0] # The work is trivial if "to" and "from" are in the same directory. if from_dir == to_dir: import shutil try: - shutil.copy(from_file, to_file) + shutil.copy(sys.argv[1], sys.argv[2]) except: sys.exit(1) sys.exit(0) @@ -59,8 +52,8 @@ commentline = re.compile(r'^\s*#.*$') # we allow space in path name figureline = re.compile(r'^(\s*[01]\s*)(\S[\S ]*)(\s*)$') -input = open(from_file, 'r') -output = open(to_file, 'w') +input = open(sys.argv[1], 'r') +output = open(sys.argv[2], 'w') # path in the fig is relative to this path os.chdir(from_dir) -- 2.39.2