mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
now both the viewer (loadLatestFile(..)) and buildcache (loaddiffs(..)) will not load diffs older than the latest base file...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
11b4705ded
commit
0dda320a5e
@ -2,7 +2,7 @@
|
|||||||
#=======================================================================
|
#=======================================================================
|
||||||
|
|
||||||
__version__ = '''0.0.01'''
|
__version__ = '''0.0.01'''
|
||||||
__sub_version__ = '''20140102074435'''
|
__sub_version__ = '''20140102083502'''
|
||||||
__copyright__ = '''(c) Alex A. Naanou 2011'''
|
__copyright__ = '''(c) Alex A. Naanou 2011'''
|
||||||
|
|
||||||
|
|
||||||
@ -269,16 +269,19 @@ def mergediffs(path, base, isdiff, merge, dfl,
|
|||||||
return res
|
return res
|
||||||
# base images file...
|
# base images file...
|
||||||
if get_latest_base:
|
if get_latest_base:
|
||||||
res.update(loadlatest(
|
base_file, data = loadlatest(
|
||||||
path,
|
path,
|
||||||
isversion if isversion != None else lambda n: n.endswith(base),
|
isversion if isversion != None else lambda n: n.endswith(base),
|
||||||
lambda n: n == base,
|
lambda n: n == base,
|
||||||
load if load != None else lambda path: json.load(open(path)),
|
load if load != None else lambda path: json.load(open(path)),
|
||||||
{},
|
{},
|
||||||
cmp,
|
cmp,
|
||||||
verbosity=verbosity))
|
verbosity=verbosity)
|
||||||
|
res.update(data)
|
||||||
|
base_date = os.path.basename(base_file).split('-')[0]
|
||||||
else:
|
else:
|
||||||
target = pathjoin(path, base)
|
target = pathjoin(path, base)
|
||||||
|
base_date = ''
|
||||||
if os.path.exists(target):
|
if os.path.exists(target):
|
||||||
if verbosity >= 1:
|
if verbosity >= 1:
|
||||||
print 'Loading: %s' % target
|
print 'Loading: %s' % target
|
||||||
@ -290,7 +293,8 @@ def mergediffs(path, base, isdiff, merge, dfl,
|
|||||||
else:
|
else:
|
||||||
files.sort(cmp)
|
files.sort(cmp)
|
||||||
for n in files:
|
for n in files:
|
||||||
if isdiff(n):
|
# skip non-diffs and diffs older than base...
|
||||||
|
if isdiff(n) and n.split('-')[0] >= base_date:
|
||||||
target = pathjoin(path, n)
|
target = pathjoin(path, n)
|
||||||
# XXX is this the correct way???
|
# XXX is this the correct way???
|
||||||
if verbosity >= 1:
|
if verbosity >= 1:
|
||||||
@ -312,7 +316,7 @@ def loadlatest(path, isversion, isbase, load, dfl, cmp=None, verbosity=0):
|
|||||||
base = None
|
base = None
|
||||||
# if no cache dir...
|
# if no cache dir...
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
return data
|
return path, data
|
||||||
files = os.listdir(path)
|
files = os.listdir(path)
|
||||||
if cmp == None:
|
if cmp == None:
|
||||||
files.sort()
|
files.sort()
|
||||||
@ -328,13 +332,13 @@ def loadlatest(path, isversion, isbase, load, dfl, cmp=None, verbosity=0):
|
|||||||
# XXX is this the correct way???
|
# XXX is this the correct way???
|
||||||
if verbosity >= 1:
|
if verbosity >= 1:
|
||||||
print 'Loading: %s' % target
|
print 'Loading: %s' % target
|
||||||
return load(target)
|
return target, load(target)
|
||||||
if base != None:
|
if base != None:
|
||||||
# XXX is this the correct way???
|
# XXX is this the correct way???
|
||||||
if verbosity >= 1:
|
if verbosity >= 1:
|
||||||
print 'Loading: %s' % base
|
print 'Loading: %s' % base
|
||||||
return load(base)
|
return base, load(base)
|
||||||
return data
|
return 'default', data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -364,7 +368,7 @@ def getdata(path, config=CONFIG, verbosity=0):
|
|||||||
lambda n: n == config['data'],
|
lambda n: n == config['data'],
|
||||||
lambda path: json.load(open(path)),
|
lambda path: json.load(open(path)),
|
||||||
{},
|
{},
|
||||||
verbosity=verbosity)
|
verbosity=verbosity)[-1]
|
||||||
|
|
||||||
|
|
||||||
#-----------------------------------------------------------getmarked---
|
#-----------------------------------------------------------getmarked---
|
||||||
@ -377,7 +381,7 @@ def getmarked(path, config=CONFIG, verbosity=0):
|
|||||||
lambda n: n == config['marked'],
|
lambda n: n == config['marked'],
|
||||||
lambda path: json.load(open(path)),
|
lambda path: json.load(open(path)),
|
||||||
[],
|
[],
|
||||||
verbosity=verbosity)
|
verbosity=verbosity)[-1]
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------gettags---
|
#-------------------------------------------------------------gettags---
|
||||||
@ -390,7 +394,7 @@ def gettags(path, config=CONFIG, verbosity=0):
|
|||||||
lambda n: n == config['tagscache'],
|
lambda n: n == config['tagscache'],
|
||||||
lambda path: json.load(open(path)),
|
lambda path: json.load(open(path)),
|
||||||
{},
|
{},
|
||||||
verbosity=verbosity)
|
verbosity=verbosity)[-1]
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------build_cache_dirs---
|
#----------------------------------------------------build_cache_dirs---
|
||||||
|
|||||||
@ -146,6 +146,8 @@ function loadLatestFile(path, dfl, pattern, diff_pattern, default_data){
|
|||||||
}).sort().reverse()[0]
|
}).sort().reverse()[0]
|
||||||
}
|
}
|
||||||
var file = file == null ? dfl : file
|
var file = file == null ? dfl : file
|
||||||
|
var base_date = file.split('-')[0]
|
||||||
|
base_date = base_date == file ? '' : base_date
|
||||||
|
|
||||||
var diff_data = {}
|
var diff_data = {}
|
||||||
var diff = true
|
var diff = true
|
||||||
@ -155,7 +157,8 @@ function loadLatestFile(path, dfl, pattern, diff_pattern, default_data){
|
|||||||
diff_pattern = RegExp(diff_pattern)
|
diff_pattern = RegExp(diff_pattern)
|
||||||
var diff_data = [diff_data]
|
var diff_data = [diff_data]
|
||||||
var diffs_names = $.map(listDir(path), function(e){
|
var diffs_names = $.map(listDir(path), function(e){
|
||||||
return diff_pattern.test(e) ? e : null
|
//return diff_pattern.test(e) ? e : null
|
||||||
|
return diff_pattern.test(e) && e.split('-')[0] >= base_date ? e : null
|
||||||
}).sort()
|
}).sort()
|
||||||
diff = $.when.apply(null, $.map(diffs_names, function(e, i){
|
diff = $.when.apply(null, $.map(diffs_names, function(e, i){
|
||||||
return $.getJSON(path +'/'+ e)
|
return $.getJSON(path +'/'+ e)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user