Skip to content

Latest commit

 

History

History
201 lines (194 loc) · 5.68 KB

README.md

File metadata and controls

201 lines (194 loc) · 5.68 KB

Element

The element class is use to manage easier the file or directory from pythontree class

└─home
  └─Desktop
    ├─document
    │ └─setup.py
    ├─python
    │ └─try.py
    └─ruby
      └─try.rb
>>> import Element
>>> element = Element("home/Desktop/document/setup.py")
  • attributes
    • path
      in the "path" attribute there is the file or directory path
       >>> element.path
       'home/Desktop/document/setup.py'
      
    • name
      in the "name" attribute there is the file or directory name
       >>> element.name
       'setup.py'
      
    • type
      in the "type" attribute there is the file or directory type
       >>> element.type
       '.py'
      
    • is_file
      in the "is_file" attribute there is a bool True value if is file if not False
       >>> element.is_file
       True
      
    • is_dir
      in the "is_dir" attribute there is a bool True value True if is dir if not False
       >>> element.is_file
       False
      
  • classes
    • is_empty
      the "is_empty" class return a bool True value if the file or directory is empty if not False
       >>> element.is_empty()
       True
      
    • md5
      the "md5" class return the md5 of file and return False if element is directory
       >>> element.md5()
       'd41d8cd98f00b204e9800998ecf8427e'
      
    • delete
      the "delete" class delete file or directory
       >>> element.delete()
      
       └─home
         └─Desktop
           ├─document
           ├─python
           │ └─try.py
           └─ruby
             └─try.rb
      

Pythontree

PyPI - Python Version Hex.pm PyPI - Pypi.org Library Project Version

This project has been created to facilitate folder management

  • OS Supported

    Linux Support macOS Support Windows Not_Supported

  • Installation

    • pip
       # pip3 install pythontree
       # pip3 install pythontree --upgrade
      
    • git
       $ git clone https://github.com/MattVoid/pythontree.git
       $ cd pythontree
       $ python3 setup.py install
      
  • Roots

    • roots
      it's a grapich function, print a tree of the chosen path
       >>> import pythontree
       >>> Roots = pythontree.Roots('*** you can choose the path to start ***')
       >>> Roots.roots()
      
      Alt text
    • element
      return an array with files or folders starting from your chosen path
       └─home
         └─Desktop
           ├─document
           │ └─setup.py
           ├─python
           │ └─try.py
           └─ruby
             └─try.rb
      
       >>> import pythontree
       >>> Roots = pythontree.Roots('/home') # you can choose the path to start
       >>> print(Roots.element())
       ['/home/Desktop/document/setup.py', '/home/Desktop/python/try.py', '/home/Desktop/ruby/try.rb']
       >>> print(Roots.element()['file']['name'])
       ['setup.py', 'try.py', 'try.rb']
       >>> print(Roots.element()['dir']['path'])
       ['/home/Desktop', '/home/Desktop/document', '/home/Desktop/python', '/home/Desktop/ruby']
       >>> print(Roots.element()['dir']['name'])
       ['Desktop', 'document', 'python', 'ruby']
      
    • type
      return an array with files with an extension of your choice starting from your path
       >>> import pythontree
       >>> Roots = pythontree.Roots('/home') # you can choose the path to start
       >>> print(Roots.type('rb')['name']) # you can choose the extension to return
       ['try.rb']
       >>> print(Roots.type('rb')['path'])
       ['/home/Desktop/ruby/try.rb']
      
  • Clean

    • element
      return an array with empty folders or equal files
       └─home
         └─Desktop
           ├─document
           │ └─setup.py
           ├─python
           │ ├─try.py
           │ ├─try(copy).py
           │ ├─try(copy 2).py
           │ └─pythontree.py
           ├─ruby
           │ └─try.rb
           └─project
      
       >>> import pythontree
       >>> Clean = pythontree.Clean('/home') # you can choose the path to start
       >>> print(Clean.element()['empty']['path'])
       ['/home/Desktop/project']
       >>> Clean.element()['empty']['name']
       ['project']
       >>> print(Clean.element()['duplicate']['path'])
       ['/home/Desktop/python/try(copy).py', '/home/Desktop/python/try(copy 2).py']
       >>> print(Clean.element()['duplicate']['name'])
       ['try(copy).py','try(copy 2).py']
       >>> print(Clean.element()['duplicate']['original']['path']) #original returns the reference file
       ['/home/Desktop/python/try.py','/home/Desktop/python/try.py']
       >>> print(Clean.element()['duplicate']['original']['name'])
       ['try.py','try.py']
      
    • delete
      • files
        delete equal files starting from your chosen path
         >>> import pythontree
         >>> Clean = pythontree.Clean('*** you can choose the path to start ***')
         >>> Clean.delete('files')
        
      • dirs
        delete empty folders starting from your chosen path
         >>> import pythontree
         >>> Clean = pythontree.Clean('*** you can choose the path to start ***')
         >>> Clean.delete('dirs')
        
      • both
        delete empty folders and equal files starting from your chosen path
         >>> import pythontree
         >>> Clean = pythontree.Clean('*** you can choose the path to start ***')
         >>> Clean.delete('both')