Giter VIP home page Giter VIP logo

python-configparser-examples's Issues

TypeError: get() got an unexpected keyword argument 'vars'

`Traceback (most recent call last):
File "/home/cis/projects/bitmessage/py/PyBitmessage/src/tests/test_config.py", line 22, in test_safeGetBoolean
BMConfigParser().safeGetBoolean('nonexistent', 'nonexistent'),
File "/home/cis/projects/bitmessage/py/PyBitmessage/pybitmessage/bmconfigparser.py", line 130, in safeGetBoolean
return self.getboolean(section, field)
File "/usr/lib/python3.7/configparser.py", line 828, in getboolean
raw=raw, vars=vars, fallback=fallback, **kwargs)
File "/usr/lib/python3.7/configparser.py", line 808, in _get_conv
**kwargs)
File "/usr/lib/python3.7/configparser.py", line 802, in _get
return conv(self.get(section, option, **kwargs))
TypeError: get() got an unexpected keyword argument 'vars'

======================================================================
ERROR: test_safeGetInt (src.tests.test_config.TestConfig)
safeGetInt retuns provided default for nonexistent option or 0

Traceback (most recent call last):
File "/home/cis/projects/bitmessage/py/PyBitmessage/src/tests/test_config.py", line 34, in test_safeGetInt
BMConfigParser().safeGetInt('nonexistent', 'nonexistent'), 0)
File "/home/cis/projects/bitmessage/py/PyBitmessage/pybitmessage/bmconfigparser.py", line 148, in safeGetInt
return self.getint(section, field)
File "/usr/lib/python3.7/configparser.py", line 818, in getint
fallback=fallback, **kwargs)
File "/usr/lib/python3.7/configparser.py", line 808, in _get_conv
**kwargs)
File "/usr/lib/python3.7/configparser.py", line 802, in _get
return conv(self.get(section, option, **kwargs))
TypeError: get() got an unexpected keyword argument 'vars'
`

I don't know what exactly the issue is

I am calling function getint like that

self.getint("section", "field")

Not sure what the issue is...

I am attempting to use your examples to pull variables from an .INI file. I am attempting to follow you well written examples and after spending a large amount of time reformatting my entire config file and my entire script, it isn't working.

config file:

[DEFAULT]

status_message = 'Parsing default configuration data...'

...

[OTHERSECTIONNAME]

Python attempt 1 code:

Import global configuration values

global_config = ConfigParser.RawConfigParser()
global_config.read('environments.ini')

DEBUG - Prove that the config file is accessible

print global_config.get('DEFAULT')

attempt 1 error:

print global_config.get('DEFAULT')
TypeError: get() takes exactly 3 arguments (2 given)

Python attempt 2 code:

Import global configuration values

global_config = ConfigParser.RawConfigParser()
global_config.read('environments.ini')

DEBUG - Prove that the config file is accessible

print global_config.get('DEFAULT', 'status_message')

Attempt 2 error:

print global_config.get('DEFAULT', 'status_message')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ConfigParser.py", line 326, in get
ConfigParser.NoOptionError: No option 'status_message' in section: 'DEFAULT'

This is at top level just after the import statements. I attempted to create a class to set this variable but could not figure out how to access it from other classes and methods. This seems very simple. Is this syntax not Python 2.7 compatible maybe?

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.