def mkdir(dir): dir = dir.replace(' ', '_') try: _mkdir(dir) except FileExistsError: pass return dir
def load_graph(self, args, **kwargs): graph = caffe.Net(args.networkfile, args.weights, caffe.TEST) self.save = args.save if self.save and not _exists(self.save): _mkdir(self.save) inputs = self.inputs if self.inputs else self.list_inputs_of_graph(graph) outputs = self.outputs if self.outputs else self.list_outputs_of_graph(graph) return graph, inputs, outputs
def make_database(): config = _get_config_filepath() battle_path = get_database_filepath() if not _path.isdir(config): _mkdir(config) if not _path.isdir(battle_path): _mkdir(battle_path) battle_database = _path.join(battle_path, 'materials.sqlite') if not _path.isfile(battle_database): engine = _create_engine('sqlite:///{}'.format(database_filepath)) Base.metadata.create_all(engine)
def create_virtualenv(directory=None, pyver=None, interpreter='python'): """ Create a virtual environment for inyoka. :param directory: Where to create this virtual environment (folder must not exist). :param pyver: Which Python Version to use. """ if directory is None: workon_home = os.environ.get('WORKON_HOME') if workon_home: directory = _path.join(workon_home, 'inyoka') else: directory = '../inyoka-testsuite' if not _isdir(directory): _mkdir(_path.expanduser(_path.expandvars(directory))) local('%s %s > %s' % (interpreter, _j('extra/make-bootstrap.py'), _j('bootstrap.py')), capture=False) local('%s ./bootstrap.py --no-site-packages -r %s %s' % (interpreter, _j('extra/requirements.txt'), directory), capture=False)
def make_pelican_starter_project(c, path): _make_sure_path_not_exists_but_parent_directory_does(path) _mkdir(path) _make_empty_content_tree(_join(path, 'content')) _mkdir(_join(path, 'output')) # skipping Makefile for now src = _build_starter_dir_path() # Copy over the config file (warnings without) this = 'pelicanconf.py' _copyfile(_join(src, this), _join(path, this)) # Copy the two pages over head = 'content', 'pages' for tail in 'my-one-page.md', 'my-other-page.md': this = (*head, tail) _copyfile(_join(src, *this), _join(path, *this))
def clean_up_docs(dir_path, out_dir=None, overwrite_dirty=False): if out_dir is not None: try: os._mkdir(out_dir) except: pass # presumably the directory already exists else: out_dir = dir_path print "\ncleaning documents in %s..." % dir_path for doc in [f for f in os.listdir(dir_path) if not os.path.isdir(os.path.join(dir_path, f))]: dirty_path = os.path.join(dir_path, doc) dirty_doc = open(dirty_path, "r").readline().split(" ") clean_doc = clean_up_txt(dirty_doc) out_path = dirty_path if overwrite_dirty else dirty_path + ".cleaned" if out_dir != dir_path: # then an output directory was passed in out_path = os.path.join(out_dir, doc) clean_doc_out = open(out_path, "w") clean_doc_out.write(" ".join(clean_doc)) print "documents cleaned and written."
def clean_up_docs(dir_path, out_dir = None, overwrite_dirty=False): if out_dir is not None: try: os._mkdir(out_dir) except: pass # presumably the directory already exists else: out_dir = dir_path print "\ncleaning documents in %s..." % dir_path for doc in [f for f in os.listdir(dir_path) if not os.path.isdir(os.path.join(dir_path, f))]: dirty_path = os.path.join(dir_path, doc) dirty_doc = open(dirty_path, 'r').readline().split(" ") clean_doc = clean_up_txt(dirty_doc) out_path = dirty_path if overwrite_dirty else dirty_path + ".cleaned" if out_dir != dir_path: # then an output directory was passed in out_path = os.path.join(out_dir, doc) clean_doc_out = open(out_path, 'w') clean_doc_out.write(" ".join(clean_doc)) print "documents cleaned and written."
from .wrapper import ( AstroParams, BrightnessTemp, CosmoParams, FlagOptions, HaloField, PerturbHaloField, UserParams, brightness_temperature, compute_luminosity_function, compute_tau, construct_fftw_wisdoms, determine_halo_list, get_all_fieldnames, global_params, initial_conditions, ionize_box, perturb_field, perturb_halo_list, run_coeval, run_lightcone, spin_temperature, ) configure_logging() try: _mkdir(path.expanduser(config["direc"])) except FileExistsError: pass
def test_dir(directory): if not _isdir(directory): try: _mkdir(directory) except: pass
def mkdir(path): from os import mkdir as _mkdir if exists(path) and isdir(path): return # nothing to do _mkdir(path)
def _make_empty_content_tree(here): _mkdir(here) _mkdir(_join(here, 'images')) # just to avoid a warning _mkdir(_join(here, 'pages'))