Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
b8c64d35
Commit
b8c64d35
authored
Mar 10, 2017
by
Jason Madden
Committed by
GitHub
Mar 10, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #951 from renstrom/replace-optparse-with-argparse
Replace optparse with argparse
parents
c33ebf92
a062f834
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
53 deletions
+48
-53
CHANGES.rst
CHANGES.rst
+1
-0
src/greentest/bench_spawn.py
src/greentest/bench_spawn.py
+9
-15
src/greentest/testrunner.py
src/greentest/testrunner.py
+12
-12
util/makedist.py
util/makedist.py
+5
-6
util/set_version.py
util/set_version.py
+11
-12
util/wintest.py
util/wintest.py
+10
-8
No files found.
CHANGES.rst
View file @
b8c64d35
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
on Linux. They no longer pass the socket type or protocol to
on Linux. They no longer pass the socket type or protocol to
``getaddrinfo`` when ``connect`` is called. Reported in :issue:`944`
``getaddrinfo`` when ``connect`` is called. Reported in :issue:`944`
by Bernie Hackett.
by Bernie Hackett.
- Replace ``optparse`` module with ``argparse``. See :issue:`947`.
1.2.1 (2017-01-12)
1.2.1 (2017-01-12)
==================
==================
...
...
src/greentest/bench_spawn.py
View file @
b8c64d35
...
@@ -149,25 +149,19 @@ def all_functions():
...
@@ -149,25 +149,19 @@ def all_functions():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
USAGE
=
'USAGE: python %s [--with-kwargs] [--eventlet-hub HUB] %s'
%
(
sys
.
argv
[
0
],
'|'
.
join
(
all
()))
import
argparse
if
not
sys
.
argv
[
1
:]:
parser
=
argparse
.
ArgumentParser
()
sys
.
exit
(
USAGE
)
parser
.
add_argument
(
'--with-kwargs'
,
default
=
False
,
action
=
'store_true'
)
import
optparse
parser
.
add_argument
(
'--eventlet-hub'
)
parser
=
optparse
.
OptionParser
()
parser
.
add_argument
(
'--ignore-import-errors'
,
action
=
'store_true'
)
parser
.
add_option
(
'--with-kwargs'
,
default
=
False
,
action
=
'store_true'
)
parser
.
add_argument
(
'benchmark'
,
choices
=
all
()
+
[
'all'
])
parser
.
add_option
(
'--eventlet-hub'
)
options
=
parser
.
parse_args
()
parser
.
add_option
(
'--ignore-import-errors'
,
action
=
'store_true'
)
options
,
args
=
parser
.
parse_args
()
if
options
.
with_kwargs
:
if
options
.
with_kwargs
:
options
.
kwargs
=
{
'foo'
:
1
,
'bar'
:
'hello'
}
options
.
kwargs
=
{
'foo'
:
1
,
'bar'
:
'hello'
}
else
:
else
:
options
.
kwargs
=
{}
options
.
kwargs
=
{}
if
len
(
args
)
!=
1
:
if
options
.
benchmark
==
'all'
:
sys
.
exit
(
USAGE
)
if
args
[
0
]
==
'all'
:
bench_all
(
options
)
bench_all
(
options
)
else
:
else
:
if
args
[
0
]
not
in
all
():
function
=
globals
()[
'bench_'
+
options
.
benchmark
]
sys
.
exit
(
USAGE
)
function
=
globals
()[
'bench_'
+
args
[
0
]]
function
(
options
)
function
(
options
)
src/greentest/testrunner.py
View file @
b8c64d35
...
@@ -268,17 +268,17 @@ def print_list(lst):
...
@@ -268,17 +268,17 @@ def print_list(lst):
def
main
():
def
main
():
# FIXME: transition to
argparse
import
argparse
import
optparse
# pylint:disable=deprecated-module
parser
=
argparse
.
ArgumentParser
()
parser
=
optparse
.
OptionParser
(
)
parser
.
add_argument
(
'--ignore'
)
parser
.
add_
option
(
'--ignor
e'
)
parser
.
add_
argument
(
'--discover'
,
action
=
'store_tru
e'
)
parser
.
add_
option
(
'--discover
'
,
action
=
'store_true'
)
parser
.
add_
argument
(
'--full
'
,
action
=
'store_true'
)
parser
.
add_
option
(
'--full'
,
action
=
'store_true
'
)
parser
.
add_
argument
(
'--config
'
)
parser
.
add_
option
(
'--config
'
)
parser
.
add_
argument
(
'--failfast'
,
action
=
'store_true
'
)
parser
.
add_
option
(
'--failfast'
,
action
=
'store_true'
)
parser
.
add_
argument
(
"--coverage"
,
action
=
"store_true"
)
parser
.
add_
option
(
"--coverage
"
,
action
=
"store_true"
)
parser
.
add_
argument
(
"--quiet
"
,
action
=
"store_true"
)
parser
.
add_
option
(
"--quiet"
,
action
=
"store_true"
)
parser
.
add_
argument
(
'tests'
,
nargs
=
'*'
)
options
,
args
=
parser
.
parse_args
()
options
=
parser
.
parse_args
()
FAILING_TESTS
=
[]
FAILING_TESTS
=
[]
coverage
=
False
coverage
=
False
if
options
.
coverage
or
os
.
environ
.
get
(
"GEVENTTEST_COVERAGE"
):
if
options
.
coverage
or
os
.
environ
.
get
(
"GEVENTTEST_COVERAGE"
):
...
@@ -297,7 +297,7 @@ def main():
...
@@ -297,7 +297,7 @@ def main():
config_data
=
f
.
read
()
config_data
=
f
.
read
()
six
.
exec_
(
config_data
,
config
)
six
.
exec_
(
config_data
,
config
)
FAILING_TESTS
=
config
[
'FAILING_TESTS'
]
FAILING_TESTS
=
config
[
'FAILING_TESTS'
]
tests
=
discover
(
arg
s
,
options
.
ignore
,
coverage
)
tests
=
discover
(
options
.
test
s
,
options
.
ignore
,
coverage
)
if
options
.
discover
:
if
options
.
discover
:
for
cmd
,
options
in
tests
:
for
cmd
,
options
in
tests
:
print
(
util
.
getname
(
cmd
,
env
=
options
.
get
(
'env'
),
setenv
=
options
.
get
(
'setenv'
)))
print
(
util
.
getname
(
cmd
,
env
=
options
.
get
(
'env'
),
setenv
=
options
.
get
(
'setenv'
)))
...
...
util/makedist.py
View file @
b8c64d35
...
@@ -13,7 +13,7 @@ from __future__ import print_function
...
@@ -13,7 +13,7 @@ from __future__ import print_function
import
sys
import
sys
import
os
import
os
import
glob
import
glob
import
opt
parse
import
arg
parse
from
os.path
import
exists
,
join
,
abspath
,
basename
from
os.path
import
exists
,
join
,
abspath
,
basename
from
pipes
import
quote
from
pipes
import
quote
...
@@ -76,11 +76,10 @@ def _makedist(version=None, dest=None):
...
@@ -76,11 +76,10 @@ def _makedist(version=None, dest=None):
def
main
():
def
main
():
parser
=
optparse
.
OptionParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_option
(
'--dest'
)
parser
.
add_argument
(
'--dest'
)
parser
.
add_option
(
'--version'
)
parser
.
add_argument
(
'--version'
)
options
,
args
=
parser
.
parse_args
()
options
=
parser
.
parse_args
()
assert
not
args
,
'Expected no arguments'
return
makedist
(
options
.
version
,
dest
=
options
.
dest
)
return
makedist
(
options
.
version
,
dest
=
options
.
dest
)
...
...
util/set_version.py
View file @
b8c64d35
...
@@ -9,7 +9,7 @@ from __future__ import print_function
...
@@ -9,7 +9,7 @@ from __future__ import print_function
import
sys
import
sys
import
os
import
os
import
re
import
re
from
optparse
import
Option
Parser
from
argparse
import
Argument
Parser
from
distutils.version
import
LooseVersion
from
distutils.version
import
LooseVersion
...
@@ -132,26 +132,25 @@ def write(filename, data):
...
@@ -132,26 +132,25 @@ def write(filename, data):
def main():
def main():
global options
global options
parser =
Option
Parser()
parser =
Argument
Parser()
parser.add_
option
('
--
version
', default='
dev
')
parser.add_
argument
('
--
version
', default='
dev
')
parser.add_
option
('
--
dry
-
run
', action='
store_true
')
parser.add_
argument
('
--
dry
-
run
', action='
store_true
')
options, args = parser.parse_args(
)
parser.add_argument('
filename
'
)
assert len(args) == 1, '
One
argument
is
expected
,
got
%
s
' % len(args
)
options = parser.parse_args(
)
version = options.version
version = options.version
if version.lower() == '
dev
':
if version.lower() == '
dev
':
version = ''
version = ''
if version and strict_version_re.match(version) is None:
if version and strict_version_re.match(version) is None:
sys.stderr.write('
WARNING
:
Not
a
strict
version
:
%
r
(
bdist_msi
will
fail
)
' % version)
sys.stderr.write('
WARNING
:
Not
a
strict
version
:
%
r
(
bdist_msi
will
fail
)
' % version)
filename = args[0]
original_content, new_content = modify_version(options.filename, version)
original_content, new_content = modify_version(filename, version)
if options.dry_run:
if options.dry_run:
tmpname = '
/
tmp
/
' + os.path.basename(filename) + '
.
set_version
'
tmpname = '
/
tmp
/
' + os.path.basename(
options.
filename) + '
.
set_version
'
write(tmpname, new_content)
write(tmpname, new_content)
if not os.system('
diff
-
u
%
s
%
s
' % (filename, tmpname)):
if not os.system('
diff
-
u
%
s
%
s
' % (
options.
filename, tmpname)):
sys.exit('
No
differences
applied
')
sys.exit('
No
differences
applied
')
else:
else:
write(filename, new_content)
write(
options.
filename, new_content)
print('
Updated
%
s
' % filename)
print('
Updated
%
s
' %
options.
filename)
if __name__ == '
__main__
':
if __name__ == '
__main__
':
...
...
util/wintest.py
View file @
b8c64d35
...
@@ -4,7 +4,7 @@ Unix utilities must be installed on target machine for this to work: http://unxu
...
@@ -4,7 +4,7 @@ Unix utilities must be installed on target machine for this to work: http://unxu
"""
"""
import
sys
import
sys
import
os
import
os
import
opt
parse
import
arg
parse
def
system
(
cmd
,
exit
=
True
):
def
system
(
cmd
,
exit
=
True
):
...
@@ -16,13 +16,15 @@ def system(cmd, exit=True):
...
@@ -16,13 +16,15 @@ def system(cmd, exit=True):
return
retcode
return
retcode
parser
=
optparse
.
OptionParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_option
(
'--host'
)
parser
.
add_argument
(
'--host'
)
parser
.
add_option
(
'--username'
,
default
=
'Administrator'
)
parser
.
add_argument
(
'--username'
,
default
=
'Administrator'
)
parser
.
add_option
(
'--source'
)
parser
.
add_argument
(
'--source'
)
parser
.
add_option
(
'--dist'
,
action
=
'store_true'
)
parser
.
add_argument
(
'--dist'
,
action
=
'store_true'
)
parser
.
add_option
(
'--python'
,
default
=
'27'
)
parser
.
add_argument
(
'--python'
,
default
=
'27'
)
options
,
args
=
parser
.
parse_args
()
parser
.
add_argument
(
'args'
,
nargs
=
'*'
)
options
=
parser
.
parse_args
()
args
=
options
.
args
def
prepare
():
def
prepare
():
...
...
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