refactor(profile): simplify the generator code
This commit is contained in:
1 parent
64b9f06ff0
commit
8f16160794
1 file changed
+4
-5
+4
-5
@@ -186,8 +186,7 @@ class BaselineProfileGenerator {
|
||||
val fileName = device.executeShellCommand("ls $DOWNLOAD_DIR")
|
||||
.lineSequence()
|
||||
.map(String::trim)
|
||||
.filter { it.endsWith(GZ_SUFFIX) }
|
||||
.firstOrNull()
|
||||
.firstOrNull { it.endsWith(GZ_SUFFIX) }
|
||||
?: error("No $GZ_SUFFIX archives available in $DOWNLOAD_DIR")
|
||||
val archiveBytes = Base64.decode(
|
||||
device.executeShellCommand("base64 $DOWNLOAD_DIR/$fileName")
|
||||
@@ -208,7 +207,7 @@ class BaselineProfileGenerator {
|
||||
val headword = entry?.let(::firstHeadword).orEmpty()
|
||||
if (headword.isNotEmpty()) query = headword
|
||||
} else {
|
||||
refTarget = refTarget ?: firstReference(line)
|
||||
refTarget = firstReference(line)
|
||||
if (refTarget != null) break
|
||||
}
|
||||
}
|
||||
@@ -222,7 +221,7 @@ class BaselineProfileGenerator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the plain target of the first [ref]...[/ref] pair on the line,
|
||||
* Extracts the plain target of the first `[ref]...[/ref]` pair on the line,
|
||||
* dropping any nested DSL tags, so the scenario can follow a real
|
||||
* cross-reference instead of relying on a hardcoded word.
|
||||
*/
|
||||
@@ -307,7 +306,7 @@ class BaselineProfileGenerator {
|
||||
private companion object {
|
||||
val UTF8_BOM = byteArrayOf(0xEF.toByte(), 0xBB.toByte(), 0xBF.toByte())
|
||||
val UTF16_BOM = byteArrayOf(0xFE.toByte(), 0xFF.toByte())
|
||||
val NESTED_TAG_REGEX = Regex("\\[[^\\]]*\\]")
|
||||
val NESTED_TAG_REGEX = Regex("\\[[^]]*]")
|
||||
|
||||
const val DOWNLOAD_DIR = "/sdcard/Download"
|
||||
const val GZ_SUFFIX = ".dsl.gz"
|
||||
|
||||
Reference in new issue
Block a user