Deprecated. Patch should now be imported from caliendo.patch.patch
540436
def patch(*args, **kwargs):
    
    from caliendo.patch import patch as p
    return p(*args, **kwargs)
630579
def _apply_cn_keys_patch():
    
    import sys
    if sys.version_info[:2] == (3, 5):
        import http.client as hc
        old_parse = hc.parse_headers

        def parse_header(*args, **kwargs):
            fp = args[0]
            old_readline = fp.readline

            def new_readline(*args, **kwargs):
                ret = old_readline(*args, **kwargs)
                if ret.lower().startswith(b'x-log-query-info'):
                    return b'x-log-query-info: \r\n'
                return ret

            fp.readline = new_readline

            ret = old_parse(*args, **kwargs)
            return ret

        hc.parse_headers = parse_header
617425
def patch(patch_inspect=True):
    
    PATCHED['collections.abc.Generator'] = _collections_abc.Generator = Generator
    PATCHED['collections.abc.Coroutine'] = _collections_abc.Coroutine = Coroutine
    PATCHED['collections.abc.Awaitable'] = _collections_abc.Awaitable = Awaitable

    if patch_inspect:
        import inspect
        PATCHED['inspect.isawaitable'] = inspect.isawaitable = isawaitable
1086731
def _patch_awx_callback():
    
    # AWX uses sitecustomize.py to force-load this package. If it exists, we're
    # running under AWX.
    try:
        from awx_display_callback.events import EventContext
        from awx_display_callback.events import event_context
    except ImportError:
        return

    if hasattr(EventContext(), '_local'):
        # Patched version.
        return

    def patch_add_local(self, **kwargs):
        tls = vars(self._local)
        ctx = tls.setdefault('_ctx', {})
        ctx.update(kwargs)

    EventContext._local = threading.local()
    EventContext.add_local = patch_add_local
237437
def patch_func(replacement, target_mod, func_name):
    
    original = getattr(target_mod, func_name)

    # set the 'unpatched' attribute on the replacement to
    # point to the original.
    vars(replacement).setdefault('unpatched', original)

    # replace the function in the original module
    setattr(target_mod, func_name, replacement)
243855
def patch():
    
    if getattr(httplib, PATCH_FLAG, False):
        return
    # we set an attribute to avoid multiple wrapping
    setattr(httplib, PATCH_FLAG, True)

    wrapt.wrap_function_wrapper(
        httplib_client_module,
        'HTTPConnection._send_request',
        _send_request
    )

    wrapt.wrap_function_wrapper(
        httplib_client_module,
        'HTTPConnection.getresponse',
        _xray_traced_http_getresponse
    )

    wrapt.wrap_function_wrapper(
        httplib_client_module,
        'HTTPResponse.read',
        _xray_traced_http_client_read
    )
1347981
def apply_patch(self, patch):
        

        history_file = File(self.__history_file)
        patches_history = history_file.cache() and [line.strip() for line in history_file.content] or []

        if patch.uid not in patches_history:
            LOGGER.debug("> Applying '{0}' patch!".format(patch.name))
            if patch.apply():
                history_file.content = ["{0}\n".format(patch.uid)]
                history_file.append()
            else:
                raise umbra.exceptions.PatchApplyError("{0} | '{1}' patch failed to apply!".format(
                    self.__class__.__name__, patch.path))
        else:
            LOGGER.debug("> '{0}' patch is already applied!".format(patch.name))
        return True
310731
function patch(obj, method, optionsArgIndex) {
    var orig = obj[method];
    if (!orig) return;
    obj[method] = function () {
      var opts = arguments[optionsArgIndex];
      var file = null;
      if (opts) {
        file = typeof opts == 'string' ? opts : opts.filename;
      }
      if (file) callback(file);
      return orig.apply(this, arguments);
    };
  }
1141670
def patch_modules():
    
    old_call = subprocess.call

    def dummy_call(*args, **kwargs):
        with tempfile.TemporaryFile("wb+") as f:
            kwargs["stdout"] = f
            kwargs["stderr"] = f
            rv = subprocess.Popen(*args, **kwargs).wait()
            f.seek(0)
            click.echo(f.read().decode("utf-8", "replace").rstrip())
        return rv

    subprocess.call = dummy_call

    try:
        yield
    finally:
        subprocess.call = old_call
1217104
def __make_storeable_patch_patchable(self, patch):
        

        new_patch = {}
        for key in patch:
            new_patch[key.replace("|", ".")] = patch[key]

        return new_patch
601465
def deprecated(context):
    """"""
    if 'fetchJsonPath' in context:
        context.assert_key_has_value(key='fetchJsonPath', caller=__name__)

        context['fetchJson'] = {'path': context['fetchJsonPath']}

        if 'fetchJsonKey' in context:
            context['fetchJson']['key'] = context.get('fetchJsonKey', None)

        logger.warning("fetchJsonPath and fetchJsonKey "
                       "are deprecated. They will stop working upon the next "
                       "major release. Use the new context key fetchJson "
                       "instead. It's a lot better, promise! For the moment "
                       "pypyr is creating the new fetchJson key for you "
                       "under the hood.")
1304529
def patch_init_py(base_dir, name, version):
    """"""
    # Ensure main package dir is there (may be absent in script-only packages)
    package_dir = os.path.join(base_dir, name)
    if not os.path.isdir(package_dir):
        os.makedirs(package_dir)
    # Open top-level __init__.py and read whole file
    init_py = os.path.join(package_dir, '__init__.py')
    log.info("patching %s to bake in version '%s'" % (init_py, version))
    with open(init_py, 'r+') as init_file:
        lines = init_file.readlines()
        # Search for sentinels indicating version checking block
        try:
            begin = lines.index("# BEGIN VERSION CHECK\n")
            end = lines.index("# END VERSION CHECK\n")
        except ValueError:
            begin = end = len(lines)
        # Delete existing repo version checking block in file
        init_file.seek(0)
        init_file.writelines(lines[:begin] + lines[end+1:])
        # Append new version attribute to ensure it is authoritative, but only
        # if it is not already there (this happens in pip sdist installs)
        version_cmd = "__version__ = '{0}'\n".format(version)
        if not lines or lines[-1] != version_cmd:
            init_file.write("\n# Automatically added by katversion\n")
            init_file.write(version_cmd)
        init_file.truncate()
1068684
def patch_loader(*decorator_args, serializer):
    
    def wrapped(fn):
        @wraps(fn)
        def decorated(*args, **kwargs):
            result = serializer.load(request.get_json(),
                                     instance=kwargs.pop('instance'),
                                     partial=True)
            if not result.errors and not result.data.id:
                abort(HTTPStatus.NOT_FOUND)
            return fn(*result)
        return decorated

    if decorator_args and callable(decorator_args[0]):
        return wrapped(decorator_args[0])
    return wrapped
1290586
def patched_packing_env(env):
  """"""
  old_env = pkg_resources.packaging.markers.default_environment
  new_env = lambda: env
  pkg_resources._vendor.packaging.markers.default_environment = new_env
  try:
    yield
  finally:
    pkg_resources._vendor.packaging.markers.default_environment = old_env
418796
function fixAcornEsmImport() {
	return {
		name: 'fix-acorn-esm-import',
		renderChunk(code, chunk, options) {
			if (/esm?/.test(options.format)) {
				let found = false;
				const fixedCode = code.replace(expectedAcornImport, () => {
					found = true;
					return newAcornImport;
				});
				if (!found) {
					this.error(
						'Could not find expected acorn import, please deactive this plugin and examine generated code.'
					);
				}
				return fixedCode;
			}
		}
	};
}
1103549
def patch(self, instance, errors):
        
        if errors:
            return self.errors(errors)
        return self.updated(instance)
792328
function(desc, f) {
    if (typeof desc === 'object') {
        f(desc.env);
        if (Array.isArray(desc.components)) {
            desc.components.forEach(function(x) { patchEnv(x, f);});
        }
    } else {
        var err = new Error('patchEnv: not an object');
        err['desc'] = desc;
        throw err;
    }
}