Bug 1288225 - Use PEP 8 style for method names. r=ahal
authorJ. Ryan Stinnett <jryans@gmail.com>
Fri, 22 Jul 2016 17:13:15 -0500
changeset 332212 d865632280ba4212731114d90babce298d79ee6e
parent 332211 4956db508be7ce4971345553cca09c39a1a9f0e4
child 332213 410cc90a90da1146d73bb27b3e3018a5be95db6a
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1288225
milestone50.0a1
Bug 1288225 - Use PEP 8 style for method names. r=ahal MozReview-Commit-ID: 7ci9vAdUw0J
tools/lint/mach_commands.py
--- a/tools/lint/mach_commands.py
+++ b/tools/lint/mach_commands.py
@@ -91,28 +91,28 @@ class MachCommands(MachCommandBase):
                      help='Path to eslint binary.')
     @CommandArgument('args', nargs=argparse.REMAINDER)  # Passed through to eslint.
     def eslint(self, setup, ext=None, binary=None, args=None):
         '''Run eslint.'''
 
         module_path = self.get_eslint_module_path()
 
         # eslint requires at least node 4.2.3
-        nodePath = self.getNodeOrNpmPath("node", LooseVersion("4.2.3"))
+        nodePath = self.get_node_or_npm_path("node", LooseVersion("4.2.3"))
         if not nodePath:
             return 1
 
         if setup:
             return self.eslint_setup()
 
-        npmPath = self.getNodeOrNpmPath("npm")
+        npmPath = self.get_node_or_npm_path("npm")
         if not npmPath:
             return 1
 
-        if self.eslintModuleHasIssues():
+        if self.eslint_module_has_issues():
             install = self._prompt_yn("\nContinuing will automatically fix "
                                       "these issues. Would you like to "
                                       "continue")
             if install:
                 self.eslint_setup()
             else:
                 return 1
 
@@ -173,17 +173,17 @@ class MachCommands(MachCommandBase):
         sys.path.append(os.path.dirname(__file__))
 
         module_path = self.get_eslint_module_path()
 
         # npm sometimes fails to respect cwd when it is run using check_call so
         # we manually switch folders here instead.
         os.chdir(module_path)
 
-        npmPath = self.getNodeOrNpmPath("npm")
+        npmPath = self.get_node_or_npm_path("npm")
         if not npmPath:
             return 1
 
         # Install eslint and necessary plugins.
         for pkg in ESLINT_PACKAGES:
             name, version = pkg.split("@")
             success = False
 
@@ -193,43 +193,43 @@ class MachCommands(MachCommandBase):
                 if pkg.startswith("eslint-plugin-mozilla"):
                     cmd = [npmPath, "install",
                            os.path.join(module_path, "eslint-plugin-mozilla")]
                 else:
                     cmd = [npmPath, "install", pkg]
 
                 print("Installing %s v%s using \"%s\"..."
                       % (name, version, " ".join(cmd)))
-                success = self.callProcess(pkg, cmd)
+                success = self.call_process(pkg, cmd)
 
             if not success:
                 return 1
 
         eslint_path = os.path.join(module_path, "node_modules", ".bin", "eslint")
 
         print("\nESLint and approved plugins installed successfully!")
         print("\nNOTE: Your local eslint binary is at %s\n" % eslint_path)
 
         os.chdir(orig_cwd)
 
-    def callProcess(self, name, cmd, cwd=None):
+    def call_process(self, name, cmd, cwd=None):
         try:
             with open(os.devnull, "w") as fnull:
                 subprocess.check_call(cmd, cwd=cwd, stdout=fnull)
         except subprocess.CalledProcessError:
             if cwd:
                 print("\nError installing %s in the %s folder, aborting." % (name, cwd))
             else:
                 print("\nError installing %s, aborting." % name)
 
             return False
 
         return True
 
-    def eslintModuleHasIssues(self):
+    def eslint_module_has_issues(self):
         has_issues = False
         node_module_path = os.path.join(self.get_eslint_module_path(), "node_modules")
 
         for pkg in ESLINT_PACKAGES:
             name, req_version = pkg.split("@")
             path = os.path.join(node_module_path, name, "package.json")
 
             if not os.path.exists(path):
@@ -242,53 +242,53 @@ class MachCommands(MachCommandBase):
             if data["version"] != req_version:
                 print("%s v%s should be v%s." % (name, data["version"], req_version))
                 has_issues = True
 
         return has_issues
 
     def node_package_installed(self, package_name="", globalInstall=False, cwd=None):
         try:
-            npmPath = self.getNodeOrNpmPath("npm")
+            npmPath = self.get_node_or_npm_path("npm")
 
             cmd = [npmPath, "ls", "--parseable", package_name]
 
             if globalInstall:
                 cmd.append("-g")
 
             with open(os.devnull, "w") as fnull:
                 subprocess.check_call(cmd, stdout=fnull, stderr=fnull, cwd=cwd)
 
             return True
         except subprocess.CalledProcessError:
             return False
 
-    def getPossibleNodePathsWin(self):
+    def get_possible_node_paths_win(self):
         """
         Return possible nodejs paths on Windows.
         """
         if platform.system() != "Windows":
             return []
 
         return list({
             "%s\\nodejs" % os.environ.get("SystemDrive"),
             os.path.join(os.environ.get("ProgramFiles"), "nodejs"),
             os.path.join(os.environ.get("PROGRAMW6432"), "nodejs"),
             os.path.join(os.environ.get("PROGRAMFILES"), "nodejs")
         })
 
-    def getNodeOrNpmPath(self, filename, minversion=None):
+    def get_node_or_npm_path(self, filename, minversion=None):
         """
         Return the nodejs or npm path.
         """
         if platform.system() == "Windows":
             for ext in [".cmd", ".exe", ""]:
                 try:
                     nodeOrNpmPath = which.which(filename + ext,
-                                                path=self.getPossibleNodePathsWin())
+                                                path=self.get_possible_node_paths_win())
                     if self.is_valid(nodeOrNpmPath, minversion):
                         return nodeOrNpmPath
                 except which.WhichError:
                     pass
         else:
             try:
                 nodeOrNpmPath = which.which(filename)
                 if self.is_valid(nodeOrNpmPath, minversion):
@@ -297,17 +297,17 @@ class MachCommands(MachCommandBase):
                 pass
 
         if filename == "node":
             print(NODE_NOT_FOUND_MESSAGE)
         elif filename == "npm":
             print(NPM_NOT_FOUND_MESSAGE)
 
         if platform.system() == "Windows":
-            appPaths = self.getPossibleNodePathsWin()
+            appPaths = self.get_possible_node_paths_win()
 
             for p in appPaths:
                 print("  - %s" % p)
         elif platform.system() == "Darwin":
             print("  - /usr/local/bin/node")
         elif platform.system() == "Linux":
             print("  - /usr/bin/nodejs")