Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F94143755
workspace.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
Wed, Dec 4, 06:05
Size
1 KB
Mime Type
text/x-python
Expires
Fri, Dec 6, 06:05 (1 d, 11 h)
Engine
blob
Format
Raw Data
Handle
22743927
Attached To
rAKA akantu
workspace.py
View Options
__copyright__
=
(
"Copyright (©) 2021-2023 EPFL (Ecole Polytechnique Fédérale de Lausanne)"
"Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)"
)
__license__
=
"LGPLv3"
import
os
class
Workspace
:
def
__init__
(
self
,
include_paths
,
suffixes
=
[
'.c'
,
'.cpp'
,
'.cc'
,
'.cxx'
]):
self
.
_include_paths
=
include_paths
self
.
_suffixes
=
suffixes
@property
def
files
(
self
):
paths
=
self
.
_walk
()
return
[
path
for
path
in
paths
if
self
.
_should_include
(
path
)]
@property
def
include_paths
(
self
):
paths
=
self
.
_walk
()
return
[
path
for
path
in
paths
if
os
.
path
.
isdir
(
path
)]
@property
def
paths
(
self
):
return
[
path
for
path
in
self
.
_include_paths
if
self
.
_should_include
(
path
)
or
os
.
path
.
isdir
(
path
)]
def
_should_include
(
self
,
name
):
_
,
ext
=
os
.
path
.
splitext
(
name
)
return
ext
in
self
.
_suffixes
def
_walk
(
self
):
paths
=
[]
for
path
in
self
.
_include_paths
:
if
os
.
path
.
isdir
(
path
):
for
root
,
dirs
,
files
in
os
.
walk
(
path
):
paths
.
extend
(
[
os
.
path
.
join
(
root
,
dir_
)
for
dir_
in
dirs
])
paths
.
extend
(
[
os
.
path
.
join
(
root
,
file_
)
for
file_
in
files
])
else
:
paths
.
append
(
path
)
return
[
os
.
path
.
abspath
(
path
)
for
path
in
paths
]
Event Timeline
Log In to Comment