Return info about parent needed by child to unpickle process object.
    Monkey-patch from
435365
def get_preparation_data(name):
    '''
    
    '''
    d = dict(
        name=name,
        sys_path=sys.path,
        sys_argv=sys.argv,
        log_to_stderr=_log_to_stderr,
        orig_dir=process.ORIGINAL_DIR,
        authkey=process.current_process().authkey,
    )

    if _logger is not None:
        d['log_level'] = _logger.getEffectiveLevel()

    if not WINEXE:
        main_path = getattr(sys.modules['__main__'], '__file__', None)
        if not main_path and sys.argv[0] not in ('', '-c'):
            main_path = sys.argv[0]
        if main_path is not None:
            if (not os.path.isabs(main_path) and process.ORIGINAL_DIR
                    is not None):
                main_path = os.path.join(process.ORIGINAL_DIR, main_path)
            if not main_path.endswith('.exe'):
                d['main_path'] = os.path.normpath(main_path)

    return d
545165
def start_parent():
    

    while True:
        args = [sys.executable] + sys.argv
        new_environ = environ.copy()
        new_environ["_IN_CHILD"] = 'yes'
        ret = subprocess.call(args, env=new_environ)

        if ret != settings.CODE_RELOAD_EXIT:
            return ret
1320913
def get_parent(self):
        """"""

        parent_iter = self.model.iter_parent(self.iter)
        if parent_iter:
            return TreeModelRow(self.model, parent_iter)
721985
def __monkey_patch_juman_lines(self, input_str):
        # type: (text_type)->text_type
        
        assert isinstance(self.juman, pyknp.Juman)
        if not self.juman.socket and not self.juman.subprocess:
            if self.juman.server is not None:
                self.juman.socket = MonkeyPatchSocket(self.juman.server, self.juman.port, b"RUN -e2\n")
            else:
                command = "%s %s" % (self.juman.command, self.juman.option)
                if self.juman.rcfile:
                    command += " -r %s" % self.juman.rcfile
                self.juman.subprocess = pyknp.Subprocess(command)
        if self.juman.socket:
            return self.juman.socket.query(input_str, pattern=self.juman.pattern)
        return self.juman.subprocess.query(input_str, pattern=self.juman.pattern)
1373459
def needsattached(func):
    """"""

    @functools.wraps(func)
    def wrap(self, *args, **kwargs):
      if not self.attached:
        raise PositionError('Not attached to any process.')
      return func(self, *args, **kwargs)
    return wrap
1075331
def _prep_obj(self, obj, parent, parents_ids=EMPTY_FROZENSET, is_namedtuple=False):
        """"""
        original_type = type(obj)
        try:
            if is_namedtuple:
                obj = obj._asdict()
            else:
                obj = obj.__dict__
        except AttributeError:
            try:
                obj = {i: getattr(obj, i) for i in obj.__slots__}
            except AttributeError:
                self[UNPROCESSED].append(obj)
                return unprocessed

        result = self._prep_dict(obj, parent=parent, parents_ids=parents_ids,
                                 print_as_attribute=True, original_type=original_type)
        result = "nt{}".format(result) if is_namedtuple else "obj{}".format(result)
        return result
244056
def _child(details):
	

	# If the details are a list
	if isinstance(details, list):

		# Create a list of options for the key
		return OptionsNode(details)

	# Else if we got a dictionary
	elif isinstance(details, dict):

		# If array is present
		if '__array__' in details:
			return ArrayNode(details)

		# Else if we have a hash
		elif '__hash__' in details:
			return HashNode(details)

		# Else if we have a type
		elif '__type__' in details:

			# If the type is a dictionary or list, this is a complex type
			if isinstance(details['__type__'], (dict,list)):
				return _child(details['__type__'])

			# Else it's just a Node
			else:
				return Node(details)

		# Else it's most likely a parent
		else:
			return Parent(details)

	# Else if we got a string
	elif isinstance(details, basestring):

		# Use the value as the type
		return Node(details)

	# Else raise an error
	else:
		raise TypeError('details')
155121
def monkey_patch(enabled=True):
    

    if enabled:
        Image.open = imdirect_open
    else:
        Image.open = pil_open
538761
def get_parent_scope_from_var(name, global_ok=False, skip_frames=0) -> typing.Optional[Scope]:
    

    stack = inspect.stack()
    try:
        for frame_info in stack[skip_frames + 1:]:
            frame = None

            try:
                frame = frame_info.frame

                if name in frame.f_locals or (global_ok and name in frame.f_globals):
                    return Scope(globals_=frame.f_globals, locals_=frame.f_locals)
            finally:
                del frame
    finally:
        del stack

    return None
1157090
def pydoc_cli_monkey_patched(port):
    

    # Monkey-patch input so that input does not raise EOFError when
    # called by pydoc.cli
    def input(_):  # pylint: disable=W0622
        """Monkey-patched version of builtins.input"""
        while 1:
            time.sleep(1.0)

    import builtins
    builtins.input = input
    sys.argv += ["-p", port]
    pydoc.cli()
313528
function _monkeyPatchConfigure(compiler, complete, options) {
  var configurePath = path.join(compiler.dir, 'configure.py');
  var snapshotPath = options.startupSnapshot;

  if (snapshotPath != null) {
    _log('monkey patching configure file');
    snapshotPath = path.join(process.cwd(), snapshotPath);
    return _monkeypatch(
      configurePath,
      function(content) {
        return ~content.indexOf('v8_embed_script');
      },
      function(content, next) {
        next(
          null,
          content.replace(
            'def configure_v8(o):',
            `def configure_v8(o):
  o['variables']['v8_embed_script'] = r'${snapshotPath}'
  o['variables']['v8_warmup_script'] = r'${snapshotPath}'`,
          ),
        );
      },
      complete,
    );
  } else {
    _log('not  patching configure file');
  }

  return complete();
}
510067
def _get_parent(self):
        """"""
        _dir = os.path.dirname(self.path)
        if is_repo(_dir):
            return Local(_dir)
        else:
            return None
939904
def save(self):
        
        fpath = self.get_fpath()
        if fpath in ['', None]:
            if self._tree.parent is not None:
                if VERBOSE_PREF:
                    print('[pref.save] Can my parent save me?')  # ...to disk
                return self._tree.parent.save()
            if VERBOSE_PREF:
                print('[pref.save] I cannot be saved. I have no parents.')
            return False
        with open(fpath, 'wb') as f:
            print('[pref] Saving to ' + fpath)
            pref_dict = self.to_dict()
            pickle.dump(pref_dict, f, protocol=2)  # Use protocol 2 to support python2 and 3
        return True
213262
function monkeyPatchPipe(stream) {
  while (!stream.hasOwnProperty('pipe')) {
    stream = Object.getPrototypeOf(stream)
    if (!stream) return null
  }

  let existingPipe = stream.pipe
  newPipe['$$monkey-patch'] = true
  return stream.pipe = newPipe

  /** Create new pipe copy of existing pipe */
  function newPipe() {
    let result = existingPipe.apply(this, arguments)
    result.setMaxListeners(0)
    if (!result.pipe['$$monkey-patch']) {
      monkeyPatchPipe(result)
    }

    return result.on('error', function(err) {
      gutil.log(gutil.colors.yellow(err))
      gutil.beep()
      this.emit('end')
    })
  }
}
254609
function parent(object, path) {
        return path.length == 1 ? object : get(object, baseSlice(path, 0, -1));
      }
237489
def parent(version=None, include=None):
    '''
    
    '''
    parser = argparse.ArgumentParser(add_help=False)
    add_default_args(parser, version=version, include=include)
    return parser
61630
def callback_parent(attr, old, new):
    ''''''
    import os

    # Remove accidental white space if copy/pasted
    new = new.strip()
    parent_input.value = new

    # Verify new parent path exists and update `datadirs_select` widget
    if os.path.exists(new):
        # Create sorted list of data directories, ignore files
        joinisdir = lambda parent, d: os.path.isdir(os.path.join(parent, d))
        options = sorted([d for d in os.listdir(new) if joinisdir(new, d)])

        # Update dropdown list of available data directories and select first
        datadirs_select.options = options
        datadirs_select.value = options[0]
        callback_datadirs('value', options[0], options[0])

    else:
        msg = '''
              The parent path `{}` does not exist.

              Check that you have entered the absolute path.
              '''.format(new)
        output_window.text = output_template.format(msg)

    return None