Commit e33a48cb authored by abuddenberg's avatar abuddenberg
Browse files

Removed hardcoded dependency on dist/images directory; now creates dir structure under home

parent ef618aa6
......@@ -2,7 +2,8 @@
import urllib
import re
from os.path import join
from os.path import join, expanduser, exists
from os import makedirs
import requests
from dateutil.parser import parse
......@@ -21,13 +22,19 @@ def sanitized(pattern):
return dec
def build_image_dir():
image_dir = expanduser('~/.gcis-py-client/images/')
if not exists(image_dir):
makedirs(image_dir)
return image_dir
class WebformClient:
def __init__(self, url, token, local_image_dir='../dist/images/'):
def __init__(self, url, token, local_image_dir=None, remote_dir='/system/files/'):
self.base_url = url
self.token = token
self.images_dir = local_image_dir
self.remote_image_dir = '/system/files/'
self.images_dir = local_image_dir if local_image_dir else build_image_dir()
self.remote_image_dir = remote_dir
def get_list(self):
url = '{b}/metadata/list?token={t}'.format(b=self.base_url, t=self.token)
......@@ -147,4 +154,4 @@ class WebformClient:
dataset_map[dataset.identifier].merge(dataset)
dataset_map[dataset.identifier].activity.merge(dataset.activity)
return dataset_map.values()
\ No newline at end of file
return dataset_map.values()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment