mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
added .relatedtags(...) to tags.py...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
61e9166e18
commit
48574cee03
7
TODO.otl
7
TODO.otl
@ -1,4 +1,4 @@
|
|||||||
[_] 11% general tasks
|
[_] 14% general tasks
|
||||||
[_] 0% actions:
|
[_] 0% actions:
|
||||||
[_] import
|
[_] import
|
||||||
[_] export/build
|
[_] export/build
|
||||||
@ -47,8 +47,9 @@
|
|||||||
| this can happen when adding a new object to a tag via an .update(...) method, in-place.
|
| this can happen when adding a new object to a tag via an .update(...) method, in-place.
|
||||||
|
|
|
|
||||||
| need to use immutable data only.
|
| need to use immutable data only.
|
||||||
[_] 0% compleate the new tags module
|
[_] 33% compleate the new tags module
|
||||||
[_] .relatedtags(...)
|
[X] .relatedtags(...)
|
||||||
|
[_] see if we need strict and non-strict .relatedtags(...)
|
||||||
[_] concatinative mode or abbility to build new tagsets from selections
|
[_] concatinative mode or abbility to build new tagsets from selections
|
||||||
[_] import test images and ratings
|
[_] import test images and ratings
|
||||||
[_] importer based on xmpgen
|
[_] importer based on xmpgen
|
||||||
|
|||||||
25
tags.py
25
tags.py
@ -1,7 +1,7 @@
|
|||||||
#=======================================================================
|
#=======================================================================
|
||||||
|
|
||||||
__version__ = '''0.0.01'''
|
__version__ = '''0.0.01'''
|
||||||
__sub_version__ = '''20111001012751'''
|
__sub_version__ = '''20111004190928'''
|
||||||
__copyright__ = '''(c) Alex A. Naanou 2011'''
|
__copyright__ = '''(c) Alex A. Naanou 2011'''
|
||||||
|
|
||||||
|
|
||||||
@ -145,8 +145,22 @@ class TagSetWithReverseIndexMixin(AbstractTagSet):
|
|||||||
return self._reverse_index.keys()
|
return self._reverse_index.keys()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------TagSetWithRelatedTagsMixin---
|
||||||
|
class TagSetWithRelatedTagsMixin(AbstractTagSet):
|
||||||
|
'''
|
||||||
|
|
||||||
|
NOTE: this requires the .tags(...) method.
|
||||||
|
'''
|
||||||
|
##!!! should be two modes: strict (all) and non-strict (any)...
|
||||||
|
def relatedtags(self, *tags):
|
||||||
|
'''
|
||||||
|
'''
|
||||||
|
return self.tags(*self.all(*tags)).difference(tags)
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------TagSet---
|
#--------------------------------------------------------------TagSet---
|
||||||
class TagSet(TagSetWithReverseIndexMixin, BasicTagSet):
|
class TagSet(TagSetWithRelatedTagsMixin, TagSetWithReverseIndexMixin, BasicTagSet):
|
||||||
'''
|
'''
|
||||||
'''
|
'''
|
||||||
pass
|
pass
|
||||||
@ -224,7 +238,8 @@ if __name__ == '__main__':
|
|||||||
## ts = TagSetWithObjectIndex()
|
## ts = TagSetWithObjectIndex()
|
||||||
|
|
||||||
|
|
||||||
N = 100000
|
## N = 100000
|
||||||
|
N = 1000
|
||||||
obj_tpl = 'image%010d'
|
obj_tpl = 'image%010d'
|
||||||
|
|
||||||
def populate_tagset():
|
def populate_tagset():
|
||||||
@ -263,6 +278,10 @@ if __name__ == '__main__':
|
|||||||
print ts.tags(obj_tpl % 0)
|
print ts.tags(obj_tpl % 0)
|
||||||
print ts.tags(obj_tpl % 10)
|
print ts.tags(obj_tpl % 10)
|
||||||
|
|
||||||
|
print ts.relatedtags('image')
|
||||||
|
print ts.relatedtags('image', '0')
|
||||||
|
print ts.relatedtags('10')
|
||||||
|
|
||||||
|
|
||||||
print 'selecting (all)...',
|
print 'selecting (all)...',
|
||||||
t0 = time()
|
t0 = time()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user