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

View file

@ -659,8 +659,10 @@ def walk_generator(
absolute_name = os.path.join(current_location.absolute_path, base_name) absolute_name = os.path.join(current_location.absolute_path, base_name)
if os.path.isdir(absolute_name): if os.path.isdir(absolute_name):
exclude = normalize(absolute_name) in exclude_directories exclude = (
exclude |= normalize(base_name) in exclude_directories normalize(absolute_name) in exclude_directories or
normalize(base_name) in exclude_directories
)
if exclude: if exclude:
callback_exclusion(absolute_name, 'directory') callback_exclusion(absolute_name, 'directory')
continue 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( setuptools.setup(
name='voussoirkit', name='voussoirkit',
packages=['voussoirkit'], packages=['voussoirkit'],
version='0.0.7', version='0.0.8',
author='voussoir', author='voussoir',
author_email='_', author_email='_',
description='voussoir\'s toolkit', description='voussoir\'s toolkit',
url='https://github.com/voussoir/else', url='https://github.com/voussoir/else',
install_requires=['pyperclip']
) )