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

Proposed by Leo Arias
Status: Merged
Approved by: Michael Terry
Approved revision: 84
Merged at revision: 81
Proposed branch: lp:~elopio/snapcraft/fix1474022-lower_case3
Merge into: lp:~snappy-dev/snapcraft/core
Prerequisite: lp:~elopio/snapcraft/fix1474022-lower_case2
Diff against target: 154 lines (+24/-24)
4 files modified
snapcraft/cmds.py (+2/-2)
snapcraft/plugin.py (+13/-13)
snapcraft/yaml.py (+7/-7)
tests/unit/test_plugin.py (+2/-2)
To merge this branch: bzr merge lp:~elopio/snapcraft/fix1474022-lower_case3
Reviewer Review Type Date Requested Status
Michael Terry (community) Approve
Review via email: mp+264617@code.launchpad.net

Commit message

Refactored all arguments to be lowercase, following pep8.

Description of the change

Still missing: internal variable names.

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

LGTM

review: Approve
Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

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

Still looks fine.

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-14 04:42:49 +0000
3+++ snapcraft/cmds.py 2015-07-14 04:42:49 +0000
4@@ -30,8 +30,8 @@
5 snapcraft.common.log("snapcraft.yaml already exists!", file=sys.stderr)
6 sys.exit(1)
7 yaml = 'parts:\n'
8- for partName in args.part:
9- part = snapcraft.plugin.load_plugin(partName, partName, loadCode=False)
10+ for part_name in args.part:
11+ part = snapcraft.plugin.load_plugin(part_name, part_name, load_code=False)
12 yaml += ' ' + part.names()[0] + ':\n'
13 for opt in part.config.get('options', []):
14 if part.config['options'][opt].get('required', False):
15
16=== modified file 'snapcraft/plugin.py'
17--- snapcraft/plugin.py 2015-07-14 04:42:49 +0000
18+++ snapcraft/plugin.py 2015-07-14 04:42:49 +0000
19@@ -25,7 +25,7 @@
20
21 class Plugin:
22
23- def __init__(self, name, partName, properties, optionsOverride=None, loadCode=True, loadConfig=True):
24+ def __init__(self, name, part_name, properties, options_override=None, load_code=True, load_config=True):
25 self.valid = False
26 self.code = None
27 self.config = None
28@@ -34,14 +34,14 @@
29 self.plugin_name = name
30 self.is_local_plugin = False
31
32- self.sourcedir = os.path.join(os.getcwd(), "parts", partName, "src")
33- self.builddir = os.path.join(os.getcwd(), "parts", partName, "build")
34- self.installdir = os.path.join(os.getcwd(), "parts", partName, "install")
35+ self.sourcedir = os.path.join(os.getcwd(), "parts", part_name, "src")
36+ self.builddir = os.path.join(os.getcwd(), "parts", part_name, "build")
37+ self.installdir = os.path.join(os.getcwd(), "parts", part_name, "install")
38 self.stagedir = os.path.join(os.getcwd(), "stage")
39 self.snapdir = os.path.join(os.getcwd(), "snap")
40- self.statefile = os.path.join(os.getcwd(), "parts", partName, "state")
41+ self.statefile = os.path.join(os.getcwd(), "parts", part_name, "state")
42
43- if loadConfig:
44+ if load_config:
45 # First look in local path
46 localPluginDir = os.path.abspath(os.path.join('parts', 'plugins'))
47 configPath = os.path.join(localPluginDir, name + ".yaml")
48@@ -55,7 +55,7 @@
49 return
50 self.config = yaml.load(open(configPath, 'r')) or {}
51
52- if loadCode:
53+ if load_code:
54 class Options():
55 pass
56 options = Options()
57@@ -69,8 +69,8 @@
58 snapcraft.common.log("Required field %s missing on part %s" % (opt, name), file=sys.stderr)
59 return
60 setattr(options, opt, None)
61- if optionsOverride:
62- options = optionsOverride
63+ if options_override:
64+ options = options_override
65
66 moduleName = self.config.get('module', name)
67
68@@ -88,10 +88,10 @@
69 for propName in dir(module):
70 prop = getattr(module, propName)
71 if issubclass(prop, snapcraft.BasePlugin):
72- self.code = prop(partName, options)
73+ self.code = prop(part_name, options)
74 break
75
76- self.part_names.append(partName)
77+ self.part_names.append(part_name)
78 self.valid = True
79
80 def __str__(self):
81@@ -248,8 +248,8 @@
82 return []
83
84
85-def load_plugin(partName, plugin_name, properties={}, loadCode=True):
86- part = Plugin(plugin_name, partName, properties, loadCode=loadCode)
87+def load_plugin(part_name, plugin_name, properties={}, load_code=True):
88+ part = Plugin(plugin_name, part_name, properties, load_code=load_code)
89 if not part.is_valid():
90 snapcraft.common.log("Could not load part %s" % plugin_name, file=sys.stderr)
91 sys.exit(1)
92
93=== modified file 'snapcraft/yaml.py'
94--- snapcraft/yaml.py 2015-07-14 04:42:49 +0000
95+++ snapcraft/yaml.py 2015-07-14 04:42:49 +0000
96@@ -34,20 +34,20 @@
97 sys.exit(1)
98 self.systemPackages = self.data.get('systemPackages', [])
99
100- for partName in self.data.get("parts", []):
101- properties = self.data["parts"][partName] or {}
102+ for part_name in self.data.get("parts", []):
103+ properties = self.data["parts"][part_name] or {}
104
105- plugin_name = properties.get("plugin", partName)
106+ plugin_name = properties.get("plugin", part_name)
107 if "plugin" in properties:
108 del properties["plugin"]
109
110 if "after" in properties:
111- afterRequests[partName] = properties["after"]
112+ afterRequests[part_name] = properties["after"]
113 del properties["after"]
114
115 # TODO: support 'filter' or 'blacklist' field to filter what gets put in snap/
116
117- self.load_plugin(partName, plugin_name, properties)
118+ self.load_plugin(part_name, plugin_name, properties)
119
120 localPlugins = set()
121 for part in self.all_parts:
122@@ -104,8 +104,8 @@
123 self.all_parts.remove(topPart)
124 self.all_parts = sortedParts
125
126- def load_plugin(self, partName, plugin_name, properties, loadCode=True):
127- part = snapcraft.plugin.load_plugin(partName, plugin_name, properties, loadCode=loadCode)
128+ def load_plugin(self, part_name, plugin_name, properties, load_code=True):
129+ part = snapcraft.plugin.load_plugin(part_name, plugin_name, properties, load_code=load_code)
130
131 self.systemPackages += part.config.get('systemPackages', [])
132 self.all_parts.append(part)
133
134=== modified file 'tests/unit/test_plugin.py'
135--- tests/unit/test_plugin.py 2015-07-13 16:15:03 +0000
136+++ tests/unit/test_plugin.py 2015-07-14 04:42:49 +0000
137@@ -25,7 +25,7 @@
138 class TestPlugin(unittest.TestCase):
139
140 def test_is_dirty(self):
141- p = Plugin("mock", "mock-part", {}, loadConfig=False)
142+ p = Plugin("mock", "mock-part", {}, load_config=False)
143 p.statefile = tempfile.NamedTemporaryFile().name
144 self.addCleanup(os.remove, p.statefile)
145 p.code = mock.Mock()
146@@ -38,7 +38,7 @@
147 self.assertFalse(p.code.pull.called)
148
149 def test_collect_snap_files(self):
150- p = Plugin("mock", "mock-part", {}, loadConfig=False)
151+ p = Plugin("mock", "mock-part", {}, load_config=False)
152
153 tmpdirObject = tempfile.TemporaryDirectory()
154 self.addCleanup(tmpdirObject.cleanup)

Subscribers

People subscribed via source and target branches

to all changes: