Skip to content

Commit 0b91910

Browse files
committed
Moved getClassData function from external_samples_data.ts to python.ts.
1 parent ab01bfc commit 0b91910

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/blocks/mrc_call_python_function.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { createFieldDropdown } from '../fields/FieldDropdown';
3434
import { createFieldNonEditableText } from '../fields/FieldNonEditableText';
3535
import { MRC_STYLE_FUNCTIONS } from '../themes/styles'
3636
import * as toolboxItems from '../toolbox/items';
37-
import { getClassData } from './utils/external_samples_data';
37+
import { getClassData } from './utils/python';
3838
import * as commonStorage from '../storage/common_storage';
3939

4040

src/blocks/utils/external_samples_data.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,3 @@ import { PythonData, ClassData } from './python_json_types';
2323
import generatedExternalSamplesData from './generated/external_samples_data.json';
2424

2525
export const externalSamplesData = generatedExternalSamplesData as PythonData;
26-
27-
export function getClassData(className: string): ClassData | null {
28-
for (const classData of externalSamplesData.classes) {
29-
if (classData.className === className) {
30-
return classData;
31-
}
32-
}
33-
return null;
34-
}

src/blocks/utils/python.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ export function initialize() {
116116
}
117117
}
118118

119+
// Returns the ClassData for the given class name.
120+
export function getClassData(className: string): ClassData | null {
121+
for (const pythonData of allPythonData) {
122+
for (const classData of pythonData.classes) {
123+
if (classData.className === className) {
124+
return classData;
125+
}
126+
}
127+
}
128+
return null;
129+
}
119130

120131
// If the given type is a type alias, returns the value of the type alias.
121132
// For example, if type is 'wpimath.units.nanoseconds', this function will return 'float'

0 commit comments

Comments
 (0)