mirror of
https://github.com/codespell-project/codespell.git
synced 2025-05-17 15:36:17 +08:00
Add function to detect hidden file
This commit is contained in:
14
codespell.py
14
codespell.py
@ -79,6 +79,16 @@ def build_dict(filename):
|
||||
|
||||
misspellings[key] = Mispell(data, fix, reason)
|
||||
|
||||
def ishidden(filename):
|
||||
bfilename = os.path.basename(filename)
|
||||
|
||||
if bfilename != '' and bfilename != '.' and bfilename != '..' \
|
||||
and bfilename[0] == '.':
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def istextfile(filename):
|
||||
with open(filename, mode='rb') as f:
|
||||
s = f.read(1024)
|
||||
@ -149,9 +159,7 @@ def main(*args):
|
||||
|
||||
for filename in args[1:]:
|
||||
# ignore hidden files
|
||||
bfilename = os.path.basename(filename)
|
||||
if bfilename != '' and bfilename != '.' and bfilename != '..' \
|
||||
and bfilename[0] == '.':
|
||||
if ishidden(filename):
|
||||
continue
|
||||
|
||||
if not options.recursive and os.path.isdir(filename):
|
||||
|
Reference in New Issue
Block a user