summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjnozsc <jnozsc@gmail.com>2020-02-27 11:46:42 -0800
committerwm4 <1387750+wm4@users.noreply.github.com>2020-02-27 21:36:21 +0100
commit611c92ef1db2efa5c2f548c8ae3aa4072bbe67a8 (patch)
treec67b4d00cacf7576690e3e23ebc4f366a27aaed2
parentc4440db7448ab8b64103af46e7ffb38e3e57bc0e (diff)
downloadmpv-611c92ef1db2efa5c2f548c8ae3aa4072bbe67a8.tar.bz2
mpv-611c92ef1db2efa5c2f548c8ae3aa4072bbe67a8.tar.xz
*.py: cosmetic changes
-rwxr-xr-xTOOLS/matroska.py2
-rwxr-xr-xTOOLS/osxbundle.py4
-rwxr-xr-xTOOLS/stats-conv.py4
-rw-r--r--waftools/checks/generic.py2
-rw-r--r--waftools/clang_compilation_database.py2
-rw-r--r--waftools/dependencies.py2
-rw-r--r--waftools/detections/compiler.py2
-rw-r--r--waftools/detections/compiler_swift.py52
-rw-r--r--waftools/features.py2
9 files changed, 40 insertions, 32 deletions
diff --git a/TOOLS/matroska.py b/TOOLS/matroska.py
index 0e447bc5ea..2c1b751a54 100755
--- a/TOOLS/matroska.py
+++ b/TOOLS/matroska.py
@@ -276,7 +276,7 @@ class MatroskaElement(object):
def add_subelements(self, subelements):
self.subelements = subelements
- self.subids = set(x[0].elid for x in subelements)
+ self.subids = {x[0].elid for x in subelements}
elementd = {}
elementlist = []
diff --git a/TOOLS/osxbundle.py b/TOOLS/osxbundle.py
index 49a0a98e53..f164b2b3b1 100755
--- a/TOOLS/osxbundle.py
+++ b/TOOLS/osxbundle.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-
+from __future__ import print_function
import os
import shutil
import sys
@@ -37,7 +37,7 @@ def copy_binary(binary_name):
def apply_plist_template(plist_file, version):
for line in fileinput.input(plist_file, inplace=1):
- print (line.rstrip().replace('${VERSION}', version))
+ print(line.rstrip().replace('${VERSION}', version))
def create_bundle_symlink(binary_name, symlink_name):
os.symlink(os.path.basename(binary_name),
diff --git a/TOOLS/stats-conv.py b/TOOLS/stats-conv.py
index 5fc092e3c7..16d787ab96 100755
--- a/TOOLS/stats-conv.py
+++ b/TOOLS/stats-conv.py
@@ -147,8 +147,8 @@ if hasval:
ax[1] = win.addPlot()
ax[1].setXLink(ax[0])
for cur in ax:
- if cur is not None:
- cur.addLegend(offset = (-1, 1))
+ if cur is not None:
+ cur.addLegend(offset = (-1, 1))
for e in G.sevents:
cur = ax[1 if e.type == "value" else 0]
if not cur in G.curveno:
diff --git a/waftools/checks/generic.py b/waftools/checks/generic.py
index b83774d9b9..cecbeabdd1 100644
--- a/waftools/checks/generic.py
+++ b/waftools/checks/generic.py
@@ -135,7 +135,7 @@ def _check_pkg_config(_dyn_libs, _pkgc_args, *args, **kw_ext):
def check_headers(*headers, **kw_ext):
def undef_others(ctx, headers, found):
- not_found_hs = set(headers) - set([found])
+ not_found_hs = set(headers) - {found}
for not_found_h in not_found_hs:
ctx.undefine(inflector.define_key(not_found_h))
diff --git a/waftools/clang_compilation_database.py b/waftools/clang_compilation_database.py
index 558b88a4a6..666471f07e 100644
--- a/waftools/clang_compilation_database.py
+++ b/waftools/clang_compilation_database.py
@@ -44,7 +44,7 @@ def write_compilation_database(ctx):
root = json.load(database_file)
except IOError:
root = []
- clang_db = dict((x['file'], x) for x in root)
+ clang_db = {x['file']: x for x in root}
for task in getattr(ctx, 'clang_compilation_database_tasks', []):
try:
cmd = task.last_cmd
diff --git a/waftools/dependencies.py b/waftools/dependencies.py
index 3cef6a3562..62e0c22b29 100644
--- a/waftools/dependencies.py
+++ b/waftools/dependencies.py
@@ -220,5 +220,5 @@ def dependencies_use(ctx):
BuildContext.filtered_sources = filtered_sources
BuildContext.pick_first_matching_dep = pick_first_matching_dep
BuildContext.dependencies_use = dependencies_use
-BuildContext.dependencies_includes = env_fetch(lambda x: "INCLUDES_{0}".format(x))
+BuildContext.dependencies_includes = env_fetch(lambda x: "INCLUDES_{0}".format(x))
BuildContext.dependency_satisfied = dependency_satisfied
diff --git a/waftools/detections/compiler.py b/waftools/detections/compiler.py
index 6946710900..399a606144 100644
--- a/waftools/detections/compiler.py
+++ b/waftools/detections/compiler.py
@@ -55,7 +55,7 @@ def __add_gcc_flags__(ctx):
def __add_clang_flags__(ctx):
ctx.env.CFLAGS += ["-Wno-logical-op-parentheses", "-fcolor-diagnostics",
"-Wno-tautological-compare",
- "-Wno-tautological-constant-out-of-range-compare" ]
+ "-Wno-tautological-constant-out-of-range-compare"]
def __add_mswin_flags__(ctx):
ctx.env.CFLAGS += ['-D_WIN32_WINNT=0x0602', '-DUNICODE', '-DCOBJMACROS',
diff --git a/waftools/detections/compiler_swift.py b/waftools/detections/compiler_swift.py
index 854d1a6db8..ff11818702 100644
--- a/waftools/detections/compiler_swift.py
+++ b/waftools/detections/compiler_swift.py
@@ -4,6 +4,7 @@ import os.path
from waflib import Utils
from distutils.version import StrictVersion
+
def __run(cmd):
try:
output = Utils.subprocess.check_output(cmd, stderr=Utils.subprocess.STDOUT, universal_newlines=True)
@@ -11,6 +12,7 @@ def __run(cmd):
except Exception:
return ""
+
def __add_swift_flags(ctx):
ctx.env.SWIFT_FLAGS = [
"-frontend", "-c", "-sdk", ctx.env.MACOS_SDK,
@@ -23,7 +25,7 @@ def __add_swift_flags(ctx):
# prevent possible breakages with future swift versions
if StrictVersion(ctx.env.SWIFT_VERSION) >= StrictVersion("6.0"):
- ctx.env.SWIFT_FLAGS.extend([ "-swift-version", "5" ])
+ ctx.env.SWIFT_FLAGS.extend(["-swift-version", "5"])
if ctx.is_debug_build():
ctx.env.SWIFT_FLAGS.append("-g")
@@ -31,16 +33,18 @@ def __add_swift_flags(ctx):
if ctx.is_optimization():
ctx.env.SWIFT_FLAGS.append("-O")
+
def __add_static_swift_library_linking_flags(ctx, swift_library):
ctx.env.append_value('LINKFLAGS', [
'-L%s' % swift_library,
'-Xlinker', '-force_load_swift_libs', '-lc++',
])
+
def __add_dynamic_swift_library_linking_flags(ctx, swift_library):
- ctx.env.append_value('LINKFLAGS', [ '-L%s' % swift_library ])
+ ctx.env.append_value('LINKFLAGS', ['-L%s' % swift_library])
- #ABI compatibility
+ # ABI compatibility
if StrictVersion(ctx.env.SWIFT_VERSION) >= StrictVersion("5.0"):
ctx.env.append_value('LINKFLAGS', [
'-Xlinker', '-rpath', '-Xlinker', '/usr/lib/swift',
@@ -51,15 +55,16 @@ def __add_dynamic_swift_library_linking_flags(ctx, swift_library):
'-Xlinker', '-rpath', '-Xlinker', swift_library,
])
+
def __find_swift_library(ctx):
swift_libraries = {}
- #look for set lib paths in passed environment variables
+ # look for set lib paths in passed environment variables
if 'SWIFT_LIB_DYNAMIC' in ctx.environ:
swift_libraries['SWIFT_LIB_DYNAMIC'] = ctx.environ['SWIFT_LIB_DYNAMIC']
if 'SWIFT_LIB_STATIC' in ctx.environ:
swift_libraries['SWIFT_LIB_STATIC'] = ctx.environ['SWIFT_LIB_STATIC']
- #search for swift libs relative to the swift compiler executable
+ # search for swift libs relative to the swift compiler executable
swift_library_relative_paths = {
'SWIFT_LIB_DYNAMIC': '../../lib/swift/macosx',
'SWIFT_LIB_STATIC': '../../lib/swift_static/macosx'
@@ -72,7 +77,7 @@ def __find_swift_library(ctx):
if swift_library is not None:
swift_libraries[lib_type] = swift_library.abspath()
- #fall back to xcode-select path
+ # fall back to xcode-select path
swift_library_paths = {
'SWIFT_LIB_DYNAMIC': [
'Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx',
@@ -95,7 +100,7 @@ def __find_swift_library(ctx):
else:
break
- #check if library paths were found
+ # check if library paths were found
ctx.start_msg('Checking for dynamic Swift Library')
if 'SWIFT_LIB_DYNAMIC' in swift_libraries:
ctx.end_msg(swift_libraries['SWIFT_LIB_DYNAMIC'])
@@ -115,48 +120,49 @@ def __find_swift_library(ctx):
else:
__add_dynamic_swift_library_linking_flags(ctx, swift_libraries['SWIFT_LIB_DYNAMIC'])
+
def __find_macos_sdk(ctx):
ctx.start_msg('Checking for macOS SDK')
sdk = None
sdk_build_version = None
sdk_version = None
- #look for set macOS SDK paths and version in passed environment variables
+ # look for set macOS SDK paths and version in passed environment variables
if 'MACOS_SDK' in ctx.environ:
sdk = ctx.environ['MACOS_SDK']
if 'MACOS_SDK_VERSION' in ctx.environ:
ctx.env.MACOS_SDK_VERSION = ctx.environ['MACOS_SDK_VERSION']
- #find macOS SDK paths and version
+ # find macOS SDK paths and version
if not sdk:
sdk = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-path'])
if not ctx.env.MACOS_SDK_VERSION:
- #show-sdk-build-version: is not available on older command line tools, but return a build version (eg 17A360)
- #show-sdk-version: is always available, but on older dev tools it's only the major version
- sdk_build_version = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-build-version' ])
- sdk_version = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-version' ])
+ # show-sdk-build-version: is not available on older command line tools, but return a build version (eg 17A360)
+ # show-sdk-version: is always available, but on older dev tools it's only the major version
+ sdk_build_version = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-build-version'])
+ sdk_version = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-version'])
if sdk:
ctx.env.MACOS_SDK = sdk
build_version = '10.10.0'
if not ctx.env.MACOS_SDK_VERSION:
- #convert build version to a version string
- #first 2 two digits are the major version, starting with 15 which is 10.11 (offset of 4)
- #1 char is the minor version, A => 0, B => 1 and ongoing
- #las digits are bugfix version, which are nor relevant for us
- #eg 16E185 => 10.12.4, 17A360 => 10.13, 18B71 => 10.14.1
+ # convert build version to a version string
+ # first 2 two digits are the major version, starting with 15 which is 10.11 (offset of 4)
+ # 1 char is the minor version, A => 0, B => 1 and ongoing
+ # las digits are bugfix version, which are nor relevant for us
+ # eg 16E185 => 10.12.4, 17A360 => 10.13, 18B71 => 10.14.1
if sdk_build_version and isinstance(sdk_build_version, str):
verRe = re.compile("(\d+)(\D+)(\d+)")
version_parts = verRe.search(sdk_build_version)
- major = int(version_parts.group(1))-4
+ major = int(version_parts.group(1)) - 4
minor = string.ascii_lowercase.index(version_parts.group(2).lower())
build_version = '10.' + str(major) + '.' + str(minor)
if not isinstance(sdk_version, str):
sdk_version = '10.10.0'
- #pick the higher version, always pick sdk over build if newer
+ # pick the higher version, always pick sdk over build if newer
if StrictVersion(build_version) > StrictVersion(sdk_version):
ctx.env.MACOS_SDK_VERSION = build_version
else:
@@ -166,15 +172,16 @@ def __find_macos_sdk(ctx):
else:
ctx.end_msg(False)
+
def __find_swift_compiler(ctx):
ctx.start_msg('Checking for swift (Swift compiler)')
swift = ''
- #look for set swift paths in passed environment variables
+ # look for set swift paths in passed environment variables
if 'SWIFT' in ctx.environ:
swift = ctx.environ['SWIFT']
- #find swift executable
+ # find swift executable
if not swift:
swift = __run(['xcrun', '-find', 'swift'])
@@ -186,6 +193,7 @@ def __find_swift_compiler(ctx):
else:
ctx.end_msg(False)
+
def configure(ctx):
if ctx.env.DEST_OS == "darwin":
__find_macos_sdk(ctx)
diff --git a/waftools/features.py b/waftools/features.py
index d038392a82..74c2483a48 100644
--- a/waftools/features.py
+++ b/waftools/features.py
@@ -3,7 +3,7 @@ import optparse
class Feature(object):
def __init__(self, group, feature):
- self.group = group
+ self.group = group
self.identifier, self.attributes = feature['name'], feature
def add_options(self):