Ñò ;þGc@sªdZddklZddkTddklZddkZddkZddkZddk Z ddk Z ddk Z ddk Z ddk Z defd„ƒYZdS(s§A ``distutils`` command to compress Javascript/CSS files. DEPRECATED!! BUGGY!! Do not use in new projects. The WebHelpers developers are investigating alternatives. iÿÿÿÿ(tCommand(t*(tlogNtcompress_resourcescBsÒeZdZeidƒZddd d!d"d#gZd d gZdZ d„Z d„Z d„Z hdd6dd6Z d„Zd„ZdeeiƒƒeeiƒƒZd„Zd„Zd„Zd„ZRS($s=Compress Javascript and CSS files into smaller/combined formss hey there you sresource-dirs=trs.Relative directory where resources are locatedsresource-files=s7Filenames to include (in order they should be included)scombined-name=sNames of combined filess extensions=s-Extensions to compress (default .js and .css)s compress-jss$Compress Javascript using ShrinkSafesexample-settingss&Put some example settings in setup.cfgs5http://alex.dojotoolkit.org/shrinksafe/shrinksafe.phpcCs@g|_g|_ddg|_d|_t|_t|_dS(Ns.jss.csstcombined(t resource_dirstresource_filest extensionst combined_nametFalset compress_jstexample_settings(tself((sJ/usr/lib/python2.6/site-packages/webhelpers/commands/compress_resources.pytinitialize_options's     cCsË|iodSt|itƒoqt|iiƒƒdjoUtidƒg}|iiƒD]$}|iƒo||iƒq_q_~|_n|i dƒ|i dƒ|i dƒ|i dƒdS(Nis Splitting resource_files by lineRRRR ( R t isinstanceRt basestringtlent splitlinesRtdebugtstriptensure_string_listt ensure_string(R t_[1]tline((sJ/usr/lib/python2.6/site-packages/webhelpers/commands/compress_resources.pytfinalize_options/s  .   cCsU|io|iƒdSx5|iD]*}x!|iD]}|i||ƒq3Wq#WdS(N(R trun_example_settingsRRt compress_dir(R tdirtext((sJ/usr/lib/python2.6/site-packages/webhelpers/commands/compress_resources.pytrun>s    s/* From %(filename)s: */s.jss.cssc Cs!g}x™|iD]Ž}|idƒoqntii|ƒdp||7}n|i|ƒpqntitii||ƒƒ}|iƒ|i |ƒqW|pdS|i |}tii||ƒ}||jo|i |ƒng}xp|D]h}|i |h|d6} |i | dƒt|dƒ} |i | iƒƒ| iƒ|i dƒqûWdi|ƒ}t} tii|ƒoLt|dƒ} | iƒ} | iƒ|| jod} t} qád } nd } | o*t|d ƒ} | i|ƒ| iƒntid |t|ƒd | fƒ|ioÝ|djoÐtii|dƒ}tii|ƒ p%tii|ƒtii|ƒjom|i|ƒ}t|d ƒ} | i|ƒ| iƒtid|t|ƒd dt|ƒt|ƒƒqtid|ƒndS(Nt#itfilenames trbs ts no changescontent changedtcreatedtwbs %s: %iKb (%s)is.jss compressed.jss%s: compressed to %iKb (%i%%)ids*%s: skipping recreation (seems up-to-date)(Rt startswithtostpathtsplitexttendswithtglobtjointsorttextendR tremovetcomment_stylestappendtopentreadtclosetTruetexistsR twriteRtinfoRR tgetmtimetcompress_javascriptR(R RRt filenamestnametglobbedt combined_fntcontenttfntcommenttft need_writetexistingtstatust compress_fnR ((sJ/usr/lib/python2.6/site-packages/webhelpers/commands/compress_resources.pyRKsn           $%   cCs-|i|ihdd6d|fd6ƒ}|S(Nt1t stripnewliness content.jss shrinkfile[](tsubmit_file_uploadtshrinksafe_url(R R>tresult((sJ/usr/lib/python2.6/site-packages/webhelpers/commands/compress_resources.pyR9…s  s----cCsZ|i|ƒ\}}ti|ƒ}|id|ƒ|i|ƒti|ƒ}|iƒS(Ns Content-Type(t _encode_dataturllib2tRequestt add_headertadd_dataturlopenR2(R turltfieldst content_typetbodytreqtres((sJ/usr/lib/python2.6/site-packages/webhelpers/commands/compress_resources.pyRHŽs  cCsg}xÁ|iƒD]³\}}|id|iƒd|}t|tƒo|d|d7}n|i|ƒt|tƒo,|id|i|dƒƒ|d}n|idƒ|i|ƒqW|id|iƒ|idƒdi|ƒ}d |i}||fS( Ns--s)Content-Disposition: form-data; name="%s"s; filename="%s"isContent-Type: %siR"s s multipart/form-data; boundary=%s(titemsR0t http_boundaryRttuplet_get_content_typeR+(R RRtdatat fieldnametvaluetheaderRTRS((sJ/usr/lib/python2.6/site-packages/webhelpers/commands/compress_resources.pyRK–s$      cCsti|ƒdpdS(Nisapplication/octet-stream(t mimetypest guess_type(R R ((sJ/usr/lib/python2.6/site-packages/webhelpers/commands/compress_resources.pyRZ©scCs£ddkl}|i}t|iƒ}|id„ƒtii|i pd|dƒ}hhtii|dƒd6dd 6d d 6d 6}|d ||i ƒdS(Niÿÿÿÿ(t edit_configcSstt|ƒt|ƒƒS((tcmpR(tatb((sJ/usr/lib/python2.6/site-packages/webhelpers/commands/compress_resources.pyt°st.itpublicRsfile1.js file2.jsRR4R Rs setup.cfg( tsetuptools.command.setoptRat distributiontlisttpackagesR,R&R'R+t package_dirtdry_run(R RatdistRkRltsettings((sJ/usr/lib/python2.6/site-packages/webhelpers/commands/compress_resources.pyR¬s #(sresource-dirs=Rs.Relative directory where resources are locatedN(sresource-files=Ns7Filenames to include (in order they should be included)(scombined-name=NsNames of combined files(s extensions=Ns-Extensions to compress (default .js and .css)(s compress-jsNs$Compress Javascript using ShrinkSafe(sexample-settingsNs&Put some example settings in setup.cfg(t__name__t __module__t descriptionttextwraptdedenttlong_descriptiontNonet user_optionstboolean_optionsRIRRRR/RR9tstrtrandomRXRHRKRZR(((sJ/usr/lib/python2.6/site-packages/webhelpers/commands/compress_resources.pyRs0        : &   (t__doc__t distutils.cmdRtdistutils.errorst distutilsRt pkg_resourcesR&R*RzR_RLturllibRsR(((sJ/usr/lib/python2.6/site-packages/webhelpers/commands/compress_resources.pyts