a #e7 @sBddlZddlZddlZedZGdddZGdddZdS)Nz app.loggerc@sLeZdZddZddZddZddZd d Zd d Zd dZ ddZ dS)GCPFilecCs||_g|_d|_|dS)N)gcp_pathentriesraw_srsread)selfrr /webodm/app/classes/gcp.py__init__szGCPFile.__init__cCs|rt|jd}|}Wdn1s60Ytttj|d}|r|d|_ |ddD]H}|dkrp|ddkrp|}t |dkr|j |qpt d|qpnt d |jdS) Nr rr#zMalformed GCP line: %szGCP file %s does not exist)existsopenrrstriplistmapstrsplitrlenrappendloggerwarning)rfcontentslineslinepartsr r r rs*  z GCPFile.readccs|jD]}||VqdSN)r parse_entry)rentryr r r iter_entries!s zGCPFile.iter_entriesc Csb|r^|}|dd\}}}}}}d|dd} tt|t|t|t|t||| SdS)Nr )rjoinGCPEntryfloat) rr#r xyzpxpyfilenameextrasr r r r"%s zGCPFile.parse_entrycCs ||kr||j|SdSr!) entries_countr"r)rnr r r get_entry,s zGCPFile.get_entrycCs t|jSr!)rrrr r r r00szGCPFile.entries_countcCst|jotj|jSr!)boolrospathrr3r r r r3szGCPFile.existscCs|jg}|D]J}|j||jd9_|j||jd9_|t|qt |d$}| d |dWdn1s0Y|S)a( Creates a new resized GCP file from an existing GCP file. If one already exists, it will be removed. :param gcp_file_output output path of new GCP file :param image_ratios dictionary with "imagename" --> "resize_ratio" values :return path to new GCP file g?wr N) rr$r,getr.lowerr-rrrwriter&)rZgcp_file_output image_ratiosoutputr#rr r r create_resized_copy6s  2zGCPFile.create_resized_copyN) __name__ __module__ __qualname__r rr$r"r2r0rr=r r r r rsrc@seZdZdddZddZdS)r'rcCs.||_||_||_||_||_||_||_dSr!)r)r*r+r,r-r.r/)rr)r*r+r,r-r.r/r r r r KszGCPEntry.__init__c Cs(d|j|j|j|j|j|j|jS)Nz{} {} {} {} {} {} {}) formatr)r*r+r,r-r.r/rstripr3r r r __str__Ts zGCPEntry.__str__N)r)r>r?r@r rCr r r r r'Js r')globr5logging getLoggerrrr'r r r r s  C