mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-07-08 07:35:52 +00:00
gst-env: Improve coding style and cleanup
* Remove unused variables * Remove unused imports * Apply pycodestyle style suggestions - Missing newlines - spaces before brackets - Wrong indentations Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1829>
This commit is contained in:
parent
a81398b70f
commit
252f9e39d6
16
gst-env.py
16
gst-env.py
|
@ -1,17 +1,14 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import contextlib
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import site
|
||||
import shlex
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import pathlib
|
||||
import signal
|
||||
|
@ -71,6 +68,7 @@ def listify(o):
|
|||
return o
|
||||
raise AssertionError('Object {!r} must be a string or a list'.format(o))
|
||||
|
||||
|
||||
def stringify(o):
|
||||
if isinstance(o, str):
|
||||
return o
|
||||
|
@ -80,6 +78,7 @@ def stringify(o):
|
|||
raise AssertionError('Did not expect object {!r} to have more than one element'.format(o))
|
||||
raise AssertionError('Object {!r} must be a string or a list'.format(o))
|
||||
|
||||
|
||||
def prepend_env_var(env, var, value, sysroot):
|
||||
if var is None:
|
||||
return
|
||||
|
@ -96,6 +95,7 @@ def prepend_env_var(env, var, value, sysroot):
|
|||
env[var] = val + env_val
|
||||
env[var] = env[var].replace(os.pathsep + os.pathsep, os.pathsep).strip(os.pathsep)
|
||||
|
||||
|
||||
def get_target_install_filename(target, filename):
|
||||
'''
|
||||
Checks whether this file is one of the files installed by the target
|
||||
|
@ -106,6 +106,7 @@ def get_target_install_filename(target, filename):
|
|||
return install_filename
|
||||
return None
|
||||
|
||||
|
||||
def get_pkgconfig_variable_from_pcfile(pcfile, varname):
|
||||
variables = {}
|
||||
substre = re.compile('\$\{[^${}]+\}')
|
||||
|
@ -123,6 +124,7 @@ def get_pkgconfig_variable_from_pcfile(pcfile, varname):
|
|||
variables[key] = value
|
||||
return variables.get(varname, '')
|
||||
|
||||
|
||||
@lru_cache()
|
||||
def get_pkgconfig_variable(builddir, pcname, varname):
|
||||
'''
|
||||
|
@ -147,6 +149,7 @@ def is_gio_module(target, filename, builddir):
|
|||
return False
|
||||
return True
|
||||
|
||||
|
||||
def is_library_target_and_not_plugin(target, filename):
|
||||
'''
|
||||
Don't add plugins to PATH/LD_LIBRARY_PATH because:
|
||||
|
@ -169,6 +172,7 @@ def is_library_target_and_not_plugin(target, filename):
|
|||
return False
|
||||
return True
|
||||
|
||||
|
||||
def is_binary_target_and_in_path(target, filename, bindir):
|
||||
if target['type'] != 'executable':
|
||||
return False
|
||||
|
@ -200,6 +204,7 @@ def get_wine_subprocess_env(options, env):
|
|||
|
||||
return env
|
||||
|
||||
|
||||
def setup_gdb(options):
|
||||
python_paths = set()
|
||||
|
||||
|
@ -242,9 +247,11 @@ def setup_gdb(options):
|
|||
|
||||
return python_paths
|
||||
|
||||
|
||||
def is_bash_completion_available(options):
|
||||
return os.path.exists(os.path.join(options.builddir, 'subprojects/gstreamer/data/bash-completion/helpers/gst'))
|
||||
|
||||
|
||||
def get_subprocess_env(options, gst_version):
|
||||
env = os.environ.copy()
|
||||
|
||||
|
@ -404,7 +411,6 @@ def get_subprocess_env(options, gst_version):
|
|||
installed_s = subprocess.check_output(meson + ['introspect', options.builddir, '--installed'])
|
||||
for path, installpath in json.loads(installed_s.decode()).items():
|
||||
installpath_parts = pathlib.Path(installpath).parts
|
||||
path_parts = pathlib.Path(path).parts
|
||||
|
||||
# We want to add all python modules to the PYTHONPATH
|
||||
# in a manner consistent with the way they would be imported:
|
||||
|
@ -481,12 +487,14 @@ def get_subprocess_env(options, gst_version):
|
|||
|
||||
return env
|
||||
|
||||
|
||||
def get_windows_shell():
|
||||
command = ['powershell.exe', '-noprofile', '-executionpolicy', 'bypass', '-file',
|
||||
os.path.join(SCRIPTDIR, 'data', 'misc', 'cmd_or_ps.ps1')]
|
||||
result = subprocess.check_output(command)
|
||||
return result.decode().strip()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(prog="gst-env")
|
||||
|
||||
|
|
Loading…
Reference in a new issue