Supports `import: otherfile.yml` in docstring specs
490002
def parse_imports(full_doc, root_path=None):
    
    regex = re.compile('import: "(.*)"')
    import_prop = regex.search(full_doc)
    if import_prop:
        start = import_prop.start()
        spaces_num = start - full_doc.rfind('\n', 0, start) - 1
        filepath = import_prop.group(1)
        if filepath.startswith('/'):
            imported_doc = load_from_file(filepath)
        else:
            imported_doc = load_from_file(filepath, root_path=root_path)
        indented_imported_doc = imported_doc.replace(
            '\n', '\n' + ' ' * spaces_num
        )
        full_doc = regex.sub(indented_imported_doc, full_doc, count=1)
        return parse_imports(full_doc)
    return full_doc
1103700
def parse_yaml(self, y):
        '''

        '''
        self.connector_id = y['connectorId']
        self.name = y['name']
        if 'transMethod' in y:
            self.trans_method = y['transMethod']
        else:
            self.trans_method = ''
        if RTS_EXT_NS_YAML + 'comment' in y:
            self.comment = y[RTS_EXT_NS_YAML + 'comment']
        else:
            self.comment = ''
        if RTS_EXT_NS_YAML + 'visible' in y:
            visible = y[RTS_EXT_NS_YAML + 'visible']
            if visible == True or visible == 'true' or visible == '1':
                self.visible = True
            else:
                self.visible = False
        if 'sourceServicePort' not in y:
            raise InvalidServicePortConnectorNodeError
        self.source_service_port = \
                TargetPort().parse_yaml(y['sourceServicePort'])
        if 'targetServicePort' not in y:
            raise InvalidServicePortConnectorNodeError
        self.target_service_port = \
                TargetPort().parse_yaml(y['targetServicePort'])
        if RTS_EXT_NS_YAML + 'properties' in y:
            for p in y[RTS_EXT_NS_YAML + 'properties']:
                if 'value' in p:
                    value = p['value']
                else:
                    value = None
                self._properties[p['name']] = value
        return self
578347
function stringYAML2YAML (doc, compact = false) {
  if (!doc || typeof doc !== 'string') {
    throw new TypeError('Argument must be a string or object, and not empty: ' + doc)
  }

  let obj = yaml.safeLoad(doc)

  if (!obj || typeof obj !== 'object') {
    throw new TypeError('Argument must be in yaml format: ' + doc)
  }

  return yaml.safeDump(obj, compact ? { 'flowLevel': 0 } : undefined)
}
1056877
def auto_change_docstring(app, what, name, obj, options, lines):
    
    """
    if what == 'module' and name.startswith('pylatex'):
        lines.insert(0, len(name) * '=')
        lines.insert(0, name)

    hits = 0
    for i, line in enumerate(lines.copy()):
        if line.endswith('\\'):
            lines[i - hits] += lines.pop(i + 1 - hits)
            hits += 1
934764
def prose_wc(args):
    
    if args.file is None:
        return 1
    if args.split_hyphens:
        INTERSTITIAL_PUNCTUATION.append(re.compile(r'-'))
    content = args.file.read().decode('utf-8')
    filename = args.file.name
    body = strip_frontmatter(content)
    parsed = markdown_to_text(body)
    result = wc(filename, body, parsed=parsed,
                is_jekyll=(body != content))
    if (args.update and
            filename != '_stdin_' and
            result['counts']['type'] == 'jekyll'):
        update_file(filename, result, content, args.indent)
    else:
        _mockable_print({
            'yaml': yaml.safe_dump(result, default_flow_style=False,
                              indent=args.indent),
            'json': json.dumps(result, indent=args.indent),
            'default': default_dump(result),
        }[args.format])
    return 0
13245
def _extract_yaml_docstring(stream):
        '''
        
        '''
        comment_lines = []
        lines = stream.read().splitlines()
        for line in lines:
            line_strip = line.strip()
            if not line_strip:
                continue
            if line_strip.startswith('#'):
                comment_lines.append(
                    line_strip.replace('#', '', 1).strip()
                )
            else:
                break
        return ' '.join(comment_lines)
964721
function parseApiFile(file) {
  const jsDocRegex = /\/\*\*([\s\S]*?)\*\//gm;
  const fileContent = fs.readFileSync(file, { encoding: 'utf8' });
  const ext = path.extname(file);
  const yaml = [];
  const jsDocComments = [];

  if (ext === '.yaml' || ext === '.yml') {
    yaml.push(jsYaml.safeLoad(fileContent));
  } else {
    const regexResults = fileContent.match(jsDocRegex);
    if (regexResults) {
      for (let i = 0; i < regexResults.length; i += 1) {
        const jsDocComment = doctrine.parse(regexResults[i], { unwrap: true });
        jsDocComments.push(jsDocComment);
      }
    }
  }

  return {
    yaml,
    jsdoc: jsDocComments,
  };
}
1151685
function parseFile (filePath, fileContent) {
  let config = null
  const extension = path.extname(filePath)

  if (extension === '.yml' || extension === '.yaml') {
    config = yaml.safeLoad(replaceEnvironmentVariables(fileContent))
  } else if (extension === '.js') {
    config = require(path.resolve(filePath)) // eslint-disable-line
  } else if (extension === '.json') {
    config = JSON.parse(replaceEnvironmentVariables(fileContent))
  } else {
    throw new Error(`${extension} is not supported as configuration file`)
  }

  return config
}
904954
def __load_yml(self, stream):
        

        try:
            return yaml.load(stream, Loader=yaml.SafeLoader)
        except ValueError as e:
            cause = "invalid yml format. %s" % str(e)
            raise InvalidFormatError(cause=cause)
1096672
def show_doc_from_name(mod_name, ft_name:str, doc_string:bool=True, arg_comments:dict={}, alt_doc_string:str=''):
    ""
    mod = import_mod(mod_name)
    splits = str.split(ft_name, '.')
    assert hasattr(mod, splits[0]), print(f"Module {mod_name} doesn't have a function named {splits[0]}.")
    elt = getattr(mod, splits[0])
    for i,split in enumerate(splits[1:]):
        assert hasattr(elt, split), print(f"Class {'.'.join(splits[:i+1])} doesn't have a function named {split}.")
        elt = getattr(elt, split)
    show_doc(elt, doc_string, ft_name, arg_comments, alt_doc_string)
1250635
def _load(content_or_fp):
    
    try:
        data = yaml.load(content_or_fp, Loader=yaml.loader.BaseLoader)
    except Exception as e:
        raise type(e)('Malformed yaml file:\n%r' % format_exc())

    try:
        ver = data['spec']
    except:
        raise ValueError('The file does not specify a spec version')

    try:
        ver = tuple(map(int, (ver.split("."))))
    except:
        raise ValueError("Invalid spec version format. Expect 'X.Y'"
                         " (X and Y integers), found %s" % ver)

    if ver > SPEC_VERSION_TUPLE:
        raise ValueError('The spec version of the file is '
                         '%s but the parser is %s. '
                         'Please update pyvisa-sim.' % (ver, SPEC_VERSION))

    return data
821411
function yakeFileMain(argv, cwd)
{    
    if( cwd === undefined) cwd = process.cwd();
    if( argv === undefined ) argv = process.argv


    const [options, args, helpText] = CLI.CliParse(argv);
    const collection = getTasksFromYakefile(cwd, options.getValueFor('file'));
    const p = loadPackageJson();
    if( tryShowVersion(options, p.version) )
        return;
    if( tryShowTasks(options, collection) )
        return;
    if( tryShowHelp(options, helpText) )
        return;

    tryRunTask(args, collection);
}
185469
def from_file(cls, config_path=None, *args, **kwargs):
        

        config_reader = kaptan.Kaptan()

        config = {}

        if config_path:
            if not os.path.exists(config_path):
                raise exc.CihaiException(
                    '{0} does not exist.'.format(os.path.abspath(config_path))
                )
            if not any(
                config_path.endswith(ext) for ext in ('json', 'yml', 'yaml', 'ini')
            ):
                raise exc.CihaiException(
                    '{0} does not have a yaml,yml,json,ini extend.'.format(
                        os.path.abspath(config_path)
                    )
                )
            else:
                custom_config = config_reader.import_config(config_path).get()
                config = merge_dict(config, custom_config)

        return cls(config)
1292530
def _load_yml_config(self, config_file):
        
        if not isinstance(config_file, six.string_types):
            raise TypeError('config_file must be a str.')

        try:
            def construct_yaml_int(self, node):
                obj  = SafeConstructor.construct_yaml_int(self, node)
                data = ConfigInt(
                    obj,
                    node.start_mark,
                    node.end_mark
                )

                return data

            def construct_yaml_float(self, node):
                obj, = SafeConstructor.construct_yaml_float(self, node)
                data = ConfigFloat(
                    obj,
                    node.start_mark,
                    node.end_mark
                )

                return data

            def construct_yaml_str(self, node):
                # Override the default string handling function
                # to always return unicode objects
                obj = SafeConstructor.construct_scalar(self, node)

                assert isinstance(obj, six.string_types)
                data = ConfigUnicode(
                    obj,
                    node.start_mark,
                    node.end_mark
                )

                return data

            def construct_yaml_mapping(self, node):
                obj, = SafeConstructor.construct_yaml_map(self, node)
                data = ConfigDict(
                    obj,
                    node.start_mark,
                    node.end_mark
                )

                return data

            def construct_yaml_seq(self, node):
                obj, = SafeConstructor.construct_yaml_seq(self, node)
                data = ConfigSeq(
                    obj,
                    node.start_mark,
                    node.end_mark
                )

                return data

            # SafeConstructor.add_constructor(u'tag:yaml.org,2002:bool',  construct_yaml_bool)
            SafeConstructor.add_constructor(u'tag:yaml.org,2002:float', construct_yaml_float)
            SafeConstructor.add_constructor(u'tag:yaml.org,2002:int', construct_yaml_int)
            SafeConstructor.add_constructor(u'tag:yaml.org,2002:map', construct_yaml_mapping)
            SafeConstructor.add_constructor(u'tag:yaml.org,2002:seq', construct_yaml_seq)
            SafeConstructor.add_constructor(u'tag:yaml.org,2002:str', construct_yaml_str)

            data = SafeLoader(config_file).get_data()
            if data is None:
                raise AttributeError('The configuration file needs to have data in it.')

            self._data = normalize_keys(data, snake_case=False)
        except YAMLError as e:
            if hasattr(e, 'problem_mark'):
                mark = e.problem_mark
                raise SyntaxError(
                    "There is a syntax error in your freight-forwarder config file line: {0} column: {1}".format(
                        mark.line + 1,
                        mark.column + 1
                    )
                )
            else:
                raise SyntaxError("There is a syntax error in your freight-forwarder config.")
334976
def determine_file_type(filename):
    
    if filename.endswith('.cls'):
        return FileType.CLS
    elif filename.endswith('.go'):
        return FileType.GO
    elif filename.endswith('.java'):
        return FileType.JAVA
    elif filename.endswith('.js'):
        return FileType.JAVASCRIPT
    elif filename.endswith('.php'):
        return FileType.PHP
    elif filename.endswith('.py'):
        return FileType.PYTHON
    elif (
        filename.endswith(
            ('.yaml', '.yml'),
        )
    ):
        return FileType.YAML
    return FileType.OTHER
1289636
function normalizeModuleAndLoadMetadata(programPath) {

    nameAnonymousExports(programPath);

    const {local, source} = getModuleMetadata(programPath);

    removeModuleDeclarations(programPath);

    // Reuse the imported namespace name if there is one.
    for (const [, metadata] of source) {
        if (metadata.importsNamespace.size > 0) {
            // This is kind of gross. If we stop using `loose: true` we should
            // just make this destructuring assignment.
            metadata.name = metadata.importsNamespace.values().next().value;
        }
    }

    return {
        exportName: 'exports',
        exportNameListName: null,
        local,
        source
    };
}
120269
def getYamlDocument(filePath):
    
    with open(filePath) as stream:
        doc = yaml.load(stream)
        return doc