Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-scripts
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yuya Nishihara
qt-scripts
Commits
8fc76a0d
Commit
8fc76a0d
authored
3 years ago
by
Yuya Nishihara
Browse files
Options
Downloads
Patches
Plain Diff
add script to update .pyproject file
parent
72a71b04
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
update-pyproject.py
+55
-0
55 additions, 0 deletions
update-pyproject.py
with
55 additions
and
0 deletions
update-pyproject.py
0 → 100755
+
55
−
0
View file @
8fc76a0d
#!/usr/bin/env python3
import
argparse
import
fnmatch
import
json
import
os
import
re
import
sys
def
collect_files
(
paths
,
include_pat
):
for
top
in
paths
:
if
not
os
.
path
.
isdir
(
top
):
if
not
include_pat
.
match
(
top
):
continue
yield
top
continue
for
root
,
_dirs
,
files
in
os
.
walk
(
top
):
for
f
in
files
:
if
not
include_pat
.
match
(
f
):
continue
yield
os
.
path
.
join
(
root
,
f
)
def
dump_json
(
data
,
f
):
json
.
dump
(
data
,
f
,
indent
=
4
,
sort_keys
=
True
)
f
.
write
(
'
\n
'
)
def
main
():
ap
=
argparse
.
ArgumentParser
()
ap
.
add_argument
(
'
-I
'
,
'
--include
'
,
action
=
'
append
'
)
ap
.
add_argument
(
'
-o
'
,
'
--output
'
)
ap
.
add_argument
(
'
paths
'
,
nargs
=
'
+
'
)
args
=
ap
.
parse_args
()
if
args
.
include
:
include_pat
=
re
.
compile
(
'
|
'
.
join
(
'
(?:%s)
'
%
fnmatch
.
translate
(
p
)
for
p
in
args
.
include
))
else
:
include_pat
=
re
.
compile
(
r
'
.*
'
)
files
=
sorted
(
map
(
os
.
path
.
relpath
,
collect_files
(
args
.
paths
,
include_pat
)))
data
=
{}
if
args
.
output
:
with
open
(
args
.
output
,
'
r
'
)
as
f
:
data
.
update
(
json
.
load
(
f
))
data
[
'
files
'
]
=
files
if
args
.
output
:
with
open
(
args
.
output
+
'
.new
'
,
'
w
'
)
as
f
:
dump_json
(
data
,
f
)
os
.
rename
(
args
.
output
+
'
.new
'
,
args
.
output
)
else
:
dump_json
(
data
,
sys
.
stdout
)
if
__name__
==
'
__main__
'
:
main
()
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