Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
be86bdea
Kaydet (Commit)
be86bdea
authored
Eyl 26, 2000
tarafından
Greg Ward
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Standardize whitespace in function calls.
üst
fd7b91ef
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
92 deletions
+92
-92
core.py
Lib/distutils/core.py
+3
-3
unixccompiler.py
Lib/distutils/unixccompiler.py
+52
-52
util.py
Lib/distutils/util.py
+12
-12
version.py
Lib/distutils/version.py
+25
-25
No files found.
Lib/distutils/core.py
Dosyayı görüntüle @
be86bdea
...
@@ -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
Dosyayı görüntüle @
be86bdea
...
@@ -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,16 +138,16 @@ class UnixCCompiler (CCompiler):
...
@@ -138,16 +138,16 @@ 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
:
raise
CompileError
,
msg
raise
CompileError
,
msg
...
@@ -163,16 +163,16 @@ class UnixCCompiler (CCompiler):
...
@@ -163,16 +163,16 @@ 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
)
# Not many Unices required ranlib anymore -- SunOS 4.x is, I
# Not many Unices required ranlib anymore -- SunOS 4.x is, I
# think the only major Unix that does. Maybe we need some
# think the only major Unix that does. Maybe we need some
...
@@ -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
Dosyayı görüntüle @
be86bdea
...
@@ -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
Dosyayı görüntüle @
be86bdea
...
@@ -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