Merge lp:~sergiusens/snapcraft/module_name into lp:~snappy-dev/snapcraft/core

Proposed by Sergio Schvezov
Status: Merged
Approved by: Leo Arias
Approved revision: 191
Merged at revision: 191
Proposed branch: lp:~sergiusens/snapcraft/module_name
Merge into: lp:~snappy-dev/snapcraft/core
Diff against target: 130 lines (+6/-16)
12 files modified
integration-tests/data/local-plugin/parts/plugins/x-local-plugin.yaml (+0/-1)
plugins/ant-project.yaml (+0/-1)
plugins/autotools-project.yaml (+0/-1)
plugins/cmake-project.yaml (+0/-1)
plugins/go-project.yaml (+0/-1)
plugins/make-project.yaml (+0/-1)
plugins/maven-project.yaml (+0/-1)
plugins/python2-project.yaml (+0/-1)
plugins/python3-project.yaml (+0/-1)
plugins/tar-content.yaml (+0/-1)
snapcraft/plugin.py (+5/-5)
snapcraft/tests/test_plugin.py (+1/-1)
To merge this branch: bzr merge lp:~sergiusens/snapcraft/module_name
Reviewer Review Type Date Requested Status
Leo Arias (community) Approve
Review via email: mp+271898@code.launchpad.net

Commit message

Remove modules from plugins and infer it from the file name to follow the spec

To post a comment you must log in.
Revision history for this message
Leo Arias (elopio) wrote :

lgtm, all tests pass.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'integration-tests/data/local-plugin/parts/plugins/x-local-plugin.yaml'
2--- integration-tests/data/local-plugin/parts/plugins/x-local-plugin.yaml 2015-07-21 18:18:10 +0000
3+++ integration-tests/data/local-plugin/parts/plugins/x-local-plugin.yaml 2015-09-22 03:09:51 +0000
4@@ -1,1 +0,0 @@
5-module: local_plugin
6
7=== renamed file 'integration-tests/data/local-plugin/parts/plugins/local_plugin.py' => 'integration-tests/data/local-plugin/parts/plugins/x_local_plugin.py'
8=== modified file 'plugins/ant-project.yaml'
9--- plugins/ant-project.yaml 2015-09-18 14:53:03 +0000
10+++ plugins/ant-project.yaml 2015-09-22 03:09:51 +0000
11@@ -1,4 +1,3 @@
12-module: ant_project
13 requires:
14 - jdk
15 options:
16
17=== modified file 'plugins/autotools-project.yaml'
18--- plugins/autotools-project.yaml 2015-09-18 14:53:03 +0000
19+++ plugins/autotools-project.yaml 2015-09-22 03:09:51 +0000
20@@ -1,4 +1,3 @@
21-module: autotools_project
22 build-packages: [autoconf, automake, autopoint]
23 options:
24 source:
25
26=== modified file 'plugins/cmake-project.yaml'
27--- plugins/cmake-project.yaml 2015-09-18 14:53:03 +0000
28+++ plugins/cmake-project.yaml 2015-09-22 03:09:51 +0000
29@@ -1,4 +1,3 @@
30-module: cmake_project
31 build-packages: [cmake]
32 options:
33 source:
34
35=== modified file 'plugins/go-project.yaml'
36--- plugins/go-project.yaml 2015-09-08 18:06:03 +0000
37+++ plugins/go-project.yaml 2015-09-22 03:09:51 +0000
38@@ -1,4 +1,3 @@
39-module: go_project
40 requires:
41 - go
42 options:
43
44=== modified file 'plugins/make-project.yaml'
45--- plugins/make-project.yaml 2015-09-18 14:53:03 +0000
46+++ plugins/make-project.yaml 2015-09-22 03:09:51 +0000
47@@ -1,4 +1,3 @@
48-module: make_project
49 build-packages: [make]
50 options:
51 source:
52
53=== modified file 'plugins/maven-project.yaml'
54--- plugins/maven-project.yaml 2015-09-18 14:53:03 +0000
55+++ plugins/maven-project.yaml 2015-09-22 03:09:51 +0000
56@@ -1,4 +1,3 @@
57-module: maven_project
58 build-packages:
59 - maven
60 requires:
61
62=== modified file 'plugins/python2-project.yaml'
63--- plugins/python2-project.yaml 2015-09-17 15:00:52 +0000
64+++ plugins/python2-project.yaml 2015-09-22 03:09:51 +0000
65@@ -1,4 +1,3 @@
66-module: python2_project
67 requires:
68 - python2
69 options:
70
71=== modified file 'plugins/python3-project.yaml'
72--- plugins/python3-project.yaml 2015-09-08 18:06:03 +0000
73+++ plugins/python3-project.yaml 2015-09-22 03:09:51 +0000
74@@ -1,4 +1,3 @@
75-module: python3_project
76 requires:
77 - python3
78 options:
79
80=== modified file 'plugins/tar-content.yaml'
81--- plugins/tar-content.yaml 2015-09-08 18:06:03 +0000
82+++ plugins/tar-content.yaml 2015-09-22 03:09:51 +0000
83@@ -1,4 +1,3 @@
84-module: tar_content
85 options:
86 source:
87 required: true
88
89=== modified file 'snapcraft/plugin.py'
90--- snapcraft/plugin.py 2015-09-18 21:02:50 +0000
91+++ snapcraft/plugin.py 2015-09-22 03:09:51 +0000
92@@ -119,20 +119,20 @@
93
94 def _load_code(self, name, part_name, properties):
95 options = self._make_options(name, properties)
96- moduleName = self.config.get('module', name)
97+ module_name = name.replace('-', '_')
98
99 # Load code from local plugin dir if it is there
100 if is_local_plugin(name):
101 sys.path = [plugindir(name)] + sys.path
102 else:
103- moduleName = 'snapcraft.plugins.' + moduleName
104+ module_name = 'snapcraft.plugins.' + module_name
105
106- module = importlib.import_module(moduleName)
107+ module = importlib.import_module(module_name)
108 if is_local_plugin(name):
109 sys.path.pop(0)
110
111- for propName in dir(module):
112- prop = getattr(module, propName)
113+ for prop_name in dir(module):
114+ prop = getattr(module, prop_name)
115 if issubclass(prop, snapcraft.BasePlugin):
116 self.code = prop(part_name, options)
117 break
118
119=== modified file 'snapcraft/tests/test_plugin.py'
120--- snapcraft/tests/test_plugin.py 2015-09-17 04:52:11 +0000
121+++ snapcraft/tests/test_plugin.py 2015-09-22 03:09:51 +0000
122@@ -214,7 +214,7 @@
123 """Ensure local plugins are loaded from parts/plugins"""
124 def mock_import_modules(module_name):
125 # called with the name only and sys.path set
126- self.assertEqual(module_name, "x-mock")
127+ self.assertEqual(module_name, "x_mock")
128 self.assertTrue(sys.path[0].endswith("parts/plugins"))
129 return mock_plugin
130 with patch("importlib.import_module", side_effect=mock_import_modules):

Subscribers

People subscribed via source and target branches