Example::

            .. _header_2:

            Header 2
            -------------------------------------------------------------------

        **中文文档**
429317
def header(self, title, level, key, width=80):
        
        linestyle_code = {1: "=", 2: "-", 3: "~"}
        if level not in linestyle_code:
            raise Exception("'level' argument has to be 1, 2 or 3")
        else:
            linestyle = linestyle_code[level]

        if key:
            return "\n".join([".. _%s" % key, "", title, linestyle * width])
        else:
            return "\n".join([title, "=" * width])
1115468
def __ascii_reader(fh, header):
        

        lines = header.split('\n')
        recoverable = [True]

        def get(prefix=''):
            if lines:
                line = lines.pop(0)
            else:
                raise RuntimeError(recoverable[0], 'Unable to find more lines')

            if not lines:
                recoverable[0] = False

                # Read more lines and make sure we prepend any old data
                lines[:] = fh.read(Stl.BUFFER_SIZE).split('\n')
                line += lines.pop(0)
            line = line.lower().strip()
            if prefix:
                if line.startswith(prefix):
                    values = line.replace(prefix, '', 1).strip().split()
                elif line.startswith('endsolid'):
                    raise StopIteration()
                else:
                    raise RuntimeError(recoverable[0],
                                       '%r should start with %r' % (line,
                                                                    prefix))

                if len(values) == 3:
                    vertex = [float(v) for v in values]
                    return vertex
                else:  # pragma: no cover
                    raise RuntimeError(recoverable[0],
                                       'Incorrect value %r' % line)
            else:
                return line

        line = get()
        if not line.startswith('solid ') and line.startswith('solid'):
            print("Error")

        if not lines:
            raise RuntimeError(recoverable[0],
                               'No lines found, impossible to read')

        while True:
            # Read from the header lines first, until that point we can recover
            # and go to the binary option. After that we cannot due to
            # unseekable files such as sys.stdin
            #
            # Numpy doesn't support any non-file types so wrapping with a
            # buffer and/or StringIO does not work.
            try:
                normals = get('facet normal')
                assert get() == 'outer loop'
                v0 = get('vertex')
                v1 = get('vertex')
                v2 = get('vertex')
                assert get() == 'endloop'
                assert get() == 'endfacet'
                attrs = 0
                yield (normals, (v0, v1, v2), attrs)
            except AssertionError as e:
                raise RuntimeError(recoverable[0], e)
            except StopIteration:
                if any(lines):
                    # Seek back to where the next solid should begin
                    fh.seek(-len('\n'.join(lines)), os.SEEK_CUR)
                raise
949104
function combine(file) {
      if (!file) return;

      if (pathArr.indexOf(file.path) < 0) {
        pathArr.push(file.path);

        if (file.caculateContents) {
          cont = file.caculateContents
        } else {
          return;
        }

        contents.push(cont);

        size += cont.length;
      }

      if (file.children) {
        // 遍历依赖文件并且合并
        file.children.forEach(function(fc) {
          combine(denps[fc] || {path: fc});
        });
      }
    }
312040
def _read_file_header(self):
        """"""
        header = self.fileobj.readline()
        payload1 = self.fileobj.readline()
        payload2 = self.fileobj.readline()
        version, reserved, organisation = payload1.split(None, 2)
        self.fileobj.readline() # Lose the separator newline
        self.header_read = True
        # print "--------------------------------------------------"
        # print header,"\n", payload1, "\n", payload2,"\n"
        # print "--------------------------------------------------"
        if self.version and int(self.version) != version:
            raise IOError("Version mismatch. Requested version was '%s' but version in file was '%s'"%(self.version, version))
        
        if version == '1':
            url, ip_address, date, content_type, length = header.split()
            self.file_headers = {"ip_address" : ip_address,
                                 "date" : datetime.datetime.strptime(date, "%Y%m%d%H%M%S"),
                                 "org" : organisation}
            self.version = 1
        elif version == '2':
            url, ip_address, date, content_type, result_code, checksum, location, offset, filename, length  = header.split()
            self.file_headers = {"ip_address" : ip_address,
                                 "date" : datetime.datetime.strptime(date, "%Y%m%d%H%M%S"),
                                 "org" : organisation}
            self.version = 2
        else:
            raise IOError("Unknown ARC version '%s'"%version)
15216
def md2rst(md_lines):
    ''
    lvl2header_char = {1: '=', 2: '-', 3: '~'}
    for md_line in md_lines:
        if md_line.startswith('#'):
            header_indent, header_text = md_line.split(' ', 1)
            yield header_text
            header_char = lvl2header_char[len(header_indent)]
            yield header_char * len(header_text)
        else:
            yield md_line
1258079
function processFile(file, encoding) {
    var fileContent = file.contents.toString(encoding),
        matches = fileContent.match(reg$$Global),
        expression,
        tempRegResults,
        name,
        value,
        replaceStr;

    if(null === matches) {
        return file;
    }
    for(var i = 0, len = matches.length; i < len; i ++) {
        expression = matches[i];
        tempRegResults = expression.match(reg$$);
        name = tempRegResults[1];
        value = tempRegResults[2];

        replaceStr = (resolvers[name] || loop)(file, valueProcess(name, value));
        //替换表达式的值为应该替换的那一部分
        fileContent = fileContent.replace(expression, replaceStr.replace("$", "$$$$"));
    }

    file.contents = new Buffer(fileContent);
    return file;
}
511477
def header(*msg, level='h1', separator=" ", print_out=print):
    ''' 
    '''
    out_string = separator.join(str(x) for x in msg)
    if level == 'h0':
        # box_len = 80 if len(msg) < 80 else len(msg)
        box_len = 80
        print_out('+' + '-' * (box_len + 2))
        print_out("| %s" % out_string)
        print_out('+' + '-' * (box_len + 2))
    elif level == 'h1':
        print_out("")
        print_out(out_string)
        print_out('-' * 60)
    elif level == 'h2':
        print_out('\t%s' % out_string)
        print_out('\t' + ('-' * 40))
    else:
        print_out('\t\t%s' % out_string)
        print_out('\t\t' + ('-' * 20))
903719
def fix_header(filepath):
    
    with open(filepath, "r+") as f:
        current = f.read()
        fixed = "\n".join(line.strip() for line in current.split("\n"))
        if current == fixed:
            return
        f.seek(0)
        f.truncate()
        f.write(fixed)
324533
private static void extractText(Path file, BufferedWriter writer, String separator, boolean includePhrase){
        try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file.toFile()),"utf-8"));){
            String line;
            while( (line = reader.readLine()) != null ){
                //去除首尾空白字符
                line = line.trim();
                //忽略空行
                if(!"".equals(line)){
                    //词和词之间以空格隔开
                    String[] words = line.split("\\s+");
                    if(words == null){
                        //忽略不符合规范的行
                        continue;
                    }
                    StringBuilder phrase = new StringBuilder();
                    int phraseCount=0;
                    boolean find=false;
                    for(String word : words){
                        String[] attr = word.split("/");
                        if(attr == null || attr.length < 1){
                            //忽略不符合规范的词
                            continue;
                        }
                        if(attr[0].trim().startsWith("[")){
                            find = true;
                        }                        
                        //去掉[和]
                        String item = attr[0].replace("[", "").replace("]", "").trim();
                        writer.write(item+separator);
                        if(find){
                            phrase.append(item);
                            phraseCount++;
                        }
                        //短语标注错误
                        if(phraseCount > 10){
                            find = false;
                            phraseCount = 0;
                            phrase.setLength(0);
                        }
                        if(find && attr.length > 1 && attr[1].trim().endsWith("]")){
                            find = false;
                            if(includePhrase){
                                writer.write(phrase.toString()+separator);
                            }
                            phrase.setLength(0);
                        }
                        //词数目
                        WORD_COUNT.incrementAndGet();
                        //字符数目
                        CHAR_COUNT.addAndGet(item.length());
                    }
                    //换行
                    writer.write("\n");
                }
            }
        }catch(Exception e){
            LOGGER.info("从语料库 "+file+" 中抽取文本失败：", e);
        }        
    }
545742
def read_header(filename):
    '''  '''
    header = {}
    in_header = False
    data = nl.universal_read(filename)
    lines = [x.strip() for x in data.split('\n')]
    for line in lines:
        if line=="*** Header Start ***":
            in_header=True
            continue
        if line=="*** Header End ***":
            return header
        fields = line.split(": ")
        if len(fields)==2:
            header[fields[0]] = fields[1]
452628
def read_header(cls, headers_path, block_height, allow_none=False):
        
        if os.path.exists(headers_path):
    
            header_parser = BlockHeaderSerializer()
            sb = os.stat( headers_path )
            if sb.st_size < BLOCK_HEADER_SIZE * block_height:
                # beyond EOF 
                if allow_none:
                    return None 
                else:
                    raise Exception('EOF on block headers')

            with open( headers_path, "rb" ) as f:
                f.seek( block_height * BLOCK_HEADER_SIZE, os.SEEK_SET )
                hdr = SPVClient.read_header_at( f )

            return hdr
        else:
            if allow_none:
                return None
            else:
                raise Exception('No such file or directory: {}'.format(headers_path))
704750
def header(fname, sep="\t"):
    
    fh = iter(nopen(fname))
    h = tokens(next(fh), sep)
    h[0] = h[0].lstrip("#")
    return h
58933
def print_header_content(nlh):
    
    answer = 'type={0} length={1} flags=<{2}> sequence-nr={3} pid={4}'.format(
        nl_nlmsgtype2str(nlh.nlmsg_type, bytearray(), 32).decode('ascii'),
        nlh.nlmsg_len,
        nl_nlmsg_flags2str(nlh.nlmsg_flags, bytearray(), 128).decode('ascii'),
        nlh.nlmsg_seq,
        nlh.nlmsg_pid,
    )
    return answer
1125687
function copyExamp(path,pathLength){
	fs.readdir(path,function(err, files){
		if(err){
			console.log('examples read dir err:' + path);
		}else{
			// 遍历目录下所有子项
			files.forEach(function(item){
				var tmpPath = path + '/' + item;
				fs.stat(tmpPath,function(err, stat){
					if(stat.isFile()){
						// 判断文件类型,如果是.html则转化
						var htmlIndex = item.indexOf('.html');
						var jsIndex = item.indexOf('.js');
						var cssIndex = item.indexOf('.css');
						if(htmlIndex < 0 && (jsIndex > -1 || cssIndex > -1)){
							// 创建读取流
		                    readable = fs.createReadStream( tmpPath );
		                    // 创建写入流
		                    writable = fs.createWriteStream( 'examples/' + tmpPath.substring(pathLength) );
		                    // 通过管道来传输流
		                    readable.pipe(writable);
						}
						if(htmlIndex > -1){
							fs.readFile(tmpPath,function(err,data){
								var htmlStr = '';
								if(err){
									console.log('read html err:' + tmpPath)
								}else{
									htmlStr = data.toString();
								}
								var ctx = 'http://design.yonyoucloud.com/static/'
								var tpl = [
							        '<!DOCTYPE html>',
							        '<html lang="en">',
							        '<head>',
							        '<meta charset="UTF-8">',
							        '<meta name="viewport" content="width=device-width, initial-scale=1">',
							       	'<title>Title</title>',
									'<link rel="stylesheet" href="'+ ctx +'/font-awesome/css/font-awesome.css">',
							       	'<link rel="stylesheet" type="text/css" href="'+ ctx +'/uui/latest/css/u.css">',
							       	'<link rel="stylesheet" type="text/css" href="'+ ctx +'/uui/latest/css/u-extend.css">',
								    '<link rel="stylesheet" type="text/css" href="'+ ctx +'/uui/latest/css/tree.css">',
							        '<link rel="stylesheet" type="text/css" href="'+ ctx +'/uui/latest/css/grid.css">',
							        '<link rel="stylesheet" type="text/css" href="widget.css">',
							        '</head>',
							        '<body>',
							        htmlStr,
							        '<script src="'+ ctx +'/jquery/jquery-1.11.2.js"></script>',
							    	'<script src="'+ ctx +'/knockout/knockout-3.2.0.debug.js"></script>',
							        '<script src="'+ ctx +'/uui/latest/js/u-polyfill.js"></script>',
							        '<script src="'+ ctx +'/uui/latest/js/u.js"></script>',
							        '<script src="'+ ctx +'/uui/latest/js/u-tree.js"></script>',
							        '<script src="'+ ctx +'/uui/latest/js/u-grid.js"></script>',
									'<script src="'+ ctx +'/requirejs/require.debug.js"></script>',
									'<script src="widget.js"></script>',
							        '</body>',
							        '</html>'
						        ]
					        	var tplStr = tpl.join('\r\n');
					        	fs.writeFile('examples/' + tmpPath.substring(pathLength),tplStr,function(err){
						        	if(err){
						        		console.log('write err:' + 'examples/' + item + '.html');
						        	}
						        })
					        })
						}
					}
					// 子项为目录创建目录
					if(stat.isDirectory()){
						var dirPath = 'examples/' + tmpPath.substring(pathLength);
						fs.exists(dirPath, function(exist) {
							if(!exist){
								fs.mkdirSync(dirPath);
							}
						});
						copyExamp(tmpPath,pathLength);
					}
				})
			})
		}
	})
}
1018216
def write_header(self):
        

        self.output.seek(0)
        self.output.write(struct.pack('!HHHHHH', self.id, self.flags,
                                      self.counts[0], self.counts[1],
                                      self.counts[2], self.counts[3]))
        self.output.seek(0, 2)
605732
function setZip(context, config, _stream, pathname) {
  const ext = path.extname(pathname).toLowerCase()
  if (ZIPFILE.indexOf(ext) === -1) {
    return _stream
  }
  const acceptEncoding = context.acceptEncoding
  // 如果acceptEncoding不为数组，就返回值
  if (!Array.isArray(acceptEncoding)) {
    return _stream
  }
  let zip = config.zip
  // 获取客户端支持的encoding
  let encoding = getEncoding(zip, acceptEncoding)
  // 设置压缩格式，并返回压缩后的响应正文
  switch (encoding) {
    case 'gzip':
      context.set({
        'Content-Encoding': 'gzip',
        'Transfer-Encoding': 'chunked'
      })
      return _stream.pipe(zlib.createGzip())
      break
    case 'deflate':
      context.set({
        'Content-Encoding': 'deflate',
        'Transfer-Encoding': 'chunked'
      })
      return _stream.pipe(zlib.createDeflate())
      break
    default:
      return _stream
      break
  }
  /**
   * 获取客户端和服务器支持的压缩格式
   * 并选择一种压缩格式
   * @param  {Mixed} _zip             config zip配置
   * @param  {Array} _acceptEncoding  客户端支持的压缩格式
   * @return {String}
   */
  function getEncoding(_zip, _acceptEncoding) {
    if (!_zip) {
      return false
    }
    if (_zip == true) {
      _zip = ENCODING
    }
    if ('string' === typeof _zip) {
      _zip = [_zip]
    }
    if (!Array.isArray(_zip)) {
      return false
    }
    for (let i = 0, length = _acceptEncoding.length; i < length; i++) {
      for (let j = 0; j < _zip.length; j++) {
        if (_zip[j] === _acceptEncoding[i]) {
          return _acceptEncoding[i].toLocaleLowerCase()
        }
      }
    }
  }
}
823053
def _discarded_reads2_out_file_name(self):
        """"""
        if self.Parameters['-4'].isOn():
            discarded_reads2 = self._absolute(str(self.Parameters['-4'].Value))
        else:
            raise ValueError(
                "No discarded-reads2 (flag -4) output path specified")
        return discarded_reads2