www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 5aa3189dd148360d95be8843b92fb08f5c5ff216
parent 5cf6a1cff3cd9e1b676b50e5fb7bdfa3a4ee8bae
Author: Simon Kornblith <simon@simonster.com>
Date:   Fri,  8 Jul 2011 07:20:04 +0000

- Only log translator parse error once
- Fix export (broken by last commit)
- Use init() instead of reset() in Zotero.Translate.IO.Write
- Don't use toSource() in date.js


Diffstat:
Mchrome/content/zotero/xpcom/date.js | 2+-
Mchrome/content/zotero/xpcom/translation/translate.js | 20+++++++++-----------
Mchrome/content/zotero/xpcom/translation/translate_firefox.js | 5++---
3 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/chrome/content/zotero/xpcom/date.js b/chrome/content/zotero/xpcom/date.js @@ -315,7 +315,7 @@ Zotero.Date = new function(){ } if(date.month) date.month--; // subtract one for JS style - Zotero.debug("DATE: retrieved with algorithms: "+date.toSource()); + Zotero.debug("DATE: retrieved with algorithms: "+JSON.stringify(date)); date.part = m[1]+m[7]; } else { diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js @@ -1151,13 +1151,7 @@ Zotero.Translate.Base.prototype = { this._sandboxManager.eval("var translatorInfo = "+translator.code, ["detect"+this._entryFunctionSuffix, "do"+this._entryFunctionSuffix, "Export"]); } catch(e) { - if(translator.logError) { - translator.logError(e.toString()); - } else { - Zotero.logError(e); - } - - this.complete(false, "parse error"); + this.complete(false, e); } if(callback) callback(); @@ -1701,15 +1695,19 @@ Zotero.Translate.Export.prototype._prepareTranslation = function() { } // initialize IO + // this is currently hackish since we pass null callbacks to the init function (they have + // callbacks to be consistent with import, but they are synchronous, so we ignore them) if(!this.location) { - var io = this._io = new Zotero.Translate.IO.String(null, this.path ? this.path : "", this.translator[0].configOptions["dataMode"]); + var io = this._io = new Zotero.Translate.IO.String(null, this.path ? this.path : ""); + io.init(this.translator[0].configOptions["dataMode"], function() {}); this.__defineGetter__("string", function() { return io.string; }); } else if(!Zotero.Translate.IO.Write) { throw new Error("Writing to files is not supported in this build of Zotero."); } else { - this._io = new Zotero.Translate.IO.Write(this.location, - this.translator[0].configOptions["dataMode"], - this._displayOptions["exportCharset"] ? this._displayOptions["exportCharset"] : null); + this._io = new Zotero.Translate.IO.Write(this.location); + this._io.init(this.translator[0].configOptions["dataMode"], + this._displayOptions["exportCharset"] ? this._displayOptions["exportCharset"] : null, + function() {}); } this._sandboxManager.importObject(this._io); diff --git a/chrome/content/zotero/xpcom/translation/translate_firefox.js b/chrome/content/zotero/xpcom/translation/translate_firefox.js @@ -465,13 +465,12 @@ function() { /******* Write support *******/ -Zotero.Translate.IO.Write = function(file, mode, charset) { +Zotero.Translate.IO.Write = function(file) { Zotero.Translate.IO.maintainedInstances.push(this); this._rawStream = Components.classes["@mozilla.org/network/file-output-stream;1"] .createInstance(Components.interfaces.nsIFileOutputStream); this._rawStream.init(file, 0x02 | 0x08 | 0x20, 0664, 0); // write, create, truncate this._writtenToStream = false; - if(mode || charset) this.reset(mode, charset); } Zotero.Translate.IO.Write.prototype = { @@ -528,7 +527,7 @@ Zotero.Translate.IO.Write.prototype = { this._writtenToStream = true; }, - "reset":function(newMode, charset) { + "init":function(newMode, charset, callback) { this._mode = newMode; if(Zotero.Translate.IO.rdfDataModes.indexOf(this._mode) !== -1) { this._initRDF();