Proposes a name for the backup file.

			Keyword arguments:
			path -- temporal filename
426703
def get_backup_filename(self, path):
		
		head = datetime.utcnow().replace(tzinfo=pytz.UTC).strftime("%Y%m%d%H%M%S")
		self.backup = "stations/backup/%s.%s" % (head, path)
		return self.backup
1121682
def __format_path(self, path):
        
        # Unicode strings are converted back to strings, because it seems
        # that inotify_add_watch from ctypes does not work well when
        # it receives an ctypes.create_unicode_buffer instance as argument.
        # Therefore even wd are indexed with bytes string and not with
        # unicode paths.
        if isinstance(path, unicode):
            path = path.encode(sys.getfilesystemencoding())
        return os.path.normpath(path)
1224064
def atomic_create_file(file_path):
    """"""
    fd, tmp_file_path = tempfile.mkstemp(
        prefix=os.path.basename(file_path), dir=os.path.dirname(file_path), suffix=".metadata_tmp"
    )
    try:
        with os.fdopen(fd, "w") as out_file:
            yield out_file

        os.rename(tmp_file_path, file_path)
    except Exception:  # pytest: disable=broad-except
        with contextlib.suppress(Exception):
            os.unlink(tmp_file_path)
        raise
836036
def upload_path(instance, filename):
    '''
        
    '''

    filename = filename.replace(" ", "_")
    filename = unicodedata.normalize('NFKD', filename).lower()
    return os.path.join(str(timezone.now().date().isoformat()), filename)
562887
def write_path(path, s, owner=None, group=None, mode=None,
               utimes=None, sync=False):
    
    path = os.path.abspath(path)
    fd, tmp_path = tempfile.mkstemp(suffix='.tmp',
                                    prefix='.ansible_mitogen_transfer-',
                                    dir=os.path.dirname(path))
    fp = os.fdopen(fd, 'wb', mitogen.core.CHUNK_SIZE)
    LOG.debug('write_path(path=%r) temporary file: %s', path, tmp_path)

    try:
        try:
            if mode:
                set_file_mode(tmp_path, mode, fd=fp.fileno())
            if owner or group:
                set_file_owner(tmp_path, owner, group, fd=fp.fileno())
            fp.write(s)
        finally:
            fp.close()

        if sync:
            os.fsync(fp.fileno())
        os.rename(tmp_path, path)
    except BaseException:
        os.unlink(tmp_path)
        raise

    if utimes:
        os.utime(path, utimes)
21950
def path(self, **kwargs):
        
        new_path = path(self.getPath(), **kwargs)
        return File(new_path)
641320
def extant_file(path):
    
    if not os.path.exists(path):
        raise argparse.ArgumentTypeError("{} does not exist".format(path))
    return path
774438
def dump_file_by_path(self, path, **kwargs):
        
        file = self.state.fs.get(path)
        if file is None:
            return None
        return file.concretize(**kwargs)
1087246
def _backup_dir_item(self, dir_path, process_bar):
        
        self.path_helper.set_src_filepath(dir_path)
        if self.path_helper.abs_src_filepath is None:
            self.total_errored_items += 1
            log.info("Can't backup %r", dir_path)

        # self.summary(no, dir_path.stat.st_mtime, end=" ")
        if dir_path.is_symlink:
            self.summary("TODO Symlink: %s" % dir_path)
            return

        if dir_path.resolve_error is not None:
            self.summary("TODO resolve error: %s" % dir_path.resolve_error)
            pprint_path(dir_path)
            return

        if dir_path.different_path:
            self.summary("TODO different path:")
            pprint_path(dir_path)
            return

        if dir_path.is_dir:
            self.summary("TODO dir: %s" % dir_path)
        elif dir_path.is_file:
            # self.summary("Normal file: %s", dir_path)

            file_backup = FileBackup(dir_path, self.path_helper, self.backup_run)
            old_backup_entry = self.fast_compare(dir_path)
            if old_backup_entry is not None:
                # We can just link the file from a old backup
                file_backup.fast_deduplication_backup(old_backup_entry, process_bar)
            else:
                file_backup.deduplication_backup(process_bar)

            assert file_backup.fast_backup is not None, dir_path.path
            assert file_backup.file_linked is not None, dir_path.path

            file_size = dir_path.stat.st_size
            if file_backup.file_linked:
                # os.link() was used
                self.total_file_link_count += 1
                self.total_stined_bytes += file_size
            else:
                self.total_new_file_count += 1
                self.total_new_bytes += file_size

            if file_backup.fast_backup:
                self.total_fast_backup += 1
        else:
            self.summary("TODO:" % dir_path)
            pprint_path(dir_path)
762628
def path_to_url2(path):
    
    path = os.path.normpath(os.path.abspath(path))
    drive, path = os.path.splitdrive(path)
    filepath = path.split(os.path.sep)
    url = '/'.join([urllib.quote(part) for part in filepath])
    if not drive:
        url = url.lstrip('/')
    return 'file:///' + drive + url
1003952
def dirname(path: Optional[str]) -> Optional[str]:
    
    if path is not None:
        return os.path.dirname(path)
1242098
def _backup_file(path):
    
    backup_base = '/var/local/woven-backup'
    backup_path = ''.join([backup_base,path])
    if not exists(backup_path):
        directory = ''.join([backup_base,os.path.split(path)[0]])
        sudo('mkdir -p %s'% directory)
        sudo('cp %s %s'% (path,backup_path))
930428
def tmp_file(*args, **kwargs):
    
    fileno, path = tempfile.mkstemp(*args, **kwargs)

    # create the file
    with open(path, "w") as f:
        f.write("")

    # yield it
    try:
        yield fileno, path
    finally:
        if os.path.exists(path):
            os.remove(path)
1232819
public static String getFilename(String path) throws IllegalArgumentException {
        if (Pattern.matches(sPatternUrl, path))
            return getURLFilename(path);

        return new File(path).getName();
    }
241340
def _get_filename_path(self, path):
        
        feature_filename = os.path.join(path, self.feature_type.value)

        if self.feature_name is not None:
            feature_filename = os.path.join(feature_filename, self.feature_name)

        return feature_filename
123924
def tmppath(path=None, include_unix_username=True):
    
    addon = "luigitemp-%08d" % random.randrange(1e9)
    temp_dir = '/tmp'  # default tmp dir if none is specified in config

    # 1. Figure out to which temporary directory to place
    configured_hdfs_tmp_dir = hdfs().tmp_dir
    if configured_hdfs_tmp_dir is not None:
        # config is superior
        base_dir = configured_hdfs_tmp_dir
    elif path is not None:
        # need to copy correct schema and network location
        parsed = urlparse(path)
        base_dir = urlunparse((parsed.scheme, parsed.netloc, temp_dir, '', '', ''))
    else:
        # just system temporary directory
        base_dir = temp_dir

    # 2. Figure out what to place
    if path is not None:
        if path.startswith(temp_dir + '/'):
            # Not 100%, but some protection from directories like /tmp/tmp/file
            subdir = path[len(temp_dir):]
        else:
            # Protection from /tmp/hdfs:/dir/file
            parsed = urlparse(path)
            subdir = parsed.path
        subdir = subdir.lstrip('/') + '-'
    else:
        # just return any random temporary location
        subdir = ''

    if include_unix_username:
        subdir = os.path.join(getpass.getuser(), subdir)

    return os.path.join(base_dir, subdir + addon)
186621
def set_tmp_folder():
    
    output = "%s" % datetime.datetime.now()
    for char in [' ', ':', '.', '-']:
        output = output.replace(char, '')
    output.strip()
    tmp_folder = os.path.join(tempfile.gettempdir(), output)
    return tmp_folder