[issue14985] os.path.isfile and os.path.isdir inconsistent on OSX Lion

2012-06-02 Thread Adrian Bastholm

New submission from Adrian Bastholm :

os.path.isfile doesn't reckognize a .picasa.ini file as a file
and os.path.isdir doesn't reckognize a directory as a directory

code:

def traverse (targetDir):
currentDir = targetDir
dirs = os.listdir(targetDir)
#dirs = [x for x in os.listdir('.') if x.endswith('.JPG')]
for entry in dirs:
if os.path.isdir(entry):
print("Traversing " + entry)
traverse(entry)
else:
print("Not dir: " + entry)
if os.path.isfile(entry):
print("Processing " + " " + currentDir + " " + entry)
else:
print("Not file: " + entry)
print("\n")
return True

The test directory contains jpg files and a folder with some other jpgs and a 
subfolder containing jpgs

--
assignee: ronaldoussoren
components: Macintosh
messages: 162133
nosy: javahaxxor, ronaldoussoren
priority: normal
severity: normal
status: open
title: os.path.isfile and os.path.isdir  inconsistent on OSX Lion
type: behavior
versions: Python 3.2

___
Python tracker 
<http://bugs.python.org/issue14985>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14986] print() fails on latin1 characters on OSX

2012-06-02 Thread Adrian Bastholm

New submission from Adrian Bastholm :

print(listentry) fails on folder name with swedish (latin1) characters
Error:

 File 
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/encodings/mac_roman.py",
 line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u030a' in position 
33: character maps to 

--
assignee: ronaldoussoren
components: Macintosh
messages: 162134
nosy: javahaxxor, ronaldoussoren
priority: normal
severity: normal
status: open
title: print() fails on latin1 characters on OSX
versions: Python 3.2

___
Python tracker 
<http://bugs.python.org/issue14986>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14986] print() fails on latin1 characters on OSX

2012-06-02 Thread Adrian Bastholm

Adrian Bastholm  added the comment:

The char in question: 'å'. It is a folder with this character in the name. My 
encoding is UTF-8. Running print("\u030a") gives a blank line

U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE
General Character Properties
In Unicode since: 1.1
Unicode category: Letter, Uppercase
Canonical decomposition: U+0041 LATIN CAPITAL LETTER A + U+030A COMBINING RING 
ABOVE
Various Useful Representations
UTF-8: 0xC3 0x85
UTF-16: 0x00C5
C octal escaped UTF-8: \303\205
XML decimal entity: Å
Annotations and Cross References
See also:
 • U+212B ANGSTROM SIGN
Equivalents:
 • U+0041 LATIN CAPITAL LETTER A U+030A COMBINING RING ABOVE

The code:

def traverse (targetDir):
currentDir = targetDir
dirs = os.listdir(targetDir)
for entry in dirs:
if os.path.isdir(entry):
print("Traversing " + entry)
traverse(entry)
else:
print("Not dir: " + entry)
if os.path.isfile(entry):
print("Processing " + " " + currentDir + " " + entry)
else:
print("Not file: " + entry)
print("\n")

--

___
Python tracker 
<http://bugs.python.org/issue14986>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14986] print() fails on latin1 characters on OSX

2012-06-02 Thread Adrian Bastholm

Adrian Bastholm  added the comment:

The last post is the CAPITAL Å. The following is the small letter "å"

U+00E5 LATIN SMALL LETTER A WITH RING ABOVE
General Character Properties
In Unicode since: 1.1
Unicode category: Letter, Lowercase
Canonical decomposition: U+0061 LATIN SMALL LETTER A + U+030A COMBINING RING 
ABOVE
Various Useful Representations
UTF-8: 0xC3 0xA5
UTF-16: 0x00E5
C octal escaped UTF-8: \303\245
XML decimal entity: å
Annotations and Cross References
Notes:
 • Danish, Norwegian, Swedish, Walloon
Equivalents:
 • U+0061 LATIN SMALL LETTER A U+030A COMBINING RING ABOVE

--

___
Python tracker 
<http://bugs.python.org/issue14986>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14985] os.path.isfile and os.path.isdir inconsistent on OSX Lion

2012-06-02 Thread Adrian Bastholm

Adrian Bastholm  added the comment:

You're right, my code was shite. Strange though it seemed to work on some 
files. The following updated version does everything as intended with the help 
of os.path.join:

def traverse (targetDir):
currentDir = targetDir
dirs = os.listdir(targetDir)
for entry in dirs:
if os.path.isdir(os.path.join(currentDir,entry)):
print("Traversing " + os.path.join(targetDir,entry))
traverse(os.path.join(targetDir,entry))
else:
if os.path.isfile(os.path.join(targetDir,entry)):
print("Processing" + " " + os.path.join(currentDir,entry))
else:
print("Not file: " + entry)
print("\n")

--

___
Python tracker 
<http://bugs.python.org/issue14985>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14986] print() fails on latin1 characters on OSX

2012-06-02 Thread Adrian Bastholm

Adrian Bastholm  added the comment:

Output in console:

Python 3.2.3 (v3.2.3:3d0686d90f55, Apr 10 2012, 11:25:50) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.stdout)
<_io.TextIOWrapper name='' mode='w' encoding='UTF-8'>
>>> import os
>>> print([(k, os.environ[k]) for k in os.environ if k.startswith('LC')])
[('LC_CTYPE', 'UTF-8')]
>>> print([(k, os.environ[k]) for k in os.environ if k.startswith('LANG')])
[]
>>> import locale
>>> print(locale.getlocale())
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/locale.py", 
line 524, in getlocale
return _parse_localename(localename)
  File 
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/locale.py", 
line 433, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
>>> print('\u00e5')
å
>>> print('\u0061\u030a')
å
**

Output from Eclipse:

<_io.TextIOWrapper name='' mode='w' encoding='MacRoman'>
[]
[]
(None, None)
å
Traceback (most recent call last):
  File 
"/Users/adyhasch/Documents/PythonWorkspace/PatternRenamer/src/prenamer.py", 
line 70, in 
print('\u0061\u030a')
  File 
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/encodings/mac_roman.py",
 line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u030a' in position 
1: character maps to 


I'm running PyDev ..

--

___
Python tracker 
<http://bugs.python.org/issue14986>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14986] print() fails on latin1 characters on OSX

2012-06-02 Thread Adrian Bastholm

Adrian Bastholm  added the comment:

my code runs fine in a console window, so it's some kind of configuration 
error. Sorry for wasting your time guys .. It would be nice to know why PyDev 
is not setting the right environment vars though ..

>>> traverse(".")
Processing ./.DS_Store
Traversing ./2011-10-03--Sebi_o_costi_ny_frisyr
Processing ./2011-10-03--Sebi_o_costi_ny_frisyr/.DS_Store
Processing ./2011-10-03--Sebi_o_costi_ny_frisyr/.picasa.ini
Traversing ./2011-10-03--Sebi_o_costi_ny_frisyr/2011-10-04--Sebastian_2år
Processing 
./2011-10-03--Sebi_o_costi_ny_frisyr/2011-10-04--Sebastian_2år/.DS_Store
Processing 
./2011-10-03--Sebi_o_costi_ny_frisyr/2011-10-04--Sebastian_2år/.picasa.ini
Processing 
./2011-10-03--Sebi_o_costi_ny_frisyr/2011-10-04--Sebastian_2år/DSC_5467.JPG
Processing 
./2011-10-03--Sebi_o_costi_ny_frisyr/2011-10-04--Sebastian_2år/DSC_5468.JPG
Processing 
./2011-10-03--Sebi_o_costi_ny_frisyr/2011-10-04--Sebastian_2år/DSC_5472.JPG

Processing ./2011-10-03--Sebi_o_costi_ny_frisyr/DSC_5440.JPG
Processing ./2011-10-03--Sebi_o_costi_ny_frisyr/DSC_5441.JPG

Processing ./__init__.py
Processing ./DSC_5440.JPG
Processing ./DSC_5453.JPG
Processing ./prenamer.py

--

___
Python tracker 
<http://bugs.python.org/issue14986>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14986] print() fails on latin1 characters on OSX

2012-06-03 Thread Adrian Bastholm

Adrian Bastholm  added the comment:

Thanks a lot for the help, guys !

--

___
Python tracker 
<http://bugs.python.org/issue14986>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com