File: utils.py

package info (click to toggle)
python-moto 5.1.18-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 116,520 kB
  • sloc: python: 636,725; javascript: 181; makefile: 39; sh: 3
file content (24 lines) | stat: -rw-r--r-- 845 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def find_duplicates(input_list: list[str]) -> list[str]:
    input_list_copy = input_list.copy()
    while len(input_list_copy) > 0:
        # start at front of list
        item = input_list_copy.pop(0)
        if item in input_list_copy:
            return [item, item]
    return []


def find_path_overlaps(input_list: list[str]) -> list[str]:
    input_list_copy = input_list.copy()
    while len(input_list_copy) > 0:
        # start at front of list
        item = input_list_copy.pop(0)
        if item in input_list_copy:
            return [item, item]
        else:
            for second_item in input_list_copy:
                if second_item.startswith(item + "."):
                    return [item, second_item]
                elif item.startswith(second_item + "."):
                    return [item, second_item]
    return []