Documentation
¶
Index ¶
- func GetString(ent tl.Entity, key string) (string, error)
- func ReadRows(in io.Reader, cb func(Row)) error
- func SetString(ent tl.Entity, key string, value string) error
- type Adapter
- type DirAdapter
- func (adapter *DirAdapter) Close() error
- func (adapter *DirAdapter) DirSHA1() (string, error)
- func (adapter *DirAdapter) Exists() bool
- func (adapter *DirAdapter) FileInfos() ([]os.FileInfo, error)
- func (adapter *DirAdapter) Open() error
- func (adapter *DirAdapter) OpenFile(filename string, cb func(io.Reader)) error
- func (adapter *DirAdapter) Path() string
- func (adapter *DirAdapter) ReadRows(filename string, cb func(Row)) error
- func (adapter *DirAdapter) SHA1() (string, error)
- func (adapter *DirAdapter) WriteRows(filename string, rows [][]string) error
- type OverlayAdapter
- func (adapter OverlayAdapter) Close() error
- func (adapter OverlayAdapter) DirSHA1() (string, error)
- func (adapter OverlayAdapter) Exists() bool
- func (adapter OverlayAdapter) Open() error
- func (adapter OverlayAdapter) OpenFile(filename string, cb func(io.Reader)) error
- func (adapter OverlayAdapter) Path() string
- func (adapter OverlayAdapter) ReadRows(filename string, cb func(Row)) error
- func (adapter OverlayAdapter) SHA1() (string, error)
- type Reader
- func (reader *Reader) Agencies() (out chan tl.Agency)
- func (reader *Reader) CalendarDates() (out chan tl.CalendarDate)
- func (reader *Reader) Calendars() (out chan tl.Calendar)
- func (reader *Reader) ContainsFile(filename string) bool
- func (reader *Reader) FareAttributes() (out chan tl.FareAttribute)
- func (reader *Reader) FareRules() (out chan tl.FareRule)
- func (reader *Reader) FeedInfos() (out chan tl.FeedInfo)
- func (reader *Reader) Frequencies() (out chan tl.Frequency)
- func (reader *Reader) Levels() (out chan tl.Level)
- func (reader *Reader) Pathways() (out chan tl.Pathway)
- func (reader *Reader) ReadEntities(c interface{}) error
- func (reader *Reader) Routes() (out chan tl.Route)
- func (reader *Reader) Shapes() chan tl.Shape
- func (reader *Reader) StopTimes() (out chan tl.StopTime)
- func (reader *Reader) StopTimesByTripID(tripIDs ...string) chan []tl.StopTime
- func (reader *Reader) Stops() (out chan tl.Stop)
- func (reader *Reader) Transfers() (out chan tl.Transfer)
- func (reader *Reader) Trips() (out chan tl.Trip)
- func (reader *Reader) ValidateStructure() []error
- type Row
- type S3Adapter
- type URLAdapter
- type Writer
- type WriterAdapter
- type ZipAdapter
- func (adapter ZipAdapter) Close() error
- func (adapter ZipAdapter) DirSHA1() (string, error)
- func (adapter ZipAdapter) Exists() bool
- func (adapter ZipAdapter) FileInfos() ([]os.FileInfo, error)
- func (adapter ZipAdapter) Open() error
- func (adapter ZipAdapter) OpenFile(filename string, cb func(io.Reader)) error
- func (adapter ZipAdapter) Path() string
- func (adapter ZipAdapter) ReadRows(filename string, cb func(Row)) error
- func (adapter ZipAdapter) SHA1() (string, error)
- type ZipWriterAdapter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adapter ¶
type Adapter interface { OpenFile(string, func(io.Reader)) error ReadRows(string, func(Row)) error Open() error Close() error Exists() bool Path() string SHA1() (string, error) DirSHA1() (string, error) }
Adapter provides an interface for working with various kinds of GTFS sources: zip, directory, url.
type DirAdapter ¶
type DirAdapter struct {
// contains filtered or unexported fields
}
DirAdapter supports plain directories of CSV files.
func NewDirAdapter ¶
func NewDirAdapter(path string) *DirAdapter
NewDirAdapter returns an initialized DirAdapter.
func (*DirAdapter) DirSHA1 ¶
func (adapter *DirAdapter) DirSHA1() (string, error)
DirSHA1 returns the SHA1 of all the .txt files in the main directory, sorted, and concatenated.
func (*DirAdapter) Exists ¶
func (adapter *DirAdapter) Exists() bool
Exists checks if the specified directory exists.
func (*DirAdapter) FileInfos ¶
func (adapter *DirAdapter) FileInfos() ([]os.FileInfo, error)
FileInfos returns a list of os.FileInfo for all top-level .txt files.
func (*DirAdapter) Open ¶
func (adapter *DirAdapter) Open() error
Open the adapter. Return an error if the directory does not exist.
func (*DirAdapter) OpenFile ¶
func (adapter *DirAdapter) OpenFile(filename string, cb func(io.Reader)) error
OpenFile opens a file in the directory. Returns an error if the file cannot be read.
type OverlayAdapter ¶
type OverlayAdapter struct {
// contains filtered or unexported fields
}
OverlayAdapter searches a specified list of directories for the specified file. Used for reducing the complexity of writing tests.
func NewOverlayAdapter ¶
func NewOverlayAdapter(paths ...string) OverlayAdapter
NewOverlayAdapter returns a new OverlayAdapter.
func (OverlayAdapter) Close ¶
func (adapter OverlayAdapter) Close() error
Close implements CSV Adapter.Close.
func (OverlayAdapter) DirSHA1 ¶
func (adapter OverlayAdapter) DirSHA1() (string, error)
DirSHA1 returns the SHA1 of all the .txt files in the main directory, sorted, and concatenated.
func (OverlayAdapter) Exists ¶
func (adapter OverlayAdapter) Exists() bool
Exists implements CSV Adapter.Exists.
func (OverlayAdapter) Open ¶
func (adapter OverlayAdapter) Open() error
Open implements CSV Adapter Open.
func (OverlayAdapter) OpenFile ¶
func (adapter OverlayAdapter) OpenFile(filename string, cb func(io.Reader)) error
OpenFile searches paths until it finds the specified file.
func (OverlayAdapter) Path ¶
func (adapter OverlayAdapter) Path() string
Path implements CSV Adapter.Path.
func (OverlayAdapter) ReadRows ¶
func (adapter OverlayAdapter) ReadRows(filename string, cb func(Row)) error
ReadRows implements CSV Adapter ReadRows.
func (OverlayAdapter) SHA1 ¶
func (adapter OverlayAdapter) SHA1() (string, error)
SHA1 is an alias for DirSHA1
type Reader ¶
type Reader struct {
Adapter
}
Reader reads GTFS entities from CSV files.
func (*Reader) CalendarDates ¶
func (reader *Reader) CalendarDates() (out chan tl.CalendarDate)
CalendarDates sends CalendarDates.
func (*Reader) ContainsFile ¶
ContainsFile checks if filename is present and contains a readable row.
func (*Reader) FareAttributes ¶
func (reader *Reader) FareAttributes() (out chan tl.FareAttribute)
FareAttributes sends FareAttributes.
func (*Reader) Frequencies ¶
Frequencies sends Frequencies.
func (*Reader) ReadEntities ¶
ReadEntities provides a generic interface for reading entities.
func (*Reader) StopTimesByTripID ¶
StopTimesByTripID sends StopTimes for selected trips.
func (*Reader) ValidateStructure ¶
ValidateStructure returns if all required CSV files are present.
type S3Adapter ¶
type S3Adapter struct { ZipAdapter // contains filtered or unexported fields }
S3Adapter downloads a GTFS file from an S3 bucket to a temporary file, and removes the file when it is closed.
type URLAdapter ¶
type URLAdapter struct { ZipAdapter // contains filtered or unexported fields }
URLAdapter downloads a GTFS URL to a temporary file, and removes the file when it is closed.
func (*URLAdapter) Close ¶
func (adapter *URLAdapter) Close() error
Close the adapter, and remove the temporary file. An error is returned if the file could not be deleted.
func (*URLAdapter) Open ¶
func (adapter *URLAdapter) Open() error
Open the adapter, and download the provided URL to a temporary file.
type Writer ¶
type Writer struct { WriterAdapter // contains filtered or unexported fields }
Writer implements a GTFS CSV Writer.
func (*Writer) AddEntities ¶
AddEntities writes entities to the output.
type WriterAdapter ¶
WriterAdapter provides a writing interface.
type ZipAdapter ¶
type ZipAdapter struct {
// contains filtered or unexported fields
}
ZipAdapter supports reading from zip archives.
func NewZipAdapter ¶
func NewZipAdapter(path string) *ZipAdapter
NewZipAdapter returns an initialized zip adapter.
func (ZipAdapter) DirSHA1 ¶
func (adapter ZipAdapter) DirSHA1() (string, error)
DirSHA1 returns the SHA1 of all the .txt files in the main directory, sorted, and concatenated.
func (ZipAdapter) Exists ¶
func (adapter ZipAdapter) Exists() bool
Exists returns if the zip file exists.
func (ZipAdapter) FileInfos ¶
func (adapter ZipAdapter) FileInfos() ([]os.FileInfo, error)
FileInfos returns a list of os.FileInfo for all top-level .txt files.
func (ZipAdapter) Open ¶
func (adapter ZipAdapter) Open() error
Open the adapter. Return an error if the file does not exist.
func (ZipAdapter) OpenFile ¶
func (adapter ZipAdapter) OpenFile(filename string, cb func(io.Reader)) error
OpenFile opens the file inside the archive and passes it to the provided callback.
func (ZipAdapter) Path ¶
func (adapter ZipAdapter) Path() string
Path returns the path to the zip file.
func (ZipAdapter) ReadRows ¶
func (adapter ZipAdapter) ReadRows(filename string, cb func(Row)) error
ReadRows opens the specified file and runs the callback on each Row. An error is returned if the file cannot be read.
func (ZipAdapter) SHA1 ¶
func (adapter ZipAdapter) SHA1() (string, error)
SHA1 returns the SHA1 checksum of the zip archive.
type ZipWriterAdapter ¶
type ZipWriterAdapter struct { DirAdapter // contains filtered or unexported fields }
ZipWriterAdapter functions the same as DirAdapter, but writes to a temporary directory, and creates a zip archive when closed.
func NewZipWriterAdapter ¶
func NewZipWriterAdapter(path string) *ZipWriterAdapter
NewZipWriterAdapter returns a new ZipWriterAdapter.
func (*ZipWriterAdapter) Close ¶
func (adapter *ZipWriterAdapter) Close() error
Close creates a zip archive of all the written files at the specified destination.