+
    7j%                     v    R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	 RRRRR	R
RR/t
R t ! R R]4      tR# )un  
Load places from the LD2/LD3 lab databases into the Django application database.

Sources
-------
LD2  bigdata_ld2_database.sqlite3
       final_features   — OSM tags (historic, tourism, amenity, shop, leisure,
                          man_made, memorial, artwork_type, heritage) for all cities
       intermediate_data — raw OSM tags including website, phone, opening_hours

LD3  ld3_claude.sqlite3
       ld3_object       — PageRank scores + Wikidata labels/descriptions for ALL cities

Cities loaded: Berlin, London, New York, Paris

Usage:
    python manage.py load_data
    python manage.py load_data --clear
N)BaseCommand)settings)transactionBerlinberlinLondonlondonzNew Yorknew_yorkParisparisc           	          \         P                  V \        P                  ! R RV P	                  4       4      P                  R4      4      # )z
[^a-z0-9]+_)
CITY_SLUGSgetresublowerstripnames   &N/Users/jokubas/Desktop/engineering/processing/management/commands/load_data.py_slugifyr   $   s1    >>$}c4::< H N Ns STT    c                   0   a  ] tR t^(t o RtR tR tRtV tR# )Commandz1Load cities and places from LD2/LD3 lab databasesc                .    VP                  R RRR7       R# )z--clear
store_truez'Delete all existing data before loading)actionhelpN)add_argument)selfparsers   &&r   add_argumentsCommand.add_arguments+   s    Il!J 	 	Lr   c                l   ^ RI HpHpHpHpHpHp \        \        RR4      p	\        \        RR4      p
\        P                  P                  V	4      '       g!   V P                  P                  RV	 24       R# \        P                  P                  V
4      '       g!   V P                  P                  RV
 24       R# VR,          '       Ed@   V P                  P                  R	4       VP                  P!                  4       P#                  4        VP                  P!                  4       P#                  4        VP                  P!                  4       P#                  4        VP                  P!                  4       P#                  4        VP                  P!                  4       P#                  4        VP                  P!                  4       P#                  4        V P                  P                  V P$                  P'                  R
4      4       \(        P*                  ! V	4      p\(        P,                  Vn        \(        P*                  ! V
4      p\(        P,                  Vn        V P                  P                  R4       VP1                  4       pVP3                  R4       / pVP5                  4        F!  pVR,          VR,          VR,          3pWV&   K#  	  V P                  P                  R\7        V4       R24       V P                  P                  R4       VP1                  4       pVP3                  R4       / pVP5                  4        F"  pVR,          VR,          VR,          3pVVV&   K$  	  V P                  P                  R\7        V4       R24       V P                  P                  R4       VP3                  R4       VP5                  4       p/ pV F+  pVP9                  VR,          . 4      P;                  V4       K-  	  . RIOp^ pVP=                  4        EF  w  pp\?        V4      pVP                  PA                  VR VR!R/R"7      w  ppV P                  P                  V P$                  PC                  R#V R$\7        V4       R%24      4       \E        4       pV F5  pV F,  pVV,          pV'       g   K  VPG                  V R&V 24       K.  	  K7  	  V F  pVP                  PI                  VR'7       K!  	  . p V FV  pVVR,          VR,          3pVPK                  V4      p!V!'       g   K1  V!R(,          f   K>  V P;                  V!R(,          4       KX  	  V '       d   \M        V 4      MR)p"V '       d   \O        V 4      MR*p#V#V"8  d
   V#V",
          MR*p$V P                  P                  R+\7        V 4       R,V"R- R.V#R- R/24       ^ p%\P        PR                  ! 4       ;_uu_ 4        V EF  pVVR,          VR,          3pVPK                  V4      p!VPK                  V4      p&V!'       d   V!R0,          '       d
   V!R0,          MR;'       g    VR ,          ;'       g    Rp'V''       g   K  V!'       d
   V!R1,          MRp(R;p);p*p+V&'       dR   V&R2,          ;'       g    RR3,          ;'       g    Rp)V&R4,          p+V&R5,          ;'       g    RR3,          ;'       g    Rp*V!'       d$   V!R(,          e   V!R(,          V",
          V$,          p,MVR)p-VR6,          '       d
   V-R7,          p-VR,          '       d
   V-R8,          p-VR,          '       d
   V-R9,          p-\M        V-R*4      p,VP                  PA                  TVR,          VR,          ;'       g    R:/ R V'R3,          bR;VR;,          ;'       g    R)bR<VR<,          ;'       g    R)bR6VR6,          bR=V(bR>V)bR?V+bR@V*bRVR,          bRVR,          bRVR,          bRVR,          bRVR,          bRVR,          bRVR,          bRVR,          bRVR,          bR(V!'       d
   V!R(,          MRRAV,/CRB7      w  p.pV FU  pVV,          pV'       g   K   VP                  PK                  V R&V 2R'7      p/VP                  PI                  V.V/RC7       KW  	  V%^,          p%EK  	  RRR4       V%Vn+        VPY                  4        VV%,          pV P                  P                  V P$                  P'                  RDV% REV 24      4       EK  	  VP[                  4        VP[                  4        V P                  P                  V P$                  P'                  RFV RG\7        V4       RH24      4       R#   TPT                   d     EKI  i ; i  + '       g   i     L; i)J    )CityCategoryPlacePlaceCategoryImageFeature
PlaceImageLD2_DB_PATH LD3_DB_PATHzLD2 database not found: NzLD3 database not found: clearzClearing existing data...zCleared.z4Loading PageRank and Wikidata enrichment from LD3...z\SELECT city_name, osm_id, osm_type, pagerank, wd_label_en, wd_description_en FROM ld3_object	city_nameosm_idosm_typez  z LD3 entries loadedz2Loading contact info from LD2 intermediate_data...zdSELECT city_name, osm_id, osm_type, tag_website, tag_phone, tag_opening_hours FROM intermediate_dataz contact entries loadedz)Loading places from LD2 final_features...z3SELECT * FROM final_features ORDER BY city_name, idhistorictourismamenityshopleisureman_madememorialartwork_typeheritager   bbox)slugdefaultsz
=== z: z places ===:r   pagerankg        g      ?z  PageRank: z entries, range [z.6fz, ]wd_label_enwd_description_entag_website:Ni  N	tag_phonetag_opening_hourswikidata_qidg      ?g333333?g?nodelatlondescriptionwebsitephoneopening_hoursinterest_score)cityr1   r2   r>   )placecategoryz	  Loaded z places for z
Done! z places across z cities.)	r3   r4   r5   r6   r7   r8   r9   r:   r;   ).places.modelsr&   r'   r(   r)   r*   r+   getattrr   ospathexistsstderrwritestdoutobjectsalldeletestyleSUCCESSsqlite3connectRowrow_factorycursorexecutefetchalllen
setdefaultappenditemsr   update_or_createMIGRATE_HEADINGsetaddget_or_creater   minmaxr   atomicDoesNotExistplace_countsaveclose)0r    argsoptionsr&   r'   r(   r)   r*   r+   ld2_pathld3_pathld2ld3ld3_curld3_maprowkeyld2_curcontact_mapall_rows	city_rows
tag_fieldstotal_placesr0   rowsr=   rP   r   	cat_namesfieldvalcat_name	pr_valuesld3_rowpr_minpr_maxpr_rangert   contact_rowr   rK   rL   rN   rM   rO   scorerQ   cats0   &*,                                             r   handleCommand.handle/   s   ``8]B78]B7ww~~h''KK 8
CDww~~h''KK 8
CD7KK9:  $$&--/""$++-!!%%'..0MM&&(  "))+LL%%'KKdjj00<=ooh'!++ooh'!++ 	PQ**,	
 ##%C{#S]C
ODCCL & 	Bs7|n,?@A 	NO**,%	
 ##%C{#S]C
ODC"K & 	Bs;/00GHI 	EFMN##% 	C  [!126==cB J
 (0OItI&Dll33 )VT: 4 GD! KKdjj882c$i[<> ? I'Ee*Cs!q&67 ( 
 &  ..H.= & I #h-ZA!++c*7wz2>$$WZ%89	  (1S^cF'0S^cF*06/vsHKKs9~. / Rs|16
 K##%%C$c(mS_EC%kk#.G"-//#"6K 4;w}?U?U/[_  v;  
    CJ'*=">tK 7;:G:me"#.}#=#C#CT"J"R"Rd +K 8)45H)I)O)ORQU(V(^(^Z^ 7:#6#B*1**=*F()R !$~..!SLEy>>!SLEz??!SLE),UC$}}==!"8}!$Z!:!:F""DJ"!3u:#4#4" "3u:#4#4" +C,?	"
 *;" &w" $U" ,]" 'J" &s9~" &s9~" #CK" &s9~" 'J" 'J"  +C,?!"" 'J#"$ 'w
(;D,n'"	  >  HE18 ",!%j3%&.&6&6&:&:5'3%@P&:&Q - 5 5 C C%Z] C ^ ",  1$KW   &\  +DIIKK'LKKdjj00K=YK@B Cm  1r 					$**,,|nOC	N3C8LN 	O $,#8#8 % $%S &%s   +Af#>f#f#!
f#,	f#6f#f#f#0f#f#
f#(3f#f#4f#Af#f#-f#A;f#=*f#->f

+f#
f f#f  f##f3 N)	__name__
__module____qualname____firstlineno__r   r"   r   __static_attributes____classdictcell__)__classdict__s   @r   r   r   (   s     >DLBO BOr   r   )__doc__rU   r   r`   django.core.management.baser   django.confr   	django.dbr   r   r   r   r   r   r   <module>r      sQ   & 
 	  3   ! 
	
UIOk IOr   