Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfigFactory can't parse single quoted string #79

Open
alexey-terentiev opened this issue Apr 21, 2016 · 2 comments
Open

ConfigFactory can't parse single quoted string #79

alexey-terentiev opened this issue Apr 21, 2016 · 2 comments
Assignees
Labels

Comments

@alexey-terentiev
Copy link

Config:

foo = '-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath='

Code:

from pyhocon import ConfigFactory

config = ConfigFactory.parse_file("test.conf", resolve=False)

Result:

Traceback (most recent call last):
  File "converter.py", line 5, in <module>
    config = ConfigFactory.parse_file("test.conf", resolve=False)
  File "C:\Python27\lib\site-packages\pyhocon\config_parser.py", line 48, in parse_file
    return ConfigFactory.parse_string(content, os.path.dirname(filename), resolve)
  File "C:\Python27\lib\site-packages\pyhocon\config_parser.py", line 87, in parse_string
    return ConfigParser().parse(content, basedir, resolve)
  File "C:\Python27\lib\site-packages\pyhocon\config_parser.py", line 255, in parse
    config = config_expr.parseString(content, parseAll=True)[0]
  File "C:\Python27\lib\site-packages\pyparsing.py", line 1172, in parseString
    raise exc
pyparsing.ParseException: Expected end of text (at char 6), (line:1, col:7)
@darthbear darthbear added the bug label Apr 21, 2016
@darthbear darthbear self-assigned this Apr 21, 2016
@darthbear
Copy link
Member

Hi @alexey-terentiev,

I just tried parsing this file in Scala but it doesn't support single quotes. I can implement this feature but it will have a different behavior than the Scala version.

import com.typesafe.config._
val c = ConfigFactory.load("test.conf", ConfigParseOptions.defaults().setAllowMissing(false), ConfigResolveOptions.defaults())

com.typesafe.config.ConfigException$Parse: test5.conf: 1: Expecting end of input or a comma, got ':' (if you intended ':' to be part of the value for 'foo', try enclosing the value in double quotes, or you may be able to rename the file .properties rather than .conf)
  at com.typesafe.config.impl.Parser$ParseContext.parseError(Parser.java:435)
  at com.typesafe.config.impl.Parser$ParseContext.parseError(Parser.java:431)
  at com.typesafe.config.impl.Parser$ParseContext.parseObject(Parser.java:887)
  at com.typesafe.config.impl.Parser$ParseContext.parse(Parser.java:993)
  at com.typesafe.config.impl.Parser.parse(Parser.java:34)
  at com.typesafe.config.impl.Parseable.rawParseValue(Parseable.java:222)
  at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:602)
  at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:554)
  at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:176)
  at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:170)
  at com.typesafe.config.impl.Parseable.parse(Parseable.java:148)
  at com.typesafe.config.impl.SimpleIncluder.fromBasename(SimpleIncluder.java:172)
  at com.typesafe.config.impl.ConfigImpl.parseResourcesAnySyntax(ConfigImpl.java:128)
  at com.typesafe.config.ConfigFactory.parseResourcesAnySyntax(ConfigFactory.java:811)
  at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:113)
  ... 32 elided

@alexey-terentiev
Copy link
Author

Hi,
If it's designed without single quotes support then it's not a bug, I guess, and can be aborted.
There could be usecases when you might want to totally ignore all special characters and substitutions so this issue could be a very low priority feature request. += and self reference are more important ones :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants