mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
keep os.path in 2 and 3 consistent (#2152)
We can't merge these because os/__init__ is still different. Also slight refactor of tests/check_consistent.py to avoid `from os import path`.
This commit is contained in:
committed by
Guido van Rossum
parent
d84069e78d
commit
b89f9553e9
@@ -5,7 +5,6 @@
|
||||
|
||||
import os
|
||||
import filecmp
|
||||
from os import path
|
||||
|
||||
consistent_files = [
|
||||
{'stdlib/2/builtins.pyi', 'stdlib/2/__builtin__.pyi'},
|
||||
@@ -13,18 +12,20 @@ consistent_files = [
|
||||
{'stdlib/2/os2emxpath.pyi', 'stdlib/2/posixpath.pyi', 'stdlib/2/ntpath.pyi', 'stdlib/2/macpath.pyi'},
|
||||
{'stdlib/3/ntpath.pyi', 'stdlib/3/posixpath.pyi', 'stdlib/3/macpath.pyi', 'stdlib/3/posixpath.pyi'},
|
||||
{'stdlib/3.4/enum.pyi', 'third_party/3/enum.pyi'},
|
||||
{'stdlib/2/os/path.pyi', 'stdlib/3/os/path.pyi'},
|
||||
]
|
||||
|
||||
def main():
|
||||
files = [path.join(root, file) for root, dir, files in os.walk('.') for file in files]
|
||||
no_symlink = 'You cannot use symlinks in typeshed, please copy the file to its link.'
|
||||
files = [os.path.join(root, file) for root, dir, files in os.walk('.') for file in files]
|
||||
no_symlink = 'You cannot use symlinks in typeshed, please copy {} to its link.'
|
||||
for file in files:
|
||||
if path.islink(file):
|
||||
_, ext = os.path.splitext(file)
|
||||
if ext == '.pyi' and os.path.islink(file):
|
||||
raise ValueError(no_symlink.format(file))
|
||||
for file1, *others in consistent_files:
|
||||
f1 = path.join(os.getcwd(), file1)
|
||||
f1 = os.path.join(os.getcwd(), file1)
|
||||
for file2 in others:
|
||||
f2 = path.join(os.getcwd(), file2)
|
||||
f2 = os.path.join(os.getcwd(), file2)
|
||||
if not filecmp.cmp(f1, f2):
|
||||
raise ValueError('File {f1} does not match file {f2}. Please copy it to {f2}'.format(f1=file1, f2=file2))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user