Code Duplication    Length = 14-14 lines in 2 locations

libs/displayname.py 2 locations

@@ 177-190 (lines=14) @@
174
    except ValueError:
175
        # Last section wasn't an int
176
        amember = roleForName(name, server)
177
        if amember:
178
            # Name was just a role - return
179
            return { "Role" : amember, "Int" : None }
180
        else:
181
            # Now we check if we got an ID instead
182
            # Get just the numbers
183
            memID = ''.join(list(filter(str.isdigit, name)))
184
            newMem = roleForID(memID, server)
185
            if newMem:
186
                # We FOUND it!
187
                return { "Role" : newMem, "Int" : None }
188
            else:
189
                # Nothing was right about this...
190
                return { "Role" : None, "Int" : None }
191
    # Should never get here
192
    return None
193
@@ 142-155 (lines=14) @@
139
        # Only one part - no int included (or not separated by space)
140
        # Check if role exists - and if not throw an error, if so, throw a diff error
141
        amember = roleForName(name, server)
142
        if amember:
143
            # We at least have a member
144
            return { "Role" : amember, "Int" : None }
145
        else:
146
            # Now we check if we got an ID instead
147
            # Get just the numbers
148
            memID = ''.join(list(filter(str.isdigit, name)))
149
            newMem = roleForID(memID, server)
150
            if newMem:
151
                # We FOUND it!
152
                return { "Role" : newMem, "Int" : None }
153
            else:
154
                # Nothing was right about this...
155
                return { "Role" : None, "Int" : None }
156
    try:
157
        # Let's cast the last item as an int and catch any exceptions
158
        theInt = int(theList[len(theList)-1])