Ejemplo n.º 1
0
    QUERY = 'PSD'

    parser = OptionParser()

    ##!!! need to define the path so that it shoes up in -h

    options, args = parser.parse_args()

    if len(args) != 1:
        parser.print_usage()
    else:
        config = json.load(open(CONFIG_NAME))
        INDEX_PATH = config.get('INDEX_ROOT', os.path.join('test', 'index2'))
        ARCHIVE_ROOT = config.get('ARCHIVE_ROOT', '')

        IN_PATH = args[0]
        IN_PATH = IN_PATH.replace('\\', '/')

        guid = gid.image_gid(IN_PATH)

        index = store.Index(INDEX_PATH)

        for p in index[guid][QUERY]:
            path, name, ext, date = p
            ##!!! this is windows-only
            print '%s\\%s.%s' % ('\\'.join([ARCHIVE_ROOT] + path), name, ext)

#=======================================================================
#                                            vim:set ts=4 sw=4 nowrap :
Ejemplo n.º 2
0
	parser = OptionParser()

	##!!! need to define the path so that it shoes up in -h

	options, args = parser.parse_args()

	if len(args) != 1:
		parser.print_usage()
	else:
		config = json.load(open(CONFIG_NAME))
		INDEX_PATH = config.get('INDEX_ROOT', os.path.join('test', 'index2'))
		ARCHIVE_ROOT = config.get('ARCHIVE_ROOT', '')

		IN_PATH = args[0]
		IN_PATH = IN_PATH.replace('\\', '/')

		guid = gid.image_gid(IN_PATH)

		index = store.Index(INDEX_PATH)

		for p in index[guid][QUERY]:
			path, name, ext, date = p
			##!!! this is windows-only
			print '%s\\%s.%s' % ('\\'.join([ARCHIVE_ROOT] + path), name, ext)




#=======================================================================
#                                            vim:set ts=4 sw=4 nowrap :
Ejemplo n.º 3
0
def gid_index(index, existing=None):
    '''
	'''
    skipped = []
    # index via a propper GID...
    # split similarly named but different files...
    if existing is None:
        res = {}
    else:
        res = existing
    failed = []
    im_n = 0
    up_n = 0
    new_n = 0

    for name, l in index.iteritems():
        l.sort()
        raws = [e for e in l if e[2] == RAW]

        # multiple raw files...
        if len(raws) > 1:
            sets = split_by_raws(raws, l, failed)
        # single raw...
        elif len(raws) == 1:
            sets = [(raws[0], l)]
        # no raw files...
        else:
            print(' ' *
                  78), '\rno raw file found for "%s"...' % os.path.join(name)
            sets = []
            ##!!! need to report this in a usable way...
            failed += l

        # add actual elements to index...
        for raw, l in sets:
            im_n += 1
            print 'Processing image:', im_n, 'new:', new_n, 'updated:', up_n, '\r',

            # get file GID...
            GID = image_gid('%s.%s' % (os.path.join(
                *[config['ARCHIVE_ROOT']] + raw[0] + [raw[1]]), raw[2]))

            ##!!! normalize the image format...
            img = {
                'gid': GID,
                'name': name,
                'imported': time.time(),
                'updated': time.time(),
                # NOTE: this might get distorted on archiving or
                # 		copying...
                # 		mostly intended for importing...
                'ctime': raw[3],
                ##!!! make these more general...
                'RAW': [e for e in l if e[2] == RAW],
                'XMP': [e for e in l if e[2] == XMP],
                'JPG': [e for e in l if e[2] == JPEG],
                'PSD': [e for e in l if e[2] == PSD],
                'TIFF': [e for e in l if e[2] == TIFF],
                'other':
                [e for e in l if e[2] != OR(TIFF, PSD, JPEG, XMP, RAW)],
            }
            # add new data...
            if GID not in res:
                res[GID] = img
                new_n += 1
            # update existing...
            else:
                cur = res[GID]
                updating = False
                for k, v in img.iteritems():
                    # skip
                    if k in ('imported', 'name', 'gid', 'ctime', 'updated'):
                        continue
                    if v != cur[k]:
                        cur[k] = v
                        updating = True
                # do the actual update...
                if updating:
                    cur['updated'] = time.time()
                    res[GID] = cur
                    up_n += 1
                else:
                    skipped += [GID]

    return res, failed, skipped
Ejemplo n.º 4
0
def gid_index(index, existing=None):
	'''
	'''
	skipped = []
	# index via a propper GID...
	# split similarly named but different files...
	if existing is None:
		res = {}
	else:
		res = existing
	failed = []
	im_n = 0
	up_n = 0
	new_n = 0

	for name, l in index.iteritems():
		l.sort()
		raws = [e for e in l if e[2] == RAW] 

		# multiple raw files...
		if len(raws) > 1:
			sets = split_by_raws(raws, l, failed)
		# single raw...
		elif len(raws) == 1:
			sets = [(raws[0], l)]
		# no raw files...
		else:
			print (' '*78), '\rno raw file found for "%s"...' % os.path.join(name)
			sets = []
			##!!! need to report this in a usable way...
			failed += l

		# add actual elements to index...
		for raw, l in sets:
			im_n += 1
			print 'Processing image:', im_n, 'new:', new_n, 'updated:', up_n, '\r',

			# get file GID...
			GID = image_gid('%s.%s' % (os.path.join(*[config['ARCHIVE_ROOT']] + raw[0] + [raw[1]]), raw[2]))

			##!!! normalize the image format...
			img = {
				'gid': GID,
				'name': name,
				'imported': time.time(),
				'updated': time.time(),
				# NOTE: this might get distorted on archiving or
				# 		copying...
				# 		mostly intended for importing...
				'ctime': raw[3], 
				##!!! make these more general...
				'RAW': [e for e in l if e[2] == RAW],
				'XMP': [e for e in l if e[2] == XMP],
				'JPG': [e for e in l if e[2] == JPEG],
				'PSD': [e for e in l if e[2] == PSD],
				'TIFF': [e for e in l if e[2] == TIFF],
				'other': [e for e in l if e[2] != OR(TIFF, PSD, JPEG, XMP, RAW)],
			}
			# add new data...
			if GID not in res:
				res[GID] = img
				new_n += 1
			# update existing...
			else:
				cur = res[GID]
				updating = False
				for k, v in img.iteritems():
					# skip 
					if k in ('imported', 'name', 'gid', 'ctime', 'updated'):
						continue
					if v != cur[k]:
						cur[k] = v
						updating = True
				# do the actual update...
				if updating:
					cur['updated'] = time.time()
					res[GID] = cur
					up_n += 1
				else:
					skipped += [GID]

	return res, failed, skipped