Skip to content

Commit

Permalink
Comment out unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
paullewis committed Feb 29, 2024
1 parent 79295eb commit b61e55a
Showing 1 changed file with 45 additions and 45 deletions.
90 changes: 45 additions & 45 deletions packages/breadboard-web/src/make-graphs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ async function findTsFiles(dir: string): Promise<string[]> {
return tsFiles;
}

async function findPyFiles(dir: string): Promise<string[]> {
const files: Dirent[] = await readdir(dir, { withFileTypes: true });
let pyFiles: string[] = [];
for (const file of files) {
const res: string = path.resolve(dir, file.name);
if (file.isDirectory()) {
pyFiles = pyFiles.concat(await findPyFiles(res));
} else if (file.isFile() && file.name.endsWith(".py")) {
pyFiles.push(res);
}
}
return pyFiles;
}
// async function findPyFiles(dir: string): Promise<string[]> {
// const files: Dirent[] = await readdir(dir, { withFileTypes: true });
// let pyFiles: string[] = [];
// for (const file of files) {
// const res: string = path.resolve(dir, file.name);
// if (file.isDirectory()) {
// pyFiles = pyFiles.concat(await findPyFiles(res));
// } else if (file.isFile() && file.name.endsWith(".py")) {
// pyFiles.push(res);
// }
// }
// return pyFiles;
// }

async function saveBoard(filePath: string): Promise<ManifestItem | undefined> {
try {
Expand Down Expand Up @@ -87,38 +87,38 @@ async function saveBoard(filePath: string): Promise<ManifestItem | undefined> {
}
}

async function savePythonBoard(
filePath: string
): Promise<ManifestItem | undefined> {
try {
const relativePath: string = path.relative(PATH, filePath);
const baseName: string = path.basename(filePath);
const jsonFile: string = baseName.replace(".py", ".json");

// Create corresponding directories based on the relative path
const graphDir: string = path.dirname(path.join(GRAPH_PATH, relativePath));

// Make sure the directories exist
await mkdir(graphDir, { recursive: true });

const jsonPath = path.join(graphDir, jsonFile);
execSync(`python3 ${filePath} ` + jsonPath);
const boardOutput = await readFile(jsonPath);
const graph_descriptor = JSON.parse(
boardOutput.toString()
) as GraphDescriptor;

const manifestEntry: ManifestItem = {
title: graph_descriptor.title ?? "Untitled",
url: `/graphs/${relativePath.replace(".py", ".json")}`,
version: graph_descriptor.version ?? "undefined",
};

return manifestEntry;
} catch (e) {
console.error(`Error loading ${filePath}: ${e}`);
}
}
// async function savePythonBoard(
// filePath: string
// ): Promise<ManifestItem | undefined> {
// try {
// const relativePath: string = path.relative(PATH, filePath);
// const baseName: string = path.basename(filePath);
// const jsonFile: string = baseName.replace(".py", ".json");

// // Create corresponding directories based on the relative path
// const graphDir: string = path.dirname(path.join(GRAPH_PATH, relativePath));

// // Make sure the directories exist
// await mkdir(graphDir, { recursive: true });

// const jsonPath = path.join(graphDir, jsonFile);
// execSync(`python3 ${filePath} ` + jsonPath);
// const boardOutput = await readFile(jsonPath);
// const graph_descriptor = JSON.parse(
// boardOutput.toString()
// ) as GraphDescriptor;

// const manifestEntry: ManifestItem = {
// title: graph_descriptor.title ?? "Untitled",
// url: `/graphs/${relativePath.replace(".py", ".json")}`,
// version: graph_descriptor.version ?? "undefined",
// };

// return manifestEntry;
// } catch (e) {
// console.error(`Error loading ${filePath}: ${e}`);
// }
// }

async function saveAllBoards(): Promise<void> {
const tsFiles = await findTsFiles(PATH);
Expand Down

0 comments on commit b61e55a

Please sign in to comment.