Python urllib.unquote() Examples

The following are 30 code examples of urllib.unquote(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module urllib , or try the search function .
Example #1
Source File: elastic.py    From ivre with GNU General Public License v3.0 7 votes vote down vote up
def __init__(self, url):
        super(ElasticDB, self).__init__()
        self.username = ''
        self.password = ''
        self.hosts = None
        if '@' in url.netloc:
            username, hostname = url.netloc.split('@', 1)
            if ':' in username:
                self.username, self.password = (unquote(val) for val in
                                                username.split(':', 1))
            else:
                self.username = unquote(username)
            if hostname:
                self.hosts = [hostname]
        elif url.netloc:
            self.hosts = [url.netloc]
        index_prefix = url.path.lstrip('/')
        if index_prefix:
            self.index_prefix = index_prefix + '-'
        else:
            self.index_prefix = 'ivre-'
        self.params = dict(x.split('=', 1) if '=' in x else (x, None)
                           for x in url.query.split('&') if x) 
Example #2
Source File: SubmitOrderRequest.py    From 12306 with MIT License 6 votes vote down vote up
def __init__(self, selectObj, secretStr, from_station, to_station, train_no, set_type,
                 passengerTicketStrList, oldPassengerStr, train_date, ticke_peoples):
        self.session = selectObj
        # self.secretStr = secretStr
        try:
            self.secretStr = urllib.unquote(secretStr)
        except AttributeError:
            self.secretStr = urllib.parse.unquote(secretStr)
        self.from_station = from_station
        self.to_station = to_station
        self.to_station = to_station
        self.train_no = train_no
        self.set_type = set_type
        self.passengerTicketStrList = passengerTicketStrList
        self.oldPassengerStr = oldPassengerStr
        self.train_date = train_date
        self.ticke_peoples = ticke_peoples 
Example #3
Source File: s3server.py    From tornado-zh with MIT License 6 votes vote down vote up
def put(self, bucket, object_name):
        object_name = urllib.unquote(object_name)
        bucket_dir = os.path.abspath(os.path.join(
            self.application.directory, bucket))
        if not bucket_dir.startswith(self.application.directory) or \
           not os.path.isdir(bucket_dir):
            raise web.HTTPError(404)
        path = self._object_path(bucket, object_name)
        if not path.startswith(bucket_dir) or os.path.isdir(path):
            raise web.HTTPError(403)
        directory = os.path.dirname(path)
        if not os.path.exists(directory):
            os.makedirs(directory)
        object_file = open(path, "w")
        object_file.write(self.request.body)
        object_file.close()
        self.finish() 
Example #4
Source File: webapp.py    From kano-toolset with GNU General Public License v2.0 6 votes vote down vote up
def _parse_api_call(self, call_str):
        call_re = r"#api:(\w+)(\[\d+\])?(/[^/]*)+$"
        call_match = re.search(call_re, call_str)

        name = call_match.group(1)
        call = [name]
        timestamp = call_match.group(2)
        if timestamp is not None:
            call.append(timestamp[1:-1])
        else:
            call.append(None)

        args = re.sub(r"^#api:[^/]*/?", r"", call_match.group(0))

        if len(args) > 0:
            if args[-1] == "/":
                args = args[:-1]
            arglist = map(urllib.unquote, args.split("/"))
            call += arglist[1:]  # remove seq

        return call 
Example #5
Source File: base_view.py    From PyOne with Mozilla Public License 2.0 6 votes vote down vote up
def web_console():
    g = proc.Group()
    action=request.args.get('action')
    allow_action=['UpdateFile','UploadDir','Upload']
    if action not in allow_action:
        return make_response('error')
    if action in ['UploadDir','Upload']:
        local=urllib.unquote(request.args.get('local'))
        remote=urllib.unquote(request.args.get('remote'))
        user=urllib.unquote(request.args.get('user'))
        cmd=["python","-u",os.path.join(config_dir,'function.py'),action,local,remote,user]
    elif action=='UpdateFile':
        type_=request.args.get('type')
        cmd=["python","-u",os.path.join(config_dir,'function.py'),'UpdateFile',type_]
    else:
        cmd=["python","-u",os.path.join(config_dir,'function.py'),action]
    p = g.run(cmd)
    def read_process():
        while g.is_pending():
            lines = g.readlines()
            for proc, line in lines:
                yield "data:" + line + "\n\n"
        yield "data:end\n\n"
    resp=Response(read_process(), mimetype= 'text/event-stream')
    return resp 
Example #6
Source File: internals.py    From SplunkForPCAP with MIT License 6 votes vote down vote up
def read(self, ifile):
        """ Reads an input header from an input file.

        The input header is read as a sequence of *<name>***:***<value>* pairs separated by a newline. The end of the
        input header is signalled by an empty line or an end-of-file.

        :param ifile: File-like object that supports iteration over lines.

        """
        name, value = None, None

        for line in ifile:
            if line == '\n':
                break
            item = line.split(':', 1)
            if len(item) == 2:
                # start of a new item
                if name is not None:
                    self[name] = value[:-1]  # value sans trailing newline
                name, value = item[0], unquote(item[1])
            elif name is not None:
                # continuation of the current item
                value += unquote(line)

        if name is not None: self[name] = value[:-1] if value[-1] == '\n' else value 
Example #7
Source File: client.py    From SplunkForPCAP with MIT License 6 votes vote down vote up
def _entity_path(self, state):
        """Calculate the path to an entity to be returned.

        *state* should be the dictionary returned by
        :func:`_parse_atom_entry`. :func:`_entity_path` extracts the
        link to this entity from *state*, and strips all the namespace
        prefixes from it to leave only the relative path of the entity
        itself, sans namespace.

        :rtype: ``string``
        :return: an absolute path
        """
        # This has been factored out so that it can be easily
        # overloaded by Configurations, which has to switch its
        # entities' endpoints from its own properties/ to configs/.
        raw_path = urllib.unquote(state.links.alternate)
        if 'servicesNS/' in raw_path:
            return _trailing(raw_path, 'servicesNS/', '/', '/')
        elif 'services/' in raw_path:
            return _trailing(raw_path, 'services/')
        else:
            return raw_path 
Example #8
Source File: AutoSubmitOrderRequest.py    From 12306 with MIT License 6 votes vote down vote up
def __init__(self, selectObj,
                 secretStr,
                 train_date,
                 query_from_station_name,
                 query_to_station_name,
                 passengerTicketStr,
                 oldPassengerStr,
                 train_no,
                 stationTrainCode,
                 leftTicket,
                 set_type,):
        self.set_type = set_type
        try:
            self.secretStr = urllib.unquote(secretStr)
        except AttributeError:
            self.secretStr = urllib.parse.unquote(secretStr)
        self.train_date = train_date
        self.query_from_station_name = query_from_station_name
        self.query_to_station_name = query_to_station_name
        self.passengerTicketStr = passengerTicketStr.rstrip("_{0}".format(self.set_type))
        self.oldPassengerStr = oldPassengerStr
        self.session = selectObj
        self.train_no = train_no
        self.stationTrainCode = stationTrainCode
        self.leftTicket = leftTicket 
Example #9
Source File: default.py    From tdw with GNU General Public License v3.0 6 votes vote down vote up
def play_url(params):
	torr_link=params['file']
	img=urllib.unquote_plus(params["img"])
	#showMessage('heading', torr_link, 10000)
	TSplayer=tsengine()
	out=TSplayer.load_torrent(torr_link,'TORRENT',port=aceport)
	if out=='Ok':
		for k,v in TSplayer.files.iteritems():
			li = xbmcgui.ListItem(urllib.unquote(k))
			uri = construct_request({
				'torr_url': torr_link,
				'title': k,
				'ind':v,
				'img':img,
				'mode': 'play_url2'
			})
			xbmcplugin.addDirectoryItem(handle, uri, li, False)
	xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
	xbmcplugin.endOfDirectory(handle)
	TSplayer.end() 
Example #10
Source File: chutes.py    From Paradrop with Apache License 2.0 6 votes vote down vote up
def startChute(host, port, name):
    '''
    Start chute with given name from host with pdfcd running on specified port.
    '''

    print 'Starting chute...\n'

    params = {'name': name}
    r = requests.post('http://' + host + ':' + str(port) + '/v1/chute/start', data=json.dumps(params), stream=True)

    for line in r.iter_lines():
        if line:
            try:
                line = json.loads(line)
                if line.get('success'):
                    print line.get('message')
                else:
                    print 'ERROR: Failed to start chute.(' + urllib.unquote(str(line.get('message'))) + ')'
            except Exception as e:
                print line 
Example #11
Source File: chutes.py    From Paradrop with Apache License 2.0 6 votes vote down vote up
def stopChute(host, port, name):
    '''
    Stop chute with given name from host with pdfcd running on specified port.
    '''

    print 'Stopping chute...\n'

    params = {'name': name}
    r = requests.post('http://' + host + ':' + str(port) + '/v1/chute/stop', data=json.dumps(params), stream=True)

    for line in r.iter_lines():
        if line:
            try:
                line = json.loads(line)
                if line.get('success'):
                    print line.get('message')
                else:
                    print 'ERROR: Failed to stop chute.(' + urllib.unquote(str(line.get('message'))) + ')'
            except Exception as e:
                print line 
Example #12
Source File: chutes.py    From Paradrop with Apache License 2.0 6 votes vote down vote up
def deleteChute(host, port, name):
    '''
    Remove chute with given name from host with pdfcd running on specified port.
    '''

    print 'Removing chute...\n'

    params = {'name': name}
    r = requests.post('http://' + host + ':' + str(port) + '/v1/chute/delete', data=json.dumps(params), stream=True)

    for line in r.iter_lines():
        if line:
            try:
                line = json.loads(line)
                if line.get('success'):
                    print line.get('message')
                else:
                    print 'ERROR: Failed to delete chute.(' + urllib.unquote(str(line.get('message'))) + ')'
            except Exception as e:
                print line 
Example #13
Source File: chutes.py    From Paradrop with Apache License 2.0 6 votes vote down vote up
def updateChute(host, port, config):
    '''
    Take a local config yaml file and launch chute of given host with pdfcd running on specified port.
    '''
    config_json = readChuteConfig(config)
    if config_json is None:
        return

    print 'Updating chute...\n'
    params = {'config': config_json}
    r = requests.post('http://' + host + ':' + str(port) + '/v1/chute/update', data=json.dumps(params), stream=True)
    for line in r.iter_lines():
        if line:
            try:
                line = json.loads(line)
                if line.get('success'):
                    print line.get('message')
                else:
                    print 'ERROR: Failed to install chute.(' + urllib.unquote(str(line.get('message'))) + ')'
            except Exception as e:
                print line 
Example #14
Source File: chutes.py    From Paradrop with Apache License 2.0 6 votes vote down vote up
def installChute(host, port, config):
    '''
    Take a local config yaml file and launch chute of given host with pdfcd running on specified port.
    '''
    config_json = readChuteConfig(config)
    if config_json is None:
        return

    print 'Installing chute...\n'
    params = {'config': config_json}
    r = requests.post('http://' + host + ':' + str(port) + '/v1/chute/create', data=json.dumps(params), stream=True)
    for line in r.iter_lines():
        if line:
            try:
                line = json.loads(line)
                if line.get('success'):
                    print line.get('message')
                else:
                    print 'ERROR: Failed to install chute.(' + urllib.unquote(str(line.get('message'))) + ')'
            except Exception as e:
                print line 
Example #15
Source File: compatibility_utils.py    From Lector with GNU General Public License v3.0 5 votes vote down vote up
def unquoteurl(href):
    if isinstance(href,binary_type):
        href = href.decode('utf-8')
    href = unquote(href)
    return href

# unescape html 
Example #16
Source File: themes.py    From StormOnline with Apache License 2.0 5 votes vote down vote up
def _get_theme(self):
        if self.user:
            try:
                return UserSettings.objects.get(user=self.user, key="site-theme").value
            except Exception:
                pass
        if '_theme' in self.request.COOKIES:
            if six.PY2:
                func = urllib.unquote
            else:
                func = urllib.parse.unquote
            return func(self.request.COOKIES['_theme'])
        return self.default_theme 
Example #17
Source File: pan.py    From baidu-wangpan-parse with MIT License 5 votes vote down vote up
def get_resp_json(self, need_verify=False):
        url = 'http://pan.baidu.com/api/sharedownload'
        payload = {
            'sign': self.sign,
            'timestamp': self.timestamp,
            'bdstoken': 'null',
            'channel': 'chunlei',
            'clienttype': '0',
            'web': '1',
            'app_id': '250528',
        }
        data = {
            'encrypt': '0',
            'product': 'share',
            'type': 'nolimit',
            'uk': self.uk,
            'primaryid': self.primary_id,
            'fid_list': self.fid_list,
        }

        if self.is_folder:
            data['type'] = 'batch'

        if self.is_encrypt:
            data['extra'] = '{"sekey":"' + parse.unquote(self.sess.cookies['BDCLND']) + '"}'

        if need_verify:
            data['vcode_input'] = self.verify_code_input
            data['vcode_str'] = self.verify_code_str

        resp = self.sess.post(
            url=url,
            params=payload,
            data=data,
            headers=self.headers
        )
        return json.loads(resp.text) 
Example #18
Source File: client.py    From bugatsinho.github.io with GNU General Public License v3.0 5 votes vote down vote up
def url2name(url):

    from os.path import basename

    url = url.split('|')[0]
    return basename(unquote(urlparse.urlsplit(url)[2])) 
Example #19
Source File: replica.py    From rucio with Apache License 2.0 5 votes vote down vote up
def GET(self):
        """
        Return a summary of the bad replicas by incident.

        HTTP Success:
            200 OK

        HTTP Error:
            406 Not Acceptable
            500 InternalError

        """
        header('Content-Type', 'application/x-json-stream')
        result = []
        rse_expression, from_date, to_date = None, None, None
        if ctx.query:
            try:
                params = loads(unquote(ctx.query[1:]))
            except ValueError:
                params = parse_qs(ctx.query[1:])
            if 'rse_expression' in params:
                rse_expression = params['rse_expression'][0]
            if 'from_date' in params and params['from_date'][0]:
                from_date = datetime.strptime(params['from_date'][0], "%Y-%m-%d")
            if 'to_date' in params:
                to_date = datetime.strptime(params['to_date'][0], "%Y-%m-%d")

        try:
            result = get_bad_replicas_summary(rse_expression=rse_expression, from_date=from_date, to_date=to_date)
        except RucioException as error:
            raise generate_http_error(500, error.__class__.__name__, error.args[0])
        except Exception as error:
            print(format_exc())
            raise InternalError(error)
        for row in result:
            yield dumps(row, cls=APIEncoder) + '\n' 
Example #20
Source File: replica.py    From rucio with Apache License 2.0 5 votes vote down vote up
def GET(self):
        """
        List the suspicious replicas on a lsit of RSEs.

        HTTP Success:
            200 OK

        HTTP Error:
            406 Not Acceptable
            500 InternalError

        """
        header('Content-Type', 'application/json')
        result = []
        rse_expression, younger_than, nattempts = None, None, None
        if ctx.query:
            try:
                params = loads(unquote(ctx.query[1:]))
            except ValueError:
                params = parse_qs(ctx.query[1:])
            print(params)
            if 'rse_expression' in params:
                rse_expression = params['rse_expression'][0]
            if 'younger_than' in params and params['younger_than'][0]:
                younger_than = datetime.strptime(params['younger_than'][0], "%Y-%m-%dT%H:%M:%S")
            if 'nattempts' in params:
                nattempts = int(params['nattempts'][0])

        try:
            result = get_suspicious_files(rse_expression=rse_expression, younger_than=younger_than, nattempts=nattempts)
        except RucioException as error:
            raise generate_http_error(500, error.__class__.__name__, error.args[0])
        except Exception as error:
            print(format_exc())
            raise InternalError(error)
        return render_json_list(result) 
Example #21
Source File: fixers.py    From jbox with MIT License 5 votes vote down vote up
def __call__(self, environ, start_response):
        for key in 'REQUEST_URL', 'REQUEST_URI', 'UNENCODED_URL':
            if key not in environ:
                continue
            request_uri = unquote(environ[key])
            script_name = unquote(environ.get('SCRIPT_NAME', ''))
            if request_uri.startswith(script_name):
                environ['PATH_INFO'] = request_uri[len(script_name):] \
                    .split('?', 1)[0]
                break
        return self.app(environ, start_response) 
Example #22
Source File: client.py    From SplunkForPCAP with MIT License 5 votes vote down vote up
def create(self, name, **params):
        """Creates a new role.

        This function makes two roundtrips to the server, plus at most
        two more if
        the ``autologin`` field of :func:`connect` is set to ``True``.

        :param name: Name for the role.
        :type name: ``string``
        :param params: Additional arguments (optional). For a list of available
            parameters, see `Roles parameters
            <http://dev.splunk.com/view/SP-CAAAEJ6#rolesparams>`_
            on Splunk Developer Portal.
        :type params: ``dict``

        :return: The new role.
        :rtype: :class:`Role`

        **Example**::

            import splunklib.client as client
            c = client.connect(...)
            roles = c.roles
            paltry = roles.create("paltry", imported_roles="user", defaultApp="search")
        """
        if not isinstance(name, basestring):
            raise ValueError("Invalid role name: %s" % str(name))
        name = name.lower()
        self.post(name=name, **params)
        # splunkd doesn't return the user in the POST response body,
        # so we have to make a second round trip to fetch it.
        response = self.get(name)
        entry = _load_atom(response, XNAME_ENTRY).entry
        state = _parse_atom_entry(entry)
        entity = self.item(
            self.service,
            urllib.unquote(state.links.alternate),
            state=state)
        return entity 
Example #23
Source File: comedy.py    From plugin.video.ustvvod with GNU General Public License v2.0 5 votes vote down vote up
def add_fullepisodes_southpark(episode_tree):
	try:
		season = urllib.unquote(sys.argv[2].split('&')[2].split('=')[1].replace('%22','')).split(' ')[1]
		episode_menu = episode_tree.find_all('article', class_ = 'thumb')
		for episode_item in episode_menu:
			episode_name = episode_item.find(class_ = 'title')
			if episode_name is None:
				continue
			url = episode_item.a['href']
			try:
				season_number, episode_number = re.compile('s([0-9]{2})e([0-9]{2})').findall(url)[0]
			except:
				episode_number = -1
				season_number = -1
			
			if int(season) != int(season_number):
				continue
			episode_name = episode_name.string.strip()
			episode_plot = episode_item.find('p', class_ = 'episode').string.strip()
			episode_airdate = episode_item.find(class_ = 'air-date').string.strip()
			episode_airdate = common.format_date(episode_airdate , '%m.%d.%Y', '%d.%m.%Y')
			episode_thumb = re.match('(.*?)url\(\'(.*?)\'\)', episode_item.find('a', class_ = 'fill')['style']).group(2)
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels={	'title' : episode_name,
							'season' : season_number,
							'episode' : episode_number,
							'plot' : episode_plot,
							'premiered' : episode_airdate }
			common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
	except:
		pass 
Example #24
Source File: freeproxylists.py    From IPProxyTool with MIT License 5 votes vote down vote up
def parse_page(self, response):
        pattern = re.compile('<tr class=(.*?)</tr>', re.S)
        items = re.findall(pattern = pattern, string = response.body)
        for i, item in enumerate(items):
            if i > 0:
                if 'async' in item:
                    continue

                ip_pattern = re.compile('IPDecode\(\"(.*?)\"\)', re.S)
                ip_decode = re.findall(ip_pattern, item)[0]
                ip_url = urllib.unquote(ip_decode)
                ip_soup = BeautifulSoup(ip_url, 'lxml')
                ip = ip_soup.text.encode()

                item = '<tr class=' + item + '</tr>'
                soup = BeautifulSoup(item, 'lxml')
                tbodys = soup.find_all('td')

                proxy = Proxy()
                proxy.set_value(
                        ip = ip,
                        port = tbodys[1].text.encode(),
                        country = tbodys[4].text.encode(),
                        anonymity = tbodys[3].text.encode(),
                        source = self.name,
                )

                self.add_proxy(proxy = proxy) 
Example #25
Source File: net-creds.py    From net-creds with GNU General Public License v3.0 5 votes vote down vote up
def get_http_searches(http_url_req, body, host):
    '''
    Find search terms from URLs. Prone to false positives but rather err on that side than false negatives
    search, query, ?s, &q, ?q, search?p, searchTerm, keywords, command
    '''
    false_pos = ['i.stack.imgur.com']

    searched = None
    if http_url_req != None:
        searched = re.search(http_search_re, http_url_req, re.IGNORECASE)
        if searched == None:
            searched = re.search(http_search_re, body, re.IGNORECASE)

    if searched != None and host not in false_pos:
        searched = searched.group(3)
        # Eliminate some false+
        try:
            # if it doesn't decode to utf8 it's probably not user input
            searched = searched.decode('utf8')
        except UnicodeDecodeError:
            return
        # some add sites trigger this function with single digits
        if searched in [str(num) for num in range(0,10)]:
            return
        # nobody's making >100 character searches
        if len(searched) > 100:
            return
        msg = 'Searched %s: %s' % (host, unquote(searched.encode('utf8')).replace('+', ' '))
        return msg 
Example #26
Source File: fixers.py    From recruit with Apache License 2.0 5 votes vote down vote up
def __call__(self, environ, start_response):
        for key in "REQUEST_URL", "REQUEST_URI", "UNENCODED_URL":
            if key not in environ:
                continue
            request_uri = unquote(environ[key])
            script_name = unquote(environ.get("SCRIPT_NAME", ""))
            if request_uri.startswith(script_name):
                environ["PATH_INFO"] = request_uri[len(script_name) :].split("?", 1)[0]
                break
        return self.app(environ, start_response) 
Example #27
Source File: __init__.py    From qgis-cartodb with GNU General Public License v2.0 5 votes vote down vote up
def _split_url_string(param_str):
        """Turn URL string into parameters."""
        parameters = parse_qs(param_str.encode('utf-8'), keep_blank_values=True)
        for k, v in parameters.iteritems():
            parameters[k] = urllib.unquote(v[0])
        return parameters 
Example #28
Source File: __init__.py    From qgis-cartodb with GNU General Public License v2.0 5 votes vote down vote up
def _split_header(header):
        """Turn Authorization: header into parameters."""
        params = {}
        parts = header.split(',')
        for param in parts:
            # Ignore realm parameter.
            if param.find('realm') > -1:
                continue
            # Remove whitespace.
            param = param.strip()
            # Split key-value.
            param_parts = param.split('=', 1)
            # Remove quotes and unescape the value.
            params[param_parts[0]] = urllib.unquote(param_parts[1].strip('\"'))
        return params 
Example #29
Source File: tooler_views.py    From vulscan with MIT License 5 votes vote down vote up
def index(request):
    if request.method == 'GET':
        old = u"hello world!"
        new = u"hello%20world%21"
        return render(request,'tooler.html',{'old':old,'new':new,})
    elif request.method == 'POST':
        try:
            #判断处理方式
            #return HttpResponse(requests)
            #获取表单值并设置编码
            old  = request.POST['old'] .encode('utf-8')
            action = request.POST['action'] 

            if action == 'urlencode':
                new = urllib.quote(old)
            elif action == 'urldecode':
                new = urllib.unquote(old)   
            elif action == 'asciicode':
                ascii_code = ''
                for i in range(len(old)):
                    ascii_code = ascii_code + u'chr(' + str(ord(old[i])).strip() + u')' 
                #中文部分会存在问题
                new = ascii_code
            elif action == 'enbase64':
                new = base64.encodestring(old)
            elif action == 'debase64':
                new = base64.decodestring(old)
            elif action == 'enmd5':
                passwd = hashlib.md5()
                passwd.update(old)
                new = passwd.hexdigest()
            else:
                return HttpResponse('error!')
            return render(request,'tooler.html',{'old':old,'new':new,})
            #以上可能会出现异常操作,未做异常处理/
        except:
            return HttpResponse('error!') 
Example #30
Source File: streamserver.py    From pulseaudio-dlna with GNU General Public License v3.0 5 votes vote down vote up
def _decode_settings(self, path):
        try:
            data_quoted = re.findall(r'/(.*?)/', path)[0]
            data_string = base64.b64decode(urllib.unquote(data_quoted))
            settings = {
                k: v for k, v in re.findall('(.*?)="(.*?)",?', data_string)
            }
            logger.info(
                'URL settings: {path} ({data_string})'.format(
                    path=path,
                    data_string=data_string))
            return settings
        except (TypeError, ValueError, IndexError):
            pass
        return {}