Skip to content

Commit

Permalink
Merge pull request #157 from hed-standard/merge-conversion
Browse files Browse the repository at this point in the history
Rewrite short/long converter
  • Loading branch information
happy5214 authored Jul 26, 2024
2 parents 9c779b7 + 6905aa2 commit 9a4b907
Show file tree
Hide file tree
Showing 37 changed files with 1,309 additions and 1,510 deletions.
2 changes: 1 addition & 1 deletion bids/tsvParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function parseTSV(contents) {
const rows = stripBOM(normalizeEOL(contents))
.split('\n')
.filter(isContentfulRow)
.map((str) => str.split('\t'))
.map((str) => str.split('\t').map((cell) => cell.trim()))
const headers = rows.length ? rows[0] : []

headers.forEach((x) => {
Expand Down
2 changes: 1 addition & 1 deletion bids/types/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class BidsSidecar extends BidsJsonFile {
const sidecarHedTags = Object.entries(this.jsonData)
.map(([sidecarKey, sidecarValue]) => {
if (sidecarValueHasHed(sidecarValue)) {
return [sidecarKey, new BidsSidecarKey(sidecarKey, sidecarValue.HED)]
return [sidecarKey.trim(), new BidsSidecarKey(sidecarKey.trim(), sidecarValue.HED)]
} else {
return null
}
Expand Down
12 changes: 11 additions & 1 deletion common/issues/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,15 @@ export default {
level: 'error',
message: stringTemplate`"${'tag'}" appears as "${'parentTag'}" and cannot be used as an extension. Indices (${0}, ${1}).`,
},
invalidExtension: {
hedCode: 'TAG_EXTENSION_INVALID',
level: 'error',
message: stringTemplate`"${'tag'}" appears as an extension of "${'parentTag'}", which does not allow tag extensions.`,
},
emptyTagFound: {
hedCode: 'TAG_EMPTY',
level: 'error',
message: stringTemplate`Empty tag cannot be converted.`,
message: stringTemplate`Empty tag at index ${'index'} cannot be converted.`,
},
duplicateTagsInSchema: {
hedCode: 'SCHEMA_DUPLICATE_NODE',
Expand Down Expand Up @@ -309,4 +314,9 @@ export default {
level: 'error',
message: stringTemplate`Unknown HED error "${'internalCode'}" - parameters: "${'parameters'}".`,
},
internalConsistencyError: {
hedCode: 'GENERIC_ERROR',
level: 'error',
message: stringTemplate`Internal consistency error - message: "${'message'}".`,
},
}
11 changes: 2 additions & 9 deletions common/schema/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,6 @@ export class Hed3Schema extends Schema {
* @type {SchemaEntries}
*/
entries
/**
* The mapping between short and long tags.
* @type {Mapping}
*/
mapping
/**
* The standard HED schema version this schema is linked to.
* @type {string}
Expand All @@ -122,9 +117,8 @@ export class Hed3Schema extends Schema {
*
* @param {object} xmlData The schema XML data.
* @param {SchemaEntries} entries A collection of schema entries.
* @param {Mapping} mapping A mapping between short and long tags.
*/
constructor(xmlData, entries, mapping) {
constructor(xmlData, entries) {
super(xmlData)

if (!this.library) {
Expand All @@ -133,7 +127,6 @@ export class Hed3Schema extends Schema {
this.withStandard = xmlData.HED?.$?.withStandard
}
this.entries = entries
this.mapping = mapping
}

/**
Expand Down Expand Up @@ -164,7 +157,7 @@ export class PartneredSchema extends Hed3Schema {
* @param {Hed3Schema} actualSchema The actual HED 3 schema underlying this partnered schema.
*/
constructor(actualSchema) {
super({}, actualSchema.entries, actualSchema.mapping)
super({}, actualSchema.entries)
this.actualSchema = actualSchema
this.withStandard = actualSchema.withStandard
this.library = undefined
Expand Down
Loading

0 comments on commit 9a4b907

Please sign in to comment.