Given profile data and the name of a
    social media service, format it for
    the zone file.

    @serviceName: name of the service
    @data: legacy profile verification

    Returns the formatted account on success,
    as a dict.
433863
def format_account(service_name, data):
    

    if "username" not in data:
        raise KeyError("Account is missing a username")

    account = {
        "@type": "Account",
        "service": service_name,
        "identifier": data["username"],
        "proofType": "http"
    }

    if (data.has_key(service_name)
        and data[service_name].has_key("proof")
        and data[service_name]["proof"].has_key("url")):
        account["proofUrl"] = data[service_name]["proof"]["url"]

    return account
288930
def _set_format(profile):
    
    x = set()
    for sample in profile:
        x = x.union(set(profile[sample].keys()))
    if not x:
        return ''
    end, start = max(x), min(x)
    x = range(start, end, 4)
    scaled_profile = defaultdict(list)
    for pos in x:
        for sample in profile:
            y = _get_closer(profile[sample], pos)
            if y:
                scaled_profile[sample].append(profile[sample][y])
            else:
                scaled_profile[sample].append(0)
    return {'x': list(x), 'y': scaled_profile, 'names': scaled_profile.keys()}
1050544
def get_profile_data(self, auth_response):
        
        res = auth_response
        token = res.get('access_token')
        me = res.get('user')

        if not me.get('id'):
            raise x.UserException('Instagram must return a user id')

        data = dict(
            provider=self.provider,
            email=None,
            id=me.get('id'),
            token=token,
        )
        return data
249435
def logout_service_description(self):
        """"""
        label = 'Logout from ' + self.name
        if (self.auth_type):
            label = label + ' (' + self.auth_type + ')'
        return({"@id": self.logout_uri,
                "profile": self.profile_base + 'logout',
                "label": label})
3912
def activate(self, profile_name=NotSet):
        
        if profile_name is NotSet:
            profile_name = self.profile_name
        self._active_profile_name = profile_name
141449
def login_service_description(self):
        
        label = 'Login to ' + self.name
        if (self.auth_type):
            label = label + ' (' + self.auth_type + ')'
        desc = {"@id": self.login_uri,
                "profile": self.profile_base + self.auth_pattern,
                "label": label}
        if (self.header):
            desc['header'] = self.header
        if (self.description):
            desc['description'] = self.description
        return desc
800087
function formatProfileData(profileData) {
  var profile;
  if (profileData) {
    profile = extractAttributeFields(profileData.attributes);
    profile.username = profileData.username;
    profile.email = profileData.email;
  }
  return profile;
}
89911
def _vcap_from_service_definition(service_def):
    
    if 'credentials' in service_def:
        credentials = service_def['credentials']
    else:
        credentials = service_def

    service = {}
    service['credentials'] = credentials
    service['name'] = _name_from_service_definition(service_def)
    vcap = {'streaming-analytics': [service]}
    return vcap
1293093
def as_json(self, validate=True):
        
        if (validate):
            self.validate()
        json_dict = {}
        if (self.api_version > '1.0'):
            json_dict['@context'] = self.context
        params_to_write = set(self.params)
        params_to_write.discard('identifier')
        if (self.identifier):
            if (self.api_version == '1.0'):
                json_dict['identifier'] = self.identifier  # local id
            else:
                json_dict['@id'] = self.id  # URI
        params_to_write.discard('profile')
        if (self.compliance):
            if (self.api_version < '2.0'):
                json_dict['profile'] = self.compliance
            else:
                # FIXME - need to support extra profile features
                json_dict['profile'] = [self.compliance]
                d = {}
                if (self.formats is not None):
                    d['formats'] = self.formats
                if (self.qualities is not None):
                    d['qualities'] = self.qualities
                if (self.supports is not None):
                    d['supports'] = self.supports
                if (len(d) > 0):
                    json_dict['profile'].append(d)
                params_to_write.discard('formats')
                params_to_write.discard('qualities')
                params_to_write.discard('supports')
        for param in params_to_write:
            if (hasattr(self, param) and
                    getattr(self, param) is not None):
                json_dict[param] = getattr(self, param)
        return(json.dumps(json_dict, sort_keys=True, indent=2))
1176372
def profile(profile_name):
    '''
    
    '''

    # run tuned-adm with the profile specified
    result = __salt__['cmd.retcode']('tuned-adm profile {0}'.format(profile_name))
    if int(result) != 0:
        return False
    return '{0}'.format(profile_name)
38996
def create_primary_zone(self, account_name, zone_name):
        
        zone_properties = {"name": zone_name, "accountName": account_name, "type": "PRIMARY"}
        primary_zone_info = {"forceImport": True, "createType": "NEW"}
        zone_data = {"properties": zone_properties, "primaryCreateInfo": primary_zone_info}
        return self.rest_api_connection.post("/v1/zones", json.dumps(zone_data))
781132
def load_profile(self, profile_name):
        """"""
        data = self.storage.get_user_profiles(profile_name)

        for x in data.get_user_views():
            self._graph.add_edge(int(x[0]), int(x[1]), {'weight': float(x[2])})
            self.all_records[int(x[1])] += 1

        return self._graph
440652
def profile_list(self, provider, lookup='all'):
        '''
        
        '''
        data = {}
        lookups = self.lookup_profiles(provider, lookup)

        if not lookups:
            return data

        for alias, driver in lookups:
            if alias not in data:
                data[alias] = {}
            if driver not in data[alias]:
                data[alias][driver] = {}
        return data
854299
def get_record(self, zone_name, record_id):
        
        return self._client.get(
            '/domain/zone/{}/record/{}'.format(zone_name, record_id))
247374
def _get_profile(self):
        
        url = PROFILE_URL + self.hash + '.json'
        try:
            profile = json.load(urlopen(url))
            # set the profile as an instance variable
            self._profile = profile['entry'][0]
        except:
            self._profile = {}
160057
def _get_zone_id(self):
        
        if 'VCAP_SERVICES' in os.environ:
            services = json.loads(os.getenv('VCAP_SERVICES'))
            predix_asset = services['predix-asset'][0]['credentials']
            return predix_asset['zone']['http-header-value']
        else:
            return predix.config.get_env_value(self, 'zone_id')
469094
def update_profile_image(self, filename, file_=None):
        
        headers, post_data = API._pack_image(filename, 700, f=file_)
        return bind_api(
            api=self,
            path='/account/update_profile_image.json',
            method='POST',
            payload_type='user',
            allowed_param=['include_entities', 'skip_status'],
            require_auth=True
        )(self, post_data=post_data, headers=headers)