I have been creating a python script that basically hides/unhides files and folders in linux environment. Here's the code
import os
class unhide_files:
def __init__(self, directory):
self.parent_dir,self.sub_folders,self.files = list(os.walk(directory))[0]
os.chdir(directory)
def general_unhide(self,files):
try:
for f in files:
if "." in f:
os.rename(f,f.replace(".","",True))
except Exception as err:
print(str(err))
def unhide_file(self):
general_unhide(self.files) #unhide_file could not use general_unhide
def unhide_sub_folders(self):
general_unhide(self.sub_folders) #unhide_sub_folders could not use general_unhide
if __name__ == "__main__":
path = input("Enter the directory's path ")
unhid = unhide_files(path)
# testing to see if it works. Directory unhiding is still to
be done
unhid.unhide_file()
# hiding files behaviour is still to be implemented
The problem with the code is that, besides being a class method general_unhide
cannot be accessed by other methods in the class.
Any particular reason for this? Or is it just a silly mistake?