Skip to content
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

locate for all partitions #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,19 @@ def interpret(cmd, arguments, parts, shorthands, outdir):
else:
logic.recursive_restore(myfile, part, partition_dir)
elif cmd == 'locate':
if len(arguments) != 2:
print 'Wrong number of parameters!'
else:
if len(arguments) == 1:
text = arguments[0]
for i, partidx in shorthands:
part = check_valid_part(i, parts, shorthands)
if part is not None:
results = utils.locate(part, text)
for node, path in results:
desc = (
' [GHOST]' if node.is_ghost else
' [DELETED]' if node.is_deleted else ''
)
print "partition %s [%s]: %s%s" % (i, node.index, path, desc)
Comment on lines +195 to +203
Copy link
Owner

Choose a reason for hiding this comment

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

I would avoid repetition, if possible. Could you consider moving the common code to a function or similar?

elif len(arguments) == 2:
part = check_valid_part(arguments[0], parts, shorthands)
if part is not None:
text = arguments[1]
Expand All @@ -202,6 +212,8 @@ def interpret(cmd, arguments, parts, shorthands, outdir):
' [DELETED]' if node.is_deleted else ''
)
print "[%s]: %s%s" % (node.index, path, desc)
else:
print 'Wrong number of parameters!'
elif cmd == 'traceback':
if len(arguments) != 2:
print 'Wrong number of parameters!'
Expand Down