Function to get CartoCSS from Python dicts
358886
def cssify(css_dict):
    """"""
    css = ''
    for key, value in dict_items(css_dict):
        css += '{key} {{ '.format(key=key)
        for field, field_value in dict_items(value):
            css += ' {field}: {field_value};'.format(field=field,
                                                     field_value=field_value)
        css += '} '
    return css.strip()
868932
def validate_dict(d):
    """"""
    try:
        return dict(d)
    except TypeError:
        d = validate_path_exists(d)
        try:
            with open(d) as f:
                return dict(yaml.load(f))
        except Exception:
            raise ValueError("Could not convert {} to dictionary!".format(d))
68672
def get_python_dict(scala_map):
    """"""
    python_dict = {}
    keys = get_python_list(scala_map.keys().toList())
    for key in keys:
        python_dict[key] = scala_map.apply(key)
    return python_dict
1180296
def get_object(self):
        """"""

        from ..util import AttrDict

        c = self.record.unpacked_contents

        if not c:
            c = yaml.safe_load(self.default)

        return AttrDict(c)
361364
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'documents' in _dict:
            args['documents'] = EnvironmentDocuments._from_dict(
                _dict.get('documents'))
        if 'disk_usage' in _dict:
            args['disk_usage'] = DiskUsage._from_dict(_dict.get('disk_usage'))
        if 'collections' in _dict:
            args['collections'] = CollectionUsage._from_dict(
                _dict.get('collections'))
        return cls(**args)
608324
def from_dict(d):
        
        obstory_ids = _value_from_dict(d, 'obstory_ids')
        lat_min = _value_from_dict(d, 'lat_min')
        lat_max = _value_from_dict(d, 'lat_max')
        long_min = _value_from_dict(d, 'long_min')
        long_max = _value_from_dict(d, 'long_max')
        time_min = _value_from_dict(d, 'time_min')
        time_max = _value_from_dict(d, 'time_max')
        mime_type = _string_from_dict(d, 'mime_type')
        skip = _value_from_dict(d, 'skip', 0)
        limit = _value_from_dict(d, 'limit', 100)
        semantic_type = _string_from_dict(d, 'semantic_type')
        observation_type = _string_from_dict(d, 'observation_type')
        observation_id = _value_from_dict(d, 'observation_id')
        repository_fname = _string_from_dict(d, 'repository_fname')
        exclude_imported = _boolean_from_dict(d, 'exclude_imported')
        exclude_export_to = _string_from_dict(d, 'exclude_export_to')
        if 'meta' in d:
            meta_constraints = list((MetaConstraint.from_dict(x) for x in d['meta']))
        else:
            meta_constraints = []
        return FileRecordSearch(obstory_ids=obstory_ids, lat_min=lat_min, lat_max=lat_max, long_min=long_min,
                                long_max=long_max, time_min=time_min, time_max=time_max, mime_type=mime_type,
                                semantic_type=semantic_type,
                                observation_type=observation_type,
                                observation_id=observation_id, repository_fname=repository_fname,
                                meta_constraints=meta_constraints, limit=limit, skip=skip,
                                exclude_imported=exclude_imported,
                                exclude_export_to=exclude_export_to)
1264367
def from_map(map_key):
    ''
    image_id = subprocess.check_output(['plash', 'map',
                                        map_key]).decode().strip('\n')
    if not image_id:
        raise MapDoesNotExist('map {} not found'.format(repr(map_key)))
    return hint('image', image_id)
1203762
function getAtlas(key) {
         if (typeof key === "string") {
           return this.atlases.get(key);
         } else {
           return this.atlases.values().next().value;
         }
       }
1330658
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'model_id' in _dict:
            args['model_id'] = _dict.get('model_id')
        if 'model_version' in _dict:
            args['model_version'] = _dict.get('model_version')
        if 'documents' in _dict:
            args['documents'] = [
                Document._from_dict(x) for x in (_dict.get('documents'))
            ]
        if 'aligned_elements' in _dict:
            args['aligned_elements'] = [
                AlignedElement._from_dict(x)
                for x in (_dict.get('aligned_elements'))
            ]
        if 'unaligned_elements' in _dict:
            args['unaligned_elements'] = [
                UnalignedElement._from_dict(x)
                for x in (_dict.get('unaligned_elements'))
            ]
        return cls(**args)
438685
def _todict(cls):
        
        return dict((getattr(cls, attr), attr) for attr in dir(cls) if not attr.startswith('_'))
372103
function cartodbUrl(opts) {
    var host = opts.host || 'carto.com';
    var protocol = opts.protocol || 'https';
    return protocol + '://' + opts.user + '.' + host + '/api/v1/viz/' + opts.table + '/viz.json';
  }
317531
def _opts_to_dict(*opts):
	''''''
	ret = {}
	for key, val in opts:
		if key[:2] == '--':
			key = key[2:]
		elif key[:1] == '-':
			key = key[1:]
		if val == '':
			val = True
		ret[key.replace('-','_')] = val
	return ret
1063424
def _ParseDocstring(function):
  """"""
  if not function.__doc__:
    return {}

  type_check_dict = {}
  for match in param_regexp.finditer(function.__doc__):
    param_str = match.group(1).strip()
    param_splitted = param_str.split(" ")
    if len(param_splitted) >= 2:
      type_str = " ".join(param_splitted[:-1])
      name = param_splitted[-1]
      type_check_dict[name] = type_str

  for match in returns_regexp.finditer(function.__doc__):
    type_check_dict["returns"] = match.group(1)

  for match in type_regexp.finditer(function.__doc__):
    name = match.group(1)
    type_str = match.group(2)
    type_check_dict[name] = type_str
  for match in rtype_regexp.finditer(function.__doc__):
    type_check_dict["returns"] = match.group(1)
  return type_check_dict
1018467
def _extract_multimap_field(blob, name):
    ''''''
    message = ('"{}" field must be a map whose values are either a string or '
               'list of strings.'.format(name))
    raw_map = typesafe_pop(blob, name, {}) or {}
    if not isinstance(raw_map, dict):
        raise ParserError(message)
    # We use an `OrderedDict` to ensure that multimap fields are processed in a
    # determinist order. This prevents obscure bugs caused by subtly different
    # behavior.
    multimap = collections.OrderedDict()
    # Sort by key so that processing occurs in convenient lexographical order.
    # This keeps things deterministic in a simple way.
    for key, raw_value in sorted(raw_map.items()):
        value = _optional_list(raw_value)
        if value is None:
            raise ParserError(message)
        multimap[key] = value  # Remembers order.
    return multimap
198491
def geosgeometry_str_to_struct(value):
    '''
    
    '''

    result = geos_ptrn.match(value)

    if not result:
        return None

    return {
        'srid': result.group(1),
        'x': result.group(2),
        'y': result.group(3),
    }
752921
def get(map_name):
  """"""
  if isinstance(map_name, Map):
    return map_name

  # Get the list of maps. This isn't at module scope to avoid problems of maps
  # being defined after this module is imported.
  maps = get_maps()
  map_class = maps.get(map_name)
  if map_class:
    return map_class()
  raise NoMapException("Map doesn't exist: %s" % map_name)
597340
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'collection_id' in _dict:
            args['collection_id'] = _dict.get('collection_id')
        if 'name' in _dict:
            args['name'] = _dict.get('name')
        if 'description' in _dict:
            args['description'] = _dict.get('description')
        if 'created' in _dict:
            args['created'] = string_to_datetime(_dict.get('created'))
        if 'updated' in _dict:
            args['updated'] = string_to_datetime(_dict.get('updated'))
        if 'status' in _dict:
            args['status'] = _dict.get('status')
        if 'configuration_id' in _dict:
            args['configuration_id'] = _dict.get('configuration_id')
        if 'language' in _dict:
            args['language'] = _dict.get('language')
        if 'document_counts' in _dict:
            args['document_counts'] = DocumentCounts._from_dict(
                _dict.get('document_counts'))
        if 'disk_usage' in _dict:
            args['disk_usage'] = CollectionDiskUsage._from_dict(
                _dict.get('disk_usage'))
        if 'training_status' in _dict:
            args['training_status'] = TrainingStatus._from_dict(
                _dict.get('training_status'))
        if 'source_crawl' in _dict:
            args['source_crawl'] = SourceStatus._from_dict(
                _dict.get('source_crawl'))
        return cls(**args)