2016-03-02: import from json list
504347
def _import_LOV(
        baseuri="http://lov.okfn.org/dataset/lov/api/v2/vocabulary/list",
        keyword=""):
    

    printDebug("----------\nReading source... <%s>" % baseuri)
    query = requests.get(baseuri, params={})
    all_options = query.json()
    options = []

    # pre-filter if necessary
    if keyword:
        for x in all_options:
            if keyword in x['uri'].lower() or keyword in x['titles'][0][
                    'value'].lower() or keyword in x['nsp'].lower():
                options.append(x)
    else:
        options = all_options

    printDebug("----------\n%d results found.\n----------" % len(options))

    if options:
        # display:
        counter = 1
        for x in options:
            uri, title, ns = x['uri'], x['titles'][0]['value'], x['nsp']
            # print("%s ==> %s" % (d['titles'][0]['value'], d['uri']))
            click.echo(
                click.style("[%d]" % counter, fg='blue') +
                click.style(uri + " ==> ", fg='black') +
                click.style(title, fg='red'))

            counter += 1

        while True:
            var = input(Style.BRIGHT +
                        "=====\nSelect ID to import: (q=quit)\n" +
                        Style.RESET_ALL)
            if var == "q":
                break
            else:
                try:
                    _id = int(var)
                    ontouri = options[_id - 1]['uri']
                    print(Fore.RED + "\n---------\n" + ontouri +
                          "\n---------" + Style.RESET_ALL)
                    action_analyze([ontouri])
                    if click.confirm(
                            '=====\nDo you want to save to your local library?'
                    ):
                        action_import(ontouri)
                    return
                except:
                    print("Error retrieving file. Import failed.")
                    continue
569243
def from_json(json):
        
        points = []
        for point in json['points']:
            points.append(Point.from_json(point))
        return Segment(points)
313738
def list_from_json(source_list_json):
    
    result = []
    if source_list_json == [] or source_list_json == None:
        return result
    for list_item in source_list_json:
        item = json.loads(list_item)
        try:
            if item['class_name'] == 'Departure':
                temp = Departure()
            elif item['class_name'] == 'Disruption':
                temp = Disruption()
            elif item['class_name'] == 'Station':
                temp = Station()
            elif item['class_name'] == 'Trip':
                temp = Trip()
            elif item['class_name'] == 'TripRemark':
                temp = TripRemark()
            elif item['class_name'] == 'TripStop':
                temp = TripStop()
            elif item['class_name'] == 'TripSubpart':
                temp = TripSubpart()
            else:
                print('Unrecognised Class ' + item['class_name'] + ', skipping')
                continue
            temp.from_json(list_item)
            result.append(temp)
        except KeyError:
            print('Unrecognised item with no class_name, skipping')
            continue
    return result
44207
def get_sis_import_list(self, account_id, created_since=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - account_id
        """ID"""
        path["account_id"] = account_id

        # OPTIONAL - created_since
        """If set, only shows imports created after the specified date (use ISO8601 format)"""
        if created_since is not None:
            if issubclass(created_since.__class__, basestring):
                created_since = self._validate_iso8601_string(created_since)
            elif issubclass(created_since.__class__, date) or issubclass(created_since.__class__, datetime):
                created_since = created_since.strftime('%Y-%m-%dT%H:%M:%S+00:00')
            params["created_since"] = created_since

        self.logger.debug("GET /api/v1/accounts/{account_id}/sis_imports with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("GET", "/api/v1/accounts/{account_id}/sis_imports".format(**path), data=data, params=params, data_key='sis_imports', all_pages=True)
556460
def import_json(cls, filename):
        
        with open(filename, 'rb') as f:
            json_graph = f.read().decode('utf-8')
        return cls.from_json(json_graph)
817131
def column_headers_from_list_of_dicts(self, json_input):
        
        if not json_input \
        or not hasattr(json_input, '__getitem__') \
        or not hasattr(json_input[0], 'keys'):
            return None
        column_headers = json_input[0].keys()
        for entry in json_input:
            if not hasattr(entry, 'keys') \
            or not hasattr(entry, '__iter__') \
            or len(entry.keys()) != len(column_headers):
                return None
            for header in column_headers:
                if header not in entry:
                    return None
        return column_headers
435943
def from_json(cls, json):
    """"""
    obj = cls(key_range.KeyRange.from_json(json["key_range"]),
              model.QuerySpec.from_json(json["query_spec"]))
    cursor = json["cursor"]
    # lint bug. Class method can access protected fields.
    # pylint: disable=protected-access
    if cursor and json["cursor_object"]:
      obj._cursor = datastore_query.Cursor.from_websafe_string(cursor)
    else:
      obj._cursor = cursor
    return obj
631105
def require_json():
    
    # Fails when "json" is missing and "simplejson" is not installed either
    try:
        import json # pylint: disable=F0401
        return json
    except ImportError:
        try:
            import simplejson # pylint: disable=F0401
            return simplejson
        except ImportError as exc:
            raise ImportError("""Please 'pip install "simplejson>=2.1.6"' (%s)""" % (exc,))
1163968
def from_json(s):
    
    d = json.loads(s)
    sbp = SBP.from_json_dict(d)
    return sbp
261042
def _from_json_list(cls, response_raw, wrapper=None):
        

        json = response_raw.body_bytes.decode()
        obj = converter.json_to_class(dict, json)
        array = obj[cls._FIELD_RESPONSE]
        array_deserialized = []

        for item in array:
            item_unwrapped = item if wrapper is None else item[wrapper]
            item_deserialized = converter.deserialize(cls, item_unwrapped)
            array_deserialized.append(item_deserialized)

        pagination = converter.deserialize(client.Pagination,
                                           obj[cls._FIELD_PAGINATION])

        return client.BunqResponse(array_deserialized, response_raw.headers,
                                   pagination)
425347
def list_to_json(source_list):
    
    result = []
    for item in source_list:
        result.append(item.to_json())
    return result
750362
def from_json(cls, key):
        
        obj = cls()
        try:
            jkey = json_decode(key)
        except Exception as e:  # pylint: disable=broad-except
            raise InvalidJWKValue(e)
        obj.import_key(**jkey)
        return obj
152005
function listToArray ( list, opts ) {
	const length = list.getLength();
	const data = [];
	for ( let i = 0; i < length; i++ ) {
		const value = getJsonValueFromSassValue(list.getValue(i), opts);
		data.push(value);
	}
	return data;
}
151748
def _fromJSON(cls, jsonobject):
        
        newInstance = cls(jsonobject[0], jsonobject[1])
        for arrayType, jsonEntry in viewitems(jsonobject[2]):
            arrayEntry = {'dataProcessingRef': jsonEntry['dataProcessingRef'],
                          'params': [tuple(_) for _ in jsonEntry['params']]
                          }
            newInstance.arrayInfo[arrayType] = arrayEntry

        return newInstance
1222920
def bulkImport_json(self, filename, onDuplicate="error", formatType="auto", **params) :
        """"""

        url = "%s/import" % self.database.URL
        params["onDuplicate"] = onDuplicate
        params["collection"] = self.name
        params["type"] = formatType
        with open(filename) as f:
            data = f.read()
            r = self.connection.session.post(URL, params = params, data = data)

            try :
                errorMessage = "At least: %d errors. The first one is: '%s'\n\n more in <this_exception>.data" % (len(data), data[0]["errorMessage"])
            except KeyError:
                raise UpdateError(data['errorMessage'], data)
1105257
def parse_imports(self, src):
        "  "
        result = []

        def child(obj):
            result.append(obj.group(1))
        src = self.import_re.sub(child, src)
        return src, result
773264
def from_json(cls, json_str):
        """"""
        d = json.loads(json_str)
        return cls.from_dict(d)