import ConfigParser error

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
mister-man
Member
Posts: 70
Joined: Wed Aug 29, 2012 7:09 pm
Location: Germany

import ConfigParser error

Postby mister-man » Thu Jan 16, 2014 2:18 pm

Hay,

I try to import configparser, but it i found an error.
I tried to fix it, but I can't find the error.

MyCode:

Code: Select all

# =============================================================================
# >> IMPORTS
# =============================================================================
# Reads configs or cfg files
import ConfigParser
     

# =============================================================================
# >> CLASSES
# =============================================================================

class inicfg(object):
    def __init__(self, path, file):
        self.__filepath = str(path) + str(file)
        self.__path = path
        self.__file = file
        config = ConfigParser.RawConfigParser()
       
    def addSection(self, section):
        config.add_section(section)
       
    def setKeyvalue(self, section, key, value):
        config.set(section, key, value)
       
    def save(self):
        with open(self.__filepath, 'wb') as configfile:
            config.write(configfile)


Error:

Code: Select all

[SP]  Caught an Exception:
Traceback (most recent call last):
  File '..\addons\source-python\packages\source-python\addons\manager.py', line
48, in __missing__
    instance = _LoadedAddon(addon_name)
  File '..\addons\source-python\packages\source-python\addons\manager.py', line
237, in __init__
    self._addon = __import__(addon_name + '.' + addon_name)
  File '..\addons\source-python\plugins\premium\premium.py', line 26, in <module
>
    from premium._libs import inicfg

ImportError: cannot import name inicfg


[SP] Addon 'premium' was unable to be loaded.
----------

Community of Gamers --> http://c-o-g.de
User avatar
mister-man
Member
Posts: 70
Joined: Wed Aug 29, 2012 7:09 pm
Location: Germany

Postby mister-man » Thu Jan 16, 2014 4:03 pm

I found my misstake, "import ConfigParser" should " import configparser
----------



Community of Gamers --> http://c-o-g.de
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Fri Jan 17, 2014 1:52 am

Just so you know, we already include ConfigObj with SP. I find it much easier to use to parse ini files than configparser. We use it in the translations package within the Python API.

Satoon

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 22 guests