Verify that a control structure is still valid or find one.

        Returns:
            ControlStructure: The verified or discovered control structure.
508481
def _verify_control_structure(self, device_info, control_info=None):
        

        if control_info is None:
            control_info = self._find_control_structure(device_info.ram_start, device_info.ram_size)

        #FIXME: Actually reread the memory here to verify that the control structure is still valid
        return control_info
723645
protected function processControlStructure()
	{
		// Save the index so we can rewind back to it in case of failure
		$savedIndex = $this->i;

		// Count this control structure in this context's statements unless it's an elseif/else
		// in which case it's already been counted as part of the if
		if (!in_array($this->tokens[$this->i][0], [T_ELSE, T_ELSEIF], true))
		{
			++$this->context['statements'];
		}

		// If the control structure is anything but an "else", skip its condition to reach the first
		// brace or statement
		if ($this->tokens[$this->i][0] !== T_ELSE)
		{
			$this->skipCondition();
		}

		$this->skipWhitespace();

		// Abort if this control structure does not use braces
		if ($this->tokens[$this->i] !== '{')
		{
			// Rewind all the way to the original token
			$this->i = $savedIndex;

			return;
		}

		++$this->braces;

		// Replacement for the first brace
		$replacement = [T_WHITESPACE, ''];

		// Add a space after "else" if the brace is removed and it's not followed by whitespace or a
		// variable
		if ($this->tokens[$savedIndex][0]  === T_ELSE
		 && $this->tokens[$this->i + 1][0] !== T_VARIABLE
		 && $this->tokens[$this->i + 1][0] !== T_WHITESPACE)
		{
			$replacement = [T_WHITESPACE, ' '];
		}

		// Record the token of the control structure (T_IF, T_WHILE, etc...) in the current context
		$this->context['lastBlock'] = $this->tokens[$savedIndex][0];

		// Create a new context
		$this->context = [
			'braces'      => $this->braces,
			'index'       => $this->i,
			'lastBlock'   => null,
			'parent'      => $this->context,
			'replacement' => $replacement,
			'savedIndex'  => $savedIndex,
			'statements'  => 0
		];
	}
1240608
def _check_state(self):
        
        if(self.grid is not None and
           self.configs.configs is not None and
           self.assignments['forward_model'] is not None):
            self.can_model = True

        if(self.grid is not None and
           self.assignments['measurements'] is not None):
            self.can_invert = True
958851
private boolean checkStructure() {
        File ds;

        ds = new File(mapsetPath + File.separator + GrassLegacyConstans.CATS + File.separator);
        if (!ds.exists())
            if (!ds.mkdir())
                return false;
        ds = new File(mapsetPath + File.separator + GrassLegacyConstans.CELL + File.separator);
        if (!ds.exists())
            if (!ds.mkdir())
                return false;
        ds = new File(mapsetPath + File.separator + GrassLegacyConstans.CELL_MISC + File.separator);
        if (!ds.exists())
            if (!ds.mkdir())
                return false;
        ds = new File(mapsetPath + File.separator + GrassLegacyConstans.CELL_MISC + File.separator + name);
        if (!ds.exists())
            if (!ds.mkdir())
                return false;
        ds = new File(mapsetPath + File.separator + GrassLegacyConstans.FCELL + File.separator);
        if (!ds.exists())
            if (!ds.mkdir())
                return false;
        ds = new File(mapsetPath + File.separator + GrassLegacyConstans.CELLHD + File.separator);
        if (!ds.exists())
            if (!ds.mkdir())
                return false;
        ds = new File(mapsetPath + File.separator + GrassLegacyConstans.COLR + File.separator);
        if (!ds.exists())
            if (!ds.mkdir())
                return false;
        ds = new File(mapsetPath + File.separator + GrassLegacyConstans.HIST + File.separator);
        if (!ds.exists())
            if (!ds.mkdir())
                return false;
        return true;
    }
825233
def is_valid(self):
        '''
        
        '''

        valid = super(RegistrationContactForm,self).is_valid()
        msgs = messages.get_messages(self._request)

        # We only want validation messages to show up once, so pop messages that have already show up
        # before checking to see if any messages remain to be shown.
        prior_messages = self._session.pop('prior_messages',[])
        remaining_messages = []

        for m in msgs:
            m_dict = {'message': m.message, 'level': m.level, 'extra_tags': m.extra_tags}
            if m_dict not in prior_messages:
                remaining_messages.append(m_dict)

        if remaining_messages:
            self._session['prior_messages'] = remaining_messages
            self._request.session.modified = True
            return False
        return valid
544035
private Glyph createControlStructure(Control ctrl) {
		Glyph cg;
		Set<PhysicalEntity> controllers = getControllers(ctrl);
		// If no representable controller found, skip this control
		if (controllers.isEmpty()) {
			cg = null;
		} else if (controllers.size() == 1 && getControllerSize(ctrl.getControlledOf()) == 0)
		{ // If there is only one controller with no modulator, put an arc for controller
			cg = getGlyphToLink(controllers.iterator().next(), convertID(ctrl.getUri()));
		} else {
			// This list will contain handles for each participant of the AND structure
			List<Glyph> toConnect = new ArrayList<Glyph>();

			// Bundle controllers if necessary
			Glyph gg = handlePEGroup(controllers, convertID(ctrl.getUri()));
			if(gg != null)
				toConnect.add(gg);

			// Handle co-factors of catalysis
			if (ctrl instanceof Catalysis) {
				Set<PhysicalEntity> cofs = ((Catalysis) ctrl).getCofactor();
				Glyph g = handlePEGroup(cofs, convertID(ctrl.getUri()));
				if (g != null) 
					toConnect.add(g);
			}

			if (toConnect.isEmpty()) {
				return null;
			} else if (toConnect.size() == 1) {
				cg = toConnect.iterator().next();
			} else {
				cg = connectWithAND(toConnect);
			}
		}

		return cg;
	}
975649
def is_valid(self):
        
        self.cleaned_data = {}
        self.changed_fields = []
        self.validated = False
        self._errors = {}
        self._named_errors = {}
        cleaned_data = {}
        changed_fields = []
        errors = {}
        named_errors = {}

        # Validate sub forms
        for name, subform in self._forms.items():
            if not subform.is_valid():
                errors[name] = subform._errors
                named_errors.update(subform._named_errors)
                continue
            if subform.has_changed:
                changed_fields.append(name)

        # Validate sub sets
        for name, formset in self._sets.items():
            if not formset.is_valid():
                errors[name] = formset._errors
                named_errors.update(formset._named_errors)
                continue
            if formset.has_changed:
                changed_fields.append(name)

        # Validate each field
        for name, field in self._fields.items():
            field.error = None
            py_value = field.validate(self)
            if field.error:
                errors[name] = field.error
                named_errors[field.name] = field.error
                continue
            cleaned_data[name] = py_value
            if hasattr(field, '_deleted'):
                cleaned_data[name] = None
                field.has_changed = True
            if field.has_changed:
                changed_fields.append(name)

        # Validate relation between fields
        for name, field in self._fields.items():
            field.validate(self, cleaned_data)
            if field.error:
                errors[name] = field.error
                named_errors[field.name] = field.error
                continue

        if errors:
            self._errors = errors
            self._named_errors = named_errors
            return False

        self.changed_fields = changed_fields
        self.cleaned_data = self.clean(cleaned_data)
        self.validated = True
        return True
531886
function isControlTransfer(stmt, path, control = "break") {
    const { [control]: type } = {
      break: "BreakStatement",
      continue: "ContinueStatement"
    };
    if (!type) {
      throw new Error("Can only handle break and continue statements");
    }
    const checker = `is${type}`;

    if (stmt[checker]()) {
      return _isControlTransfer(stmt, path);
    }

    let isTransferred = false;
    let result = {
      [control]: false,
      bail: false
    };

    stmt.traverse({
      [type](cPath) {
        // if we already detected a break/continue statement,
        if (isTransferred) return;

        result = _isControlTransfer(cPath, path);

        if (result.bail || result[control]) {
          isTransferred = true;
        }
      }
    });

    return result;

    function _isControlTransfer(cPath, path) {
      const label = cPath.get("label");

      if (label.node !== null) {
        // labels are fn scoped and not accessible by inner functions
        // path is the switch statement
        if (!isSameFunctionScope(path, cPath)) {
          // we don't have to worry about this break statement
          return {
            break: false,
            bail: false
          };
        }

        // here we handle the break labels
        // if they are outside switch, we bail out
        // if they are within the case, we keep them
        let labelPath;
        if (path.scope.getLabel) {
          labelPath = getLabel(label.node.name, path);
        } else {
          labelPath = path.scope.getBinding(label.node.name).path;
        }
        const _isAncestor = isAncestor(labelPath, path);

        return {
          bail: _isAncestor,
          [control]: _isAncestor
        };
      }

      // set the flag that it is indeed breaking
      let isCTransfer = true;

      // this flag is to capture
      // switch(0) { case 0: while(1) if (x) break; }
      let possibleRunTimeControlTransfer = false;

      // and compute if it's breaking the correct thing
      let parent = cPath.parentPath;

      while (parent !== stmt.parentPath) {
        // loops and nested switch cases
        if (parent.isLoop() || parent.isSwitchCase()) {
          // invalidate all the possible runtime breaks captured
          // while (1) { if (x) break; }
          possibleRunTimeControlTransfer = false;

          // and set that it's not breaking our switch statement
          isCTransfer = false;
          break;
        }
        //
        // this is a special case and depends on
        // the fact that SwitchStatement is handled in the
        // exit hook of the traverse
        //
        // switch (0) {
        //   case 0: if (x) break;
        // }
        //
        // here `x` is runtime only.
        // in this case, we need to bail out. So we depend on exit hook
        // of switch so that, it would have visited the IfStatement first
        // before the SwitchStatement and would have removed the
        // IfStatement if it was a compile time determined
        //
        if (parent.isIfStatement()) {
          possibleRunTimeControlTransfer = true;
        }
        parent = parent.parentPath;
      }

      return {
        [control]: possibleRunTimeControlTransfer || isCTransfer,
        bail: possibleRunTimeControlTransfer
      };
    }
  }
1326210
function(sControlName, aControlsToTest, aExcludedControls, bIncludeNonRenderable, bIncludeNonInstantiable) {
		if (!sControlName) {
			return false;
		}

		if (aControlsToTest.length) { // only test specific controls
			if (aControlsToTest.indexOf(sControlName) === -1) { // not one of the chosen ones
				return false;
			}
		} else if (aExcludedControls.indexOf(sControlName) > -1) {
			return false;
		}

		if (!bIncludeNonRenderable && !ControlIterator.controlCanBeRendered(sControlName)) {
			return false;
		}

		if (!bIncludeNonInstantiable && !ControlIterator.controlCanBeInstantiated(sControlName)) {
			return false;
		}

		return true;
	}
1184328
public function verifyModuleStructure(){
		// Check Model Path
		$isValid = $this->verifyPath(dirname($this->getNames()->modelPath));
		
		// Check Entity Path
		$isValid = $isValid && $this->verifyPath(dirname($this->getNames()->entityPath));
		
		//$moduleFile = "{$this->getNames()->modulePath}/Module.php";
		
		return $isValid;
	}
297221
public static Pattern controlsDegradationIndirectly()
	{
		Pattern p = controlsStateChange();
		p.add(new Size(new ParticipatesInConv(RelType.INPUT), 1, Size.Type.EQUAL), "output PE");
		p.add(new Empty(peToControl()), "output PE");
		p.add(new ParticipatesInConv(RelType.INPUT), "output PE", "degrading Conv");
		p.add(new NOT(type(ComplexAssembly.class)), "degrading Conv");
		p.add(new Size(participant(), 1, Size.Type.EQUAL), "degrading Conv");
		p.add(new Empty(new Participant(RelType.OUTPUT)), "degrading Conv");
		p.add(new Empty(convToControl()), "degrading Conv");
		p.add(equal(false), "degrading Conv", "Conversion");
		return p;
	}
1294857
def check(self, cfg, state, peek_blocks):
        

        # Get the current CFGNode
        node = self._get_cfg_node(cfg, state)

        if node is None:
            l.error("Failed to find CFGNode for state %s on the control flow graph.", state)
            return False

        # crawl the graph to see if we can reach the target function within the limited steps
        for src, dst in self._dfs_edges(cfg.graph, node, max_steps=peek_blocks):
            the_node = None
            if src.addr == self.function.addr:
                the_node = src
            elif dst.addr == self.function.addr:
                the_node = dst

            if the_node is not None:
                if self.arguments is None:
                    # we do not care about arguments
                    return True

                else:
                    # check arguments
                    arch = state.arch
                    state = the_node.input_state
                    same_arguments = self._check_arguments(arch, state)

                    if same_arguments:
                        # all arguments are the same!
                        return True

        l.debug("SimState %s will not reach function %s.", state, self.function)
        return False
992846
public function validate(Control $control): bool
  {
    $value = $control->getSubmittedValue();

    // An empty value is valid.
    if ($value==='' || $value===null || $value===false)
    {
      return true;
    }

    // Objects and arrays are not a valid http URL.
    if (!is_scalar($value))
    {
      return false;
    }

    // Filter valid URL from the value.
    $url = filter_var($value, FILTER_VALIDATE_URL);

    // If the actual value and the filtered value are not equal the value is not a valid url.
    if ($url!==$value)
    {
      return false;
    }

    // filter_var allows not to specify the HTTP protocol. Test the URL starts with http (or https).
    if (substr($url, 0, 4)!=='http')
    {
      return false;
    }

    // Test that the page actually exits. We consider all HTTP 200-399 responses as valid.
    try
    {
      $headers = get_headers($url);
      $ok      = (is_array($headers) && preg_match('/^HTTP\\/\\d+\\.\\d+\\s+[23]\\d\\d\\s*.*$/', $headers[0]));
    }
    catch (\Exception $e)
    {
      // Something went wrong. Possibly:
      // * Unable to open stream
      // * Peer certificate did not match expected
      $ok = false;
    }

    return $ok;
  }
926865
public function isValid() {
		
		$valid = TRUE;
		
		foreach ($this->controls as $control) {
			
			if (!$control->validate()) {
				$valid = FALSE;
			}
			
		}
		
		return $valid;
		
	}
934762
protected function isControlStructure()
	{
		return in_array(
			$this->tokens[$this->i][0],
			[T_ELSE, T_ELSEIF, T_FOR, T_FOREACH, T_IF, T_WHILE],
			true
		);
	}
1095524
def control_iter(base_dir, control_name=CONTROL_NAME):
    
    controls = (os.path.join(p, control_name) for p, _, fs in os.walk(base_dir)
                if control_name in fs)
    return controls
417391
def verify(self):
        
        if self._verify is None:
            from twilio.rest.verify import Verify
            self._verify = Verify(self)
        return self._verify