Permalink
Browse files

puke 1.1

- console.log(arg1, arg2, …)
- Require
- Yak
- few fixes
  • Loading branch information...
1 parent 0e68856 commit 426e9fffed4fd0070a3bdf21447e1128485cfdd0 @etabard etabard committed Nov 16, 2011
Showing with 26,045 additions and 24,322 deletions.
  1. BIN bin/puke.js.runner
  2. +63 −0 puke/Cache.py
  3. +57 −25 puke/Console.py
  4. +15 −51 puke/FileList.py
  5. +1 −1 puke/FileSystem.py
  6. +148 −0 puke/Require.py
  7. +9 −1 puke/Sed.py
  8. +1 −1 puke/Task.py
  9. +82 −14 puke/Tools.py
  10. +5 −0 puke/Yak.py
  11. +17 −5 puke/__init__.py
  12. +0 −9 puke/datas/envjasmine/include/dependencies.js
  13. +0 −7,179 puke/datas/envjasmine/include/jquery-1.4.4.js
  14. +0 −3 puke/datas/envjasmine/lib/envjasmine.html
  15. +0 −217 puke/datas/envjasmine/lib/envjasmine.js
  16. +0 −13,999 puke/datas/envjasmine/lib/envjs/env.rhino.1.2.js
  17. +0 −114 puke/datas/envjasmine/lib/jasmine-ajax/mock-ajax.js
  18. +0 −19 puke/datas/envjasmine/lib/jasmine-ajax/spec-helper.js
  19. +0 −205 puke/datas/envjasmine/lib/jasmine-jquery/jasmine-jquery-1.1.3.js
  20. +0 −1 puke/datas/envjasmine/lib/jasmine-jquery/jasmine-jquery.js
  21. +0 −2,421 puke/datas/envjasmine/lib/jasmine/jasmine.js.old
  22. BIN puke/datas/envjasmine/lib/rhino/js.jar
  23. +0 −29 puke/datas/envjasmine/lib/spanDir/spanDir.js
  24. +0 −10 puke/datas/envjasmine/specs/test.js
  25. +25,334 −0 puke/datas/envjs/env.rhino.js
  26. +23 −0 puke/datas/envjs/envjs.bootstrap.js
  27. +207 −0 puke/datas/envjs/jasmine-ajax/mock-ajax.js
  28. 0 puke/datas/envjs/jasmine-ajax/spec-helper.js
  29. +46 −12 .../{envjasmine/lib/jasmine-jquery/jasmine-jquery-1.2.0.js → envjs/jasmine-jquery/jasmine-jquery.js}
  30. 0 puke/datas/{envjasmine/lib → envjs}/jasmine/MIT.LICENSE
  31. +29 −3 ...vjasmine/lib/jasmine-rhino-reporter/jasmine-rhino-reporter.js → envjs/jasmine/jasmine-console.js}
  32. 0 puke/datas/{envjasmine/lib → envjs}/jasmine/jasmine-html.js
  33. 0 puke/datas/{envjasmine/lib → envjs}/jasmine/jasmine.css
  34. 0 puke/datas/{envjasmine/lib → envjs}/jasmine/jasmine.js
  35. +4 −0 puke/datas/envjs/jquery/jquery-1.7.js
  36. +4 −3 setup.py
View
Binary file not shown.
View
@@ -0,0 +1,63 @@
+import urllib2
+import hashlib
+
+from puke.Console import *
+from puke.FileSystem import *
+
+class Cache:
+
+ @staticmethod
+ def fetchHttp(url):
+ id = hashlib.sha256(url).hexdigest()
+
+ if Cache.check(id):
+ return Cache.getPath(id)
+
+ try:
+ handler = urllib2.build_opener()
+ payload = handler.open(url).read()
+ except Exception as error:
+ console.error('HTTP fail %s (%s)' % (url, error))
+
+ return Cache.write(id, payload, url)
+
+
+ @staticmethod
+ def write(id, payload, info = None):
+ writefile(".pukecache/%s" % id, payload)
+
+ if info:
+ writefile(".pukecache/%s.meta" % id, info)
+
+ return Cache.getPath(id)
+
+ @staticmethod
+ def read(id):
+ if not Cache.check(id):
+ return None
+
+ return readfile(".pukecache/%s" % id)
+
+ @staticmethod
+ def check(id):
+ return fileexists(".pukecache/%s" % id)
+
+ @staticmethod
+ def getPath(id):
+ return ".pukecache/%s" % id
+
+ @staticmethod
+ def getInfo(id):
+ if not fileexists(".pukecache/%s.meta" % id):
+ return ""
+
+ return readfile(".pukecache/%s.meta" % id)
+
+
+ @staticmethod
+ def clean():
+ try:
+ rm(".pukecache/")
+ return True
+ except:
+ return False
View
@@ -1,54 +1,80 @@
-import logging, sys, os
+import logging, sys, os, json
from colorama import *
init(autoreset = True)
class console:
+
@staticmethod
- def log(msg):
+ def log(*messages):
+ color = Style.BRIGHT
if os.environ.get("NOCOLOR"):
- logging.info( msg)
- else:
- logging.info( Style.BRIGHT + msg)
+ color = ""
+
+ for m in messages:
+ msg = console.stringify(m)
+ logging.info(color + msg)
@staticmethod
- def info(msg):
- logging.info( msg)
+ def info(*messages):
+ for m in messages:
+ msg = console.stringify(m)
+ logging.info( msg)
@staticmethod
- def debug(msg):
+ def debug(*messages):
+ color = Back.BLUE
+
if os.environ.get("NOCOLOR"):
- logging.debug( msg )
- else:
- logging.debug( Back.BLUE + msg )
+ color = ""
+
+ if os.environ.get("NOCOLOR"):
+ color = ""
+
+ for m in messages:
+ msg = console.stringify(m)
+ logging.debug( color + msg )
@staticmethod
- def warn(msg):
-
- msg = console.pukefactory(msg)
+ def warn(*messages):
+ color = Fore.YELLOW + Style.BRIGHT
+
if os.environ.get("NOCOLOR"):
- logging.warning( msg)
- else:
- logging.warning( Fore.YELLOW + Style.BRIGHT + msg)
+ color = ""
+
+ for m in messages:
+ msg = console.stringify(m)
+ msg = console.pukefactory(msg)
+
+ logging.warning( color + msg)
@staticmethod
- def error(msg):
+ def error(*messages):
+ color = Back.RED + Style.BRIGHT
+
if os.environ.get("NOCOLOR"):
- logging.error( msg)
- else:
- logging.error( Back.RED + Style.BRIGHT + msg)
+ color = ""
+
+ for m in messages:
+ msg = console.stringify(m)
+ logging.error( color + msg)
@staticmethod
- def confirm(msg):
+ def confirm(*messages):
+ color = Fore.GREEN + Style.BRIGHT
+
if os.environ.get("NOCOLOR"):
- logging.info(msg )
- else:
- logging.info(Fore.GREEN + Style.BRIGHT + msg )
+ color = ""
+
+ for m in messages:
+ msg = console.stringify(m)
+ logging.info(color + msg )
@staticmethod
def header(msg, level = 2):
+ msg = console.stringify(msg)
logging.info("")
if level == 1:
color = Fore.MAGENTA
@@ -62,6 +88,7 @@ def header(msg, level = 2):
@staticmethod
def fail(msg):
+ msg = console.stringify(msg)
msg = console.pukefactory(msg)
console.error(" /!\\ BUILD FAIL : " + msg)
sys.exit(1)
@@ -81,4 +108,9 @@ def pukefactory(msg):
return msg
+ @staticmethod
+ def stringify(msg):
+ if isinstance(msg, str):
+ return msg
+ return json.JSONEncoder().encode(msg)
View
@@ -1,10 +1,12 @@
import os, logging
import fnmatch, re
-import urllib2
import hashlib
+
+
from puke.Console import *
from puke.FileSystem import *
+from puke.Cache import *
@@ -72,6 +74,17 @@ def get (self, full = False):
return self.__list
+
+ @staticmethod
+ def getSignature(list):
+ sig = ""
+ for (f,p) in list:
+ sig += "%s" % hashlib.sha256(f).hexdigest()
+
+ sig = hashlib.sha256(sig).hexdigest()
+
+ return sig
+
@staticmethod
def check(flist, full = False):
if isinstance(flist, FileList):
@@ -90,7 +103,7 @@ def check(flist, full = False):
for (f, p) in flist:
if f.startswith('http'):
- f = PukeBuffer.fetchHttp(f)
+ f = Cache.fetchHttp(f)
if not full:
result.append(f)
@@ -119,54 +132,5 @@ def __explore(self, dir ):
-class PukeBuffer:
- @staticmethod
- def fetchHttp(url):
- id = hashlib.sha256(url).hexdigest()
-
- if PukeBuffer.check(id):
- return PukeBuffer.getPath(id)
-
- try:
- handler = urllib2.build_opener()
- payload = handler.open(url).read()
- except Exception as error:
- console.error('HTTP fail %s (%s)' % (url, error))
-
- return PukeBuffer.write(id, payload, url)
-
-
- @staticmethod
- def write(id, payload, info = None):
- writefile(".pukecache/%s" % id, payload)
-
- if info:
- writefile(".pukecache/%s.meta" % id, info)
-
- return PukeBuffer.getPath(id)
-
- @staticmethod
- def check(id):
- return fileexists(".pukecache/%s" % id)
-
- @staticmethod
- def getPath(id):
- return ".pukecache/%s" % id
-
- @staticmethod
- def getInfo(id):
- if not fileexists(".pukecache/%s.meta" % id):
- return ""
-
- return readfile(".pukecache/%s.meta" % id)
-
-
- @staticmethod
- def clean():
- try:
- rm(".pukecache/")
- return True
- except:
- return False
View
@@ -1,4 +1,4 @@
-import os
+import os, time
import shutil
from puke.Console import *
Oops, something went wrong.

0 comments on commit 426e9ff

Please sign in to comment.