org.jetbrains.jupyter.parser.notebook.CellMetadata.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jupyter-notebooks-parser Show documentation
Show all versions of jupyter-notebooks-parser Show documentation
Jupyter Notebooks parser and Kotlin utilities for them
The newest version!
package org.jetbrains.jupyter.parser.notebook
import kotlinx.serialization.json.JsonObject
public abstract class CellMetadata {
public abstract val name: String?
public abstract val tags: Set?
public abstract val jupyter: JsonObject?
init {
validate()
}
private fun validate() {
name?.let {
require(CELL_METADATA_NAME_REGEX.containsMatchIn(it)) { "name does not match pattern $CELL_METADATA_NAME_REGEX - $it" }
}
tags?.let {
for (tag in it)
require(CELL_METADATA_TAGS_REGEX.containsMatchIn(tag)) { "tags item does not match pattern $CELL_METADATA_TAGS_REGEX - $tag" }
}
}
private companion object {
private val CELL_METADATA_NAME_REGEX = Regex("^.+$")
private val CELL_METADATA_TAGS_REGEX = Regex("^[^,]+$")
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy