A backwards compatible method of getting the key to the all_contracts
    dictionary for a particular contract
351323
def solidity_get_contract_key(all_contracts, filepath, contract_name):
    
    if contract_name in all_contracts:
        return contract_name
    else:
        if filepath is None:
            filename = '<stdin>'
        else:
            _, filename = os.path.split(filepath)
        contract_key = filename + ":" + contract_name
        return contract_key if contract_key in all_contracts else None
671865
def get_contract(self, contract_name: str) -> Dict:
        
        assert self.contracts, 'ContractManager should have contracts compiled'
        return self.contracts[contract_name]
593404
def as_dict(self):
        
        d = {"@module": self.__class__.__module__,
             "@class": self.__class__.__name__,
             "name": self.name, "options": self.options}
        if len(self.subkeys) > 0:
            subkeys = []
            for subkey in self.subkeys:
                subkeys.append(subkey.as_dict())
            d.update({"subkeys": subkeys})
        return d
836137
def fetch(self, keyDict):
        
        for key in keyDict.keys():
            keyDict[key] = self.tbl[key]
121130
def functions(self):
        
        out = {}
        for key in self._func_names:
            out[key[len(self._prefix):]] = getattr(self, key)
        return out
304182
def compile_all(self):
        

        # Solidity input JSON
        solc_input = self.get_solc_input()

        # Compile the contracts
        real_path = os.path.realpath(self.contracts_dir)
        compilation_result = compile_standard(solc_input, allow_paths=real_path)

        # Create the output folder if it doesn't already exist
        os.makedirs(self.output_dir, exist_ok=True)

        # Write the contract ABI to output files
        compiled_contracts = compilation_result['contracts']
        for contract_file in compiled_contracts:
            for contract in compiled_contracts[contract_file]:
                contract_name = contract.split('.')[0]
                contract_data = compiled_contracts[contract_file][contract_name]

                contract_data_path = self.output_dir + '/{0}.json'.format(contract_name)
                with open(contract_data_path, "w+") as contract_data_file:
                    json.dump(contract_data, contract_data_file)
1164784
def _parse_new_contract_args(*args, **kwargs):
    """"""
    # No arguments
    if (not args) and (not kwargs):
        return [
            {
                "name": "argument_invalid",
                "msg": "Argument `*[argument_name]*` is not valid",
                "type": RuntimeError,
            }
        ]
    # Process args
    if (len(args) > 1) or ((len(args) == 1) and kwargs):
        raise TypeError("Illegal custom contract exception definition")
    if len(args) == 1:
        return [dict([("name", "default")] + list(_format_arg(args[0]).items()))]
    # Process kwargs
    return [
        dict([("name", name)] + list(_format_arg(kwargs[name]).items()))
        for name in sorted(list(kwargs.keys()))
    ]
526407
def to_dict(self):
        
        return {key: self.__getitem__(key).value for key in self.options()}
771210
def get_all_keys(self, headers=None, **params):
        
        key = Key(self.name, self.contained_key)
        return SimpleResultSet([key])
188026
def keys(self, **kwargs):
        
        warnings.warn('Use of `rel.fetch.keys()` notation is deprecated. '
                      'Please use `rel.fetch("KEY")` or `rel.fetch(dj.key)` for equivalent result', stacklevel=2)
        yield from self._expression.proj().fetch(as_dict=True, **kwargs)
290261
def get_all_keys(reactor, key_type, value_type, etcd_address):
    
    etcd = Client(reactor, etcd_address)
    result = yield etcd.get(b'\x00', range_end=b'\x00')

    res = {}
    for item in result.kvs:
        if key_type == u'utf8':
            key = item.key.decode('utf8')
        elif key_type == u'binary':
            key = binascii.b2a_base64(item.key).decode().strip()
        else:
            raise Exception('logic error')

        if value_type == u'json':
            value = json.loads(item.value.decode('utf8'))
        elif value_type == u'binary':
            value = binascii.b2a_base64(item.value).decode().strip()
        elif value_type == u'utf8':
            value = item.value.decode('utf8')
        else:
            raise Exception('logic error')

        res[key] = value

    returnValue(res)
1178435
def asdict(self):
        
        result = {}
        for key in self._fields:
            value = getattr(self, key)
            if isinstance(value, list):
                value = [i.asdict() if isinstance(i, Resource) else i for i in value]
            if isinstance(value, Resource):
                value = value.asdict()
            result[key] = value
        return result
314339
def get_kwargs(self):
        """"""

        kwargs = {}

        for attr in self.attrs:
            val = self.attrs[attr]
            if val is not None:
                kwargs[attr] = repr(val)

        code = ", ".join(repr(key) + ": " + kwargs[key] for key in kwargs)

        code = "{" + code + "}"

        return code
260281
def key_values(self):
        
        key_values = {}
        for key in self.keys:
            if key in self.payload:
                key_values[key] = self.payload[key]
        return key_values
73695
def as_dict(self):
        
        #TODO/FIXME: add selected information
        if self.hidden:
            rdict = {}
        else:
            def_selected = self.selected()
            comps = [
                {
                    'name': comp.name,
                    'default': comp.name in self.defaults,
                    'options': comp.get_ordered_options() if isinstance(comp, Optionable) else None
                }
                for comp in self
            ]
            rdict = {
                'name': self.name,
                'required': self.required,
                'multiple': self.multiple,
                'args': self.in_name,
                'returns': self.out_name,
                'components': comps
            }
        return rdict
791908
def getStrikes(self, contract_identifier, smin=None, smax=None):
        
        strikes = []
        contracts = self.contractDetails(contract_identifier)["contracts"]

        if contracts[0].m_secType not in ("FOP", "OPT"):
            return []

        # collect expirations
        for contract in contracts:
            strikes.append(contract.m_strike)

        # convert to floats
        strikes = list(map(float, strikes))
        # strikes = list(set(strikes))

        # get min/max
        if smin is not None or smax is not None:
            smin = smin if smin is not None else 0
            smax = smax if smax is not None else 1000000000
            srange = list(set(range(smin, smax, 1)))
            strikes = [n for n in strikes if n in srange]

        strikes.sort()
        return tuple(strikes)
178115
def to_dict(self):
        
        return {
            'sid': self.asset,
            'amount': self.amount,
            'cost_basis': self.cost_basis,
            'last_sale_price': self.last_sale_price
        }