Exemplo n.º 1
0
    def __init__(self, dlconfig=None):
        super(DownloadConfigInterface, self).__init__()

        self.dlconfig = dlconfig or CallbackConfigParser()

        # Dumb^WPoor man's versioning of DownloadConfig, add missing default values.
        write = False
        for section, sect_dict in dldefaults.iteritems():
            if not self.dlconfig.has_section(section):
                self.dlconfig.add_section(section)
            for k, v in sect_dict.iteritems():
                if not self.dlconfig.has_option(section, k):
                    write = True
                    self.dlconfig.set(section, k, v)

        if write and self.dlconfig.filename:
            self.dlconfig.write_file()

        if dlconfig:
            # TODO(emilon): I guess this can be removed?
            # modify/fix incorrectly saved dlconfigs
            if dlconfig.has_option('downloadconfig', 'saveas') and isinstance(
                    dlconfig.get('downloadconfig', 'saveas'), tuple):
                dlconfig.set('downloadconfig', 'saveas',
                             dlconfig.get('saveas')[-1])
Exemplo n.º 2
0
    def __init__(self, dlconfig=None):
        super(DownloadConfigInterface, self).__init__()

        self.dlconfig = dlconfig or CallbackConfigParser()

        # Dumb^WPoor man's versioning of DownloadConfig, add missing default values.
        write = False
        for section, sect_dict in dldefaults.iteritems():
            if not self.dlconfig.has_section(section):
                self.dlconfig.add_section(section)
            for k, v in sect_dict.iteritems():
                if not self.dlconfig.has_option(section, k):
                    write = True
                    self.dlconfig.set(section, k, v)

        if write and self.dlconfig.filename:
            self.dlconfig.write_file()
Exemplo n.º 3
0
    def __init__(self, dlconfig=None):
        super(DownloadConfigInterface, self).__init__()

        self.dlconfig = dlconfig or CallbackConfigParser()

        # Dumb^WPoor man's versioning of DownloadConfig, add missing default values.
        write = False
        for section, sect_dict in dldefaults.iteritems():
            if not self.dlconfig.has_section(section):
                self.dlconfig.add_section(section)
            for k, v in sect_dict.iteritems():
                if not self.dlconfig.has_option(section, k):
                    write = True
                    self.dlconfig.set(section, k, v)

        if write and self.dlconfig.filename:
            self.dlconfig.write_file()
Exemplo n.º 4
0
    def __init__(self, dlconfig=None):
        super(DownloadConfigInterface, self).__init__()

        self.dlconfig = dlconfig or CallbackConfigParser()

        # Dumb^WPoor man's versioning of DownloadConfig, add missing default values.
        write = False
        for section, sect_dict in dldefaults.iteritems():
            if not self.dlconfig.has_section(section):
                self.dlconfig.add_section(section)
            for k, v in sect_dict.iteritems():
                if not self.dlconfig.has_option(section, k):
                    write = True
                    self.dlconfig.set(section, k, v)

        if write and self.dlconfig.filename:
            self.dlconfig.write_file()

        if dlconfig:
            # TODO(emilon): I guess this can be removed?
            # modify/fix incorrectly saved dlconfigs
            if dlconfig.has_option('downloadconfig', 'saveas') and isinstance(dlconfig.get('downloadconfig', 'saveas'), tuple):
                dlconfig.set('downloadconfig', 'saveas', dlconfig.get('saveas')[-1])
# see LICENSE.txt for license information

import sys
import wx
import os

from cStringIO import StringIO

from ConfigParser import ConfigParser, MissingSectionHeaderError, NoSectionError, ParsingError, DEFAULTSECT

from Tribler.Core.Utilities.bencode import bencode, bdecode
from Tribler.Core.defaults import dldefaults, DEFAULTPORT

# TODO: remove these defaults, config doesn't work this way with Tribler Core.
bt1_defaults = []
for k, v in dldefaults.iteritems():
    bt1_defaults.append((k, v, "See triblerAPI"))

DEBUG = False


################################################################
#
# Class: ConfigReader
#
# Extension of ConfigParser that supports various types of
# config values.  Values are converted to strings when writing
# and back into their respective types when reading.
#
################################################################
class ConfigReader(ConfigParser):
Exemplo n.º 6
0
# see LICENSE.txt for license information

import sys
import wx
import os

from cStringIO import StringIO

from ConfigParser import ConfigParser, MissingSectionHeaderError, NoSectionError, ParsingError, DEFAULTSECT

from Tribler.Core.BitTornado.bencode import bencode, bdecode
from Tribler.Core.defaults import dldefaults,DEFAULTPORT

# TODO: remove these defaults, config doesn't work this way with Tribler Core.
bt1_defaults = []
for k,v in dldefaults.iteritems():
    bt1_defaults.append((k,v,"See triblerAPI"))

DEBUG = False

################################################################
#
# Class: ConfigReader
#
# Extension of ConfigParser that supports various types of
# config values.  Values are converted to strings when writing
# and back into their respective types when reading.
#
################################################################
class ConfigReader(ConfigParser):
    def __init__(self, filename, section, defaults = None):