資源簡介
NULL
博文鏈接:https://ssh-2009-126-com.iteye.com/blog/715747

代碼片段和文件信息
#!/usr/bin/python
#?This?code?is?original?from?jsmin?by?Douglas?Crockford?it?was?translated?to
#?Python?by?Baruch?Even.?The?original?code?had?the?following?copyright?and
#?license.
#
#?/*?jsmin.c
#????2007-05-22
#
#?Copyright?(c)?2002?Douglas?Crockford??(www.crockford.com)
#
#?Permission?is?hereby?granted?free?of?charge?to?any?person?obtaining?a?copy?of
#?this?software?and?associated?documentation?files?(the?“Software“)?to?deal?in
#?the?Software?without?restriction?including?without?limitation?the?rights?to
#?use?copy?modify?merge?publish?distribute?sublicense?and/or?sell?copies
#?of?the?Software?and?to?permit?persons?to?whom?the?Software?is?furnished?to?do
#?so?subject?to?the?following?conditions:
#
#?The?above?copyright?notice?and?this?permission?notice?shall?be?included?in?all
#?copies?or?substantial?portions?of?the?Software.
#
#?The?Software?shall?be?used?for?Good?not?Evil.
#
#?THE?SOFTWARE?IS?PROVIDED?“AS?IS“?WITHOUT?WARRANTY?OF?ANY?KIND?EXPRESS?OR
#?IMPLIED?INCLUDING?BUT?NOT?LIMITED?TO?THE?WARRANTIES?OF?MERCHANTABILITY
#?FITNESS?FOR?A?PARTICULAR?PURPOSE?AND?NONINFRINGEMENT.?IN?NO?EVENT?SHALL?THE
#?AUTHORS?OR?COPYRIGHT?HOLDERS?BE?LIABLE?FOR?ANY?CLAIM?DAMAGES?OR?OTHER
#?LIABILITY?WHETHER?IN?AN?ACTION?OF?CONTRACT?TORT?OR?OTHERWISE?ARISING?FROM
#?OUT?OF?OR?IN?CONNECTION?WITH?THE?SOFTWARE?OR?THE?USE?OR?OTHER?DEALINGS?IN?THE
#?SOFTWARE.
#?*/
from?StringIO?import?StringIO
def?jsmin(js):
????ins?=?StringIO(js)
????outs?=?StringIO()
????javascriptMinify().minify(ins?outs)
????str?=?outs.getvalue()
????if?len(str)?>?0?and?str[0]?==?‘\n‘:
????????str?=?str[1:]
????return?str
def?isAlphanum(c):
????“““return?true?if?the?character?is?a?letter?digit?underscore
???????????dollar?sign?or?non-ASCII?character.
????“““
????return?((c?>=?‘a(chǎn)‘?and?c?<=?‘z‘)?or?(c?>=?‘0‘?and?c?<=?‘9‘)?or
????????????(c?>=?‘A‘?and?c?<=?‘Z‘)?or?c?==?‘_‘?or?c?==?‘$‘?or?c?==?‘\\‘?or?(c?is?not?None?and?ord(c)?>?126));
class?UnterminatedComment(Exception):
????pass
class?UnterminatedStringLiteral(Exception):
????pass
class?UnterminatedRegularexpression(Exception):
????pass
class?javascriptMinify(object):
????def?_outA(self):
????????self.outstream.write(self.theA)
????def?_outB(self):
????????self.outstream.write(self.theB)
????def?_get(self):
????????“““return?the?next?character?from?stdin.?Watch?out?for?lookahead.?If
???????????the?character?is?a?control?character?translate?it?to?a?space?or
???????????linefeed.
????????“““
????????c?=?self.theLookahead
????????self.theLookahead?=?None
????????if?c?==?None:
????????????c?=?self.instream.read(1)
????????if?c?>=?‘?‘?or?c?==?‘\n‘:
????????????return?c
????????if?c?==?‘‘:?#?EOF
????????????return?‘\000‘
????????if?c?==?‘\r‘:
????????????return?‘\n‘
????????return?‘?‘
????def?_peek(self):
????????self.theLookahead?=?self._get()
????????return?self.theLookahead
????def?_next(self):
????????“““get?the?next?charact
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄??????????0??2010-07-16?18:05??firebug
?????文件??????10248??2010-06-25?09:42??firebug\ChangeLog
?????目錄??????????0??2010-07-16?18:05??firebug\CVS
?????文件????????862??2010-06-25?09:42??firebug\CVS\Entries
?????文件?????????19??2010-06-24?11:06??firebug\CVS\Repository
?????文件?????????43??2010-06-24?11:06??firebug\CVS\Root
?????文件????????136??2010-06-25?09:42??firebug\deploy
?????文件????????457??2010-06-25?09:42??firebug\errorIcon.png
?????文件??????78968??2010-06-25?09:42??firebug\firebug-lite-compressed.js
?????文件??????16333??2010-06-25?09:42??firebug\firebug-lite.css
?????文件?????107183??2010-06-25?09:42??firebug\firebug-lite.js
?????文件???????1043??2010-06-25?09:42??firebug\firebug.gif
?????文件????????499??2010-06-25?09:42??firebug\firebug_logo.png
?????文件????????524??2010-06-25?09:42??firebug\infoIcon.png
?????文件???????7842??2010-06-25?09:42??firebug\jsmin.py
?????文件????????286??2010-06-25?09:42??firebug\minifier.py
?????文件?????????63??2010-06-25?09:42??firebug\minify
?????文件?????????63??2010-06-25?09:42??firebug\minify.bat
?????文件???????5203??2010-06-25?09:42??firebug\progress.gif
?????文件?????????64??2010-06-25?09:42??firebug\spacer.gif
?????文件????????300??2010-06-25?09:42??firebug\tree_close.gif
?????文件????????202??2010-06-25?09:42??firebug\tree_open.gif
?????文件????????516??2010-06-25?09:42??firebug\warningIcon.png
-----------?---------??----------?-----??----
???????????????230854????????????????????23
評論
共有 條評論