PyLint fixes for tools-webrtc and webrtc/tools

Fix a lot of errors before bringing in the new config in
https://codereview.webrtc.org/2737963003/

BUG=webrtc:7303
NOTRY=True

Review-Url: https://codereview.webrtc.org/2736233003
Cr-Commit-Position: refs/heads/master@{#17137}
diff --git a/webrtc/examples/androidtests/video_quality_loopback_test.py b/webrtc/examples/androidtests/video_quality_loopback_test.py
index 5ef8537..7c7ef31 100755
--- a/webrtc/examples/androidtests/video_quality_loopback_test.py
+++ b/webrtc/examples/androidtests/video_quality_loopback_test.py
@@ -89,10 +89,10 @@
 
   ffmpeg_path = os.path.join(toolchain_dir, 'linux', 'ffmpeg')
 
-  def convert_video(input_video, output_video):
+  def ConvertVideo(input_video, output_video):
     _RunCommand([ffmpeg_path, '-y', '-i', input_video, output_video])
 
-  convert_video(test_video, test_video_yuv)
+  ConvertVideo(test_video, test_video_yuv)
 
   reference_video = os.path.join(SRC_DIR,
       'resources', 'reference_video_640x360_30fps.y4m')
@@ -100,7 +100,7 @@
   reference_video_yuv = os.path.join(temp_dir,
       'reference_video_640x360_30fps.yuv')
 
-  convert_video(reference_video, reference_video_yuv)
+  ConvertVideo(reference_video, reference_video_yuv)
 
   # Run compare script.
   compare_script = os.path.join(SRC_DIR, 'webrtc', 'tools',
diff --git a/webrtc/tools/barcode_tools/barcode_decoder.py b/webrtc/tools/barcode_tools/barcode_decoder.py
index e615fa8..41164aa 100755
--- a/webrtc/tools/barcode_tools/barcode_decoder.py
+++ b/webrtc/tools/barcode_tools/barcode_decoder.py
@@ -21,7 +21,7 @@
 sys.stderr = sys.stdout
 
 
-def convert_yuv_to_png_files(yuv_file_name, yuv_frame_width, yuv_frame_height,
+def ConvertYuvToPngFiles(yuv_file_name, yuv_frame_width, yuv_frame_height,
                              output_directory, ffmpeg_path):
   """Converts a YUV video file into PNG frames.
 
@@ -61,7 +61,7 @@
   return True
 
 
-def decode_frames(input_directory, zxing_path):
+def DecodeFrames(input_directory, zxing_path):
   """Decodes the barcodes overlaid in each frame.
 
   The function uses the Zxing command-line tool from the Zxing C++ distribution
@@ -85,11 +85,11 @@
   print 'Decoding barcodes from PNG files with %s...' % zxing_path
   return helper_functions.perform_action_on_all_files(
       directory=input_directory, file_pattern='frame_',
-      file_extension='png', start_number=1, action=_decode_barcode_in_file,
+      file_extension='png', start_number=1, action=_DecodeBarcodeInFile,
       command_line_decoder=zxing_path)
 
 
-def _decode_barcode_in_file(file_name, command_line_decoder):
+def _DecodeBarcodeInFile(file_name, command_line_decoder):
   """Decodes the barcode in the upper left corner of a PNG file.
 
   Args:
@@ -116,7 +116,7 @@
   return True
 
 
-def _generate_stats_file(stats_file_name, input_directory='.'):
+def _GenerateStatsFile(stats_file_name, input_directory='.'):
   """Generate statistics file.
 
   The function generates a statistics file. The contents of the file are in the
@@ -128,7 +128,7 @@
   stats_file = open(stats_file_name, 'w')
 
   print 'Generating stats file: %s' % stats_file_name
-  for i in range(1, _count_frames_in(input_directory=input_directory) + 1):
+  for i in range(1, _CountFramesIn(input_directory=input_directory) + 1):
     frame_number = helper_functions.zero_pad(i)
     barcode_file_name = file_prefix + frame_number + '.txt'
     png_frame = file_prefix + frame_number + '.png'
@@ -136,10 +136,10 @@
     entry = 'frame_' + entry_frame_number + ' '
 
     if os.path.isfile(barcode_file_name):
-      barcode = _read_barcode_from_text_file(barcode_file_name)
+      barcode = _ReadBarcodeFromTextFile(barcode_file_name)
       os.remove(barcode_file_name)
 
-      if _check_barcode(barcode):
+      if _CheckBarcode(barcode):
         entry += (helper_functions.zero_pad(int(barcode[0:11])) + '\n')
       else:
         entry += 'Barcode error\n'  # Barcode is wrongly detected.
@@ -152,7 +152,7 @@
   stats_file.close()
 
 
-def _read_barcode_from_text_file(barcode_file_name):
+def _ReadBarcodeFromTextFile(barcode_file_name):
   """Reads the decoded barcode for a .txt file.
 
   Args:
@@ -166,7 +166,7 @@
   return barcode
 
 
-def _check_barcode(barcode):
+def _CheckBarcode(barcode):
   """Check weather the UPC-A barcode was decoded correctly.
 
   This function calculates the check digit of the provided barcode and compares
@@ -200,7 +200,7 @@
   return dsum == int(barcode[11])
 
 
-def _count_frames_in(input_directory='.'):
+def _CountFramesIn(input_directory='.'):
   """Calculates the number of frames in the input directory.
 
   The function calculates the number of frames in the input directory. The
@@ -225,7 +225,7 @@
   return num - 1
 
 
-def _parse_args():
+def _ParseArgs():
   """Registers the command-line options."""
   usage = "usage: %prog [options]"
   parser = optparse.OptionParser(usage=usage)
@@ -256,7 +256,7 @@
   return options
 
 
-def _main():
+def main():
   """The main function.
 
   A simple invocation is:
@@ -265,27 +265,27 @@
   --yuv_frame_width=640 --yuv_frame_height=480
   --stats_file=<path_and_name_to_stats_file>
   """
-  options = _parse_args()
+  options = _ParseArgs()
 
   # Convert the overlaid YUV video into a set of PNG frames.
-  if not convert_yuv_to_png_files(options.yuv_file, options.yuv_frame_width,
-                                  options.yuv_frame_height,
-                                  output_directory=options.png_working_dir,
-                                  ffmpeg_path=options.ffmpeg_path):
+  if not ConvertYuvToPngFiles(options.yuv_file, options.yuv_frame_width,
+                              options.yuv_frame_height,
+                              output_directory=options.png_working_dir,
+                              ffmpeg_path=options.ffmpeg_path):
     print 'An error occurred converting from YUV to PNG frames.'
     return -1
 
   # Decode the barcodes from the PNG frames.
-  if not decode_frames(input_directory=options.png_working_dir,
-                       zxing_path=options.zxing_path):
+  if not DecodeFrames(input_directory=options.png_working_dir,
+                      zxing_path=options.zxing_path):
     print 'An error occurred decoding barcodes from PNG frames.'
     return -2
 
   # Generate statistics file.
-  _generate_stats_file(options.stats_file,
-                       input_directory=options.png_working_dir)
+  _GenerateStatsFile(options.stats_file,
+                     input_directory=options.png_working_dir)
   print 'Completed barcode decoding.'
   return 0
 
 if __name__ == '__main__':
-  sys.exit(_main())
+  sys.exit(main())
diff --git a/webrtc/tools/barcode_tools/barcode_encoder.py b/webrtc/tools/barcode_tools/barcode_encoder.py
index 3a8f354..fb8b04d 100755
--- a/webrtc/tools/barcode_tools/barcode_encoder.py
+++ b/webrtc/tools/barcode_tools/barcode_encoder.py
@@ -17,9 +17,9 @@
 _DEFAULT_BARCODES_FILE = 'barcodes.yuv'
 
 
-def generate_upca_barcodes(number_of_barcodes, barcode_width, barcode_height,
-                           output_directory='.',
-                           path_to_zxing='zxing-read-only'):
+def GenerateUpcaBarcodes(number_of_barcodes, barcode_width, barcode_height,
+                         output_directory='.',
+                         path_to_zxing='zxing-read-only'):
   """Generates UPC-A barcodes.
 
   This function generates a number_of_barcodes UPC-A barcodes. The function
@@ -39,7 +39,7 @@
     (bool): True if the conversion is successful.
   """
   base_file_name = os.path.join(output_directory, "barcode_")
-  jars = _form_jars_string(path_to_zxing)
+  jars = _FormJarsString(path_to_zxing)
   command_line_encoder = 'com.google.zxing.client.j2se.CommandLineEncoder'
   barcode_width = str(barcode_width)
   barcode_height = str(barcode_height)
@@ -64,7 +64,7 @@
   return not errors
 
 
-def convert_png_to_yuv_barcodes(input_directory='.', output_directory='.'):
+def ConvertPngToYuvBarcodes(input_directory='.', output_directory='.'):
   """Converts PNG barcodes to YUV barcode images.
 
   This function reads all the PNG files from the input directory which are in
@@ -79,11 +79,11 @@
     (bool): True if the conversion was without errors.
   """
   return helper_functions.perform_action_on_all_files(
-      input_directory, 'barcode_', 'png', 0, _convert_to_yuv_and_delete,
+      input_directory, 'barcode_', 'png', 0, _ConvertToYuvAndDelete,
       output_directory=output_directory, pattern='barcode_')
 
 
-def _convert_to_yuv_and_delete(output_directory, file_name, pattern):
+def _ConvertToYuvAndDelete(output_directory, file_name, pattern):
   """Converts a PNG file to a YUV file and deletes the PNG file.
 
   Args:
@@ -116,7 +116,7 @@
   return True
 
 
-def combine_yuv_frames_into_one_file(output_file_name, input_directory='.'):
+def CombineYuvFramesIntoOneFile(output_file_name, input_directory='.'):
   """Combines several YUV frames into one YUV video file.
 
   The function combines the YUV frames from input_directory into one YUV video
@@ -132,12 +132,12 @@
   """
   output_file = open(output_file_name, "wb")
   success = helper_functions.perform_action_on_all_files(
-      input_directory, 'barcode_', 'yuv', 0, _add_to_file_and_delete,
+      input_directory, 'barcode_', 'yuv', 0, _AddToFileAndDelete,
       output_file=output_file)
   output_file.close()
   return success
 
-def _add_to_file_and_delete(output_file, file_name):
+def _AddToFileAndDelete(output_file, file_name):
   """Adds the contents of a file to a previously opened file.
 
   Args:
@@ -159,9 +159,9 @@
   return True
 
 
-def _overlay_barcode_and_base_frames(barcodes_file, base_file, output_file,
-                                     barcodes_component_sizes,
-                                     base_component_sizes):
+def _OverlayBarcodeAndBaseFrames(barcodes_file, base_file, output_file,
+                                 barcodes_component_sizes,
+                                 base_component_sizes):
   """Overlays the next YUV frame from a file with a barcode.
 
   Args:
@@ -201,8 +201,8 @@
   return True
 
 
-def overlay_yuv_files(barcode_width, barcode_height, base_width, base_height,
-                      barcodes_file_name, base_file_name, output_file_name):
+def OverlayYuvFiles(barcode_width, barcode_height, base_width, base_height,
+                    barcodes_file_name, base_file_name, output_file_name):
   """Overlays two YUV files starting from the upper left corner of both.
 
   Args:
@@ -230,17 +230,17 @@
 
   data_left = True
   while data_left:
-    data_left = _overlay_barcode_and_base_frames(barcodes_file, base_file,
-                                                 output_file,
-                                                 barcodes_component_sizes,
-                                                 base_component_sizes)
+    data_left = _OverlayBarcodeAndBaseFrames(barcodes_file, base_file,
+                                             output_file,
+                                             barcodes_component_sizes,
+                                             base_component_sizes)
 
   barcodes_file.close()
   base_file.close()
   output_file.close()
 
 
-def calculate_frames_number_from_yuv(yuv_width, yuv_height, file_name):
+def CalculateFramesNumberFromYuv(yuv_width, yuv_height, file_name):
   """Calculates the number of frames of a YUV video.
 
   Args:
@@ -258,7 +258,7 @@
   return int(file_size/frame_size)  # Should be int anyway
 
 
-def _form_jars_string(path_to_zxing):
+def _FormJarsString(path_to_zxing):
   """Forms the the Zxing core and javase jars argument.
 
   Args:
@@ -273,7 +273,7 @@
     delimiter = ';'
   return javase_jar + delimiter + core_jar
 
-def _parse_args():
+def _ParseArgs():
   """Registers the command-line options."""
   usage = "usage: %prog [options]"
   parser = optparse.OptionParser(usage=usage)
@@ -320,7 +320,7 @@
   return options
 
 
-def _main():
+def main():
   """The main function.
 
   A simple invocation will be:
@@ -329,7 +329,7 @@
   --base_yuv=<path_and_name_of_base_file>
   --output_yuv=<path and name_of_output_file>
   """
-  options = _parse_args()
+  options = _ParseArgs()
   # The barcodes with will be different than the base frame width only if
   # explicitly specified at the command line.
   if options.barcode_width == _DEFAULT_BARCODE_WIDTH:
@@ -342,26 +342,26 @@
 
   # Calculate the number of barcodes - it is equal to the number of frames in
   # the base file.
-  number_of_barcodes = calculate_frames_number_from_yuv(
+  number_of_barcodes = CalculateFramesNumberFromYuv(
       options.base_frame_width, options.base_frame_height, options.base_yuv)
 
   script_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
   zxing_dir = os.path.join(script_dir, 'third_party', 'zxing')
   # Generate barcodes - will generate them in PNG.
-  generate_upca_barcodes(number_of_barcodes, options.barcode_width,
-                         options.barcode_height,
-                         output_directory=options.png_barcodes_output_dir,
-                         path_to_zxing=zxing_dir)
+  GenerateUpcaBarcodes(number_of_barcodes, options.barcode_width,
+                       options.barcode_height,
+                       output_directory=options.png_barcodes_output_dir,
+                       path_to_zxing=zxing_dir)
   # Convert the PNG barcodes to to YUV format.
-  convert_png_to_yuv_barcodes(options.png_barcodes_input_dir,
-                              options.yuv_barcodes_output_dir)
+  ConvertPngToYuvBarcodes(options.png_barcodes_input_dir,
+                          options.yuv_barcodes_output_dir)
   # Combine the YUV barcodes into one YUV file.
-  combine_yuv_frames_into_one_file(options.barcodes_yuv,
-                                   input_directory=options.yuv_frames_input_dir)
+  CombineYuvFramesIntoOneFile(options.barcodes_yuv,
+                              input_directory=options.yuv_frames_input_dir)
   # Overlay the barcodes over the base file.
-  overlay_yuv_files(options.barcode_width, options.barcode_height,
-                    options.base_frame_width, options.base_frame_height,
-                    options.barcodes_yuv, options.base_yuv, options.output_yuv)
+  OverlayYuvFiles(options.barcode_width, options.barcode_height,
+                  options.base_frame_width, options.base_frame_height,
+                  options.barcodes_yuv, options.base_yuv, options.output_yuv)
 
   if not keep_barcodes_yuv_file:
     # Remove the temporary barcodes YUV file
@@ -369,4 +369,4 @@
 
 
 if __name__ == '__main__':
-  sys.exit(_main())
+  sys.exit(main())
diff --git a/webrtc/tools/barcode_tools/build_zxing.py b/webrtc/tools/barcode_tools/build_zxing.py
index 466bd50..92696a7 100755
--- a/webrtc/tools/barcode_tools/build_zxing.py
+++ b/webrtc/tools/barcode_tools/build_zxing.py
@@ -12,7 +12,7 @@
 import sys
 
 
-def run_ant_build_command(path_to_ant_build_file):
+def RunAntBuildCommand(path_to_ant_build_file):
   """Tries to build the passed build file with ant."""
   ant_executable = 'ant'
   if sys.platform == 'win32':
@@ -32,13 +32,13 @@
                                                                 e)
     return -1
 
-def _main():
+def main():
   core_build = os.path.join('third_party', 'zxing', 'core', 'build.xml')
-  run_ant_build_command(core_build)
+  RunAntBuildCommand(core_build)
 
   javase_build = os.path.join('third_party', 'zxing', 'javase', 'build.xml')
-  return run_ant_build_command(javase_build)
+  return RunAntBuildCommand(javase_build)
 
 
 if __name__ == '__main__':
-  sys.exit(_main())
+  sys.exit(main())
diff --git a/webrtc/tools/barcode_tools/helper_functions.py b/webrtc/tools/barcode_tools/helper_functions.py
index fb9854f8..e27322f 100644
--- a/webrtc/tools/barcode_tools/helper_functions.py
+++ b/webrtc/tools/barcode_tools/helper_functions.py
@@ -20,7 +20,7 @@
   pass
 
 
-def zero_pad(number, padding=_DEFAULT_PADDING):
+def ZeroPad(number, padding=_DEFAULT_PADDING):
   """Converts an int into a zero padded string.
 
   Args:
@@ -35,7 +35,7 @@
   return str(number).zfill(padding)
 
 
-def run_shell_command(cmd_list, fail_msg=None):
+def RunShellCommand(cmd_list, fail_msg=None):
   """Executes a command.
 
   Args:
@@ -60,8 +60,8 @@
   return output.strip()
 
 
-def perform_action_on_all_files(directory, file_pattern, file_extension,
-                                start_number, action, **kwargs):
+def PerformActionOnAllFiles(directory, file_pattern, file_extension,
+                            start_number, action, **kwargs):
   """Function that performs a given action on all files matching a pattern.
 
   It is assumed that the files are named file_patternxxxx.file_extension, where
@@ -86,7 +86,7 @@
   process_pool = multiprocessing.Pool(processes=multiprocessing.cpu_count())
   results = []
   while True:
-    zero_padded_file_number = zero_pad(file_number)
+    zero_padded_file_number = ZeroPad(file_number)
     file_name = file_prefix + zero_padded_file_number + '.' + file_extension
     if not os.path.isfile(file_name):
       break
diff --git a/webrtc/tools/barcode_tools/yuv_cropper.py b/webrtc/tools/barcode_tools/yuv_cropper.py
index c57a90d..609f07d 100755
--- a/webrtc/tools/barcode_tools/yuv_cropper.py
+++ b/webrtc/tools/barcode_tools/yuv_cropper.py
@@ -12,7 +12,7 @@
 import sys
 
 
-def _crop_one_frame(yuv_file, output_file, component_sizes):
+def _CropOneFrame(yuv_file, output_file, component_sizes):
   """Crops one frame.
 
   This function crops one frame going through all the YUV planes and cropping
@@ -44,7 +44,7 @@
   return True
 
 
-def crop_frames(yuv_file_name, output_file_name, width, height, crop_height):
+def CropFrames(yuv_file_name, output_file_name, width, height, crop_height):
   """Crops rows of pixels from the top of the YUV frames.
 
   This function goes through all the frames in a video and crops the crop_height
@@ -69,13 +69,13 @@
 
   data_left = True
   while data_left:
-    data_left = _crop_one_frame(yuv_file, output_file, component_sizes)
+    data_left = _CropOneFrame(yuv_file, output_file, component_sizes)
 
   yuv_file.close()
   output_file.close()
 
 
-def _parse_args():
+def _ParseArgs():
   """Registers the command-line options."""
   usage = "usage: %prog [options]"
   parser = optparse.OptionParser(usage=usage)
@@ -101,7 +101,7 @@
   return options
 
 
-def _main():
+def main():
   """A tool to crop rows of pixels from the top part of a YUV file.
 
   A simple invocation will be:
@@ -109,17 +109,17 @@
   --yuv_file=<path_and_name_of_yuv_file>
   --output_yuv=<path and name_of_output_file>
   """
-  options = _parse_args()
+  options = _ParseArgs()
 
   if os.path.getsize(options.yuv_file) == 0:
     sys.stderr.write('Error: The YUV file you have passed has size 0. The '
                      'produced output will also have size 0.\n')
     return -1
 
-  crop_frames(options.yuv_file, options.output_file, options.width,
-              options.height, options.crop_height)
+  CropFrames(options.yuv_file, options.output_file, options.width,
+             options.height, options.crop_height)
   return 0
 
 
 if __name__ == '__main__':
-  sys.exit(_main())
+  sys.exit(main())