Temporarily cd into a directory
3033
def cd(dest):
    
    origin = os.getcwd()
    try:
        os.chdir(dest)
        yield dest
    finally:
        os.chdir(origin)
361395
def _from_directory(self, dirname, prefix=""):
        
        ps = [os.path.join(here, dirname, p) for p in os.listdir(os.path.join(here, dirname))]
        n = prefix + wt_kit.string2identifier(os.path.basename(dirname))
        setattr(self, n, ps)
1165447
def method_file_cd(f):
    
    @wraps(f)
    def wrapper(self, *args, **kwargs):
        with preserve_current_directory():
            self.GetDirectory().cd()
            return f(self, *args, **kwargs)
    return wrapper
61186
def make(directory):
    """"""

    if os.path.exists(directory):
        if os.path.isdir(directory):
            click.echo('Directory already exists')
        else:
            click.echo('Path exists and is not a directory')
        sys.exit()

    os.makedirs(directory)
    os.mkdir(os.path.join(directory, 'jsons'))
    copy_default_config(os.path.join(directory, 'config.yaml'))
49773
def setup(api=None):
    
    global tmp_dir_object

    tmp_dir_object = tempfile.TemporaryDirectory()

    dir_name = tmp_dir_object.name

    dir_a = os.path.join(dir_name, "a")
    os.mkdir(dir_a)
    dir_b = os.path.join(dir_name, "b")
    os.mkdir(dir_b)

    # populate directory a with text files
    file_list = [
            ["hi.txt", """Hi World!"""],
            ["hi.html", """<strong>Hi World!</strong>"""],
            ["hello.html", """
                <img src='/static/b/smile.png'</img>
                pop-up
                <script src='/static/a/hi.js'></script>"""],
            ["hi.js", """alert('Hi World')""" ]
    ]

    for f in file_list:
        with open(os.path.join(dir_a, f[0]), mode="wt") as fo:
            fo.write(f[1])

    # populate directory b with binary file
    image = b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\n\x00\x00\x00\n\x08\x02\x00\x00\x00\x02PX\xea\x00\x00\x006IDAT\x18\xd3c\xfc\xff\xff?\x03n\xc0\xc4\x80\x170100022222\xc2\x85\x90\xb9\x04t3\x92`7\xb2\x15D\xeb\xc6\xe34\xa8n4c\xe1F\x120\x1c\x00\xc6z\x12\x1c\x8cT\xf2\x1e\x00\x00\x00\x00IEND\xaeB`\x82'

    with open(os.path.join(dir_b, "smile.png"), mode="wb") as fo:
            fo.write(image)
917329
def install(self, to, chmod=0644):
        
        self.copy(to)
        path(to).chmod(chmod)
1263376
def cd(*args):
    
    if args[0] == "-":
        try:
            newpwd, os.environ["OLDPWD"] = os.environ["OLDPWD"], os.getcwd()
        except KeyError as e:  # $OLDPWD initially not set
            raise e
        else:
            os.chdir(newpwd)
            print(newpwd)
    else:
        os.environ["OLDPWD"] = os.getcwd()
        os.chdir(*args)
1042261
def create_directory(self, filename):
        """"""
        path = os.path.join(self.path, filename)
        makedirs(path)
        return path
442489
def cd(path):
    
    _cdhist.append(pwd())  # Push to history.
    path = abspath(path)
    os.chdir(path)
    return path
448540
def makedirs(d):
    """"""
    if sys.version_info[0] < 3:
        from distutils.dir_util import mkpath
        mkpath(d)
    else:
        os.makedirs(d, exist_ok=True)
963888
def saveDirectory(alias):
	""""""
	if not settings.platformCompatible():
		return False
	dataFile = open(settings.getDataFile(), "wb")
	currentDirectory = os.path.abspath(".")
	directory = {alias : currentDirectory}
	pickle.dump(directory, dataFile)
	speech.success(alias + " will now link to " + currentDirectory + ".")
	speech.success("Tip: use 'hallie go to " + alias + "' to change to this directory.")
874049
def cmd_cd(self, *args):
        
        if len(args) == 0:
            path = os.environ['HOME']
        else:
            path = args[0]
        os.chdir(path)
        self.cmd_pwd()
902621
def cd(new_directory, clean_up=lambda: True):  # pylint: disable=invalid-name
    
    previous_directory = os.getcwd()
    os.chdir(os.path.expanduser(new_directory))
    try:
        yield
    finally:
        os.chdir(previous_directory)
        clean_up()
512361
def change_directory(self, directory):
        
        self._process.write(('cd %s\n' % directory).encode())
        if sys.platform == 'win32':
            self._process.write((os.path.splitdrive(directory)[0] + '\r\n').encode())
            self.clear()
        else:
            self._process.write(b'\x0C')
398210
def script(state, host, filename, chdir=None):
    '''
    
    '''

    temp_file = state.get_temp_filename(filename)
    yield files.put(state, host, filename, temp_file)

    yield chmod(temp_file, '+x')

    if chdir:
        yield 'cd {0} && {1}'.format(chdir, temp_file)
    else:
        yield temp_file
339551
def _make_temp_directory(prefix):
    '''
    
    '''
    temp_dir = _make_temp_filename(prefix=str(prefix))
    _os.makedirs(temp_dir)
    return temp_dir
747579
def tmp_chdir(new_path):
    """"""
    prev_cwd = os.getcwd()
    os.chdir(new_path)
    try:
        yield
    finally:
        os.chdir(prev_cwd)