Parse the given spec into a `specs.Spec` object.

    :param spec: a single spec string.
    :return: a single specs.Specs object.
    :raises: CmdLineSpecParser.BadSpecError if the address selector could not be parsed.
484176
def parse_spec(self, spec):
    

    if spec.endswith('::'):
      spec_path = spec[:-len('::')]
      return DescendantAddresses(self._normalize_spec_path(spec_path))
    elif spec.endswith(':'):
      spec_path = spec[:-len(':')]
      return SiblingAddresses(self._normalize_spec_path(spec_path))
    else:
      spec_parts = spec.rsplit(':', 1)
      spec_path = self._normalize_spec_path(spec_parts[0]) 
      name = spec_parts[1] if len(spec_parts) > 1 else os.path.basename(spec_path)
      return SingleAddress(spec_path, name)
1103238
def __dict_to_pod_spec(spec):
    '''
    
    '''
    spec_obj = kubernetes.client.V1PodSpec()
    for key, value in iteritems(spec):
        if hasattr(spec_obj, key):
            setattr(spec_obj, key, value)

    return spec_obj
1337195
def load(self, spec):
        
        if spec.template is not None:
            return self.loader.unicode(spec.template, spec.template_encoding)

        path = self._find(spec)

        return self.loader.read(path, spec.template_encoding)
320020
def get_target_from_spec(self, spec, relative_to=''):
    
    return self.get_target(Address.parse(spec, relative_to=relative_to))
400150
def _parse_command_spec(self, spec, precmds):
        '''
        
        '''
        if 'pre_command' in spec:
            precmd_alias = spec['pre_command']
            try:
                precmd = precmds[precmd_alias]

                if self._blacklist_check(precmd):
                    raise RuntimeError("Command Blacklist: " + precmd)

                args = self._run_pre_command(precmd)
                logger.debug('Pre-command results: %s', args)

                expanded_specs = []
                for arg in args:
                    _spec = copy.copy(spec)
                    _spec['command'] = _spec['command'] + ' ' + arg
                    expanded_specs.append(_spec)
                return expanded_specs
            except LookupError:
                logger.debug('Pre-command %s not found. Skipping %s...',
                             precmd_alias, spec['command'])
                return []
        else:
            return [spec]
17553
def parse(cmdline = ARGV)
			vals = {}
			required = {}

			opt :version, "Print version and exit" if @version && ! (@specs[:version] || @long["version"])
			opt :help, "Show this message" unless @specs[:help] || @long["help"]

			@specs.each do |sym, opts|
				required[sym] = true if opts.required?
				vals[sym] = opts.default
				vals[sym] = [] if opts.multi && !opts.default # multi arguments default to [], not nil
			end

			resolve_default_short_options!

			## resolve symbols
			given_args = {}
			@leftovers = each_arg cmdline do |arg, params|
				## handle --no- forms
				arg, negative_given = if arg =~ /^--no-([^-]\S*)$/
																["--#{$1}", true]
															else
																[arg, false]
															end

				sym = case arg
							when /^-([^-])$/      then @short[$1]
							when /^--([^-]\S*)$/  then @long[$1] || @long["no-#{$1}"]
							else                       raise CommandlineError, "invalid argument syntax: '#{arg}'"
							end

				sym = nil if arg =~ /--no-/ # explicitly invalidate --no-no- arguments

				next nil if ignore_invalid_options && !sym
				raise CommandlineError, "unknown argument '#{arg}'" unless sym

				if given_args.include?(sym) && !@specs[sym].multi?
					raise CommandlineError, "option '#{arg}' specified multiple times"
				end

				given_args[sym] ||= {}
				given_args[sym][:arg] = arg
				given_args[sym][:negative_given] = negative_given
				given_args[sym][:params] ||= []

				# The block returns the number of parameters taken.
				num_params_taken = 0

				unless params.empty?
					if @specs[sym].single_arg?
						given_args[sym][:params] << params[0, 1]  # take the first parameter
						num_params_taken = 1
					elsif @specs[sym].multi_arg?
						given_args[sym][:params] << params        # take all the parameters
						num_params_taken = params.size
					end
				end

				num_params_taken
			end

			## check for version and help args
			raise VersionNeeded if given_args.include? :version
			raise HelpNeeded if given_args.include? :help

			## check constraint satisfaction
			@constraints.each do |type, syms|
				constraint_sym = syms.find { |sym| given_args[sym] }
				next unless constraint_sym

				case type
				when :depends
					syms.each { |sym| raise CommandlineError, "--#{@specs[constraint_sym].long} requires --#{@specs[sym].long}" unless given_args.include? sym }
				when :conflicts
					syms.each { |sym| raise CommandlineError, "--#{@specs[constraint_sym].long} conflicts with --#{@specs[sym].long}" if given_args.include?(sym) && (sym != constraint_sym) }
				end
			end

			required.each do |sym, val|
				raise CommandlineError, "option --#{@specs[sym].long} must be specified" unless given_args.include? sym
			end

			## parse parameters
			given_args.each do |sym, given_data|
				arg, params, negative_given = given_data.values_at :arg, :params, :negative_given

				opts = @specs[sym]
				if params.empty? && !opts.flag?
					raise CommandlineError, "option '#{arg}' needs a parameter" unless opts.default
					params << (opts.array_default? ? opts.default.clone : [opts.default])
				end

				params[0].each do |p|
					raise CommandlineError, "option '#{arg}' only accepts one of: #{opts.permitted.join(', ')}" unless opts.permitted.include? p
				end unless opts.permitted.nil?

				vals["#{sym}_given".intern] = true # mark argument as specified on the commandline

				vals[sym] = opts.parse(params, negative_given)

				if opts.single_arg?
					if opts.multi?        # multiple options, each with a single parameter
						vals[sym] = vals[sym].map { |p| p[0] }
					else                  # single parameter
						vals[sym] = vals[sym][0][0]
					end
				elsif opts.multi_arg? && !opts.multi?
					vals[sym] = vals[sym][0]  # single option, with multiple parameters
				end
				# else: multiple options, with multiple parameters

				opts.callback.call(vals[sym]) if opts.callback
			end

			## modify input in place with only those
			## arguments we didn't process
			cmdline.clear
			@leftovers.each { |l| cmdline << l }

			## allow openstruct-style accessors
			class << vals
				def method_missing(m, *_args)
					self[m] || self[m.to_s]
				end
			end
			vals
		end
46915
public static PJsonObject parseSpec(final String spec) {
        final JSONObject jsonSpec;
        try {
            jsonSpec = new JSONObject(spec);
        } catch (JSONException e) {
            throw new RuntimeException("Cannot parse the spec file: " + spec, e);
        }
        return new PJsonObject(jsonSpec, "spec");
    }
508148
def _example_from_definition(self, prop_spec):
        
        # Get value from definition
        definition_name = self.get_definition_name_from_ref(prop_spec['$ref'])

        if self.build_one_definition_example(definition_name):
            example_dict = self.definitions_example[definition_name]
            if not isinstance(example_dict, dict):
                return example_dict
            example = dict((example_name, example_value) for example_name, example_value in example_dict.items())
            return example
1068905
def _section_from_spec(elf_file, spec):
    '''
        
    '''
    if isinstance(spec, int):
        num = int(spec)
        if num < elf_file.num_sections():
            return elf_file.get_section(num)

    # Not a number. Must be a name then
    if isinstance(spec, str):
        try:
            return elf_file.get_section_by_name(spec)
        except AttributeError:
            return None
1164722
def parse_spec(self):
        
        recruiters = []
        spec = get_config().get("recruiters")
        for match in self.SPEC_RE.finditer(spec):
            name = match.group(1)
            count = int(match.group(2))
            recruiters.append((name, count))
        return recruiters
1176892
static BackoffSpec parse(String specification) {
        requireNonNull(specification, "specification");
        final BackoffSpec spec = new BackoffSpec(specification);
        for (String option : OPTION_SPLITTER.split(specification)) {
            spec.parseOption(option);
        }
        return spec;
    }
916758
def from_path(cls, spec_path):
        
        with spec_path.open() as spec_file:
            return cls.from_document(load(spec_file))
651354
def spec(self):
        """"""
        from ambry_sources.sources import SourceSpec

        d = self.dict
        d['url'] = self.url

        # Will get the URL twice; once as ref and once as URL, but the ref is ignored

        return SourceSpec(**d)
948000
def _get_spec(tree_base, spec, template, saltenv='base'):
    '''
    
    '''
    spec_tgt = os.path.basename(spec)
    dest = os.path.join(tree_base, 'SPECS', spec_tgt)
    return __salt__['cp.get_url'](
        spec,
        dest,
        saltenv=saltenv)
252563
def nodes_for_spec(self, spec):
        
        tokens = []
        if isinstance(spec, sb.create_spec):
            container = nodes.container(classes=["option_spec_option shortline blue-back"])
            creates = spec.kls
            for name, option in sorted(spec.kwargs.items(), key=lambda x: len(x[0])):
                para = nodes.paragraph(classes=["option monospaced"])
                para += nodes.Text("{0} = ".format(name))
                self.nodes_for_signature(option, para)

                fields = {}
                if creates and hasattr(creates, 'fields') and isinstance(creates.fields, dict):
                    for key, val in creates.fields.items():
                        if isinstance(key, tuple):
                            fields[key[0]] = val
                        else:
                            fields[key] = val

                txt = fields.get(name) or "No description"
                viewlist = ViewList()
                for line in dedent(txt).split('\n'):
                    viewlist.append(line, name)
                desc = nodes.section(classes=["description monospaced"])
                self.state.nested_parse(viewlist, self.content_offset, desc)

                container += para
                container += desc
                container.extend(self.nodes_for_spec(option))
            tokens.append(container)
        elif isinstance(spec, sb.optional_spec):
            tokens.extend(self.nodes_for_spec(spec.spec))
        elif isinstance(spec, sb.container_spec):
            tokens.extend(self.nodes_for_spec(spec.spec))
        elif isinstance(spec, sb.dictof):
            tokens.extend(self.nodes_for_spec(spec.value_spec))

        return tokens
652423
@NonNull
  public static Caffeine<Object, Object> from(String spec) {
    return from(CaffeineSpec.parse(spec));
  }
796019
def _section_from_spec(self, spec):
        '''
            
        '''
        try:
            num = int(spec)
            if num < self.elf_file.num_sections():
                return self.elf_file.get_section(num)
            else:
                return None
        except ValueError:
            # Not a number. Must be a name then
            return self.elf_file.get_section_by_name(spec)