def addPicture(self,button): ''' This functions adds a picture from the filesystem to the database. ''' path=getFile() Hash=p.add(path,'setMe') # set the current image to this one after refreshing everything self.refreshTags() for button in self.pictures: if button.get_label() == Hash: button.toggled() break
# this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies # of the Software, and to permit persons to whom the Software is furnished to do # so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import pictures as p from sys import argv,exit import os.path if len(argv) != 3: print("Usage: python addall.py idb directory") exit(1) p._idb = p.idb.db(argv[1]) i = argv[2] if os.path.isfile(i): try: p.add(i, 'setMe') except AssertionError as e: print('Already in database!')
# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import pictures as p from sys import argv,exit import os import os.path def genTags(name): tags = '.'.join(name.split(' - ', 1)[1].split('.')[:-1]).split(',') for n, i in enumerate(tags[:]): tags[n] = i.strip() return tags if len(argv) != 3: print("Usage: python addall.py idb directory") exit(1) p._idb = p.idb.db(argv[1]) # get a list of files in the directory for i in os.listdir(argv[2]): if os.path.isfile(argv[2] + i): print("current path is: " + argv[2] + i) p.add(argv[2] + i, genTags(i))