Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
e5e92036
Commit
e5e92036
authored
Mar 18, 2015
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Creating script to check formatting; for now just prints diffs
parent
be10d383
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
verify_formatting.py
verify_formatting.py
+55
-0
No files found.
verify_formatting.py
0 → 100755
View file @
e5e92036
#!/usr/bin/env python3
from
__future__
import
print_function
import
sys
import
os
import
subprocess
def
hindent
(
contents
):
return
subprocess
.
check_output
([
"hindent"
,
"--style"
,
"gibiansky"
],
input
=
bytes
(
contents
,
'utf-8'
))
def
diff
(
src1
,
src2
):
with
open
(
".tmp1"
,
"w"
)
as
f1
:
f1
.
write
(
src1
)
with
open
(
".tmp2"
,
"w"
)
as
f2
:
f2
.
write
(
src2
)
return
subprocess
.
check_output
([
"diff"
,
".tmp1"
,
".tmp2"
])
# Verify that we're in the right directory
try
:
open
(
"ihaskell.cabal"
,
"r"
)
.
close
()
except
:
print
(
sys
.
argv
[
0
],
"must be run from the ihaskell directory"
,
file
=
sys
.
stderr
)
# Find all the source files
sources
=
[]
for
root
,
dirnames
,
filenames
in
os
.
walk
(
"src"
):
for
filename
in
filenames
:
if
filename
.
endswith
(
".hs"
):
sources
.
append
(
os
.
path
.
join
(
root
,
filename
))
hindent_outputs
=
{}
for
source_file
in
sources
:
print
(
"Formatting file"
,
source_file
)
with
open
(
source_file
,
"r"
)
as
f
:
original_source
=
f
.
read
()
formatted_source
=
hindent
(
original_source
)
hindent_outputs
[
source_file
]
=
(
original_source
,
formatted_source
)
diffs
=
{
filename
:
diff
(
original
,
formatted
)
for
(
filename
,
(
original
,
formatted
))
in
hindent_outputs
.
values
()}
for
filename
,
diff
in
diffs
.
items
():
print
(
filename
)
print
(
'='
*
10
)
print
(
diff
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment