Skip to content

London | Nadika Zavodovska | Module-Tools | Sprint 4 | Implement Shell Tools in Python #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

nadika-zavodovska
Copy link

Hello,

I've done all the tasks for the Implement-Shell-Tools folder.

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Thank you.

@nadika-zavodovska nadika-zavodovska added Needs Review Participant to add when requesting review 📅 Sprint 4 Assigned during Sprint 4 of this module labels Apr 11, 2025
@OracPrime OracPrime added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Participant to add when requesting review labels May 30, 2025
Copy link

@OracPrime OracPrime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally strong work - a couple of minor issues to fix (mainly moving top level code to the bottom of files

# loopp through each line
for line in file_object:
# rstrip("\n") - removes any trailing newline character (\n) from the end of each line
line_to_print = line.rstrip("\n")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach works, but you might want to consider how you could make things more efficient by using the end parameter on your print statements and not need to strip the line

# For converting the given path to an absolute path
from pathlib import Path
# For colouring terminal output (blue for directories)
from colorama import Fore, Style, init

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Colorama isn't a standard library is it? Doesn't this mean you need a requirements.txt?

# Setup argument parser. Creates an instance(object) from built-in ArgumentParser class
parser = argparse.ArgumentParser(prog="ls command",
description="Implement 'ls' command with -1 and -a flags",
epilog="Now you can see the files in chossen path"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing you don't have spell-check turned on in your editor?

from colorama import Fore, Style, init

# Sets up colorama for blue colour for directories
init()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's generally considered best practice to have function definitions first, top level code at the end of the file. It makes it easier if all of the top level logic is in one place, and where another coder would expect to find it.


# Get absolute path
absolute_path = Path(args.path).resolve()
list_directory_files(str(absolute_path), display_hidden_files=args.a, display_one_per_line=args.one_per_line)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You convert the Path object to a string and pass it to your function. An alternative you might want to consider (I'm not saying you have to do it for this exercise, but it might be a good learning experience) having your function take a Path argument instead of a string, and use the Path functions to do a lot of the work inside the function

import os

# Setup argument parser. Creates an instance(object) from built-in ArgumentParser class
parser = argparse.ArgumentParser(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in previous file, you really ought to have top level code after function definitions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise this file is very good.

@OracPrime OracPrime added Reviewed Volunteer to add when completing a review and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels May 30, 2025
@nadika-zavodovska
Copy link
Author

Generally strong work - a couple of minor issues to fix (mainly moving top level code to the bottom of files

@OracPrime David, thank you for reviewing my code and for the helpful feedback!

@OracPrime
Copy link

Those new commits all look good, well done.

@nadika-zavodovska
Copy link
Author

Those new commits all look good, well done.

Thank you, @OracPrime David!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reviewed Volunteer to add when completing a review 📅 Sprint 4 Assigned during Sprint 4 of this module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants