data expansion - uvision needs filename and path separately.
428111
def _expand_data(self, old_data, new_data, group):
        
        for file in old_data:
            if file:
                extension = file.split(".")[-1].lower()
                if extension in self.file_types.keys():
                    new_data['groups'][group].append(self._expand_one_file(normpath(file),
                                                                           new_data, extension))
                else:
                    logger.debug("Filetype for file %s not recognized" % file)
        if hasattr(self, '_expand_sort_key'):
            new_data['groups'][group] = sorted(new_data['groups'][group],
                                               key=self._expand_sort_key)
327814
def expand_filepath(filepath):
    
    return os.path.abspath(os.path.expandvars(os.path.expanduser(filepath)))
47212
def extname(path, **kwargs):
    """"""
    import os.path
    name, ext = os.path.splitext(path, **kwargs)
    return ext
1090420
def _add_file(self, key, path):
        """"""
        filename = os.path.basename(path)
        base, ext = os.path.splitext(filename)
        if os.path.exists(self.file_path(filename)):
            with tempfile.NamedTemporaryFile(
                    dir=self.path, prefix=base, suffix=ext) as tf:
                filename = os.path.basename(tf.name)
        shutil.copyfile(path, self.file_path(filename))
        self.contents['files'][key] = filename
529718
def resolve_file_path_list(pathlist, workdir, prefix='',
                           randomize=False):
    
    files = []
    with open(pathlist, 'r') as f:
        files = [line.strip() for line in f]

    newfiles = []
    for f in files:
        f = os.path.expandvars(f)
        if os.path.isfile(f):
            newfiles += [f]
        else:
            newfiles += [os.path.join(workdir, f)]

    if randomize:
        _, tmppath = tempfile.mkstemp(prefix=prefix, dir=workdir)
    else:
        tmppath = os.path.join(workdir, prefix)

    tmppath += '.txt'

    with open(tmppath, 'w') as tmpfile:
        tmpfile.write("\n".join(newfiles))
    return tmppath
532278
function appendFilename(pathStr, valueToAppend) {
  var pfile = path.parse(pathStr);
  var result = Array.prototype.join.call([
    pfile.dir,
    '/',
    pfile.name,
    valueToAppend,
    pfile.ext
  ], '');
  return result;
}
1211097
def expand_filename_pattern(pattern, base_dir):
    
    # 'join' ignores base_dir, if expandedPattern is absolute.
    # 'normpath' replaces 'A/foo/../B' with 'A/B', for pretty printing only
    pattern = os.path.normpath(os.path.join(base_dir, pattern))

    # expand tilde and variables
    pattern = os.path.expandvars(os.path.expanduser(pattern))

    # expand wildcards
    fileList = glob.glob(pattern)

    return fileList
506597
def _add_path(dir_name, payload_info_list):
    """"""
    for payload_info_dict in payload_info_list:
        file_name = payload_info_dict['filename'] or payload_info_dict['pid']
        payload_info_dict['path'] = d1_common.utils.filesystem.gen_safe_path(
            dir_name, 'data', file_name
        )
415992
function truncFilename(path, rootFolderName) {
    // bail if a string wasn't provided
    if (typeof path !== 'string') {
        return path;
    }

    var index = path.indexOf(rootFolderName);
    if (index > 0) {
        return path.substring(index + rootFolderName.length + 1);
    } else {
        return path;
    }
}
584842
def bind_path(self, name, folder):
        """"""
        if not len(name) or name[0] != '/' or name[-1] != '/':
            raise ValueError(
                "name must start and end with '/': {0}".format(name))
        self._folder_masks.insert(0, (name, folder))
974776
def extract_files(files):
    """"""
    expanded_files = []
    legal_extensions = [".md", ".txt", ".rtf", ".html", ".tex", ".markdown"]

    for f in files:
        # If it's a directory, recursively walk through it and find the files.
        if os.path.isdir(f):
            for dir_, _, filenames in os.walk(f):
                for filename in filenames:
                    fn, file_extension = os.path.splitext(filename)
                    if file_extension in legal_extensions:
                        joined_file = os.path.join(dir_, filename)
                        expanded_files.append(joined_file)

        # Otherwise add the file directly.
        else:
            expanded_files.append(f)

    return expanded_files
70751
def set_path(ctx, path_str, value, data):
    
    ctx.gbc.say('set_path:value:' + str(value) + ' at:' + path_str + ' in:',
                stuff=data, verbosity=1001)

    path = path_str.split('.')
    ctx.gbc.say('path:', stuff=path, verbosity=100)
    if len(path) > 1:
        destk = '.'.join(path[0:-1])
        lp = path[-1]
        ctx.gbc.say('destk:%s' % destk, verbosity=100)
        ctx.gbc.say('last:%s' % lp, verbosity=100)
        ctx.gbc.say('current keys:', stuff=data.keys(), verbosity=1001)
        if len(path) > 2:
            destk = unescape(ctx, destk)
        if destk not in data.keys():
            ctx.gbc.say('destk not in current keys:',
                        stuff=data.keys(), verbosity=1001)
            data[destk] = {}
            ctx.gbc.say('destk not added:', stuff=data, verbosity=1001)

        lp = unescape(ctx, lp)
        data[destk][lp] = value
        ctx.gbc.say('destk and val added:', stuff=data, verbosity=1001)
    else:
        path_str = unescape(ctx, path_str)
        data[path_str] = value
    ctx.gbc.say('set_path:res:', stuff=data, verbosity=1001)
    return data
1117701
function (data) {
      var include = function (path, includeData) {
        var d = utils.shallowCopy({}, data);
        if (includeData) {
          d = utils.shallowCopy(d, includeData);
        }
        return includeFile(path, opts)(d);
      };
      return fn.apply(opts.context, [data || {}, escapeFn, include, rethrow]);
    }
889268
function expandIncludes(source, rootPath) {
	var matcher = new RegExp("^([\t ]*)include ([^/].*);\n?", "gm");
	var match;
	var expanded = '';
	var after = source;
	var includes = [];
	var lastIndex = 0;
	while (match = matcher.exec(source)) {
		var statement = match[0];
		var indent = match[1];
		var filePath = path.join(rootPath, match[2])
		includes.push(filePath);

		expanded += source.substr(lastIndex, match.index - lastIndex);

		expanded += indent + "## Start Include: " + filePath + "\n";

		try {
			var fileContent = fs.readFileSync(filePath, 'utf8');

			// preserve indentation of the include line
			var indentedContent = singleTrailingNewline(NgindoxUtil.indentBlock(fileContent, indent));

			// recurse with relative path
			expanded += expandIncludes(indentedContent, path.dirname(rootPath));
		} catch (err) {
			// file probably missing
			expanded += indent + "## Error: " + err + "\n";
		}

		expanded += indent + "## End Include: " + filePath + "\n";

		// store end of match as begining of next search
		lastIndex = matcher.lastIndex;
	}

	expanded += source.substr(lastIndex);

	return expanded;
}
713767
def split_extension(pathname):
        
        filepart = win32.PathRemoveExtension(pathname)
        extpart  = win32.PathFindExtension(pathname)
        return (filepart, extpart)
1085244
def generic_filename(path):
    '''
    
    '''

    for sep in common_path_separators:
        if sep in path:
            _, path = path.rsplit(sep, 1)
    return path
1073318
def _add_suffix(file_path, suffix, sep='_', ext=None):
    """"""
    # Split file_path on last '.' to separate file_name and file_extension
    split = os.path.basename(file_path).rsplit('.', 1)

    # Use original file_extension if None is given
    ext = split[1] if not ext else ext.strip('.')

    # Rebuild new file_path with suffix
    return os.path.join(os.path.dirname(file_path), split[0] + sep + suffix + '.' + ext)