Révision 4e82c425 modules/utilities.py

b/modules/utilities.py
4 4

  
5 5

  
6 6
def tail(f, lines=20):
7
    """Returns the specified last number of lines of a file.
8

  
9
    @param f: The file to retrieve the last lines from.
10
    @param lines: The number of lines to be retrieved.
11
    @return str: The last number of lines
12
    """
7 13
    total_lines_wanted = lines
8 14

  
9 15
    block_size = 1024
......
29 35

  
30 36
def check_bak(file_name):
31 37
    """Checks if a file already exists and backs it up if so.
38

  
32 39
    @param file_name: file to be checked if exists
33 40
    """
34 41
    import os
......
83 90

  
84 91

  
85 92
def _human_key(key):
93
    """Function used as sorting strategy where numbers are sorted human-wise.
94

  
95
    @param key:
96
    @return:
97
    """
86 98
    import re
87 99
    parts = re.split('(\d*\.\d+|\d+)', key)
88 100
    return tuple((e.swapcase() if i % 2 == 0 else float(e))
......
90 102

  
91 103

  
92 104
def is_binary(file):
105
    """Checks if a file is a text file or a binary one.
106

  
107
    @param file:
108
    @return:
109
    """
93 110
    try:
94 111
        with open(file, "r") as fh:
95 112
            fh.read(50)

Formats disponibles : Unified diff