Load a policy
@param {string} documentPath - path to the document file
@param {string} name - the policy name
@returns {Promise<Policy>} - the promise of a policy
164150
function loadPolicy(documentPath, name) {
  return plugin.myrmex.fire('beforePolicyLoad', documentPath, name)
  .spread((documentPath, name) => {
    // Because we use require() to get the document, it could either be a JSON file
    // or the content exported by a node module
    // But because require() caches the content it loads, we clone the result to avoid bugs
    // if the function is called twice
    const document = _.cloneDeep(require(documentPath));
    const Policy = require('./policy');
    const policy = new Policy(document, name);

    // This event allows to inject code to alter the Lambda configuration
    return plugin.myrmex.fire('afterPolicyLoad', policy);
  })
  .spread((policy) => {
    return Promise.resolve(policy);
  });
}
36657
@Override
    public AbstractPolicy getPolicy(String name, PolicyFinder policyFinder) throws PolicyIndexException {
        readLock.lock();
        try {
            logger.debug("Getting policy named: " + name);
            if (policies.containsKey(name)) {
                return handleDocument(m_policyReader.readPolicy(policies.get(name)), policyFinder);
            } else {
                throw new PolicyIndexException("Attempting to get non-existent policy " + name);
            }
        } catch (ParsingException pe) {
            throw new PolicyIndexException(pe.getMessage(),pe);
        } finally {
            readLock.unlock();
        }
    }
898168
function loadResourcesHandler (classpath, self) {
        var Handler = Aria.getClassRef(classpath);

        if (Handler) {
            return new Handler();
        } else {
            var callbackArgs = {
                scope : self,
                classpath : classpath
            };

            Aria.load({
                classes : [classpath],
                oncomplete : {
                    fn : delayLoading,
                    args : callbackArgs
                },
                onerror : {
                    fn : resourcesHandlerError,
                    args : callbackArgs
                }
            });

            return new PromisedHandler();
        }
    }
1077234
function loadJSON( path ) {
    return new Promise( function( resolve, reject ) {
        var xhr = new XMLHttpRequest( {
            mozSystem: true
        } );
        xhr.onload = function() {
            var text = xhr.responseText;
            try {
                resolve( JSON.parse( text ) );
            } catch ( ex ) {
                reject( Error( "Bad JSON format for \"" + path + "\"!\n" + ex + "\n" + text ) );
            }
        };
        xhr.onerror = function() {
            reject( Error( "Unable to load file \"" + path + "\"!\n" + xhr.statusText ) );
        };
        xhr.open( "GET", path, true );
        xhr.withCredentials = true; // Indispensable pour le CORS.
        xhr.send();
    } );
}
1292566
function fsRead(filePath) {
    return new Promise((resolve, reject) => {
        fs.readFile(filePath, (err, data) => {
            if (err) {
                if (err.syscall === 'open') {
                    console.log('Open "' + err.path +'" fail!')
                }
                reject(err);
            }
            resolve(data.toString())
        })
    })
}
545828
function loadBundle(bundleName) {
  if (!_bundleLoad[bundleName]) {
    const mappedBundleName = _paths[bundleName] || bundleName;
    const url = toUrl(mappedBundleName);
    const {nameSpace} = _bundles[bundleName] || {};
    let job;

    // I really hate this.
    // Use script tag, not fetch, only to support sourcemaps.
    // And I don't know how to mock it up, so __skip_script_load_test
    if (!define.__skip_script_load_test &&
        isBrowser &&
        // no name space or browser has support of document.currentScript
        (!nameSpace || 'currentScript' in _global.document)) {
      job = new Promise((resolve, reject) => {
        const script = document.createElement('script');
        if (nameSpace) {
          script.setAttribute('data-namespace', nameSpace);
        }
        script.type = 'text/javascript';
        script.charset = 'utf-8';
        script.async = true;
        script.addEventListener('load', resolve);
        script.addEventListener('error', reject);
        script.src = url;

        // If the script is cached, IE10 executes the script body and the
        // onload handler synchronously here.  That's a spec violation,
        // so be sure to do this asynchronously.
        if (document.documentMode === 10) {
          setTimeout(() => {
            document.head.appendChild(script);
          });
        } else {
          document.head.appendChild(script);
        }
      });
    }

    if (!job) {
      // in nodejs or web worker
      // or need name space in browser doesn't support document.currentScipt
      job = _fetch(mappedBundleName)
      .then(response => response.text())
      .then(text => {
        // ensure default user space
        // the bundle itself may switch to package space in middle of the file
        switchToUserSpace();
        if (!nameSpace) {
          (new Function(text)).call(_global);
        } else {
          const wrapped = function(id, deps, cb) {
            nameSpacedDefine(nameSpace, id, deps, cb);
          };
          wrapped.amd = define.amd;
          wrapped.switchToUserSpace = switchToUserSpace;
          wrapped.switchToPackageSpace = switchToPackageSpace;
          const f = new Function('define', text);
          f.call(_global, wrapped);
        }
      });
    }

    _bundleLoad[bundleName] = job;
  }

  return _bundleLoad[bundleName];
}
373177
def get(self, name, failobj=None):
        
        name = name.lower()
        for k, v in self._headers:
            if k.lower() == name:
                return self.policy.header_fetch_parse(k, v)
        return failobj
1163779
function loadEnv(name) {
    var fullEnvPath = path.resolve(applicationRoot, './configs/' + name);
    try {
      debug('Loaded environment: ' + fullEnvPath);
      fs.statSync(fullEnvPath);
      dotenv.config({ path: fullEnvPath });
    }
    catch (e) {
      debug('Could not load environment "' + fullEnvPath + '"');
    }
  }
1295693
function loadPackageJSONConfigFile(filePath) {
    debug(`Loading package.json config file: ${filePath}`);
    try {
        return loadJSONConfigFile(filePath).eslintConfig || null;
    } catch (e) {
        debug(`Error reading package.json file: ${filePath}`);
        e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
        throw e;
    }
}
953240
protected void doLoadFromClasspath(String policyImpl, IAsyncResultHandler<IPolicy> handler) {
        IPolicy rval;
        String classname = policyImpl.substring(6);
        Class<?> c = null;

        // First try a simple Class.forName()
        try { c = Class.forName(classname); } catch (ClassNotFoundException e) { }
        // Didn't work?  Try using this class's classloader.
        if (c == null) {
            try { c = getClass().getClassLoader().loadClass(classname); } catch (ClassNotFoundException e) { }
        }
        // Still didn't work?  Try the thread's context classloader.
        if (c == null) {
            try { c = Thread.currentThread().getContextClassLoader().loadClass(classname); } catch (ClassNotFoundException e) { }
        }

        if (c == null) {
            handler.handle(AsyncResultImpl.<IPolicy>create(new PolicyNotFoundException(classname)));
            return;
        }

        try {
            rval = (IPolicy) c.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            handler.handle(AsyncResultImpl.<IPolicy>create(new PolicyNotFoundException(policyImpl, e)));
            return;
        }
        policyCache.put(policyImpl, rval);
        handler.handle(AsyncResultImpl.create(rval));
        return;
    }
793021
function loadFromFile(path) {
    var data = fs.readFileSync(path, {encoding: "utf8"});
    _root = Repository.readObject(data);
    return _root;
}
460295
public static policydataset get(nitro_service service, String name) throws Exception{
		policydataset obj = new policydataset();
		obj.set_name(name);
		policydataset response = (policydataset) obj.get_resource(service);
		return response;
	}
1293640
function read(callback) {
        let raw = fs.readFileSync(thing.path).toString()
        //let json = thing.path.split('.').reverse()[0] === 'json'
        // TODO add support for role.yaml
        let policies = JSON.parse(raw).policies
        callback(null, policies || [])
      }
1282715
public static transformpolicy_binding get(nitro_service service, String name) throws Exception{
		transformpolicy_binding obj = new transformpolicy_binding();
		obj.set_name(name);
		transformpolicy_binding response = (transformpolicy_binding) obj.get_resource(service);
		return response;
	}
1349935
@Override
    public boolean updatePolicy(String name, String newDocument)
    throws PolicyIndexException {

        writeLock.lock();
        try {
            logger.debug("Updating policy named: " + name);
            if (doDelete(name)) {
                doAdd(name, newDocument);
                return true;
            } else {
                // delete failed
                return false;
            }
        } finally {
            writeLock.unlock();
        }
    }
668556
function loadFromPath(path, container) {
  if (path && typeof path === 'string' && path.length > 0) {
    return load(path, container)
  }
  return Promise.resolve([])
}
1205473
function realRequirPath(filePath) {
  // console.log('realRequirPath:filePath: ' + filePath);
  var jsFilePath = filePath + '.js';
  if (fs.existsSync(filePath)) {
    if (fs.statSync(filePath).isDirectory()) {
      jsFilePath = filePath + '.js';
      if (fs.existsSync(jsFilePath)) {
        return jsFilePath;
      } else {
        jsFilePath = path.join(filePath, 'index.js');
      }
      // console.log('realRequirPath:jsFilePath: ' + jsFilePath);
    } else if (fs.statSync(filePath).isFile()) {
      return filePath;
    } else {
      return null;
    }
  } else {
    jsFilePath = filePath + '.js';
    // console.log('realRequirPath:filePath: ' + filePath);
  }

  if (fs.existsSync(jsFilePath)) {
    // console.log('realRequirPath:filePath: ' + filePath);
    return jsFilePath;
  } else {
    return null;
  }
}