Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5edc77d0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Apply pylint to conv_linker_config.py"

parents 80f0eb1e 1d4bfd8c
Loading
Loading
Loading
Loading
+148 −145
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ import collections
import json
import os

import linker_config_pb2
import linker_config_pb2 #pylint: disable=import-error
from google.protobuf.descriptor import FieldDescriptor
from google.protobuf.json_format import ParseDict
from google.protobuf.text_format import MessageToString
@@ -54,9 +54,11 @@ def SystemProvide(args):
    def IsInLibPath(lib_name):
        lib_path = os.path.join(args.system, 'lib', lib_name)
        lib64_path = os.path.join(args.system, 'lib64', lib_name)
    return os.path.exists(lib_path) or os.path.islink(lib_path) or os.path.exists(lib64_path) or os.path.islink(lib64_path)
        return os.path.exists(lib_path) or os.path.islink(
            lib_path) or os.path.exists(lib64_path) or os.path.islink(
                lib64_path)

  installed_libraries = list(filter(IsInLibPath, libraries))
    installed_libraries = [lib for lib in libraries if IsInLibPath(lib)]
    for item in installed_libraries:
        if item not in getattr(pb, 'provideLibs'):
            getattr(pb, 'provideLibs').append(item)
@@ -69,7 +71,8 @@ def Append(args):
    with open(args.source, 'rb') as f:
        pb.ParseFromString(f.read())

  if getattr(type(pb), args.key).DESCRIPTOR.label == FieldDescriptor.LABEL_REPEATED:
    if getattr(type(pb),
               args.key).DESCRIPTOR.label == FieldDescriptor.LABEL_REPEATED:
        for value in args.value.split():
            getattr(pb, args.key).append(value)
    else:
@@ -78,6 +81,7 @@ def Append(args):
    with open(args.output, 'wb') as f:
        f.write(pb.SerializeToString())


def Merge(args):
    pb = linker_config_pb2.LinkerConfig()
    for other in args.input:
@@ -87,12 +91,14 @@ def Merge(args):
    with open(args.out, 'wb') as f:
        f.write(pb.SerializeToString())


def GetArgParser():
    parser = argparse.ArgumentParser()
    subparsers = parser.add_subparsers()

    parser_proto = subparsers.add_parser(
      'proto', help='Convert the input JSON configuration file into protobuf.')
        'proto',
        help='Convert the input JSON configuration file into protobuf.')
    parser_proto.add_argument(
        '-s',
        '--source',
@@ -118,7 +124,8 @@ def GetArgParser():
    print_proto.set_defaults(func=Print)

    system_provide_libs = subparsers.add_parser(
      'systemprovide', help='Append system provide libraries into the configuration.')
        'systemprovide',
        help='Append system provide libraries into the configuration.')
    system_provide_libs.add_argument(
        '-s',
        '--source',
@@ -135,12 +142,11 @@ def GetArgParser():
        '--value',
        required=True,
        type=str,
      help='Values of the libraries to append. If there are more than one it should be separated by empty space')
        help='Values of the libraries to append. If there are more than one '
        'it should be separated by empty space'
    )
    system_provide_libs.add_argument(
      '--system',
      required=True,
      type=str,
      help='Path of the system image.')
        '--system', required=True, type=str, help='Path of the system image.')
    system_provide_libs.set_defaults(func=SystemProvide)

    append = subparsers.add_parser(
@@ -157,26 +163,23 @@ def GetArgParser():
        required=True,
        type=str,
        help='Target linker configuration file to write in protobuf.')
  append.add_argument(
      '--key',
      required=True,
      type=str,
      help='.')
    append.add_argument('--key', required=True, type=str, help='.')
    append.add_argument(
        '--value',
        required=True,
        type=str,
      help='Values of the libraries to append. If there are more than one it should be separated by empty space')
        help='Values of the libraries to append. If there are more than one'
        'it should be separated by empty space'
    )
    append.set_defaults(func=Append)

  append = subparsers.add_parser(
      'merge', help='Merge configurations')
    append = subparsers.add_parser('merge', help='Merge configurations')
    append.add_argument(
        '-o',
        '--out',
        required=True,
        type=str,
      help='Ouptut linker configuration file to write in protobuf.')
        help='Output linker configuration file to write in protobuf.')
    append.add_argument(
        '-i',
        '--input',