Dict representation of the database as credentials plus tables dict representation.
6202
def to_dict(self):
        """"""
        db_dict = self.credentials
        db_dict.update(self.tables.to_dict())
        return db_dict
231757
def to_dict(self):
        """"""
        return {'schema': self.schema, 'name': self.name, 'columns': [col.to_dict() for col in self._columns],
                'foreign_keys': self.foreign_keys.to_dict(), 'ref_keys': self.ref_keys.to_dict()}
413610
def mysql_to_dict(data, key):
    '''
    
    '''
    ret = {}
    headers = ['']
    for line in data:
        if not line:
            continue
        if line.startswith('+'):
            continue
        comps = line.split('|')
        for comp in range(len(comps)):
            comps[comp] = comps[comp].strip()
        if len(headers) > 1:
            index = len(headers) - 1
            row = {}
            for field in range(index):
                if field < 1:
                    continue
                else:
                    row[headers[field]] = salt.utils.stringutils.to_num(comps[field])
            ret[row[key]] = row
        else:
            headers = comps
    return ret
1077764
def dict_to_table(dictionary, list_of_keys=None):
    

    # assert len(dictionary.values()) > 0, "Dictionary cannot be empty"

    # Create an empty table

    table = Table()

    # If the dictionary is not empty, fill the table

    if len(dictionary) > 0:

        # Add the names as first column

        table['name'] = dictionary.keys()

        # Now add all other properties

        # Use the first parameter as prototype

        prototype = dictionary.values()[0]

        column_names = prototype.keys()

        # If we have a white list for the columns, use it

        if list_of_keys is not None:

            column_names = filter(lambda key: key in list_of_keys, column_names)

        # Fill the table

        for column_name in column_names:

            table[column_name] = map(lambda x: x[column_name], dictionary.values())

    return table
1213814
def get_schema_dict(self, table):
        
        # Retrieve schema in list form
        schema = self.get_schema(table, with_headers=True)

        # Pop headers from first item in list
        headers = schema.pop(0)

        # Create dictionary by zipping headers with each row
        return {values[0]: dict(zip(headers, values[0:])) for values in schema}
589199
def asDictionary(self):
        
        self._dict = {
            "type" : self._type,
            "workspaceId" : self._workspaceId,
            "dataSourceName": self._dataSourceName,
            "gdbVersion" : self._gdbVersion
        }
        return self._dict
1324272
def to_dict(self):
        """"""
        make = lambda pair: (pair[0], pair[1].to_dict())
        return dict(
            variables=dict(make(v) for v in self.variables.items()),
            properties=dict(make(p) for p in self.properties.items()),
            roles=dict(make(r) for r in self.roles.items()),
            predicates=dict(make(p) for p in self.predicates.items())
        )
508016
def dataset(self):
        '''
        
        '''
        target = self.db.target_table
        db_examples = self.db.rows(target, [self.db.target_att, self.db.pkeys[target]])

        examples = []
        for cls, pk in sorted(db_examples, key=lambda ex: ex[0]):
            facts = self._facts(pk, self.db.pkeys[target], target, visited=set())
            examples.append('%s %s' % (cls, ', '.join(facts)))

        return '\n'.join(examples)
461527
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'recognitions') and self.recognitions is not None:
            _dict['recognitions'] = [x._to_dict() for x in self.recognitions]
        return _dict
677122
def as_dictionary(self, is_proof=True):
        
        if self._created is None:
            self._created = DDO._get_timestamp()

        data = {
            '@context': DID_DDO_CONTEXT_URL,
            'id': self._did,
            'created': self._created,
        }
        if self._public_keys:
            values = []
            for public_key in self._public_keys:
                values.append(public_key.as_dictionary())
            data['publicKey'] = values
        if self._authentications:
            values = []
            for authentication in self._authentications:
                values.append(authentication)
            data['authentication'] = values
        if self._services:
            values = []
            for service in self._services:
                values.append(service.as_dictionary())
            data['service'] = values
        if self._proof and is_proof:
            data['proof'] = self._proof

        return data
868169
def to_dict(self):
        
        data = {
            "auth_info": self.auth_info.to_dict(),
            "requester": self.requester,
            "requester_name": self.requester_name,
            "attributes": self.attributes,
            "subject_id": self.subject_id,
            "subject_type": self.subject_type,
        }
        data.update(
            {
                "user_id": self.subject_id,
                "hash_type": self.subject_type,
                "name_id": self.subject_id,
                "approved_attributes": self.attributes,
            }
        )
        return data
750233
def to_dict(self):
        
        data = {}

        # mandatory characteristics
        data["name"] = self.name
        data["description"] = self.description if self.description and len(self.description) else None
        data["type"] = self.type if self.type and len(self.type) else None
        data["allowed_chars"] = self.allowed_chars if self.allowed_chars and len(self.allowed_chars) else None
        data["allowed_choices"] = self.allowed_choices
        data["autogenerated"] = self.autogenerated
        data["channel"] = self.channel if self.channel and len(self.channel) else None
        data["creation_only"] = self.creation_only
        data["default_order"] = self.default_order
        data["default_value"] = self.default_value if self.default_value and len(self.default_value) else None
        data["deprecated"] = self.deprecated
        data["exposed"] = self.exposed
        data["filterable"] = self.filterable
        data["format"] = self.format if self.format and len(self.format) else None
        data["max_length"] = int(self.max_length) if self.max_length is not None else None
        data["max_value"] = int(self.max_value) if self.max_value is not None else None
        data["min_length"] = int(self.min_length) if self.min_length is not None else None
        data["min_value"] = int(self.min_value) if self.min_value is not None else None
        data["orderable"] = self.orderable
        data["read_only"] = self.read_only
        data["required"] = self.required
        data["transient"] = self.transient
        data["unique"] = self.unique
        data["uniqueScope"] = self.unique_scope if self.unique_scope and len(self.unique_scope) else None
        data["subtype"] = self.subtype if self.subtype and len(self.subtype) else None
        data["userlabel"] = self.userlabel if self.userlabel and len(self.userlabel) else None

        return data
904761
def _get_credentials():
    '''
    
    '''
    ret = {
        'user': False,
        'passwd': False
    }

    # Loop through opts, grains, and pillar
    # Return the first acceptable configuration found
    for item in ret:
        for struct in [__opts__, __grains__, __pillar__]:
            # Look for the config key
            # Support old-style config format and new
            for config_key in __valid_configs[item]:
                value = salt.utils.data.traverse_dict_and_list(
                    struct,
                    config_key,
                    None)
                if value:
                    ret[item] = value
                    break
    return ret['user'], ret['passwd']
261455
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'credential_id') and self.credential_id is not None:
            _dict['credential_id'] = self.credential_id
        if hasattr(self, 'source_type') and self.source_type is not None:
            _dict['source_type'] = self.source_type
        if hasattr(
                self,
                'credential_details') and self.credential_details is not None:
            _dict['credential_details'] = self.credential_details._to_dict()
        return _dict
1078374
def to_dict(self):
        
        return {'schema': self.schema, 'table': self.table, 'name': self.name, 'type': self.type}
61289
def cli(env, identifier):
    """"""

    mgr = SoftLayer.ObjectStorageManager(env.client)
    credential = mgr.create_credential(identifier)
    table = formatting.Table(['id', 'password', 'username', 'type_name'])
    table.sortby = 'id'
    table.add_row([
        credential['id'],
        credential['password'],
        credential['username'],
        credential['type']['name']
    ])

    env.fout(table)
207555
def table_schema(self):
        
        if self.__dict__.get('_table_schema') is None:
            self._table_schema = None
            table_schema = {}
            for row in self.query_schema():
                name, default, dtype = self.db().lexicon.column_info(row)
                if isinstance(default, str):
                    json_matches = re.findall(r"^\'(.*)\'::jsonb$", default)
                    if len(json_matches) > 0:
                        default = json.loads(json_matches[0])
                if name == self.primary_key:
                    default = None
                table_schema[name] = {'default': default, 'type': dtype}
            if len(table_schema):
                self._table_schema = table_schema
        return self._table_schema