summaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/support
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/support')
-rw-r--r--packages/Python/lldbsuite/support/__init__.py0
-rw-r--r--packages/Python/lldbsuite/support/encoded_file.py65
-rw-r--r--packages/Python/lldbsuite/support/fs.py65
-rw-r--r--packages/Python/lldbsuite/support/funcutils.py24
-rw-r--r--packages/Python/lldbsuite/support/gmodules.py29
-rw-r--r--packages/Python/lldbsuite/support/optional_with.py58
-rw-r--r--packages/Python/lldbsuite/support/seven.py25
-rw-r--r--packages/Python/lldbsuite/support/sockutil.py24
8 files changed, 0 insertions, 290 deletions
diff --git a/packages/Python/lldbsuite/support/__init__.py b/packages/Python/lldbsuite/support/__init__.py
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/packages/Python/lldbsuite/support/__init__.py
+++ /dev/null
diff --git a/packages/Python/lldbsuite/support/encoded_file.py b/packages/Python/lldbsuite/support/encoded_file.py
deleted file mode 100644
index 5c04cce3b3f9..000000000000
--- a/packages/Python/lldbsuite/support/encoded_file.py
+++ /dev/null
@@ -1,65 +0,0 @@
-"""
- The LLVM Compiler Infrastructure
-
-This file is distributed under the University of Illinois Open Source
-License. See LICENSE.TXT for details.
-
-Prepares language bindings for LLDB build process. Run with --help
-to see a description of the supported command line arguments.
-"""
-
-# Python modules:
-import io
-
-# Third party modules
-import six
-
-
-def _encoded_read(old_read, encoding):
- def impl(size):
- result = old_read(size)
- # If this is Python 2 then we need to convert the resulting `unicode` back
- # into a `str` before returning
- if six.PY2:
- result = result.encode(encoding)
- return result
- return impl
-
-
-def _encoded_write(old_write, encoding):
- def impl(s):
- # If we were asked to write a `str` (in Py2) or a `bytes` (in Py3) decode it
- # as unicode before attempting to write.
- if isinstance(s, six.binary_type):
- s = s.decode(encoding, "replace")
- return old_write(s)
- return impl
-
-'''
-Create a Text I/O file object that can be written to with either unicode strings or byte strings
-under Python 2 and Python 3, and automatically encodes and decodes as necessary to return the
-native string type for the current Python version
-'''
-
-
-def open(
- file,
- encoding,
- mode='r',
- buffering=-1,
- errors=None,
- newline=None,
- closefd=True):
- wrapped_file = io.open(
- file,
- mode=mode,
- buffering=buffering,
- encoding=encoding,
- errors=errors,
- newline=newline,
- closefd=closefd)
- new_read = _encoded_read(getattr(wrapped_file, 'read'), encoding)
- new_write = _encoded_write(getattr(wrapped_file, 'write'), encoding)
- setattr(wrapped_file, 'read', new_read)
- setattr(wrapped_file, 'write', new_write)
- return wrapped_file
diff --git a/packages/Python/lldbsuite/support/fs.py b/packages/Python/lldbsuite/support/fs.py
deleted file mode 100644
index 30388596ea16..000000000000
--- a/packages/Python/lldbsuite/support/fs.py
+++ /dev/null
@@ -1,65 +0,0 @@
-"""
- The LLVM Compiler Infrastructure
-
-This file is distributed under the University of Illinois Open Source
-License. See LICENSE.TXT for details.
-
-Prepares language bindings for LLDB build process. Run with --help
-to see a description of the supported command line arguments.
-"""
-
-# Python modules:
-import os
-import platform
-import sys
-
-
-def _find_file_in_paths(paths, exe_basename):
- """Returns the full exe path for the first path match.
-
- @params paths the list of directories to search for the exe_basename
- executable
- @params exe_basename the name of the file for which to search.
- e.g. "swig" or "swig.exe".
-
- @return the full path to the executable if found in one of the
- given paths; otherwise, returns None.
- """
- for path in paths:
- trial_exe_path = os.path.join(path, exe_basename)
- if os.path.exists(trial_exe_path):
- return os.path.normcase(trial_exe_path)
- return None
-
-
-def find_executable(executable):
- """Finds the specified executable in the PATH or known good locations."""
-
- # Figure out what we're looking for.
- if platform.system() == "Windows":
- executable = executable + ".exe"
- extra_dirs = []
- else:
- extra_dirs = ["/usr/local/bin"]
-
- # Figure out what paths to check.
- path_env = os.environ.get("PATH", None)
- if path_env is not None:
- paths_to_check = path_env.split(os.path.pathsep)
- else:
- paths_to_check = []
-
- # Add in the extra dirs
- paths_to_check.extend(extra_dirs)
- if len(paths_to_check) < 1:
- raise os.OSError(
- "executable was not specified, PATH has no "
- "contents, and there are no extra directories to search")
-
- result = _find_file_in_paths(paths_to_check, executable)
-
- if not result or len(result) < 1:
- raise os.OSError(
- "failed to find exe='%s' in paths='%s'" %
- (executable, paths_to_check))
- return result
diff --git a/packages/Python/lldbsuite/support/funcutils.py b/packages/Python/lldbsuite/support/funcutils.py
deleted file mode 100644
index 2fa10097d43b..000000000000
--- a/packages/Python/lldbsuite/support/funcutils.py
+++ /dev/null
@@ -1,24 +0,0 @@
-from __future__ import print_function
-from __future__ import absolute_import
-
-# System modules
-import inspect
-
-# Third-party modules
-
-# LLDB modules
-
-
-def requires_self(func):
- func_argc = len(inspect.getargspec(func).args)
- if func_argc == 0 or (
- getattr(
- func,
- 'im_self',
- None) is not None) or (
- hasattr(
- func,
- '__self__')):
- return False
- else:
- return True
diff --git a/packages/Python/lldbsuite/support/gmodules.py b/packages/Python/lldbsuite/support/gmodules.py
deleted file mode 100644
index 5d66bd14896d..000000000000
--- a/packages/Python/lldbsuite/support/gmodules.py
+++ /dev/null
@@ -1,29 +0,0 @@
-from __future__ import absolute_import
-from __future__ import print_function
-
-# System modules
-import os
-import re
-
-
-GMODULES_SUPPORT_MAP = {}
-GMODULES_HELP_REGEX = re.compile(r"\s-gmodules\s")
-
-
-def is_compiler_clang_with_gmodules(compiler_path):
- # Before computing the result, check if we already have it cached.
- if compiler_path in GMODULES_SUPPORT_MAP:
- return GMODULES_SUPPORT_MAP[compiler_path]
-
- def _gmodules_supported_internal():
- compiler = os.path.basename(compiler_path)
- if "clang" not in compiler:
- return False
- else:
- # Check the compiler help for the -gmodules option.
- clang_help = os.popen("%s --help" % compiler_path).read()
- return GMODULES_HELP_REGEX.search(
- clang_help, re.DOTALL) is not None
-
- GMODULES_SUPPORT_MAP[compiler_path] = _gmodules_supported_internal()
- return GMODULES_SUPPORT_MAP[compiler_path]
diff --git a/packages/Python/lldbsuite/support/optional_with.py b/packages/Python/lldbsuite/support/optional_with.py
deleted file mode 100644
index f91b3c6fdeb6..000000000000
--- a/packages/Python/lldbsuite/support/optional_with.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# ====================================================================
-# Provides a with-style resource handler for optionally-None resources
-# ====================================================================
-
-
-class optional_with(object):
- # pylint: disable=too-few-public-methods
- # This is a wrapper - it is not meant to provide any extra methods.
- """Provides a wrapper for objects supporting "with", allowing None.
-
- This lets a user use the "with object" syntax for resource usage
- (e.g. locks) even when the wrapped with object is None.
-
- e.g.
-
- wrapped_lock = optional_with(thread.Lock())
- with wrapped_lock:
- # Do something while the lock is obtained.
- pass
-
- might_be_none = None
- wrapped_none = optional_with(might_be_none)
- with wrapped_none:
- # This code here still works.
- pass
-
- This prevents having to write code like this when
- a lock is optional:
-
- if lock:
- lock.acquire()
-
- try:
- code_fragment_always_run()
- finally:
- if lock:
- lock.release()
-
- And I'd posit it is safer, as it becomes impossible to
- forget the try/finally using optional_with(), since
- the with syntax can be used.
- """
-
- def __init__(self, wrapped_object):
- self.wrapped_object = wrapped_object
-
- def __enter__(self):
- if self.wrapped_object is not None:
- return self.wrapped_object.__enter__()
- else:
- return self
-
- def __exit__(self, the_type, value, traceback):
- if self.wrapped_object is not None:
- return self.wrapped_object.__exit__(the_type, value, traceback)
- else:
- # Don't suppress any exceptions
- return False
diff --git a/packages/Python/lldbsuite/support/seven.py b/packages/Python/lldbsuite/support/seven.py
deleted file mode 100644
index e04f48308b7d..000000000000
--- a/packages/Python/lldbsuite/support/seven.py
+++ /dev/null
@@ -1,25 +0,0 @@
-import six
-
-if six.PY2:
- import commands
- get_command_output = commands.getoutput
- get_command_status_output = commands.getstatusoutput
-
- cmp_ = cmp
-else:
- def get_command_status_output(command):
- try:
- import subprocess
- return (
- 0,
- subprocess.check_output(
- command,
- shell=True,
- universal_newlines=True))
- except subprocess.CalledProcessError as e:
- return (e.returncode, e.output)
-
- def get_command_output(command):
- return get_command_status_output(command)[1]
-
- cmp_ = lambda x, y: (x > y) - (x < y)
diff --git a/packages/Python/lldbsuite/support/sockutil.py b/packages/Python/lldbsuite/support/sockutil.py
deleted file mode 100644
index 789deed8017a..000000000000
--- a/packages/Python/lldbsuite/support/sockutil.py
+++ /dev/null
@@ -1,24 +0,0 @@
-"""
- The LLVM Compiler Infrastructure
-
-This file is distributed under the University of Illinois Open Source
-License. See LICENSE.TXT for details.
-
-Helper functions for working with sockets.
-"""
-
-# Python modules:
-import io
-import socket
-
-# LLDB modules
-import use_lldb_suite
-
-
-def recvall(sock, size):
- bytes = io.BytesIO()
- while size > 0:
- this_result = sock.recv(size)
- bytes.write(this_result)
- size -= len(this_result)
- return bytes.getvalue()