From 3b8b4f269dbfd01b5525f8e4ed2a77c8e2d814d8 Mon Sep 17 00:00:00 2001 From: seangreaves Date: Wed, 18 Jan 2023 22:30:30 +0000 Subject: [PATCH] formatted large dictionaries --- assets/.DS_Store | Bin 10244 -> 0 bytes dashboard/.DS_Store | Bin 6148 -> 0 bytes sugartrail/base.py | 224 ++++++++++++++++++++++++++++++++++-------- sugartrail/mapview.py | 52 ++++++---- 4 files changed, 218 insertions(+), 58 deletions(-) delete mode 100644 assets/.DS_Store delete mode 100644 dashboard/.DS_Store diff --git a/assets/.DS_Store b/assets/.DS_Store deleted file mode 100644 index bf1e5beae7b9b92560c8247cdbe3d9b07f6ef7bd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10244 zcmeHMTWl0n82j@OV@6=1QzHbl$*l#CMYGXw51m=>uhIi$Ii}dcV>5i zrb%PGMM*SKRD3f=jW0YPCi0+|=nDxCN(d2+x9Ec*CPsbmg^T~0GmG0Bi7#NxoMg^_ z{&W6+&VRo7{+T^z0RWqFS{xt(00Lc1%9T`2Q`k7Wrj(H1Ba=k(2T;L+V~_-mT0sdA z2oMMm2oMMm2oU%$B0%44R)jfR26ccyfIxu2Z3Ni+Awn0E315zL>AgCr^0ojZ%c$Ec z)MncO<`eN{!k6P*(g+pgt|YlD`dbX-?$jUg?GnBm=aRbv`kN2*XGVXAg5KP$KqTnV;YWIUw;Kdv&zb6R|plt9N}>1kX`6>RX67} zso8@}>#}V#Rcx!N1BPBm%JZ9T%T*0a&w37qrjyB`9>db?LX(}dG{^Jp5{tyQG>pX}qw)G}4YA0k2O7r4L}5X6!;byQVKZ&nFS5w#J?Xzsp^EFb>l4(P zvanK+vG3(m)7m)sX1@5)&En#}DlT4><|tj=QctfjU|XHWaXl%|b7=LCklK;e^R()o z0o%-_Ehi~g52)rq&Qx8!(KMN{)9dO-UDoP%?5x}D875^p=ji)&vNQ5}3t5wE4ZBl& z#x-oqIiP19lF>vxUz~Wla>25?m22xaZ{OMU@ZR>zRdeUb)isjTPcT}p@r0pgy9Cw~MAd!lrFg9k)HBTi(px z!fKUPLFi*+jhd!wm#Y>nUbuUYqVzjMYF2MA5GCbHEKKTeqkiu>(g?d#t7f=%)*tNf z24%y_8^m{d4xILaAVd?Z`2+Dl6=n7lK!G~g1P?+7^wA+=0Zzb4cn#ix({K*X!v**f zuE16J8oq&_;aB(ruEPzug@7W~U@hK{br{7MZpCf59h-3vK8ky>4ZE=)58+`vf`gbw z8#6e9$MGqA8lS;u@g;l%PvM*RHlD!`@GO3epWu1CfS2%F{2qV6AMqMq#~XMvR1pe? zmV}mumW5V^)`ns{`cN^0dbwV#L+hzEHG`bI|7r+zPnR9xmR4!=J~mPEOV6b5^32?nbS@D){hD-&EyJh9g*q; z;~*Mv8Vf{a|*Ds2}jcjPjzE|GSM zq70rAUK4H-1bGTEXQbu(a0WhtPvIib@;mqmeu2M;iUQ8X#kid4$jG$Ee{I5^mboI)uxF#1NLnU(ZONGkwP&2d}@r~rUQB`lP&SRvF-x+Dem zln|Bs#sTcZ5j4QSo26)R{EH0G+HFDzr?_%;SXjTeslAR;8(}+bj+dl=Sk~o4lVP88 z?xKF03`e!vZ&lbRK6_r$CB3CThPQSSjyj|9u-O@WpxU{$X*9Px(M8gov@5SpZ8qv8 zS$E(PlDLZ@SC>f^+ey=ovv}xoL*Jmwy4{3X20UtQ55c1CodT1@C}WXe55z^@Y?qJKJfhAy11TgwU`5~ensEYA3sml z$HtG2?cXl;pVKf_j`K@6$Woi#VEcTI6e}VO2m`{vA_IIr=&ePk*usD?APgV_bUqly zfHC*zjt(r`69BP@ZYOBd?;_PYmnKJd utwH^SN int(self.officer_appointments_maxsize): - network.maxsize_entities.append(dict({'node':officer_id,'type': 'Officer', 'maxsize_type': 'Appointments', 'size': len(appointments['items'])})) + network.maxsize_entities.append(dict({ + 'node':officer_id, + 'type': 'Officer', + 'maxsize_type': 'Appointments', + 'size': len(appointments['items']) + })) if self.get_officer_correspondance_address: correspondance_address = sugartrail.api.get_correspondance_address(officer_id) if correspondance_address: if sugartrail.processing.normalise_address(correspondance_address['items'][0]['address']) not in lower_n_addresses: network.link_type = "Officer Corresponance Address" - new_address = {'address': sugartrail.processing.normalise_address(correspondance_address['items'][0]['address']), 'n':network.n+1, 'link_type':network.link_type, 'node_type': network.node_type, 'node': network.node} + new_address = { + 'address': sugartrail.processing.normalise_address(correspondance_address['items'][0]['address']), + 'n':network.n+1, + 'link_type':network.link_type, + 'node_type': network.node_type, + 'node': network.node + } if new_address not in new_addresses: new_addresses.append(new_address) if self.get_officer_duplicates: @@ -492,11 +600,22 @@ class Network: for duplicate in duplicate_officers: network.link_type = "Duplicate Officer" if duplicate['links']['self'].split('/')[2] not in lower_n_officers: - new_officer = {'officer_id': duplicate['links']['self'].split('/')[2], 'name': duplicate['title'], 'n':network.n+1, 'link_type': network.link_type, 'node_type': network.node_type, 'node': network.node} + new_officer = { + 'officer_id': duplicate['links']['self'].split('/')[2], + 'name': duplicate['title'], 'n':network.n+1, + 'link_type': network.link_type, + 'node_type': network.node_type, + 'node': network.node + } if new_officer not in new_officers: new_officers.append(new_officer) elif len(duplicate_officers) > int(self.officer_duplicates_maxsize): - network.maxsize_entities.append(dict({'node':officer_id,'type': 'Officer', 'maxsize_type': 'Duplicates', 'size': len(duplicate_officers)})) + network.maxsize_entities.append(dict({ + 'node':officer_id, + 'type': 'Officer', + 'maxsize_type': 'Duplicates', + 'size': len(duplicate_officers) + })) network.addresses.extend(new_addresses) network.officer_ids.extend(new_officers) network.company_ids.extend(new_companies) @@ -523,11 +642,22 @@ class Network: for company in companies['items']: network.link_type = "Company at Address" if company['company_number'] not in lower_n_companies: - new_company = {'company_id': company['company_number'], 'n':network.n+1, 'link_type':network.link_type, 'node_type': network.node_type, 'node': network.node} + new_company = { + 'company_id': company['company_number'], + 'n':network.n+1, + 'link_type':network.link_type, + 'node_type': network.node_type, + 'node': network.node + } if new_company not in new_companies: new_companies.append(new_company) elif len(companies['items']) > int(self.companies_at_address_maxsize): - network.maxsize_entities.append(dict({'node':address,'type': 'Address', 'maxsize_type': 'Companies', 'size': len(companies['items'])})) + network.maxsize_entities.append(dict({ + 'node':address, + 'type': 'Address', + 'maxsize_type': 'Companies', + 'size': len(companies['items']) + })) if self.get_officers_at_address: officers = sugartrail.api.get_officers_at_address(address) if officers: @@ -536,10 +666,22 @@ class Network: if 'links' and 'title' in officer: network.link_type = "Officer at Address" if officer['links']['self'].split('/')[2] not in lower_n_officers: - new_officer = {'officer_id': officer['links']['self'].split('/')[2], 'name': officer['title'], 'n':network.n+1, 'link_type':network.link_type, 'node_type': network.node_type, 'node': network.node} + new_officer = { + 'officer_id': officer['links']['self'].split('/')[2], + 'name': officer['title'], + 'n':network.n+1, + 'link_type': network.link_type, + 'node_type': network.node_type, + 'node': network.node + } if new_officer not in new_officers: new_officers.append(new_officer) elif len(officers) > int(self.officers_at_address_maxsize): - network.maxsize_entities.append(dict({'node':address,'type': 'Address', 'maxsize_type': 'Officers', 'size': len(officers)})) + network.maxsize_entities.append(dict({ + 'node':address, + 'type': 'Address', + 'maxsize_type': 'Officers', + 'size': len(officers) + })) network.officer_ids.extend(new_officers) network.company_ids.extend(new_companies) diff --git a/sugartrail/mapview.py b/sugartrail/mapview.py index 0143c03..abbf8ae 100644 --- a/sugartrail/mapview.py +++ b/sugartrail/mapview.py @@ -19,28 +19,30 @@ def load_map_data(network): through other companies towards the origin company.""" # initialise historic address trail antpath address_trail = AntPath( - locations=[], - dash_array=[1,10], - delay=1000, - color='#ed2f2f', - pulse_color='#FFFFFF' + locations=[], + dash_array=[1,10], + delay=1000, + color='#ed2f2f', + pulse_color='#FFFFFF' ) # initialise trail from company to origin antpath origin_trail = AntPath( - locations=[], - dash_array=[1,10], - delay=1000, - color='#000000', - pulse_color='#FFFFFF' + locations=[], + dash_array=[1,10], + delay=1000, + color='#000000', + pulse_color='#FFFFFF' ) # initialise table for printing company to origin trail path_table = HTML( - value="" + value="" ) # initialise map - m = Map(center=(50, 0), - zoom=5, - layout=Layout(width='90%', height='650px')) + m = Map( + center=(50, 0), + zoom=5, + layout=Layout(width='90%', height='650px') + ) # add antpath layers m.add_layer(address_trail) m.add_layer(origin_trail) @@ -77,13 +79,29 @@ def get_marker_data(network,address_trail, origin_trail, path_table): message = HTML() message.value = str(company_name) + "
" + str(address) icon = AwesomeIcon( - marker_color=marker_color + marker_color=marker_color ) # find historic addresses path for company address_path = get_address_path(network,str(row['company_number'])) - marker = Marker(icon=icon, opacity=1, location=(row['lat'], row['lon']), draggable=False, popup=message, title="Address") + marker = Marker( + icon=icon, + opacity=1, + location=(row['lat'], + row['lon']), + draggable=False, + popup=message, + title="Address" + ) # attach on click behavoir for marker - marker.on_click(functools.partial(on_button_clicked, address_path=address_path, address_trail=address_trail, path_table=path_table, origin_trail=origin_trail, path=path, location=(row['lat'], row['lon']), locations_from_origin = locations_from_origin)) + marker.on_click(functools.partial( + on_button_clicked, + address_path=address_path, + address_trail=address_trail, + path_table=path_table, + origin_trail=origin_trail, + path=path, location=(row['lat'], row['lon']), + locations_from_origin = locations_from_origin + )) markers.append(marker) return markers