def download_attachments(output_path, urls):
 locations = []
 for url in urls:
  path = urlparse(url).path
  path = path.split(u'/')
  filename = path.pop((-1))
  localpath = u''
  for item in path:
   if ((sys.platform != u'win32') or (u':' not in item)):
    localpath = os.path.join(localpath, item)
  full_path = os.path.join(output_path, localpath)
  if (not os.path.exists(full_path)):
   os.makedirs(full_path)
  print(u'downloading {}'.format(filename))
  try:
   urlretrieve(url, os.path.join(full_path, filename))
   locations.append(os.path.join(localpath, filename))
  except (URLError, IOError) as e:
   logger.warning(u'No file could be downloaded from %s\n%s', url, e)
 return locations

def download_attachments ( output_path , urls ) : locations = [ ] for url in urls : path = urlparse ( url ) . path path = path . split ( u'/' ) filename = path . pop ( ( - 1 ) ) localpath = u'' for item in path : if ( ( sys . platform != u'win32' ) or ( u':' not in item ) ) : localpath = os . path . join ( localpath , item ) full_path = os . path . join ( output_path , localpath ) if ( not os . path . exists ( full_path ) ) : os . makedirs ( full_path ) print ( u'downloading {}' . format ( filename ) ) try : urlretrieve ( url , os . path . join ( full_path , filename ) ) locations . append ( os . path . join ( localpath , filename ) ) except ( URLError , IOError ) as e : logger . warning ( u'No file could be downloaded from %s\n%s' , url , e ) return locations
downloads wordpress attachments and returns a list of paths to attachments that can be associated with a post .