Skip to content

Commit 031f275

Browse files
committed
Merge branch 'master' of https://github.com/JuliaString/Format.jl into oldmaster
2 parents cb6fbb3 + 04b5040 commit 031f275

18 files changed

+887
-621
lines changed

.travis.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1+
## Documentation: http://docs.travis-ci.com/user/languages/julia/
12
language: julia
23
os:
3-
- linux
4-
- osx
4+
- linux
5+
- osx
56
julia:
6-
- 0.6
7-
- 0.7
8-
- 1.0
9-
- nightly
7+
- 0.6
8+
- 0.7
9+
- 1.0
10+
- nightly
1011
notifications:
1112
email: false
13+
git:
14+
depth: 99999999
15+
16+
## uncomment the following lines to allow failures on nightly julia
17+
## (tests will run but not make your overall status red)
18+
matrix:
19+
allow_failures:
20+
- julia: nightly
21+
22+
# uncomment the following lines to override the default test script
23+
#script:
24+
1225
after_success:
13-
# push coverage results to Codecov
14-
- julia -e 'cd(Pkg.dir("Formatting")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
26+
- julia -e 'VERSION < v"0.7.0-DEV" || (using Pkg); cd(Pkg.dir("Format")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder()); Codecov.submit(Codecov.process_folder())'

LICENSE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
The Formatting.jl package is licensed under the MIT "Expat" License:
1+
The JuliaString/Format.jl package is licensed under the MIT "Expat" License,
2+
and is based on the JuliaIO/Formatting.jl package, licensed as follows:
23

34
> Copyright (c) 2014: Dahua Lin and contributors.
5+
> Portions Copyright (c) 2017: Gandalf Software, Inc. (Scott Paul Jones) and other contributors
46
>
57
> Permission is hereby granted, free of charge, to any person obtaining
68
> a copy of this software and associated documentation files (the

Project.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
authors = [
2+
"Dahua Lin <[email protected]>",
3+
"John M Kuhn <[email protected]>",
4+
"ScottPJones <[email protected]>",
5+
"Thomas Breloff <[email protected]>",
6+
"Alex Arslan <[email protected]>",
7+
"Chuan-Zheng Lee <[email protected]>",
8+
"Galen Lynch <[email protected]>",
9+
"Iain Dunning <[email protected]>",
10+
"Joseph Kleinhenz <[email protected]>",
11+
"Keno Fischer <[email protected]>",
12+
"Kevin Squire <[email protected]>",
13+
"Theodore Papamarkou <[email protected]>",
14+
"Tony Fong <[email protected]>",
15+
"Tony Kelman <[email protected]>",
16+
"Viral B. Shah <[email protected]>",
17+
"Yichao Yu <[email protected]>",
18+
19+
"ranjanan <[email protected]>"
20+
]
21+
desc = "C, Python, and type-defined numeric and string formatting"
22+
keywords = ["Strings", "Formatting"]
23+
license = "MIT"
24+
name = "Format"
25+
uuid = "1fa38f19-a742-5d3f-a2b9-30dd87b9d5f8"
26+
version = "0.7.2"
27+
28+
[deps]
29+
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
30+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
31+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

README.md

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,52 @@
1-
# Formatting
1+
# Format
22

33
This package offers Python-style general formatting and c-style numerical formatting (for speed).
44

5-
| **PackageEvaluator** | **Build Status** |
6-
|:---------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------:|
7-
|[![][pkg-0.6-img]][pkg-0.6-url] | [![][travis-img]][travis-url] [![][appveyor-img]][appveyor-url] [![][codecov-img]][codecov-url] |
5+
| **Info** | **Windows** | **Linux & MacOS** | **Package Evaluator** | **CodeCov** | **Coveralls** |
6+
|:------------------:|:------------------:|:---------------------:|:-----------------:|:---------------------:|:-----------------:|
7+
| [![][license-img]][license-url] | [![][app-s-img]][app-s-url] | [![][travis-s-img]][travis-url] | [![][pkg-s-img]][pkg-s-url] | [![][codecov-img]][codecov-url] | [![][coverall-s-img]][coverall-s-url]
8+
| [![][gitter-img]][gitter-url] | [![][app-m-img]][app-m-url] | [![][travis-m-img]][travis-url] | [![][pkg-m-img]][pkg-m-url] | [![][codecov-img]][codecov-url] | [![][coverall-m-img]][coverall-m-url]
89

10+
[license-img]: http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat
11+
[license-url]: LICENSE.md
912

10-
[travis-img]: https://travis-ci.org/JuliaIO/Formatting.jl.svg?branch=master
11-
[travis-url]: https://travis-ci.org/JuliaIO/Formatting.jl
13+
[gitter-img]: https://badges.gitter.im/Join%20Chat.svg
14+
[gitter-url]: https://gitter.im/JuliaString/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
1215

13-
[appveyor-img]: https://ci.appveyor.com/api/projects/status/all0t7gefcl5dgv1/branch/master?svg=true
14-
[appveyor-url]: https://ci.appveyor.com/project/jmkuhn/formatting-jl/branch/master
16+
[travis-url]: https://travis-ci.org/JuliaString/Format.jl
17+
[travis-s-img]: https://travis-ci.org/JuliaString/Format.jl.svg
18+
[travis-m-img]: https://travis-ci.org/JuliaString/Format.jl.svg?branch=newmaster
1519

16-
[codecov-img]: https://codecov.io/gh/JuliaIO/Formatting.jl/branch/master/graph/badge.svg
17-
[codecov-url]: https://codecov.io/gh/JuliaIO/Formatting.jl
20+
[app-s-url]: https://ci.appveyor.com/project/ScottPJones/format-jl
21+
[app-m-url]: https://ci.appveyor.com/project/ScottPJones/format-jl/branch/newmaster
22+
[app-s-img]: https://ci.appveyor.com/api/projects/status/9wb580eyjv4k3iej?svg=true
23+
[app-m-img]: https://ci.appveyor.com/api/projects/status/9wb580eyjv4k3iej/branch/newmaster?svg=true
1824

19-
[pkg-0.6-img]: http://pkg.julialang.org/badges/Formatting_0.6.svg
20-
[pkg-0.6-url]: http://pkg.julialang.org/?pkg=Formatting
25+
[pkg-s-url]: http://pkg.julialang.org/?pkg=Format
26+
[pkg-m-url]: http://pkg.julialang.org/?pkg=Format
27+
[pkg-s-img]: http://pkg.julialang.org/badges/Format_0.6.svg
28+
[pkg-m-img]: http://pkg.julialang.org/badges/Format_0.7.svg
2129

22-
---------------
30+
[codecov-url]: https://codecov.io/gh/JuliaString/Format.jl
31+
[codecov-img]: https://codecov.io/gh/JuliaString/Format.jl/branch/newmaster/graph/badge.svg
2332

33+
[coverall-s-url]: https://coveralls.io/github/JuliaString/Format.jl
34+
[coverall-m-url]: https://coveralls.io/github/JuliaString/Format.jl?branch=newmaster
35+
[coverall-s-img]: https://coveralls.io/repos/github/JuliaString/Format.jl/badge.svg
36+
[coverall-m-img]: https://coveralls.io/repos/github/JuliaString/Format.jl/badge.svg?branch=newmaster
2437

2538
## Getting Started
2639

27-
This package is pure Julia. Setting up this package is like setting up other Julia packages:
28-
29-
```julia
30-
Pkg.add("Formatting")
31-
```
40+
This package is pure Julia. It is now registered, so it can be added simply with `Pkg.add("Format")`.
41+
Note: The default branch is `newmaster` instead of `master`, remember that if you wish to make a PR on this package. (It is forked off of [Formatting.jl](https://github.com/JuliaIO/Formatting.jl), and I try to keep the master branch up to date with that, and cherry pick or port all necessary changes to `Format`).
3242

3343
To start using the package, you can simply write
3444

3545
```julia
36-
using Formatting
46+
using Format
3747
```
3848

39-
This package depends on Julia of version 0.2 or above. It has no other dependencies. The package is MIT-licensed.
49+
This package depends on Julia of version 0.6 or above, and. The package is MIT-licensed.
4050

4151

4252
## Python-style Types and Functions
@@ -111,9 +121,9 @@ One can use ``printfmt`` and ``printfmtln`` for formatted printing:
111121

112122
#### Formatted String
113123

114-
One can use ``fmt`` to format a single value into a string, or ``format`` to format one to multiple arguments into a string using an format expression.
124+
One can use ``pyfmt`` to format a single value into a string, or ``format`` to format one to multiple arguments into a string using an format expression.
115125

116-
- **fmt**(fspec, a)
126+
- **pyfmt**(fspec, a)
117127

118128
Format a single value using a format specification given by ``fspec``, where ``fspec`` can be either a string or an instance of ``FormatSpec``.
119129

@@ -146,7 +156,7 @@ stripping trailing zeros, and mixed fractions.
146156
### Usage and Implementation
147157

148158
The idea here is that the package compiles a function only once for each unique
149-
format string within the `Formatting.*` name space, so repeated use is faster.
159+
format string within the `Format.*` name space, so repeated use is faster.
150160
Unrelated parts of a session using the same format string would reuse the same
151161
function, avoiding redundant compilation. To avoid the proliferation of
152162
functions, we limit the usage to only 1 argument. Practical consideration
@@ -155,10 +165,10 @@ seems manageable.
155165

156166
Usage
157167
```julia
158-
using Formatting
168+
using Format
159169
160170
fmt = "%10.3f"
161-
s = sprintf1( fmt, 3.14159 ) # usage 1. Quite performant. Easiest to switch to.
171+
s = cfmt( fmt, 3.14159 ) # usage 1. Quite performant. Easiest to switch to.
162172
163173
fmtrfunc = generate_formatter( fmt ) # usage 2. This bypass repeated lookup of cached function. Most performant.
164174
s = fmtrfunc( 3.14159 )
@@ -167,7 +177,7 @@ s = format( 3.14159, precision=3 ) # usage 3. Most flexible, with some non-print
167177
```
168178
### Speed
169179

170-
`sprintf1`: Speed penalty is about 20% for floating point and 30% for integers.
180+
`cfmt`: Speed penalty is about 20% for floating point and 30% for integers.
171181

172182
If the formatter is stored and used instead (see the example using `generate_formatter` above),
173183
the speed penalty reduces to 10% for floating point and 15% for integers.

REQUIRE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
julia 0.6
2-
Compat 0.64.0
1+
julia 0.6 2-
2+
Compat 1.0.1

src/Format.jl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
__precompile__(true)
2+
3+
module Format
4+
5+
import Base.show
6+
using Compat
7+
using Compat.Printf
8+
const V6_COMPAT = VERSION < v"0.7.0-DEV"
9+
10+
_stdout() = @static V6_COMPAT ? STDOUT : stdout
11+
_codeunits(s) = Vector{UInt8}(@static V6_COMPAT ? s : codeunits(s))
12+
@static if V6_COMPAT
13+
const m_eval = eval
14+
else
15+
m_eval(expr) = Core.eval(@__MODULE__, expr)
16+
end
17+
18+
export FormatSpec, FormatExpr, printfmt, printfmtln, format, generate_formatter
19+
export pyfmt, cfmt, fmt
20+
export fmt_default, fmt_default!, reset!, default_spec, default_spec!
21+
22+
# Deal with mess from #16058
23+
# Later, use Strs package!
24+
isdefined(Main, :ASCIIStr) || (const ASCIIStr = String)
25+
isdefined(Main, :UTF8Str) || (const UTF8Str = String)
26+
isdefined(Main, :AbstractChar) || (const AbstractChar = Char)
27+
28+
include("cformat.jl" )
29+
include("fmtspec.jl")
30+
include("fmtcore.jl")
31+
include("formatexpr.jl")
32+
include("fmt.jl")
33+
34+
end # module Format

src/Formatting.jl

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)