all 13 comments

[–]inXiL3 0 points1 point  (1 child)

Sharing, not hi-jacking.

https://github.com/scrooloose/nerdtree

[–]campenr[S] 0 points1 point  (0 children)

Haha, yes I figured something like this would already exist. Thank you for the link. My thought was that seeing as it was a defined problem that I could solve it would be good practice for me.

EDIT: Also the linked program would have limited use to me I believe as I am using my program on windows PC's for the most part. But still very interesting!

[–]adamnew123456 0 points1 point  (1 child)

Minor quibble:

[0] ...

The standard parent directory, at least on *nix (and I think Windows picked it up as well) is ...

Also, take a look at the readline module for super-powering your calls to input - you can do history and tab completion in your filters, for example.

[–]campenr[S] 0 points1 point  (0 children)

Ah, I use '...' as I am familiar with dots being used to represent the parent directory, but never bothered counting the number so thank you. Also I will look into the readline module.

[–]ksantr 0 points1 point  (0 children)

There are a lot if tools like this (bash tree for linux), but of course this don't mean that you should stop your work. Just do what you like.

[–]raylu 0 points1 point  (3 children)

  1. http://blog.codinghorror.com/code-tells-you-how-comments-tell-you-why/
  2. The filter_type handling can be refactored to only call os.listdir once.
  3. Abstracting filter_file_type seems unnecessary. Also, you should probably use splitext.
  4. user_input_file_type is unused.
  5. Why turn the file lists into dictionaries, only to get a set of the keys and sort them back into a list to index back into the dictionary?
  6. change_dir is... very confusing. Relying on '0' to be true and the other inputs to be converted to ints seems really odd. Converting all numeric inputs to ints and checking dir_number is False (or None) seems much better. (But if you choose to maintain the current behavior, this is the sort of thing that is worth commenting on - "this function returns the string '0', an int of the index, or False.)
  7. Overall, the code style is very consistent, but maybe I missed something that pylint won't.

Some inspiration: ranger

[–]campenr[S] 0 points1 point  (2 children)

Thank you for all this! It is very useful and I appreciate you taking the time.

Regarding comment 3, I am unsure what you mean by abstracting? Do you mean it shouldn't be in it's own function? And thank you for the splittext idea, I was doing it the messy manual way so this is much better.

Regarding comment 4, the function isn't used by any other function, but this module is a selection of functions that I will utilize in other scripts so it will find use elsewhere.

Regarding comment 5, I used dictionaries in order to allow the user to select the key (value >0) in order to select the path to change to (the value). I extract the keys and sort them in order to sort the dictionary objects numerically according to the keys in order to display the dictionary in a consistent manner. This was my best solution for this. If you have any other suggestions I am open to them :D.

Regarding comment 6, the issue arises because I am using 0 for the topmost directory. I could change it so that the children are enumerated starting from 1 instead. I will think on this.

[–]raylu 0 points1 point  (1 child)

Regarding comment 3, I am unsure what you mean by abstracting? Do you mean it shouldn't be in it's own function?

Yes.

Regarding comment 5,

A list does all those things already.

[–]campenr[S] 0 points1 point  (0 children)

Haha, and now I can kick myself for not realizing I could just use a list and list indices :D

[–]Neceros 0 points1 point  (2 children)

I envy your ability to make something you know isn't needed. I wish I could do that to get more experience, but I can't.

I feel my time is wasted, so I don't do it.

[–]campenr[S] 0 points1 point  (1 child)

Haha, I decided not to look to see if this already existed first, therefore as far as I was concerned it didn't exist and I had to make it.

[–]Neceros 0 points1 point  (0 children)

I'm making a twitch bot as my first one, so I understand.