~mars/+junk/pyslow

« back to all changes in this revision

Viewing changes to src/pyslow/profiler.py

  • Committer: Maris Fogels
  • Date: 2010-01-27 15:51:24 UTC
  • Revision ID: maris.fogels@canonical.com-20100127155124-0s0f7fkleg2qbzx9
The INI parser now handles multiline settings strings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
 
115
115
 
116
116
    def _init_pages_to_test_from_ini(self, ini):
117
 
        # The pages to test are stored as a space-separated list.
118
 
        pages = ini.get(self.default_ini_file_section, 'pages_to_test')
119
 
        return pages.split(' ')
 
117
        # The pages to test are stored as a multiline settings var
 
118
        raw_setting = ini.get(self.default_ini_file_section, 'pages_to_test')
 
119
        return split_setting(raw_setting)
120
120
 
121
121
    @classmethod
122
122
    def from_filepath(cls, filepath):
133
133
        return stats
134
134
 
135
135
    def iterstats(self):
136
 
        return iter(self._profiles)
 
 
b'\\ No newline at end of file'
 
136
        return iter(self._profiles)
 
137
 
 
138
 
 
139
def split_setting(setting_string):
 
140
    """A helper that splits multiline INI settings strings into a list.
 
141
 
 
142
    The function also throws out the comment lines for you.
 
143
    """
 
144
    return [line for line in setting_string.split('\n')
 
145
            if line and not line.startswith('#')]
 
 
b'\\ No newline at end of file'