Update of /cvsroot/freevo/freevo/src/util
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2495/src/util

Modified Files:
        __init__.py fileops.py mediainfo.py misc.py vfs.py 
Log Message:
fix unicode handling

Index: __init__.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/util/__init__.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** __init__.py 2 Jan 2004 11:19:40 -0000       1.8
--- __init__.py 5 Feb 2004 19:26:42 -0000       1.9
***************
*** 11,14 ****
--- 11,17 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.9  2004/02/05 19:26:42  dischi
+ # fix unicode handling
+ #
  # Revision 1.8  2004/01/02 11:19:40  dischi
  # import popen3
***************
*** 20,40 ****
  # move xml help stuff to new fxdparser
  #
- # Revision 1.5  2003/11/22 20:34:08  dischi
- # use new vfs
- #
- # Revision 1.4  2003/11/02 10:50:40  dischi
- # remove debug
- #
- # Revision 1.3  2003/11/02 09:24:35  dischi
- # Check for libs and make it possible to install runtime from within
- # freevo
- #
- # Revision 1.2  2003/10/18 13:04:42  dischi
- # add distutils
- #
- # Revision 1.1  2003/10/11 11:20:11  dischi
- # move util.py into a directory and split it into two files
- #
- #
  # -----------------------------------------------------------------------
  # Freevo - A Home Theater PC framework
--- 23,26 ----
***************
*** 65,72 ****
  
  if sys.argv[0].find('setup.py') == -1 and sys.argv[0].find('install.py') == -1:
!     import vfs
      import __builtin__
!     __builtin__.__dict__['vfs'] = vfs
!     
      from misc import *
      from fileops import *
--- 51,76 ----
  
  if sys.argv[0].find('setup.py') == -1 and sys.argv[0].find('install.py') == -1:
!     import config
      import __builtin__
! 
!     def Unicode(string, encoding=config.encoding):
!         if type(string) == str:
!             try:
!                 return unicode(string, encoding)
!             except Exception, e:
!                 _debug_( "Could not convert %s to unicode using \"%s\" encoding: %s" 
% \
!                          ( repr(string), encoding, e ))
!         return string
! 
!     def String(string, encoding=config.encoding):
!         if type(string) == unicode:
!             try:
!                 return string.encode(encoding)
!             except Exception, e:
!                 _debug_( "Could not convert %s to string using \"%s\" encoding: %s" 
% \
!                          ( repr(string), encoding, e ))
!         return string
! 
!     import vfs
      from misc import *
      from fileops import *
***************
*** 75,77 ****
      import objectcache
      import popen3
!     
--- 79,84 ----
      import objectcache
      import popen3
! 
!     __builtin__.__dict__['vfs']     = vfs
!     __builtin__.__dict__['Unicode'] = Unicode
!     __builtin__.__dict__['String']  = String

Index: fileops.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/util/fileops.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** fileops.py  5 Feb 2004 02:52:26 -0000       1.14
--- fileops.py  5 Feb 2004 19:26:42 -0000       1.15
***************
*** 11,14 ****
--- 11,17 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.15  2004/02/05 19:26:42  dischi
+ # fix unicode handling
+ #
  # Revision 1.14  2004/02/05 02:52:26  gsbarbieri
  # Handle filenames internally as unicode objects.
***************
*** 161,173 ****
      pointed to by path.
      """
-     encoding = config.encoding
-     try:
-         if type( path ) == unicode:
-             path = path.encode( encoding )
-     except Exception, e:
-         print "ERROR:" + \
-               "Could not encode %s to \"%s\" encoding: %s" % \
-               ( repr( path ), encoding, e )
-         
      s = os.statvfs(path)
      return s[statvfs.F_BAVAIL] * long(s[statvfs.F_BSIZE])
--- 164,167 ----
***************
*** 181,193 ****
      """
      
-     encoding = config.encoding
-     try:
-         if type( path ) == unicode:
-             path = path.encode( encoding )
-     except Exception, e:
-         print "ERROR:" + \
-               "Could not encode %s to \"%s\" encoding: %s" % \
-               ( repr( path ), encoding, e )
-         
      s = os.statvfs(path)
      return s[statvfs.F_BLOCKS] * long(s[statvfs.F_BSIZE])
--- 175,178 ----

Index: mediainfo.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/util/mediainfo.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** mediainfo.py        3 Feb 2004 20:49:37 -0000       1.16
--- mediainfo.py        5 Feb 2004 19:26:42 -0000       1.17
***************
*** 11,14 ****
--- 11,17 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.17  2004/02/05 19:26:42  dischi
+ # fix unicode handling
+ #
  # Revision 1.16  2004/02/03 20:49:37  dischi
  # do not simplifiy dvds on disc/vcds cue/bin
***************
*** 330,334 ****
                  value = getattr(object,k)
                  if isinstance(value, str) or isinstance(value, unicode):
!                     value = value.replace('\0', '').lstrip().rstrip()
                  if value:
                      ret[k] = value
--- 333,337 ----
                  value = getattr(object,k)
                  if isinstance(value, str) or isinstance(value, unicode):
!                     value = Unicode(value.replace('\0', '').lstrip().rstrip())
                  if value:
                      ret[k] = value
***************
*** 354,358 ****
          if info:
              info = self.simplify(info)
!             info['title:filename'] = util.getname(filename)
              if info.has_key('video'):
                  for video in info['video']:
--- 357,361 ----
          if info:
              info = self.simplify(info)
!             info['title:filename'] = Unicode(util.getname(filename))
              if info.has_key('video'):
                  for video in info['video']:

Index: misc.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/util/misc.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** misc.py     5 Feb 2004 05:44:26 -0000       1.22
--- misc.py     5 Feb 2004 19:26:42 -0000       1.23
***************
*** 11,14 ****
--- 11,17 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.23  2004/02/05 19:26:42  dischi
+ # fix unicode handling
+ #
  # Revision 1.22  2004/02/05 05:44:26  gsbarbieri
  # Fixes some bugs related to handling unicode internally.
***************
*** 226,230 ****
      if name.endswith('_'):
          name = name[:-1]
!     return name
  
  
--- 229,233 ----
      if name.endswith('_'):
          name = name[:-1]
!     return Unicode(name)
  
  

Index: vfs.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/util/vfs.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** vfs.py      5 Feb 2004 05:44:26 -0000       1.15
--- vfs.py      5 Feb 2004 19:26:42 -0000       1.16
***************
*** 17,20 ****
--- 17,23 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.16  2004/02/05 19:26:42  dischi
+ # fix unicode handling
+ #
  # Revision 1.15  2004/02/05 05:44:26  gsbarbieri
  # Fixes some bugs related to handling unicode internally.
***************
*** 24,32 ****
  # Handle filenames internally as unicode objects.
  #
! # This does *NOT* affect filenames that have only ASCII chars, since the translation 
ASCII -> Unicode is painless. However this *DOES* affect files with accents, like é 
(e acute, \xe9) and others.
  #
! # I tested with Video, Images and Music modules, but *NOT* with Games, so if you 
have the games modules, give it a try.
  #
! # It determines the encoding based on (in order) FREEVO_LOCALE, LANG and LC_ALL, 
which may have the form: "LANGUAGE_CODE.ENCODING", like "pt_BR.UTF-8", and others.
  #
  # Revision 1.13  2004/02/04 11:54:27  dischi
--- 27,39 ----
  # Handle filenames internally as unicode objects.
  #
! # This does *NOT* affect filenames that have only ASCII chars, since the
! # translation ASCII -> Unicode is painless. However this *DOES* affect files with
! # accents, like é (e acute, \xe9) and others.
  #
! # I tested with Video, Images and Music modules, but *NOT* with Games, so if you
! # have the games modules, give it a try.
  #
! # It determines the encoding based on (in order) FREEVO_LOCALE, LANG and LC_ALL,
! # which may have the form: "LANGUAGE_CODE.ENCODING", like "pt_BR.UTF-8", and others.
  #
  # Revision 1.13  2004/02/04 11:54:27  dischi
***************
*** 222,235 ****
          files = []
  
-         encoding=config.encoding
-         try:
-             if type( directory ) == str:
-                 directory = unicode( directory, encoding )
-         except Exception, e:
-             _debug_( "ERROR: " + \
-                   "Could not convert %s to unicode using \"%s\" encoding: %s" % \
-                      ( repr( directory ), encoding, e )
-                      )
-         
          if include_dot_files:
              for f in os.listdir(directory):
--- 229,232 ----
***************
*** 247,260 ****
          if overlay and overlay != directory and os.path.isdir(overlay):
              for fname in os.listdir( overlay ):
-                 
-                 if type( fname ) == str:
-                     try:
-                         fname = unicode( fname, encoding )
-                     except Exception, e:
-                         _debug_( "ERROR: " + \
-                               "Could not convert %s to unicode using \"%s\" 
encoding: %s" % \
-                                  ( repr( fname ), encoding, e )
-                                  )
-                         
                  f = overlay + fname
          
--- 244,247 ----



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to