This commit is contained in:
Ethan Dalool 2016-12-27 01:25:32 -08:00
parent e014776d1b
commit a9f661ddb4
4 changed files with 24 additions and 15 deletions

View file

@ -14,7 +14,9 @@ class Path:
self.absolute_path = path
def __contains__(self, other):
return other.normcase.startswith(self.normcase)
if isinstance(other, Path):
other = other.normcase
return other.startswith(self.normcase)
def __eq__(self, other):
if not hasattr(other, 'absolute_path'):
@ -22,7 +24,7 @@ class Path:
return self.normcase == other.normcase
def __hash__(self):
return hash(os.path.normcase(self.absolute_path))
return hash(self.normcase)
def __repr__(self):
return '{c}({path})'.format(c=self.__class__.__name__, path=repr(self.absolute_path))
@ -73,8 +75,9 @@ class Path:
@property
def relative_path(self):
cwd = Path(os.getcwd())
cwd.correct_case()
self.correct_case()
if self.absolute_path == cwd:
if self == cwd:
return '.'
if self in cwd:
@ -85,7 +88,6 @@ class Path:
return self.absolute_path
backsteps = cwd.depth - common.depth
backsteps = os.sep.join('..' for x in range(backsteps))
print('hi')
return self.absolute_path.replace(common.absolute_path, backsteps)
@property
@ -166,15 +168,16 @@ def get_path_casing(path):
try:
cased = glob.glob(pattern)[0]
imaginary_portion = input_path.normcase
real_portion = os.path.normcase(cased)
imaginary_portion = imaginary_portion.replace(real_portion, '')
imaginary_portion = imaginary_portion.lstrip(os.sep)
cased = os.path.join(cased, imaginary_portion)
cased = cased.rstrip(os.sep)
return cased
except IndexError:
return input_path
return input_path.absolute_path
imaginary_portion = input_path.normcase
real_portion = os.path.normcase(cased)
imaginary_portion = imaginary_portion.replace(real_portion, '')
imaginary_portion = imaginary_portion.lstrip(os.sep)
cased = os.path.join(cased, imaginary_portion)
cased = cased.rstrip(os.sep)
return cased
def glob_patternize(piece):
'''

View file

@ -659,8 +659,10 @@ def walk_generator(
absolute_name = os.path.join(current_location.absolute_path, base_name)
if os.path.isdir(absolute_name):
exclude = normalize(absolute_name) in exclude_directories
exclude |= normalize(base_name) in exclude_directories
exclude = (
normalize(absolute_name) in exclude_directories or
normalize(base_name) in exclude_directories
)
if exclude:
callback_exclusion(absolute_name, 'directory')
continue

View file

@ -0,0 +1,3 @@
phase1
xcopy voussoirkit C:\Python35\Lib\site-packages\voussoirkit /y
phase2

View file

@ -3,9 +3,10 @@ import setuptools
setuptools.setup(
name='voussoirkit',
packages=['voussoirkit'],
version='0.0.7',
version='0.0.8',
author='voussoir',
author_email='_',
description='voussoir\'s toolkit',
url='https://github.com/voussoir/else',
install_requires=['pyperclip']
)