Code Monkey home page Code Monkey logo

tree's Introduction

Tree

Tree is a recursive directory listing command that produces a depth indented listing of files

This assignment is to re-create the tree command, using Python.

Functionality

To play around with the actual tree command, you will need to install it within your virtual machine:

sudo apt update
sudo apt install tree

While the actual tree command accepts a bunch of optional flags/options, we are only going to worry about the basic use cases:

  • Passing in a path as the first/only argument

    $ tree examples/simple/
    examples/simple/
    ├── another
    ├── bites
    │   ├── dust
    │   │   └── dot.jpg
    │   └── the
    └── one.txt
    
    2 directories, 4 files
    
  • Not passing in any arguments, which will display the contents of the working directory

    $ cd examples/simple/
    $ tree
    .
    ├── another
    ├── bites
    │   ├── dust
    │   │   └── dot.jpg
    │   └── the
    └── one.txt
    
    2 directories, 4 files
    

Your script should produce identical output, but run with

./pytree.py [path]
# which is equivalent to
python3 pytree.py [path]

Requirements

  • Put your code into pytree.py
  • pytest tests passing (90% total)
  • Code Climate checks passing (10%)
  • All of the logic must exist in Python. In other words, you may not use any of the following modules/functions:
    • os.popen()
    • os.spawn*()
    • os.system()
    • subprocess

Dealing with unicode

tree uses some unicode characters to create the layout and draw the lines. This includes non-breaking spaces (tested with tree v1.7.0), highlighted below:

non-breaking spaces

Working with unicode/encodings can be challenging, but in short, we recommend copying-and-pasting the special characters directly from the tree output in your terminal to strings in your Python script.

Running tests locally

Run the following from this directory:

# install dependencies
sudo apt update
sudo apt install tree
pip3 install -r requirements.txt
# run the pytests
pytest -v
# run the pep8 checks
pep8

Code Climate checks

If you want to try running these locally:

  1. Install Docker (follow the "Ubuntu Xenial 16.04 (LTS)" instructions)
  2. Run the Code Climate CLI.

Note that this is advanced, so don't worry if you have trouble getting it running.

tree's People

Contributors

afeld avatar akshaybhatai avatar diegow88 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.