-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLib.py
More file actions
33 lines (30 loc) · 755 Bytes
/
Lib.py
File metadata and controls
33 lines (30 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!usr/bin/python
# -*- coding: utf-8 -*-import string
class Lib:
def __init__(self, positions, links):
self.positions = positions
self.links = []
for l in links:
if not l[0] == l[2]:
if not l in self.links:
self.links.append(l)
def get_companions(self, position):
companions = []
for l in self.links:
if position in l:
if not l[0] == position:
companions.append(l[0])
elif not l[2] == position:
companions.append(l[2])
return companions
def get_company_weight(self, position_a, position_b):
weight = 0
true_value_found = False
for l in self.links:
if true_value_found:
break
if l[0] == position_a:
weight = l[1]
if l[2] == position_b:
true_value_found = True
return weight