class_docstr: A context manager to protect command execution from UNC paths.
  
  In the Win32 API, commands can't be invoked with the cwd being a UNC path.
  This context manager temporarily changes directory to the 'C:' drive on
  entering, and restores the original working directory on exit.
  
  The context manager returns the starting working directory *if* it made a
  change and None otherwise, so that users can apply the necessary adjustment
  to their system calls in the event of a change.
  
  Examples
  --------
  ::
      cmd = 'dir'
      with AvoidUNCPath() as path:
          if path is not None:
              cmd = '"pushd %s &&"%s' % (path, cmd)
          os.system(cmd)
class_docstr_tok: ["A","context","manager","to","protect","command","execution","from","UNC","paths",".","In","the","Win32","API",",","commands","ca","n't","be","invoked","with","the","cwd","being","a","UNC","path",".","This","context","manager","temporarily","changes","directory","to","the","'","C",":","'","drive","on","entering",",","and","restores","the","original","working","directory","on","exit",".","The","context","manager","returns","the","starting","working","directory","*","if","*","it","made","a","change","and","None","otherwise",",","so","that","users","can","apply","the","necessary","adjustment","to","their","system","calls","in","the","event","of","a","change",".","Examples","--","--","--","--",":",":","cmd","=","'dir'","with","AvoidUNCPath","(",")","as","path",":","if","path","is","not","None",":","cmd","=","'","''","pushd","%","s","&","&","''","%","s","'","%","(","path",",","cmd",")","os.system","(","cmd",")"]
code: def __enter__(self):
      self.path = py3compat.getcwd()
      self.is_unc_path = self.path.startswith(r"\\")
      if self.is_unc_path:
          # change to c drive (as cmd.exe cannot handle UNC addresses)
          os.chdir("C:")
          return self.path
      else:
          # We return None to signal that there was no change in the working
          # directory
          return None
  
file_path: catboost/contrib/python/ipython/py2/IPython/utils/_process_win32.py
imports: from __future__ import print_function
  import os
  import sys
  import ctypes
  from ctypes import c_int, POINTER
  from ctypes.wintypes import LPCWSTR, HLOCAL
  from subprocess import STDOUT
  from ._process_common import read_no_interrupt, process_handler, arg_split
  from .None import py3compat
  from .encoding import DEFAULT_ENCODING
label_desc: Use image node_id 1 for calling the AvoidUNCPath obj's underlying member method code with example usage: obj.__enter__() and returns: self, None