Merge lp:~elopio/snapcraft/fix1474022-lower_case2 into lp:~snappy-dev/snapcraft/core

Proposed by Leo Arias
Status: Merged
Approved by: Michael Terry
Approved revision: 83
Merged at revision: 79
Proposed branch: lp:~elopio/snapcraft/fix1474022-lower_case2
Merge into: lp:~snappy-dev/snapcraft/core
Prerequisite: lp:~elopio/snapcraft/fix1474022-lower_case
Diff against target: 273 lines (+48/-48)
4 files modified
snapcraft/cmds.py (+3/-3)
snapcraft/plugin.py (+14/-14)
snapcraft/plugins/ubuntu.py (+9/-9)
snapcraft/yaml.py (+22/-22)
To merge this branch: bzr merge lp:~elopio/snapcraft/fix1474022-lower_case2
Reviewer Review Type Date Requested Status
Michael Terry (community) Approve
Review via email: mp+264611@code.launchpad.net

Commit message

Refactored all the attributes to be lowercase, following pep8.

Description of the change

Still missing: arguments and internal variables

To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) wrote :

Noted a change that we don't want to make yet.

review: Needs Fixing
83. By Leo Arias

Revert the change of systemPackages.

Revision history for this message
Leo Arias (elopio) wrote :

done. Thanks for the review.

Revision history for this message
Michael Terry (mterry) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snapcraft/cmds.py'
2--- snapcraft/cmds.py 2015-07-13 16:26:54 +0000
3+++ snapcraft/cmds.py 2015-07-14 04:42:01 +0000
4@@ -181,16 +181,16 @@
5 print("Installing required packages on the host system: " + ", ".join(newPackages))
6 subprocess.call(['sudo', 'apt-get', 'install'] + newPackages, stdout=subprocess.DEVNULL)
7
8- for part in config.allParts:
9+ for part in config.all_parts:
10 for cmd in cmds:
11 if cmd == 'stage':
12 # This ends up running multiple times, as each part gets to its
13 # staging cmd. That's inefficient, but largely OK.
14 # FIXME: fix the above by iterating over cmds before iterating
15- # allParts. But then we need to make sure we continue to handle
16+ # all_parts. But then we need to make sure we continue to handle
17 # cases like go, where you want go built before trying to pull
18 # a go project.
19- if not check_for_collisions(config.allParts):
20+ if not check_for_collisions(config.all_parts):
21 sys.exit(1)
22
23 snapcraft.common.env = config.build_env_for_part(part)
24
25=== modified file 'snapcraft/plugin.py'
26--- snapcraft/plugin.py 2015-07-13 16:15:03 +0000
27+++ snapcraft/plugin.py 2015-07-14 04:42:01 +0000
28@@ -29,10 +29,10 @@
29 self.valid = False
30 self.code = None
31 self.config = None
32- self.partNames = []
33+ self.part_names = []
34 self.deps = []
35- self.pluginName = name
36- self.isLocalPlugin = False
37+ self.plugin_name = name
38+ self.is_local_plugin = False
39
40 self.sourcedir = os.path.join(os.getcwd(), "parts", partName, "src")
41 self.builddir = os.path.join(os.getcwd(), "parts", partName, "build")
42@@ -46,7 +46,7 @@
43 localPluginDir = os.path.abspath(os.path.join('parts', 'plugins'))
44 configPath = os.path.join(localPluginDir, name + ".yaml")
45 if os.path.exists(configPath):
46- self.isLocalPlugin = True
47+ self.is_local_plugin = True
48 else:
49 # OK, now look at snapcraft's plugins
50 configPath = os.path.join(snapcraft.common.plugindir, name + ".yaml")
51@@ -75,14 +75,14 @@
52 moduleName = self.config.get('module', name)
53
54 # Load code from local plugin dir if it is there
55- if self.isLocalPlugin:
56+ if self.is_local_plugin:
57 sys.path = [localPluginDir] + sys.path
58 else:
59 moduleName = 'snapcraft.plugins.' + moduleName
60
61 module = importlib.import_module(moduleName)
62
63- if self.isLocalPlugin:
64+ if self.is_local_plugin:
65 sys.path.pop(0)
66
67 for propName in dir(module):
68@@ -91,14 +91,14 @@
69 self.code = prop(partName, options)
70 break
71
72- self.partNames.append(partName)
73+ self.part_names.append(partName)
74 self.valid = True
75
76 def __str__(self):
77- return self.partNames[0]
78+ return self.part_names[0]
79
80 def __repr__(self):
81- return self.partNames[0]
82+ return self.part_names[0]
83
84 def makedirs(self):
85 try:
86@@ -126,10 +126,10 @@
87 return self.valid
88
89 def names(self):
90- return self.partNames
91+ return self.part_names
92
93 def notify_stage(self, stage, hint=''):
94- snapcraft.common.log(stage + " " + self.partNames[0] + hint)
95+ snapcraft.common.log(stage + " " + self.part_names[0] + hint)
96
97 def is_dirty(self, stage):
98 try:
99@@ -248,9 +248,9 @@
100 return []
101
102
103-def load_plugin(partName, pluginName, properties={}, loadCode=True):
104- part = Plugin(pluginName, partName, properties, loadCode=loadCode)
105+def load_plugin(partName, plugin_name, properties={}, loadCode=True):
106+ part = Plugin(plugin_name, partName, properties, loadCode=loadCode)
107 if not part.is_valid():
108- snapcraft.common.log("Could not load part %s" % pluginName, file=sys.stderr)
109+ snapcraft.common.log("Could not load part %s" % plugin_name, file=sys.stderr)
110 sys.exit(1)
111 return part
112
113=== modified file 'snapcraft/plugins/ubuntu.py'
114--- snapcraft/plugins/ubuntu.py 2015-07-13 16:15:03 +0000
115+++ snapcraft/plugins/ubuntu.py 2015-07-14 04:42:01 +0000
116@@ -25,25 +25,25 @@
117
118 def __init__(self, name, options):
119 super().__init__(name, options)
120- self.downloadablePackages = []
121- self.includedPackages = []
122+ self.downloadable_packages = []
123+ self.included_packages = []
124 if options.package:
125- self.includedPackages.append(options.package)
126+ self.included_packages.append(options.package)
127 else:
128 # User didn't specify a package, use the part name
129 if name == 'ubuntu':
130 snapcraft.common.log("Part %s needs either a package option or a name" % name)
131 sys.exit(1)
132- self.includedPackages.append(name)
133+ self.included_packages.append(name)
134
135 def pull(self):
136- self.downloadablePackages = self.get_all_dep_packages(self.includedPackages)
137- return self.download_debs(self.downloadablePackages)
138+ self.downloadable_packages = self.get_all_dep_packages(self.included_packages)
139+ return self.download_debs(self.downloadable_packages)
140
141 def build(self):
142- if not self.downloadablePackages:
143- self.downloadablePackages = self.get_all_dep_packages(self.includedPackages)
144- return self.unpack_debs(self.downloadablePackages, self.installdir)
145+ if not self.downloadable_packages:
146+ self.downloadable_packages = self.get_all_dep_packages(self.included_packages)
147+ return self.unpack_debs(self.downloadable_packages, self.installdir)
148
149 def snap_files(self):
150 return (['*'], ['/usr/include', '/lib/*/*.a', '/usr/lib/*/*.a'])
151
152=== modified file 'snapcraft/yaml.py'
153--- snapcraft/yaml.py 2015-07-13 16:15:03 +0000
154+++ snapcraft/yaml.py 2015-07-14 04:42:01 +0000
155@@ -24,7 +24,7 @@
156
157 def __init__(self):
158 self.systemPackages = []
159- self.allParts = []
160+ self.all_parts = []
161 afterRequests = {}
162
163 try:
164@@ -37,7 +37,7 @@
165 for partName in self.data.get("parts", []):
166 properties = self.data["parts"][partName] or {}
167
168- pluginName = properties.get("plugin", partName)
169+ plugin_name = properties.get("plugin", partName)
170 if "plugin" in properties:
171 del properties["plugin"]
172
173@@ -47,23 +47,23 @@
174
175 # TODO: support 'filter' or 'blacklist' field to filter what gets put in snap/
176
177- self.load_plugin(partName, pluginName, properties)
178+ self.load_plugin(partName, plugin_name, properties)
179
180 localPlugins = set()
181- for part in self.allParts:
182- if part.isLocalPlugin:
183- localPlugins.add(part.pluginName)
184+ for part in self.all_parts:
185+ if part.is_local_plugin:
186+ localPlugins.add(part.plugin_name)
187 for localPlugin in localPlugins:
188 snapcraft.common.log("Using local plugin %s" % localPlugin)
189
190 # Grab all required dependencies, if not already specified
191- newParts = self.allParts.copy()
192+ newParts = self.all_parts.copy()
193 while newParts:
194 part = newParts.pop(0)
195 requires = part.config.get('requires', [])
196 for requiredPart in requires:
197 alreadyPresent = False
198- for p in self.allParts:
199+ for p in self.all_parts:
200 if requiredPart in p.names():
201 alreadyPresent = True
202 break
203@@ -71,13 +71,13 @@
204 newParts.append(self.load_plugin(requiredPart, requiredPart, {}))
205
206 # Gather lists of dependencies
207- for part in self.allParts:
208+ for part in self.all_parts:
209 depNames = part.config.get('requires', []) + afterRequests.get(part.names()[0], [])
210 for dep in depNames:
211 foundIt = False
212- for i in range(len(self.allParts)):
213- if dep in self.allParts[i].names():
214- part.deps.append(self.allParts[i])
215+ for i in range(len(self.all_parts)):
216+ if dep in self.all_parts[i].names():
217+ part.deps.append(self.all_parts[i])
218 foundIt = True
219 break
220 if not foundIt:
221@@ -86,11 +86,11 @@
222
223 # Now sort them (this is super inefficient, but easy-ish to follow)
224 sortedParts = []
225- while self.allParts:
226+ while self.all_parts:
227 topPart = None
228- for part in self.allParts:
229+ for part in self.all_parts:
230 mentioned = False
231- for other in self.allParts:
232+ for other in self.all_parts:
233 if part in other.deps:
234 mentioned = True
235 break
236@@ -101,14 +101,14 @@
237 snapcraft.common.log("Circular dependency chain!")
238 sys.exit(1)
239 sortedParts = [topPart] + sortedParts
240- self.allParts.remove(topPart)
241- self.allParts = sortedParts
242+ self.all_parts.remove(topPart)
243+ self.all_parts = sortedParts
244
245- def load_plugin(self, partName, pluginName, properties, loadCode=True):
246- part = snapcraft.plugin.load_plugin(partName, pluginName, properties, loadCode=loadCode)
247+ def load_plugin(self, partName, plugin_name, properties, loadCode=True):
248+ part = snapcraft.plugin.load_plugin(partName, plugin_name, properties, loadCode=loadCode)
249
250 self.systemPackages += part.config.get('systemPackages', [])
251- self.allParts.append(part)
252+ self.all_parts.append(part)
253 return part
254
255 def runtime_env(self, root):
256@@ -143,7 +143,7 @@
257
258 env += self.runtime_env(root)
259 env += self.build_env(root)
260- for part in self.allParts:
261+ for part in self.all_parts:
262 env += part.env(root)
263
264 return env
265@@ -153,7 +153,7 @@
266 env = []
267
268 env += self.runtime_env(root)
269- for part in self.allParts:
270+ for part in self.all_parts:
271 env += part.env(root)
272
273 return env

Subscribers

People subscribed via source and target branches

to all changes: