This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def takeWhileR[A](s: Stream[A], f: A => Boolean): Stream[A] = | |
| s.foldRight(Stream[A]())((h, t) => | |
| if (f(h)) Stream(h) #::: t | |
| else Stream.apply()) | |
| def takeWhileL[A](s: Stream[A], f: A => Boolean): Stream[A] = | |
| s.foldLeft(Stream[A]())((t, h) => | |
| if (f(h)) Stream(h) #::: t | |
| else Stream.apply()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.ekrich.config | |
| import java.io.File | |
| import java.nio.file.{Path, Paths} | |
| import java.nio.file.{Files, Paths} | |
| import java.nio.charset.StandardCharsets | |
| object Formatter { | |
| def main(args: Array[String]): Unit = { | |
| println(s"Running HOCON formatter. pwd: ${new File(".").getAbsolutePath}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // bugfix for simplify single entry object rendering | |
| // if you want to understand then compare treating object in corner cases: atRoot and inside an array | |
| if(v.isInstanceOf[SimpleConfigObject]) { | |
| val redact = new jl.StringBuilder() | |
| v.renderValue(redact, indentVal + 1, atRoot, options) | |
| if(options.getConfigFormatOptions.getSimplifyNestedObjects && | |
| redact.charAt(redact.length() - 1) != '}' | |
| ) { | |
| redact.insert(0, "{ ") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import ddpyhocon | |
| def format_hocon(input_file, output_file): | |
| with open(input_file, 'r') as infile: | |
| # Parse the HOCON file into a Python dictionary | |
| config = ddpyhocon.ConfigFactory.parse_file(infile) | |
| with open(output_file, 'w') as outfile: | |
| # Write the formatted HOCON file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.regex.*; | |
| String hocon = """ | |
| include "a.conf" | |
| include file("b.conf") | |
| include required("c.conf") | |
| include required file("bad.conf") | |
| include required "also.bad.conf" | |
| """; |
OlderNewer