Code Duplication    Length = 29-29 lines in 2 locations

plumd/util.py 2 locations

@@ 112-140 (lines=29) @@
109
    return fdat
110
111
112
def get_file_map_list(fname, col, skip):
113
    """Return a dict representation of a file - use on small files only.
114
115
    eg. file contents of:
116
117
    8       1 sda1 284 166 2673 1724 58 18 9056 369 0 1122 2091
118
119
    with a call of col=2, skip=0 returns:
120
121
    {"sda1": [8, 1, 284, 166, 2673, 1724, 58, 18, 9056, 369, 0, 1122, 2091]}
122
123
    :param fname: Full pathname to a file.
124
    :type fname: str
125
    :param col: Column number to use as the map
126
    :type col: int
127
    :param skip: Skip this many lines of the file.
128
    :type skip: int
129
    :rtype: dict
130
    """
131
    fdat = {}
132
    if os.access(fname, os.R_OK):
133
        with open(fname, 'r') as fd:
134
            dat = fd.read().split("\n")
135
            for line in dat[skip:]:
136
                vals = line.split()
137
                if len(vals) > col:
138
                    map_val = vals.pop(col)
139
                    fdat[map_val] = vals
140
    return fdat
141
142
143
def get_file_list(fname):
@@ 81-109 (lines=29) @@
78
    return tag
79
80
81
def get_file_map(fname, col, skip):
82
    """Return a dict representation of a file - use on small files only.
83
84
    eg. file contents of:
85
86
    8       1 sda1 284 166 2673 1724 58 18 9056 369 0 1122 2091
87
88
    with a call of col=2, skip=0 returns:
89
90
    {"sda1": [8, 1, 284, 166, 2673, 1724, 58, 18, 9056, 369, 0, 1122, 2091]}
91
92
    :param fname: Full pathname to a file.
93
    :type fname: str
94
    :param col: Column number to use as the map
95
    :type col: int
96
    :param skip: Skip this many lines of the file.
97
    :type skip: int
98
    :rtype: dict
99
    """
100
    fdat = {}
101
    if os.access(fname, os.R_OK):
102
        with open(fname, 'r') as fd:
103
            dat = fd.read().split("\n")
104
            for line in dat[skip:]:
105
                vals = line.split()
106
                if len(vals) > col:
107
                    map_val = vals.pop(col)
108
                    fdat[map_val] = deque(vals)
109
    return fdat
110
111
112
def get_file_map_list(fname, col, skip):