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")
|
val fileName = device.executeShellCommand("ls $DOWNLOAD_DIR")
|
||||||
.lineSequence()
|
.lineSequence()
|
||||||
.map(String::trim)
|
.map(String::trim)
|
||||||
.filter { it.endsWith(GZ_SUFFIX) }
|
.firstOrNull { it.endsWith(GZ_SUFFIX) }
|
||||||
.firstOrNull()
|
|
||||||
?: error("No $GZ_SUFFIX archives available in $DOWNLOAD_DIR")
|
?: error("No $GZ_SUFFIX archives available in $DOWNLOAD_DIR")
|
||||||
val archiveBytes = Base64.decode(
|
val archiveBytes = Base64.decode(
|
||||||
device.executeShellCommand("base64 $DOWNLOAD_DIR/$fileName")
|
device.executeShellCommand("base64 $DOWNLOAD_DIR/$fileName")
|
||||||
@@ -208,7 +207,7 @@ class BaselineProfileGenerator {
|
|||||||
val headword = entry?.let(::firstHeadword).orEmpty()
|
val headword = entry?.let(::firstHeadword).orEmpty()
|
||||||
if (headword.isNotEmpty()) query = headword
|
if (headword.isNotEmpty()) query = headword
|
||||||
} else {
|
} else {
|
||||||
refTarget = refTarget ?: firstReference(line)
|
refTarget = firstReference(line)
|
||||||
if (refTarget != null) break
|
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
|
* dropping any nested DSL tags, so the scenario can follow a real
|
||||||
* cross-reference instead of relying on a hardcoded word.
|
* cross-reference instead of relying on a hardcoded word.
|
||||||
*/
|
*/
|
||||||
@@ -307,7 +306,7 @@ class BaselineProfileGenerator {
|
|||||||
private companion object {
|
private companion object {
|
||||||
val UTF8_BOM = byteArrayOf(0xEF.toByte(), 0xBB.toByte(), 0xBF.toByte())
|
val UTF8_BOM = byteArrayOf(0xEF.toByte(), 0xBB.toByte(), 0xBF.toByte())
|
||||||
val UTF16_BOM = byteArrayOf(0xFE.toByte(), 0xFF.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 DOWNLOAD_DIR = "/sdcard/Download"
|
||||||
const val GZ_SUFFIX = ".dsl.gz"
|
const val GZ_SUFFIX = ".dsl.gz"
|
||||||
|
|||||||
Reference in new issue
Block a user