Skip to content

Commit

Permalink
Update view.js
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Sep 7, 2024
1 parent c799384 commit c5206b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 6 additions & 8 deletions source/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ view.View = class {
{ name: 'RangeError', message: /^Offset is outside the bounds of the DataView/, url: 'https://github.com/lutzroeder/netron/issues/563' },
{ name: 'RangeError', message: /^Invalid string length/, url: 'https://github.com/lutzroeder/netron/issues/648' },
{ name: 'Python Error', message: /^Unknown function/, url: 'https://github.com/lutzroeder/netron/issues/546' },
{ name: 'Error loading model.', message: /^Unsupported file content \(/, url: 'https://github.com/lutzroeder/netron/issues/550' },
{ name: 'Error loading model.', message: /^Unsupported file content/, url: 'https://github.com/lutzroeder/netron/issues/550' },
{ name: 'Error loading model.', message: /^Unsupported Protocol Buffers content/, url: 'https://github.com/lutzroeder/netron/issues/593' },
{ name: 'Error loading model.', message: /^Unsupported Protocol Buffers text content/, url: 'https://github.com/lutzroeder/netron/issues/594' },
{ name: 'Error loading model.', message: /^Unsupported JSON content/, url: 'https://github.com/lutzroeder/netron/issues/595' },
Expand Down Expand Up @@ -5728,7 +5728,6 @@ view.ModelFactoryService = class {

_unsupported(context) {
const identifier = context.identifier;
const extension = identifier.split('.').pop().toLowerCase();
const stream = context.stream;
const callbacks = [
(stream) => zip.Archive.open(stream, 'zip'),
Expand Down Expand Up @@ -5808,7 +5807,7 @@ view.ModelFactoryService = class {
}
}
const content = `${JSON.stringify(obj).substring(0, 100).replace(/\s/, '').substring(0, 48)}...`;
throw new view.Error(`Unsupported JSON content '${content.length > 64 ? `${content.substring(0, 100)}...` : content}' for extension '.${extension}'.`);
throw new view.Error(`Unsupported JSON content '${content.length > 64 ? `${content.substring(0, 100)}...` : content}'.`);
}
};
const pbtxt = () => {
Expand Down Expand Up @@ -5844,7 +5843,7 @@ view.ModelFactoryService = class {
entries.push(...Array.from(tags).filter(([key]) => key.toString().indexOf('.') === -1));
entries.push(...Array.from(tags).filter(([key]) => key.toString().indexOf('.') !== -1));
const content = entries.map(([key, value]) => value === true ? key : `${key}:${JSON.stringify(value)}`).join(',');
throw new view.Error(`Unsupported Protocol Buffers text content '${content.length > 64 ? `${content.substring(0, 100)}...` : content}' for extension '.${extension}'.`);
throw new view.Error(`Unsupported Protocol Buffers text content '${content.length > 64 ? `${content.substring(0, 100)}...` : content}'.`);
}
};
const pb = () => {
Expand Down Expand Up @@ -5899,7 +5898,7 @@ view.ModelFactoryService = class {
return content.join(',');
};
const content = format(tags);
throw new view.Error(`Unsupported Protocol Buffers content '${content.length > 64 ? `${content.substring(0, 100)}...` : content}' for extension '.${extension}'.`);
throw new view.Error(`Unsupported Protocol Buffers content '${content.length > 64 ? `${content.substring(0, 100)}...` : content}'.`);
}
};
const flatbuffers = () => {
Expand Down Expand Up @@ -5974,9 +5973,8 @@ view.ModelFactoryService = class {
if (stream) {
stream.seek(0);
const buffer = stream.peek(Math.min(16, stream.length));
const bytes = Array.from(buffer).map((c) => (c < 16 ? '0' : '') + c.toString(16)).join('');
const content = stream.length > 268435456 ? `(${bytes}) [${stream.length}]` : `(${bytes})`;
throw new view.Error(`Unsupported file content ${content} for extension '.${extension}'.`);
const content = Array.from(buffer).map((c) => (c < 16 ? '0' : '') + c.toString(16)).join('');
throw new view.Error(`Unsupported file content '${content}'.`);
}
throw new view.Error("Unsupported file directory.");
};
Expand Down
6 changes: 3 additions & 3 deletions test/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"type": "_",
"target": "gzip_invalid_archive.tar.gz",
"source": "https://github.com/lutzroeder/netron/files/5468427/gzip_invalid_archive.tar.gz",
"error": "Unsupported file content (ff000000000000000000000000000000) for extension '.gz'.",
"error": "Unsupported file content 'ff000000000000000000000000000000'.",
"link": "https://github.com/lutzroeder/netron/issues/249"
},
{
Expand Down Expand Up @@ -163,7 +163,7 @@
"type": "_",
"target": "random.onnx",
"source": "https://github.com/lutzroeder/netron/files/7449479/random.onnx.zip[random.onnx]",
"error": "Unsupported file content (746d6c20786d6c6e733d22687474703a) for extension '.onnx'.",
"error": "Unsupported file content '746d6c20786d6c6e733d22687474703a'.",
"link": "https://github.com/lutzroeder/netron/issues/458"
},
{
Expand Down Expand Up @@ -198,7 +198,7 @@
"type": "_",
"target": "zip_invalid_archive.zip",
"source": "https://github.com/lutzroeder/netron/files/5468425/zip_invalid_archive.zip",
"error": "Unsupported file content (ff000000000000000000000000000000) for extension '.zip'.",
"error": "Unsupported file content 'ff000000000000000000000000000000'.",
"link": "https://github.com/lutzroeder/netron/issues/250"
},
{
Expand Down

0 comments on commit c5206b5

Please sign in to comment.