Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
common-package
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue 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
GSHS Utilities
common-package
Merge requests
!29
Develop
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Develop
develop
into
main
Overview
0
Commits
153
Pipelines
0
Changes
1
Closed
Huihui, Jonathan
requested to merge
develop
into
main
1 year ago
Overview
0
Commits
153
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Viewing commit
1b1dc748
Prev
Next
Show latest version
1 file
+
10
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
1b1dc748
minor fixes to file operations script
· 1b1dc748
Bishnoi, Bhaskar
authored
1 year ago
src/common/file_operations.py
+
10
−
1
Options
@@ -49,7 +49,13 @@ def delete_directory(dirc=None):
if
dirc
is
not
None
:
try
:
if
path_exists
(
dirc
):
Path
(
dirc
).
rmdir
()
directory_to_delete
=
Path
(
dirc
)
for
item
in
directory_to_delete
.
iterdir
():
if
item
.
is_file
():
item
.
unlink
()
if
item
.
is_dir
():
item
.
rmdir
()
directory_to_delete
.
rmdir
()
return
f
"
{
dirc
}
deleted successfully.
"
else
:
return
f
"
{
dirc
}
does not exist.
"
@@ -125,6 +131,9 @@ def write_file(file_name, file_data=""):
"""
try
:
if
Path
(
file_name
).
suffix
==
"
.json
"
:
if
not
Path
(
file_name
).
exists
():
with
open
(
f
"
{
file_name
}
"
,
'
w
'
)
as
json_file
:
json_file
.
write
(
json
.
dumps
({}))
with
open
(
f
"
{
file_name
}
"
,
"
r+
"
)
as
file
:
file_contents
=
json
.
load
(
file
)
file_contents
.
update
(
file_data
)
Loading