0
1
Fork 0
Browse Source

style

master
kallejre 3 years ago
parent
commit
a982728c48
  1. 24
      wonderful _cleanup.py

24
wonderful _cleanup.py

@ -1,11 +1,14 @@
import os, re
#for itm in os.listdir('mystery'):
import os
import re
crime_separator = '*******\nCrime'
not_sus_regex = r"[Nn][o\']t[ a-z]*sus"
not_sus = re.compile(not_sus_regex, re.IGNORECASE)
people = dict()
companies = set()
# in_to_cm('6\'0"') == 182.88
class Person:
def __init__(self, name):
n = name.strip().split()
@ -24,25 +27,37 @@ class Person:
self.plate = None
self.make = None
self.color = None
def add_member(self, comp):
self.memberships.add(comp)
def __repr__(self):
out = list()
for i in sorted(filter(lambda x: x[0] != '_', dir(self))):
if not callable(eval('self.' + i)):
out.append(': '.join([i, str(eval('self.' + i))]))
return '\n'.join(out)
def in_to_cm(inch):
return round(int(inch.split('\'')[0]) * 30.48 + int(inch.split('\'')[1][:-1]) * 2.54, 2)
def lb_to_kg(lb):
return round(int(lb.split()[0]) * 0.4536, 2)
wonderful_blacklist = {'alice', 'hatter', 'rabbit', 'march mare'}
def check_wonders(x):
x = x.lower()
for alice in wonderful_blacklist:
if alice in x:
return False
return True
with open(r'mystery\crimescene') as f:
scene = filter(lambda x: check_wonders(x), f.read().split(crime_separator))
@ -102,8 +117,10 @@ with open(r'mystery\vehicles') as f:
people[name].make = make
people[name].color = color
def format_output(field):
if not field:return ''
if not field:
return ''
elif type(field) in {list, tuple}:
return ', '.join(list(map(format_output, field)))
elif type(field) in {set}:
@ -113,6 +130,7 @@ def format_output(field):
else:
return str(field).replace('\n', ' ')
f = open('people.csv', 'w')
print('Full name;First;Last;G;Height;Age;Weight;Address;Sus;Make;Color;Plate;Membership;Interview', file=f)
for name in sorted(people):

Loading…
Cancel
Save