- 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
This commit is contained in:
Simon Kornblith 2011-07-08 07:20:04 +00:00
parent 5cf6a1cff3
commit 5aa3189dd1
3 changed files with 12 additions and 15 deletions

View file

@ -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 {

View file

@ -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);

View file

@ -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();