Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
6f52a749
Commit
6f52a749
authored
8 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
further refactoring of cl_lines_of_code.py
parent
15eb60cb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dev-tools/git-utils/cl_lines_of_code.py
+41
-32
41 additions, 32 deletions
dev-tools/git-utils/cl_lines_of_code.py
with
41 additions
and
32 deletions
dev-tools/git-utils/cl_lines_of_code.py
+
41
−
32
View file @
6f52a749
...
...
@@ -15,11 +15,27 @@
import
datetime
,
email
.
utils
,
optparse
,
os
,
re
,
sys
,
time
def
append_to_history
():
if
adds
is
None
:
return
# print( "%s %8u %5s %5s %7s %s \t%s"%(d,locs,'+'+str(adds),'-'+str(dels),hsh,who,cmt.strip()) )
history
.
append
((
d
,
locs
,
list
(
locs_type
),
adds
,
dels
,
hsh
,
who
,
cmt
))
# ------------------------------------------------------------------------------
# categorize files
# ------------------------------------------------------------------------------
def
filetype
(
x
):
file_type
=
8
if
dirSkip
(
x
):
return
file_type
if
fileCpp
(
x
)
and
dirCore
(
x
):
file_type
=
0
elif
(
fileCpp
(
x
)
or
filePython
(
x
))
and
dirFuncTest
(
x
):
file_type
=
1
elif
dirUnitTests
(
x
):
file_type
=
2
elif
dirGUI
(
x
):
file_type
=
5
elif
dirPyAPI
(
x
):
file_type
=
6
elif
dirThirdParty
(
x
):
file_type
=
7
return
file_type
def
filePython
(
x
):
if
"
.py
"
in
x
and
not
"
.pypp.
"
in
x
:
return
True
...
...
@@ -78,30 +94,25 @@ def dirUnitTests(x):
if
"
/Tests/UnitTests/TestFit/
"
in
x
:
return
True
return
False
def
filetype
(
x
):
file_type
=
8
if
dirSkip
(
x
):
return
file_type
if
fileCpp
(
x
)
and
dirCore
(
x
):
file_type
=
0
elif
(
fileCpp
(
x
)
or
filePython
(
x
))
and
dirFuncTest
(
x
):
file_type
=
1
elif
dirUnitTests
(
x
):
file_type
=
2
elif
dirGUI
(
x
):
file_type
=
5
elif
dirPyAPI
(
x
):
file_type
=
6
elif
dirThirdParty
(
x
):
file_type
=
7
return
file_type
# ------------------------------------------------------------------------------
#
# ------------------------------------------------------------------------------
def
append_to_history
():
if
adds
is
None
:
return
# print( "%s %8u %5s %5s %7s %s \t%s"%(d,locs,'+'+str(adds),'-'+str(dels),hsh,who,cmt.strip()) )
history
.
append
((
d
,
locs
,
list
(
locs_type
),
adds
,
dels
,
hsh
,
who
,
cmt
))
def
save_history_as_table
(
fname
):
f
=
open
(
fname
,
'
w
'
)
for
entry
in
history
:
d
=
entry
[
0
]
tim
=
2012
+
(
d
-
datetime
.
datetime
(
2012
,
1
,
1
)).
total_seconds
()
/
366.0
/
24
/
3600
f
.
write
(
"
%9.4f %s
\n
"
%
(
tim
,
entry
[
1
:]
)
)
f
.
write
(
"
%9.4f
"
%
(
tim
)
)
for
i
in
entry
[
2
]
+
[
entry
[
1
]]:
f
.
write
(
"
%6i
"
%
(
i
)
)
f
.
write
(
"
# %s %s
\n
"
%
(
entry
[
5
],
entry
[
7
]
)
)
f
.
close
()
print
(
"
Table with one line per commit written to
"
+
fname
)
...
...
@@ -114,14 +125,12 @@ parser.add_option('-o', '--output-filename', type="string", action="store", dest
parser
.
add_option
(
'
-i
'
,
'
--input-dir
'
,
type
=
"
string
"
,
action
=
"
store
"
,
dest
=
"
gitdir
"
,
help
=
"
Path to the .git folder.
"
,
default
=
"
.
"
)
(
options
,
args
)
=
parser
.
parse_args
()
extfolder
=
True
targetfolder
=
options
.
gitdir
# 0 1 2 3 4 5 6 7 8
descr
=
[
"
Core
"
,
"
Functional Tests
"
,
"
Unit Tests
"
,
"
*.py
"
,
"
macros
"
,
"
GUI
"
,
"
PythonAPI
"
,
"
Third
"
,
"
Undef
"
]
fc
=
0
locs
=
0
locs_type
=
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
]
locs_type
=
[
0
for
cat
in
descr
]
# 0 1 2 3 4 5 6 7 8
descr
=
[
"
Core
"
,
"
Functional Tests
"
,
"
Unit Tests
"
,
"
*.py
"
,
"
macros
"
,
"
GUI
"
,
"
PythonAPI
"
,
"
Third
"
,
"
Undef
"
]
adds
=
None
cmt
=
None
prev_time
=
datetime
.
datetime
(
2000
,
1
,
1
)
...
...
@@ -129,13 +138,13 @@ prev_time = datetime.datetime(2000,1,1)
history
=
[]
prevfolder
=
os
.
getcwd
()
if
extfolder
:
os
.
chdir
(
targetfolde
r
)
os
.
chdir
(
options
.
gitdi
r
)
# parsing output of git log
file_type_ppp
=
8
file_type_mmm
=
8
for
x
in
os
.
popen
(
'
git log develop --reverse -p
'
):
for
x
in
os
.
popen
(
'
git log develop
--no-renames
--reverse -p
'
):
if
x
.
startswith
(
'
commit
'
):
append_to_history
()
hsh
=
x
[
7
:
14
];
...
...
@@ -154,8 +163,8 @@ for x in os.popen('git log develop --reverse -p'):
sys
.
stdout
.
write
(
'
\r
'
)
sys
.
stdout
.
flush
()
# accelerate development
if
(
d
.
year
!=
2012
):
break
#
if( d.year!=2012 ):
#
break
if
fc
==
2
:
cmt
=
x
[:
-
1
]
fc
=
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment