Skip to content

confparse.properties.read() doesn't handle single file #1

@GoogleCodeExporter

Description

@GoogleCodeExporter
What steps will reproduce the problem?
1. See inline comments below.
2.
3.

What is the expected output? What do you see instead?
   Stack trace from _read()


What version of the product are you using? On what operating system?
Ubuntu, current version

Please provide any additional information below.
The code
    def read(self,filenames=[]):
        """read and parse the list of named configuration files, given
        by name.  A single filename is also allowed.  Non-existing
        files are ignored.  Return list of successfully read
        files. The filename attribute is update with the last element
        of the list, so that the write methods can be called with no
        argument"""

        if isinstance(filenames, basestring):
            self._read( file(filenames), filenames)
            self.template=filenames
            ###################################################
            # Single file processing falls through to following
            # for loop. Since filenames is a string, the forloop treats
            # each character as a filename.
            #
            # Should be an 'else' before the 'for'
            ###################################################

        for filename in filenames:
            try:
                fp = open(filename)
            except IOError:
                continue
            self._read(fp, filename)
            fp.close()

            self.template=filename

        return self.proxy




Original issue reported on code.google.com by christop...@gmail.com on 24 Mar 2009 at 3:39

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions