def dereference_resource_descriptor(descriptor, base_path, base_descriptor=None):
PROPERTIES = ['<STR_LIT>', '<STR_LIT>']<EOL>if base_descriptor is None:<EOL><INDENT>base_descriptor = descriptor<EOL><DEDENT>for property in PROPERTIES:<EOL><INDENT>value = descriptor.get(property)<EOL>if not isinstance(value, six.string_types):<EOL><INDENT>continue<EOL><DEDENT>if value.startswith('<STR_LIT:#>'):<EOL><INDENT>try:<EOL><INDENT>pointer = jsonpointer.JsonPointer(value[<NUM_LIT:1>:])<EOL>descriptor[property] = pointer.resolve(base_descriptor)<EOL><DEDENT>except Exception as error:<EOL><INDENT>message = '<STR_LIT>' % (value, property)<EOL>six.raise_from(<EOL>exceptions.DataPackageException(message),<EOL>error<EOL>)<EOL><DEDENT><DEDENT>elif value.startswith('<STR_LIT:http>'):<EOL><INDENT>try:<EOL><INDENT>response = requests.get(value)<EOL>response.raise_for_status()<EOL>descriptor[property] = response.json()<EOL><DEDENT>except Exception as error:<EOL><INDENT>message = '<STR_LIT>' % (value, property)<EOL>six.raise_from(<EOL>exceptions.DataPackageException(message),<EOL>error<EOL>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if not is_safe_path(value):<EOL><INDENT>raise exceptions.DataPackageException(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % (value, property))<EOL><DEDENT>if not base_path:<EOL><INDENT>raise exceptions.DataPackageException(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % (value, property))<EOL><DEDENT>fullpath = os.path.join(base_path, value)<EOL>try:<EOL><INDENT>with io.open(fullpath, encoding='<STR_LIT:utf-8>') as file:<EOL><INDENT>descriptor[property] = json.load(file)<EOL><DEDENT><DEDENT>except Exception as error:<EOL><INDENT>message = '<STR_LIT>' % (value, property)<EOL>six.raise_from(<EOL>exceptions.DataPackageException(message),<EOL>error<EOL>)<EOL><DEDENT><DEDENT><DEDENT>return descriptor<EOL>
Dereference resource descriptor (IN-PLACE FOR NOW).