Persist this Vocabulary to files so it can be reloaded later.
        Each namespace corresponds to one file.

        Parameters
        ----------
        directory : ``str``
            The directory where we save the serialized vocabulary.
764061
def save_to_files(self, directory: str) -> None:
        
        os.makedirs(directory, exist_ok=True)
        if os.listdir(directory):
            logging.warning("vocabulary serialization directory %s is not empty", directory)

        with codecs.open(os.path.join(directory, NAMESPACE_PADDING_FILE), 'w', 'utf-8') as namespace_file:
            for namespace_str in self._non_padded_namespaces:
                print(namespace_str, file=namespace_file)

        for namespace, mapping in self._index_to_token.items():
            # Each namespace gets written to its own file, in index order.
            with codecs.open(os.path.join(directory, namespace + '.txt'), 'w', 'utf-8') as token_file:
                num_tokens = len(mapping)
                start_index = 1 if mapping[0] == self._padding_token else 0
                for i in range(start_index, num_tokens):
                    print(mapping[i].replace('\n', '@@NEWLINE@@'), file=token_file)
231304
def chdir(new_dir):
    
    cur_dir = os.getcwd()
    safe_mkdir(new_dir)
    os.chdir(new_dir)
    try:
        yield
    finally:
        os.chdir(cur_dir)
17130
def set_cache_dir(directory):
    
    global cache_dir

    if directory is None:
        cache_dir = None
        return

    if not os.path.exists(directory):
        os.makedirs(directory)
    if not os.path.isdir(directory):
        raise ValueError("not a directory")
    cache_dir = directory
264769
public static void purgeDirectory(File directory) {

        if (directory.canRead() && directory.isDirectory()) {
            File[] files = directory.listFiles();
            for (int i = 0; i < files.length; i++) {
                File f = files[i];
                if (f.isDirectory()) {
                    purgeDirectory(f);
                }
                if (f.canWrite()) {
                    f.delete();
                }
            }
            directory.delete();
        }
    }
542359
public void setCompileDirectory(String directory) {
        if (directory != null && directory.trim().length() > 0) {
            File file = new File(directory);
            if (file.exists() || file.mkdirs()) {
                this.compileDirectory = file;
            }
        }
    }
1371998
def save(self):
        # type: () -> None
        
        self._ensure_have_load_only()

        for fname, parser in self._modified_parsers:
            logger.info("Writing to %s", fname)

            # Ensure directory exists.
            ensure_dir(os.path.dirname(fname))

            with open(fname, "w") as f:
                parser.write(f)
972495
public void setDirectory(final String directory) {
        this.directory = new File(this.configuration.getDirectory(), directory);
        if (!this.directory.exists()) {
            throw new IllegalArgumentException(String.format(
                    "Directory does not exist: %s.\n" +
                            "Configuration contained value %s which is supposed to be relative to " +
                            "configuration directory.",
                    this.directory, directory));
        }

        if (!this.directory.getAbsolutePath()
                .startsWith(this.configuration.getDirectory().getAbsolutePath())) {
            throw new IllegalArgumentException(String.format(
                    "All files and directories must be contained in the configuration directory the " +
                            "directory provided in the configuration breaks that contract: %s in config " +
                            "file resolved to %s.",
                    directory, this.directory));
        }
    }
323950
def register_directory(self, dirpath, **kwargs):
        

        kwargs['file_extensions'] = kwargs.get("file_extensions",
                                               self.rdf_formats)
        files = list_files(file_directory=dirpath, **kwargs)
        for fileinfo in files:
            self.register_rml(fileinfo[-1], **kwargs)
746408
def create_dir(directory):
    
    if not os.access(directory, os.F_OK):
        os.makedirs(directory)
    return os.path.abspath(directory)
425072
def save_source_vocabs(source_vocabs: List[Vocab], folder: str):
    
    for i, vocab in enumerate(source_vocabs):
        vocab_to_json(vocab, os.path.join(folder, C.VOCAB_SRC_NAME % i))
658845
def make_vocab_from_args(args: argparse.Namespace):
    
    parameter_path = args.param_path
    overrides = args.overrides
    serialization_dir = args.serialization_dir

    params = Params.from_file(parameter_path, overrides)

    make_vocab_from_params(params, serialization_dir)
508659
def rrmdir(directory):
    
    for root, dirs, files in os.walk(directory, topdown=False):
        for name in files:
            os.remove(os.path.join(root, name))
        for name in dirs:
            os.rmdir(os.path.join(root, name))
    os.rmdir(directory)
1157254
def save_files(self):
        """"""
        while True:
            try:
                os.mkdir(self.output_name)
            except Exception as e:
                self.output_name = raw_input("This directory already exists - please enter a new name:")
            else:
                break
        self.workdir = os.getcwd()
        os.chdir(self.workdir+"/"+self.output_name)
1000261
private static byte[] persist(String description, Directory rootDir, Blob icon) {
		ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
		DataOutputStream dataOutputStream = new DataOutputStream(arrayOutputStream);

		try {
			// Immer erster Stelle die aktuelle Version schreiben
			dataOutputStream.writeByte(CURRENT_BINARY_VERSION);

			// Die Reihenfolge der Felder darf sich aus Gründen der
			// Kompatibilität niemals ändern. Neue Felder können hinzugefügt
			// werden. Dann ist die Version hochzusetzten.
			dataOutputStream.writeUTF(rootDir.id());
			dataOutputStream.writeUTF(description);
			dataOutputStream.writeUTF(icon != null ? icon.id() : "");
		} catch (IOException e) {
			throw new RuntimeException(e);
		}

		return arrayOutputStream.toByteArray();
	}
128330
def chdir(directory):
    
    directory = os.path.abspath(directory)
    logger.info("chdir -> %s" % directory)
    try:
        if not os.path.isdir(directory):
            logger.error(
                "chdir -> %s failed! Directory does not exist!", directory
            )
            return False
        os.chdir(directory)
        return True
    except Exception as e:
        logger.error("chdir -> %s failed! %s" % (directory, e))
        return False
831467
def save_keywords(filename, xml):
    """"""
    tmp_dir = os.path.dirname(filename)
    if not os.path.isdir(tmp_dir):
        os.mkdir(tmp_dir)

    file_desc = open(filename, "w")
    file_desc.write(xml)
    file_desc.close()
238374
public static void createDirectory( File directory ) throws IOException {

		if( ! directory.exists()
				&& ! directory.mkdirs())
			throw new IOException( "The directory " + directory + " could not be created." );
	}