Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61003926
version_info.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, May 3, 22:28
Size
2 KB
Mime Type
text/x-python
Expires
Sun, May 5, 22:28 (2 d)
Engine
blob
Format
Raw Data
Handle
17451890
Attached To
R11434 py-licenser
version_info.py
View Options
# -*- coding: utf-8 -*-
""" version_info.py: Base class for interaction with version control system"""
__author__
=
"Guillaume Anciaux and Nicolas Richart"
__credits__
=
[
"Guillaume Anciaux <guillaume.anciaux@epfl.ch>"
,
"Nicolas Richart <nicolas.richart@epfl.ch>"
,
]
__copyright__
=
"Copyright (©) 2010-2021 EPFL (Ecole Polytechnique Fédérale"
\
" de Lausanne) Laboratory (LSMS - Laboratoire de Simulation"
\
" en Mécanique des Solides)"
__license__
=
"GPLv3"
__version__
=
"2.0"
from
.
import
print_colored
from
.
import
export
import
os
@export
class
VersionInfo
:
"""Generic class handling the communication with the versioning system"""
# members
_authors
=
set
()
_author_list
=
dict
()
_modification_dates
=
[]
_name
=
""
_repo
=
""
_filename
=
""
_revisions
=
[]
_names
=
dict
()
def
__new__
(
cls
,
repo
,
filename
,
authors_ignore_list
=
[],
backend
=
None
,
**
kwargs
):
"""
Factory constructor depending on the chosen backend
"""
if
backend
==
'svn'
:
from
.vcs
import
svn
return
super
()
.
__new__
(
svn
.
SVNInfo
)
elif
backend
==
'git'
:
from
.vcs
import
git
return
super
()
.
__new__
(
git
.
GITInfo
)
else
:
raise
Exception
(
"{0} not a known backend"
.
format
(
backend
))
# noinspection PyUnusedLocal
def
__init__
(
self
,
repo
,
filename
,
authors_ignore_list
=
[],
**
kwargs
):
self
.
_repo
=
os
.
path
.
expanduser
(
repo
)
self
.
_filename
=
os
.
path
.
expanduser
(
filename
)
self
.
_authors_ignore_list
=
authors_ignore_list
@property
def
creation_date
(
self
):
if
len
(
self
.
_modification_dates
)
>
0
:
return
min
(
self
.
_modification_dates
)
@property
def
last_modification_date
(
self
):
if
len
(
self
.
_modification_dates
)
>
0
:
return
max
(
self
.
_modification_dates
)
@property
def
authors
(
self
):
return
self
.
_authors
def
number_of_modifications
(
self
,
author
):
return
len
(
self
.
_author_list
[
author
])
def
modifications_by_author
(
self
,
author
):
auth
=
self
.
_author_list
[
author
]
res
=
[]
stats
=
{}
for
d
,
r
,
msg
in
auth
:
date
=
d
.
strftime
(
"
%d
-%m-%Y"
)
info
=
print_colored
(
"@ {0} rev {1} msg {2}"
.
format
(
date
,
r
,
msg
),
'blue'
,
attrs
=
[
'bold'
])
modif
,
_stats
=
self
.
get_modifications
(
r
)
for
k
,
v
in
_stats
.
items
():
if
k
in
stats
:
stats
[
k
]
+=
v
else
:
stats
[
k
]
=
v
res
.
append
([
info
,
modif
,
modif
.
split
(
"
\n
"
),
_stats
])
return
res
,
stats
@property
def
name
(
self
):
return
self
.
_name
@property
def
oldest_name
(
self
):
return
self
.
_name
def
get_modifications
(
self
,
revision
):
pass
Event Timeline
Log In to Comment