MCPcopy Create free account
hub / github.com/IQEngine/IQEngine / getMetaFromFile

Method getMetaFromFile

client/src/api/metadata/local-client.ts:17–46  ·  view source on GitHub ↗
(
    file: FileWithDirectoryAndFileHandle,
    dataFile: FileWithDirectoryAndFileHandle,
    account: string,
    container: string
  )

Source from the content-addressed store, hash-verified

15 }
16
17 async getMetaFromFile(
18 file: FileWithDirectoryAndFileHandle,
19 dataFile: FileWithDirectoryAndFileHandle,
20 account: string,
21 container: string
22 ) {
23 const fileContent = await file.text();
24 let metadata = Object.assign(new SigMFMetadata(), JSON.parse(fileContent)) as SigMFMetadata;
25 metadata.dataFileHandle = dataFile;
26 metadata.metadataFileHandle = file;
27 const origin: TraceabilityOrigin = metadata.global['traceability:origin'];
28 if (!origin) {
29 metadata.global['traceability:origin'] = {
30 type: 'local',
31 account: account,
32 container: container,
33 file_path: !file.webkitRelativePath
34 ? file.name.replace('.sigmf-meta', '')
35 : file.webkitRelativePath.replace('.sigmf-meta', ''),
36 };
37 }
38
39 if (!metadata.global['traceability:sample_length']) {
40 metadata.global['traceability:sample_length'] = Math.round(dataFile.size / metadata.getBytesPerIQSample());
41 }
42 metadata.annotations = metadata.annotations.map((annotation) => Object.assign(new Annotation(), annotation));
43 metadata.captures = metadata.captures.map((capture) => Object.assign(new CaptureSegment(), capture));
44 console.debug('getMetaFromFile', metadata);
45 return metadata;
46 }
47
48 async getDataSourceMetaPaths(account: string, container: string): Promise<string[]> {
49 if (!this.files) {

Callers 1

getMetaMethod · 0.95

Calls 2

getBytesPerIQSampleMethod · 0.80
textMethod · 0.45

Tested by

no test coverage detected