Repository: getnikola/nikola

Issue:
import_wordpress --no-downloads still creates empty folders
```
[2016-02-23T15:43:03Z] INFO: init: Created empty site at new_site.
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2007/05/dashboard.jpg => new_site/files/blog/wp-content/uploads/2007/05/dashboard.jpg
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2007/05/screenshot7.jpeg => new_site/files/blog/wp-content/uploads/2007/05/screenshot7.jpeg
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2007/07/p1012766.JPG => new_site/files/blog/wp-content/uploads/2007/07/p1012766.JPG
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2007/07/p1012763.JPG => new_site/files/blog/wp-content/uploads/2007/07/p1012763.JPG
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29.png => new_site/files/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29.png
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29-300x187.png => new_site/files/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29-300x187.png
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29-1024x640.png => new_site/files/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29-1024x640.png
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29-150x150.png => new_site/files/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29-150x150.png
```

```
new_site/files/blog/
└── wp-content
    └── uploads
        ├── 2007
        │   ├── 05
        │   └── 07
        └── 2010
            └── 12
```

import_wordpress --no-downloads still creates empty folders
```
[2016-02-23T15:43:03Z] INFO: init: Created empty site at new_site.
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2007/05/dashboard.jpg => new_site/files/blog/wp-content/uploads/2007/05/dashboard.jpg
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2007/05/screenshot7.jpeg => new_site/files/blog/wp-content/uploads/2007/05/screenshot7.jpeg
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2007/07/p1012766.JPG => new_site/files/blog/wp-content/uploads/2007/07/p1012766.JPG
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2007/07/p1012763.JPG => new_site/files/blog/wp-content/uploads/2007/07/p1012763.JPG
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29.png => new_site/files/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29.png
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29-300x187.png => new_site/files/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29-300x187.png
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29-1024x640.png => new_site/files/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29-1024x640.png
[2016-02-23T15:43:03Z] INFO: import_wordpress: Downloading http://davidak.de/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29-150x150.png => new_site/files/blog/wp-content/uploads/2010/12/Bildschirmfoto-2010-12-14-um-19.47.29-150x150.png
```

```
new_site/files/blog/
└── wp-content
    └── uploads
        ├── 2007
        │   ├── 05
        │   └── 07
        └── 2010
            └── 12
```



Discussion:

Resolving patch:
diff --git a/nikola/plugins/command/import_wordpress.py b/nikola/plugins/command/import_wordpress.py
--- a/nikola/plugins/command/import_wordpress.py
+++ b/nikola/plugins/command/import_wordpress.py
@@ -446,9 +446,6 @@ def populate_context(self, channel):
 
     def download_url_content_to_file(self, url, dst_path):
         """Download some content (attachments) to a file."""
-        if self.no_downloads:
-            return
-
         try:
             request = requests.get(url, auth=self.auth)
             if request.status_code >= 400:
@@ -468,10 +465,13 @@ def import_attachment(self, item, wordpress_namespace):
                             'foo')
         path = urlparse(url).path
         dst_path = os.path.join(*([self.output_folder, 'files'] + list(path.split('/'))))
-        dst_dir = os.path.dirname(dst_path)
-        utils.makedirs(dst_dir)
-        LOGGER.info("Downloading {0} => {1}".format(url, dst_path))
-        self.download_url_content_to_file(url, dst_path)
+        if self.no_downloads:
+            LOGGER.info("Skipping downloading {0} => {1}".format(url, dst_path))
+        else:
+            dst_dir = os.path.dirname(dst_path)
+            utils.makedirs(dst_dir)
+            LOGGER.info("Downloading {0} => {1}".format(url, dst_path))
+            self.download_url_content_to_file(url, dst_path)
         dst_url = '/'.join(dst_path.split(os.sep)[2:])
         links[link] = '/' + dst_url
         links[url] = '/' + dst_url
@@ -567,10 +567,13 @@ def add(our_key, wp_key, is_int=False, ignore_zero=False, is_float=False):
 
                         path = urlparse(url).path
                         dst_path = os.path.join(*([self.output_folder, 'files'] + list(path.split('/'))))
-                        dst_dir = os.path.dirname(dst_path)
-                        utils.makedirs(dst_dir)
-                        LOGGER.info("Downloading {0} => {1}".format(url, dst_path))
-                        self.download_url_content_to_file(url, dst_path)
+                        if self.no_downloads:
+                            LOGGER.info("Skipping downloading {0} => {1}".format(url, dst_path))
+                        else:
+                            dst_dir = os.path.dirname(dst_path)
+                            utils.makedirs(dst_dir)
+                            LOGGER.info("Downloading {0} => {1}".format(url, dst_path))
+                            self.download_url_content_to_file(url, dst_path)
                         dst_url = '/'.join(dst_path.split(os.sep)[2:])
                         links[url] = '/' + dst_url
 


Test patch: