Given a string in the format `scope:directive`, or simply `scope`
    or `directive`, return a Placement object suitable for passing
    back over the websocket API.
326393
def parse(directive):
    
    if not directive:
        # Handle null case
        return None

    if isinstance(directive, (list, tuple)):
        results = []
        for d in directive:
            results.extend(parse(d))
        return results

    if isinstance(directive, (dict, client.Placement)):
        # We've been handed something that we can simply hand back to
        # the api. (Forwards compatibility)
        return [directive]

    # Juju 2.0 can't handle lxc containers.
    directive = directive.replace('lxc', 'lxd')

    if ":" in directive:
        # Planner has given us a scope and directive in string form
        scope, directive = directive.split(":")
        return [client.Placement(scope=scope, directive=directive)]

    if directive.isdigit():
        # Planner has given us a machine id (we rely on juju core to
        # verify its validity.)
        return [client.Placement(scope=MACHINE_SCOPE, directive=directive)]

    if "/" in directive:
        # e.g. "0/lxd/0"
        # https://github.com/juju/juju/blob/master/instance/placement_test.go#L29
        return [
            client.Placement(scope=MACHINE_SCOPE, directive=directive),
        ]

    # Planner has probably given us a container type. Leave it up to
    # juju core to verify that it is valid.
    return [client.Placement(scope=directive)]
451544
function template(string, data) {
  var proxyRegEx = /\{\{([^\}]+)?\}\}/g;
  return string.replace(proxyRegEx, function(_, key) {
    var keyParts = key.split('.');
    var value = data;
    for (var i = 0; i < keyParts.length; i++) {
      value = value[keyParts[i]];
    }
    return value || '';
  });
}
158518
function scopeCssText (cssText, scope) {
  return transformCss(cssText, (rule) => {
    const transformed = {...rule}
    if (!rule.isScoped) {
      transformed.selector = scopeRule(rule, scope)
      transformed.isScoped = true
    }
    return transformed
  })
}
987752
def extract_directives(header)
        processed_header = String.new("")
        directives = []

        header.lines.each_with_index do |line, index|
          if directive = line[DIRECTIVE_PATTERN, 1]
            name, *args = Shellwords.shellwords(directive)
            if respond_to?("process_#{name}_directive", true)
              directives << [index + 1, name, *args]
              # Replace directive line with a clean break
              line = "\n"
            end
          end
          processed_header << line
        end

        processed_header.chomp!
        # Ensure header ends in a new line like before it was processed
        processed_header << "\n" if processed_header.length > 0 && header[-1] == "\n"

        return processed_header, directives
      end
340566
public void makeScope(String path) {
        log.debug("makeScope: {}", path);
        WebSocketScope wsScope = null;
        if (!scopes.containsKey(path)) {
            // new websocket scope
            wsScope = new WebSocketScope();
            wsScope.setPath(path);
            notifyListeners(WebSocketEvent.SCOPE_CREATED, wsScope);
            addWebSocketScope(wsScope);
            log.debug("Use the IWebSocketScopeListener interface to be notified of new scopes");
        } else {
            log.debug("Scope already exists: {}", path);
        }
    }
781040
def _prefix_scope(self, scope):
        
        if self.protocol_scope_prefix:
            if isinstance(scope, tuple):
                return scope[0]
            elif scope.startswith(self.protocol_scope_prefix):
                return scope
            else:
                return '{}{}'.format(self.protocol_scope_prefix, scope)
        else:
            if isinstance(scope, tuple):
                return scope[0]
            else:
                return scope
1275380
function internal_parse_scope(center, distributionScope) {
	// "?" or "*" is filted by this.require()
	if (distributionScope.length < 4) return this.require(":::");

	// systemPart:pathPart:scopePart
	//		- rx_tokens = /^([^:]+):(.*):([^:]+)$/		-> m[0],m[1],m[2]
	var rx_tokens = /^(.*):([^:]+)$/, m = distributionScope.match(rx_tokens);
	if (! m) return this.require(":::");

	// TODO: dynamic scopePart parser, the <parts> is systemPart:pathPart
	// 		- var full = m[0], parts = m[1], scopePart = m[2];
	return (m[2] == '?') ? this.require("::?")
		: (m[2] == '*') ? Promise.resolve(center.require(m[1]))
		: Promise.reject("dynamic scopePart is not support for '"+distributionScope+"'");
}
290419
private Text parseText(Node el, Map<String, Scope> scopes) {
        Text text;
        if (nodeAttribute(el, TAG_VAR_ATTR_INHERIT, DEFAULT_INHERIT_VALUE)) {
            text = new Text(
                    nodeAttribute(el, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME),
                    null,
                    nodeAttribute(el, TAG_VAR_ATTR_TRANSPARENT, false)
            );
        } else {
            String scopeName = nodeAttribute(el, TAG_SCOPE, Scope.ROOT);
            Scope scope = scopes.get(scopeName);
            if (scope == null) {
                throw new TextProcessorFactoryException(
                        MessageFormat.format("Scope \"{0}\" not found.", scopeName)
                );
            }

            text = new Text(
                    nodeAttribute(el, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME),
                    scope,
                    nodeAttribute(el, TAG_VAR_ATTR_TRANSPARENT, false)
            );
        }
        return text;
    }
209597
def _get_code_w_scope(data, position, obj_end, opts, element_name):
    """"""
    code_end = position + _UNPACK_INT(data[position:position + 4])[0]
    code, position = _get_string(
        data, position + 4, code_end, opts, element_name)
    scope, position = _get_object(data, position, code_end, opts, element_name)
    if position != code_end:
        raise InvalidBSON('scope outside of javascript code boundaries')
    return Code(code, scope), position
1221309
def parse_directive_locations(lexer: Lexer) -> List[NameNode]:
    """"""
    # optional leading pipe
    expect_optional_token(lexer, TokenKind.PIPE)
    locations: List[NameNode] = []
    append = locations.append
    while True:
        append(parse_directive_location(lexer))
        if not expect_optional_token(lexer, TokenKind.PIPE):
            break
    return locations
948310
function visitDirective(directive: Directive): ?Directive {
  if (
    this.getContext()
      .serverSchema.getDirectives()
      .some(schemaDirective => schemaDirective.name === directive.name)
  ) {
    return directive;
  }
  return null;
}
875401
def get_directives(self, token: dict = None, prot: str = "https") -> dict:
        
        # search request
        req_url = "{}://v1.{}.isogeo.com/directives".format(prot, self.api_url)

        req = self.get(
            req_url, headers=self.header, proxies=self.proxies, verify=self.ssl
        )

        # checking response
        checker.check_api_response(req)

        # end of method
        return req.json()
779955
def _parse_directive(self, directive):
        
        words = directive.split()
        if len(words) == 1 and words[0] not in ('include', 'exclude',
                                                'global-include',
                                                'global-exclude',
                                                'recursive-include',
                                                'recursive-exclude',
                                                'graft', 'prune'):
            # no action given, let's use the default 'include'
            words.insert(0, 'include')

        action = words[0]
        patterns = thedir = dir_pattern = None

        if action in ('include', 'exclude',
                      'global-include', 'global-exclude'):
            if len(words) < 2:
                raise DistlibException(
                    '%r expects <pattern1> <pattern2> ...' % action)

            patterns = [convert_path(word) for word in words[1:]]

        elif action in ('recursive-include', 'recursive-exclude'):
            if len(words) < 3:
                raise DistlibException(
                    '%r expects <dir> <pattern1> <pattern2> ...' % action)

            thedir = convert_path(words[1])
            patterns = [convert_path(word) for word in words[2:]]

        elif action in ('graft', 'prune'):
            if len(words) != 2:
                raise DistlibException(
                    '%r expects a single <dir_pattern>' % action)

            dir_pattern = convert_path(words[1])

        else:
            raise DistlibException('unknown action %r' % action)

        return action, patterns, thedir, dir_pattern
872973
function getScope(scopeManager, currentNode) {

    // On Program node, get the outermost scope to avoid return Node.js special function scope or ES modules scope.
    const inner = currentNode.type !== "Program";

    for (let node = currentNode; node; node = node.parent) {
        const scope = scopeManager.acquire(node, inner);

        if (scope) {
            if (scope.type === "function-expression-name") {
                return scope.childScopes[0];
            }
            return scope;
        }
    }

    return scopeManager.scopes[0];
}
1080886
def create_scope(self, info, scope_id):
        
        route_values = {}
        if scope_id is not None:
            route_values['scopeId'] = self._serialize.url('scope_id', scope_id, 'str')
        content = self._serialize.body(info, 'CreateScopeInfo')
        response = self._send(http_method='PUT',
                              location_id='4e11e2bf-1e79-4eb5-8f34-a6337bd0de38',
                              version='5.0-preview.2',
                              route_values=route_values,
                              content=content)
        return self._deserialize('IdentityScope', response)
214728
function (text, scope, attrKey, bindingDefinitions) {
            if (!_.isString(text)) {
                return text;
            }

            bindingDefinitions = bindingDefinitions || this.parse(text);

            var binding,
                bindings = [],
                ret = [];

            for (var i = 0; i < bindingDefinitions.length; i++) {
                var bindingDef = bindingDefinitions[i];
                if (bindingDef.length) {
                    ret.push(bindingDef);
                } else {
                    try {
                        binding = this.create(bindingDef, scope, attrKey, ret);
                    } catch (e) {
                        throw new Error("Create binding for '" + text + "'. " + e.message);
                    }

                    if (binding instanceof Binding) {
                        bindings.push(binding);
                        scope.$bindings[attrKey] = scope.$bindings[attrKey] || [];
                        scope.$bindings[attrKey].push(binding);
                    }
                    ret.push(binding);
                }

            }

            if (bindings.length > 0) {
                return bindings[0].getContextValue();
            } else if (ret.length > 0) {
                if (ret.length === 1) {
                    return ret[0];
                }
                return Binding.contextToString(ret);
            } else {
                return text;
            }

        }
677412
function directives() {
    var i, p, pn;

    for (;;) {
      if (state.tokens.next.id === "(string)") {
        p = peek(0);
        if (p.id === "(endline)") {
          i = 1;
          do {
            pn = peek(i);
            i = i + 1;
          } while (pn.id === "(endline)");

          if (pn.id !== ";") {
            if (pn.id !== "(string)" && pn.id !== "(number)" &&
              pn.id !== "(regexp)" && pn.identifier !== true &&
              pn.id !== "}") {
              break;
            }
            warning("W033", state.tokens.next);
          } else {
            p = pn;
          }
        } else if (p.id === "}") {
          // Directive with no other statements, warn about missing semicolon
          warning("W033", p);
        } else if (p.id !== ";") {
          break;
        }

        advance();
        if (state.directive[state.tokens.curr.value]) {
          warning("W034", state.tokens.curr, state.tokens.curr.value);
        }

        if (state.tokens.curr.value === "use strict") {
          if (!state.option["(explicitNewcap)"])
            state.option.newcap = true;
          state.option.undef = true;
        }

        // there's no directive negation, so always set to true
        state.directive[state.tokens.curr.value] = true;

        if (p.id === ";") {
          advance(";");
        }
        continue;
      }
      break;
    }
  }