Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
fa3178a6
Commit
fa3178a6
authored
Sep 26, 2000
by
Greg Ward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Standardize whitespace in function calls.
parent
b2a1b0db
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
92 deletions
+92
-92
Lib/distutils/core.py
Lib/distutils/core.py
+3
-3
Lib/distutils/unixccompiler.py
Lib/distutils/unixccompiler.py
+52
-52
Lib/distutils/util.py
Lib/distutils/util.py
+12
-12
Lib/distutils/version.py
Lib/distutils/version.py
+25
-25
No files found.
Lib/distutils/core.py
View file @
fa3178a6
...
@@ -84,7 +84,7 @@ def setup (**attrs):
...
@@ -84,7 +84,7 @@ def setup (**attrs):
# Determine the distribution class -- either caller-supplied or
# Determine the distribution class -- either caller-supplied or
# our Distribution (see below).
# our Distribution (see below).
klass
=
attrs
.
get
(
'distclass'
)
klass
=
attrs
.
get
(
'distclass'
)
if
klass
:
if
klass
:
del
attrs
[
'distclass'
]
del
attrs
[
'distclass'
]
else
:
else
:
...
@@ -98,7 +98,7 @@ def setup (**attrs):
...
@@ -98,7 +98,7 @@ def setup (**attrs):
# Create the Distribution instance, using the remaining arguments
# Create the Distribution instance, using the remaining arguments
# (ie. everything except distclass) to initialize it
# (ie. everything except distclass) to initialize it
try
:
try
:
_setup_distribution
=
dist
=
klass
(
attrs
)
_setup_distribution
=
dist
=
klass
(
attrs
)
except
DistutilsSetupError
,
msg
:
except
DistutilsSetupError
,
msg
:
raise
SystemExit
,
"error in setup script: %s"
%
msg
raise
SystemExit
,
"error in setup script: %s"
%
msg
...
@@ -135,7 +135,7 @@ def setup (**attrs):
...
@@ -135,7 +135,7 @@ def setup (**attrs):
# And finally, run all the commands found on the command line.
# And finally, run all the commands found on the command line.
if
ok
:
if
ok
:
try
:
try
:
dist
.
run_commands
()
dist
.
run_commands
()
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
raise
SystemExit
,
"interrupted"
raise
SystemExit
,
"interrupted"
except
(
IOError
,
os
.
error
),
exc
:
except
(
IOError
,
os
.
error
),
exc
:
...
...
Lib/distutils/unixccompiler.py
View file @
fa3178a6
...
@@ -91,8 +91,8 @@ class UnixCCompiler (CCompiler):
...
@@ -91,8 +91,8 @@ class UnixCCompiler (CCompiler):
extra_postargs
=
None
):
extra_postargs
=
None
):
(
_
,
macros
,
include_dirs
)
=
\
(
_
,
macros
,
include_dirs
)
=
\
self
.
_fix_compile_args
(
None
,
macros
,
include_dirs
)
self
.
_fix_compile_args
(
None
,
macros
,
include_dirs
)
pp_opts
=
gen_preprocess_options
(
macros
,
include_dirs
)
pp_opts
=
gen_preprocess_options
(
macros
,
include_dirs
)
pp_args
=
self
.
preprocessor
+
pp_opts
pp_args
=
self
.
preprocessor
+
pp_opts
if
output_file
:
if
output_file
:
pp_args
.
extend
([
'-o'
,
output_file
])
pp_args
.
extend
([
'-o'
,
output_file
])
...
@@ -108,7 +108,7 @@ class UnixCCompiler (CCompiler):
...
@@ -108,7 +108,7 @@ class UnixCCompiler (CCompiler):
if
output_file
:
if
output_file
:
self
.
mkpath
(
os
.
path
.
dirname
(
output_file
))
self
.
mkpath
(
os
.
path
.
dirname
(
output_file
))
try
:
try
:
self
.
spawn
(
pp_args
)
self
.
spawn
(
pp_args
)
except
DistutilsExecError
,
msg
:
except
DistutilsExecError
,
msg
:
raise
CompileError
,
msg
raise
CompileError
,
msg
...
@@ -123,11 +123,11 @@ class UnixCCompiler (CCompiler):
...
@@ -123,11 +123,11 @@ class UnixCCompiler (CCompiler):
extra_postargs
=
None
):
extra_postargs
=
None
):
(
output_dir
,
macros
,
include_dirs
)
=
\
(
output_dir
,
macros
,
include_dirs
)
=
\
self
.
_fix_compile_args
(
output_dir
,
macros
,
include_dirs
)
self
.
_fix_compile_args
(
output_dir
,
macros
,
include_dirs
)
(
objects
,
skip_sources
)
=
self
.
_prep_compile
(
sources
,
output_dir
)
(
objects
,
skip_sources
)
=
self
.
_prep_compile
(
sources
,
output_dir
)
# Figure out the options for the compiler command line.
# Figure out the options for the compiler command line.
pp_opts
=
gen_preprocess_options
(
macros
,
include_dirs
)
pp_opts
=
gen_preprocess_options
(
macros
,
include_dirs
)
cc_args
=
pp_opts
+
[
'-c'
]
cc_args
=
pp_opts
+
[
'-c'
]
if
debug
:
if
debug
:
cc_args
[:
0
]
=
[
'-g'
]
cc_args
[:
0
]
=
[
'-g'
]
...
@@ -138,14 +138,14 @@ class UnixCCompiler (CCompiler):
...
@@ -138,14 +138,14 @@ class UnixCCompiler (CCompiler):
# Compile all source files that weren't eliminated by
# Compile all source files that weren't eliminated by
# '_prep_compile()'.
# '_prep_compile()'.
for
i
in
range
(
len
(
sources
)):
for
i
in
range
(
len
(
sources
)):
src
=
sources
[
i
]
;
obj
=
objects
[
i
]
src
=
sources
[
i
]
;
obj
=
objects
[
i
]
if
skip_sources
[
src
]:
if
skip_sources
[
src
]:
self
.
announce
(
"skipping %s (%s up-to-date)"
%
(
src
,
obj
))
self
.
announce
(
"skipping %s (%s up-to-date)"
%
(
src
,
obj
))
else
:
else
:
self
.
mkpath
(
os
.
path
.
dirname
(
obj
))
self
.
mkpath
(
os
.
path
.
dirname
(
obj
))
try
:
try
:
self
.
spawn
(
self
.
compiler_so
+
cc_args
+
self
.
spawn
(
self
.
compiler_so
+
cc_args
+
[
src
,
'-o'
,
obj
]
+
[
src
,
'-o'
,
obj
]
+
extra_postargs
)
extra_postargs
)
except
DistutilsExecError
,
msg
:
except
DistutilsExecError
,
msg
:
...
@@ -163,14 +163,14 @@ class UnixCCompiler (CCompiler):
...
@@ -163,14 +163,14 @@ class UnixCCompiler (CCompiler):
output_dir
=
None
,
output_dir
=
None
,
debug
=
0
):
debug
=
0
):
(
objects
,
output_dir
)
=
self
.
_fix_object_args
(
objects
,
output_dir
)
(
objects
,
output_dir
)
=
self
.
_fix_object_args
(
objects
,
output_dir
)
output_filename
=
\
output_filename
=
\
self
.
library_filename
(
output_libname
,
output_dir
=
output_dir
)
self
.
library_filename
(
output_libname
,
output_dir
=
output_dir
)
if
self
.
_need_link
(
objects
,
output_filename
):
if
self
.
_need_link
(
objects
,
output_filename
):
self
.
mkpath
(
os
.
path
.
dirname
(
output_filename
))
self
.
mkpath
(
os
.
path
.
dirname
(
output_filename
))
self
.
spawn
(
self
.
archiver
+
self
.
spawn
(
self
.
archiver
+
[
output_filename
]
+
[
output_filename
]
+
objects
+
self
.
objects
)
objects
+
self
.
objects
)
...
@@ -181,11 +181,11 @@ class UnixCCompiler (CCompiler):
...
@@ -181,11 +181,11 @@ class UnixCCompiler (CCompiler):
# it for us, hence the check for leading colon.
# it for us, hence the check for leading colon.
if
self
.
ranlib
:
if
self
.
ranlib
:
try
:
try
:
self
.
spawn
(
self
.
ranlib
+
[
output_filename
])
self
.
spawn
(
self
.
ranlib
+
[
output_filename
])
except
DistutilsExecError
,
msg
:
except
DistutilsExecError
,
msg
:
raise
LibError
,
msg
raise
LibError
,
msg
else
:
else
:
self
.
announce
(
"skipping %s (up-to-date)"
%
output_filename
)
self
.
announce
(
"skipping %s (up-to-date)"
%
output_filename
)
# create_static_lib ()
# create_static_lib ()
...
@@ -203,9 +203,9 @@ class UnixCCompiler (CCompiler):
...
@@ -203,9 +203,9 @@ class UnixCCompiler (CCompiler):
extra_postargs
=
None
,
extra_postargs
=
None
,
build_temp
=
None
):
build_temp
=
None
):
self
.
link_shared_object
(
self
.
link_shared_object
(
objects
,
objects
,
self
.
library_filename
(
output_libname
,
lib_type
=
'shared'
),
self
.
library_filename
(
output_libname
,
lib_type
=
'shared'
),
output_dir
,
output_dir
,
libraries
,
libraries
,
library_dirs
,
library_dirs
,
...
@@ -230,19 +230,19 @@ class UnixCCompiler (CCompiler):
...
@@ -230,19 +230,19 @@ class UnixCCompiler (CCompiler):
extra_postargs
=
None
,
extra_postargs
=
None
,
build_temp
=
None
):
build_temp
=
None
):
(
objects
,
output_dir
)
=
self
.
_fix_object_args
(
objects
,
output_dir
)
(
objects
,
output_dir
)
=
self
.
_fix_object_args
(
objects
,
output_dir
)
(
libraries
,
library_dirs
,
runtime_library_dirs
)
=
\
(
libraries
,
library_dirs
,
runtime_library_dirs
)
=
\
self
.
_fix_lib_args
(
libraries
,
library_dirs
,
runtime_library_dirs
)
self
.
_fix_lib_args
(
libraries
,
library_dirs
,
runtime_library_dirs
)
lib_opts
=
gen_lib_options
(
self
,
lib_opts
=
gen_lib_options
(
self
,
library_dirs
,
runtime_library_dirs
,
library_dirs
,
runtime_library_dirs
,
libraries
)
libraries
)
if
type
(
output_dir
)
not
in
(
StringType
,
NoneType
):
if
type
(
output_dir
)
not
in
(
StringType
,
NoneType
):
raise
TypeError
,
"'output_dir' must be a string or None"
raise
TypeError
,
"'output_dir' must be a string or None"
if
output_dir
is
not
None
:
if
output_dir
is
not
None
:
output_filename
=
os
.
path
.
join
(
output_dir
,
output_filename
)
output_filename
=
os
.
path
.
join
(
output_dir
,
output_filename
)
if
self
.
_need_link
(
objects
,
output_filename
):
if
self
.
_need_link
(
objects
,
output_filename
):
ld_args
=
(
objects
+
self
.
objects
+
ld_args
=
(
objects
+
self
.
objects
+
lib_opts
+
[
'-o'
,
output_filename
])
lib_opts
+
[
'-o'
,
output_filename
])
if
debug
:
if
debug
:
...
@@ -250,14 +250,14 @@ class UnixCCompiler (CCompiler):
...
@@ -250,14 +250,14 @@ class UnixCCompiler (CCompiler):
if
extra_preargs
:
if
extra_preargs
:
ld_args
[:
0
]
=
extra_preargs
ld_args
[:
0
]
=
extra_preargs
if
extra_postargs
:
if
extra_postargs
:
ld_args
.
extend
(
extra_postargs
)
ld_args
.
extend
(
extra_postargs
)
self
.
mkpath
(
os
.
path
.
dirname
(
output_filename
))
self
.
mkpath
(
os
.
path
.
dirname
(
output_filename
))
try
:
try
:
self
.
spawn
(
self
.
linker_so
+
ld_args
)
self
.
spawn
(
self
.
linker_so
+
ld_args
)
except
DistutilsExecError
,
msg
:
except
DistutilsExecError
,
msg
:
raise
LinkError
,
msg
raise
LinkError
,
msg
else
:
else
:
self
.
announce
(
"skipping %s (up-to-date)"
%
output_filename
)
self
.
announce
(
"skipping %s (up-to-date)"
%
output_filename
)
# link_shared_object ()
# link_shared_object ()
...
@@ -273,32 +273,32 @@ class UnixCCompiler (CCompiler):
...
@@ -273,32 +273,32 @@ class UnixCCompiler (CCompiler):
extra_preargs
=
None
,
extra_preargs
=
None
,
extra_postargs
=
None
):
extra_postargs
=
None
):
(
objects
,
output_dir
)
=
self
.
_fix_object_args
(
objects
,
output_dir
)
(
objects
,
output_dir
)
=
self
.
_fix_object_args
(
objects
,
output_dir
)
(
libraries
,
library_dirs
,
runtime_library_dirs
)
=
\
(
libraries
,
library_dirs
,
runtime_library_dirs
)
=
\
self
.
_fix_lib_args
(
libraries
,
library_dirs
,
runtime_library_dirs
)
self
.
_fix_lib_args
(
libraries
,
library_dirs
,
runtime_library_dirs
)
lib_opts
=
gen_lib_options
(
self
,
lib_opts
=
gen_lib_options
(
self
,
library_dirs
,
runtime_library_dirs
,
library_dirs
,
runtime_library_dirs
,
libraries
)
libraries
)
output_filename
=
output_progname
# Unix-ism!
output_filename
=
output_progname
# Unix-ism!
if
output_dir
is
not
None
:
if
output_dir
is
not
None
:
output_filename
=
os
.
path
.
join
(
output_dir
,
output_filename
)
output_filename
=
os
.
path
.
join
(
output_dir
,
output_filename
)
if
self
.
_need_link
(
objects
,
output_filename
):
if
self
.
_need_link
(
objects
,
output_filename
):
ld_args
=
objects
+
self
.
objects
+
lib_opts
+
[
'-o'
,
output_filename
]
ld_args
=
objects
+
self
.
objects
+
lib_opts
+
[
'-o'
,
output_filename
]
if
debug
:
if
debug
:
ld_args
[:
0
]
=
[
'-g'
]
ld_args
[:
0
]
=
[
'-g'
]
if
extra_preargs
:
if
extra_preargs
:
ld_args
[:
0
]
=
extra_preargs
ld_args
[:
0
]
=
extra_preargs
if
extra_postargs
:
if
extra_postargs
:
ld_args
.
extend
(
extra_postargs
)
ld_args
.
extend
(
extra_postargs
)
self
.
mkpath
(
os
.
path
.
dirname
(
output_filename
))
self
.
mkpath
(
os
.
path
.
dirname
(
output_filename
))
try
:
try
:
self
.
spawn
(
self
.
linker_exe
+
ld_args
)
self
.
spawn
(
self
.
linker_exe
+
ld_args
)
except
DistutilsExecError
,
msg
:
except
DistutilsExecError
,
msg
:
raise
LinkError
,
msg
raise
LinkError
,
msg
else
:
else
:
self
.
announce
(
"skipping %s (up-to-date)"
%
output_filename
)
self
.
announce
(
"skipping %s (up-to-date)"
%
output_filename
)
# link_executable ()
# link_executable ()
...
@@ -320,18 +320,18 @@ class UnixCCompiler (CCompiler):
...
@@ -320,18 +320,18 @@ class UnixCCompiler (CCompiler):
def
find_library_file
(
self
,
dirs
,
lib
,
debug
=
0
):
def
find_library_file
(
self
,
dirs
,
lib
,
debug
=
0
):
for
dir
in
dirs
:
for
dir
in
dirs
:
shared
=
os
.
path
.
join
(
shared
=
os
.
path
.
join
(
dir
,
self
.
library_filename
(
lib
,
lib_type
=
'shared'
))
dir
,
self
.
library_filename
(
lib
,
lib_type
=
'shared'
))
static
=
os
.
path
.
join
(
static
=
os
.
path
.
join
(
dir
,
self
.
library_filename
(
lib
,
lib_type
=
'static'
))
dir
,
self
.
library_filename
(
lib
,
lib_type
=
'static'
))
# We're second-guessing the linker here, with not much hard
# We're second-guessing the linker here, with not much hard
# data to go on: GCC seems to prefer the shared library, so I'm
# data to go on: GCC seems to prefer the shared library, so I'm
# assuming that *all* Unix C compilers do. And of course I'm
# assuming that *all* Unix C compilers do. And of course I'm
# ignoring even GCC's "-static" option. So sue me.
# ignoring even GCC's "-static" option. So sue me.
if
os
.
path
.
exists
(
shared
):
if
os
.
path
.
exists
(
shared
):
return
shared
return
shared
elif
os
.
path
.
exists
(
static
):
elif
os
.
path
.
exists
(
static
):
return
static
return
static
else
:
else
:
...
...
Lib/distutils/util.py
View file @
fa3178a6
...
@@ -88,16 +88,16 @@ def change_root (new_root, pathname):
...
@@ -88,16 +88,16 @@ def change_root (new_root, pathname):
two, which is tricky on DOS/Windows and Mac OS.
two, which is tricky on DOS/Windows and Mac OS.
"""
"""
if
os
.
name
==
'posix'
:
if
os
.
name
==
'posix'
:
if
not
os
.
path
.
isabs
(
pathname
):
if
not
os
.
path
.
isabs
(
pathname
):
return
os
.
path
.
join
(
new_root
,
pathname
)
return
os
.
path
.
join
(
new_root
,
pathname
)
else
:
else
:
return
os
.
path
.
join
(
new_root
,
pathname
[
1
:])
return
os
.
path
.
join
(
new_root
,
pathname
[
1
:])
elif
os
.
name
==
'nt'
:
elif
os
.
name
==
'nt'
:
(
drive
,
path
)
=
os
.
path
.
splitdrive
(
pathname
)
(
drive
,
path
)
=
os
.
path
.
splitdrive
(
pathname
)
if
path
[
0
]
==
'
\
\
'
:
if
path
[
0
]
==
'
\
\
'
:
path
=
path
[
1
:]
path
=
path
[
1
:]
return
os
.
path
.
join
(
new_root
,
path
)
return
os
.
path
.
join
(
new_root
,
path
)
elif
os
.
name
==
'mac'
:
elif
os
.
name
==
'mac'
:
if
not
os
.
path
.
isabs
(
pathname
):
if
not
os
.
path
.
isabs
(
pathname
):
...
@@ -129,10 +129,10 @@ def check_environ ():
...
@@ -129,10 +129,10 @@ def check_environ ():
if
os
.
name
==
'posix'
and
not
os
.
environ
.
has_key
(
'HOME'
):
if
os
.
name
==
'posix'
and
not
os
.
environ
.
has_key
(
'HOME'
):
import
pwd
import
pwd
os
.
environ
[
'HOME'
]
=
pwd
.
getpwuid
(
os
.
getuid
())[
5
]
os
.
environ
[
'HOME'
]
=
pwd
.
getpwuid
(
os
.
getuid
())[
5
]
if
not
os
.
environ
.
has_key
(
'PLAT'
):
if
not
os
.
environ
.
has_key
(
'PLAT'
):
os
.
environ
[
'PLAT'
]
=
get_platform
()
os
.
environ
[
'PLAT'
]
=
get_platform
()
_environ_checked
=
1
_environ_checked
=
1
...
@@ -147,15 +147,15 @@ def subst_vars (str, local_vars):
...
@@ -147,15 +147,15 @@ def subst_vars (str, local_vars):
'_check_environ()'. Raise ValueError for any variables not found in
'_check_environ()'. Raise ValueError for any variables not found in
either 'local_vars' or 'os.environ'."""
either 'local_vars' or 'os.environ'."""
check_environ
()
check_environ
()
def
_subst
(
match
,
local_vars
=
local_vars
):
def
_subst
(
match
,
local_vars
=
local_vars
):
var_name
=
match
.
group
(
1
)
var_name
=
match
.
group
(
1
)
if
local_vars
.
has_key
(
var_name
):
if
local_vars
.
has_key
(
var_name
):
return
str
(
local_vars
[
var_name
])
return
str
(
local_vars
[
var_name
])
else
:
else
:
return
os
.
environ
[
var_name
]
return
os
.
environ
[
var_name
]
return
re
.
sub
(
r'\
$([
a-zA-Z_][a-zA-Z_0-9]*)'
,
_subst
,
str
)
return
re
.
sub
(
r'\
$([
a-zA-Z_][a-zA-Z_0-9]*)'
,
_subst
,
str
)
# subst_vars ()
# subst_vars ()
...
@@ -169,7 +169,7 @@ def grok_environment_error (exc, prefix="error: "):
...
@@ -169,7 +169,7 @@ def grok_environment_error (exc, prefix="error: "):
prefixed with 'prefix'.
prefixed with 'prefix'.
"""
"""
# check for Python 1.5.2-style {IO,OS}Error exception objects
# check for Python 1.5.2-style {IO,OS}Error exception objects
if
hasattr
(
exc
,
'filename'
)
and
hasattr
(
exc
,
'strerror'
):
if
hasattr
(
exc
,
'filename'
)
and
hasattr
(
exc
,
'strerror'
):
if
exc
.
filename
:
if
exc
.
filename
:
error
=
prefix
+
"%s: %s"
%
(
exc
.
filename
,
exc
.
strerror
)
error
=
prefix
+
"%s: %s"
%
(
exc
.
filename
,
exc
.
strerror
)
else
:
else
:
...
...
Lib/distutils/version.py
View file @
fa3178a6
...
@@ -39,10 +39,10 @@ class Version:
...
@@ -39,10 +39,10 @@ class Version:
def
__init__
(
self
,
vstring
=
None
):
def
__init__
(
self
,
vstring
=
None
):
if
vstring
:
if
vstring
:
self
.
parse
(
vstring
)
self
.
parse
(
vstring
)
def
__repr__
(
self
):
def
__repr__
(
self
):
return
"%s ('%s')"
%
(
self
.
__class__
.
__name__
,
str
(
self
))
return
"%s ('%s')"
%
(
self
.
__class__
.
__name__
,
str
(
self
))
# Interface for version-number classes -- must be implemented
# Interface for version-number classes -- must be implemented
...
@@ -99,25 +99,25 @@ class StrictVersion (Version):
...
@@ -99,25 +99,25 @@ class StrictVersion (Version):
in the distutils documentation.
in the distutils documentation.
"""
"""
version_re
=
re
.
compile
(
r'^(\
d+)
\. (\
d+) (
\. (\
d+))? ([
ab](\
d+))?$
',
version_re
=
re
.
compile
(
r'^(\
d+)
\. (\
d+) (
\. (\
d+))? ([
ab](\
d+))?$
',
re.VERBOSE)
re.VERBOSE)
def parse (self, vstring):
def parse (self, vstring):
match = self.version_re.match
(vstring)
match = self.version_re.match(vstring)
if not match:
if not match:
raise ValueError, "invalid version number '
%
s
'" % vstring
raise ValueError, "invalid version number '
%
s
'" % vstring
(major, minor, patch, prerelease, prerelease_num) =
\
(major, minor, patch, prerelease, prerelease_num) =
\
match.group
(1, 2, 4, 5, 6)
match.group(1, 2, 4, 5, 6)
if patch:
if patch:
self.version = tuple
(map
(string.atoi, [major, minor, patch]))
self.version = tuple
(map
(string.atoi, [major, minor, patch]))
else:
else:
self.version = tuple
(map
(string.atoi, [major, minor]) + [0])
self.version = tuple
(map
(string.atoi, [major, minor]) + [0])
if prerelease:
if prerelease:
self.prerelease = (prerelease[0], string.atoi
(prerelease_num))
self.prerelease = (prerelease[0], string.atoi(prerelease_num))
else:
else:
self.prerelease = None
self.prerelease = None
...
@@ -125,21 +125,21 @@ class StrictVersion (Version):
...
@@ -125,21 +125,21 @@ class StrictVersion (Version):
def __str__ (self):
def __str__ (self):
if self.version[2] == 0:
if self.version[2] == 0:
vstring = string.join
(map
(str, self.version[0:2]), '
.
')
vstring = string.join
(map
(str, self.version[0:2]), '
.
')
else:
else:
vstring = string.join
(map
(str, self.version), '
.
')
vstring = string.join
(map
(str, self.version), '
.
')
if self.prerelease:
if self.prerelease:
vstring = vstring + self.prerelease[0] + str
(self.prerelease[1])
vstring = vstring + self.prerelease[0] + str(self.prerelease[1])
return vstring
return vstring
def __cmp__ (self, other):
def __cmp__ (self, other):
if isinstance
(other, StringType):
if isinstance(other, StringType):
other = StrictVersion
(other)
other = StrictVersion(other)
compare = cmp
(self.version, other.version)
compare = cmp(self.version, other.version)
if (compare == 0): # have to compare prerelease
if (compare == 0): # have to compare prerelease
# case 1: neither has prerelease; they'
re
equal
# case 1: neither has prerelease; they'
re
equal
...
@@ -154,7 +154,7 @@ class StrictVersion (Version):
...
@@ -154,7 +154,7 @@ class StrictVersion (Version):
elif
(
not
self
.
prerelease
and
other
.
prerelease
):
elif
(
not
self
.
prerelease
and
other
.
prerelease
):
return
1
return
1
elif
(
self
.
prerelease
and
other
.
prerelease
):
elif
(
self
.
prerelease
and
other
.
prerelease
):
return
cmp
(
self
.
prerelease
,
other
.
prerelease
)
return
cmp
(
self
.
prerelease
,
other
.
prerelease
)
else
:
# numeric versions don't match --
else
:
# numeric versions don't match --
return
compare
# prerelease stuff doesn't matter
return
compare
# prerelease stuff doesn't matter
...
@@ -264,7 +264,7 @@ class LooseVersion (Version):
...
@@ -264,7 +264,7 @@ class LooseVersion (Version):
def __init__ (self, vstring=None):
def __init__ (self, vstring=None):
if vstring:
if vstring:
self.parse
(vstring)
self.parse(vstring)
def parse (self, vstring):
def parse (self, vstring):
...
@@ -272,11 +272,11 @@ class LooseVersion (Version):
...
@@ -272,11 +272,11 @@ class LooseVersion (Version):
# from the parsed tuple -- so I just store the string here for
# from the parsed tuple -- so I just store the string here for
# use by __str__
# use by __str__
self
.
vstring
=
vstring
self
.
vstring
=
vstring
components
=
filter
(
lambda
x
:
x
and
x
!=
'.'
,
components
=
filter
(
lambda
x
:
x
and
x
!=
'.'
,
self
.
component_re
.
split
(
vstring
))
self
.
component_re
.
split
(
vstring
))
for
i
in
range
(
len
(
components
)):
for
i
in
range
(
len
(
components
)):
try
:
try
:
components
[
i
]
=
int
(
components
[
i
])
components
[
i
]
=
int
(
components
[
i
])
except
ValueError
:
except
ValueError
:
pass
pass
...
@@ -288,14 +288,14 @@ class LooseVersion (Version):
...
@@ -288,14 +288,14 @@ class LooseVersion (Version):
def
__repr__
(
self
):
def
__repr__
(
self
):
return
"LooseVersion ('%s')"
%
str
(
self
)
return
"LooseVersion ('%s')"
%
str
(
self
)
def
__cmp__
(
self
,
other
):
def
__cmp__
(
self
,
other
):
if
isinstance
(
other
,
StringType
):
if
isinstance
(
other
,
StringType
):
other
=
LooseVersion
(
other
)
other
=
LooseVersion
(
other
)
return
cmp
(
self
.
version
,
other
.
version
)
return
cmp
(
self
.
version
,
other
.
version
)
# end class LooseVersion
# end class LooseVersion
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