~longsleep/snapcraft/snapcraft-debs-plugin

« back to all changes in this revision

Viewing changes to snapcraft/yaml.py

  • Committer: Snappy Tarmac
  • Author(s): Daniel Holbach, Leo Arias
  • Date: 2015-10-05 19:54:20 UTC
  • mfrom: (231.1.9 fix-pep8-and-doc-indentation)
  • Revision ID: snappy_tarmac-20151005195420-w1ql5nndj5413sb5
Fix markdown indentation, make pep8 and pyflakes3 happy. by elopio approved by elopio

Show diffs side-by-side

added added

removed removed

Lines of Context:
145
145
                        present = True
146
146
                        break
147
147
                if not present:
148
 
                    new_parts.append(self.load_plugin(required_part, required_part, {}))
 
148
                    new_parts.append(self.load_plugin(required_part,
 
149
                                                      required_part, {}))
149
150
 
150
151
    def _compute_part_dependencies(self, after_requests):
151
152
        '''Gather the lists of dependencies and adds to all_parts.'''
152
153
        w = snapcraft.wiki.Wiki()
153
154
 
154
155
        for part in self.all_parts:
155
 
            dep_names = part.config.get('requires', []) + after_requests.get(part.names()[0], [])
 
156
            dep_names = part.config.get('requires', []) + \
 
157
                after_requests.get(part.names()[0], [])
156
158
            for dep in dep_names:
157
159
                found = False
158
160
                for i in range(len(self.all_parts)):
164
166
                    wiki_part = w.get_part(dep)
165
167
                    found = True if wiki_part else False
166
168
                    if found:
167
 
                        part.deps.append(self.load_plugin(dep, wiki_part['plugin'], wiki_part))
 
169
                        part.deps.append(self.load_plugin(
 
170
                            dep, wiki_part['plugin'], wiki_part))
168
171
                if not found:
169
 
                    raise SnapcraftLogicError('part name missing {}'.format(dep))
 
172
                    raise SnapcraftLogicError(
 
173
                        'part name missing {}'.format(dep))
170
174
 
171
175
    def _sort_parts(self):
172
176
        '''Performs an inneficient but easy to follow sorting of parts.'''
184
188
                    top_part = part
185
189
                    break
186
190
            if not top_part:
187
 
                raise SnapcraftLogicError('circular dependency chain found in parts definition')
 
191
                raise SnapcraftLogicError(
 
192
                    'circular dependency chain found in parts definition')
188
193
            sorted_parts = [top_part] + sorted_parts
189
194
            self.all_parts.remove(top_part)
190
195
 
191
196
        return sorted_parts
192
197
 
193
198
    def load_plugin(self, part_name, plugin_name, properties, load_code=True):
194
 
        part = snapcraft.plugin.load_plugin(part_name, plugin_name, properties, load_code=load_code)
 
199
        part = snapcraft.plugin.load_plugin(part_name, plugin_name,
 
200
                                            properties, load_code=load_code)
195
201
 
196
202
        self.build_tools += part.config.get('build-packages', [])
197
203
        self.all_parts.append(part)
280
286
 
281
287
 
282
288
def _validate_snapcraft_yaml(snapcraft_yaml):
283
 
    schema_file = os.path.abspath(os.path.join(common.get_schemadir(), 'snapcraft.yaml'))
 
289
    schema_file = os.path.abspath(os.path.join(common.get_schemadir(),
 
290
                                               'snapcraft.yaml'))
284
291
 
285
292
    try:
286
293
        with open(schema_file) as fp:
287
294
            schema = yaml.load(fp)
288
295
            format_check = jsonschema.FormatChecker()
289
 
            jsonschema.validate(snapcraft_yaml, schema, format_checker=format_check)
 
296
            jsonschema.validate(snapcraft_yaml, schema,
 
297
                                format_checker=format_check)
290
298
    except FileNotFoundError:
291
 
        raise SnapcraftSchemaError('snapcraft validation file is missing from installation path')
 
299
        raise SnapcraftSchemaError(
 
300
            'snapcraft validation file is missing from installation path')
292
301
    except jsonschema.ValidationError as e:
293
302
        raise SnapcraftSchemaError(e.message)
294
303