query stringlengths 9 60 | language stringclasses 1
value | code stringlengths 105 25.7k | url stringlengths 91 217 |
|---|---|---|---|
set working directory | python | def _set_WorkingDir(self, path):
"""Sets the working directory
"""
self._curr_working_dir = path
try:
mkdir(self.WorkingDir)
except OSError:
# Directory already exists
pass | https://github.com/biocore/burrito-fillings/blob/02ab71a46119b40793bd56a4ae00ca15f6dc3329/bfillings/mothur.py#L391-L399 |
set working directory | python | def set_working_directory(self, dirname):
"""Set current working directory.
In the workingdirectory and explorer plugins.
"""
if dirname:
self.main.workingdirectory.chdir(dirname, refresh_explorer=True,
refresh_console=False) | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L577-L583 |
set working directory | python | def set_workdir(self, workdir, chroot=False):
"""Set the working directory. Cannot be set more than once unless chroot is True"""
if not chroot and hasattr(self, "workdir") and self.workdir != workdir:
raise ValueError("self.workdir != workdir: %s, %s" % (self.workdir, workdir))
se... | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/tasks.py#L1378-L1404 |
set working directory | python | def set_workdir(self, workdir, chroot=False):
"""
Set the working directory. Cannot be set more than once unless chroot is True
"""
if not chroot and hasattr(self, "workdir") and self.workdir != workdir:
raise ValueError("self.workdir != workdir: %s, %s" % (self.workdir, wor... | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/flows.py#L254-L266 |
set working directory | python | def set_working_directory(self, path):
r"""
Set the working directory to ``path``\ . All relative paths will
be resolved relative to it.
:type path: str
:param path: the path of the directory
:raises: :exc:`~exceptions.IOError`
"""
_complain_ifclosed(self... | https://github.com/crs4/pydoop/blob/f375be2a06f9c67eaae3ce6f605195dbca143b2b/pydoop/hdfs/fs.py#L461-L471 |
set working directory | python | def working_directory(path):
"""
A context manager that changes the working directory to the given
path, and then changes it back to its previous value on exit.
"""
prev_cwd = os.getcwd()
os.chdir(path)
try:
yield
finally:
os.chdir(prev_cwd) | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/context.py#L181-L191 |
set working directory | python | def __set_workdir(self):
"""Set current script directory as working directory"""
fname = self.get_current_filename()
if fname is not None:
directory = osp.dirname(osp.abspath(fname))
self.open_dir.emit(directory) | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1537-L1542 |
set working directory | python | def set_working_dir(self, working_dir):
"""
Sets the working directory for this hypervisor.
:param working_dir: path to the working directory
"""
# encase working_dir in quotes to protect spaces in the path
yield from self.send('hypervisor working_dir "{}"'.format(worki... | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/dynamips_hypervisor.py#L152-L162 |
set working directory | python | def working_directory(path):
"""Change working directory and restore the previous on exit"""
prev_dir = os.getcwd()
os.chdir(str(path))
try:
yield
finally:
os.chdir(prev_dir) | https://github.com/wimglenn/wimpy/blob/4e8ebe4e7052d88c9f88ac7dcaa1b587cc2cf86e/wimpy/util.py#L41-L48 |
set working directory | python | def working_directory(self):
"""
Get the current working directory.
:rtype: str
:return: current working directory
"""
_complain_ifclosed(self.closed)
wd = self.fs.get_working_directory()
return wd | https://github.com/crs4/pydoop/blob/f375be2a06f9c67eaae3ce6f605195dbca143b2b/pydoop/hdfs/fs.py#L483-L492 |
set working directory | python | def do_set_workdir(self, args):
"""Set the working directory.
The working directory is used to load and save known devices
to improve startup times. During startup the application
loads and saves a file `insteon_plm_device_info.dat`. This file
is saved in the working directory.
... | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/tools.py#L877-L903 |
set working directory | python | def set_working_directory(working_directory):
"""Add working_directory to sys.paths.
This allows dynamic loading of arbitrary python modules in cwd.
Args:
working_directory: string. path to add to sys.paths
"""
logger.debug("starting")
logger.debug(f"adding {working_directory} to sys... | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/moduleloader.py#L51-L65 |
set working directory | python | def change_to_workdir(self):
"""Change working directory to working attribute
:return: None
"""
logger.info("Changing working directory to: %s", self.workdir)
self.check_dir(self.workdir)
try:
os.chdir(self.workdir)
except OSError as exp:
... | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1243-L1259 |
set working directory | python | def create_working_dir(config, prefix):
'''
Create a fresh temporary directory, based on the fiven prefix.
Returns the new path.
'''
# Fetch base directory from executor configuration
basepath = config.get("Execution", "directory")
if not prefix:
prefix = 'opensubmit'
f... | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/filesystem.py#L119-L135 |
set working directory | python | def working_dir(path):
"""
Change working directory within a context::
>>> import os
>>> from cqparts.utils import working_dir
>>> print(os.getcwd())
/home/myuser/temp
>>> with working_dir('..'):
... print(os.getcwd())
...
/home/myuser
... | https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/utils/misc.py#L62-L83 |
set working directory | python | def working_directory(self):
""" The working_directory property
:return: str
"""
if self.chroot_directory and not \
self._working_directory.startswith(self.chroot_directory):
return self.chroot_directory + self._working_directory
else:
ret... | https://github.com/wal-e/wal-e/blob/027263860e72a403bc0e1497bb3e67523138e7a2/wal_e/pep3143daemon/daemon.py#L196-L205 |
set working directory | python | def set_cwd(self, dirname):
"""Set shell current working directory."""
# Replace single for double backslashes on Windows
if os.name == 'nt':
dirname = dirname.replace(u"\\", u"\\\\")
if not self.external_kernel:
code = u"get_ipython().kernel.set_cwd(u'''{}''')".... | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/shell.py#L110-L122 |
set working directory | python | def _createWorkingDir(rootdir,input):
"""
Create a working directory based on input name under the parent directory specified as rootdir
"""
# extract rootname from input
rootname = input[:input.find('_')]
newdir = os.path.join(rootdir,rootname)
if not os.path.exists(newdir):
os.mkdi... | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/runastrodriz.py#L578-L587 |
set working directory | python | def set_directory(path):
"""
| Creates a directory with given path.
| The directory creation is delegated to
Python :func:`os.makedirs` definition so that directories hierarchy is recursively created.
:param path: Directory path.
:type path: unicode
:return: Definition success.
:rty... | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/io.py#L292-L314 |
set working directory | python | def work_dir(path):
'''
Context menager for executing commands in some working directory.
Returns to the previous wd when finished.
Usage:
>>> with work_dir(path):
... subprocess.call('git status')
'''
starting_directory = os.getcwd()
try:
os.chdir(path)
yield
... | https://github.com/jochym/Elastic/blob/8daae37d0c48aab8dfb1de2839dab02314817f95/parcalc/parcalc.py#L79-L94 |
set working directory | python | def cd(path, on=os):
"""Change the current working directory within this context.
Preserves the previous working directory and can be applied to remote
connections that offer @getcwd@ and @chdir@ methods using the @on@
argument.
"""
original = on.getcwd()
on.chdir(path)
yi... | https://github.com/marrow/util/blob/abb8163dbd1fa0692d42a44d129b12ae2b39cdf2/marrow/util/context/__init__.py#L13-L26 |
set working directory | python | def cd(self, path=None):
"""
Get or set the current working directory from the underlying
interpreter (see https://en.wikipedia.org/wiki/Working_directory).
Args:
path: New working directory or None (to display the working
directory).
Returns:
... | https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L477-L498 |
set working directory | python | def set_cwd(fn):
"""
Decorator to set the specified working directory to execute the function, and then restore the previous cwd.
"""
def wrapped(self, *args, **kwargs):
log.info('Calling function: %s with args=%s', fn, args if args else [])
cwd = os.getcwd()
... | https://github.com/tethysplatform/condorpy/blob/a5aaaef0d73198f7d9756dda7abe98b4e209f1f4/condorpy/htcondor_object_base.py#L108-L124 |
set working directory | python | def set_folder(self, folder):
"""
Sets the folder where the files to serve are located.
"""
self.folder = folder
self.templates.directories[0] = folder
self.app.root_path = folder | https://github.com/nicolas-van/pygreen/blob/41d433edb408f86278cf95269fabf3acc00c9119/pygreen.py#L81-L87 |
set working directory | python | def set_outdir(self):
"""Set output directory."""
dirname = self.w.outdir.get_text()
if os.path.isdir(dirname):
self.outdir = dirname
self.logger.debug('Output directory set to {0}'.format(self.outdir))
else:
self.w.outdir.set_text(self.outdir)
... | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/SaveImage.py#L314-L322 |
set working directory | python | def get_working_dir(script__file__):
""" hardcoded sets the 'equivalent' working directory if not in git """
start = Path(script__file__).resolve()
_root = Path(start.root)
working_dir = start
while not list(working_dir.glob('.git')):
if working_dir == _root:
return
work... | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/utils.py#L23-L34 |
set working directory | python | def setup_dir(self):
"""Change directory for script if necessary."""
cd = self.opts.cd or self.config['crony'].get('directory')
if cd:
self.logger.debug(f'Adding cd to {cd}')
self.cmd = f'cd {cd} && {self.cmd}' | https://github.com/youversion/crony/blob/c93d14b809a2e878f1b9d6d53d5a04947896583b/crony/crony.py#L160-L165 |
set working directory | python | def cwd():
"""Return the be current working directory"""
cwd = os.environ.get("BE_CWD")
if cwd and not os.path.isdir(cwd):
sys.stderr.write("ERROR: %s is not a directory" % cwd)
sys.exit(lib.USER_ERROR)
return cwd or os.getcwd().replace("\\", "/") | https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L52-L58 |
set working directory | python | def working_area(files, name=""):
"""
Copy all files to a temporary directory (the working area)
Optionally names the working area name
Returns path to the working area
"""
with tempfile.TemporaryDirectory() as dir:
dir = Path(Path(dir) / name)
dir.mkdir(exist_ok=True)
f... | https://github.com/cs50/lib50/blob/941767f6c0a3b81af0cdea48c25c8d5a761086eb/lib50/_api.py#L101-L115 |
set working directory | python | def cd(directory):
"""Change the current working directory, temporarily.
Use as a context manager: with cd(d): ...
"""
old_dir = os.getcwd()
try:
os.chdir(directory)
yield
finally:
os.chdir(old_dir) | https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L164-L174 |
set working directory | python | def change_dir(self, session, path):
"""
Changes the working directory
"""
if path == "-":
# Previous directory
path = self._previous_path or "."
try:
previous = os.getcwd()
os.chdir(path)
except IOError as ex:
... | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L704-L721 |
set working directory | python | def preserve_set_th1_add_directory(state=True):
"""
Context manager to temporarily set TH1.AddDirectory() state
"""
with LOCK:
status = ROOT.TH1.AddDirectoryStatus()
try:
ROOT.TH1.AddDirectory(state)
yield
finally:
ROOT.TH1.AddDirectory(status) | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/context.py#L167-L177 |
set working directory | python | def setdirs(outfiles):
"""Create the directories if need be"""
for k in outfiles:
fname=outfiles[k]
dname= os.path.dirname(fname)
if not os.path.isdir(dname):
os.mkdir(dname) | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/commissioning/convert/convertcases.py#L76-L82 |
set working directory | python | def step_a_new_working_directory(context):
"""
Creates a new, empty working directory
"""
command_util.ensure_context_attribute_exists(context, "workdir", None)
command_util.ensure_workdir_exists(context)
shutil.rmtree(context.workdir, ignore_errors=True) | https://github.com/e7dal/bubble3/blob/59c735281a95b44f6263a25f4d6ce24fca520082/behave4cmd0/command_steps.py#L79-L85 |
set working directory | python | def chdir(directory):
"""Change the current working directory to a different directory for a code
block and return the previous directory after the block exits. Useful to
run commands from a specificed directory.
:param str directory: The directory path to change to for this context.
"""
cur = ... | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L883-L894 |
set working directory | python | def settings_dir(self):
"""
Directory that contains the the settings for the project
"""
path = os.path.join(self.dir, '.dsb')
utils.create_dir(path)
return os.path.realpath(path) | https://github.com/danielfrg/datasciencebox/blob/6b7aa642c6616a46547035fcb815acc1de605a6f/datasciencebox/core/project.py#L58-L64 |
set working directory | python | def set_cwd(new_path):
"""
Usage:
with set_cwd('/some/dir'):
walk_around_the_filesystem()
"""
try:
curdir = os.getcwd()
except OSError:
curdir = new_path
try:
os.chdir(new_path)
yield
finally:
os.chdir(curdir) | https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/context.py#L8-L23 |
set working directory | python | def mkdir(dirs, user=None, group=None, mode=None, use_sudo=True):
"""Create directory with sudo and octal mode, then set ownership."""
if isinstance(dirs, basestring):
dirs = [dirs]
runner = sudo if use_sudo else run
if dirs:
modearg = '-m {:o}'.format(mode) if mode else ''
cmd =... | https://github.com/gpoulter/fablib/blob/5d14c4d998f79dd1aa3207063c3d06e30e3e2bf9/fablib.py#L112-L123 |
set working directory | python | def cd(self, *subpaths):
"""
Change the current working directory and update all the paths in the
workspace. This is useful for commands that have to be run from a
certain directory.
"""
target = os.path.join(*subpaths)
os.chdir(target) | https://github.com/Kortemme-Lab/pull_into_place/blob/247f303100a612cc90cf31c86e4fe5052eb28c8d/pull_into_place/pipeline.py#L340-L347 |
set working directory | python | def set_current_client_working_directory(self, directory):
"""Set current client working directory."""
shellwidget = self.get_current_shellwidget()
if shellwidget is not None:
shellwidget.set_cwd(directory) | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L571-L575 |
set working directory | python | def _ensure_dir(directory, description):
"""
Ensure the given directory exists, creating it if not.
@raise errors.FatalError: if the directory could not be created.
"""
if not os.path.exists(directory):
try:
os.makedirs(directory)
except OSError, e:
sys.stder... | https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/common/run.py#L247-L258 |
set working directory | python | def as_cwd():
""" Use workdir.options.path as a temporary working directory """
_set_log_level()
owd = os.getcwd()
logger.debug('entering working directory: ' + options.path)
os.chdir(os.path.expanduser(options.path))
yield
logger.debug('returning to original directory: ' + owd)
os.chdir... | https://github.com/ajk8/workdir-python/blob/44a62f45cefb9a1b834d23191e88340b790a553e/workdir/__init__.py#L38-L46 |
set working directory | python | def setup_dirs():
"""Make required directories to hold logfile.
:returns: str
"""
try:
top_dir = os.path.abspath(os.path.expanduser(os.environ["XDG_CACHE_HOME"]))
except KeyError:
top_dir = os.path.abspath(os.path.expanduser("~/.cache"))
our_cache_dir = os.path.join(top_dir, PRO... | https://github.com/TomasTomecek/sen/blob/239b4868125814e8bf5527708119fc08b35f6cc0/sen/util.py#L42-L53 |
set working directory | python | def chdir(path):
"""Change the working directory to `path` for the duration of this context
manager.
:param str path: The path to change to
"""
cur_cwd = os.getcwd()
os.chdir(path)
try:
yield
finally:
os.chdir(cur_cwd) | https://github.com/naphatkrit/temp-utils/blob/4b0cb5a76fcaa9f3b5db05ed1f5f7a1979a86d2c/temp_utils/contextmanagers.py#L9-L20 |
set working directory | python | def cd(path):
"""Context manager to temporarily change working directories
:param str path: The directory to move into
>>> print(os.path.abspath(os.curdir))
'/home/user/code/myrepo'
>>> with cd("/home/user/code/otherdir/subdir"):
... print("Changed directory: %s" % os.path.abspath(os.curdi... | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/contextmanagers.py#L63-L85 |
set working directory | python | def chdir(self, target_directory):
"""Change current working directory to target directory.
Args:
target_directory: The path to new current working directory.
Raises:
OSError: if user lacks permission to enter the argument directory
or if the target is n... | https://github.com/jmcgeheeiv/pyfakefs/blob/6c36fb8987108107fc861fc3013620d46c7d2f9c/pyfakefs/fake_filesystem.py#L3813-L3831 |
set working directory | python | def get_DIR(self):
"""
Dialog that allows user to choose a working directory
"""
dlg = wx.DirDialog(self, "Choose a directory:", defaultPath=self.currentDirectory,
style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON | wx.DD_CHANGE_DIR)
ok = self.show_dlg(d... | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/demag_gui.py#L5093-L5106 |
set working directory | python | def cd(self, folder):
""" Changes the working directory on the server.
:param folder: the desired directory.
:type folder: string
"""
if folder.startswith('/'):
self._ftp.cwd(folder)
else:
for subfolder in folder.split('/'):
if sub... | https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/ftp_utils.py#L130-L141 |
set working directory | python | def ensure_dir(self, *path_parts):
"""Ensures a subdirectory of the working directory.
Parameters
----------
path_parts : iterable[str]
The parts of the path after the working directory.
"""
path = self.getpath(*path_parts)
ensure_directory(path)
... | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/cache.py#L358-L368 |
set working directory | python | def pwd(editor, location):
" Change working directory. "
try:
os.chdir(location)
except OSError as e:
editor.show_message('{}'.format(e)) | https://github.com/prompt-toolkit/pyvim/blob/5928b53b9d700863c1a06d2181a034a955f94594/pyvim/commands/commands.py#L412-L417 |
set working directory | python | def performInDirectory(dirPath):
"""
Change the current working directory to dirPath before performing
an operation, then restore the original working directory after
"""
originalDirectoryPath = os.getcwd()
try:
os.chdir(dirPath)
yield
finally:
os.chdir(originalDirect... | https://github.com/ga4gh/ga4gh-common/blob/ea1b562dce5bf088ac4577b838cfac7745f08346/ga4gh/common/utils.py#L339-L349 |
set working directory | python | def set_workdir(self, workdir, chroot=False):
"""Set the working directory of the task."""
super().set_workdir(workdir, chroot=chroot)
# Small hack: the log file of optics is actually the main output file.
self.output_file = self.log_file | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/tasks.py#L4149-L4153 |
set working directory | python | def cd(self, remote):
""" Change working directory on server """
try:
self.conn.cwd(remote)
except Exception:
return False
else:
return self.pwd() | https://github.com/codebynumbers/ftpretty/blob/5ee6e2cc679199ff52d1cd2ed1b0613f12aa6f67/ftpretty.py#L196-L203 |
set working directory | python | def chdir(self, dir, change_os_dir=0):
"""Change the current working directory for lookups.
If change_os_dir is true, we will also change the "real" cwd
to match.
"""
curr=self._cwd
try:
if dir is not None:
self._cwd = dir
if ch... | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Node/FS.py#L1168-L1181 |
set working directory | python | def set_cwd(cls, cwd):
"""
Set the cwd that is used to manipulate paths.
"""
if not cwd:
try:
cwd = os.getcwdu()
except AttributeError:
cwd = os.getcwd()
if isinstance(cwd, six.binary_type):
cwd = cwd.decode(sys.... | https://github.com/Bachmann1234/diff-cover/blob/901cb3fc986982961785e841658085ead453c6c9/diff_cover/git_path.py#L23-L35 |
set working directory | python | def chdir(directory):
"""Change the current working directory.
Args:
directory (str): Directory to go to.
"""
directory = os.path.abspath(directory)
logger.info("chdir -> %s" % directory)
try:
if not os.path.isdir(directory):
logger.error(
"chdir -> %... | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/shell/__init__.py#L73-L91 |
set working directory | python | def prepare(self):
"""
Prepare the Directory for use in an Environment.
This will create the directory if the create flag is set.
"""
if self._create:
self.create()
for k in self._children:
self._children[k]._env = self._env
self._chil... | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L336-L346 |
set working directory | python | def Cwd(directory):
'''
Context manager for current directory (uses with_statement)
e.g.:
# working on some directory
with Cwd('/home/new_dir'):
# working on new_dir
# working on some directory again
:param unicode directory:
Target directory to enter
'... | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L70-L90 |
set working directory | python | def ensure_dir (self, mode=0o777, parents=False):
"""Ensure that this path exists as a directory.
This function calls :meth:`mkdir` on this path, but does not raise an
exception if it already exists. It does raise an exception if this
path exists but is not a directory. If the directory... | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/io.py#L402-L437 |
set working directory | python | def chdir(self, directory_path, make=False):
"""Change directories and optionally make the directory if it doesn't exist."""
if os.sep in directory_path:
for directory in directory_path.split(os.sep):
if make and not self.directory_exists(directory):
try:
... | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L81-L93 |
set working directory | python | def make_dirs(path):
"""
Create directories if not exist
:param path: string
:return:
"""
try:
os.makedirs(os.path.dirname(path))
except OSError as err:
if err.errno != errno.EEXIST:
LOGGER.error('Failed to create directory ... | https://github.com/FlaskGuys/Flask-Imagine/blob/f79c6517ecb5480b63a2b3b8554edb6e2ac8be8c/flask_imagine/adapters/filesystem.py#L139-L150 |
set working directory | python | def makeDirectory(self, full_path, dummy = 40841):
"""Make a directory
>>> nd.makeDirectory('/test')
:param full_path: The full path to get the directory property. Should be end with '/'.
:return: ``True`` when success to make a directory or ``False``
"""
i... | https://github.com/carpedm20/ndrive/blob/ac58eaf8a8d46292ad752bb38047f65838b8ad2b/ndrive/client.py#L544-L564 |
set working directory | python | def make_directory(path):
""" Create directory if that not exists. """
try:
makedirs(path)
logging.debug('Directory created: {0}'.format(path))
except OSError as e:
if e.errno != errno.EEXIST:
raise | https://github.com/klen/starter/blob/24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f/starter/core.py#L42-L50 |
set working directory | python | def make_dir(cls, directory_name):
"""Create a directory in the system"""
if not os.path.exists(directory_name):
os.makedirs(directory_name) | https://github.com/jordanncg/Bison/blob/c7f04fd67d141fe26cd29db3c3fb3fc0fd0c45df/bison/libs/common.py#L35-L38 |
set working directory | python | def set_folder(self, folder='assets'):
"""
Changes the file folder to look at
:param folder: str [images, assets]
:return: None
"""
folder = folder.replace('/', '.')
self._endpoint = 'files/{folder}'.format(folder=folder) | https://github.com/divio/python-mautic/blob/1fbff629070200002373c5e94c75e01561df418a/mautic/files.py#L10-L18 |
set working directory | python | def chdir(self, directory, browsing_history=False,
refresh_explorer=True, refresh_console=True):
"""Set directory as working directory"""
if directory:
directory = osp.abspath(to_text_string(directory))
# Working directory history management
if browsing_... | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/workingdirectory/plugin.py#L211-L240 |
set working directory | python | def _set_results_dir(self):
"""Create results directory if not exists."""
if self.running_instance_id:
self.results_dir = os.path.join(
self.results_dir,
self.cloud,
self.image_id,
self.running_instance_id
)
... | https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L368-L407 |
set working directory | python | def create(self, segment):
"""A best-effort attempt to create directories.
Warnings are issued to the user if those directories could not
created or if they don't exist.
The caller should only call this function if the user
requested prefetching (i.e. concurrency) to avoid spur... | https://github.com/wal-e/wal-e/blob/027263860e72a403bc0e1497bb3e67523138e7a2/wal_e/worker/prefetch.py#L91-L128 |
set working directory | python | def create():
""" Create workdir.options.path """
if not os.path.isdir(options.path):
logger.info('creating working directory: ' + options.path)
os.makedirs(options.path) | https://github.com/ajk8/workdir-python/blob/44a62f45cefb9a1b834d23191e88340b790a553e/workdir/__init__.py#L87-L91 |
set working directory | python | def node_working_directory(self, node):
"""
Returns a working directory for a specific node.
If the directory doesn't exist, the directory is created.
:param node: Node instance
:returns: Node working directory
"""
workdir = self.node_working_path(node)
... | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project.py#L200-L216 |
set working directory | python | def set_directory(robject):
"""
Context manager to temporarily set the directory of a ROOT object
(if possible)
"""
if (not hasattr(robject, 'GetDirectory') or
not hasattr(robject, 'SetDirectory')):
log.warning("Cannot set the directory of a `{0}`".format(
type(robject)))... | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/context.py#L146-L163 |
set working directory | python | def make_dir(self):
"""Make the directory where the file is located."""
if not os.path.exists(self.dirname):
os.makedirs(self.dirname) | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/utils.py#L124-L127 |
set working directory | python | def change_directory(path=None):
"""
Context manager that changes directory and resets it when existing
>>> with change_directory('/tmp'):
>>> pass
"""
if path is not None:
try:
oldpwd = getcwd()
logger.debug('changing directory from %s to %s' % (oldpwd, ... | https://github.com/devopsconsulting/vdt.version/blob/25854ac9e1a26f1c7d31c26fd012781f05570574/vdt/version/utils.py#L81-L97 |
set working directory | python | def ensure_dir(self, mode=0777):
"""
Make sure the directory exists, create if necessary.
"""
if not self.exists() or not self.isdir():
os.makedirs(self, mode) | https://github.com/olt/scriptine/blob/f4cfea939f2f3ad352b24c5f6410f79e78723d0e/scriptine/_path.py#L914-L919 |
set working directory | python | def directory(name,
user=None,
group=None,
recurse=None,
max_depth=None,
dir_mode=None,
file_mode=None,
makedirs=False,
clean=False,
require=None,
exclude_pat=None,
f... | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L3104-L3638 |
set working directory | python | def do_cd(self, path = '/'):
"""change current working directory"""
path = path[0]
if path == "..":
self.current_path = "/".join(self.current_path[:-1].split("/")[0:-1]) + '/'
elif path == '/':
self.current_path = "/"
else:
if path[-1] == '/':... | https://github.com/carpedm20/ndrive/blob/ac58eaf8a8d46292ad752bb38047f65838b8ad2b/cmdline.py#L84-L112 |
set working directory | python | def set_up_dirs(proc_name, output_dir=None, work_dir=None, log_dir=None):
""" Creates output_dir, work_dir, and sets up log
"""
output_dir = safe_mkdir(adjust_path(output_dir or join(os.getcwd(), proc_name)), 'output_dir')
debug('Saving results into ' + output_dir)
work_dir = safe_mkdir(work_dir or... | https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/proc_args.py#L112-L123 |
set working directory | python | def pushd(directory):
"""Change working directories in style and stay organized!
:param directory: Where do you want to go and remember?
:return: saved directory stack
"""
directory = os.path.expanduser(directory)
_saved_paths.insert(0, os.path.abspath(os.getcwd()))
os.chdir(directory)
... | https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/cli.py#L47-L56 |
set working directory | python | def make_directory(directory):
"""
Makes directory if it does not exist.
Parameters
-----------
directory : :obj:`str`
Directory path
"""
if not os.path.isdir(directory):
os.mkdir(directory)
logger.info('Path {} not found, I will create it.'
.for... | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/tools/config.py#L171-L184 |
set working directory | python | def make(self):
"""
Creates this directory and any of the missing directories in the path.
Any errors that may occur are eaten.
"""
try:
if not self.exists:
logger.info("Creating %s" % self.path)
os.makedirs(self.path)
except os... | https://github.com/hyde/fswrap/blob/41e4ad6f7e9ba73eabe61bd97847cd284e3edbd2/fswrap.py#L549-L560 |
set working directory | python | def create_dir(path):
""" Create directory specified by `path` if it doesn't already exist.
Parameters
----------
path : str
path to directory
Returns
-------
bool
True if `path` exists
"""
# https://stackoverflow.com/a/5032238
try:
os.makedirs(path, exi... | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/__init__.py#L859-L882 |
set working directory | python | def mkdir(path,
owner=None,
grant_perms=None,
deny_perms=None,
inheritance=True,
reset=False):
'''
Ensure that the directory is available and permissions are set.
Args:
path (str):
The full path to the directory.
owner (str):
... | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_file.py#L1230-L1332 |
set working directory | python | def set_local_path(directory, create_dir=False):
"""
sets path for local saving of information
if create is true we will create the folder even if it doesnt exist
"""
if not os.path.exists(directory) and create_dir is True:
os.makedirs(directory)
if not os.path.exists(directory)... | https://github.com/rinocloud/rinocloud-python/blob/7c4bf994a518f961cffedb7260fc1e4fa1838b38/rinocloud/config.py#L6-L20 |
set working directory | python | def set_server_dir(self, dir):
"""
Set the directory of the server to be controlled
"""
self.dir = os.path.abspath(dir)
config = os.path.join(self.dir, 'etc', 'grid', 'config.xml')
self.configured = os.path.exists(config) | https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/external.py#L55-L61 |
set working directory | python | def make_dir(self, path, relative=False):
"""
Make a directory.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root.
"""
if not relative:
path = self.relpath(path)
self._make_dir(self.get_client_kwargs(self... | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L489-L500 |
set working directory | python | def mkdir(path, owner='root', group='root', perms=0o555, force=False):
"""Create a directory"""
log("Making dir {} {}:{} {:o}".format(path, owner, group,
perms))
uid = pwd.getpwnam(owner).pw_uid
gid = grp.getgrnam(group).gr_gid
realpath = os.path.abspath(pat... | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L517-L533 |
set working directory | python | def get_DIR(self, WD=None):
"""
open dialog box for choosing a working directory
"""
if "-WD" in sys.argv and FIRST_RUN:
ind = sys.argv.index('-WD')
self.WD = sys.argv[ind + 1]
elif not WD: # if no arg was passed in for WD, make a dialog to choose one
... | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/thellier_gui.py#L465-L495 |
set working directory | python | def do_work(self):
""" Do work """
self._starttime = time.time()
if not os.path.isdir(self._dir2):
if self._maketarget:
if self._verbose:
self.log('Creating directory %s' % self._dir2)
try:
os.makedirs(self._di... | https://github.com/tkhyn/dirsync/blob/a461a6c31a4cf521c1b6a8bcfcd8602e6288e8ce/dirsync/syncer.py#L183-L201 |
set working directory | python | def mkdir(self, path, mode=o777):
"""
Create a folder (directory) named ``path`` with numeric mode ``mode``.
The default mode is 0777 (octal). On some systems, mode is ignored.
Where it is used, the current umask value is first masked out.
:param str path: name of the folder to... | https://github.com/paramiko/paramiko/blob/cf7d49d66f3b1fbc8b0853518a54050182b3b5eb/paramiko/sftp_client.py#L447-L460 |
set working directory | python | def make_directories(self):
"""
Checks if required directories exist and creates them if needed.
"""
if os.path.isdir(self.workdir) == False: os.mkdir(self.workdir) | https://github.com/lcharleux/argiope/blob/8170e431362dc760589f7d141090fd133dece259/argiope/models.py#L36-L40 |
set working directory | python | def change_directory(self, directory):
"""
Changes the current directory.
Change is made by running a "cd" command followed by a "clear" command.
:param directory:
:return:
"""
self._process.write(('cd %s\n' % directory).encode())
if sys.platform == 'win3... | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/terminal.py#L49-L62 |
set working directory | python | def mkdirs(path, mode):
"""
Creates the directory specified by path, creating intermediate directories
as necessary. If directory already exists, this is a no-op.
:param path: The directory to create
:type path: str
:param mode: The mode to give to the directory e.g. 0o755, ignores umask
:t... | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/file.py#L42-L59 |
set working directory | python | def ensure_dir_exists(directory):
"Creates local directories if they don't exist."
if directory.startswith('gs://'):
return
if not os.path.exists(directory):
dbg("Making dir {}".format(directory))
os.makedirs(directory, exist_ok=True) | https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/utils.py#L32-L38 |
set working directory | python | def make_directory(path):
"""
Make a directory and any intermediate directories that don't already
exist. This function handles the case where two threads try to create
a directory at once.
"""
if not os.path.exists(path):
# concurrent writes that try to create the same dir can fail
... | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/clients/system.py#L71-L86 |
set working directory | python | def create_directory(self, path, mode=777):
"""
Creates a directory on the remote system.
:param path: full path to the remote directory to create
:type path: str
:param mode: int representation of octal mode for directory
"""
conn = self.get_conn()
conn.m... | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/sftp_hook.py#L155-L163 |
set working directory | python | def create_dir(directory):
"""Create given directory, if doesn't exist.
Parameters
----------
directory : string
Directory path (can be relative or absolute)
Returns
-------
string
Absolute directory path
"""
if not os.access(directory, os.F_OK):
os.makedirs... | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L1212-L1227 |
set working directory | python | def set_dir(self, dir_):
"""Sets directory, auto-loads, updates all GUI contents."""
self.__lock_set_dir(dir_)
self.__lock_auto_load()
self.__lock_update_table()
self.__update_info()
self.__update_window_title() | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/gui/a_XExplorer.py#L320-L327 |
set working directory | python | def cd(self, dir_p):
"""Change the current directory level.
in dir_p of type str
The name of the directory to go in.
return progress of type :class:`IProgress`
Progress object to track the operation completion.
"""
if not isinstance(dir_p, basestring):
... | https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L8736-L8751 |
set working directory | python | def git_working_dir(func):
"""Decorator which changes the current working dir to the one of the git
repository in order to assure relative paths are handled correctly"""
@wraps(func)
def set_git_working_dir(self, *args, **kwargs):
cur_wd = os.getcwd()
os.chdir(self.repo.working_tree_dir... | https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/index/util.py#L82-L97 |
set working directory | python | def cd(self, newdir):
"""
go to the path
"""
prevdir = os.getcwd()
os.chdir(newdir)
try:
yield
finally:
os.chdir(prevdir) | https://github.com/chairco/pyRscript/blob/e952f450a873de52baa4fe80ed901f0cf990c0b7/pyRscript/pyRscript.py#L52-L61 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.