Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
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
Jérome Perrin
setuptools
Commits
9624e747
Commit
9624e747
authored
Aug 02, 2000
by
Greg Ward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the 'execute()' function (moved here from cmd.py with minor tweakage).
parent
8370736a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
util.py
util.py
+26
-0
No files found.
util.py
View file @
9624e747
...
...
@@ -223,3 +223,29 @@ def split_quoted (s):
return
words
# split_quoted ()
def
execute
(
func
,
args
,
msg
=
None
,
verbose
=
0
,
dry_run
=
0
):
"""Perform some action that affects the outside world (eg. by writing
to the filesystem). Such actions are special because they are disabled
by the 'dry_run' flag, and announce themselves if 'verbose' is true.
This method takes care of all that bureaucracy for you; all you have to
do is supply the function to call and an argument tuple for it (to
embody the "external action" being performed), and an optional message
to print.
"""
# Generate a message if we weren't passed one
if
msg
is
None
:
msg
=
"%s%s"
%
(
func
.
__name__
,
`args`
)
if
msg
[
-
2
:]
==
',)'
:
# correct for singleton tuple
msg
=
msg
[
0
:
-
2
]
+
')'
# Print it if verbosity level is high enough
if
verbose
:
print
msg
# And do it, as long as we're not in dry-run mode
if
not
dry_run
:
apply
(
func
,
args
)
# execute()
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