Processes filename into argument form
481406
protected String prepareFilename(final StringBuffer buf, final String outputDir, final String sourceFile) {
    // FREEHEP BEGIN exit if absolute path is too long. Max length on relative
    // paths in windows is even shorter.
    if (isWindows() && sourceFile.length() > this.maxPathLength) {
      throw new BuildException("Absolute path too long, " + sourceFile.length() + " > " + this.maxPathLength + ": '"
          + sourceFile);
    }
    // FREEHEP END
    return quoteFilename(buf, sourceFile);
  }
445080
def sanitize_filename(filename):
    
    sanitized_filename = re.sub(r'[/\\:*?"<>|]', '-', filename)
    sanitized_filename = sanitized_filename.replace('&', 'and')
    sanitized_filename = sanitized_filename.replace('"', '')
    sanitized_filename = sanitized_filename.replace("'", '')
    sanitized_filename = sanitized_filename.replace("/", '')
    sanitized_filename = sanitized_filename.replace("\\", '')

    # Annoying.
    if sanitized_filename[0] == '.':
        sanitized_filename = u'dot' + sanitized_filename[1:]

    return sanitized_filename
331522
def file_arg(arg):
    
    prefix = 'file://'

    if arg.startswith(prefix):
        return os.path.abspath(arg[len(prefix):])
    else:
        msg = 'Invalid file argument "{}", does not begin with "file://"'
        raise argparse.ArgumentTypeError(msg.format(arg))
1147290
def file_to_str(fname):
    
    data = None
    # rU = read with Universal line terminator
    with open(fname, 'rU') as fd:
        data = fd.read()
    return data
689398
def input_file(filename):
    
    if excluded(filename) or not filename_match(filename):
        return {}
    if options.verbose:
        message('checking ' + filename)
    options.counters['files'] = options.counters.get('files', 0) + 1
    errors = Checker(filename).check_all()
    if options.testsuite and not errors:
        message("%s: %s" % (filename, "no errors found"))
    return errors
1068267
def process_arguments(arguments):
    """"""
    Settings.update(arguments)

    Settings.config_program_reqs(PROGRAMS)

    Settings.verbose = arguments.verbose + 1
    Settings.paths = set(arguments.paths)

    if arguments.formats == DEFAULT_FORMATS:
        Settings.formats = arguments.to_png_formats | \
            jpeg.FORMATS | gif.FORMATS
    else:
        Settings.formats = set(
            arguments.formats.upper().split(FORMAT_DELIMETER))

    if arguments.comics:
        Settings.formats = Settings.formats | comic.FORMATS

    if arguments.optimize_after is not None:
        try:
            after_dt = dateutil.parser.parse(arguments.optimize_after)
            arguments.optimize_after = time.mktime(after_dt.timetuple())
        except Exception as ex:
            print(ex)
            print('Could not parse date to optimize after.')
            exit(1)

    if arguments.jobs < 1:
        Settings.jobs = 1

    # Make a rough guess about weather or not to invoke multithreding
    # jpegrescan '-t' uses three threads
    # one off multithread switch bcaseu this is the only one right now
    files_in_paths = 0
    non_file_in_paths = False
    for filename in arguments.paths:
        if os.path.isfile(filename):
            files_in_paths += 1
        else:
            non_file_in_paths = True
    Settings.jpegrescan_multithread = not non_file_in_paths and \
        Settings.jobs - (files_in_paths*3) > -1

    return arguments
1085244
def generic_filename(path):
    '''
    
    '''

    for sep in common_path_separators:
        if sep in path:
            _, path = path.rsplit(sep, 1)
    return path
571586
def template_from_filename(filename):
    """"""
    ext = filename.split(os.path.extsep)[-1]
    if not ext in TEMPLATES_MAP:
        raise ValueError("No template for file extension {}".format(ext))
    return TEMPLATES_MAP[ext]
473595
def process(filename, encoding=DEFAULT_ENCODING, extension=None, **kwargs):
    

    # make sure the filename exists
    if not os.path.exists(filename):
        raise exceptions.MissingFileError(filename)

    # get the filename extension, which is something like .docx for
    # example, and import the module dynamically using importlib. This
    # is a relative import so the name of the package is necessary
    # normally, file extension will be extracted from the file name
    # if the file name has no extension, then the user can pass the
    # extension as an argument
    if extension:
        ext = extension
        # check if the extension has the leading .
        if not ext.startswith('.'):
            ext = '.' + ext
        ext = ext.lower()
    else:
        _, ext = os.path.splitext(filename)
        ext = ext.lower()

    # check the EXTENSION_SYNONYMS dictionary
    ext = EXTENSION_SYNONYMS.get(ext, ext)

    # to avoid conflicts with packages that are installed globally
    # (e.g. python's json module), all extension parser modules have
    # the _parser extension
    rel_module = ext + _FILENAME_SUFFIX

    # If we can't import the module, the file extension isn't currently
    # supported
    try:
        filetype_module = importlib.import_module(
            rel_module, 'textract.parsers'
        )
    except ImportError:
        raise exceptions.ExtensionNotSupported(ext)

    # do the extraction

    parser = filetype_module.Parser()
    return parser.process(filename, encoding, **kwargs)
228842
def split_input(args):
    """"""
    args['files'] = []
    args['urls'] = []
    for arg in args['query']:
        if os.path.isfile(arg):
            args['files'].append(arg)
        else:
            args['urls'].append(arg.strip('/'))
986230
def normalizeFilename(filename):
    
    result = os.path.expanduser(filename)
    result = os.path.abspath(result)
    return result
84063
def _parse_arguments():
    """"""
    parser = argparse.ArgumentParser(description="CMake AST Dumper")
    parser.add_argument("filename", nargs=1, metavar=("FILE"),
                        help="read FILE")
    return parser.parse_args()
322098
def _file_name(fname, base_dir):
        

        fname = fname.replace("\\", "\\\\")

        if base_dir != '' and fname[0] != ':' and not os.path.isabs(fname):
            fname = os.path.join(base_dir, fname)

        return fname
237606
def format_filename(self, item: Union[Post, StoryItem], target: Optional[str] = None):
        """"""
        return _PostPathFormatter(item).format(self.filename_pattern, target=target)
1112318
def punify_filename(filename):
    
    path, extension = splitext(filename)
    return path.encode('punycode').decode('utf8') + extension
1352279
def out_filename(template, n_val, mode):
    """"""
    return '{0}_{1}_{2}.cpp'.format(template.name, n_val, mode.identifier)
1112227
def to_file_url(filename):
    
    url = 'file://' + os.path.abspath(filename).replace(os.path.sep, '/')
    return url