helper function to do a search of Policy data from a registry.pol file
    returns the "data" field
    https://msdn.microsoft.com/en-us/library/aa374407(VS.85).aspx
    [key;value;type;size;data]
509446
def _getDataFromRegPolData(search_string, policy_data, return_value_name=False):
    '''
    
    '''
    value = None
    values = []
    encoded_semicolon = ';'.encode('utf-16-le')
    if return_value_name:
        values = {}
    if search_string:
        registry = Registry()
        if len(search_string.split(encoded_semicolon)) >= 3:
            vtype = registry.vtype_reverse[ord(search_string.split(encoded_semicolon)[2].decode('utf-32-le'))]
        else:
            vtype = None
        search_string = re.escape(search_string)
        matches = re.finditer(search_string, policy_data, re.IGNORECASE)
        matches = [m for m in matches]
        if matches:
            for match in matches:
                pol_entry = policy_data[match.start():(policy_data.index(']'.encode('utf-16-le'),
                                                                         match.end())
                                                       )
                                        ].split(encoded_semicolon)
                if len(pol_entry) >= 2:
                    valueName = pol_entry[1].decode('utf-16-le').rstrip(chr(0))
                if len(pol_entry) >= 5:
                    value = pol_entry[4]
                    if vtype == 'REG_DWORD' or vtype == 'REG_QWORD':
                        if value:
                            if vtype == 'REG_DWORD':
                                for v in struct.unpack(b'I', value):
                                    value = v
                            elif vtype == 'REG_QWORD':
                                for v in struct.unpack(b'Q', value):
                                    value = v
                        else:
                            value = 0
                    elif vtype == 'REG_MULTI_SZ':
                        value = value.decode('utf-16-le').rstrip(chr(0)).split(chr(0))
                    else:
                        value = value.decode('utf-16-le').rstrip(chr(0))
                if return_value_name:
                    log.debug('we want value names and the value')
                    values[valueName] = value
                elif len(matches) > 1:
                    log.debug('we have multiple matches, we will return a list')
                    values.append(value)
    if values:
        value = values

    return value
331536
function readPolicyVariables ({ id, organizationId, type }, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      Joi.validate({ id, organizationId, type }, validationRules.readPolicyVariables, function (err) {
        if (err) return cb(Boom.badRequest(err))

        const sqlQuery = SQL`
          SELECT  *
          FROM policies
          WHERE id = ${id}
        `

        if (type === 'shared') {
          sqlQuery.append(SQL` AND org_id is NULL`)
        } else {
          sqlQuery.append(SQL` AND org_id=${organizationId}`)
        }

        db.query(sqlQuery, function (err, result) {
          if (err) return cb(Boom.badImplementation(err))
          if (result.rowCount === 0) return cb(Boom.notFound())

          let variables = []

          _.each(result.rows[0].statements.Statement, function (statement) {
            if (statement.Resource) {
              _.map(statement.Resource, function (resource) {
                // ignore context vars but list all others, should match validation.js
                let variableMatches = resource.match(/\${((?!(udaru)|(request)).*)(.+?)}/g)
                _.each(variableMatches, function (variable) {
                  variables.push(variable)
                })
              })
            }
          })

          return cb(null, variables)
        })
      })

      return promise
    }
362144
private SerializationPolicy getSerializationPolicy(CmsObject cms) {

        boolean online = cms.getRequestContext().getCurrentProject().isOnlineProject();
        if (online && (m_serPolicyOnline != null)) {
            return m_serPolicyOnline;
        } else if (!online && (m_serPolicyOffline != null)) {
            return m_serPolicyOffline;
        }

        SerializationPolicy serializationPolicy = null;

        // Open the RPC resource file and read its contents
        InputStream is = null;
        try {
            // check if this is a static resource request
            if (m_serializationPolicyPath.startsWith(OpenCms.getSystemInfo().getStaticResourceContext())) {
                URL resourceURL = CmsStaticResourceHandler.getStaticResourceURL(m_serializationPolicyPath);
                URLConnection connection;
                connection = resourceURL.openConnection();
                is = connection.getInputStream();
            } else {
                // try reading from the RFS
                String rfsPath = m_serializationPolicyPath;
                if (rfsPath.startsWith(OpenCms.getSystemInfo().getContextPath())) {
                    rfsPath = rfsPath.substring(OpenCms.getSystemInfo().getContextPath().length());
                }
                rfsPath = CmsStringUtil.joinPaths(OpenCms.getSystemInfo().getWebApplicationRfsPath(), rfsPath);
                File policyFile = new File(rfsPath);
                if (policyFile.exists() && policyFile.canRead()) {
                    is = new FileInputStream(policyFile);
                } else {
                    // the file does not exist in the RFS, try the VFS
                    String policyPath = OpenCms.getLinkManager().getRootPath(cms, m_serializationPolicyPath);
                    is = new ByteArrayInputStream(cms.readFile(policyPath).getContents());
                }
            }
        } catch (Exception ex) {
            // most likely file not found
            String message = "ERROR: The serialization policy file '"
                + m_serializationPolicyPath
                + "' was not found; did you forget to include it in this deployment?";
            LOG.warn(message);
            LOG.warn(ex.getLocalizedMessage(), ex);

        }
        if (is == null) {
            return new CmsDummySerializationPolicy();
        }

        // read the policy
        try {
            serializationPolicy = SerializationPolicyLoader.loadFromStream(is, null);
        } catch (ParseException e) {
            LOG.error("ERROR: Failed to parse the policy file '" + m_serializationPolicyPath + "'", e);
        } catch (IOException e) {
            LOG.error("ERROR: Could not read the policy file '" + m_serializationPolicyPath + "'", e);
        } finally {
            try {
                is.close();
            } catch (@SuppressWarnings("unused") IOException e) {
                // Ignore this error
            }
        }

        if (online) {
            m_serPolicyOnline = serializationPolicy;
        } else {
            m_serPolicyOffline = serializationPolicy;
        }
        return serializationPolicy;
    }
119403
public ProfilePolicyMetadata[] queryPolicyMetadata(String[] policyName, Profile profile) throws RuntimeFault, RemoteException {
        return getVimService().queryPolicyMetadata(getMOR(), policyName, profile == null ? null : profile.getMOR());
    }
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;
	}
991499
def RegistryKeyFromClient(args):
  
  for path in _GetExpandedPaths(args):
    pathspec = rdf_paths.PathSpec(
        path=path, pathtype=rdf_paths.PathSpec.PathType.REGISTRY)
    with vfs.VFSOpen(pathspec) as file_obj:
      yield file_obj.Stat()
1163501
public static policydataset[] get(nitro_service service) throws Exception{
		policydataset obj = new policydataset();
		policydataset[] response = (policydataset[])obj.get_resources(service);
		return response;
	}
1237896
def itemData(self, f=None, savePath=None):
        

        params = {
        }
        if f is not None and \
           f.lower() in ['zip', 'json']:
            params['f'] = f
        url = "%s/data" % self.root
        if self.type in ["Shapefile", "CityEngine Web Scene", "Web Scene", "KML",
                         "Code Sample",
                         "Code Attachment", "Operations Dashboard Add In",
                         "CSV", "CSV Collection", "CAD Drawing", "Service Definition",
                         "Microsoft Word", "Microsoft Powerpoint",
                         "Microsoft Excel", "PDF", "Image",
                         "Visio Document", "iWork Keynote", "iWork Pages",
                         "iWork Numbers", "Map Document", "Map Package",
                         "Basemap Package", "Tile Package", "Project Package",
                         "Task File", "ArcPad Package", "Explorer Map",
                         "Globe Document", "Scene Document", "Published Map",
                         "Map Template", "Windows Mobile Package", "Pro Map",
                         "Layout", "Layer", "Layer Package", "File Geodatabase",
                         "Explorer Layer", "Geoprocessing Package", "Geoprocessing Sample",
                         "Locator Package", "Rule Package", "Workflow Manager Package",
                         "Desktop Application", "Desktop Application Template",
                         "Code Sample", "Desktop Add In", "Explorer Add In",
                         "ArcGIS Desktop Add-In", "ArcGIS Explorer Add-In",
                         "ArcGIS Explorer application configuration", "ArcGIS Explorer document",
                         ]:
            if savePath is None:
                raise AttributeError('savePath must be provided for a item of type: %s' % self.type)
            if os.path.isdir(savePath) == False:
                os.makedirs(savePath)
            result = self._get(url=url,
                               param_dict=params,
                               securityHandler=self._securityHandler,
                               proxy_url=self._proxy_url,
                               proxy_port=self._proxy_port,
                               out_folder=savePath,
                               file_name=self.name)
            return result
        else:
            results =  self._get(url, params,
                                 proxy_port=self._proxy_port,
                                 securityHandler=self._securityHandler,
                                 proxy_url=self._proxy_url)
            return results
31048
private com.datastax.driver.core.policies.ReconnectionPolicy getPolicy(ReconnectionPolicy policy, Properties props)
    {
        com.datastax.driver.core.policies.ReconnectionPolicy reconnectionPolicy = null;
        switch (policy)
        {
        case ConstantReconnectionPolicy:
            String property = props.getProperty("constantDelayMs");
            long constantDelayMs = property != null ? new Long(property) : 0l;
            reconnectionPolicy = new ConstantReconnectionPolicy(constantDelayMs);
            break;

        case ExponentialReconnectionPolicy:
            String baseDelayMsAsStr = props.getProperty("baseDelayMs");
            String maxDelayMsAsStr = props.getProperty("maxDelayMs");
            if (!StringUtils.isBlank(baseDelayMsAsStr) && !StringUtils.isBlank(maxDelayMsAsStr))
            {
                long baseDelayMs = new Long(baseDelayMsAsStr);
                long maxDelayMs = new Long(maxDelayMsAsStr);
                reconnectionPolicy = new ExponentialReconnectionPolicy(baseDelayMs, maxDelayMs);
            }
            break;

        default:
            break;
        }

        return reconnectionPolicy;
    }
584363
private String fileToName(File policyFile) throws PolicyIndexException {
        try {
            if (!policyFile.getName().endsWith(".xml"))
                throw new PolicyIndexException("Invalid policy file name.  Policy files must end in .xml - " + policyFile.getName());

            return PID.fromFilename(policyFile.getName().substring(0, policyFile.getName().lastIndexOf(".xml"))).toString();
        } catch (MalformedPIDException e) {
            throw new PolicyIndexException("Invalid policy file name.  Filename cannot be converted to a valid PID - " + policyFile.getName());
        }

    }
220185
function SearchResultModel(serviceRegistry, fileClient, searchResult, totalNumber, searchParams, options) {
        this.registry = serviceRegistry;
        this.fileClient = fileClient;
        if(searchResult && searchResult.categories) {
        	this._fileList = searchResult.refResult;
        	this._categories = searchResult.categories;
        } else {
        	this._fileList = searchResult;
        }
        this._numberOnPage = this._fileList.length;
        this._totalNumber = totalNumber;
        this._shape = searchParams.shape ? searchParams.shape : 'file'; //$NON-NLS-1$
        this._listRoot = {
            isRoot: true,
            children: []
        };
        this._filteredRoot = {
            isRoot: true,
            children: []
        };
        this._filterText = null;
        this._indexedFileItems = [];
        this._location2ModelMap = [];
        this._lineDelimiter = ""; //$NON-NLS-0$
        this.onMatchNumberChanged = options.onMatchNumberChanged;
        this._matchFilter = options.matchFilter;
        this._searchHelper = mSearchUtils.generateSearchHelper(searchParams);
    }
244512
def get_role_policy(role_name, policy_name, region=None, key=None,
                    keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    try:
        _policy = conn.get_role_policy(role_name, policy_name)
        # I _hate_ you for not giving me an object boto.
        _policy = _policy.get_role_policy_response.policy_document
        # Policy is url encoded
        _policy = _unquote(_policy)
        _policy = salt.utils.json.loads(_policy, object_pairs_hook=odict.OrderedDict)
        return _policy
    except boto.exception.BotoServerError:
        return {}
844430
def _get_registry(self, registry_path_or_url):
        ''''''
        if os.path.isfile(registry_path_or_url):
            with open(registry_path_or_url, 'r') as f:
                reader = compat.csv_dict_reader(f.readlines())
        else:
            res = requests.get(registry_path_or_url)
            res.raise_for_status()

            reader = compat.csv_dict_reader(StringIO(res.text))

        return dict([(o['id'], o) for o in reader])
731050
private static String getPoliciesDocType(PolicyType type) {
        String docType = "planPolicies"; //$NON-NLS-1$
        if (type == PolicyType.Api) {
            docType = "apiPolicies"; //$NON-NLS-1$
        } else if (type == PolicyType.Client) {
            docType = "clientPolicies"; //$NON-NLS-1$
        }
        return docType;
    }
1217757
public static dospolicy_stats get(nitro_service service, String name) throws Exception{
		dospolicy_stats obj = new dospolicy_stats();
		obj.set_name(name);
		dospolicy_stats response = (dospolicy_stats) obj.stat_resource(service);
		return response;
	}
85843
function getData(file) {
		var relativePath, pathData;

		relativePath = path.relative(projectConfig.paths.src.views.layouts, file.path);
		relativePath = relativePath.replace('.' + taskConfig.extension, '');

		pathData = dataSource.getDataForPath(relativePath);
		pathData = defaultData.apply(pathData);

		return pathData;
	}
709306
def get_policy_type(self, project, type_id):
        
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url('project', project, 'str')
        if type_id is not None:
            route_values['typeId'] = self._serialize.url('type_id', type_id, 'str')
        response = self._send(http_method='GET',
                              location_id='44096322-2d3d-466a-bb30-d1b7de69f61f',
                              version='5.0',
                              route_values=route_values)
        return self._deserialize('PolicyType', response)