mirror of https://github.com/vladmandic/automatic
parent
14c3cf9172
commit
acf475ee45
3261
html/locale_en.json
3261
html/locale_en.json
File diff suppressed because it is too large
Load Diff
|
|
@ -135,6 +135,8 @@ import pydantic # pylint: disable=W0611,C0411
|
|||
timer.startup.record("pydantic")
|
||||
|
||||
try:
|
||||
# transformers==5.x has different dependency stack so switching between v4 and v5 becomes very painful
|
||||
# this temporarily disables dependency version checks so we can use either v4 or v5 until we drop support for v4
|
||||
fake_version_check = types.ModuleType("transformers.dependency_versions_check")
|
||||
sys.modules["transformers.dependency_versions_check"] = fake_version_check # disable transformers version checks
|
||||
fake_version_check.dep_version_check = lambda pkg, hint=None: None
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
const fs = require('fs');
|
||||
|
||||
/**
|
||||
* Custom stringifier that switches to minified format at a specific depth
|
||||
*/
|
||||
const mixedStringify = (data, maxDepth, indent = 2, currentDepth = 0) => {
|
||||
if (currentDepth >= maxDepth) {
|
||||
return JSON.stringify(data);
|
||||
}
|
||||
|
||||
const spacing = ' '.repeat(indent * currentDepth);
|
||||
const nextSpacing = ' '.repeat(indent * (currentDepth + 1));
|
||||
|
||||
if (Array.isArray(data)) {
|
||||
if (data.length === 0) return '[]';
|
||||
const items = data.map((item) => nextSpacing + mixedStringify(item, maxDepth, indent, currentDepth + 1));
|
||||
return `[\n${items.join(',\n')}\n${spacing}]`;
|
||||
}
|
||||
|
||||
if (typeof data === 'object' && data !== null) {
|
||||
const keys = Object.keys(data);
|
||||
if (keys.length === 0) return '{}';
|
||||
const items = keys.map((key) => {
|
||||
const value = mixedStringify(data[key], maxDepth, indent, currentDepth + 1);
|
||||
return `${nextSpacing}"${key}": ${value}`;
|
||||
});
|
||||
return `{\n${items.join(',\n')}\n${spacing}}`;
|
||||
}
|
||||
|
||||
return JSON.stringify(data);
|
||||
};
|
||||
|
||||
// Capture CLI arguments
|
||||
const [,, inputFile, outputFile, maxDepth] = process.argv;
|
||||
console.log(`Input File: ${inputFile}, Output File: ${outputFile}, Max Depth: ${maxDepth}`);
|
||||
|
||||
if (!inputFile || !outputFile || !maxDepth) {
|
||||
console.log('Usage: node reformat.js <input.json> <output.json> <depth>');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
// Read input file
|
||||
const rawData = fs.readFileSync(inputFile, 'utf8');
|
||||
const jsonData = JSON.parse(rawData);
|
||||
|
||||
// Reformat with mixed depth
|
||||
const result = mixedStringify(jsonData, parseInt(maxDepth, 10));
|
||||
|
||||
// Write output file
|
||||
fs.writeFileSync(outputFile, result);
|
||||
console.log(`Success! File saved to ${outputFile} (levels expanded: ${maxDepth})`);
|
||||
} catch (err) {
|
||||
console.error('Error processing JSON:', err.message);
|
||||
}
|
||||
Loading…
Reference in New Issue