Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thorsummoner
ttt_terrorcon
Commits
d27a5208
Commit
d27a5208
authored
Aug 08, 2021
by
dylan grafmyre
Browse files
add new mount
parent
cd0f2826
Changes
1
Hide whitespace changes
Inline
Side-by-side
contrib/mount
View file @
d27a5208
...
...
@@ -57,6 +57,33 @@ def update_mount(buf, name, path):
return
ret
.
getvalue
()
RE_EOB
=
re
.
compile
(
r
'^(\s*\}\s*)$'
,
re
.
MULTILINE
)
def
add_mount
(
buf
,
name
,
path
):
ret
=
io
.
StringIO
()
match
=
RE_EOB
.
search
(
buf
)
if
not
match
:
raise
NotImplementedError
(
'failed to add mount, no match for {!r} on
\n\n\t
{!r}'
.
format
(
RE_EOB
,
buf
))
match_span
=
match
.
span
()
match_groups
=
match
.
groups
()
ret
.
write
(
buf
[:
match_span
[
0
]])
ret
.
write
(
'
\t
'
)
ret
.
write
(
'"{}"'
.
format
(
name
))
ret
.
write
(
'
\t
'
)
ret
.
write
(
'"{}"'
.
format
(
path
))
ret
.
write
(
'
\n
'
)
ret
.
write
(
match_groups
[
0
])
ret
.
write
(
buf
[
match_span
[
1
]:])
return
ret
.
getvalue
()
def
main_set_mount
(
argp
):
name
,
path
=
argp
.
set_mount
...
...
@@ -73,10 +100,11 @@ def main_set_mount(argp):
mbuf
=
None
if
is_update
:
mbuf
=
update_mount
(
buf
,
name
,
path
)
sanity
=
pyvmf
.
Cfg
.
loads
(
mbuf
)
else
:
# is addative
mbuf
=
add_mount
(
buf
,
name
,
path
)
sanity
=
pyvmf
.
Cfg
.
loads
(
mbuf
)
fh
.
seek
(
0
)
nbytes
=
fh
.
write
(
mbuf
)
fh
.
truncate
()
...
...
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