Skip to content
This repository was archived by the owner on Jul 1, 2022. It is now read-only.

Commit ccabc37

Browse files
committed
FileNotFoundError is python3 only, support IOError. Fix #29
1 parent aaf6249 commit ccabc37

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

dagr/dagr.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,21 @@
2020
expanduser, join as path_join
2121
)
2222
from random import choice
23+
from requests import (
24+
adapters as req_adapters,
25+
codes as req_codes,
26+
session as req_session
27+
)
28+
from mechanicalsoup import StatefulBrowser
2329

30+
# Python 2/3 compatibility stuff
2431
try:
2532
# Python 3
2633
import configparser
2734
except ImportError:
2835
# Python 2
2936
import ConfigParser as configparser
30-
31-
from mechanicalsoup import StatefulBrowser
32-
from requests import (
33-
adapters as req_adapters,
34-
codes as req_codes,
35-
session as req_session
36-
)
37+
FNF_Error = getattr(__builtins__, 'FileNotFoundError', IOError)
3738

3839

3940
# Helper functions
@@ -56,7 +57,7 @@ class Dagr:
5657
"""deviantArt gallery ripper class"""
5758

5859
NAME = basename(__file__)
59-
__version__ = "0.70"
60+
__version__ = "0.70.1"
6061
MAX_DEVIATIONS = 1000000 # max deviations
6162
ART_PATTERN = (r"https://www\.deviantart\.com/"
6263
r"[a-zA-Z0-9_-]*/art/[a-zA-Z0-9_-]*")
@@ -253,7 +254,7 @@ def get_images(self, mode, mode_arg, pages):
253254
try:
254255
with open(base_dir + "/.dagr_downloaded_pages", "r") as filehandle:
255256
existing_pages = json.load(filehandle)
256-
except FileNotFoundError as fnf_error:
257+
except FNF_Error as fnf_error:
257258
# May not exist (new directory, ...)
258259
pass
259260
if not self.overwrite:

0 commit comments

Comments
 (0)