diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index ab24d56..7e60f10 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -7,13 +7,15 @@ instructions below may not work properly on Windows.
* [Install Go](https://golang.org/).
* Install Godep: `go get github.com/tools/godep`.
-* Clone this repo (do **not** use `go get`).
-* [Ensure your $GOPATH is set correctly](http://golang.org/cmd/go/#hdr-GOPATH_environment_variable). Working in a clean environment without any other packages on $GOPATH is highly encouraged to avoid conflicts with the dependencies of the tool. Using a [gvm tool](https://github.com/moovweb/gvm) is a good choice for setting up a clean environment. Also, gvm is a convenient tool for installing cross-compilation prerequisites.
-* Install dependencies with Godep: enter the repo's root and `godep restore`.
* Install go vet: `go get code.google.com/p/go.tools/cmd/vet`.
+* Fork the clc-go-cli repo
+* Setup your forked repo according to this [guide](https://splice.com/blog/contributing-open-source-git-repositories-go/)
+* [Ensure your $GOPATH is set correctly](http://golang.org/cmd/go/#hdr-GOPATH_environment_variable). Working in a clean environment without any other packages on $GOPATH is highly encouraged to avoid conflicts with the dependencies of the tool. Using a [gvm tool](https://github.com/moovweb/gvm) is a good choice for setting up a clean environment. Also, gvm is a convenient tool for installing cross-compilation prerequisites.
### Developing
+* Create a new branch for your change
+
* The TDD approach is recommended - write a failing test first, then fix it.
* Use a `dev` script to run commands as you change the code:
@@ -26,6 +28,8 @@ instructions below may not work properly on Windows.
* Before making a pull request check that `gofmt -d=true ./..` and `go vet ./...` do not produce any output (except for that coming from `Godeps/_workspace` - ignore it).
+* Push your branch to your fork and then make a pull request from your branch to master on https://github.com/CenturyLinkCloud/clc-go-cli
+
* Do not commit until the unit tests have passed (`./run_tests`).
* If you want to make an executable, simply run `./scripts/build`. The binary will appear in the `./out` folder.
@@ -34,8 +38,6 @@ instructions below may not work properly on Windows.
* The API file can be regenerated by running `./scripts/generate_api`.
-* Pull requests should be made against the development branch.
-
### Building the releases
Generally, any Linux/Darwin machine should work for building the releases. A Darwin machine is required though if you want to build a `MacOS .pkg`.
diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json
index 1b9d9ed..4f6d499 100644
--- a/Godeps/Godeps.json
+++ b/Godeps/Godeps.json
@@ -1,15 +1,15 @@
{
"ImportPath": "github.com/centurylinkcloud/clc-go-cli",
- "GoVersion": "go1.4.2",
- "GodepVersion": "v60",
+ "GoVersion": "go1.7",
+ "GodepVersion": "v75",
"Packages": [
"./..."
],
"Deps": [
{
"ImportPath": "github.com/asaskevich/govalidator",
- "Comment": "v3",
- "Rev": "5208815a79dd0135690e0d716d4663c2fbd41ac4"
+ "Comment": "v5",
+ "Rev": "7b3beb6df3c42abd3509abfc3bcacc0fbfb7c877"
},
{
"ImportPath": "github.com/ldmberman/tablewriter",
@@ -17,11 +17,15 @@
},
{
"ImportPath": "golang.org/x/net/html",
- "Rev": "db8e4de5b2d6653f66aea53094624468caad15d2"
+ "Rev": "8566e9372a500d1344adb9fdfd943c4354ef4aa2"
+ },
+ {
+ "ImportPath": "golang.org/x/net/html/atom",
+ "Rev": "8566e9372a500d1344adb9fdfd943c4354ef4aa2"
},
{
"ImportPath": "gopkg.in/yaml.v2",
- "Rev": "7ad95dd0798a40da1ccdff6dff35fd177b5edf40"
+ "Rev": "a5b47d31c556af34a302ce5d659e6fea44d90de0"
}
]
}
diff --git a/Godeps/_workspace/.gitignore b/Godeps/_workspace/.gitignore
deleted file mode 100644
index f037d68..0000000
--- a/Godeps/_workspace/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/pkg
-/bin
diff --git a/Godeps/_workspace/src/github.com/asaskevich/govalidator/error.go b/Godeps/_workspace/src/github.com/asaskevich/govalidator/error.go
deleted file mode 100644
index bdd5dc7..0000000
--- a/Godeps/_workspace/src/github.com/asaskevich/govalidator/error.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package govalidator
-
-type Errors []error
-
-func (es Errors) Errors() []error {
- return es
-}
-
-func (es Errors) Error() string {
- var err string
- for _, e := range es {
- err += e.Error() + ";"
- }
- return err
-}
-
-type Error struct {
- Name string
- Err error
-}
-
-func (e Error) Error() string {
- return e.Name + ": " + e.Err.Error()
-}
diff --git a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/.travis.yml b/Godeps/_workspace/src/github.com/ldmberman/tablewriter/.travis.yml
deleted file mode 100644
index 354b7f8..0000000
--- a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/.travis.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-language: go
-
-go:
- - 1.1
- - 1.2
- - 1.3
- - 1.4
- - tip
diff --git a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/LICENCE.md b/Godeps/_workspace/src/github.com/ldmberman/tablewriter/LICENCE.md
deleted file mode 100644
index 1fd8484..0000000
--- a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/LICENCE.md
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (C) 2014 by Oleku Konko
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
\ No newline at end of file
diff --git a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/README.md b/Godeps/_workspace/src/github.com/ldmberman/tablewriter/README.md
deleted file mode 100644
index 4ee4435..0000000
--- a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/README.md
+++ /dev/null
@@ -1,141 +0,0 @@
-ASCII Table Writer
-=========
-
-[![Build Status](https://travis-ci.org/olekukonko/tablewriter.png?branch=master)](https://travis-ci.org/olekukonko/tablewriter) [![Total views](https://sourcegraph.com/api/repos/github.com/olekukonko/tablewriter/counters/views.png)](https://sourcegraph.com/github.com/olekukonko/tablewriter)
-
-Generate ASCII table on the fly ... Installation is simple as
-
- go get github.com/olekukonko/tablewriter
-
-
-#### Features
-- Automatic Padding
-- Support Multiple Lines
-- Supports Alignment
-- Support Custom Separators
-- Automatic Alignment of numbers & percentage
-- Write directly to http , file etc via `io.Writer`
-- Read directly from CSV file
-- Optional row line via `SetRowLine`
-- Normalise table header
-- Make CSV Headers optional
-- Enable or disable table border
-- Set custom footer support
-
-
-#### Example 1 - Basic
-```go
-data := [][]string{
- []string{"A", "The Good", "500"},
- []string{"B", "The Very very Bad Man", "288"},
- []string{"C", "The Ugly", "120"},
- []string{"D", "The Gopher", "800"},
-}
-
-table := tablewriter.NewWriter(os.Stdout)
-table.SetHeader([]string{"Name", "Sign", "Rating"})
-
-for _, v := range data {
- table.Append(v)
-}
-table.Render() // Send output
-```
-
-##### Output 1
-```
-+------+-----------------------+--------+
-| NAME | SIGN | RATING |
-+------+-----------------------+--------+
-| A | The Good | 500 |
-| B | The Very very Bad Man | 288 |
-| C | The Ugly | 120 |
-| D | The Gopher | 800 |
-+------+-----------------------+--------+
-```
-
-#### Example 2 - Without Border / Footer / Bulk Append
-```go
-data := [][]string{
- []string{"1/1/2014", "Domain name", "2233", "$10.98"},
- []string{"1/1/2014", "January Hosting", "2233", "$54.95"},
- []string{"1/4/2014", "February Hosting", "2233", "$51.00"},
- []string{"1/4/2014", "February Extra Bandwidth", "2233", "$30.00"},
-}
-
-table := tablewriter.NewWriter(os.Stdout)
-table.SetHeader([]string{"Date", "Description", "CV2", "Amount"})
-table.SetFooter([]string{"", "", "Total", "$146.93"}) // Add Footer
-table.SetBorder(false) // Set Border to false
-table.AppendBulk(data) // Add Bulk Data
-table.Render()
-```
-
-##### Output 2
-```
-
- DATE | DESCRIPTION | CV2 | AMOUNT
-+----------+--------------------------+-------+---------+
- 1/1/2014 | Domain name | 2233 | $10.98
- 1/1/2014 | January Hosting | 2233 | $54.95
- 1/4/2014 | February Hosting | 2233 | $51.00
- 1/4/2014 | February Extra Bandwidth | 2233 | $30.00
-+----------+--------------------------+-------+---------+
- TOTAL | $146 93
- +-------+---------+
-
-```
-
-
-#### Example 3 - CSV
-```go
-table, _ := tablewriter.NewCSV(os.Stdout, "test_info.csv", true)
-table.SetAlignment(tablewriter.ALIGN_LEFT) // Set Alignment
-table.Render()
-```
-
-##### Output 3
-```
-+----------+--------------+------+-----+---------+----------------+
-| FIELD | TYPE | NULL | KEY | DEFAULT | EXTRA |
-+----------+--------------+------+-----+---------+----------------+
-| user_id | smallint(5) | NO | PRI | NULL | auto_increment |
-| username | varchar(10) | NO | | NULL | |
-| password | varchar(100) | NO | | NULL | |
-+----------+--------------+------+-----+---------+----------------+
-```
-
-#### Example 4 - Custom Separator
-```go
-table, _ := tablewriter.NewCSV(os.Stdout, "test.csv", true)
-table.SetRowLine(true) // Enable row line
-
-// Change table lines
-table.SetCenterSeparator("*")
-table.SetColumnSeparator("‡")
-table.SetRowSeparator("-")
-
-table.SetAlignment(tablewriter.ALIGN_LEFT)
-table.Render()
-```
-
-##### Output 4
-```
-*------------*-----------*---------*
-╪ FIRST NAME ╪ LAST NAME ╪ SSN ╪
-*------------*-----------*---------*
-╪ John ╪ Barry ╪ 123456 ╪
-*------------*-----------*---------*
-╪ Kathy ╪ Smith ╪ 687987 ╪
-*------------*-----------*---------*
-╪ Bob ╪ McCornick ╪ 3979870 ╪
-*------------*-----------*---------*
-```
-
-#### TODO
-- ~~Import Directly from CSV~~ - `done`
-- ~~Support for `SetFooter`~~ - `done`
-- ~~Support for `SetBorder`~~ - `done`
-- ~~Support table with uneven rows~~ - `done`
-- Support custom alignment
-- General Improvement & Optimisation
-- `NewHTML` Parse table from HTML
diff --git a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/csv.go b/Godeps/_workspace/src/github.com/ldmberman/tablewriter/csv.go
deleted file mode 100644
index 9887830..0000000
--- a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/csv.go
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2014 Oleku Konko All rights reserved.
-// Use of this source code is governed by a MIT
-// license that can be found in the LICENSE file.
-
-// This module is a Table Writer API for the Go Programming Language.
-// The protocols were written in pure Go and works on windows and unix systems
-
-package tablewriter
-
-import (
- "encoding/csv"
- "io"
- "os"
-)
-
-// Start A new table by importing from a CSV file
-// Takes io.Writer and csv File name
-func NewCSV(writer io.Writer, fileName string, hasHeader bool) (*Table, error) {
- file, err := os.Open(fileName)
- if err != nil {
- return &Table{}, err
- }
- defer file.Close()
- csvReader := csv.NewReader(file)
- t, err := NewCSVReader(writer, csvReader, hasHeader)
- return t, err
-}
-
-// Start a New Table Writer with csv.Reader
-// This enables customisation such as reader.Comma = ';'
-// See http://golang.org/src/pkg/encoding/csv/reader.go?s=3213:3671#L94
-func NewCSVReader(writer io.Writer, csvReader *csv.Reader, hasHeader bool) (*Table, error) {
- t := NewWriter(writer)
- if hasHeader {
- // Read the first row
- headers, err := csvReader.Read()
- if err != nil {
- return &Table{}, err
- }
- t.SetHeader(headers)
- }
- for {
- record, err := csvReader.Read()
- if err == io.EOF {
- break
- } else if err != nil {
- return &Table{}, err
- }
- t.Append(record)
- }
- return t, nil
-}
diff --git a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/csv2table/README.md b/Godeps/_workspace/src/github.com/ldmberman/tablewriter/csv2table/README.md
deleted file mode 100644
index 6cf5628..0000000
--- a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/csv2table/README.md
+++ /dev/null
@@ -1,43 +0,0 @@
-ASCII Table Writer Tool
-=========
-
-Generate ASCII table on the fly via command line ... Installation is simple as
-
-#### Get Tool
-
- go get github.com/olekukonko/tablewriter/csv2table
-
-#### Install Tool
-
- go install github.com/olekukonko/tablewriter/csv2table
-
-
-#### Usage
-
- csv2table -f test.csv
-
-#### Support for Piping
-
- cat test.csv | csv2table -p=true
-
-#### Output
-
-```
-+------------+-----------+---------+
-| FIRST NAME | LAST NAME | SSN |
-+------------+-----------+---------+
-| John | Barry | 123456 |
-| Kathy | Smith | 687987 |
-| Bob | McCornick | 3979870 |
-+------------+-----------+---------+
-```
-
-#### Another Piping with Header set to `false`
-
- echo dance,with,me | csv2table -p=true -h=false
-
-#### Output
-
- +-------+------+-----+
- | dance | with | me |
- +-------+------+-----+
diff --git a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/csv2table/csv2table.go b/Godeps/_workspace/src/github.com/ldmberman/tablewriter/csv2table/csv2table.go
deleted file mode 100644
index 411f653..0000000
--- a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/csv2table/csv2table.go
+++ /dev/null
@@ -1,84 +0,0 @@
-package main
-
-import (
- "encoding/csv"
- "flag"
- "fmt"
- "github.com/olekukonko/tablewriter"
- "io"
- "os"
- "unicode/utf8"
-)
-
-var (
- fileName = flag.String("f", "", "Set file with eg. sample.csv")
- delimiter = flag.String("d", ",", "Set CSV File delimiter eg. ,|;|\t ")
- header = flag.Bool("h", true, "Set header options eg. true|false ")
- align = flag.String("a", "none", "Set aligmement with eg. none|left|right|centre")
- pipe = flag.Bool("p", false, "Suport for Piping from STDIN")
- border = flag.Bool("b", true, "Enable / disable table border")
-)
-
-func main() {
- flag.Parse()
- fmt.Println()
- if *pipe || hasArg("-p") {
- process(os.Stdin)
- } else {
- if *fileName == "" {
- fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
- flag.PrintDefaults()
- fmt.Println()
- os.Exit(1)
- }
- processFile()
- }
- fmt.Println()
-}
-
-func hasArg(name string) bool {
- for _ , v := range os.Args {
- if name == v {
- return true
- }
- }
- return false
-}
-func processFile() {
- r, err := os.Open(*fileName)
- if err != nil {
- exit(err)
- }
- defer r.Close()
- process(r)
-}
-func process(r io.Reader) {
- csvReader := csv.NewReader(r)
- rune, size := utf8.DecodeRuneInString(*delimiter)
- if size == 0 {
- rune = ','
- }
- csvReader.Comma = rune
-
- table, err := tablewriter.NewCSVReader(os.Stdout, csvReader, *header)
-
- if err != nil {
- exit(err)
- }
-
- switch *align {
- case "left":
- table.SetAlignment(tablewriter.ALIGN_LEFT)
- case "right":
- table.SetAlignment(tablewriter.ALIGN_RIGHT)
- case "center":
- table.SetAlignment(tablewriter.ALIGN_CENTRE)
- }
- table.SetBorder(*border)
- table.Render()
-}
-
-func exit(err error) {
- fmt.Fprintf(os.Stderr, "#Error : %s", err)
- os.Exit(1)
-}
diff --git a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/table.go b/Godeps/_workspace/src/github.com/ldmberman/tablewriter/table.go
deleted file mode 100644
index 4835e31..0000000
--- a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/table.go
+++ /dev/null
@@ -1,472 +0,0 @@
-// Copyright 2014 Oleku Konko All rights reserved.
-// Use of this source code is governed by a MIT
-// license that can be found in the LICENSE file.
-
-// This module is a Table Writer API for the Go Programming Language.
-// The protocols were written in pure Go and works on windows and unix systems
-
-// Create & Generate text based table
-package tablewriter
-
-import (
- "fmt"
- "io"
- "regexp"
- "strings"
-)
-
-const (
- MAX_ROW_WIDTH = 30
-)
-
-const (
- CENTRE = "+"
- ROW = "-"
- COLUMN = "|"
- SPACE = " "
-)
-
-const (
- ALIGN_DEFAULT = iota
- ALIGN_CENTRE
- ALIGN_RIGHT
- ALIGN_LEFT
-)
-
-var (
- decimal = regexp.MustCompile(`^[0-9]+(.[0-9]+?)$`)
- percent = regexp.MustCompile(`^[0-9]+(.[0-9]+?)%$`)
-)
-
-type Table struct {
- out io.Writer
- rows [][]string
- lines [][][]string
- cs map[int]int
- rs map[int]int
- headers []string
- footers []string
- autoFmt bool
- autoWrap bool
- mW int
- pCenter string
- pRow string
- pColumn string
- tColumn int
- tRow int
- align int
- rowLine bool
- border bool
- colSize int
-}
-
-// Start New Table
-// Take io.Writer Directly
-func NewWriter(writer io.Writer) *Table {
- t := &Table{
- out: writer,
- rows: [][]string{},
- lines: [][][]string{},
- cs: make(map[int]int),
- rs: make(map[int]int),
- headers: []string{},
- footers: []string{},
- autoFmt: true,
- autoWrap: true,
- mW: MAX_ROW_WIDTH,
- pCenter: CENTRE,
- pRow: ROW,
- pColumn: COLUMN,
- tColumn: -1,
- tRow: -1,
- align: ALIGN_DEFAULT,
- rowLine: false,
- border: true,
- colSize: -1}
- return t
-}
-
-// Render table output
-func (t Table) Render() {
- if t.border {
- t.printLine(true)
- }
- t.printHeading()
- t.printRows()
-
- if !t.rowLine && t.border {
- t.printLine(true)
- }
- t.printFooter()
-
-}
-
-// Set table header
-func (t *Table) SetHeader(keys []string) {
- t.colSize = len(keys)
- for i, v := range keys {
- t.parseDimension(v, i, -1)
- t.headers = append(t.headers, v)
- }
-}
-
-// Set table Footer
-func (t *Table) SetFooter(keys []string) {
- //t.colSize = len(keys)
- for i, v := range keys {
- t.parseDimension(v, i, -1)
- t.footers = append(t.footers, v)
- }
-}
-
-// Turn header autoformatting on/off. Default is on (true).
-func (t *Table) SetAutoFormatHeaders(auto bool) {
- t.autoFmt = auto
-}
-
-// Turn automatic multiline text adjustment on/off. Default is on (true).
-func (t *Table) SetAutoWrapText(auto bool) {
- t.autoWrap = auto
-}
-
-// Set the Default column width
-func (t *Table) SetColWidth(width int) {
- t.mW = width
-}
-
-// Set the Column Separator
-func (t *Table) SetColumnSeparator(sep string) {
- t.pColumn = sep
-}
-
-// Set the Row Separator
-func (t *Table) SetRowSeparator(sep string) {
- t.pRow = sep
-}
-
-// Set the center Separator
-func (t *Table) SetCenterSeparator(sep string) {
- t.pCenter = sep
-}
-
-// Set Table Alignment
-func (t *Table) SetAlignment(align int) {
- t.align = align
-}
-
-// Set Row Line
-// This would enable / disable a line on each row of the table
-func (t *Table) SetRowLine(line bool) {
- t.rowLine = line
-}
-
-// Set Table Border
-// This would enable / disable line around the table
-func (t *Table) SetBorder(border bool) {
- t.border = border
-}
-
-// Append row to table
-func (t *Table) Append(row []string) error {
- rowSize := len(t.headers)
- if rowSize > t.colSize {
- t.colSize = rowSize
- }
-
- n := len(t.lines)
- line := [][]string{}
- for i, v := range row {
-
- // Detect string width
- // Detect String height
- // Break strings into words
- out := t.parseDimension(v, i, n)
-
- // Append broken words
- line = append(line, out)
- }
- t.lines = append(t.lines, line)
- return nil
-}
-
-// Allow Support for Bulk Append
-// Eliminates repeated for loops
-func (t *Table) AppendBulk(rows [][]string) (err error) {
- for _, row := range rows {
- err = t.Append(row)
- if err != nil {
- return err
- }
- }
- return nil
-}
-
-// Print line based on row width
-func (t Table) printLine(nl bool) {
- fmt.Fprint(t.out, t.pCenter)
- for i := 0; i < len(t.cs); i++ {
- v := t.cs[i]
- fmt.Fprintf(t.out, "%s%s%s%s",
- t.pRow,
- strings.Repeat(string(t.pRow), v),
- t.pRow,
- t.pCenter)
- }
- if nl {
- fmt.Fprintln(t.out)
- }
-}
-
-// Print heading information
-func (t Table) printHeading() {
- // Check if headers is available
- if len(t.headers) < 1 {
- return
- }
-
- // Check if border is set
- // Replace with space if not set
- fmt.Fprint(t.out, ConditionString(t.border, t.pColumn, SPACE))
-
- // Identify last column
- end := len(t.cs) - 1
-
- // Print Heading column
- for i := 0; i <= end; i++ {
- v := t.cs[i]
- h := t.headers[i]
- if t.autoFmt {
- h = Title(h)
- }
- pad := ConditionString((i == end && !t.border), SPACE, t.pColumn)
- fmt.Fprintf(t.out, " %s %s",
- Pad(h, SPACE, v),
- pad)
- }
- // Next line
- fmt.Fprintln(t.out)
- t.printLine(true)
-}
-
-// Print heading information
-func (t Table) printFooter() {
- // Check if headers is available
- if len(t.footers) < 1 {
- return
- }
-
- // Only print line if border is not set
- if !t.border {
- t.printLine(true)
- }
- // Check if border is set
- // Replace with space if not set
- fmt.Fprint(t.out, ConditionString(t.border, t.pColumn, SPACE))
-
- // Identify last column
- end := len(t.cs) - 1
-
- // Print Heading column
- for i := 0; i <= end; i++ {
- v := t.cs[i]
- f := t.footers[i]
- if t.autoFmt {
- f = Title(f)
- }
- pad := ConditionString((i == end && !t.border), SPACE, t.pColumn)
-
- if len(t.footers[i]) == 0 {
- pad = SPACE
- }
- fmt.Fprintf(t.out, " %s %s",
- Pad(f, SPACE, v),
- pad)
- }
- // Next line
- fmt.Fprintln(t.out)
- //t.printLine(true)
-
- hasPrinted := false
-
- for i := 0; i <= end; i++ {
- v := t.cs[i]
- pad := t.pRow
- center := t.pCenter
- length := len(t.footers[i])
-
- if length > 0 {
- hasPrinted = true
- }
-
- // Set center to be space if length is 0
- if length == 0 && !t.border {
- center = SPACE
- }
-
- // Print first junction
- if i == 0 {
- fmt.Fprint(t.out, center)
- }
-
- // Pad With space of length is 0
- if length == 0 {
- pad = SPACE
- }
- // Ignore left space of it has printed before
- if hasPrinted || t.border {
- pad = t.pRow
- center = t.pCenter
- }
-
- // Change Center start position
- if center == SPACE {
- if i < end && len(t.footers[i+1]) != 0 {
- center = t.pCenter
- }
- }
-
- // Print the footer
- fmt.Fprintf(t.out, "%s%s%s%s",
- pad,
- strings.Repeat(string(pad), v),
- pad,
- center)
-
- }
-
- fmt.Fprintln(t.out)
-
-}
-
-func (t Table) printRows() {
- for i, lines := range t.lines {
- t.printRow(lines, i)
- }
-
-}
-
-// Print Row Information
-// Adjust column alignment based on type
-
-func (t Table) printRow(columns [][]string, colKey int) {
- // Get Maximum Height
- max := t.rs[colKey]
- total := len(columns)
-
- // TODO Fix uneven col size
- // if total < t.colSize {
- // for n := t.colSize - total; n < t.colSize ; n++ {
- // columns = append(columns, []string{SPACE})
- // t.cs[n] = t.mW
- // }
- //}
-
- // Pad Each Height
- // pads := []int{}
- pads := []int{}
-
- for i, line := range columns {
- length := len(line)
- pad := max - length
- pads = append(pads, pad)
- for n := 0; n < pad; n++ {
- columns[i] = append(columns[i], " ")
- }
- }
- //fmt.Println(max, "\n")
- for x := 0; x < max; x++ {
- for y := 0; y < total; y++ {
-
- // Check if border is set
- fmt.Fprint(t.out, ConditionString((!t.border && y == 0), SPACE, t.pColumn))
-
- fmt.Fprintf(t.out, SPACE)
- str := columns[y][x]
-
- // This would print alignment
- // Default alignment would use multiple configuration
- switch t.align {
- case ALIGN_CENTRE: //
- fmt.Fprintf(t.out, "%s", Pad(str, SPACE, t.cs[y]))
- case ALIGN_RIGHT:
- fmt.Fprintf(t.out, "%s", PadLeft(str, SPACE, t.cs[y]))
- case ALIGN_LEFT:
- fmt.Fprintf(t.out, "%s", PadRight(str, SPACE, t.cs[y]))
- default:
- if decimal.MatchString(strings.TrimSpace(str)) || percent.MatchString(strings.TrimSpace(str)) {
- fmt.Fprintf(t.out, "%s", PadLeft(str, SPACE, t.cs[y]))
- } else {
- fmt.Fprintf(t.out, "%s", PadRight(str, SPACE, t.cs[y]))
-
- // TODO Custom alignment per column
- //if max == 1 || pads[y] > 0 {
- // fmt.Fprintf(t.out, "%s", Pad(str, SPACE, t.cs[y]))
- //} else {
- // fmt.Fprintf(t.out, "%s", PadRight(str, SPACE, t.cs[y]))
- //}
-
- }
- }
- fmt.Fprintf(t.out, SPACE)
- }
- // Check if border is set
- // Replace with space if not set
- fmt.Fprint(t.out, ConditionString(t.border, t.pColumn, SPACE))
- fmt.Fprintln(t.out)
- }
-
- if t.rowLine {
- t.printLine(true)
- }
-
-}
-
-func (t *Table) parseDimension(str string, colKey, rowKey int) []string {
- var (
- raw []string
- max int
- )
- w := DisplayWidth(str)
- // Calculate Width
- // Check if with is grater than maximum width
- if w > t.mW {
- w = t.mW
- }
-
- // Check if width exists
- v, ok := t.cs[colKey]
- if !ok || v < w || v == 0 {
- t.cs[colKey] = w
- }
-
- if rowKey == -1 {
- return raw
- }
- // Calculate Height
- if t.autoWrap {
- raw, _ = WrapString(str, t.cs[colKey])
- } else {
- raw = getLines(str)
- }
-
- for _, line := range raw {
- if w := DisplayWidth(line); w > max {
- max = w
- }
- }
-
- // Make sure the with is the same length as maximum word
- // Important for cases where the width is smaller than maxu word
- if max > t.cs[colKey] {
- t.cs[colKey] = max
- }
-
- h := len(raw)
- v, ok = t.rs[rowKey]
-
- if !ok || v < h || v == 0 {
- t.rs[rowKey] = h
- }
- //fmt.Printf("Raw %+v %d\n", raw, len(raw))
- return raw
-}
diff --git a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/table_test.go b/Godeps/_workspace/src/github.com/ldmberman/tablewriter/table_test.go
deleted file mode 100644
index dd6c794..0000000
--- a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/table_test.go
+++ /dev/null
@@ -1,276 +0,0 @@
-// Copyright 2014 Oleku Konko All rights reserved.
-// Use of this source code is governed by a MIT
-// license that can be found in the LICENSE file.
-
-// This module is a Table Writer API for the Go Programming Language.
-// The protocols were written in pure Go and works on windows and unix systems
-
-package tablewriter
-
-import (
- "bytes"
- "fmt"
- "io"
- "os"
- "strings"
- "testing"
-)
-
-func ExampleShort() {
-
- data := [][]string{
- []string{"A", "The Good", "500"},
- []string{"B", "The Very very Bad Man", "288"},
- []string{"C", "The Ugly", "120"},
- []string{"D", "The Gopher", "800"},
- }
-
- table := NewWriter(os.Stdout)
- table.SetHeader([]string{"Name", "Sign", "Rating"})
-
- for _, v := range data {
- table.Append(v)
- }
- table.Render()
-
-}
-
-func ExampleLong() {
-
- data := [][]string{
- []string{"Learn East has computers with adapted keyboards with enlarged print etc", " Some Data ", " Another Data"},
- []string{"Instead of lining up the letters all ", "the way across, he splits the keyboard in two", "Like most ergonomic keyboards", "See Data"},
- }
-
- table := NewWriter(os.Stdout)
- table.SetHeader([]string{"Name", "Sign", "Rating"})
- table.SetCenterSeparator("*")
- table.SetRowSeparator("=")
-
- for _, v := range data {
- table.Append(v)
- }
- table.Render()
-
-}
-
-func ExampleCSV() {
- table, _ := NewCSV(os.Stdout, "test.csv", true)
- table.SetCenterSeparator("*")
- table.SetRowSeparator("=")
-
- table.Render()
-}
-
-func TestCSVInfo(t *testing.T) {
- table, err := NewCSV(os.Stdout, "test_info.csv", true)
- if err != nil {
- t.Error(err)
- return
- }
- table.SetAlignment(ALIGN_LEFT)
- table.SetBorder(false)
- table.Render()
-}
-
-func TestCSVSeparator(t *testing.T) {
- table, err := NewCSV(os.Stdout, "test.csv", true)
- if err != nil {
- t.Error(err)
- return
- }
- table.SetRowLine(true)
- table.SetCenterSeparator("*")
- table.SetColumnSeparator("‡")
- table.SetRowSeparator("-")
- table.SetAlignment(ALIGN_LEFT)
- table.Render()
-}
-
-func TestBorder(t *testing.T) {
- data := [][]string{
- []string{"1/1/2014", "Domain name", "2233", "$10.98"},
- []string{"1/1/2014", "January Hosting", "2233", "$54.95"},
- []string{"1/4/2014", "February Hosting", "2233", "$51.00"},
- []string{"1/4/2014", "February Extra Bandwidth", "2233", "$30.00"},
- }
-
- table := NewWriter(os.Stdout)
- table.SetHeader([]string{"Date", "Description", "CV2", "Amount"})
- table.SetFooter([]string{"", "", "Total", "$146.93"}) // Add Footer
- table.SetBorder(false) // Set Border to false
- table.AppendBulk(data) // Add Bulk Data
- table.Render()
-}
-
-func TestPrintHeading(t *testing.T) {
- var buf bytes.Buffer
- table := NewWriter(&buf)
- table.SetHeader([]string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c"})
- table.printHeading()
- want := `| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C |
-+---+---+---+---+---+---+---+---+---+---+---+---+
-`
- got := buf.String()
- if got != want {
- t.Errorf("header rendering failed\ngot:\n%s\nwant:\n%s\n", got, want)
- }
-}
-
-func TestPrintHeadingWithoutAutoFormat(t *testing.T) {
- var buf bytes.Buffer
- table := NewWriter(&buf)
- table.SetHeader([]string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c"})
- table.SetAutoFormatHeaders(false)
- table.printHeading()
- want := `| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c |
-+---+---+---+---+---+---+---+---+---+---+---+---+
-`
- got := buf.String()
- if got != want {
- t.Errorf("header rendering failed\ngot:\n%s\nwant:\n%s\n", got, want)
- }
-}
-
-func TestPrintFooter(t *testing.T) {
- var buf bytes.Buffer
- table := NewWriter(&buf)
- table.SetHeader([]string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c"})
- table.SetFooter([]string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c"})
- table.printFooter()
- want := `| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C |
-+---+---+---+---+---+---+---+---+---+---+---+---+
-`
- got := buf.String()
- if got != want {
- t.Errorf("footer rendering failed\ngot:\n%s\nwant:\n%s\n", got, want)
- }
-}
-
-func TestPrintFooterWithoutAutoFormat(t *testing.T) {
- var buf bytes.Buffer
- table := NewWriter(&buf)
- table.SetAutoFormatHeaders(false)
- table.SetHeader([]string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c"})
- table.SetFooter([]string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c"})
- table.printFooter()
- want := `| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c |
-+---+---+---+---+---+---+---+---+---+---+---+---+
-`
- got := buf.String()
- if got != want {
- t.Errorf("footer rendering failed\ngot:\n%s\nwant:\n%s\n", got, want)
- }
-}
-
-func TestPrintTableWithAndWithoutAutoWrap(t *testing.T) {
- var buf bytes.Buffer
- var multiline = `A multiline
-string with some lines being really long.`
-
- with := NewWriter(&buf)
- with.Append([]string{multiline})
- with.Render()
- want := `+--------------------------------+
-| A multiline string with some |
-| lines being really long. |
-+--------------------------------+
-`
- got := buf.String()
- if got != want {
- t.Errorf("multiline text rendering with wrapping failed\ngot:\n%s\nwant:\n%s\n", got, want)
- }
-
- buf.Truncate(0)
- without := NewWriter(&buf)
- without.SetAutoWrapText(false)
- without.Append([]string{multiline})
- without.Render()
- want = `+-------------------------------------------+
-| A multiline |
-| string with some lines being really long. |
-+-------------------------------------------+
-`
- got = buf.String()
- if got != want {
- t.Errorf("multiline text rendering without wrapping rendering failed\ngot:\n%s\nwant:\n%s\n", got, want)
- }
-}
-
-func TestPrintLine(t *testing.T) {
- header := make([]string, 12)
- val := " "
- want := ""
- for i := range header {
- header[i] = val
- want = fmt.Sprintf("%s+-%s-", want, strings.Replace(val, " ", "-", -1))
- val = val + " "
- }
- want = want + "+"
- var buf bytes.Buffer
- table := NewWriter(&buf)
- table.SetHeader(header)
- table.printLine(false)
- got := buf.String()
- if got != want {
- t.Errorf("line rendering failed\ngot:\n%s\nwant:\n%s\n", got, want)
- }
-}
-
-func TestAnsiStrip(t *testing.T) {
- header := make([]string, 12)
- val := " "
- want := ""
- for i := range header {
- header[i] = "\033[43;30m" + val + "\033[00m"
- want = fmt.Sprintf("%s+-%s-", want, strings.Replace(val, " ", "-", -1))
- val = val + " "
- }
- want = want + "+"
- var buf bytes.Buffer
- table := NewWriter(&buf)
- table.SetHeader(header)
- table.printLine(false)
- got := buf.String()
- if got != want {
- t.Errorf("line rendering failed\ngot:\n%s\nwant:\n%s\n", got, want)
- }
-}
-
-func NewCustomizedTable(out io.Writer) *Table {
- table := NewWriter(out)
- table.SetCenterSeparator("")
- table.SetColumnSeparator("")
- table.SetRowSeparator("")
- table.SetBorder(false)
- table.SetAlignment(ALIGN_LEFT)
- table.SetHeader([]string{})
- return table
-}
-
-func TestSubclass(t *testing.T) {
- buf := new(bytes.Buffer)
- table := NewCustomizedTable(buf)
-
- data := [][]string{
- []string{"A", "The Good", "500"},
- []string{"B", "The Very very Bad Man", "288"},
- []string{"C", "The Ugly", "120"},
- []string{"D", "The Gopher", "800"},
- }
-
- for _, v := range data {
- table.Append(v)
- }
- table.Render()
-
- output := string(buf.Bytes())
- want := ` A The Good 500
- B The Very very Bad Man 288
- C The Ugly 120
- D The Gopher 800
-`
- if output != want {
- t.Error(fmt.Sprintf("Unexpected output '%v' != '%v'", output, want))
- }
-}
diff --git a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/test.csv b/Godeps/_workspace/src/github.com/ldmberman/tablewriter/test.csv
deleted file mode 100644
index 1609327..0000000
--- a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/test.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-first_name,last_name,ssn
-John,Barry,123456
-Kathy,Smith,687987
-Bob,McCornick,3979870
\ No newline at end of file
diff --git a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/test_info.csv b/Godeps/_workspace/src/github.com/ldmberman/tablewriter/test_info.csv
deleted file mode 100644
index e4c40e9..0000000
--- a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/test_info.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-Field,Type,Null,Key,Default,Extra
-user_id,smallint(5),NO,PRI,NULL,auto_increment
-username,varchar(10),NO,,NULL,
-password,varchar(100),NO,,NULL,
\ No newline at end of file
diff --git a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/util.go b/Godeps/_workspace/src/github.com/ldmberman/tablewriter/util.go
deleted file mode 100644
index e006ac6..0000000
--- a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/util.go
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2014 Oleku Konko All rights reserved.
-// Use of this source code is governed by a MIT
-// license that can be found in the LICENSE file.
-
-// This module is a Table Writer API for the Go Programming Language.
-// The protocols were written in pure Go and works on windows and unix systems
-
-package tablewriter
-
-import (
- "math"
- "regexp"
- "strings"
- "unicode/utf8"
-)
-
-var (
- ansi = regexp.MustCompile("\033\\[(?:[0-9]{1,3}(?:;[0-9]{1,3})*)?[m|K]")
-)
-
-func DisplayWidth(str string) int {
- return utf8.RuneCountInString(ansi.ReplaceAllLiteralString(str, ""))
-}
-
-// Simple Condition for string
-// Returns value based on condition
-func ConditionString(cond bool, valid, inValid string) string {
- if cond {
- return valid
- }
- return inValid
-}
-
-// Format Table Header
-// Replace _ , . and spaces
-func Title(name string) string {
- name = strings.Replace(name, "_", " ", -1)
- name = strings.Replace(name, ".", " ", -1)
- name = strings.TrimSpace(name)
- return strings.ToUpper(name)
-}
-
-// Pad String
-// Attempts to play string in the center
-func Pad(s, pad string, width int) string {
- gap := width - DisplayWidth(s)
- if gap > 0 {
- gapLeft := int(math.Ceil(float64(gap / 2)))
- gapRight := gap - gapLeft
- return strings.Repeat(string(pad), gapLeft) + s + strings.Repeat(string(pad), gapRight)
- }
- return s
-}
-
-// Pad String Right position
-// This would pace string at the left side fo the screen
-func PadRight(s, pad string, width int) string {
- gap := width - DisplayWidth(s)
- if gap > 0 {
- return s + strings.Repeat(string(pad), gap)
- }
- return s
-}
-
-// Pad String Left position
-// This would pace string at the right side fo the screen
-func PadLeft(s, pad string, width int) string {
- gap := width - DisplayWidth(s)
- if gap > 0 {
- return strings.Repeat(string(pad), gap) + s
- }
- return s
-}
diff --git a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/wrap.go b/Godeps/_workspace/src/github.com/ldmberman/tablewriter/wrap.go
deleted file mode 100644
index f3747d9..0000000
--- a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/wrap.go
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright 2014 Oleku Konko All rights reserved.
-// Use of this source code is governed by a MIT
-// license that can be found in the LICENSE file.
-
-// This module is a Table Writer API for the Go Programming Language.
-// The protocols were written in pure Go and works on windows and unix systems
-
-package tablewriter
-
-import (
- "math"
- "strings"
- "unicode/utf8"
-)
-
-var (
- nl = "\n"
- sp = " "
-)
-
-const defaultPenalty = 1e5
-
-// Wrap wraps s into a paragraph of lines of length lim, with minimal
-// raggedness.
-func WrapString(s string, lim int) ([]string, int) {
- words := strings.Split(strings.Replace(strings.TrimSpace(s), nl, sp, -1), sp)
- var lines []string
- max := 0
- for _, v := range words {
- max = len(v)
- if max > lim {
- lim = max
- }
- }
- for _, line := range WrapWords(words, 1, lim, defaultPenalty) {
- lines = append(lines, strings.Join(line, sp))
- }
- return lines, lim
-}
-
-// WrapWords is the low-level line-breaking algorithm, useful if you need more
-// control over the details of the text wrapping process. For most uses,
-// WrapString will be sufficient and more convenient.
-//
-// WrapWords splits a list of words into lines with minimal "raggedness",
-// treating each rune as one unit, accounting for spc units between adjacent
-// words on each line, and attempting to limit lines to lim units. Raggedness
-// is the total error over all lines, where error is the square of the
-// difference of the length of the line and lim. Too-long lines (which only
-// happen when a single word is longer than lim units) have pen penalty units
-// added to the error.
-func WrapWords(words []string, spc, lim, pen int) [][]string {
- n := len(words)
-
- length := make([][]int, n)
- for i := 0; i < n; i++ {
- length[i] = make([]int, n)
- length[i][i] = utf8.RuneCountInString(words[i])
- for j := i + 1; j < n; j++ {
- length[i][j] = length[i][j-1] + spc + utf8.RuneCountInString(words[j])
- }
- }
- nbrk := make([]int, n)
- cost := make([]int, n)
- for i := range cost {
- cost[i] = math.MaxInt32
- }
- for i := n - 1; i >= 0; i-- {
- if length[i][n-1] <= lim {
- cost[i] = 0
- nbrk[i] = n
- } else {
- for j := i + 1; j < n; j++ {
- d := lim - length[i][j-1]
- c := d*d + cost[j]
- if length[i][j-1] > lim {
- c += pen // too-long lines get a worse penalty
- }
- if c < cost[i] {
- cost[i] = c
- nbrk[i] = j
- }
- }
- }
- }
- var lines [][]string
- i := 0
- for i < n {
- lines = append(lines, words[i:nbrk[i]])
- i = nbrk[i]
- }
- return lines
-}
-
-// getLines decomposes a multiline string into a slice of strings.
-func getLines(s string) []string {
- var lines []string
-
- for _, line := range strings.Split(strings.TrimSpace(s), nl) {
- lines = append(lines, line)
- }
- return lines
-}
diff --git a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/wrap_test.go b/Godeps/_workspace/src/github.com/ldmberman/tablewriter/wrap_test.go
deleted file mode 100644
index a4e2642..0000000
--- a/Godeps/_workspace/src/github.com/ldmberman/tablewriter/wrap_test.go
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2014 Oleku Konko All rights reserved.
-// Use of this source code is governed by a MIT
-// license that can be found in the LICENSE file.
-
-// This module is a Table Writer API for the Go Programming Language.
-// The protocols were written in pure Go and works on windows and unix systems
-
-package tablewriter
-
-import (
- "strings"
- "testing"
-)
-
-var text = "The quick brown fox jumps over the lazy dog."
-
-func TestWrap(t *testing.T) {
- exp := []string{
- "The", "quick", "brown", "fox",
- "jumps", "over", "the", "lazy", "dog."}
-
- got, _ := WrapString(text, 6)
- if len(exp) != len(got) {
- t.Fail()
- }
-}
-
-func TestWrapOneLine(t *testing.T) {
- exp := "The quick brown fox jumps over the lazy dog."
- words, _ := WrapString(text, 500)
- got := strings.Join(words, string(sp))
- if exp != got {
- t.Fail()
- }
-}
-
-func TestUnicode(t *testing.T) {
- input := "Česká řeřicha"
- wordsUnicode, _ := WrapString(input, 13)
- // input contains 13 runes, so it fits on one line.
- if len(wordsUnicode) != 1 {
- t.Fail()
- }
-}
diff --git a/Godeps/_workspace/src/golang.org/x/net/html/atom/atom_test.go b/Godeps/_workspace/src/golang.org/x/net/html/atom/atom_test.go
deleted file mode 100644
index 6e33704..0000000
--- a/Godeps/_workspace/src/golang.org/x/net/html/atom/atom_test.go
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package atom
-
-import (
- "sort"
- "testing"
-)
-
-func TestKnown(t *testing.T) {
- for _, s := range testAtomList {
- if atom := Lookup([]byte(s)); atom.String() != s {
- t.Errorf("Lookup(%q) = %#x (%q)", s, uint32(atom), atom.String())
- }
- }
-}
-
-func TestHits(t *testing.T) {
- for _, a := range table {
- if a == 0 {
- continue
- }
- got := Lookup([]byte(a.String()))
- if got != a {
- t.Errorf("Lookup(%q) = %#x, want %#x", a.String(), uint32(got), uint32(a))
- }
- }
-}
-
-func TestMisses(t *testing.T) {
- testCases := []string{
- "",
- "\x00",
- "\xff",
- "A",
- "DIV",
- "Div",
- "dIV",
- "aa",
- "a\x00",
- "ab",
- "abb",
- "abbr0",
- "abbr ",
- " abbr",
- " a",
- "acceptcharset",
- "acceptCharset",
- "accept_charset",
- "h0",
- "h1h2",
- "h7",
- "onClick",
- "λ",
- // The following string has the same hash (0xa1d7fab7) as "onmouseover".
- "\x00\x00\x00\x00\x00\x50\x18\xae\x38\xd0\xb7",
- }
- for _, tc := range testCases {
- got := Lookup([]byte(tc))
- if got != 0 {
- t.Errorf("Lookup(%q): got %d, want 0", tc, got)
- }
- }
-}
-
-func TestForeignObject(t *testing.T) {
- const (
- afo = Foreignobject
- afO = ForeignObject
- sfo = "foreignobject"
- sfO = "foreignObject"
- )
- if got := Lookup([]byte(sfo)); got != afo {
- t.Errorf("Lookup(%q): got %#v, want %#v", sfo, got, afo)
- }
- if got := Lookup([]byte(sfO)); got != afO {
- t.Errorf("Lookup(%q): got %#v, want %#v", sfO, got, afO)
- }
- if got := afo.String(); got != sfo {
- t.Errorf("Atom(%#v).String(): got %q, want %q", afo, got, sfo)
- }
- if got := afO.String(); got != sfO {
- t.Errorf("Atom(%#v).String(): got %q, want %q", afO, got, sfO)
- }
-}
-
-func BenchmarkLookup(b *testing.B) {
- sortedTable := make([]string, 0, len(table))
- for _, a := range table {
- if a != 0 {
- sortedTable = append(sortedTable, a.String())
- }
- }
- sort.Strings(sortedTable)
-
- x := make([][]byte, 1000)
- for i := range x {
- x[i] = []byte(sortedTable[i%len(sortedTable)])
- }
-
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- for _, s := range x {
- Lookup(s)
- }
- }
-}
diff --git a/Godeps/_workspace/src/golang.org/x/net/html/atom/table_test.go b/Godeps/_workspace/src/golang.org/x/net/html/atom/table_test.go
deleted file mode 100644
index 0f2ecce..0000000
--- a/Godeps/_workspace/src/golang.org/x/net/html/atom/table_test.go
+++ /dev/null
@@ -1,351 +0,0 @@
-// generated by go run gen.go -test; DO NOT EDIT
-
-package atom
-
-var testAtomList = []string{
- "a",
- "abbr",
- "abbr",
- "accept",
- "accept-charset",
- "accesskey",
- "action",
- "address",
- "align",
- "alt",
- "annotation",
- "annotation-xml",
- "applet",
- "area",
- "article",
- "aside",
- "async",
- "audio",
- "autocomplete",
- "autofocus",
- "autoplay",
- "b",
- "base",
- "basefont",
- "bdi",
- "bdo",
- "bgsound",
- "big",
- "blink",
- "blockquote",
- "body",
- "br",
- "button",
- "canvas",
- "caption",
- "center",
- "challenge",
- "charset",
- "checked",
- "cite",
- "cite",
- "class",
- "code",
- "col",
- "colgroup",
- "color",
- "cols",
- "colspan",
- "command",
- "command",
- "content",
- "contenteditable",
- "contextmenu",
- "controls",
- "coords",
- "crossorigin",
- "data",
- "data",
- "datalist",
- "datetime",
- "dd",
- "default",
- "defer",
- "del",
- "desc",
- "details",
- "dfn",
- "dialog",
- "dir",
- "dirname",
- "disabled",
- "div",
- "dl",
- "download",
- "draggable",
- "dropzone",
- "dt",
- "em",
- "embed",
- "enctype",
- "face",
- "fieldset",
- "figcaption",
- "figure",
- "font",
- "footer",
- "for",
- "foreignObject",
- "foreignobject",
- "form",
- "form",
- "formaction",
- "formenctype",
- "formmethod",
- "formnovalidate",
- "formtarget",
- "frame",
- "frameset",
- "h1",
- "h2",
- "h3",
- "h4",
- "h5",
- "h6",
- "head",
- "header",
- "headers",
- "height",
- "hgroup",
- "hidden",
- "high",
- "hr",
- "href",
- "hreflang",
- "html",
- "http-equiv",
- "i",
- "icon",
- "id",
- "iframe",
- "image",
- "img",
- "input",
- "inputmode",
- "ins",
- "isindex",
- "ismap",
- "itemid",
- "itemprop",
- "itemref",
- "itemscope",
- "itemtype",
- "kbd",
- "keygen",
- "keytype",
- "kind",
- "label",
- "label",
- "lang",
- "legend",
- "li",
- "link",
- "list",
- "listing",
- "loop",
- "low",
- "malignmark",
- "manifest",
- "map",
- "mark",
- "marquee",
- "math",
- "max",
- "maxlength",
- "media",
- "mediagroup",
- "menu",
- "menuitem",
- "meta",
- "meter",
- "method",
- "mglyph",
- "mi",
- "min",
- "minlength",
- "mn",
- "mo",
- "ms",
- "mtext",
- "multiple",
- "muted",
- "name",
- "nav",
- "nobr",
- "noembed",
- "noframes",
- "noscript",
- "novalidate",
- "object",
- "ol",
- "onabort",
- "onafterprint",
- "onautocomplete",
- "onautocompleteerror",
- "onbeforeprint",
- "onbeforeunload",
- "onblur",
- "oncancel",
- "oncanplay",
- "oncanplaythrough",
- "onchange",
- "onclick",
- "onclose",
- "oncontextmenu",
- "oncuechange",
- "ondblclick",
- "ondrag",
- "ondragend",
- "ondragenter",
- "ondragleave",
- "ondragover",
- "ondragstart",
- "ondrop",
- "ondurationchange",
- "onemptied",
- "onended",
- "onerror",
- "onfocus",
- "onhashchange",
- "oninput",
- "oninvalid",
- "onkeydown",
- "onkeypress",
- "onkeyup",
- "onlanguagechange",
- "onload",
- "onloadeddata",
- "onloadedmetadata",
- "onloadstart",
- "onmessage",
- "onmousedown",
- "onmousemove",
- "onmouseout",
- "onmouseover",
- "onmouseup",
- "onmousewheel",
- "onoffline",
- "ononline",
- "onpagehide",
- "onpageshow",
- "onpause",
- "onplay",
- "onplaying",
- "onpopstate",
- "onprogress",
- "onratechange",
- "onreset",
- "onresize",
- "onscroll",
- "onseeked",
- "onseeking",
- "onselect",
- "onshow",
- "onsort",
- "onstalled",
- "onstorage",
- "onsubmit",
- "onsuspend",
- "ontimeupdate",
- "ontoggle",
- "onunload",
- "onvolumechange",
- "onwaiting",
- "open",
- "optgroup",
- "optimum",
- "option",
- "output",
- "p",
- "param",
- "pattern",
- "ping",
- "placeholder",
- "plaintext",
- "poster",
- "pre",
- "preload",
- "progress",
- "prompt",
- "public",
- "q",
- "radiogroup",
- "readonly",
- "rel",
- "required",
- "reversed",
- "rows",
- "rowspan",
- "rp",
- "rt",
- "ruby",
- "s",
- "samp",
- "sandbox",
- "scope",
- "scoped",
- "script",
- "seamless",
- "section",
- "select",
- "selected",
- "shape",
- "size",
- "sizes",
- "small",
- "sortable",
- "sorted",
- "source",
- "spacer",
- "span",
- "span",
- "spellcheck",
- "src",
- "srcdoc",
- "srclang",
- "start",
- "step",
- "strike",
- "strong",
- "style",
- "style",
- "sub",
- "summary",
- "sup",
- "svg",
- "system",
- "tabindex",
- "table",
- "target",
- "tbody",
- "td",
- "template",
- "textarea",
- "tfoot",
- "th",
- "thead",
- "time",
- "title",
- "title",
- "tr",
- "track",
- "translate",
- "tt",
- "type",
- "typemustmatch",
- "u",
- "ul",
- "usemap",
- "value",
- "var",
- "video",
- "wbr",
- "width",
- "wrap",
- "xmp",
-}
diff --git a/Godeps/_workspace/src/golang.org/x/net/html/charset/charset.go b/Godeps/_workspace/src/golang.org/x/net/html/charset/charset.go
deleted file mode 100644
index fd7eb58..0000000
--- a/Godeps/_workspace/src/golang.org/x/net/html/charset/charset.go
+++ /dev/null
@@ -1,244 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package charset provides common text encodings for HTML documents.
-//
-// The mapping from encoding labels to encodings is defined at
-// https://encoding.spec.whatwg.org/.
-package charset
-
-import (
- "bytes"
- "fmt"
- "io"
- "mime"
- "strings"
- "unicode/utf8"
-
- "golang.org/x/net/html"
- "golang.org/x/text/encoding"
- "golang.org/x/text/encoding/charmap"
- "golang.org/x/text/transform"
-)
-
-// Lookup returns the encoding with the specified label, and its canonical
-// name. It returns nil and the empty string if label is not one of the
-// standard encodings for HTML. Matching is case-insensitive and ignores
-// leading and trailing whitespace.
-func Lookup(label string) (e encoding.Encoding, name string) {
- label = strings.ToLower(strings.Trim(label, "\t\n\r\f "))
- enc := encodings[label]
- return enc.e, enc.name
-}
-
-// DetermineEncoding determines the encoding of an HTML document by examining
-// up to the first 1024 bytes of content and the declared Content-Type.
-//
-// See http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#determining-the-character-encoding
-func DetermineEncoding(content []byte, contentType string) (e encoding.Encoding, name string, certain bool) {
- if len(content) > 1024 {
- content = content[:1024]
- }
-
- for _, b := range boms {
- if bytes.HasPrefix(content, b.bom) {
- e, name = Lookup(b.enc)
- return e, name, true
- }
- }
-
- if _, params, err := mime.ParseMediaType(contentType); err == nil {
- if cs, ok := params["charset"]; ok {
- if e, name = Lookup(cs); e != nil {
- return e, name, true
- }
- }
- }
-
- if len(content) > 0 {
- e, name = prescan(content)
- if e != nil {
- return e, name, false
- }
- }
-
- // Try to detect UTF-8.
- // First eliminate any partial rune at the end.
- for i := len(content) - 1; i >= 0 && i > len(content)-4; i-- {
- b := content[i]
- if b < 0x80 {
- break
- }
- if utf8.RuneStart(b) {
- content = content[:i]
- break
- }
- }
- hasHighBit := false
- for _, c := range content {
- if c >= 0x80 {
- hasHighBit = true
- break
- }
- }
- if hasHighBit && utf8.Valid(content) {
- return encoding.Nop, "utf-8", false
- }
-
- // TODO: change default depending on user's locale?
- return charmap.Windows1252, "windows-1252", false
-}
-
-// NewReader returns an io.Reader that converts the content of r to UTF-8.
-// It calls DetermineEncoding to find out what r's encoding is.
-func NewReader(r io.Reader, contentType string) (io.Reader, error) {
- preview := make([]byte, 1024)
- n, err := io.ReadFull(r, preview)
- switch {
- case err == io.ErrUnexpectedEOF:
- preview = preview[:n]
- r = bytes.NewReader(preview)
- case err != nil:
- return nil, err
- default:
- r = io.MultiReader(bytes.NewReader(preview), r)
- }
-
- if e, _, _ := DetermineEncoding(preview, contentType); e != encoding.Nop {
- r = transform.NewReader(r, e.NewDecoder())
- }
- return r, nil
-}
-
-// NewReaderLabel returns a reader that converts from the specified charset to
-// UTF-8. It uses Lookup to find the encoding that corresponds to label, and
-// returns an error if Lookup returns nil. It is suitable for use as
-// encoding/xml.Decoder's CharsetReader function.
-func NewReaderLabel(label string, input io.Reader) (io.Reader, error) {
- e, _ := Lookup(label)
- if e == nil {
- return nil, fmt.Errorf("unsupported charset: %q", label)
- }
- return transform.NewReader(input, e.NewDecoder()), nil
-}
-
-func prescan(content []byte) (e encoding.Encoding, name string) {
- z := html.NewTokenizer(bytes.NewReader(content))
- for {
- switch z.Next() {
- case html.ErrorToken:
- return nil, ""
-
- case html.StartTagToken, html.SelfClosingTagToken:
- tagName, hasAttr := z.TagName()
- if !bytes.Equal(tagName, []byte("meta")) {
- continue
- }
- attrList := make(map[string]bool)
- gotPragma := false
-
- const (
- dontKnow = iota
- doNeedPragma
- doNotNeedPragma
- )
- needPragma := dontKnow
-
- name = ""
- e = nil
- for hasAttr {
- var key, val []byte
- key, val, hasAttr = z.TagAttr()
- ks := string(key)
- if attrList[ks] {
- continue
- }
- attrList[ks] = true
- for i, c := range val {
- if 'A' <= c && c <= 'Z' {
- val[i] = c + 0x20
- }
- }
-
- switch ks {
- case "http-equiv":
- if bytes.Equal(val, []byte("content-type")) {
- gotPragma = true
- }
-
- case "content":
- if e == nil {
- name = fromMetaElement(string(val))
- if name != "" {
- e, name = Lookup(name)
- if e != nil {
- needPragma = doNeedPragma
- }
- }
- }
-
- case "charset":
- e, name = Lookup(string(val))
- needPragma = doNotNeedPragma
- }
- }
-
- if needPragma == dontKnow || needPragma == doNeedPragma && !gotPragma {
- continue
- }
-
- if strings.HasPrefix(name, "utf-16") {
- name = "utf-8"
- e = encoding.Nop
- }
-
- if e != nil {
- return e, name
- }
- }
- }
-}
-
-func fromMetaElement(s string) string {
- for s != "" {
- csLoc := strings.Index(s, "charset")
- if csLoc == -1 {
- return ""
- }
- s = s[csLoc+len("charset"):]
- s = strings.TrimLeft(s, " \t\n\f\r")
- if !strings.HasPrefix(s, "=") {
- continue
- }
- s = s[1:]
- s = strings.TrimLeft(s, " \t\n\f\r")
- if s == "" {
- return ""
- }
- if q := s[0]; q == '"' || q == '\'' {
- s = s[1:]
- closeQuote := strings.IndexRune(s, rune(q))
- if closeQuote == -1 {
- return ""
- }
- return s[:closeQuote]
- }
-
- end := strings.IndexAny(s, "; \t\n\f\r")
- if end == -1 {
- end = len(s)
- }
- return s[:end]
- }
- return ""
-}
-
-var boms = []struct {
- bom []byte
- enc string
-}{
- {[]byte{0xfe, 0xff}, "utf-16be"},
- {[]byte{0xff, 0xfe}, "utf-16le"},
- {[]byte{0xef, 0xbb, 0xbf}, "utf-8"},
-}
diff --git a/Godeps/_workspace/src/golang.org/x/net/html/charset/charset_test.go b/Godeps/_workspace/src/golang.org/x/net/html/charset/charset_test.go
deleted file mode 100644
index 8b10399..0000000
--- a/Godeps/_workspace/src/golang.org/x/net/html/charset/charset_test.go
+++ /dev/null
@@ -1,236 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package charset
-
-import (
- "bytes"
- "encoding/xml"
- "io/ioutil"
- "runtime"
- "strings"
- "testing"
-
- "golang.org/x/text/transform"
-)
-
-func transformString(t transform.Transformer, s string) (string, error) {
- r := transform.NewReader(strings.NewReader(s), t)
- b, err := ioutil.ReadAll(r)
- return string(b), err
-}
-
-var testCases = []struct {
- utf8, other, otherEncoding string
-}{
- {"Résumé", "Résumé", "utf8"},
- {"Résumé", "R\xe9sum\xe9", "latin1"},
- {"これは漢字です。", "S0\x8c0o0\"oW[g0Y0\x020", "UTF-16LE"},
- {"これは漢字です。", "0S0\x8c0oo\"[W0g0Y0\x02", "UTF-16BE"},
- {"Hello, world", "Hello, world", "ASCII"},
- {"Gdańsk", "Gda\xf1sk", "ISO-8859-2"},
- {"Ââ Čč Đđ Ŋŋ Õõ Šš Žž Åå Ää", "\xc2\xe2 \xc8\xe8 \xa9\xb9 \xaf\xbf \xd5\xf5 \xaa\xba \xac\xbc \xc5\xe5 \xc4\xe4", "ISO-8859-10"},
- {"สำหรับ", "\xca\xd3\xcb\xc3\u047a", "ISO-8859-11"},
- {"latviešu", "latvie\xf0u", "ISO-8859-13"},
- {"Seònaid", "Se\xf2naid", "ISO-8859-14"},
- {"€1 is cheap", "\xa41 is cheap", "ISO-8859-15"},
- {"românește", "rom\xe2ne\xbate", "ISO-8859-16"},
- {"nutraĵo", "nutra\xbco", "ISO-8859-3"},
- {"Kalâdlit", "Kal\xe2dlit", "ISO-8859-4"},
- {"русский", "\xe0\xe3\xe1\xe1\xda\xd8\xd9", "ISO-8859-5"},
- {"ελληνικά", "\xe5\xeb\xeb\xe7\xed\xe9\xea\xdc", "ISO-8859-7"},
- {"Kağan", "Ka\xf0an", "ISO-8859-9"},
- {"Résumé", "R\x8esum\x8e", "macintosh"},
- {"Gdańsk", "Gda\xf1sk", "windows-1250"},
- {"русский", "\xf0\xf3\xf1\xf1\xea\xe8\xe9", "windows-1251"},
- {"Résumé", "R\xe9sum\xe9", "windows-1252"},
- {"ελληνικά", "\xe5\xeb\xeb\xe7\xed\xe9\xea\xdc", "windows-1253"},
- {"Kağan", "Ka\xf0an", "windows-1254"},
- {"עִבְרִית", "\xf2\xc4\xe1\xc0\xf8\xc4\xe9\xfa", "windows-1255"},
- {"العربية", "\xc7\xe1\xda\xd1\xc8\xed\xc9", "windows-1256"},
- {"latviešu", "latvie\xf0u", "windows-1257"},
- {"Việt", "Vi\xea\xf2t", "windows-1258"},
- {"สำหรับ", "\xca\xd3\xcb\xc3\u047a", "windows-874"},
- {"русский", "\xd2\xd5\xd3\xd3\xcb\xc9\xca", "KOI8-R"},
- {"українська", "\xd5\xcb\xd2\xc1\xa7\xce\xd3\xd8\xcb\xc1", "KOI8-U"},
- {"Hello 常用國字標準字體表", "Hello \xb1`\xa5\u03b0\xea\xa6r\xbc\u0437\u01e6r\xc5\xe9\xaa\xed", "big5"},
- {"Hello 常用國字標準字體表", "Hello \xb3\xa3\xd3\xc3\x87\xf8\xd7\xd6\x98\xcb\x9c\xca\xd7\xd6\xf3\x77\xb1\xed", "gbk"},
- {"Hello 常用國字標準字體表", "Hello \xb3\xa3\xd3\xc3\x87\xf8\xd7\xd6\x98\xcb\x9c\xca\xd7\xd6\xf3\x77\xb1\xed", "gb18030"},
- {"עִבְרִית", "\x81\x30\xfb\x30\x81\x30\xf6\x34\x81\x30\xf9\x33\x81\x30\xf6\x30\x81\x30\xfb\x36\x81\x30\xf6\x34\x81\x30\xfa\x31\x81\x30\xfb\x38", "gb18030"},
- {"㧯", "\x82\x31\x89\x38", "gb18030"},
- {"これは漢字です。", "\x82\xb1\x82\xea\x82\xcd\x8a\xbf\x8e\x9a\x82\xc5\x82\xb7\x81B", "SJIS"},
- {"Hello, 世界!", "Hello, \x90\xa2\x8aE!", "SJIS"},
- {"イウエオカ", "\xb2\xb3\xb4\xb5\xb6", "SJIS"},
- {"これは漢字です。", "\xa4\xb3\xa4\xec\xa4\u03f4\xc1\xbb\xfa\xa4\u01e4\xb9\xa1\xa3", "EUC-JP"},
- {"Hello, 世界!", "Hello, \x1b$B@$3&\x1b(B!", "ISO-2022-JP"},
- {"네이트 | 즐거움의 시작, 슈파스(Spaβ) NATE", "\xb3\xd7\xc0\xcc\xc6\xae | \xc1\xf1\xb0\xc5\xbf\xf2\xc0\xc7 \xbd\xc3\xc0\xdb, \xbd\xb4\xc6\xc4\xbd\xba(Spa\xa5\xe2) NATE", "EUC-KR"},
-}
-
-func TestDecode(t *testing.T) {
- for _, tc := range testCases {
- e, _ := Lookup(tc.otherEncoding)
- if e == nil {
- t.Errorf("%s: not found", tc.otherEncoding)
- continue
- }
- s, err := transformString(e.NewDecoder(), tc.other)
- if err != nil {
- t.Errorf("%s: decode %q: %v", tc.otherEncoding, tc.other, err)
- continue
- }
- if s != tc.utf8 {
- t.Errorf("%s: got %q, want %q", tc.otherEncoding, s, tc.utf8)
- }
- }
-}
-
-func TestEncode(t *testing.T) {
- for _, tc := range testCases {
- e, _ := Lookup(tc.otherEncoding)
- if e == nil {
- t.Errorf("%s: not found", tc.otherEncoding)
- continue
- }
- s, err := transformString(e.NewEncoder(), tc.utf8)
- if err != nil {
- t.Errorf("%s: encode %q: %s", tc.otherEncoding, tc.utf8, err)
- continue
- }
- if s != tc.other {
- t.Errorf("%s: got %q, want %q", tc.otherEncoding, s, tc.other)
- }
- }
-}
-
-// TestNames verifies that you can pass an encoding's name to Lookup and get
-// the same encoding back (except for "replacement").
-func TestNames(t *testing.T) {
- for _, e := range encodings {
- if e.name == "replacement" {
- continue
- }
- _, got := Lookup(e.name)
- if got != e.name {
- t.Errorf("got %q, want %q", got, e.name)
- continue
- }
- }
-}
-
-var sniffTestCases = []struct {
- filename, declared, want string
-}{
- {"HTTP-charset.html", "text/html; charset=iso-8859-15", "iso-8859-15"},
- {"UTF-16LE-BOM.html", "", "utf-16le"},
- {"UTF-16BE-BOM.html", "", "utf-16be"},
- {"meta-content-attribute.html", "text/html", "iso-8859-15"},
- {"meta-charset-attribute.html", "text/html", "iso-8859-15"},
- {"No-encoding-declaration.html", "text/html", "utf-8"},
- {"HTTP-vs-UTF-8-BOM.html", "text/html; charset=iso-8859-15", "utf-8"},
- {"HTTP-vs-meta-content.html", "text/html; charset=iso-8859-15", "iso-8859-15"},
- {"HTTP-vs-meta-charset.html", "text/html; charset=iso-8859-15", "iso-8859-15"},
- {"UTF-8-BOM-vs-meta-content.html", "text/html", "utf-8"},
- {"UTF-8-BOM-vs-meta-charset.html", "text/html", "utf-8"},
-}
-
-func TestSniff(t *testing.T) {
- switch runtime.GOOS {
- case "nacl": // platforms that don't permit direct file system access
- t.Skipf("not supported on %q", runtime.GOOS)
- }
-
- for _, tc := range sniffTestCases {
- content, err := ioutil.ReadFile("testdata/" + tc.filename)
- if err != nil {
- t.Errorf("%s: error reading file: %v", tc.filename, err)
- continue
- }
-
- _, name, _ := DetermineEncoding(content, tc.declared)
- if name != tc.want {
- t.Errorf("%s: got %q, want %q", tc.filename, name, tc.want)
- continue
- }
- }
-}
-
-func TestReader(t *testing.T) {
- switch runtime.GOOS {
- case "nacl": // platforms that don't permit direct file system access
- t.Skipf("not supported on %q", runtime.GOOS)
- }
-
- for _, tc := range sniffTestCases {
- content, err := ioutil.ReadFile("testdata/" + tc.filename)
- if err != nil {
- t.Errorf("%s: error reading file: %v", tc.filename, err)
- continue
- }
-
- r, err := NewReader(bytes.NewReader(content), tc.declared)
- if err != nil {
- t.Errorf("%s: error creating reader: %v", tc.filename, err)
- continue
- }
-
- got, err := ioutil.ReadAll(r)
- if err != nil {
- t.Errorf("%s: error reading from charset.NewReader: %v", tc.filename, err)
- continue
- }
-
- e, _ := Lookup(tc.want)
- want, err := ioutil.ReadAll(transform.NewReader(bytes.NewReader(content), e.NewDecoder()))
- if err != nil {
- t.Errorf("%s: error decoding with hard-coded charset name: %v", tc.filename, err)
- continue
- }
-
- if !bytes.Equal(got, want) {
- t.Errorf("%s: got %q, want %q", tc.filename, got, want)
- continue
- }
- }
-}
-
-var metaTestCases = []struct {
- meta, want string
-}{
- {"", ""},
- {"text/html", ""},
- {"text/html; charset utf-8", ""},
- {"text/html; charset=latin-2", "latin-2"},
- {"text/html; charset; charset = utf-8", "utf-8"},
- {`charset="big5"`, "big5"},
- {"charset='shift_jis'", "shift_jis"},
-}
-
-func TestFromMeta(t *testing.T) {
- for _, tc := range metaTestCases {
- got := fromMetaElement(tc.meta)
- if got != tc.want {
- t.Errorf("%q: got %q, want %q", tc.meta, got, tc.want)
- }
- }
-}
-
-func TestXML(t *testing.T) {
- const s = "
HTTP charset
- - - - - -The character encoding of a page can be set using the HTTP header charset declaration.
-The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ÜÀÚ
. This matches the sequence of bytes above when they are interpreted as ISO 8859-15. If the class name matches the selector then the test will pass.
The only character encoding declaration for this HTML file is in the HTTP header, which sets the encoding to ISO 8859-15.
-the-input-byte-stream-001
Result summary & related tests
Detailed results for this test
Link to spec
HTTP vs UTF-8 BOM
- - - - - -A character encoding set in the HTTP header has lower precedence than the UTF-8 signature.
-The HTTP header attempts to set the character encoding to ISO 8859-15. The page starts with a UTF-8 signature.
The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ýäè
. This matches the sequence of bytes above when they are interpreted as UTF-8. If the class name matches the selector then the test will pass.
If the test is unsuccessful, the characters  should appear at the top of the page. These represent the bytes that make up the UTF-8 signature when encountered in the ISO 8859-15 encoding.
-the-input-byte-stream-034
Result summary & related tests
Detailed results for this test
Link to spec
HTTP vs meta charset
- - - - - -The HTTP header has a higher precedence than an encoding declaration in a meta charset attribute.
-The HTTP header attempts to set the character encoding to ISO 8859-15. The page contains an encoding declaration in a meta charset attribute that attempts to set the character encoding to ISO 8859-1.
The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ÜÀÚ
. This matches the sequence of bytes above when they are interpreted as ISO 8859-15. If the class name matches the selector then the test will pass.
the-input-byte-stream-018
Result summary & related tests
Detailed results for this test
Link to spec
HTTP vs meta content
- - - - - -The HTTP header has a higher precedence than an encoding declaration in a meta content attribute.
-The HTTP header attempts to set the character encoding to ISO 8859-15. The page contains an encoding declaration in a meta content attribute that attempts to set the character encoding to ISO 8859-1.
The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ÜÀÚ
. This matches the sequence of bytes above when they are interpreted as ISO 8859-15. If the class name matches the selector then the test will pass.
the-input-byte-stream-016
Result summary & related tests
Detailed results for this test
Link to spec
No encoding declaration
- - - - - -A page with no encoding information in HTTP, BOM, XML declaration or meta element will be treated as UTF-8.
-The test on this page contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ýäè
. This matches the sequence of bytes above when they are interpreted as UTF-8. If the class name matches the selector then the test will pass.
the-input-byte-stream-015
Result summary & related tests
Detailed results for this test
Link to spec
UTF-8 BOM vs meta charset
- - - - - -A page with a UTF-8 BOM will be recognized as UTF-8 even if the meta charset attribute declares a different encoding.
-The page contains an encoding declaration in a meta charset attribute that attempts to set the character encoding to ISO 8859-15, but the file starts with a UTF-8 signature.
The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ýäè
. This matches the sequence of bytes above when they are interpreted as UTF-8. If the class name matches the selector then the test will pass.
the-input-byte-stream-038
Result summary & related tests
Detailed results for this test
Link to spec
UTF-8 BOM vs meta content
- - - - - -A page with a UTF-8 BOM will be recognized as UTF-8 even if the meta content attribute declares a different encoding.
-The page contains an encoding declaration in a meta content attribute that attempts to set the character encoding to ISO 8859-15, but the file starts with a UTF-8 signature.
The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ýäè
. This matches the sequence of bytes above when they are interpreted as UTF-8. If the class name matches the selector then the test will pass.
the-input-byte-stream-037
Result summary & related tests
Detailed results for this test
Link to spec
meta charset attribute
- - - - - -The character encoding of the page can be set by a meta element with charset attribute.
-The only character encoding declaration for this HTML file is in the charset attribute of the meta element, which declares the encoding to be ISO 8859-15.
The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ÜÀÚ
. This matches the sequence of bytes above when they are interpreted as ISO 8859-15. If the class name matches the selector then the test will pass.
the-input-byte-stream-009
Result summary & related tests
Detailed results for this test
Link to spec
meta content attribute
- - - - - -The character encoding of the page can be set by a meta element with http-equiv and content attributes.
-The only character encoding declaration for this HTML file is in the content attribute of the meta element, which declares the encoding to be ISO 8859-15.
The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ÜÀÚ
. This matches the sequence of bytes above when they are interpreted as ISO 8859-15. If the class name matches the selector then the test will pass.
the-input-byte-stream-007
Result summary & related tests
Detailed results for this test
Link to spec
Links:
` - doc, err := html.Parse(strings.NewReader(s)) - if err != nil { - log.Fatal(err) - } - var f func(*html.Node) - f = func(n *html.Node) { - if n.Type == html.ElementNode && n.Data == "a" { - for _, a := range n.Attr { - if a.Key == "href" { - fmt.Println(a.Val) - break - } - } - } - for c := n.FirstChild; c != nil; c = c.NextSibling { - f(c) - } - } - f(doc) - // Output: - // foo - // /bar/baz -} diff --git a/Godeps/_workspace/src/golang.org/x/net/html/node_test.go b/Godeps/_workspace/src/golang.org/x/net/html/node_test.go deleted file mode 100644 index 471102f..0000000 --- a/Godeps/_workspace/src/golang.org/x/net/html/node_test.go +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package html - -import ( - "fmt" -) - -// checkTreeConsistency checks that a node and its descendants are all -// consistent in their parent/child/sibling relationships. -func checkTreeConsistency(n *Node) error { - return checkTreeConsistency1(n, 0) -} - -func checkTreeConsistency1(n *Node, depth int) error { - if depth == 1e4 { - return fmt.Errorf("html: tree looks like it contains a cycle") - } - if err := checkNodeConsistency(n); err != nil { - return err - } - for c := n.FirstChild; c != nil; c = c.NextSibling { - if err := checkTreeConsistency1(c, depth+1); err != nil { - return err - } - } - return nil -} - -// checkNodeConsistency checks that a node's parent/child/sibling relationships -// are consistent. -func checkNodeConsistency(n *Node) error { - if n == nil { - return nil - } - - nParent := 0 - for p := n.Parent; p != nil; p = p.Parent { - nParent++ - if nParent == 1e4 { - return fmt.Errorf("html: parent list looks like an infinite loop") - } - } - - nForward := 0 - for c := n.FirstChild; c != nil; c = c.NextSibling { - nForward++ - if nForward == 1e6 { - return fmt.Errorf("html: forward list of children looks like an infinite loop") - } - if c.Parent != n { - return fmt.Errorf("html: inconsistent child/parent relationship") - } - } - - nBackward := 0 - for c := n.LastChild; c != nil; c = c.PrevSibling { - nBackward++ - if nBackward == 1e6 { - return fmt.Errorf("html: backward list of children looks like an infinite loop") - } - if c.Parent != n { - return fmt.Errorf("html: inconsistent child/parent relationship") - } - } - - if n.Parent != nil { - if n.Parent == n { - return fmt.Errorf("html: inconsistent parent relationship") - } - if n.Parent == n.FirstChild { - return fmt.Errorf("html: inconsistent parent/first relationship") - } - if n.Parent == n.LastChild { - return fmt.Errorf("html: inconsistent parent/last relationship") - } - if n.Parent == n.PrevSibling { - return fmt.Errorf("html: inconsistent parent/prev relationship") - } - if n.Parent == n.NextSibling { - return fmt.Errorf("html: inconsistent parent/next relationship") - } - - parentHasNAsAChild := false - for c := n.Parent.FirstChild; c != nil; c = c.NextSibling { - if c == n { - parentHasNAsAChild = true - break - } - } - if !parentHasNAsAChild { - return fmt.Errorf("html: inconsistent parent/child relationship") - } - } - - if n.PrevSibling != nil && n.PrevSibling.NextSibling != n { - return fmt.Errorf("html: inconsistent prev/next relationship") - } - if n.NextSibling != nil && n.NextSibling.PrevSibling != n { - return fmt.Errorf("html: inconsistent next/prev relationship") - } - - if (n.FirstChild == nil) != (n.LastChild == nil) { - return fmt.Errorf("html: inconsistent first/last relationship") - } - if n.FirstChild != nil && n.FirstChild == n.LastChild { - // We have a sole child. - if n.FirstChild.PrevSibling != nil || n.FirstChild.NextSibling != nil { - return fmt.Errorf("html: inconsistent sole child's sibling relationship") - } - } - - seen := map[*Node]bool{} - - var last *Node - for c := n.FirstChild; c != nil; c = c.NextSibling { - if seen[c] { - return fmt.Errorf("html: inconsistent repeated child") - } - seen[c] = true - last = c - } - if last != n.LastChild { - return fmt.Errorf("html: inconsistent last relationship") - } - - var first *Node - for c := n.LastChild; c != nil; c = c.PrevSibling { - if !seen[c] { - return fmt.Errorf("html: inconsistent missing child") - } - delete(seen, c) - first = c - } - if first != n.FirstChild { - return fmt.Errorf("html: inconsistent first relationship") - } - - if len(seen) != 0 { - return fmt.Errorf("html: inconsistent forwards/backwards child list") - } - - return nil -} diff --git a/Godeps/_workspace/src/golang.org/x/net/html/parse_test.go b/Godeps/_workspace/src/golang.org/x/net/html/parse_test.go deleted file mode 100644 index 7e47d11..0000000 --- a/Godeps/_workspace/src/golang.org/x/net/html/parse_test.go +++ /dev/null @@ -1,388 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package html - -import ( - "bufio" - "bytes" - "errors" - "fmt" - "io" - "io/ioutil" - "os" - "path/filepath" - "runtime" - "sort" - "strings" - "testing" - - "golang.org/x/net/html/atom" -) - -// readParseTest reads a single test case from r. -func readParseTest(r *bufio.Reader) (text, want, context string, err error) { - line, err := r.ReadSlice('\n') - if err != nil { - return "", "", "", err - } - var b []byte - - // Read the HTML. - if string(line) != "#data\n" { - return "", "", "", fmt.Errorf(`got %q want "#data\n"`, line) - } - for { - line, err = r.ReadSlice('\n') - if err != nil { - return "", "", "", err - } - if line[0] == '#' { - break - } - b = append(b, line...) - } - text = strings.TrimSuffix(string(b), "\n") - b = b[:0] - - // Skip the error list. - if string(line) != "#errors\n" { - return "", "", "", fmt.Errorf(`got %q want "#errors\n"`, line) - } - for { - line, err = r.ReadSlice('\n') - if err != nil { - return "", "", "", err - } - if line[0] == '#' { - break - } - } - - if string(line) == "#document-fragment\n" { - line, err = r.ReadSlice('\n') - if err != nil { - return "", "", "", err - } - context = strings.TrimSpace(string(line)) - line, err = r.ReadSlice('\n') - if err != nil { - return "", "", "", err - } - } - - // Read the dump of what the parse tree should be. - if string(line) != "#document\n" { - return "", "", "", fmt.Errorf(`got %q want "#document\n"`, line) - } - inQuote := false - for { - line, err = r.ReadSlice('\n') - if err != nil && err != io.EOF { - return "", "", "", err - } - trimmed := bytes.Trim(line, "| \n") - if len(trimmed) > 0 { - if line[0] == '|' && trimmed[0] == '"' { - inQuote = true - } - if trimmed[len(trimmed)-1] == '"' && !(line[0] == '|' && len(trimmed) == 1) { - inQuote = false - } - } - if len(line) == 0 || len(line) == 1 && line[0] == '\n' && !inQuote { - break - } - b = append(b, line...) - } - return text, string(b), context, nil -} - -func dumpIndent(w io.Writer, level int) { - io.WriteString(w, "| ") - for i := 0; i < level; i++ { - io.WriteString(w, " ") - } -} - -type sortedAttributes []Attribute - -func (a sortedAttributes) Len() int { - return len(a) -} - -func (a sortedAttributes) Less(i, j int) bool { - if a[i].Namespace != a[j].Namespace { - return a[i].Namespace < a[j].Namespace - } - return a[i].Key < a[j].Key -} - -func (a sortedAttributes) Swap(i, j int) { - a[i], a[j] = a[j], a[i] -} - -func dumpLevel(w io.Writer, n *Node, level int) error { - dumpIndent(w, level) - switch n.Type { - case ErrorNode: - return errors.New("unexpected ErrorNode") - case DocumentNode: - return errors.New("unexpected DocumentNode") - case ElementNode: - if n.Namespace != "" { - fmt.Fprintf(w, "<%s %s>", n.Namespace, n.Data) - } else { - fmt.Fprintf(w, "<%s>", n.Data) - } - attr := sortedAttributes(n.Attr) - sort.Sort(attr) - for _, a := range attr { - io.WriteString(w, "\n") - dumpIndent(w, level+1) - if a.Namespace != "" { - fmt.Fprintf(w, `%s %s="%s"`, a.Namespace, a.Key, a.Val) - } else { - fmt.Fprintf(w, `%s="%s"`, a.Key, a.Val) - } - } - case TextNode: - fmt.Fprintf(w, `"%s"`, n.Data) - case CommentNode: - fmt.Fprintf(w, "", n.Data) - case DoctypeNode: - fmt.Fprintf(w, "") - case scopeMarkerNode: - return errors.New("unexpected scopeMarkerNode") - default: - return errors.New("unknown node type") - } - io.WriteString(w, "\n") - for c := n.FirstChild; c != nil; c = c.NextSibling { - if err := dumpLevel(w, c, level+1); err != nil { - return err - } - } - return nil -} - -func dump(n *Node) (string, error) { - if n == nil || n.FirstChild == nil { - return "", nil - } - var b bytes.Buffer - for c := n.FirstChild; c != nil; c = c.NextSibling { - if err := dumpLevel(&b, c, 0); err != nil { - return "", err - } - } - return b.String(), nil -} - -const testDataDir = "testdata/webkit/" - -func TestParser(t *testing.T) { - testFiles, err := filepath.Glob(testDataDir + "*.dat") - if err != nil { - t.Fatal(err) - } - for _, tf := range testFiles { - f, err := os.Open(tf) - if err != nil { - t.Fatal(err) - } - defer f.Close() - r := bufio.NewReader(f) - - for i := 0; ; i++ { - text, want, context, err := readParseTest(r) - if err == io.EOF { - break - } - if err != nil { - t.Fatal(err) - } - - err = testParseCase(text, want, context) - - if err != nil { - t.Errorf("%s test #%d %q, %s", tf, i, text, err) - } - } - } -} - -// testParseCase tests one test case from the test files. If the test does not -// pass, it returns an error that explains the failure. -// text is the HTML to be parsed, want is a dump of the correct parse tree, -// and context is the name of the context node, if any. -func testParseCase(text, want, context string) (err error) { - defer func() { - if x := recover(); x != nil { - switch e := x.(type) { - case error: - err = e - default: - err = fmt.Errorf("%v", e) - } - } - }() - - var doc *Node - if context == "" { - doc, err = Parse(strings.NewReader(text)) - if err != nil { - return err - } - } else { - contextNode := &Node{ - Type: ElementNode, - DataAtom: atom.Lookup([]byte(context)), - Data: context, - } - nodes, err := ParseFragment(strings.NewReader(text), contextNode) - if err != nil { - return err - } - doc = &Node{ - Type: DocumentNode, - } - for _, n := range nodes { - doc.AppendChild(n) - } - } - - if err := checkTreeConsistency(doc); err != nil { - return err - } - - got, err := dump(doc) - if err != nil { - return err - } - // Compare the parsed tree to the #document section. - if got != want { - return fmt.Errorf("got vs want:\n----\n%s----\n%s----", got, want) - } - - if renderTestBlacklist[text] || context != "" { - return nil - } - - // Check that rendering and re-parsing results in an identical tree. - pr, pw := io.Pipe() - go func() { - pw.CloseWithError(Render(pw, doc)) - }() - doc1, err := Parse(pr) - if err != nil { - return err - } - got1, err := dump(doc1) - if err != nil { - return err - } - if got != got1 { - return fmt.Errorf("got vs got1:\n----\n%s----\n%s----", got, got1) - } - - return nil -} - -// Some test input result in parse trees are not 'well-formed' despite -// following the HTML5 recovery algorithms. Rendering and re-parsing such a -// tree will not result in an exact clone of that tree. We blacklist such -// inputs from the render test. -var renderTestBlacklist = map[string]bool{ - // The second will be reparented to the first