Open GoogleCodeExporter opened 9 years ago
Ha! Found it! See attached file: Change method GetFileContents in
\closure-library\closure\bin\build\source.py to
def GetFileContents(path):
"""Get a file's contents as a string.
Args:
path: str, Path to file.
Returns:
str, Contents of file.
Raises:
IOError: An error occurred opening or reading the file.
"""
fileobj = None
try:
fileobj = open(path, encoding='utf-8')
return fileobj.read()
except Exception as e:
raise IOError("{0} when opening or reading file {1}: {2}".format(e.__class__.__name__ , path, e))
finally:
if fileobj is not None:
fileobj.close()
The line
fileobj = open(path, encoding='utf-8')
is it. Files downloaded from
https://code.google.com/p/closure-library/downloads/list seem to be
UTF8-encoded (which I guessed). Now it runs through until
D:\Projekt\PhpStorm\ClosureTest>closure-library\closure\bin\build\closurebuilder
.py --root=closure-library\ --root=myproject\ --namespace="myproject.start"
D:\Projekt\PhpStorm\ClosureTest\closure-library\closure\bin\build\closurebuilder
.py: Scanning paths...
D:\Projekt\PhpStorm\ClosureTest\closure-library\closure\bin\build\closurebuilder
.py: 934 sources scanned.
D:\Projekt\PhpStorm\ClosureTest\closure-library\closure\bin\build\closurebuilder
.py: Building dependency tree..
Traceback (most recent call last):
File "D:\Projekt\PhpStorm\ClosureTest\closure-library\closure\bin\build\closurebuilder.py", line 262, in <module>
main()
File "D:\Projekt\PhpStorm\ClosureTest\closure-library\closure\bin\build\closurebuilder.py", line 211, in main
tree = depstree.DepsTree(sources)
File "D:\Projekt\PhpStorm\ClosureTest\closure-library\closure\bin\build\depstree.py", line 56, in __init__
raise NamespaceNotFoundError(require, source)
depstree.NamespaceNotFoundError: Namespace "goog.i18n.bidi.Dir" never provided.
Required in Source closure-library\closure\goog\soy\data.js
I will add a separate issue for that ...
Original comment by m...@jochenscharr.de
on 10 Nov 2013 at 7:48
Attachments:
Sorry, what I said in
- What version of the product are you using? On what operating system?
was wrong. I am not working with downloaded version
closure-library-20130212-95c19e7f0f5f.zip, but a clone of the current Closure
Library version (http://code.google.com/p/closure-library/), created using git.
The rest is correct.
Original comment by m...@jochenscharr.de
on 10 Nov 2013 at 10:47
As mentioned in issue 473, calcdeps.py on line 132 handles it correctly:
# Python 3 requires the file encoding to be specified
if (sys.version_info[0] < 3):
file_handle = open(filename, 'r')
else:
file_handle = open(filename, 'r', encoding='utf8')
As proposed in issue 473, "all invocations of 'open' should similarly check the
python version". IMHO, that should be centralized in a method wrapping 'open'.
As an absolute newbie to Python and Closure, unfortunately, this is too much
for me now ...
But I integrated it in source.py (see attached file):
def GetFileContents(path):
"""Get a file's contents as a string.
Args:
path: str, Path to file.
Returns:
str, Contents of file.
Raises:
IOError: An error occurred opening or reading the file.
"""
fileobj = None
try:
# Python 3 requires the file encoding to be specified
if(sys.version_info[0] < 3):
fileobj = open(path, 'r')
else:
fileobj = open(path, 'r', encoding='utf8')
return fileobj.read()
except Exception as e:
raise IOError("{0} when opening or reading file {1}: {2}".format(e.__class__.__name__ , path, e))
finally:
if fileobj is not None:
fileobj.close()
Original comment by m...@jochenscharr.de
on 10 Nov 2013 at 11:59
Attachments:
Original issue reported on code.google.com by
m...@jochenscharr.de
on 10 Nov 2013 at 4:53Attachments: