3 from __future__
import print_function
9 return os.path.abspath(os.path.expanduser(path))
13 if os.path.isdir(full_path):
16 contents = os.listdir(full_path)
17 except OSError
as err:
18 print(
"Cannot access directory "+full_path+
" (OSError "+str(err.errno)+
": "+err.strerror+
")")
21 elif os.path.isfile(full_path):
22 base_name = os.path.basename(full_path)
23 if base_name.endswith(
'~')
or (base_name.startswith(
'#')
and base_name.endswith(
'#')):
26 except OSError
as err:
27 print(
"Cannot remove file "+full_path+
" (OSError "+str(err.errno)+
": "+err.strerror+
")")
29 if __name__ ==
"__main__":
30 parser = argparse.ArgumentParser(description=
"Removes all emacs backup files from given directories",
31 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
32 parser.add_argument(
"input_dir", nargs=
"*", default=[
"."], metavar=
"INPUT_DIR",
33 help=
"Directories from which to remove backup files")
34 args = parser.parse_args()
36 for d
in args.input_dir:
def RemoveBackups(file_dir)