added multiple directory processing to buildcache...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-01-21 06:48:57 +04:00
parent d2362bd116
commit cbe6f43234
2 changed files with 96 additions and 82 deletions

View File

@ -2,7 +2,7 @@
#======================================================================= #=======================================================================
__version__ = '''0.0.01''' __version__ = '''0.0.01'''
__sub_version__ = '''20140112165326''' __sub_version__ = '''20140121064724'''
__copyright__ = '''(c) Alex A. Naanou 2011''' __copyright__ = '''(c) Alex A. Naanou 2011'''
@ -859,7 +859,7 @@ def handle_commandline():
res = None res = None
parser = OptionParser( parser = OptionParser(
usage='Usage: %prog [options] ROOT', usage='Usage: %prog [options] DIRS',
version='%prog ' + __version__, version='%prog ' + __version__,
epilog='Notes: This script is still experimental. ' epilog='Notes: This script is still experimental. '
'GID source default will change to "metadata" ' 'GID source default will change to "metadata" '
@ -949,7 +949,7 @@ def handle_commandline():
default=False, default=False,
help='Save current configuration at the root location. ' help='Save current configuration at the root location. '
'this is a shorthand for: ' 'this is a shorthand for: '
'%prog ... --config-print > ROOT/CONFIG; %prog') '%prog ... --config-print > DIR/CONFIG; %prog')
parser.add_option_group(configuration) parser.add_option_group(configuration)
@ -967,101 +967,114 @@ def handle_commandline():
# prepare the path... # prepare the path...
if len(args) < 1: if len(args) < 1:
IN_PATH = u'.' args = [u'.']
else:
IN_PATH = args[0] times = []
##!!! move all that is not needed in the loop to outside the loop...
for IN_PATH in args:
if len(times) > 0:
print
IN_PATH = IN_PATH.replace('\\', '/') IN_PATH = IN_PATH.replace('\\', '/')
##!!! need to convert this ut utf-8... ##!!! need to convert this ut utf-8...
if not options.force_ascii and type(IN_PATH) != unicode: if not options.force_ascii and type(IN_PATH) != unicode:
IN_PATH = IN_PATH.decode(DEFAULT_ENCODING) IN_PATH = IN_PATH.decode(DEFAULT_ENCODING)
# load configuration files.. # load configuration files..
config_name = options.config_file config_name = options.config_file
# local to script... # local to script...
if os.path.exists(config_name): if os.path.exists(config_name):
with open(config_name) as f: with open(config_name) as f:
config.update(json.load(f)) config.update(json.load(f))
# local to target... # local to target...
if os.path.exists(os.path.join(IN_PATH, config_name)): if os.path.exists(os.path.join(IN_PATH, config_name)):
with open(os.path.join(IN_PATH, config_name)) as f: with open(os.path.join(IN_PATH, config_name)) as f:
config.update(json.load(f)) config.update(json.load(f))
# update config according to set args... # update config according to set args...
config.update({ config.update({
'gid-source': options.gid_source, 'gid-source': options.gid_source,
'absolute-path': options.path_mode == 'absolute', 'absolute-path': options.path_mode == 'absolute',
'ignore-orientation': options.ignore_orientation, 'ignore-orientation': options.ignore_orientation,
'base-ribbon': int(options.base_ribbon), 'base-ribbon': int(options.base_ribbon),
'full-scan': options.full_scan, 'full-scan': options.full_scan,
'force-ascii': options.force_ascii, 'force-ascii': options.force_ascii,
}) })
# build the tags... # build the tags...
tags = config['tags'] = list(set(options.tag + config['tags']).difference(options.notag)) tags = config['tags'] = list(set(options.tag + config['tags']).difference(options.notag))
# a value from 0 through 2... # a value from 0 through 2...
verbosity = options.verbosity verbosity = options.verbosity
# bool... # bool...
dry_run = options.dry_run dry_run = options.dry_run
images_only = options.images_only images_only = options.images_only
# configuration stuff... # configuration stuff...
# write a local configuration... # write a local configuration...
if options.config_save_local: if options.config_save_local:
with open(os.path.join(IN_PATH, config_name), 'w', with open(os.path.join(IN_PATH, config_name), 'w',
encoding='ascii' if config['force-ascii'] else 'utf-8') as f: encoding='ascii' if config['force-ascii'] else 'utf-8') as f:
## ##!!! json.dump writes some "strings" as unicode and some as str ## ##!!! json.dump writes some "strings" as unicode and some as str
## ##!!! this breaks fp.write(...)... ## ##!!! this breaks fp.write(...)...
## f.write(json.dumps(config, sort_keys=True, indent=4, ensure_ascii=config['force-ascii'])) ## f.write(json.dumps(config, sort_keys=True, indent=4, ensure_ascii=config['force-ascii']))
s = json.dumps(config, sort_keys=True, indent=4, ensure_ascii=config['force-ascii']) s = json.dumps(config, sort_keys=True, indent=4, ensure_ascii=config['force-ascii'])
if not config['force-ascii'] and type(s) != unicode: if not config['force-ascii'] and type(s) != unicode:
s = s.decode(DEFAULT_ENCODING) s = s.decode(DEFAULT_ENCODING)
f.write(s) f.write(s)
# print configuration data... # print configuration data...
if True in (options.config_defaults_print, options.config_print): if True in (options.config_defaults_print, options.config_print):
# see if we need to print a prefix... # see if we need to print a prefix...
print_prefix = False print_prefix = False
if len([ s for s in (options.config_defaults_print, options.config_print) if s]) > 1: if len([ s for s in (options.config_defaults_print, options.config_print) if s]) > 1:
print_prefix = True print_prefix = True
# do the prinitng... # do the prinitng...
if options.config_print: if options.config_print:
if print_prefix: if print_prefix:
print 'Current Configuration:' print 'Current Configuration:'
print json.dumps(config, sort_keys=True, indent=4, ensure_ascii=config['force-ascii']) print json.dumps(config, sort_keys=True, indent=4, ensure_ascii=config['force-ascii'])
print print
if options.config_defaults_print: if options.config_defaults_print:
if print_prefix: if print_prefix:
print 'Default Configuration:' print 'Default Configuration:'
print json.dumps(CONFIG, sort_keys=True, indent=4, ensure_ascii=config['force-ascii']) print json.dumps(CONFIG, sort_keys=True, indent=4, ensure_ascii=config['force-ascii'])
print print
# do the actual work... # do the actual work...
# NOTE: we are not using verbosity 2 at this point... # NOTE: we are not using verbosity 2 at this point...
else: else:
progress_state = {} progress_state = {}
if verbosity == 0: if verbosity == 0:
report = None report = None
elif verbosity >= 1: elif verbosity >= 1:
report = make_inline_report_progress(progress_state) report = make_inline_report_progress(progress_state)
# do the run... # do the run...
res = build_cache(IN_PATH, res = build_cache(IN_PATH,
config, config,
hash_gid, hash_gid,
report, report,
dry_run=dry_run, dry_run=dry_run,
images_only=images_only, images_only=images_only,
verbosity=verbosity) verbosity=verbosity)
# report results... # report results...
if verbosity >= 1: if verbosity >= 1:
print times += [(progress_state['done at'] - progress_state['started at'])/60]
print 'Time: %.1fm' % ((progress_state['done at'] - progress_state['started at'])/60) print
print 'Time: %.1fm' % (times[-1],)
# report results...
if verbosity >= 1 and len(times) > 1:
print
print 'Total time: %.1fm' % (sum(times),)
## # XXX this makes the script spit out res to stdout... ## # XXX this makes the script spit out res to stdout...
## return res ## return res

View File

@ -322,6 +322,7 @@ var getElementScale = makeCSSVendorAttrGetter(
return parseFloat((/(scale|matrix)\(([^),]*)\)/).exec(data)[2]) return parseFloat((/(scale|matrix)\(([^),]*)\)/).exec(data)[2])
}) })
var getElementShift = makeCSSVendorAttrGetter( var getElementShift = makeCSSVendorAttrGetter(
'transform', 'transform',
{left: 0, top: 0}, {left: 0, top: 0},
@ -340,7 +341,6 @@ var getElementTransitionDuration = makeCSSVendorAttrGetter(
parseInt) parseInt)
// NOTE: at this point this works only on the X axis... // NOTE: at this point this works only on the X axis...
function setElementTransform(elem, offset, scale, duration){ function setElementTransform(elem, offset, scale, duration){
elem = $(elem) elem = $(elem)
@ -513,6 +513,7 @@ function animateElementTo(elem, to, duration, easing, speed, use_transitions){
} }
} }
function stopAnimation(elem){ function stopAnimation(elem){
if(elem.next_frame){ if(elem.next_frame){
cancelAnimationFrame(elem.next_frame) cancelAnimationFrame(elem.next_frame)