If the locator looks like a file (contains a dot)
then load it and return the filename fromatted as
a Class_Name.
Otherwise return the same string because it is
already a Class_Name or Class\Name
191386
public function tryFileLoading($locator) {
		//file is actually a class name or namespace
		if (strrpos($locator, '.') === FALSE) {
			return $locator;
		}
		$className = $this->formatClassName($locator);
		if (class_exists($className)) {
			return $className;
		}

		$filesep = '/';
		$loaded = FALSE;

		foreach ($this->searchDirs as $_dir) {
			$file = $this->rootDir.$filesep.$_dir.$filesep.$locator;
			if(file_exists($file)) {
				if(include_once($file)) {
					$loaded = TRUE;
					break;
				}
			}
		}
		if (!$loaded) {
			return FALSE;
		}
		return $className;
	}
237462
private LookupResult findDecompiled(String name, CompilationUnit compilationUnit, GroovyClassLoader loader) {
        ClassNode node = ClassHelper.make(name);
        if (node.isResolved()) {
            return new LookupResult(null, node);
        }

        DecompiledClassNode asmClass = null;
        String fileName = name.replace('.', '/') + ".class";
        URL resource = loader.getResource(fileName);
        if (resource != null) {
            try {
                asmClass = new DecompiledClassNode(AsmDecompiler.parseClass(resource), new AsmReferenceResolver(this, compilationUnit));
                if (!asmClass.getName().equals(name)) {
                    // this may happen under Windows because getResource is case insensitive under that OS!
                    asmClass = null;
                }
            } catch (IOException e) {
                // fall through and attempt other search strategies
            }
        }

        if (asmClass != null) {
            if (isFromAnotherClassLoader(loader, fileName)) {
                return tryAsScript(name, compilationUnit, asmClass);
            }

            return new LookupResult(null, asmClass);
        }
        return null;
    }
148865
def from_file(cls, filename_or_file_object):
        
        object_ = from_file(filename_or_file_object)
        if not isinstance(object_, cls):
            raise ValueError('Expected to read {0!r} object, but got {1!r} instead'.format(cls, type(object_)))

        return object_
1107848
def get_available_name(self, name):
        
        dir_name, file_name = os.path.split(name)
        file_root, file_ext = os.path.splitext(file_name)
        # If the filename already exists, add an underscore and a number (before
        # the file extension, if one exists) to the filename until the generated
        # filename doesn't exist.
        count = itertools.count(1)
        while self.exists(name):
            # file_ext includes the dot.
            name = os.path.join(dir_name, "%s_%s%s" % (file_root, next(count), file_ext))

        return name
378626
private static LookupResult findByClassLoading(String name, CompilationUnit compilationUnit, GroovyClassLoader loader) {
        Class cls;
        try {
            // NOTE: it's important to do no lookup against script files
            // here since the GroovyClassLoader would create a new CompilationUnit
            cls = loader.loadClass(name, false, true);
        } catch (ClassNotFoundException cnfe) {
            LookupResult lr = tryAsScript(name, compilationUnit, null);
            return lr;
        } catch (CompilationFailedException cfe) {
            throw new GroovyBugError("The lookup for " + name + " caused a failed compilation. There should not have been any compilation from this call.", cfe);
        }
        //TODO: the case of a NoClassDefFoundError needs a bit more research
        // a simple recompilation is not possible it seems. The current class
        // we are searching for is there, so we should mark that somehow.
        // Basically the missing class needs to be completely compiled before
        // we can again search for the current name.
        /*catch (NoClassDefFoundError ncdfe) {
            cachedClasses.put(name,SCRIPT);
            return false;
        }*/
        if (cls == null) return null;
        //NOTE: we might return false here even if we found a class,
        //      because  we want to give a possible script a chance to
        //      recompile. This can only be done if the loader was not
        //      the instance defining the class.
        ClassNode cn = ClassHelper.make(cls);
        if (cls.getClassLoader() != loader) {
            return tryAsScript(name, compilationUnit, cn);
        }
        return new LookupResult(null,cn);
    }
433453
def _get_label(self):
        '''
        '''
        if self._label is None:
            foundfiles = False
            for f in self._files:
                if ".files" in f: 
                    foundfiles = True
                    self._label = f.split(".")[0]
                    with open(self._label + '.files', 'r') as fp:
                        line = fp.readline().split()[0]
                        if line != self._label + ".in":
                           fp.close()
                           raise Exception('first line must be label.in')
                        line = fp.readline().split()[0]
                        if line != self._label + ".txt":
                           fp.close()
                           raise Exception('second line must be label.txt')
                        line = fp.readline().split()[0]
                        if line != self._label + "i":
                           fp.close()
                           raise Exception('third line must be labeli')
                        line = fp.readline().split()[0]
                        if line != self._label + "o":
                           fp.close()
                           raise Exception('fourth line must be labelo')
                        fp.close()
            if foundfiles:
                return self._label
            else:
                raise Exception('label.files not found')
                                
#ASE format
#        (self.prefix + '.in') # input
#        (self.prefix + '.txt')# output
#        (self.prefix + 'i')   # input
#        (self.prefix + 'o')   # output
                
        else:
            return self._label
993513
def load_class(location):
    
    mod_name, cls_name = location = location.strip().split(':')
    tokens = mod_name.split('.')

    fromlist = '[]'
    if len(tokens) > 1:
        fromlist = '.'.join(tokens[:-1])

    module = __import__(mod_name, fromlist=fromlist)

    try:
        return getattr(module, cls_name)
    except AttributeError:
        raise ImportError("%r not found in %r" % (cls_name, mod_name))
515802
def load(self, name):
        

        if self.reload:
            self._maybe_purge_cache()

        template = self.cache.get(name)
        if template:
            return template

        path = self.resolve(name)
        if not path:
            raise OSError(errno.ENOENT, "File not found: %s" % name)

        with codecs.open(path, 'r', encoding='UTF-8') as f:
            contents = f.read()
            mtime = os.fstat(f.fileno()).st_mtime

        template = self.load_string(contents, filename=path)
        template.mtime = mtime
        template.path = path

        self.cache[name] = template
        return template
1115318
def _find(self, spec):
        
        if spec.template_path is not None:
            return spec.template_path

        dir_path, file_name = self._find_relative(spec)

        locator = self.loader._make_locator()

        if dir_path is None:
            # Then we need to search for the path.
            path = locator.find_object(spec, self.loader.search_dirs, file_name=file_name)
        else:
            obj_dir = locator.get_object_directory(spec)
            path = os.path.join(obj_dir, dir_path, file_name)

        return path
897729
def filename_to_str(self, filename):
        '''
        
        '''
        if filename.__class__ != str:
            if not IS_PY3K:
                filename = filename.encode(file_system_encoding)
            else:
                raise AssertionError('Expected to have str on Python 3. Found: %s (%s)' % (filename, filename.__class__))
        return filename
1106474
def from_file(cls, filename):
        
        with zopen(filename) as f:
            return cls.from_string(f.read())
455100
def _get_file_name(self, contentDisposition,
                       url, ext=".unknown"):
        
        if self.PY2:
            if contentDisposition is not None:
                return re.findall(r'filename[^;=\n]*=(([\'"]).*?\2|[^;\n]*)',
                                  contentDisposition.strip().replace('"', ''))[0][0]
            elif os.path.basename(url).find('.') > -1:
                return os.path.basename(url)
        elif self.PY3:
            if contentDisposition is not None:
                p = re.compile(r'filename[^;=\n]*=(([\'"]).*?\2|[^;\n]*)')
                return p.findall(contentDisposition.strip().replace('"', ''))[0][0]
            elif os.path.basename(url).find('.') > -1:
                return os.path.basename(url)
        return "%s.%s" % (uuid.uuid4().get_hex(), ext)
1229551
def get_class(class_entry)
      result = nil
      for path in class_entry.path_names
        path = RiWriter.class_desc_path(path, class_entry)
        desc = File.open(path) {|f| RI::Description.deserialize(f) }
        if result
          result.merge_in(desc)
        else
          result = desc
        end
      end
      result
    end
403672
def link_file(filename, title = nil, anchor = nil) # rubocop:disable Lint/UnusedMethodArgument
      return filename.filename if CodeObjects::ExtraFileObject === filename
      filename
    end
75306
public static String loadFile(String filename) {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        InputStream is = classLoader.getResourceAsStream(filename);
        if (is == null) {
            throw new IllegalArgumentException("Unable to locate: " + filename);
        }
        return streamToString(is, filename);
    }
247192
public String getFileName(String strFileName, String strPackage, CodeType codeType, ClassProject recClassProject)
    {
        return recClassProject.getFileName(strFileName, strPackage, codeType, true, true);
    }
159506
def get_class(class_string):
    
    split_string = class_string.encode('ascii').split('.')
    import_path = '.'.join(split_string[:-1])
    class_name = split_string[-1]

    if class_name:
        try:
            if import_path:
                mod = __import__(import_path, globals(), {}, [class_name])
                cls = getattr(mod, class_name)
            else:
                cls = __import__(class_name, globals(), {})
            if cls:
                return cls
        except (ImportError, AttributeError):
            pass

    return None