Revision 34e4cf61 kamaki/cli/history.py

b/kamaki/cli/history.py
1 1
#!/usr/bin/env python
2 2

  
3
# Copyright 2012 GRNET S.A. All rights reserved.
3
# Copyright 2012-2013 GRNET S.A. All rights reserved.
4 4
#
5 5
# Redistribution and use in source and binary forms, with or
6 6
# without modification, are permitted provided that the following
......
34 34
# or implied, of GRNET S.A.
35 35

  
36 36

  
37
def order_free_contains(containing, contained):
38
    superset = containing.split()
39
    for term in contained.split():
40
        if term not in superset:
41
            return False
42
    return True
43

  
44

  
45 37
class History(object):
46 38
    def __init__(self, filepath):
47 39
        self.filepath = filepath
......
84 76
            return None
85 77
        with open(self.filepath) as f:
86 78
            try:
87
                lala = f.readlines()
88
                return lala[cmd_id - (1 if cmd_id > 0 else 0)]
79
                cmd_list = f.readlines()[:-1]  # exclude current command
80
                return cmd_list[cmd_id - (1 if cmd_id > 0 else 0)]
89 81
            except IndexError:
90 82
                return None

Also available in: Unified diff