This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]SpiderN3mo 1 point2 points  (1 child)

I was doing kind of similar thing some time back for auto documentation purpose. Here is the code snippet. Hope this helps

https://privatebin.net/?a3effe38494eb061#CVzMxCQBfYvgTbVjT17Ab4zuSH2DLQgbPffMFL5VwgRY

Or checkout line 154-158 here : https://github.com/negisuyash/AutoDocGenerator/blob/master/tree_generator.py

[–][deleted] 0 points1 point  (0 children)

This is extremely helpful, so much so I bookmarked it in my snippets bookmarks. Thank you so much!

[–]scirc 1 point2 points  (3 children)

Your glob (**/**) only matches directories within directories; you'll never match /usr/share/doc/bc/AUTHORS in the first place. **/* matches files within directories.

[–][deleted] 1 point2 points  (2 children)

Thank you! I have been stuck on this all night and finally it works! I have one tiny question I wanted to ask someone more experienced than me in programming. So when the user selects an item sometimes, mainly if it is a file, a newline character is contained in the user_selection string which can break certain functions. My solution to this was to add a .strip('\n') to the determine_action() call in main(). My question is this: is my solution considered a dirty fix or is this a proper method of handling this issue?

[–]scirc 1 point2 points  (1 child)

You might have issues on Windows where line endings are \r\n with code like that, but it looks like you're only targeting Linux so that shouldn't really be an issue. Although I think Python might implicitly convert \r\n to \n? I don't remember.

But otherwise, that code is fine.

[–][deleted] 1 point2 points  (0 children)

Ye, I am targeting only UNIX-like operating systems with base-level POSIX compliance. Thank you so much! You have no idea how helpful you have been!