Esempio n. 1
0
def get_entrypoints(filename):
    if not os.path.exists(filename):
        return {}, {}

    # This is done because you can pass a string to entry_points wrappers which
    # means that they may or may not be valid INI files. The attempt here is to
    # strip leading and trailing whitespace in order to make them valid INI
    # files.
    with open(filename) as fp:
        data = StringIO()
        for line in fp:
            data.write(line.strip())
            data.write("\n")
        data.seek(0)

    cp = ConfigParser.RawConfigParser()
    cp.readfp(data)

    console = {}
    gui = {}
    if cp.has_section('console_scripts'):
        console = dict(cp.items('console_scripts'))
    if cp.has_section('gui_scripts'):
        gui = dict(cp.items('gui_scripts'))
    return console, gui
Esempio n. 2
0
 def __init__(self, *args, **kwargs):
     self.config = ConfigParser.RawConfigParser()
     self.name = kwargs.pop('name')
     self.files = self.get_config_files()
     self.config.read(self.files)
     assert self.name
     optparse.OptionParser.__init__(self, *args, **kwargs)