Converts running-config HEREDOC into EAPI JSON dict
171250
def _multiline_convert(config, start="banner login", end="EOF", depth=1):
        """"""
        ret = list(config)  # Don't modify list in-place
        try:
            s = ret.index(start)
            e = s
            while depth:
                e = ret.index(end, e + 1)
                depth = depth - 1
        except ValueError:  # Couldn't find end, abort
            return ret
        ret[s] = {"cmd": ret[s], "input": "\n".join(ret[s + 1 : e])}
        del ret[s + 1 : e + 1]

        return ret
591438
def all_as_dict():
    '''
    
                    
    '''
    cmd = ['lxc-list']
    out = subprocess.check_output(cmd).splitlines()
    stopped = []
    running = []
    frozen = []
    current = None
    for c in out:
        c = c.strip()
        if c == 'RUNNING':
            current = running
            continue
        if c == 'STOPPED':
            current = stopped
            continue
        if c == 'FROZEN':
            current = frozen
            continue
        if not len(c):
            continue
        current.append(c)
    return {'Running': running,
            'Stopped': stopped,
            'Frozen': frozen}
1138775
def get_run_details_json(self):
        
        run_details_filename = "run_details.json"
        run_details_json_id = dxpy.find_one_data_object(more_ok=False,zero_ok=True,project=self.dx_project_id,name=run_details_filename)["id"]
        json_data = json.loads(dxpy.open_dxfile(dxid=run_details_json_id).read())
        #dxpy.download_dxfile(show_progress=True,dxid=run_details_json_id,project=self.dx_project_id,filename=output_name)
        return json_data
780440
def __dict_to_deployment_spec(spec):
    '''
    
    '''
    spec_obj = AppsV1beta1DeploymentSpec(template=spec.get('template', ''))
    for key, value in iteritems(spec):
        if hasattr(spec_obj, key):
            setattr(spec_obj, key, value)

    return spec_obj
666530
def _get_run_info_dict(self, run_id):
    """"""
    run_info_path = os.path.join(self._settings.info_dir, run_id, 'info')
    if os.path.exists(run_info_path):
      # We copy the RunInfo as a dict, so we can add stuff to it to pass to the template.
      return RunInfo(run_info_path).get_as_dict()
    else:
      return None
617359
def _load_config():
    """"""
    fname = _get_config_fname()
    if fname is None or not op.isfile(fname):
        return dict()
    with open(fname, 'r') as fid:
        config = json.load(fid)
    return config
941425
def configs_in(src_dir):
    """"""
    for filename in files_in_dir(src_dir, 'json'):
        with open(os.path.join(src_dir, filename), 'rb') as in_f:
            yield json.load(in_f)
912092
def _load_with_overrides(base) -> Dict[str, str]:
    
    should_write = False
    overrides = _get_environ_overrides()
    try:
        index = json.load((base/_CONFIG_FILENAME).open())
    except (OSError, json.JSONDecodeError) as e:
        sys.stderr.write("Error loading config from {}: {}\nRewriting...\n"
                         .format(str(base), e))
        should_write = True
        index = generate_config_index(overrides)

    for key in CONFIG_ELEMENTS:
        if key.name not in index:
            sys.stderr.write(
                f"New config index key {key.name}={key.default}"
                "\nRewriting...\n")
            if key.kind in (ConfigElementType.DIR, ConfigElementType.FILE):
                index[key.name] = base/key.default
            else:
                index[key.name] = key.default
            should_write = True

    if should_write:
        try:
            write_config(index, path=base)
        except Exception as e:
            sys.stderr.write(
                "Error writing config to {}: {}\nProceeding memory-only\n"
                .format(str(base), e))
    index.update(overrides)
    return index
736808
def get_configuration_dict(self, secret_attrs=False):
        """"""
        cd = {'repo_nexml2json': self.repo_nexml2json,
              'number_of_shards': len(self._shards),
              'initialization': self._filepath_args,
              'shards': [],
              }
        for i in self._shards:
            cd['shards'].append(i.get_configuration_dict(secret_attrs=secret_attrs))
        return cd
1120756
def _read_config(self):
        
        
        this_dir = os.path.dirname(__file__)        
        config_file = os.path.abspath(os.path.join(this_dir, "..", "config", "config.json"))

        self.generic_enum_attrs = []
        self.base_attrs = []
        self.generic_enums = []
        self.named_entity_attrs = []
        self.overide_generic_enums = []
        self.enum_attrs_for_locale = {}
        self.generic_enum_attrs_for_locale = {}
        self.list_subtypes_generic = []
        
        Printer.log("Configuration file: %s" % (config_file))

        if (os.path.isfile(config_file)):
            with open(config_file, 'r') as input_json:
                json_config_data = json.load(input_json) 
                
            self.base_attrs = json_config_data['base_attrs']
            self.generic_enums =  json_config_data['generic_enums']
            self.named_entity_attrs = json_config_data['named_entity_attrs']
            self.overide_generic_enums = json_config_data['overide_generic_enums']
            self.list_subtypes_generic = json_config_data['list_subtypes_generic']

            for enum_name, values in self.generic_enums.iteritems():
                enum_attr =  SpecificationAttribute()
                enum_attr.name = enum_name
                enum_attr.allowed_choices = values
                self.generic_enum_attrs.append(enum_attr)
        else:
            Printer.log("Configuration file missing: %s" % (config_file))
190988
def template(self):
        """"""
        r = fapi.get_config_template(self.namespace, self.name,
                                        self.snapshot_id, self.api_url)
        fapi._check_response_code(r, 200)
        return r.json()
269836
def to_json(cls, config, compact=False, indent=2, level=0):
        
        lines = ""
        if isinstance(config, ConfigTree):
            if len(config) == 0:
                lines += '{}'
            else:
                lines += '{\n'
                bet_lines = []
                for key, item in config.items():
                    bet_lines.append('{indent}"{key}": {value}'.format(
                        indent=''.rjust((level + 1) * indent, ' '),
                        key=key.strip('"'),  # for dotted keys enclosed with "" to not be interpreted as nested key
                        value=cls.to_json(item, compact, indent, level + 1))
                    )
                lines += ',\n'.join(bet_lines)
                lines += '\n{indent}}}'.format(indent=''.rjust(level * indent, ' '))
        elif isinstance(config, list):
            if len(config) == 0:
                lines += '[]'
            else:
                lines += '[\n'
                bet_lines = []
                for item in config:
                    bet_lines.append('{indent}{value}'.format(
                        indent=''.rjust((level + 1) * indent, ' '),
                        value=cls.to_json(item, compact, indent, level + 1))
                    )
                lines += ',\n'.join(bet_lines)
                lines += '\n{indent}]'.format(indent=''.rjust(level * indent, ' '))
        elif isinstance(config, basestring):
            lines = json.dumps(config)
        elif config is None or isinstance(config, NoneValue):
            lines = 'null'
        elif config is True:
            lines = 'true'
        elif config is False:
            lines = 'false'
        else:
            lines = str(config)
        return lines
1303683
def parse_config(config, env, as_dict=True):
  

  if config is None:
    return None
  stripped = config.strip()
  if len(stripped) == 0:
    config = {}
  elif stripped[0] == '{':
    config = json.loads(config)
  else:
    config = yaml.load(config)
  if as_dict:
    config = dict(config)

  # Now we need to walk the config dictionary recursively replacing any '$name' vars.
  replace_vars(config, env)
  return config
40745
def GetSyncMoConfig(ConfigDoc):
		
		moConfigMap = {}
		configList = ConfigDoc.getElementsByTagName("mo")

		for moConfigNode in configList:
			classId = None
			noun = None
			version = None
			actionVersion = None
			action = None
			ignoreReason = None
			status = None
			excludeList = None

			if moConfigNode.hasAttribute("classid"):
				classId = moConfigNode.getAttribute("classid")

			if moConfigNode.hasAttribute("noun"):
				noun = moConfigNode.getAttribute("noun")

			if moConfigNode.hasAttribute("version"):
				version = moConfigNode.getAttribute("version")

			if moConfigNode.hasAttribute("actionVersion"):
				actionVersion = moConfigNode.getAttribute("actionVersion")

			if moConfigNode.hasAttribute("action"):
				action = moConfigNode.getAttribute("action")

			if moConfigNode.hasAttribute("ignoreReason"):
				ignoreReason = moConfigNode.getAttribute("ignoreReason")

			if moConfigNode.hasAttribute("status"):
				status = moConfigNode.getAttribute("status")

			if moConfigNode.hasAttribute("excludeList"):
				excludeList = moConfigNode.getAttribute("excludeList")

			# SyncMoConfig Object
			moConfig = None

			if classId:
				moConfig = SyncMoConfig(classId, noun, version, actionVersion, action, ignoreReason, status,
										excludeList)

			if moConfig:
				if classId in moConfigMap:
					moConfigMap[classId] = moConfig
				else:
					moConfigList = []
					moConfigList.append(moConfig)
					moConfigMap[classId] = moConfigList

		return moConfigMap
145719
def _config(self) -> ExtensionConfig:
        
        return dict(pattern=self.__pattern__, search_in_keys=True, search_in_values=False)
262528
function runTypedoc() {
  const typeSource = apiType === 'node' ? tempNodeSourcePath : sourceFile;
  const command = `${repoPath}/node_modules/.bin/typedoc ${typeSource} \
  --out ${docPath} \
  --readme ${tempHomePath} \
  --options ${__dirname}/typedoc.js \
  --theme ${__dirname}/theme`;

  console.log('Running command:\n', command);
  return exec(command);
}
1013817
def _get_validated_json(json_spec, args):
    
    if not json_spec:
        return
    if not args:
        return

    validated_spec = copy.deepcopy(json_spec)

    # print ignored keys if present in json_spec
    unsupported_keys = _get_unsupported_keys(validated_spec.keys(), SUPPORTED_KEYS)
    if len(unsupported_keys) > 0:
        logger.warn(
            "Warning: the following root level fields are not supported and will be ignored: {}"
                .format(", ".join(unsupported_keys)))


    if 'stages' in validated_spec:
        validated_spec['stages'] = _get_validated_stages(validated_spec['stages'])

    if 'name' in validated_spec:
        if args.src_dir != validated_spec['name']:
            logger.warn(
                'workflow name "%s" does not match containing directory "%s"' % (validated_spec['name'], args.src_dir))

    if 'ignoreReuse' in validated_spec:
        validate_ignore_reuse(validated_spec['stages'], validated_spec['ignoreReuse'])

    validated_documentation_fields = _get_validated_json_for_build_or_update(validated_spec, args)
    validated_spec.update(validated_documentation_fields)

    # Project-based workflow specific validation
    if args.mode == 'workflow':
        validated = _validate_json_for_regular_workflow(json_spec, args)
        validated_spec.update(validated)

    # Global workflow specific validation
    if args.mode == 'globalworkflow':
        _validate_json_for_global_workflow(validated_spec, args)

    return validated_spec