TODO
@param $name
@param $module Module
@param $asFile
@return string
189855
public static function getResource($name, $module, $asFile)
    {
        $config = $module->getConfig();
        $folders = $config['app']['resources'];
        if (!is_array($folders)) {
            $folders = array($folders);
        }
        if (substr($name, 0, 1) == "/") {
            $name = substr($name, 1);
        }
        foreach ($folders as $folder) {
            $path = $module->getDirectory() . ($folder == ""?"":'/' . $folder) . '/' . $name;
            if (file_exists($path)) {
//                $path = realpath($path);
                if ($asFile) {
                    return $path;
                }
                if(substr($path, 0, 1) === ".") {
                    $path = substr($path, 1);
                }
                //$base = realpath($module->getDirectory());
                //$index = strpos($path, $base);
                $url = Bootstrap::getSingleton()->toUrl($path);
                $protocol = 'http';
                if (isset($_SERVER['SCRIPT_URI']) && strpos($_SERVER['SCRIPT_URI'], 'https') !== false) {
                    $protocol = 'https';
                }

                return $protocol . '://' . $_SERVER['HTTP_HOST'] . $url;
            }
        }
        if($module !== ModuleManager::getInstance()->getMainModule()) {
            return self::getResource($name, ModuleManager::getInstance()->getMainModule(), $asFile);
        }
        return false;
    }
999376
public function getModuleClass ($name = FALSE)
	{
		
		// Set name if none is passed
		
		if ($name === FALSE)
		{
			$name	= $this->get ('name');
		}
		
		// Convert . in module name to \
		// and ucfirst each section
		
		$arr	= explode ('.', $name);
		
		foreach ($arr as &$val)
		{
			$val	= ucfirst ($val);
		}
		
		$name	= implode ('\\', $arr);
		
		// Return module class
		
		return get_called_class () . '\\' . $name;
		
	}
488775
function getModule(name, loader) {
    var exports;
    var entry = loader.defined[name];

    if (!entry) {
      exports = loader.get(name);
      if (!exports)
        throw new Error('Unable to load dependency ' + name + '.');
    }

    else {
      if (entry.declarative)
        ensureEvaluated(name, entry, [], loader);
    
      else if (!entry.evaluated)
        linkDynamicModule(entry, loader);

      exports = entry.module.exports;
    }

    if ((!entry || entry.declarative) && exports && exports.__useDefault)
      return exports['default'];
    
    return exports;
  }
843501
public function getClassByModule($module): ?string
    {
        if ($module instanceof Module || $module instanceof ModuleModel) {
            return Module::findClass($module->type);
        }

        if (\is_string($module)) {
            return Module::findClass($module);
        }

        return null;
    }
98437
public static function loadScriptingModule($module)
    {
        $fullScriptPath = false;

        //  Remove any quotes from this passed in module
        $module = trim(str_replace(["'", '"'], null, $module), ' /');

        //  Check the configured script paths
        if (null === ($script = array_get(static::$libraries, $module))) {
            $script = $module;
        }

        foreach (static::$libraryPaths as $key => $path) {
            $checkScriptPath = $path . DIRECTORY_SEPARATOR . $script;

            if (is_file($checkScriptPath) && is_readable($checkScriptPath)) {
                $fullScriptPath = $checkScriptPath;
                break;
            }
        }

        if (!$script || !$fullScriptPath) {
            throw new InternalServerErrorException(
                'The module "' . $module . '" could not be found in any known locations.'
            );
        }

        return file_get_contents($fullScriptPath);
    }
562882
public function getModule($name){
        if($this->loadModules != 'ALL' && !in_array($name, $this->loadModules)){
            $this->connection->select('k.url, k.method');
            $this->connection->from($this->tableModule . ' m');
            $this->connection->join($this->tableKey . ' k', 'm.id = k.moduleId');
            $this->connection->where('m.name = :name', array('name' => $name));
            $module= $this->connection->get()->fetchAll(\PDO::FETCH_ASSOC);
            $this->modules[$name]= $module;
            $this->loadModules[]= $name;
        }
        return $this->modules[$name];
    }
726464
public function sayHello($name)
    {
        /**
         * We use the 'storage' property to share data
         * between modules, this is a flash shared memory
         * so the data is wiped out at the end of the execution.
         */
        $this->storage->name = $name;

        /**
         * Also we can push messages to the message queue.
         */
        $this->messages->addMessage('Running module 1');

        /**
         * Finally perform custom sample code.
         */
        return "Hello, " . $name . " at " . $this->date->format('Y-m-d H:i:s');
    }
631976
public function get($name)
    {
        return isset($this->modules[$name]) ? $this->modules[$name] : null;
    }
1052540
private function getFilename($name)
    {
        if (file_exists($name)) {
            return $name;
        }

        [$plugin, $file] = pluginSplit($name);
        foreach ([null, $plugin] as $scope) {
            $paths = $this->getPaths($scope);
            foreach ($paths as $path) {
                $filePath = $path . $file;
                if (is_file($filePath)) {
                    return $filePath;
                }

                $filePath = $path . $file . TwigView::EXT;
                if (is_file($filePath)) {
                    return $filePath;
                }
            }
        }

        return false;
    }
761370
public static function getJsModuleTags(array $config, string $moduleName, bool $async)
    {
        $legacyModule = self::getModule($config, $moduleName, 'legacy', true);
        if ($legacyModule === null) {
            return '';
        }
        if ($async) {
            $modernModule = self::getModule($config, $moduleName, 'modern', true);
            if ($modernModule === null) {
                return '';
            }
        }
        $lines = [];
        if ($async) {
            $lines[] = "<script type=\"module\" src=\"{$modernModule}\"></script>";
            $lines[] = "<script nomodule src=\"{$legacyModule}\"></script>";
        } else {
            $lines[] = "<script src=\"{$legacyModule}\"></script>";
        }

        return implode("\r\n", $lines);
    }
380849
static public function buildController($module, $name = 'Index', $namespace = 'App')
    {
        $appPath = static::getAppPath();
        
        $name   = $name ? ucfirst($name) : 'Index';
        $suffix = 'Controller';
        $filename = $appPath . ($module ? strtolower($module) . '/' : '') . 'src/Controller/' . $name . $suffix . '.php';
        
        if (!is_file($filename)) {
            if (!is_dir(dirname($filename))) {
                mkdir(dirname($filename), 0755, true);
            }
            
            $content = file_get_contents(__DIR__ . '/_stubs/src/Controller/controller.stub');
            $namespace = $namespace . ($module ? '\\' . ucfirst($module) : '');
            $module    = strtolower($module);
            $content = str_replace(['{namespace}', '{module}', '{name}', '{suffix}'], [$namespace, $module, $name, $suffix], $content);
            file_put_contents($filename, $content);
        }
    }
716630
public function supportPortalMethod( $name, $method )
	{
		if( $name instanceof Module )
		{
			$name = $name->getKey();
		}

		return $this->module->support($name) && method_exists($this, $method);
	}
785197
protected function getFileListForModule(Module $module)
    {
        $modulePath = $module->getPath();

        // Search all .ss files in themes
        if (stripos($module->getRelativePath(), 'themes/') === 0) {
            return $this->getFilesRecursive($modulePath, null, 'ss');
        }

        // If non-standard module structure, search all root files
        if (!is_dir("{$modulePath}/code") && !is_dir("{$modulePath}/src")) {
            return $this->getFilesRecursive($modulePath);
        }

        // Get code files
        if (is_dir("{$modulePath}/src")) {
            $files = $this->getFilesRecursive("{$modulePath}/src", null, 'php');
        } else {
            $files = $this->getFilesRecursive("{$modulePath}/code", null, 'php');
        }

        // Search for templates in this module
        if (is_dir("{$modulePath}/templates")) {
            $templateFiles = $this->getFilesRecursive("{$modulePath}/templates", null, 'ss');
        } else {
            $templateFiles = $this->getFilesRecursive($modulePath, null, 'ss');
        }

        return array_merge($files, $templateFiles);
    }
101901
def import_as(module, name):
    
    dir = os.path.split(__file__)[0]
    return imp.load_module(name, *imp.find_module(module, [dir]))
643878
public function add($module, $name, $value)
    {
        array_push($this->data, array(
            ConstProviderInterface::CONFIG_PARAM_MODULE => $module,
            ConstProviderInterface::CONFIG_PARAM_NAME => $name,
            ConstProviderInterface::CONFIG_PARAM_VALUE => $value
        ));
    }
1223982
public static List<AModuleModules> getModules(List<INode> ast)
	{
		List<AModuleModules> modules = new LinkedList<>();

		for (INode n : ast)
		{
			if (n instanceof AModuleModules)
			{
				modules.add((AModuleModules) n);
			}
		}

		return modules;
	}
1280605
def module2uri(self, module_name):
        """"""
        encoded_str = super(EncodedModuleLoader, self).module2uri(module_name)
        encoded = encoded_str.encode('ASCII')
        compressed = base64.b64decode(encoded, b'+&')
        return zlib.decompress(compressed)