richq / folders2flickr

Upload files to flickr
Other
102 stars 38 forks source link

Many path to upload images from #39

Open replay111 opened 9 years ago

replay111 commented 9 years ago

Hi,

is it possible to type more than one path in init file i.e.:

imagedir = /home/my_images/cars,/home/my_images/planes,/home/my_images/kids

or like:

imagedir[] = /home/my_images/cars imagedir[] = /home/my_images/planes imagedir[] = /home/my_images/kids

so app could proces a couple path, not only pic from one path?

lozbrown commented 9 years ago

bearing in mind that I've never done any python before, would this not work? I think this would split on semicolon

def grabNewImages(manydirname):                                                                                                             
    """                                                                                                                                     
    get all images in folders and subfolders which match extensions below                                                                   
    """                                                                                                                                     
    images = []                                                                                                                             
    manydirname = manydirname.split(";")                                                                                                    
    for dirname in manydirname:                                                                                                             
        for dirpath, dirnames, filenames in os.walk(dirname, topdown=True, followlinks=True):                                               
                ignore = '.f2fignore' in filenames                                                                                          
                # use os.stat here                                                                                                          
                ignoreglobs = []                                                                                                            
                if ignore:                                                                                                                  
                        fp = open(os.path.normpath(os.path.join(dirpath, '.f2fignore')))                                                    
                        ignoreglobs = parseIgnore(fp.readlines())                                                                           
                        fp.close()                                                                                                          
                dirnames[:] = [d for d in dirnames if not d[0] == '.'                                                                       
                                           and not ignoreMatch(d, ignoreglobs)]                                                             
                for f in filenames:                                                                                                         
                        if f.startswith('.'):                                                                                               
                                continue                                                                                                    
                        ext = f.lower().split(".")[-1]                                                                                      
                        if ext in ALLOWED_EXT and not ignoreMatch(f, ignoreglobs):                                                          
                                images.append(os.path.normpath(os.path.join(dirpath, f)))                                                   
    images.sort()                                                                                                                           
    return images                                                                                             
lozbrown commented 9 years ago

The above will make it find photos in each of the locations but seems to have broken something with the creation of sets. @richq any ideas?

2014-12-07 06:45:18,881 tags2set: Cannot create set "" 2014-12-07 06:45:18,881 list index out of range 2014-12-07 06:45:18,881 <type 'exceptions.IndexError'> 2014-12-07 06:45:18,881 tags2set: Cannot edit set 2014-12-07 06:45:18,881 'NoneType' object has no attribute 'editPhotos' 2014-12-07 06:45:18,881 <type 'exceptions.AttributeError'>

richq commented 9 years ago

I've had a quick look and it's nothing wrong with this code. It just adds an outer loop over the semicolon separated strings. I wrote a couple of tests to check that the code works as expected, and the existing (low number of) tests pass OK so there's no big regressions there.

The problem looks to be where IMAGE_DIR is used to get the folderTag. That'd need some fiddling too to get it to work.

lozbrown commented 9 years ago

Thanks for taking a look @richq

I'm not much of a python programer: Could images (the list that is returned by grabNewImages) be turned into an array with the original folder and the image itself being added to the aray.... or Somehow trim back the image path to the one we originally had ..?