Giter VIP home page Giter VIP logo

pylibconfig2's People

Contributors

heinertholen avatar heinzk1x avatar marbre avatar masteraler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pylibconfig2's Issues

Python3 support

I just installed pylibconfig2 and ran the tests. For python2.7 everything is fine, but the tests fail with python3.3. Assuming the 2 in the package name determines the support python version, the question is if there are any plans to support python3 in future.

parse list of groups

I have difficulties to parse this string due to the coma between each setting.
libconfig manual (page 33) says:

expt_ids:
( 
  { title: "10- or 30-year run initialized in year XXXX", id: "decadalXXXX"},
  { title: "volcano-free hindcast initialized in year XXXX", id: "noVolcXXXX" },
  { title: "prediction with 2010 volcano", id: "volcIn2010" },
  { title: "pre-industrial control", id: "piControl" },
  { title: "historical", id: "historical" },
  { title: "historical extension", id: "historicalExt" },
  { title: "other historical forcing", id: "historicalMisc" },
  { title: "mid-Holocene", id: "midHolocene" },
  { title: "last glacial maximum", id: "lgm" },
  { title: "last millennium", id: "past1000" },
  { title: "RCP4.5", id: "rcp45" },
  { title: "RCP8.5", id: "rcp85" },
  { title: "RCP2.6", id: "rcp26" },
  { title: "RCP6", id: "rcp60" },
  { title: "ESM pre-industrial control", id: "esmControl" },
  { title: "ESM historical", id: "esmHistorical" },
  { title: "ESM RCP8.5", id: "esmrcp85" },
  { title: "ESM fixed climate 1", id: "esmFixClim1" },
  { title: "ESM fixed climate 2", id: "esmFixClim2" },
  { title: "ESM feedback 1", id: "esmFdbk1" },
  { title: "ESM feedback 2", id: "esmFdbk2" },
  { title: "1 percent per year CO2", id: "1pctCO2" },
  { title: "abrupt 4XCO2", id: "abrupt4xCO2" },
  { title: "natural-only", id: "historicalNat" },
  { title: "GHG-only", id: "historicalGHG" },
  { title: "AMIP", id: "amip" },
  { title: "2030 time-slice", id: "sst2030" },
  { title: "control SST climatology", id: "sstClim" },
  { title: "CO2 forcing", id: "sstClim4xCO2" },
  { title: "all aerosol forcing", id: "sstClimAerosol" },
  { title: "sulfate aerosol forcing", id: "sstClimSulfate" },
  { title: "4xCO2 AMIP", id: "amip4xCO2" },
  { title: "AMIP plus patterned anomaly", id: "amipFuture" },
  { title: "aqua planet control", id: "aquaControl" },
  { title: "4xCO2 aqua planet", id: "aqua4xCO2" },
  { title: "aqua planet plus 4K anomaly", id: "aqua4K" },
  { title: "AMIP plus 4K anomaly", id: "amip4K" }
)

lookup() works incorrect with list indexes

_ListType seems to be derived from list, but list indexes definitely start with 0, it could work some other way with the original libconfig library

Try your own example with zero index for array:
>> c = cfg.Config("my_array = [1, 2, 3];")
>> c.lookup('my_array.[0]')

For current right-now usage I just fixed the _lookup as follows:
def _lookup(self, keys):
k = self.array_index.parseString(keys.pop(0))[0]
if k < len(self):

But you could recalculate indexes, so that they would start with 1, but work correct still

lookup returns None for booleans set to False

It seems that c.lookup fails on booleans set to false. I wrote a small example to demonstrate the issue.

import pylibconfig2 as cfg
from pylibconfig2 import conf_types

test = """
simulation =
{
    bool_false = false
    bool_true = true
}
"""


c = cfg.Config(test)

print(c)
print('')
print(c.lookup('simulation.bool_true'))
print(c.lookup('simulation.bool_false'))
print('')
print(c.simulation.bool_true)
print(c.simulation.bool_false)

The out is:

simulation = {
  bool_false = False;
  bool_true = True;
};

True
None

True
False

Also None belongs to falsy values, I think it should be False instead of None.

Parse error on decimal fractions with exponent

Trying:
c = Config(" foo = 'bar'; ")
c.set("val", 1.23e-20)
b = Config(str(c))

leads to gettin parse error "1.23e is not a number" or something similar.

Can be easily fixed in pyparsing.py like the following:
val_num = Combine( Optional(oneOf("+ -")) + Optional("0x") + Word(hexnums + ".eEL" + "-" + nums) )\ .setParseAction(convert_num)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.