Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sign-file-tree
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cython-plus
sign-file-tree
Commits
0ac2fa10
Commit
0ac2fa10
authored
Oct 14, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use os.walk in main.py
parent
e8c85e47
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
1 deletion
+49
-1
main.py
main.py
+49
-1
No files found.
main.py
View file @
0ac2fa10
...
...
@@ -132,7 +132,7 @@ class SymlinkNode:
result
[
self
.
path
]
=
self
.
data
def
main
(
path
=
'.'
):
def
main
2
(
path
=
'.'
):
global
scheduler
scheduler
=
Scheduler
()
...
...
@@ -147,6 +147,54 @@ def main(path='.'):
json
.
dump
(
result
,
sys
.
stdout
,
indent
=
2
,
separators
=
(
','
,
': '
))
def
task
(
path
):
try
:
stat_result
=
os
.
stat
(
path
)
if
stat
.
S_ISREG
(
stat_result
.
st_mode
):
data
=
compute_hash
(
path
)
else
:
data
=
{}
data
[
'stat'
]
=
stat_to_dict
(
stat_result
)
return
data
except
Exception
:
return
{}
def
walk
(
path
):
class
Getter
:
def
__init__
(
self
,
data
):
self
.
data
=
data
def
get
(
self
):
return
self
.
data
result
=
{}
for
dirpath
,
_
,
filenames
in
os
.
walk
(
path
):
result
[
dirpath
]
=
Getter
({
'stat'
:
stat_to_dict
(
os
.
stat
(
dirpath
)),
})
for
filename
in
filenames
:
filepath
=
os
.
path
.
join
(
dirpath
,
filename
)
result
[
filepath
]
=
scheduler
.
submit
(
task
,
filepath
)
return
result
def
main
(
path
=
'.'
):
global
scheduler
scheduler
=
Scheduler
()
result
=
walk
(
path
)
scheduler
.
join
()
result
=
{
k
:
v
.
get
()
for
k
,
v
in
result
.
items
()}
json
.
dump
(
result
,
sys
.
stdout
,
indent
=
2
,
separators
=
(
','
,
': '
))
if
__name__
==
"__main__"
:
if
len
(
sys
.
argv
)
==
2
:
main
(
sys
.
argv
[
1
])
...
...
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