mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Reformat with scalafmt 3.0.0
This commit is contained in:
@ -19,10 +19,9 @@ sealed trait ConversionResult[F[_]] {
|
||||
|
||||
object ConversionResult {
|
||||
|
||||
/** The conversion is done by external tools that write files to the
|
||||
* file system. These are temporary files and they will be deleted
|
||||
* once the process finishes. This handler is used to do something
|
||||
* relevant with the resulting files.
|
||||
/** The conversion is done by external tools that write files to the file system. These
|
||||
* are temporary files and they will be deleted once the process finishes. This handler
|
||||
* is used to do something relevant with the resulting files.
|
||||
*/
|
||||
type Handler[F[_], A] = Kleisli[F, ConversionResult[F], A]
|
||||
|
||||
|
@ -12,11 +12,10 @@ import scodec.bits.ByteVector
|
||||
@FunctionalInterface
|
||||
trait SanitizeHtml {
|
||||
|
||||
/** The given `bytes' are html which can be modified to strip out
|
||||
* unwanted content.
|
||||
/** The given `bytes' are html which can be modified to strip out unwanted content.
|
||||
*
|
||||
* The result should use the same character encoding as the given
|
||||
* charset implies, or utf8 if not specified.
|
||||
* The result should use the same character encoding as the given charset implies, or
|
||||
* utf8 if not specified.
|
||||
*/
|
||||
def apply(bytes: ByteVector, charset: Option[Charset]): ByteVector
|
||||
|
||||
|
@ -132,7 +132,7 @@ private[extern] object ExternConv {
|
||||
): Pipe[F, Byte, Unit] =
|
||||
in =>
|
||||
Stream
|
||||
.eval(logger.debug(s"Storing input to file ${inFile} for running $name"))
|
||||
.eval(logger.debug(s"Storing input to file $inFile for running $name"))
|
||||
.drain ++
|
||||
Stream.eval(storeFile(in, inFile))
|
||||
|
||||
|
@ -150,12 +150,12 @@ class ConversionTest extends FunSuite with FileChecks {
|
||||
conversion
|
||||
.use { conv =>
|
||||
def check: Handler[IO, Unit] =
|
||||
Kleisli({
|
||||
Kleisli {
|
||||
case ConversionResult.InputMalformed(_, _) =>
|
||||
().pure[IO]
|
||||
case cr =>
|
||||
IO.raiseError(new Exception(s"Unexpected result: $cr"))
|
||||
})
|
||||
}
|
||||
|
||||
runConversion(bombs, _ => check, conv).compile.drain
|
||||
}
|
||||
@ -171,12 +171,12 @@ class ConversionTest extends FunSuite with FileChecks {
|
||||
.emits(uris)
|
||||
.covary[IO]
|
||||
.zipWithIndex
|
||||
.evalMap({ case (uri, index) =>
|
||||
.evalMap { case (uri, index) =>
|
||||
val load = uri.readURL[IO](8192)
|
||||
val dataType = DataType.filename(uri.path.segments.last)
|
||||
logger.info(s"Processing file ${uri.path.asString}") *>
|
||||
conv.toPDF(dataType, Language.German, handler(index))(load)
|
||||
})
|
||||
}
|
||||
|
||||
def commandsExist: Boolean =
|
||||
commandExists(convertConfig.unoconv.command.program) &&
|
||||
|
@ -48,7 +48,7 @@ trait FileChecks {
|
||||
storePdfTxtHandler(file, file.resolveSibling("unexpected.txt")).map(_._1)
|
||||
|
||||
def storePdfTxtHandler(filePdf: Path, fileTxt: Path): Handler[IO, (Path, Path)] =
|
||||
Kleisli({
|
||||
Kleisli {
|
||||
case ConversionResult.SuccessPdfTxt(pdf, txt) =>
|
||||
for {
|
||||
pout <- pdf.through(storeFile(filePdf)).compile.lastOrError
|
||||
@ -64,7 +64,7 @@ trait FileChecks {
|
||||
|
||||
case cr =>
|
||||
throw new Exception(s"Unexpected result: $cr")
|
||||
})
|
||||
}
|
||||
|
||||
def commandExists(cmd: String): Boolean =
|
||||
Runtime.getRuntime.exec(Array("which", cmd)).waitFor() == 0
|
||||
|
Reference in New Issue
Block a user