From: Oleg Broytman Date: Sat, 1 Jan 2005 20:40:28 +0000 (+0000) Subject: Get preferred charset from the current locale and encode unicode fullpath from XML... X-Git-Url: https://git.phdru.name/?p=extfs.d.git;a=commitdiff_plain;h=1881278eca58aa0ff85f99c18cf8e9295d458258;hp=ed1dd87d8c746729fd52c24c671e8706a8331766 Get preferred charset from the current locale and encode unicode fullpath from XML to that charset. git-svn-id: file:///home/phd/archive/SVN/mc-extfs/trunk@34 1a6e6372-1aea-0310-bd00-dc960550e1df --- diff --git a/obexftp b/obexftp index 1dbcda6..1f4a033 100755 --- a/obexftp +++ b/obexftp @@ -4,7 +4,7 @@ ObexFTP Virtual FileSystem for Midnight Commander. Author: Oleg BroytMann . -Copyright (C) 2004 PhiloSoft Design. +Copyright (C) 2004, 2005 PhiloSoft Design. License: GPL. Manipulate a cell phone's filesystem calling obexftp binary. This is a @@ -66,11 +66,11 @@ into a temporary directory, usually /tmp, or /var/tmp, or whatever directory is named in $TMP environment variable. """ -__version__ = "1.2.1" -__revision__ = "$Id: obexftp,v 1.19 2004/10/03 15:02:45 phd Exp $" -__date__ = "$Date: 2004/10/03 15:02:45 $"[7:-2] +__version__ = "1.2.2" +__revision__ = "$Id$" +__date__ = "$Date$"[7:-2] __author__ = "Oleg Broytmann " -__copyright__ = "Copyright (C) 2004 PhiloSoft Design" +__copyright__ = "Copyright (C) 2004, 2005 PhiloSoft Design" # Change this to suite your needs @@ -79,7 +79,7 @@ obexftp_prog = "/usr/local/obex/bin/obexftp" import sys, os, shutil from time import sleep -import xml.dom.minidom +import xml.dom.minidom, locale from tempfile import mkstemp, mkdtemp, _candidate_tempdir_list @@ -125,6 +125,9 @@ if not found: logger.removeHandler(log_err_handler) logger.addHandler(logging.FileHandler(logfile_name)) +locale.setlocale(locale.LC_ALL, '') +charset = locale.getpreferredencoding() + # Parse ObexFTP XML directory listings @@ -238,6 +241,7 @@ def recursive_list(directory='/'): for entry in directories + files: fullpath = "%s/%s" % (directory, entry.name) + fullpath = fullpath.encode(charset) if fullpath.startswith('//'): fullpath = fullpath[1:] print entry.perm, "1 user group", entry.size, entry.mtime, fullpath