Эх сурвалжийг харах

Merge branch 'master' of https://deeejas.asuscomm.com:3000/Shared/anafapi.git

marton levente 3 сар өмнө
parent
commit
a0ee67ad74
1 өөрчлөгдсөн 5 нэмэгдсэн , 2 устгасан
  1. 5 2
      anafapi/anafspv.py

+ 5 - 2
anafapi/anafspv.py

@@ -103,8 +103,11 @@ class anafSPV(object):
         os.makedirs(os.path.join(self.DLLOC, cui), exist_ok=True)
         words = details.split()
         result_string = ' '.join(words[:3]) if len(words) >= 3 else ' '.join(words[:2]) if len(words) == 2 else details
-        with open(os.path.join(self.DLLOC, cui, '{}_{}_{}.pdf'.format(cui, result_string, id_)), 'wb') as file:
-            file.write(response.content)
+        try:
+            with open(os.path.join(self.DLLOC, cui, '{}_{}_{}.pdf'.format(cui, result_string, id_)), 'wb') as file:
+                file.write(response.content)
+        except FileNotFoundError:
+            pass
 
     def get_vector(self, cui):
         response = self.session.get(self.VECT.format(cui), cookies=self.requests_cookies).json()