repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
rstoneback/pysat
pysat/instruments/omni_hro.py
calculate_clock_angle
def calculate_clock_angle(inst): """ Calculate IMF clock angle and magnitude of IMF in GSM Y-Z plane Parameters ----------- inst : pysat.Instrument Instrument with OMNI HRO data """ # Calculate clock angle in degrees clock_angle = np.degrees(np.arctan2(inst['BY_GSM'], inst['BZ_...
python
def calculate_clock_angle(inst): """ Calculate IMF clock angle and magnitude of IMF in GSM Y-Z plane Parameters ----------- inst : pysat.Instrument Instrument with OMNI HRO data """ # Calculate clock angle in degrees clock_angle = np.degrees(np.arctan2(inst['BY_GSM'], inst['BZ_...
[ "def", "calculate_clock_angle", "(", "inst", ")", ":", "# Calculate clock angle in degrees", "clock_angle", "=", "np", ".", "degrees", "(", "np", ".", "arctan2", "(", "inst", "[", "'BY_GSM'", "]", ",", "inst", "[", "'BZ_GSM'", "]", ")", ")", "clock_angle", "...
Calculate IMF clock angle and magnitude of IMF in GSM Y-Z plane Parameters ----------- inst : pysat.Instrument Instrument with OMNI HRO data
[ "Calculate", "IMF", "clock", "angle", "and", "magnitude", "of", "IMF", "in", "GSM", "Y", "-", "Z", "plane" ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/instruments/omni_hro.py#L240-L259
rstoneback/pysat
pysat/instruments/omni_hro.py
calculate_imf_steadiness
def calculate_imf_steadiness(inst, steady_window=15, min_window_frac=0.75, max_clock_angle_std=90.0/np.pi, max_bmag_cv=0.5): """ Calculate IMF steadiness using clock angle standard deviation and the coefficient of variation of the IMF magnitude in the GSM Y-Z plane Parameters ...
python
def calculate_imf_steadiness(inst, steady_window=15, min_window_frac=0.75, max_clock_angle_std=90.0/np.pi, max_bmag_cv=0.5): """ Calculate IMF steadiness using clock angle standard deviation and the coefficient of variation of the IMF magnitude in the GSM Y-Z plane Parameters ...
[ "def", "calculate_imf_steadiness", "(", "inst", ",", "steady_window", "=", "15", ",", "min_window_frac", "=", "0.75", ",", "max_clock_angle_std", "=", "90.0", "/", "np", ".", "pi", ",", "max_bmag_cv", "=", "0.5", ")", ":", "# We are not going to interpolate throug...
Calculate IMF steadiness using clock angle standard deviation and the coefficient of variation of the IMF magnitude in the GSM Y-Z plane Parameters ----------- inst : pysat.Instrument Instrument with OMNI HRO data steady_window : int Window for calculating running statistical moment...
[ "Calculate", "IMF", "steadiness", "using", "clock", "angle", "standard", "deviation", "and", "the", "coefficient", "of", "variation", "of", "the", "IMF", "magnitude", "in", "the", "GSM", "Y", "-", "Z", "plane" ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/instruments/omni_hro.py#L261-L329
rstoneback/pysat
pysat/instruments/omni_hro.py
calculate_dayside_reconnection
def calculate_dayside_reconnection(inst): """ Calculate the dayside reconnection rate (Milan et al. 2014) Parameters ----------- inst : pysat.Instrument Instrument with OMNI HRO data, requires BYZ_GSM and clock_angle Notes -------- recon_day = 3.8 Re (Vx / 4e5 m/s)^1/3 Vx B_yz (sin...
python
def calculate_dayside_reconnection(inst): """ Calculate the dayside reconnection rate (Milan et al. 2014) Parameters ----------- inst : pysat.Instrument Instrument with OMNI HRO data, requires BYZ_GSM and clock_angle Notes -------- recon_day = 3.8 Re (Vx / 4e5 m/s)^1/3 Vx B_yz (sin...
[ "def", "calculate_dayside_reconnection", "(", "inst", ")", ":", "rearth", "=", "6371008.8", "sin_htheta", "=", "np", ".", "power", "(", "np", ".", "sin", "(", "np", ".", "radians", "(", "0.5", "*", "inst", "[", "'clock_angle'", "]", ")", ")", ",", "4.5...
Calculate the dayside reconnection rate (Milan et al. 2014) Parameters ----------- inst : pysat.Instrument Instrument with OMNI HRO data, requires BYZ_GSM and clock_angle Notes -------- recon_day = 3.8 Re (Vx / 4e5 m/s)^1/3 Vx B_yz (sin(theta/2))^9/2
[ "Calculate", "the", "dayside", "reconnection", "rate", "(", "Milan", "et", "al", ".", "2014", ")" ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/instruments/omni_hro.py#L331-L351
emc-openstack/storops
storops/unity/resource/cifs_share.py
UnityCifsShare.clear_access
def clear_access(self, white_list=None): """ clear all ace entries of the share :param white_list: list of username whose access entry won't be cleared :return: sid list of ace entries removed successfully """ access_entries = self.get_ace_list() sid_list = access_entrie...
python
def clear_access(self, white_list=None): """ clear all ace entries of the share :param white_list: list of username whose access entry won't be cleared :return: sid list of ace entries removed successfully """ access_entries = self.get_ace_list() sid_list = access_entrie...
[ "def", "clear_access", "(", "self", ",", "white_list", "=", "None", ")", ":", "access_entries", "=", "self", ".", "get_ace_list", "(", ")", "sid_list", "=", "access_entries", ".", "sid_list", "if", "white_list", ":", "sid_white_list", "=", "[", "UnityAclUser",...
clear all ace entries of the share :param white_list: list of username whose access entry won't be cleared :return: sid list of ace entries removed successfully
[ "clear", "all", "ace", "entries", "of", "the", "share" ]
train
https://github.com/emc-openstack/storops/blob/24b4b13bf065c0ef0538dd0b5ebb8f25d24176bd/storops/unity/resource/cifs_share.py#L114-L132
emc-openstack/storops
storops/unity/resource/cifs_share.py
UnityCifsShare.delete_ace
def delete_ace(self, domain=None, user=None, sid=None): """ delete ACE for the share delete ACE for the share. User could either supply the domain and username or the sid of the user. :param domain: domain of the user :param user: username :param sid: sid of the user o...
python
def delete_ace(self, domain=None, user=None, sid=None): """ delete ACE for the share delete ACE for the share. User could either supply the domain and username or the sid of the user. :param domain: domain of the user :param user: username :param sid: sid of the user o...
[ "def", "delete_ace", "(", "self", ",", "domain", "=", "None", ",", "user", "=", "None", ",", "sid", "=", "None", ")", ":", "if", "sid", "is", "None", ":", "if", "domain", "is", "None", ":", "domain", "=", "self", ".", "cifs_server", ".", "domain", ...
delete ACE for the share delete ACE for the share. User could either supply the domain and username or the sid of the user. :param domain: domain of the user :param user: username :param sid: sid of the user or sid list of the user :return: REST API response
[ "delete", "ACE", "for", "the", "share" ]
train
https://github.com/emc-openstack/storops/blob/24b4b13bf065c0ef0538dd0b5ebb8f25d24176bd/storops/unity/resource/cifs_share.py#L153-L175
emc-openstack/storops
storops/vnx/resource/nqm.py
VNXIOClass.luns
def luns(self): """Aggregator for ioclass_luns and ioclass_snapshots.""" lun_list, smp_list = [], [] if self.ioclass_luns: lun_list = map(lambda l: VNXLun(lun_id=l.lun_id, name=l.name, cli=self._cli), self.ioclass_luns) if self.iocl...
python
def luns(self): """Aggregator for ioclass_luns and ioclass_snapshots.""" lun_list, smp_list = [], [] if self.ioclass_luns: lun_list = map(lambda l: VNXLun(lun_id=l.lun_id, name=l.name, cli=self._cli), self.ioclass_luns) if self.iocl...
[ "def", "luns", "(", "self", ")", ":", "lun_list", ",", "smp_list", "=", "[", "]", ",", "[", "]", "if", "self", ".", "ioclass_luns", ":", "lun_list", "=", "map", "(", "lambda", "l", ":", "VNXLun", "(", "lun_id", "=", "l", ".", "lun_id", ",", "name...
Aggregator for ioclass_luns and ioclass_snapshots.
[ "Aggregator", "for", "ioclass_luns", "and", "ioclass_snapshots", "." ]
train
https://github.com/emc-openstack/storops/blob/24b4b13bf065c0ef0538dd0b5ebb8f25d24176bd/storops/vnx/resource/nqm.py#L107-L116
emc-openstack/storops
storops/vnx/resource/nqm.py
VNXIOClass.policy
def policy(self): """Returns policy which contains this ioclass.""" policies = VNXIOPolicy.get(cli=self._cli) ret = None for policy in policies: contained = policy.ioclasses.name if self._get_name() in contained: ret = VNXIOPolicy.get(name=policy.n...
python
def policy(self): """Returns policy which contains this ioclass.""" policies = VNXIOPolicy.get(cli=self._cli) ret = None for policy in policies: contained = policy.ioclasses.name if self._get_name() in contained: ret = VNXIOPolicy.get(name=policy.n...
[ "def", "policy", "(", "self", ")", ":", "policies", "=", "VNXIOPolicy", ".", "get", "(", "cli", "=", "self", ".", "_cli", ")", "ret", "=", "None", "for", "policy", "in", "policies", ":", "contained", "=", "policy", ".", "ioclasses", ".", "name", "if"...
Returns policy which contains this ioclass.
[ "Returns", "policy", "which", "contains", "this", "ioclass", "." ]
train
https://github.com/emc-openstack/storops/blob/24b4b13bf065c0ef0538dd0b5ebb8f25d24176bd/storops/vnx/resource/nqm.py#L119-L128
emc-openstack/storops
storops/vnx/resource/nqm.py
VNXIOClass.modify
def modify(self, new_name=None, iotype=None, lun_ids=None, smp_names=None, ctrlmethod=None, minsize=None, maxsize=None): """Overwrite the current properties for a VNX ioclass. :param new_name: new name for the ioclass :param iotype: can be 'rw', 'r' or 'w' :param lun_ids:...
python
def modify(self, new_name=None, iotype=None, lun_ids=None, smp_names=None, ctrlmethod=None, minsize=None, maxsize=None): """Overwrite the current properties for a VNX ioclass. :param new_name: new name for the ioclass :param iotype: can be 'rw', 'r' or 'w' :param lun_ids:...
[ "def", "modify", "(", "self", ",", "new_name", "=", "None", ",", "iotype", "=", "None", ",", "lun_ids", "=", "None", ",", "smp_names", "=", "None", ",", "ctrlmethod", "=", "None", ",", "minsize", "=", "None", ",", "maxsize", "=", "None", ")", ":", ...
Overwrite the current properties for a VNX ioclass. :param new_name: new name for the ioclass :param iotype: can be 'rw', 'r' or 'w' :param lun_ids: list of LUN IDs :param smp_names: list of Snapshot Mount Point names :param ctrlmethod: the new CtrlMethod :param minsize:...
[ "Overwrite", "the", "current", "properties", "for", "a", "VNX", "ioclass", "." ]
train
https://github.com/emc-openstack/storops/blob/24b4b13bf065c0ef0538dd0b5ebb8f25d24176bd/storops/vnx/resource/nqm.py#L143-L172
emc-openstack/storops
storops/vnx/resource/nqm.py
VNXIOClass.add_lun
def add_lun(self, luns): """A wrapper for modify method. .. note:: This API only append luns to existing luns. """ curr_lun_ids, curr_smp_names = self._get_current_names() luns = normalize_lun(luns, self._cli) new_ids, new_smps = convert_lun(luns) if new_ids: ...
python
def add_lun(self, luns): """A wrapper for modify method. .. note:: This API only append luns to existing luns. """ curr_lun_ids, curr_smp_names = self._get_current_names() luns = normalize_lun(luns, self._cli) new_ids, new_smps = convert_lun(luns) if new_ids: ...
[ "def", "add_lun", "(", "self", ",", "luns", ")", ":", "curr_lun_ids", ",", "curr_smp_names", "=", "self", ".", "_get_current_names", "(", ")", "luns", "=", "normalize_lun", "(", "luns", ",", "self", ".", "_cli", ")", "new_ids", ",", "new_smps", "=", "con...
A wrapper for modify method. .. note:: This API only append luns to existing luns.
[ "A", "wrapper", "for", "modify", "method", "." ]
train
https://github.com/emc-openstack/storops/blob/24b4b13bf065c0ef0538dd0b5ebb8f25d24176bd/storops/vnx/resource/nqm.py#L174-L186
emc-openstack/storops
storops/vnx/resource/nqm.py
VNXIOPolicy.add_class
def add_class(self, ioclass): """Add one VNXIOClass instance to policy. .. note: due to the limitation of VNX, need to stop the policy first. """ current_ioclasses = self.ioclasses if ioclass.name in current_ioclasses.name: return current_ioclasses.append(ioc...
python
def add_class(self, ioclass): """Add one VNXIOClass instance to policy. .. note: due to the limitation of VNX, need to stop the policy first. """ current_ioclasses = self.ioclasses if ioclass.name in current_ioclasses.name: return current_ioclasses.append(ioc...
[ "def", "add_class", "(", "self", ",", "ioclass", ")", ":", "current_ioclasses", "=", "self", ".", "ioclasses", "if", "ioclass", ".", "name", "in", "current_ioclasses", ".", "name", ":", "return", "current_ioclasses", ".", "append", "(", "ioclass", ")", "self...
Add one VNXIOClass instance to policy. .. note: due to the limitation of VNX, need to stop the policy first.
[ "Add", "one", "VNXIOClass", "instance", "to", "policy", "." ]
train
https://github.com/emc-openstack/storops/blob/24b4b13bf065c0ef0538dd0b5ebb8f25d24176bd/storops/vnx/resource/nqm.py#L280-L289
emc-openstack/storops
storops/vnx/resource/nqm.py
VNXIOPolicy.remove_class
def remove_class(self, ioclass): """Remove VNXIOClass instance from policy.""" current_ioclasses = self.ioclasses new_ioclasses = filter(lambda x: x.name != ioclass.name, current_ioclasses) self.modify(new_ioclasses=new_ioclasses)
python
def remove_class(self, ioclass): """Remove VNXIOClass instance from policy.""" current_ioclasses = self.ioclasses new_ioclasses = filter(lambda x: x.name != ioclass.name, current_ioclasses) self.modify(new_ioclasses=new_ioclasses)
[ "def", "remove_class", "(", "self", ",", "ioclass", ")", ":", "current_ioclasses", "=", "self", ".", "ioclasses", "new_ioclasses", "=", "filter", "(", "lambda", "x", ":", "x", ".", "name", "!=", "ioclass", ".", "name", ",", "current_ioclasses", ")", "self"...
Remove VNXIOClass instance from policy.
[ "Remove", "VNXIOClass", "instance", "from", "policy", "." ]
train
https://github.com/emc-openstack/storops/blob/24b4b13bf065c0ef0538dd0b5ebb8f25d24176bd/storops/vnx/resource/nqm.py#L291-L296
emc-openstack/storops
storops/unity/resource/cg.py
UnityConsistencyGroup.replace_lun
def replace_lun(self, *lun_list): """Replaces the exiting LUNs to lun_list.""" lun_add = self._prepare_luns_add(lun_list) lun_remove = self._prepare_luns_remove(lun_list, False) return self.modify(lun_add=lun_add, lun_remove=lun_remove)
python
def replace_lun(self, *lun_list): """Replaces the exiting LUNs to lun_list.""" lun_add = self._prepare_luns_add(lun_list) lun_remove = self._prepare_luns_remove(lun_list, False) return self.modify(lun_add=lun_add, lun_remove=lun_remove)
[ "def", "replace_lun", "(", "self", ",", "*", "lun_list", ")", ":", "lun_add", "=", "self", ".", "_prepare_luns_add", "(", "lun_list", ")", "lun_remove", "=", "self", ".", "_prepare_luns_remove", "(", "lun_list", ",", "False", ")", "return", "self", ".", "m...
Replaces the exiting LUNs to lun_list.
[ "Replaces", "the", "exiting", "LUNs", "to", "lun_list", "." ]
train
https://github.com/emc-openstack/storops/blob/24b4b13bf065c0ef0538dd0b5ebb8f25d24176bd/storops/unity/resource/cg.py#L208-L212
emc-openstack/storops
storops/unity/resource/cg.py
UnityConsistencyGroup.update_lun
def update_lun(self, add_luns=None, remove_luns=None): """Updates the LUNs in CG, adding the ones in `add_luns` and removing the ones in `remove_luns`""" if not add_luns and not remove_luns: log.debug("Empty add_luns and remove_luns passed in, " "skip update_lun...
python
def update_lun(self, add_luns=None, remove_luns=None): """Updates the LUNs in CG, adding the ones in `add_luns` and removing the ones in `remove_luns`""" if not add_luns and not remove_luns: log.debug("Empty add_luns and remove_luns passed in, " "skip update_lun...
[ "def", "update_lun", "(", "self", ",", "add_luns", "=", "None", ",", "remove_luns", "=", "None", ")", ":", "if", "not", "add_luns", "and", "not", "remove_luns", ":", "log", ".", "debug", "(", "\"Empty add_luns and remove_luns passed in, \"", "\"skip update_lun.\""...
Updates the LUNs in CG, adding the ones in `add_luns` and removing the ones in `remove_luns`
[ "Updates", "the", "LUNs", "in", "CG", "adding", "the", "ones", "in", "add_luns", "and", "removing", "the", "ones", "in", "remove_luns" ]
train
https://github.com/emc-openstack/storops/blob/24b4b13bf065c0ef0538dd0b5ebb8f25d24176bd/storops/unity/resource/cg.py#L214-L223
rstoneback/pysat
pysat/instruments/iss_fpmu.py
clean
def clean(inst): """Routine to return FPMU data cleaned to the specified level Parameters ----------- inst : (pysat.Instrument) Instrument class object, whose attribute clean_level is used to return the desired level of data selectivity. Returns -------- Void : (NoneType) ...
python
def clean(inst): """Routine to return FPMU data cleaned to the specified level Parameters ----------- inst : (pysat.Instrument) Instrument class object, whose attribute clean_level is used to return the desired level of data selectivity. Returns -------- Void : (NoneType) ...
[ "def", "clean", "(", "inst", ")", ":", "inst", ".", "data", ".", "replace", "(", "-", "999.", ",", "np", ".", "nan", ",", "inplace", "=", "True", ")", "# Te", "inst", ".", "data", ".", "replace", "(", "-", "9.9999998e+30", ",", "np", ".", "nan", ...
Routine to return FPMU data cleaned to the specified level Parameters ----------- inst : (pysat.Instrument) Instrument class object, whose attribute clean_level is used to return the desired level of data selectivity. Returns -------- Void : (NoneType) data in inst is m...
[ "Routine", "to", "return", "FPMU", "data", "cleaned", "to", "the", "specified", "level" ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/instruments/iss_fpmu.py#L59-L81
rstoneback/pysat
pysat/_files.py
Files._attach_files
def _attach_files(self, files_info): """Attaches info returned by instrument list_files routine to Instrument object. """ if not files_info.empty: if (len(files_info.index.unique()) != len(files_info)): estr = 'WARNING! Duplicate datetimes in provided file ' ...
python
def _attach_files(self, files_info): """Attaches info returned by instrument list_files routine to Instrument object. """ if not files_info.empty: if (len(files_info.index.unique()) != len(files_info)): estr = 'WARNING! Duplicate datetimes in provided file ' ...
[ "def", "_attach_files", "(", "self", ",", "files_info", ")", ":", "if", "not", "files_info", ".", "empty", ":", "if", "(", "len", "(", "files_info", ".", "index", ".", "unique", "(", ")", ")", "!=", "len", "(", "files_info", ")", ")", ":", "estr", ...
Attaches info returned by instrument list_files routine to Instrument object.
[ "Attaches", "info", "returned", "by", "instrument", "list_files", "routine", "to", "Instrument", "object", "." ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_files.py#L141-L168
rstoneback/pysat
pysat/_files.py
Files._store
def _store(self): """Store currently loaded filelist for instrument onto filesystem""" name = self.stored_file_name # check if current file data is different than stored file list # if so, move file list to previous file list, store current to file # if not, do nothing s...
python
def _store(self): """Store currently loaded filelist for instrument onto filesystem""" name = self.stored_file_name # check if current file data is different than stored file list # if so, move file list to previous file list, store current to file # if not, do nothing s...
[ "def", "_store", "(", "self", ")", ":", "name", "=", "self", ".", "stored_file_name", "# check if current file data is different than stored file list", "# if so, move file list to previous file list, store current to file", "# if not, do nothing", "stored_files", "=", "self", ".",...
Store currently loaded filelist for instrument onto filesystem
[ "Store", "currently", "loaded", "filelist", "for", "instrument", "onto", "filesystem" ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_files.py#L170-L200
rstoneback/pysat
pysat/_files.py
Files._load
def _load(self, prev_version=False): """Load stored filelist and return as Pandas Series Parameters ---------- prev_version : boolean if True, will load previous version of file list Returns ------- pandas.Series Full path file names are ...
python
def _load(self, prev_version=False): """Load stored filelist and return as Pandas Series Parameters ---------- prev_version : boolean if True, will load previous version of file list Returns ------- pandas.Series Full path file names are ...
[ "def", "_load", "(", "self", ",", "prev_version", "=", "False", ")", ":", "fname", "=", "self", ".", "stored_file_name", "if", "prev_version", ":", "fname", "=", "os", ".", "path", ".", "join", "(", "self", ".", "home_path", ",", "'previous_'", "+", "f...
Load stored filelist and return as Pandas Series Parameters ---------- prev_version : boolean if True, will load previous version of file list Returns ------- pandas.Series Full path file names are indexed by datetime Series is empty ...
[ "Load", "stored", "filelist", "and", "return", "as", "Pandas", "Series" ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_files.py#L202-L234
rstoneback/pysat
pysat/_files.py
Files.refresh
def refresh(self): """Update list of files, if there are changes. Calls underlying list_rtn for the particular science instrument. Typically, these routines search in the pysat provided path, pysat_data_dir/platform/name/tag/, where pysat_data_dir is set by pysat.utils.s...
python
def refresh(self): """Update list of files, if there are changes. Calls underlying list_rtn for the particular science instrument. Typically, these routines search in the pysat provided path, pysat_data_dir/platform/name/tag/, where pysat_data_dir is set by pysat.utils.s...
[ "def", "refresh", "(", "self", ")", ":", "output_str", "=", "'{platform} {name} {tag} {sat_id}'", "output_str", "=", "output_str", ".", "format", "(", "platform", "=", "self", ".", "_sat", ".", "platform", ",", "name", "=", "self", ".", "_sat", ".", "name", ...
Update list of files, if there are changes. Calls underlying list_rtn for the particular science instrument. Typically, these routines search in the pysat provided path, pysat_data_dir/platform/name/tag/, where pysat_data_dir is set by pysat.utils.set_data_dir(path=path).
[ "Update", "list", "of", "files", "if", "there", "are", "changes", ".", "Calls", "underlying", "list_rtn", "for", "the", "particular", "science", "instrument", ".", "Typically", "these", "routines", "search", "in", "the", "pysat", "provided", "path", "pysat_data_...
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_files.py#L237-L269
rstoneback/pysat
pysat/_files.py
Files.get_new
def get_new(self): """List new files since last recorded file state. pysat stores filenames in the user_home/.pysat directory. Returns a list of all new fileanmes since the last known change to files. Filenames are stored if there is a change and either update_files is T...
python
def get_new(self): """List new files since last recorded file state. pysat stores filenames in the user_home/.pysat directory. Returns a list of all new fileanmes since the last known change to files. Filenames are stored if there is a change and either update_files is T...
[ "def", "get_new", "(", "self", ")", ":", "# refresh files", "self", ".", "refresh", "(", ")", "# current files", "new_info", "=", "self", ".", "_load", "(", ")", "# previous set of files", "old_info", "=", "self", ".", "_load", "(", "prev_version", "=", "Tru...
List new files since last recorded file state. pysat stores filenames in the user_home/.pysat directory. Returns a list of all new fileanmes since the last known change to files. Filenames are stored if there is a change and either update_files is True at instrument object level...
[ "List", "new", "files", "since", "last", "recorded", "file", "state", ".", "pysat", "stores", "filenames", "in", "the", "user_home", "/", ".", "pysat", "directory", ".", "Returns", "a", "list", "of", "all", "new", "fileanmes", "since", "the", "last", "know...
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_files.py#L271-L293
rstoneback/pysat
pysat/_files.py
Files.get_index
def get_index(self, fname): """Return index for a given filename. Parameters ---------- fname : string filename Note ---- If fname not found in the file information already attached to the instrument.files instance, then a f...
python
def get_index(self, fname): """Return index for a given filename. Parameters ---------- fname : string filename Note ---- If fname not found in the file information already attached to the instrument.files instance, then a f...
[ "def", "get_index", "(", "self", ",", "fname", ")", ":", "idx", ",", "=", "np", ".", "where", "(", "fname", "==", "self", ".", "files", ")", "if", "len", "(", "idx", ")", "==", "0", ":", "# filename not in index, try reloading files from disk", "self", "...
Return index for a given filename. Parameters ---------- fname : string filename Note ---- If fname not found in the file information already attached to the instrument.files instance, then a files.refresh() call is made.
[ "Return", "index", "for", "a", "given", "filename", ".", "Parameters", "----------", "fname", ":", "string", "filename", "Note", "----", "If", "fname", "not", "found", "in", "the", "file", "information", "already", "attached", "to", "the", "instrument", ".", ...
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_files.py#L314-L343
rstoneback/pysat
pysat/_files.py
Files.get_file_array
def get_file_array(self, start, end): """Return a list of filenames between and including start and end. Parameters ---------- start: array_like or single string filenames for start of returned filelist stop: array_like or single string ...
python
def get_file_array(self, start, end): """Return a list of filenames between and including start and end. Parameters ---------- start: array_like or single string filenames for start of returned filelist stop: array_like or single string ...
[ "def", "get_file_array", "(", "self", ",", "start", ",", "end", ")", ":", "if", "hasattr", "(", "start", ",", "'__iter__'", ")", "&", "hasattr", "(", "end", ",", "'__iter__'", ")", ":", "files", "=", "[", "]", "for", "(", "sta", ",", "stp", ")", ...
Return a list of filenames between and including start and end. Parameters ---------- start: array_like or single string filenames for start of returned filelist stop: array_like or single string filenames inclusive end of list ...
[ "Return", "a", "list", "of", "filenames", "between", "and", "including", "start", "and", "end", ".", "Parameters", "----------", "start", ":", "array_like", "or", "single", "string", "filenames", "for", "start", "of", "returned", "filelist", "stop", ":", "arra...
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_files.py#L382-L411
rstoneback/pysat
pysat/_files.py
Files._remove_data_dir_path
def _remove_data_dir_path(self, inp=None): # import string """Remove the data directory path from filenames""" # need to add a check in here to make sure data_dir path is actually in # the filename if inp is not None: split_str = os.path.join(self.data_path, '') ...
python
def _remove_data_dir_path(self, inp=None): # import string """Remove the data directory path from filenames""" # need to add a check in here to make sure data_dir path is actually in # the filename if inp is not None: split_str = os.path.join(self.data_path, '') ...
[ "def", "_remove_data_dir_path", "(", "self", ",", "inp", "=", "None", ")", ":", "# import string", "# need to add a check in here to make sure data_dir path is actually in", "# the filename", "if", "inp", "is", "not", "None", ":", "split_str", "=", "os", ".", "path", ...
Remove the data directory path from filenames
[ "Remove", "the", "data", "directory", "path", "from", "filenames" ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_files.py#L413-L420
rstoneback/pysat
pysat/_files.py
Files.from_os
def from_os(cls, data_path=None, format_str=None, two_digit_year_break=None): """ Produces a list of files and and formats it for Files class. Requires fixed_width filename Parameters ---------- data_path : string Top level directory...
python
def from_os(cls, data_path=None, format_str=None, two_digit_year_break=None): """ Produces a list of files and and formats it for Files class. Requires fixed_width filename Parameters ---------- data_path : string Top level directory...
[ "def", "from_os", "(", "cls", ",", "data_path", "=", "None", ",", "format_str", "=", "None", ",", "two_digit_year_break", "=", "None", ")", ":", "import", "collections", "from", "pysat", ".", "utils", "import", "create_datetime_index", "if", "format_str", "is"...
Produces a list of files and and formats it for Files class. Requires fixed_width filename Parameters ---------- data_path : string Top level directory to search files for. This directory is provided by pysat to the instrument_module.list_files ...
[ "Produces", "a", "list", "of", "files", "and", "and", "formats", "it", "for", "Files", "class", "." ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_files.py#L431-L599
rstoneback/pysat
pysat/_meta.py
Meta.merge
def merge(self, other): """Adds metadata variables to self that are in other but not in self. Parameters ---------- other : pysat.Meta """ for key in other.keys(): if key not in self: # copies over both lower and high...
python
def merge(self, other): """Adds metadata variables to self that are in other but not in self. Parameters ---------- other : pysat.Meta """ for key in other.keys(): if key not in self: # copies over both lower and high...
[ "def", "merge", "(", "self", ",", "other", ")", ":", "for", "key", "in", "other", ".", "keys", "(", ")", ":", "if", "key", "not", "in", "self", ":", "# copies over both lower and higher dimensional data", "self", "[", "key", "]", "=", "other", "[", "key"...
Adds metadata variables to self that are in other but not in self. Parameters ---------- other : pysat.Meta
[ "Adds", "metadata", "variables", "to", "self", "that", "are", "in", "other", "but", "not", "in", "self", ".", "Parameters", "----------", "other", ":", "pysat", ".", "Meta" ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_meta.py#L240-L252
rstoneback/pysat
pysat/_meta.py
Meta.drop
def drop(self, names): """Drops variables (names) from metadata.""" # drop lower dimension data self._data = self._data.drop(names, axis=0) # drop higher dimension data for name in names: if name in self._ho_data: _ = self._ho_data.pop(name)
python
def drop(self, names): """Drops variables (names) from metadata.""" # drop lower dimension data self._data = self._data.drop(names, axis=0) # drop higher dimension data for name in names: if name in self._ho_data: _ = self._ho_data.pop(name)
[ "def", "drop", "(", "self", ",", "names", ")", ":", "# drop lower dimension data", "self", ".", "_data", "=", "self", ".", "_data", ".", "drop", "(", "names", ",", "axis", "=", "0", ")", "# drop higher dimension data", "for", "name", "in", "names", ":", ...
Drops variables (names) from metadata.
[ "Drops", "variables", "(", "names", ")", "from", "metadata", "." ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_meta.py#L254-L262
rstoneback/pysat
pysat/_meta.py
Meta.keep
def keep(self, keep_names): """Keeps variables (keep_names) while dropping other parameters""" current_names = self._data.columns drop_names = [] for name in current_names: if name not in keep_names: drop_names.append(name) self.drop(drop_name...
python
def keep(self, keep_names): """Keeps variables (keep_names) while dropping other parameters""" current_names = self._data.columns drop_names = [] for name in current_names: if name not in keep_names: drop_names.append(name) self.drop(drop_name...
[ "def", "keep", "(", "self", ",", "keep_names", ")", ":", "current_names", "=", "self", ".", "_data", ".", "columns", "drop_names", "=", "[", "]", "for", "name", "in", "current_names", ":", "if", "name", "not", "in", "keep_names", ":", "drop_names", ".", ...
Keeps variables (keep_names) while dropping other parameters
[ "Keeps", "variables", "(", "keep_names", ")", "while", "dropping", "other", "parameters" ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_meta.py#L264-L272
rstoneback/pysat
pysat/_meta.py
Meta.apply_default_labels
def apply_default_labels(self, other): """Applies labels for default meta labels from self onto other. Parameters ---------- other : Meta Meta object to have default labels applied Returns ------- Meta """ oth...
python
def apply_default_labels(self, other): """Applies labels for default meta labels from self onto other. Parameters ---------- other : Meta Meta object to have default labels applied Returns ------- Meta """ oth...
[ "def", "apply_default_labels", "(", "self", ",", "other", ")", ":", "other_updated", "=", "other", ".", "copy", "(", ")", "other_updated", ".", "units_label", "=", "self", ".", "units_label", "other_updated", ".", "name_label", "=", "self", ".", "name_label", ...
Applies labels for default meta labels from self onto other. Parameters ---------- other : Meta Meta object to have default labels applied Returns ------- Meta
[ "Applies", "labels", "for", "default", "meta", "labels", "from", "self", "onto", "other", ".", "Parameters", "----------", "other", ":", "Meta", "Meta", "object", "to", "have", "default", "labels", "applied", "Returns", "-------", "Meta" ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_meta.py#L307-L331
rstoneback/pysat
pysat/_meta.py
Meta.accept_default_labels
def accept_default_labels(self, other): """Applies labels for default meta labels from other onto self. Parameters ---------- other : Meta Meta object to take default labels from Returns ------- Meta """ self...
python
def accept_default_labels(self, other): """Applies labels for default meta labels from other onto self. Parameters ---------- other : Meta Meta object to take default labels from Returns ------- Meta """ self...
[ "def", "accept_default_labels", "(", "self", ",", "other", ")", ":", "self", ".", "units_label", "=", "other", ".", "units_label", "self", ".", "name_label", "=", "other", ".", "name_label", "self", ".", "notes_label", "=", "other", ".", "notes_label", "self...
Applies labels for default meta labels from other onto self. Parameters ---------- other : Meta Meta object to take default labels from Returns ------- Meta
[ "Applies", "labels", "for", "default", "meta", "labels", "from", "other", "onto", "self", ".", "Parameters", "----------", "other", ":", "Meta", "Meta", "object", "to", "take", "default", "labels", "from", "Returns", "-------", "Meta" ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_meta.py#L333-L357
rstoneback/pysat
pysat/_meta.py
Meta._label_setter
def _label_setter(self, new_label, current_label, attr_label, default=np.NaN, use_names_default=False): """Generalized setter of default meta attributes Parameters ---------- new_label : str New label to use in the Meta object current_label : str ...
python
def _label_setter(self, new_label, current_label, attr_label, default=np.NaN, use_names_default=False): """Generalized setter of default meta attributes Parameters ---------- new_label : str New label to use in the Meta object current_label : str ...
[ "def", "_label_setter", "(", "self", ",", "new_label", ",", "current_label", ",", "attr_label", ",", "default", "=", "np", ".", "NaN", ",", "use_names_default", "=", "False", ")", ":", "if", "new_label", "not", "in", "self", ".", "attrs", "(", ")", ":", ...
Generalized setter of default meta attributes Parameters ---------- new_label : str New label to use in the Meta object current_label : str The hidden attribute to be updated that actually stores metadata default : Deafult setting to ...
[ "Generalized", "setter", "of", "default", "meta", "attributes", "Parameters", "----------", "new_label", ":", "str", "New", "label", "to", "use", "in", "the", "Meta", "object", "current_label", ":", "str", "The", "hidden", "attribute", "to", "be", "updated", "...
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_meta.py#L574-L631
rstoneback/pysat
pysat/_meta.py
Meta.var_case_name
def var_case_name(self, name): """Provides stored name (case preserved) for case insensitive input If name is not found (case-insensitive check) then name is returned, as input. This function is intended to be used to help ensure the case of a given variable name is the same acr...
python
def var_case_name(self, name): """Provides stored name (case preserved) for case insensitive input If name is not found (case-insensitive check) then name is returned, as input. This function is intended to be used to help ensure the case of a given variable name is the same acr...
[ "def", "var_case_name", "(", "self", ",", "name", ")", ":", "lower_name", "=", "name", ".", "lower", "(", ")", "if", "name", "in", "self", ":", "for", "i", "in", "self", ".", "keys", "(", ")", ":", "if", "lower_name", "==", "i", ".", "lower", "("...
Provides stored name (case preserved) for case insensitive input If name is not found (case-insensitive check) then name is returned, as input. This function is intended to be used to help ensure the case of a given variable name is the same across the Meta object. Para...
[ "Provides", "stored", "name", "(", "case", "preserved", ")", "for", "case", "insensitive", "input", "If", "name", "is", "not", "found", "(", "case", "-", "insensitive", "check", ")", "then", "name", "is", "returned", "as", "input", ".", "This", "function",...
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_meta.py#L704-L731
rstoneback/pysat
pysat/_meta.py
Meta.has_attr
def has_attr(self, name): """Returns boolean indicating presence of given attribute name Case-insensitive check Notes ----- Does not check higher order meta objects Parameters ---------- name : str name of variable to...
python
def has_attr(self, name): """Returns boolean indicating presence of given attribute name Case-insensitive check Notes ----- Does not check higher order meta objects Parameters ---------- name : str name of variable to...
[ "def", "has_attr", "(", "self", ",", "name", ")", ":", "if", "name", ".", "lower", "(", ")", "in", "[", "i", ".", "lower", "(", ")", "for", "i", "in", "self", ".", "data", ".", "columns", "]", ":", "return", "True", "return", "False" ]
Returns boolean indicating presence of given attribute name Case-insensitive check Notes ----- Does not check higher order meta objects Parameters ---------- name : str name of variable to get stored case form ...
[ "Returns", "boolean", "indicating", "presence", "of", "given", "attribute", "name", "Case", "-", "insensitive", "check", "Notes", "-----", "Does", "not", "check", "higher", "order", "meta", "objects", "Parameters", "----------", "name", ":", "str", "name", "of",...
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_meta.py#L751-L774
rstoneback/pysat
pysat/_meta.py
Meta.attr_case_name
def attr_case_name(self, name): """Returns preserved case name for case insensitive value of name. Checks first within standard attributes. If not found there, checks attributes for higher order data structures. If not found, returns supplied name as it is available for use. Int...
python
def attr_case_name(self, name): """Returns preserved case name for case insensitive value of name. Checks first within standard attributes. If not found there, checks attributes for higher order data structures. If not found, returns supplied name as it is available for use. Int...
[ "def", "attr_case_name", "(", "self", ",", "name", ")", ":", "lower_name", "=", "name", ".", "lower", "(", ")", "for", "i", "in", "self", ".", "attrs", "(", ")", ":", "if", "lower_name", "==", "i", ".", "lower", "(", ")", ":", "return", "i", "# c...
Returns preserved case name for case insensitive value of name. Checks first within standard attributes. If not found there, checks attributes for higher order data structures. If not found, returns supplied name as it is available for use. Intended to be used to help ensure tha...
[ "Returns", "preserved", "case", "name", "for", "case", "insensitive", "value", "of", "name", ".", "Checks", "first", "within", "standard", "attributes", ".", "If", "not", "found", "there", "checks", "attributes", "for", "higher", "order", "data", "structures", ...
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_meta.py#L776-L807
rstoneback/pysat
pysat/_meta.py
Meta.concat
def concat(self, other, strict=False): """Concats two metadata objects together. Parameters ---------- other : Meta Meta object to be concatenated strict : bool if True, ensure there are no duplicate variable names Notes ----- Use...
python
def concat(self, other, strict=False): """Concats two metadata objects together. Parameters ---------- other : Meta Meta object to be concatenated strict : bool if True, ensure there are no duplicate variable names Notes ----- Use...
[ "def", "concat", "(", "self", ",", "other", ",", "strict", "=", "False", ")", ":", "mdata", "=", "self", ".", "copy", "(", ")", "# checks", "if", "strict", ":", "for", "key", "in", "other", ".", "keys", "(", ")", ":", "if", "key", "in", "mdata", ...
Concats two metadata objects together. Parameters ---------- other : Meta Meta object to be concatenated strict : bool if True, ensure there are no duplicate variable names Notes ----- Uses units and name label of self if other is differe...
[ "Concats", "two", "metadata", "objects", "together", "." ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_meta.py#L809-L859
rstoneback/pysat
pysat/_meta.py
Meta.pop
def pop(self, name): """Remove and return metadata about variable Parameters ---------- name : str variable name Returns ------- pandas.Series Series of metadata for variable """ # check if present if name in self:...
python
def pop(self, name): """Remove and return metadata about variable Parameters ---------- name : str variable name Returns ------- pandas.Series Series of metadata for variable """ # check if present if name in self:...
[ "def", "pop", "(", "self", ",", "name", ")", ":", "# check if present", "if", "name", "in", "self", ":", "# get case preserved name for variable", "new_name", "=", "self", ".", "var_case_name", "(", "name", ")", "# check if 1D or nD", "if", "new_name", "in", "se...
Remove and return metadata about variable Parameters ---------- name : str variable name Returns ------- pandas.Series Series of metadata for variable
[ "Remove", "and", "return", "metadata", "about", "variable" ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_meta.py#L866-L892
rstoneback/pysat
pysat/_meta.py
Meta.transfer_attributes_to_instrument
def transfer_attributes_to_instrument(self, inst, strict_names=False): """Transfer non-standard attributes in Meta to Instrument object. Pysat's load_netCDF and similar routines are only able to attach netCDF4 attributes to a Meta object. This routine identifies these attributes and rem...
python
def transfer_attributes_to_instrument(self, inst, strict_names=False): """Transfer non-standard attributes in Meta to Instrument object. Pysat's load_netCDF and similar routines are only able to attach netCDF4 attributes to a Meta object. This routine identifies these attributes and rem...
[ "def", "transfer_attributes_to_instrument", "(", "self", ",", "inst", ",", "strict_names", "=", "False", ")", ":", "# base Instrument attributes", "banned", "=", "inst", ".", "_base_attr", "# get base attribute set, and attributes attached to instance", "base_attrb", "=", "...
Transfer non-standard attributes in Meta to Instrument object. Pysat's load_netCDF and similar routines are only able to attach netCDF4 attributes to a Meta object. This routine identifies these attributes and removes them from the Meta object. Intent is to support simple transfers to ...
[ "Transfer", "non", "-", "standard", "attributes", "in", "Meta", "to", "Instrument", "object", "." ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_meta.py#L895-L951
rstoneback/pysat
pysat/_meta.py
Meta.from_csv
def from_csv(cls, name=None, col_names=None, sep=None, **kwargs): """Create instrument metadata object from csv. Parameters ---------- name : string absolute filename for csv file or name of file stored in pandas instruments location col_names : list-like...
python
def from_csv(cls, name=None, col_names=None, sep=None, **kwargs): """Create instrument metadata object from csv. Parameters ---------- name : string absolute filename for csv file or name of file stored in pandas instruments location col_names : list-like...
[ "def", "from_csv", "(", "cls", ",", "name", "=", "None", ",", "col_names", "=", "None", ",", "sep", "=", "None", ",", "*", "*", "kwargs", ")", ":", "import", "pysat", "req_names", "=", "[", "'name'", ",", "'long_name'", ",", "'units'", "]", "if", "...
Create instrument metadata object from csv. Parameters ---------- name : string absolute filename for csv file or name of file stored in pandas instruments location col_names : list-like collection of strings column names in csv and resultant meta obj...
[ "Create", "instrument", "metadata", "object", "from", "csv", "." ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_meta.py#L1047-L1102
rstoneback/pysat
pysat/instruments/cnofs_ivm.py
clean
def clean(self): """Routine to return C/NOFS IVM data cleaned to the specified level Parameters ----------- inst : (pysat.Instrument) Instrument class object, whose attribute clean_level is used to return the desired level of data selectivity. Returns -------- Void : (NoneT...
python
def clean(self): """Routine to return C/NOFS IVM data cleaned to the specified level Parameters ----------- inst : (pysat.Instrument) Instrument class object, whose attribute clean_level is used to return the desired level of data selectivity. Returns -------- Void : (NoneT...
[ "def", "clean", "(", "self", ")", ":", "# cleans cindi data", "if", "self", ".", "clean_level", "==", "'clean'", ":", "# choose areas below 550km", "# self.data = self.data[self.data.alt <= 550]", "idx", ",", "=", "np", ".", "where", "(", "self", ".", "data", ".",...
Routine to return C/NOFS IVM data cleaned to the specified level Parameters ----------- inst : (pysat.Instrument) Instrument class object, whose attribute clean_level is used to return the desired level of data selectivity. Returns -------- Void : (NoneType) data in ins...
[ "Routine", "to", "return", "C", "/", "NOFS", "IVM", "data", "cleaned", "to", "the", "specified", "level" ]
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/instruments/cnofs_ivm.py#L67-L130
charettes/django-mutant
mutant/management/__init__.py
nonraw_instance
def nonraw_instance(receiver): """ A signal receiver decorator that fetch the complete instance from db when it's passed as raw """ @wraps(receiver) def wrapper(sender, instance, raw, using, **kwargs): if raw: instance = sender._default_manager.using(using).get(pk=instance.pk...
python
def nonraw_instance(receiver): """ A signal receiver decorator that fetch the complete instance from db when it's passed as raw """ @wraps(receiver) def wrapper(sender, instance, raw, using, **kwargs): if raw: instance = sender._default_manager.using(using).get(pk=instance.pk...
[ "def", "nonraw_instance", "(", "receiver", ")", ":", "@", "wraps", "(", "receiver", ")", "def", "wrapper", "(", "sender", ",", "instance", ",", "raw", ",", "using", ",", "*", "*", "kwargs", ")", ":", "if", "raw", ":", "instance", "=", "sender", ".", ...
A signal receiver decorator that fetch the complete instance from db when it's passed as raw
[ "A", "signal", "receiver", "decorator", "that", "fetch", "the", "complete", "instance", "from", "db", "when", "it", "s", "passed", "as", "raw" ]
train
https://github.com/charettes/django-mutant/blob/865a1b712ce30501901c4691ce2110ab03f0f93b/mutant/management/__init__.py#L24-L35
charettes/django-mutant
mutant/management/__init__.py
base_definition_pre_delete
def base_definition_pre_delete(sender, instance, **kwargs): """ This is used to pass data required for deletion to the post_delete signal that is no more available thereafter. """ # see CASCADE_MARK_ORIGIN's docstring cascade_deletion_origin = popattr( instance._state, '_cascade_deletion...
python
def base_definition_pre_delete(sender, instance, **kwargs): """ This is used to pass data required for deletion to the post_delete signal that is no more available thereafter. """ # see CASCADE_MARK_ORIGIN's docstring cascade_deletion_origin = popattr( instance._state, '_cascade_deletion...
[ "def", "base_definition_pre_delete", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "# see CASCADE_MARK_ORIGIN's docstring", "cascade_deletion_origin", "=", "popattr", "(", "instance", ".", "_state", ",", "'_cascade_deletion_origin'", ",", "None", ...
This is used to pass data required for deletion to the post_delete signal that is no more available thereafter.
[ "This", "is", "used", "to", "pass", "data", "required", "for", "deletion", "to", "the", "post_delete", "signal", "that", "is", "no", "more", "available", "thereafter", "." ]
train
https://github.com/charettes/django-mutant/blob/865a1b712ce30501901c4691ce2110ab03f0f93b/mutant/management/__init__.py#L132-L145
charettes/django-mutant
mutant/management/__init__.py
base_definition_post_delete
def base_definition_post_delete(sender, instance, **kwargs): """ Make sure to delete fields inherited from an abstract model base. """ if hasattr(instance._state, '_deletion'): # Make sure to flatten abstract bases since Django # migrations can't deal with them. model = popattr(i...
python
def base_definition_post_delete(sender, instance, **kwargs): """ Make sure to delete fields inherited from an abstract model base. """ if hasattr(instance._state, '_deletion'): # Make sure to flatten abstract bases since Django # migrations can't deal with them. model = popattr(i...
[ "def", "base_definition_post_delete", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "if", "hasattr", "(", "instance", ".", "_state", ",", "'_deletion'", ")", ":", "# Make sure to flatten abstract bases since Django", "# migrations can't deal with th...
Make sure to delete fields inherited from an abstract model base.
[ "Make", "sure", "to", "delete", "fields", "inherited", "from", "an", "abstract", "model", "base", "." ]
train
https://github.com/charettes/django-mutant/blob/865a1b712ce30501901c4691ce2110ab03f0f93b/mutant/management/__init__.py#L148-L157
charettes/django-mutant
mutant/management/__init__.py
raw_field_definition_proxy_post_save
def raw_field_definition_proxy_post_save(sender, instance, raw, **kwargs): """ When proxy field definitions are loaded from a fixture they're not passing through the `field_definition_post_save` signal. Make sure they are. """ if raw: model_class = instance.content_type.model_class() ...
python
def raw_field_definition_proxy_post_save(sender, instance, raw, **kwargs): """ When proxy field definitions are loaded from a fixture they're not passing through the `field_definition_post_save` signal. Make sure they are. """ if raw: model_class = instance.content_type.model_class() ...
[ "def", "raw_field_definition_proxy_post_save", "(", "sender", ",", "instance", ",", "raw", ",", "*", "*", "kwargs", ")", ":", "if", "raw", ":", "model_class", "=", "instance", ".", "content_type", ".", "model_class", "(", ")", "opts", "=", "model_class", "."...
When proxy field definitions are loaded from a fixture they're not passing through the `field_definition_post_save` signal. Make sure they are.
[ "When", "proxy", "field", "definitions", "are", "loaded", "from", "a", "fixture", "they", "re", "not", "passing", "through", "the", "field_definition_post_save", "signal", ".", "Make", "sure", "they", "are", "." ]
train
https://github.com/charettes/django-mutant/blob/865a1b712ce30501901c4691ce2110ab03f0f93b/mutant/management/__init__.py#L172-L185
charettes/django-mutant
mutant/management/__init__.py
field_definition_post_save
def field_definition_post_save(sender, instance, created, raw, **kwargs): """ This signal is connected by all FieldDefinition subclasses see comment in FieldDefinitionBase for more details """ model_class = instance.model_def.model_class().render_state() field = instance.construct_for_migrate() ...
python
def field_definition_post_save(sender, instance, created, raw, **kwargs): """ This signal is connected by all FieldDefinition subclasses see comment in FieldDefinitionBase for more details """ model_class = instance.model_def.model_class().render_state() field = instance.construct_for_migrate() ...
[ "def", "field_definition_post_save", "(", "sender", ",", "instance", ",", "created", ",", "raw", ",", "*", "*", "kwargs", ")", ":", "model_class", "=", "instance", ".", "model_def", ".", "model_class", "(", ")", ".", "render_state", "(", ")", "field", "=",...
This signal is connected by all FieldDefinition subclasses see comment in FieldDefinitionBase for more details
[ "This", "signal", "is", "connected", "by", "all", "FieldDefinition", "subclasses", "see", "comment", "in", "FieldDefinitionBase", "for", "more", "details" ]
train
https://github.com/charettes/django-mutant/blob/865a1b712ce30501901c4691ce2110ab03f0f93b/mutant/management/__init__.py#L189-L211
charettes/django-mutant
mutant/utils.py
popattr
def popattr(obj, attr, default=NOT_PROVIDED): """ Useful for retrieving an object attr and removing it if it's part of it's dict while allowing retrieving from subclass. i.e. class A: a = 'a' class B(A): b = 'b' >>> popattr(B, 'a', None) 'a' >>> A.a 'a' """ ...
python
def popattr(obj, attr, default=NOT_PROVIDED): """ Useful for retrieving an object attr and removing it if it's part of it's dict while allowing retrieving from subclass. i.e. class A: a = 'a' class B(A): b = 'b' >>> popattr(B, 'a', None) 'a' >>> A.a 'a' """ ...
[ "def", "popattr", "(", "obj", ",", "attr", ",", "default", "=", "NOT_PROVIDED", ")", ":", "val", "=", "getattr", "(", "obj", ",", "attr", ",", "default", ")", "try", ":", "delattr", "(", "obj", ",", "attr", ")", "except", "AttributeError", ":", "if",...
Useful for retrieving an object attr and removing it if it's part of it's dict while allowing retrieving from subclass. i.e. class A: a = 'a' class B(A): b = 'b' >>> popattr(B, 'a', None) 'a' >>> A.a 'a'
[ "Useful", "for", "retrieving", "an", "object", "attr", "and", "removing", "it", "if", "it", "s", "part", "of", "it", "s", "dict", "while", "allowing", "retrieving", "from", "subclass", ".", "i", ".", "e", ".", "class", "A", ":", "a", "=", "a", "class...
train
https://github.com/charettes/django-mutant/blob/865a1b712ce30501901c4691ce2110ab03f0f93b/mutant/utils.py#L27-L47
charettes/django-mutant
mutant/utils.py
_app_cache_deepcopy
def _app_cache_deepcopy(obj): """ An helper that correctly deepcopy model cache state """ if isinstance(obj, defaultdict): return deepcopy(obj) elif isinstance(obj, dict): return type(obj)((_app_cache_deepcopy(key), _app_cache_deepcopy(val)) for key, val in obj.items()) elif isin...
python
def _app_cache_deepcopy(obj): """ An helper that correctly deepcopy model cache state """ if isinstance(obj, defaultdict): return deepcopy(obj) elif isinstance(obj, dict): return type(obj)((_app_cache_deepcopy(key), _app_cache_deepcopy(val)) for key, val in obj.items()) elif isin...
[ "def", "_app_cache_deepcopy", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "defaultdict", ")", ":", "return", "deepcopy", "(", "obj", ")", "elif", "isinstance", "(", "obj", ",", "dict", ")", ":", "return", "type", "(", "obj", ")", "(", ...
An helper that correctly deepcopy model cache state
[ "An", "helper", "that", "correctly", "deepcopy", "model", "cache", "state" ]
train
https://github.com/charettes/django-mutant/blob/865a1b712ce30501901c4691ce2110ab03f0f93b/mutant/utils.py#L139-L154
charettes/django-mutant
mutant/utils.py
app_cache_restorer
def app_cache_restorer(): """ A context manager that restore model cache state as it was before entering context. """ state = _app_cache_deepcopy(apps.__dict__) try: yield state finally: with apps_lock(): apps.__dict__ = state # Rebind the app registry...
python
def app_cache_restorer(): """ A context manager that restore model cache state as it was before entering context. """ state = _app_cache_deepcopy(apps.__dict__) try: yield state finally: with apps_lock(): apps.__dict__ = state # Rebind the app registry...
[ "def", "app_cache_restorer", "(", ")", ":", "state", "=", "_app_cache_deepcopy", "(", "apps", ".", "__dict__", ")", "try", ":", "yield", "state", "finally", ":", "with", "apps_lock", "(", ")", ":", "apps", ".", "__dict__", "=", "state", "# Rebind the app reg...
A context manager that restore model cache state as it was before entering context.
[ "A", "context", "manager", "that", "restore", "model", "cache", "state", "as", "it", "was", "before", "entering", "context", "." ]
train
https://github.com/charettes/django-mutant/blob/865a1b712ce30501901c4691ce2110ab03f0f93b/mutant/utils.py#L158-L173
charettes/django-mutant
mutant/db/deletion.py
CASCADE_MARK_ORIGIN
def CASCADE_MARK_ORIGIN(collector, field, sub_objs, using): """ Custom on_delete handler which sets _cascade_deletion_origin on the _state of the all relating objects that will deleted. We use this handler on ModelDefinitionAttribute.model_def, so when we delete a ModelDefinition we can skip field...
python
def CASCADE_MARK_ORIGIN(collector, field, sub_objs, using): """ Custom on_delete handler which sets _cascade_deletion_origin on the _state of the all relating objects that will deleted. We use this handler on ModelDefinitionAttribute.model_def, so when we delete a ModelDefinition we can skip field...
[ "def", "CASCADE_MARK_ORIGIN", "(", "collector", ",", "field", ",", "sub_objs", ",", "using", ")", ":", "CASCADE", "(", "collector", ",", "field", ",", "sub_objs", ",", "using", ")", "if", "sub_objs", ":", "for", "obj", "in", "sub_objs", ":", "obj", ".", ...
Custom on_delete handler which sets _cascade_deletion_origin on the _state of the all relating objects that will deleted. We use this handler on ModelDefinitionAttribute.model_def, so when we delete a ModelDefinition we can skip field_definition_post_delete and base_definition_post_delete and avoid an...
[ "Custom", "on_delete", "handler", "which", "sets", "_cascade_deletion_origin", "on", "the", "_state", "of", "the", "all", "relating", "objects", "that", "will", "deleted", ".", "We", "use", "this", "handler", "on", "ModelDefinitionAttribute", ".", "model_def", "so...
train
https://github.com/charettes/django-mutant/blob/865a1b712ce30501901c4691ce2110ab03f0f93b/mutant/db/deletion.py#L6-L18
charettes/django-mutant
mutant/contrib/related/management/__init__.py
mutable_model_prepared
def mutable_model_prepared(signal, sender, definition, existing_model_class, **kwargs): """ Make sure all related model class are created and marked as dependency when a mutable model class is prepared """ referenced_models = set() # Collect all model class the obsolet...
python
def mutable_model_prepared(signal, sender, definition, existing_model_class, **kwargs): """ Make sure all related model class are created and marked as dependency when a mutable model class is prepared """ referenced_models = set() # Collect all model class the obsolet...
[ "def", "mutable_model_prepared", "(", "signal", ",", "sender", ",", "definition", ",", "existing_model_class", ",", "*", "*", "kwargs", ")", ":", "referenced_models", "=", "set", "(", ")", "# Collect all model class the obsolete model class was referring to", "if", "exi...
Make sure all related model class are created and marked as dependency when a mutable model class is prepared
[ "Make", "sure", "all", "related", "model", "class", "are", "created", "and", "marked", "as", "dependency", "when", "a", "mutable", "model", "class", "is", "prepared" ]
train
https://github.com/charettes/django-mutant/blob/865a1b712ce30501901c4691ce2110ab03f0f93b/mutant/contrib/related/management/__init__.py#L13-L47
charettes/django-mutant
mutant/models/model/__init__.py
_model_class_from_pk
def _model_class_from_pk(definition_cls, definition_pk): """ Helper used to unpickle MutableModel model class from their definition pk. """ try: return definition_cls.objects.get(pk=definition_pk).model_class() except definition_cls.DoesNotExist: pass
python
def _model_class_from_pk(definition_cls, definition_pk): """ Helper used to unpickle MutableModel model class from their definition pk. """ try: return definition_cls.objects.get(pk=definition_pk).model_class() except definition_cls.DoesNotExist: pass
[ "def", "_model_class_from_pk", "(", "definition_cls", ",", "definition_pk", ")", ":", "try", ":", "return", "definition_cls", ".", "objects", ".", "get", "(", "pk", "=", "definition_pk", ")", ".", "model_class", "(", ")", "except", "definition_cls", ".", "Does...
Helper used to unpickle MutableModel model class from their definition pk.
[ "Helper", "used", "to", "unpickle", "MutableModel", "model", "class", "from", "their", "definition", "pk", "." ]
train
https://github.com/charettes/django-mutant/blob/865a1b712ce30501901c4691ce2110ab03f0f93b/mutant/models/model/__init__.py#L30-L38
charettes/django-mutant
mutant/models/model/__init__.py
OrderingFieldDefinition.clean
def clean(self): """ Make sure the lookup makes sense """ if self.lookup == '?': # Randomly sort return else: lookups = self.lookup.split(LOOKUP_SEP) opts = self.model_def.model_class()._meta valid = True while len(look...
python
def clean(self): """ Make sure the lookup makes sense """ if self.lookup == '?': # Randomly sort return else: lookups = self.lookup.split(LOOKUP_SEP) opts = self.model_def.model_class()._meta valid = True while len(look...
[ "def", "clean", "(", "self", ")", ":", "if", "self", ".", "lookup", "==", "'?'", ":", "# Randomly sort", "return", "else", ":", "lookups", "=", "self", ".", "lookup", ".", "split", "(", "LOOKUP_SEP", ")", "opts", "=", "self", ".", "model_def", ".", "...
Make sure the lookup makes sense
[ "Make", "sure", "the", "lookup", "makes", "sense" ]
train
https://github.com/charettes/django-mutant/blob/865a1b712ce30501901c4691ce2110ab03f0f93b/mutant/models/model/__init__.py#L436-L460
jakevdp/JSAnimation
make_lorenz_animation.py
lorentz_deriv
def lorentz_deriv((x, y, z), t0, sigma=10., beta=8./3, rho=28.0): """Compute the time-derivative of a Lorentz system.""" return [sigma * (y - x), x * (rho - z) - y, x * y - beta * z]
python
def lorentz_deriv((x, y, z), t0, sigma=10., beta=8./3, rho=28.0): """Compute the time-derivative of a Lorentz system.""" return [sigma * (y - x), x * (rho - z) - y, x * y - beta * z]
[ "def", "lorentz_deriv", "(", "(", "x", ",", "y", ",", "z", ")", ",", "t0", ",", "sigma", "=", "10.", ",", "beta", "=", "8.", "/", "3", ",", "rho", "=", "28.0", ")", ":", "return", "[", "sigma", "*", "(", "y", "-", "x", ")", ",", "x", "*",...
Compute the time-derivative of a Lorentz system.
[ "Compute", "the", "time", "-", "derivative", "of", "a", "Lorentz", "system", "." ]
train
https://github.com/jakevdp/JSAnimation/blob/d290db11ebb5427769b76fc532f2d10c4ea3391f/make_lorenz_animation.py#L20-L22
aktaylor08/RosbagPandas
scripts/bag_graph.py
buildParser
def buildParser(): ''' Builds the parser for reading the command line arguments''' parser = argparse.ArgumentParser(description='Bagfile reader') parser.add_argument('-b', '--bag', help='Bag file to read', required=True, type=str) parser.add_argument('-s', '--series', ...
python
def buildParser(): ''' Builds the parser for reading the command line arguments''' parser = argparse.ArgumentParser(description='Bagfile reader') parser.add_argument('-b', '--bag', help='Bag file to read', required=True, type=str) parser.add_argument('-s', '--series', ...
[ "def", "buildParser", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Bagfile reader'", ")", "parser", ".", "add_argument", "(", "'-b'", ",", "'--bag'", ",", "help", "=", "'Bag file to read'", ",", "required", "=", ...
Builds the parser for reading the command line arguments
[ "Builds", "the", "parser", "for", "reading", "the", "command", "line", "arguments" ]
train
https://github.com/aktaylor08/RosbagPandas/blob/c2af9f22537102696dffdf2e61790362726a8403/scripts/bag_graph.py#L10-L24
aktaylor08/RosbagPandas
scripts/bag_graph.py
parse_series_args
def parse_series_args(topics, fields): '''Return which topics and which field keys need to be examined for plotting''' keys = {} for field in fields: for topic in topics: if field.startswith(topic): keys[field] = (topic, field[len(topic) + 1:]) return keys
python
def parse_series_args(topics, fields): '''Return which topics and which field keys need to be examined for plotting''' keys = {} for field in fields: for topic in topics: if field.startswith(topic): keys[field] = (topic, field[len(topic) + 1:]) return keys
[ "def", "parse_series_args", "(", "topics", ",", "fields", ")", ":", "keys", "=", "{", "}", "for", "field", "in", "fields", ":", "for", "topic", "in", "topics", ":", "if", "field", ".", "startswith", "(", "topic", ")", ":", "keys", "[", "field", "]", ...
Return which topics and which field keys need to be examined for plotting
[ "Return", "which", "topics", "and", "which", "field", "keys", "need", "to", "be", "examined", "for", "plotting" ]
train
https://github.com/aktaylor08/RosbagPandas/blob/c2af9f22537102696dffdf2e61790362726a8403/scripts/bag_graph.py#L27-L36
aktaylor08/RosbagPandas
src/rosbag_pandas/rosbag_pandas.py
bag_to_dataframe
def bag_to_dataframe(bag_name, include=None, exclude=None, parse_header=False, seconds=False): ''' Read in a rosbag file and create a pandas data frame that is indexed by the time the message was recorded in the bag. :bag_name: String name for the bag file :include: None, String, or List Topics to...
python
def bag_to_dataframe(bag_name, include=None, exclude=None, parse_header=False, seconds=False): ''' Read in a rosbag file and create a pandas data frame that is indexed by the time the message was recorded in the bag. :bag_name: String name for the bag file :include: None, String, or List Topics to...
[ "def", "bag_to_dataframe", "(", "bag_name", ",", "include", "=", "None", ",", "exclude", "=", "None", ",", "parse_header", "=", "False", ",", "seconds", "=", "False", ")", ":", "# get list of topics to parse", "yaml_info", "=", "get_bag_info", "(", "bag_name", ...
Read in a rosbag file and create a pandas data frame that is indexed by the time the message was recorded in the bag. :bag_name: String name for the bag file :include: None, String, or List Topics to include in the dataframe if None all topics added, if string it is used as regular ...
[ "Read", "in", "a", "rosbag", "file", "and", "create", "a", "pandas", "data", "frame", "that", "is", "indexed", "by", "the", "time", "the", "message", "was", "recorded", "in", "the", "bag", "." ]
train
https://github.com/aktaylor08/RosbagPandas/blob/c2af9f22537102696dffdf2e61790362726a8403/src/rosbag_pandas/rosbag_pandas.py#L15-L98
aktaylor08/RosbagPandas
src/rosbag_pandas/rosbag_pandas.py
get_length
def get_length(topics, yaml_info): ''' Find the length (# of rows) in the created dataframe ''' total = 0 info = yaml_info['topics'] for topic in topics: for t in info: if t['topic'] == topic: total = total + t['messages'] break return tota...
python
def get_length(topics, yaml_info): ''' Find the length (# of rows) in the created dataframe ''' total = 0 info = yaml_info['topics'] for topic in topics: for t in info: if t['topic'] == topic: total = total + t['messages'] break return tota...
[ "def", "get_length", "(", "topics", ",", "yaml_info", ")", ":", "total", "=", "0", "info", "=", "yaml_info", "[", "'topics'", "]", "for", "topic", "in", "topics", ":", "for", "t", "in", "info", ":", "if", "t", "[", "'topic'", "]", "==", "topic", ":...
Find the length (# of rows) in the created dataframe
[ "Find", "the", "length", "(", "#", "of", "rows", ")", "in", "the", "created", "dataframe" ]
train
https://github.com/aktaylor08/RosbagPandas/blob/c2af9f22537102696dffdf2e61790362726a8403/src/rosbag_pandas/rosbag_pandas.py#L101-L112
aktaylor08/RosbagPandas
src/rosbag_pandas/rosbag_pandas.py
create_data_map
def create_data_map(msgs_to_read): ''' Create a data map for usage when parsing the bag ''' dmap = {} for topic in msgs_to_read.keys(): base_name = get_key_name(topic) + '__' fields = {} for f in msgs_to_read[topic]: key = (base_name + f).replace('.', '_') ...
python
def create_data_map(msgs_to_read): ''' Create a data map for usage when parsing the bag ''' dmap = {} for topic in msgs_to_read.keys(): base_name = get_key_name(topic) + '__' fields = {} for f in msgs_to_read[topic]: key = (base_name + f).replace('.', '_') ...
[ "def", "create_data_map", "(", "msgs_to_read", ")", ":", "dmap", "=", "{", "}", "for", "topic", "in", "msgs_to_read", ".", "keys", "(", ")", ":", "base_name", "=", "get_key_name", "(", "topic", ")", "+", "'__'", "fields", "=", "{", "}", "for", "f", "...
Create a data map for usage when parsing the bag
[ "Create", "a", "data", "map", "for", "usage", "when", "parsing", "the", "bag" ]
train
https://github.com/aktaylor08/RosbagPandas/blob/c2af9f22537102696dffdf2e61790362726a8403/src/rosbag_pandas/rosbag_pandas.py#L115-L127
aktaylor08/RosbagPandas
src/rosbag_pandas/rosbag_pandas.py
prune_topics
def prune_topics(bag_topics, include, exclude): '''prune the topics. If include is None add all to the set of topics to use if include is a string regex match that string, if it is a list use the list If exclude is None do nothing, if string remove the topics with regex, if it is a l...
python
def prune_topics(bag_topics, include, exclude): '''prune the topics. If include is None add all to the set of topics to use if include is a string regex match that string, if it is a list use the list If exclude is None do nothing, if string remove the topics with regex, if it is a l...
[ "def", "prune_topics", "(", "bag_topics", ",", "include", ",", "exclude", ")", ":", "topics_to_use", "=", "set", "(", ")", "# add all of the topics", "if", "include", "is", "None", ":", "for", "t", "in", "bag_topics", ":", "topics_to_use", ".", "add", "(", ...
prune the topics. If include is None add all to the set of topics to use if include is a string regex match that string, if it is a list use the list If exclude is None do nothing, if string remove the topics with regex, if it is a list remove those topics
[ "prune", "the", "topics", ".", "If", "include", "is", "None", "add", "all", "to", "the", "set", "of", "topics", "to", "use", "if", "include", "is", "a", "string", "regex", "match", "that", "string", "if", "it", "is", "a", "list", "use", "the", "list"...
train
https://github.com/aktaylor08/RosbagPandas/blob/c2af9f22537102696dffdf2e61790362726a8403/src/rosbag_pandas/rosbag_pandas.py#L130-L177
aktaylor08/RosbagPandas
src/rosbag_pandas/rosbag_pandas.py
get_msg_info
def get_msg_info(yaml_info, topics, parse_header=True): ''' Get info from all of the messages about what they contain and will be added to the dataframe ''' topic_info = yaml_info['topics'] msgs = {} classes = {} for topic in topics: base_key = get_key_name(topic) msg_pa...
python
def get_msg_info(yaml_info, topics, parse_header=True): ''' Get info from all of the messages about what they contain and will be added to the dataframe ''' topic_info = yaml_info['topics'] msgs = {} classes = {} for topic in topics: base_key = get_key_name(topic) msg_pa...
[ "def", "get_msg_info", "(", "yaml_info", ",", "topics", ",", "parse_header", "=", "True", ")", ":", "topic_info", "=", "yaml_info", "[", "'topics'", "]", "msgs", "=", "{", "}", "classes", "=", "{", "}", "for", "topic", "in", "topics", ":", "base_key", ...
Get info from all of the messages about what they contain and will be added to the dataframe
[ "Get", "info", "from", "all", "of", "the", "messages", "about", "what", "they", "contain", "and", "will", "be", "added", "to", "the", "dataframe" ]
train
https://github.com/aktaylor08/RosbagPandas/blob/c2af9f22537102696dffdf2e61790362726a8403/src/rosbag_pandas/rosbag_pandas.py#L180-L204
aktaylor08/RosbagPandas
src/rosbag_pandas/rosbag_pandas.py
get_bag_info
def get_bag_info(bag_file): '''Get uamle dict of the bag information by calling the subprocess -- used to create correct sized arrays''' # Get the info on the bag bag_info = yaml.load(subprocess.Popen( ['rosbag', 'info', '--yaml', bag_file], stdout=subprocess.PIPE).communicate()[0]) ...
python
def get_bag_info(bag_file): '''Get uamle dict of the bag information by calling the subprocess -- used to create correct sized arrays''' # Get the info on the bag bag_info = yaml.load(subprocess.Popen( ['rosbag', 'info', '--yaml', bag_file], stdout=subprocess.PIPE).communicate()[0]) ...
[ "def", "get_bag_info", "(", "bag_file", ")", ":", "# Get the info on the bag", "bag_info", "=", "yaml", ".", "load", "(", "subprocess", ".", "Popen", "(", "[", "'rosbag'", ",", "'info'", ",", "'--yaml'", ",", "bag_file", "]", ",", "stdout", "=", "subprocess"...
Get uamle dict of the bag information by calling the subprocess -- used to create correct sized arrays
[ "Get", "uamle", "dict", "of", "the", "bag", "information", "by", "calling", "the", "subprocess", "--", "used", "to", "create", "correct", "sized", "arrays" ]
train
https://github.com/aktaylor08/RosbagPandas/blob/c2af9f22537102696dffdf2e61790362726a8403/src/rosbag_pandas/rosbag_pandas.py#L207-L215
aktaylor08/RosbagPandas
src/rosbag_pandas/rosbag_pandas.py
get_topics
def get_topics(yaml_info): ''' Returns the names of all of the topics in the bag, and prints them to stdout if requested ''' # Pull out the topic info names = [] # Store all of the topics in a dictionary topics = yaml_info['topics'] for topic in topics: names.append(topic['to...
python
def get_topics(yaml_info): ''' Returns the names of all of the topics in the bag, and prints them to stdout if requested ''' # Pull out the topic info names = [] # Store all of the topics in a dictionary topics = yaml_info['topics'] for topic in topics: names.append(topic['to...
[ "def", "get_topics", "(", "yaml_info", ")", ":", "# Pull out the topic info", "names", "=", "[", "]", "# Store all of the topics in a dictionary", "topics", "=", "yaml_info", "[", "'topics'", "]", "for", "topic", "in", "topics", ":", "names", ".", "append", "(", ...
Returns the names of all of the topics in the bag, and prints them to stdout if requested
[ "Returns", "the", "names", "of", "all", "of", "the", "topics", "in", "the", "bag", "and", "prints", "them", "to", "stdout", "if", "requested" ]
train
https://github.com/aktaylor08/RosbagPandas/blob/c2af9f22537102696dffdf2e61790362726a8403/src/rosbag_pandas/rosbag_pandas.py#L218-L229
aktaylor08/RosbagPandas
src/rosbag_pandas/rosbag_pandas.py
get_base_fields
def get_base_fields(msg, prefix='', parse_header=True): '''function to get the full names of every message field in the message''' slots = msg.__slots__ ret_val = [] msg_types = dict() for i in slots: slot_msg = getattr(msg, i) if not parse_header and i == 'header': conti...
python
def get_base_fields(msg, prefix='', parse_header=True): '''function to get the full names of every message field in the message''' slots = msg.__slots__ ret_val = [] msg_types = dict() for i in slots: slot_msg = getattr(msg, i) if not parse_header and i == 'header': conti...
[ "def", "get_base_fields", "(", "msg", ",", "prefix", "=", "''", ",", "parse_header", "=", "True", ")", ":", "slots", "=", "msg", ".", "__slots__", "ret_val", "=", "[", "]", "msg_types", "=", "dict", "(", ")", "for", "i", "in", "slots", ":", "slot_msg...
function to get the full names of every message field in the message
[ "function", "to", "get", "the", "full", "names", "of", "every", "message", "field", "in", "the", "message" ]
train
https://github.com/aktaylor08/RosbagPandas/blob/c2af9f22537102696dffdf2e61790362726a8403/src/rosbag_pandas/rosbag_pandas.py#L232-L254
aktaylor08/RosbagPandas
src/rosbag_pandas/rosbag_pandas.py
get_message_data
def get_message_data(msg, key): '''get the datapoint from the dot delimited message field key e.g. translation.x looks up translation than x and returns the value found in x''' data = msg paths = key.split('.') for i in paths: data = getattr(data, i) return data
python
def get_message_data(msg, key): '''get the datapoint from the dot delimited message field key e.g. translation.x looks up translation than x and returns the value found in x''' data = msg paths = key.split('.') for i in paths: data = getattr(data, i) return data
[ "def", "get_message_data", "(", "msg", ",", "key", ")", ":", "data", "=", "msg", "paths", "=", "key", ".", "split", "(", "'.'", ")", "for", "i", "in", "paths", ":", "data", "=", "getattr", "(", "data", ",", "i", ")", "return", "data" ]
get the datapoint from the dot delimited message field key e.g. translation.x looks up translation than x and returns the value found in x
[ "get", "the", "datapoint", "from", "the", "dot", "delimited", "message", "field", "key", "e", ".", "g", ".", "translation", ".", "x", "looks", "up", "translation", "than", "x", "and", "returns", "the", "value", "found", "in", "x" ]
train
https://github.com/aktaylor08/RosbagPandas/blob/c2af9f22537102696dffdf2e61790362726a8403/src/rosbag_pandas/rosbag_pandas.py#L257-L265
aktaylor08/RosbagPandas
scripts/bag2csv.py
buildParser
def buildParser(): ''' Builds the parser for reading the command line arguments''' parser = argparse.ArgumentParser( description='Script to parse bagfile to csv file') parser.add_argument('bag', help='Bag file to read', type=str) parser.add_argument('-i', '--include', ...
python
def buildParser(): ''' Builds the parser for reading the command line arguments''' parser = argparse.ArgumentParser( description='Script to parse bagfile to csv file') parser.add_argument('bag', help='Bag file to read', type=str) parser.add_argument('-i', '--include', ...
[ "def", "buildParser", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Script to parse bagfile to csv file'", ")", "parser", ".", "add_argument", "(", "'bag'", ",", "help", "=", "'Bag file to read'", ",", "type", "=", "...
Builds the parser for reading the command line arguments
[ "Builds", "the", "parser", "for", "reading", "the", "command", "line", "arguments" ]
train
https://github.com/aktaylor08/RosbagPandas/blob/c2af9f22537102696dffdf2e61790362726a8403/scripts/bag2csv.py#L11-L32
pydanny/webhooks
webhooks/senders/base.py
Senderable.jsonify_payload
def jsonify_payload(self): """ Dump the payload to JSON """ # Assume already json serialized if isinstance(self.payload, string_types): return self.payload return json.dumps(self.payload, cls=StandardJSONEncoder)
python
def jsonify_payload(self): """ Dump the payload to JSON """ # Assume already json serialized if isinstance(self.payload, string_types): return self.payload return json.dumps(self.payload, cls=StandardJSONEncoder)
[ "def", "jsonify_payload", "(", "self", ")", ":", "# Assume already json serialized", "if", "isinstance", "(", "self", ".", "payload", ",", "string_types", ")", ":", "return", "self", ".", "payload", "return", "json", ".", "dumps", "(", "self", ".", "payload", ...
Dump the payload to JSON
[ "Dump", "the", "payload", "to", "JSON" ]
train
https://github.com/pydanny/webhooks/blob/84aa1c0b8f995308f4f5977270c9a0532abc16cc/webhooks/senders/base.py#L94-L99
pydanny/webhooks
webhooks/senders/base.py
Senderable._send
def _send(self): """ Send the webhook method """ payload = self.payload sending_metadata = {'success': False} post_attributes = {'timeout': self.timeout} if self.custom_headers: post_attributes['headers'] = self.custom_headers if not post_attributes.get('hea...
python
def _send(self): """ Send the webhook method """ payload = self.payload sending_metadata = {'success': False} post_attributes = {'timeout': self.timeout} if self.custom_headers: post_attributes['headers'] = self.custom_headers if not post_attributes.get('hea...
[ "def", "_send", "(", "self", ")", ":", "payload", "=", "self", ".", "payload", "sending_metadata", "=", "{", "'success'", ":", "False", "}", "post_attributes", "=", "{", "'timeout'", ":", "self", ".", "timeout", "}", "if", "self", ".", "custom_headers", ...
Send the webhook method
[ "Send", "the", "webhook", "method" ]
train
https://github.com/pydanny/webhooks/blob/84aa1c0b8f995308f4f5977270c9a0532abc16cc/webhooks/senders/base.py#L114-L196
tgalal/python-axolotl
axolotl/protocol/senderkeymessage.py
SenderKeyMessage.verifySignature
def verifySignature(self, signatureKey): """ :type signatureKey: ECPublicKey """ try: parts = ByteUtil.split(self.serialized, len(self.serialized) - self.__class__.SIGNATURE_LENGTH, self.__class__.SIGNATURE...
python
def verifySignature(self, signatureKey): """ :type signatureKey: ECPublicKey """ try: parts = ByteUtil.split(self.serialized, len(self.serialized) - self.__class__.SIGNATURE_LENGTH, self.__class__.SIGNATURE...
[ "def", "verifySignature", "(", "self", ",", "signatureKey", ")", ":", "try", ":", "parts", "=", "ByteUtil", ".", "split", "(", "self", ".", "serialized", ",", "len", "(", "self", ".", "serialized", ")", "-", "self", ".", "__class__", ".", "SIGNATURE_LENG...
:type signatureKey: ECPublicKey
[ ":", "type", "signatureKey", ":", "ECPublicKey" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/protocol/senderkeymessage.py#L76-L88
tgalal/python-axolotl
axolotl/protocol/senderkeymessage.py
SenderKeyMessage.getSignature
def getSignature(self, signatureKey, serialized): """ :type signatureKey: ECPrivateKey :type serialized: bytearray """ try: return Curve.calculateSignature(signatureKey, serialized) except InvalidKeyException as e: raise AssertionError(e)
python
def getSignature(self, signatureKey, serialized): """ :type signatureKey: ECPrivateKey :type serialized: bytearray """ try: return Curve.calculateSignature(signatureKey, serialized) except InvalidKeyException as e: raise AssertionError(e)
[ "def", "getSignature", "(", "self", ",", "signatureKey", ",", "serialized", ")", ":", "try", ":", "return", "Curve", ".", "calculateSignature", "(", "signatureKey", ",", "serialized", ")", "except", "InvalidKeyException", "as", "e", ":", "raise", "AssertionError...
:type signatureKey: ECPrivateKey :type serialized: bytearray
[ ":", "type", "signatureKey", ":", "ECPrivateKey", ":", "type", "serialized", ":", "bytearray" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/protocol/senderkeymessage.py#L90-L98
tgalal/python-axolotl
axolotl/sessionbuilder.py
SessionBuilder.process
def process(self, sessionRecord, message): """ :param sessionRecord: :param message: :type message: PreKeyWhisperMessage """ messageVersion = message.getMessageVersion() theirIdentityKey = message.getIdentityKey() unsignedPreKeyId = None if not ...
python
def process(self, sessionRecord, message): """ :param sessionRecord: :param message: :type message: PreKeyWhisperMessage """ messageVersion = message.getMessageVersion() theirIdentityKey = message.getIdentityKey() unsignedPreKeyId = None if not ...
[ "def", "process", "(", "self", ",", "sessionRecord", ",", "message", ")", ":", "messageVersion", "=", "message", ".", "getMessageVersion", "(", ")", "theirIdentityKey", "=", "message", ".", "getIdentityKey", "(", ")", "unsignedPreKeyId", "=", "None", "if", "no...
:param sessionRecord: :param message: :type message: PreKeyWhisperMessage
[ ":", "param", "sessionRecord", ":", ":", "param", "message", ":", ":", "type", "message", ":", "PreKeyWhisperMessage" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/sessionbuilder.py#L32-L56
tgalal/python-axolotl
axolotl/sessionbuilder.py
SessionBuilder.processV2
def processV2(self, sessionRecord, message): """ :type sessionRecord: SessionRecord :type message: PreKeyWhisperMessage """ if message.getPreKeyId() is None: raise InvalidKeyIdException("V2 message requires one time prekey id!") if not self.preKeyStore.conta...
python
def processV2(self, sessionRecord, message): """ :type sessionRecord: SessionRecord :type message: PreKeyWhisperMessage """ if message.getPreKeyId() is None: raise InvalidKeyIdException("V2 message requires one time prekey id!") if not self.preKeyStore.conta...
[ "def", "processV2", "(", "self", ",", "sessionRecord", ",", "message", ")", ":", "if", "message", ".", "getPreKeyId", "(", ")", "is", "None", ":", "raise", "InvalidKeyIdException", "(", "\"V2 message requires one time prekey id!\"", ")", "if", "not", "self", "."...
:type sessionRecord: SessionRecord :type message: PreKeyWhisperMessage
[ ":", "type", "sessionRecord", ":", "SessionRecord", ":", "type", "message", ":", "PreKeyWhisperMessage" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/sessionbuilder.py#L58-L98
tgalal/python-axolotl
axolotl/sessionbuilder.py
SessionBuilder.processV3
def processV3(self, sessionRecord, message): """ :param sessionRecord: :param message: :type message: PreKeyWhisperMessage :return: """ if sessionRecord.hasSessionState(message.getMessageVersion(), message.getBaseKey().serialize()): logger.warn("We've...
python
def processV3(self, sessionRecord, message): """ :param sessionRecord: :param message: :type message: PreKeyWhisperMessage :return: """ if sessionRecord.hasSessionState(message.getMessageVersion(), message.getBaseKey().serialize()): logger.warn("We've...
[ "def", "processV3", "(", "self", ",", "sessionRecord", ",", "message", ")", ":", "if", "sessionRecord", ".", "hasSessionState", "(", "message", ".", "getMessageVersion", "(", ")", ",", "message", ".", "getBaseKey", "(", ")", ".", "serialize", "(", ")", ")"...
:param sessionRecord: :param message: :type message: PreKeyWhisperMessage :return:
[ ":", "param", "sessionRecord", ":", ":", "param", "message", ":", ":", "type", "message", ":", "PreKeyWhisperMessage", ":", "return", ":" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/sessionbuilder.py#L100-L138
tgalal/python-axolotl
axolotl/sessionbuilder.py
SessionBuilder.processPreKeyBundle
def processPreKeyBundle(self, preKey): """ :type preKey: PreKeyBundle """ if not self.identityKeyStore.isTrustedIdentity(self.recipientId, preKey.getIdentityKey()): raise UntrustedIdentityException(self.recipientId, preKey.getIdentityKey()) if preKey.getSignedPreKey(...
python
def processPreKeyBundle(self, preKey): """ :type preKey: PreKeyBundle """ if not self.identityKeyStore.isTrustedIdentity(self.recipientId, preKey.getIdentityKey()): raise UntrustedIdentityException(self.recipientId, preKey.getIdentityKey()) if preKey.getSignedPreKey(...
[ "def", "processPreKeyBundle", "(", "self", ",", "preKey", ")", ":", "if", "not", "self", ".", "identityKeyStore", ".", "isTrustedIdentity", "(", "self", ".", "recipientId", ",", "preKey", ".", "getIdentityKey", "(", ")", ")", ":", "raise", "UntrustedIdentityEx...
:type preKey: PreKeyBundle
[ ":", "type", "preKey", ":", "PreKeyBundle" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/sessionbuilder.py#L140-L186
tgalal/python-axolotl
axolotl/groups/groupsessionbuilder.py
GroupSessionBuilder.process
def process(self, senderKeyName, senderKeyDistributionMessage): """ :type senderKeyName: SenderKeyName :type senderKeyDistributionMessage: SenderKeyDistributionMessage """ senderKeyRecord = self.senderKeyStore.loadSenderKey(senderKeyName) senderKeyRecord.addSenderKeyState...
python
def process(self, senderKeyName, senderKeyDistributionMessage): """ :type senderKeyName: SenderKeyName :type senderKeyDistributionMessage: SenderKeyDistributionMessage """ senderKeyRecord = self.senderKeyStore.loadSenderKey(senderKeyName) senderKeyRecord.addSenderKeyState...
[ "def", "process", "(", "self", ",", "senderKeyName", ",", "senderKeyDistributionMessage", ")", ":", "senderKeyRecord", "=", "self", ".", "senderKeyStore", ".", "loadSenderKey", "(", "senderKeyName", ")", "senderKeyRecord", ".", "addSenderKeyState", "(", "senderKeyDist...
:type senderKeyName: SenderKeyName :type senderKeyDistributionMessage: SenderKeyDistributionMessage
[ ":", "type", "senderKeyName", ":", "SenderKeyName", ":", "type", "senderKeyDistributionMessage", ":", "SenderKeyDistributionMessage" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/groups/groupsessionbuilder.py#L10-L20
tgalal/python-axolotl
axolotl/groups/groupsessionbuilder.py
GroupSessionBuilder.create
def create(self, senderKeyName): """ :type senderKeyName: SenderKeyName """ try: senderKeyRecord = self.senderKeyStore.loadSenderKey(senderKeyName); if senderKeyRecord.isEmpty() : senderKeyRecord.setSenderKeyState(KeyHelper.generateSenderKeyId(), ...
python
def create(self, senderKeyName): """ :type senderKeyName: SenderKeyName """ try: senderKeyRecord = self.senderKeyStore.loadSenderKey(senderKeyName); if senderKeyRecord.isEmpty() : senderKeyRecord.setSenderKeyState(KeyHelper.generateSenderKeyId(), ...
[ "def", "create", "(", "self", ",", "senderKeyName", ")", ":", "try", ":", "senderKeyRecord", "=", "self", ".", "senderKeyStore", ".", "loadSenderKey", "(", "senderKeyName", ")", "if", "senderKeyRecord", ".", "isEmpty", "(", ")", ":", "senderKeyRecord", ".", ...
:type senderKeyName: SenderKeyName
[ ":", "type", "senderKeyName", ":", "SenderKeyName" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/groups/groupsessionbuilder.py#L23-L44
tgalal/python-axolotl
axolotl/ratchet/ratchetingsession.py
RatchetingSession.initializeSession
def initializeSession(sessionState, sessionVersion, parameters): """ :type sessionState: SessionState :type sessionVersion: int :type parameters: SymmetricAxolotlParameters """ if RatchetingSession.isAlice(parameters.getOurBaseKey().getPublicKey(), parameters.getTheirBase...
python
def initializeSession(sessionState, sessionVersion, parameters): """ :type sessionState: SessionState :type sessionVersion: int :type parameters: SymmetricAxolotlParameters """ if RatchetingSession.isAlice(parameters.getOurBaseKey().getPublicKey(), parameters.getTheirBase...
[ "def", "initializeSession", "(", "sessionState", ",", "sessionVersion", ",", "parameters", ")", ":", "if", "RatchetingSession", ".", "isAlice", "(", "parameters", ".", "getOurBaseKey", "(", ")", ".", "getPublicKey", "(", ")", ",", "parameters", ".", "getTheirBas...
:type sessionState: SessionState :type sessionVersion: int :type parameters: SymmetricAxolotlParameters
[ ":", "type", "sessionState", ":", "SessionState", ":", "type", "sessionVersion", ":", "int", ":", "type", "parameters", ":", "SymmetricAxolotlParameters" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/ratchet/ratchetingsession.py#L14-L37
tgalal/python-axolotl
axolotl/ratchet/ratchetingsession.py
RatchetingSession.initializeSessionAsAlice
def initializeSessionAsAlice(sessionState, sessionVersion, parameters): """ :type sessionState: SessionState :type sessionVersion: int :type parameters: AliceAxolotlParameters """ sessionState.setSessionVersion(sessionVersion) sessionState.setRemoteIdentityKey(par...
python
def initializeSessionAsAlice(sessionState, sessionVersion, parameters): """ :type sessionState: SessionState :type sessionVersion: int :type parameters: AliceAxolotlParameters """ sessionState.setSessionVersion(sessionVersion) sessionState.setRemoteIdentityKey(par...
[ "def", "initializeSessionAsAlice", "(", "sessionState", ",", "sessionVersion", ",", "parameters", ")", ":", "sessionState", ".", "setSessionVersion", "(", "sessionVersion", ")", "sessionState", ".", "setRemoteIdentityKey", "(", "parameters", ".", "getTheirIdentityKey", ...
:type sessionState: SessionState :type sessionVersion: int :type parameters: AliceAxolotlParameters
[ ":", "type", "sessionState", ":", "SessionState", ":", "type", "sessionVersion", ":", "int", ":", "type", "parameters", ":", "AliceAxolotlParameters" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/ratchet/ratchetingsession.py#L40-L72
tgalal/python-axolotl
axolotl/ratchet/ratchetingsession.py
RatchetingSession.initializeSessionAsBob
def initializeSessionAsBob(sessionState, sessionVersion, parameters): """ :type sessionState: SessionState :type sessionVersion: int :type parameters: BobAxolotlParameters """ sessionState.setSessionVersion(sessionVersion) sessionState.setRemoteIdentityKey(paramet...
python
def initializeSessionAsBob(sessionState, sessionVersion, parameters): """ :type sessionState: SessionState :type sessionVersion: int :type parameters: BobAxolotlParameters """ sessionState.setSessionVersion(sessionVersion) sessionState.setRemoteIdentityKey(paramet...
[ "def", "initializeSessionAsBob", "(", "sessionState", ",", "sessionVersion", ",", "parameters", ")", ":", "sessionState", ".", "setSessionVersion", "(", "sessionVersion", ")", "sessionState", ".", "setRemoteIdentityKey", "(", "parameters", ".", "getTheirIdentityKey", "(...
:type sessionState: SessionState :type sessionVersion: int :type parameters: BobAxolotlParameters
[ ":", "type", "sessionState", ":", "SessionState", ":", "type", "sessionVersion", ":", "int", ":", "type", "parameters", ":", "BobAxolotlParameters" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/ratchet/ratchetingsession.py#L75-L104
tgalal/python-axolotl
axolotl/groups/state/senderkeyrecord.py
SenderKeyRecord.addSenderKeyState
def addSenderKeyState(self, id, iteration, chainKey, signatureKey): """ :type id: int :type iteration: int :type chainKey: bytearray :type signatureKey: ECPublicKey """ self.senderKeyStates.append(SenderKeyState(id, iteration, chainKey, signatureKey))
python
def addSenderKeyState(self, id, iteration, chainKey, signatureKey): """ :type id: int :type iteration: int :type chainKey: bytearray :type signatureKey: ECPublicKey """ self.senderKeyStates.append(SenderKeyState(id, iteration, chainKey, signatureKey))
[ "def", "addSenderKeyState", "(", "self", ",", "id", ",", "iteration", ",", "chainKey", ",", "signatureKey", ")", ":", "self", ".", "senderKeyStates", ".", "append", "(", "SenderKeyState", "(", "id", ",", "iteration", ",", "chainKey", ",", "signatureKey", ")"...
:type id: int :type iteration: int :type chainKey: bytearray :type signatureKey: ECPublicKey
[ ":", "type", "id", ":", "int", ":", "type", "iteration", ":", "int", ":", "type", "chainKey", ":", "bytearray", ":", "type", "signatureKey", ":", "ECPublicKey" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/groups/state/senderkeyrecord.py#L35-L42
tgalal/python-axolotl
axolotl/groups/state/senderkeyrecord.py
SenderKeyRecord.setSenderKeyState
def setSenderKeyState(self, id, iteration, chainKey, signatureKey): """ :type id: int :type iteration: int :type chainKey: bytearray :type signatureKey: ECKeyPair """ del self.senderKeyStates[:] self.senderKeyStates.append(SenderKeyState(id, iteration, cha...
python
def setSenderKeyState(self, id, iteration, chainKey, signatureKey): """ :type id: int :type iteration: int :type chainKey: bytearray :type signatureKey: ECKeyPair """ del self.senderKeyStates[:] self.senderKeyStates.append(SenderKeyState(id, iteration, cha...
[ "def", "setSenderKeyState", "(", "self", ",", "id", ",", "iteration", ",", "chainKey", ",", "signatureKey", ")", ":", "del", "self", ".", "senderKeyStates", "[", ":", "]", "self", ".", "senderKeyStates", ".", "append", "(", "SenderKeyState", "(", "id", ","...
:type id: int :type iteration: int :type chainKey: bytearray :type signatureKey: ECKeyPair
[ ":", "type", "id", ":", "int", ":", "type", "iteration", ":", "int", ":", "type", "chainKey", ":", "bytearray", ":", "type", "signatureKey", ":", "ECKeyPair" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/groups/state/senderkeyrecord.py#L44-L52
tgalal/python-axolotl
axolotl/sessioncipher.py
SessionCipher.encrypt
def encrypt(self, paddedMessage): """ :type paddedMessage: str """ # TODO: make this less ugly and python 2 and 3 compatible # paddedMessage = bytearray(paddedMessage.encode() if (sys.version_info >= (3, 0) and not type(paddedMessage) in (bytes, bytearray)) or type(paddedMessage)...
python
def encrypt(self, paddedMessage): """ :type paddedMessage: str """ # TODO: make this less ugly and python 2 and 3 compatible # paddedMessage = bytearray(paddedMessage.encode() if (sys.version_info >= (3, 0) and not type(paddedMessage) in (bytes, bytearray)) or type(paddedMessage)...
[ "def", "encrypt", "(", "self", ",", "paddedMessage", ")", ":", "# TODO: make this less ugly and python 2 and 3 compatible", "# paddedMessage = bytearray(paddedMessage.encode() if (sys.version_info >= (3, 0) and not type(paddedMessage) in (bytes, bytearray)) or type(paddedMessage) is unicode else p...
:type paddedMessage: str
[ ":", "type", "paddedMessage", ":", "str" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/sessioncipher.py#L34-L72
tgalal/python-axolotl
axolotl/sessioncipher.py
SessionCipher.decryptMsg
def decryptMsg(self, ciphertext, textMsg=True): """ :type ciphertext: WhisperMessage :type textMsg: Bool set this to False if you are decrypting bytes instead of string """ if not self.sessionStore.containsSession(self.recipientId, self.deviceId): ...
python
def decryptMsg(self, ciphertext, textMsg=True): """ :type ciphertext: WhisperMessage :type textMsg: Bool set this to False if you are decrypting bytes instead of string """ if not self.sessionStore.containsSession(self.recipientId, self.deviceId): ...
[ "def", "decryptMsg", "(", "self", ",", "ciphertext", ",", "textMsg", "=", "True", ")", ":", "if", "not", "self", ".", "sessionStore", ".", "containsSession", "(", "self", ".", "recipientId", ",", "self", ".", "deviceId", ")", ":", "raise", "NoSessionExcept...
:type ciphertext: WhisperMessage :type textMsg: Bool set this to False if you are decrypting bytes instead of string
[ ":", "type", "ciphertext", ":", "WhisperMessage", ":", "type", "textMsg", ":", "Bool", "set", "this", "to", "False", "if", "you", "are", "decrypting", "bytes", "instead", "of", "string" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/sessioncipher.py#L74-L89
tgalal/python-axolotl
axolotl/sessioncipher.py
SessionCipher.decryptPkmsg
def decryptPkmsg(self, ciphertext, textMsg=True): """ :type ciphertext: PreKeyWhisperMessage """ sessionRecord = self.sessionStore.loadSession(self.recipientId, self.deviceId) unsignedPreKeyId = self.sessionBuilder.process(sessionRecord, ciphertext) plaintext = self.decry...
python
def decryptPkmsg(self, ciphertext, textMsg=True): """ :type ciphertext: PreKeyWhisperMessage """ sessionRecord = self.sessionStore.loadSession(self.recipientId, self.deviceId) unsignedPreKeyId = self.sessionBuilder.process(sessionRecord, ciphertext) plaintext = self.decry...
[ "def", "decryptPkmsg", "(", "self", ",", "ciphertext", ",", "textMsg", "=", "True", ")", ":", "sessionRecord", "=", "self", ".", "sessionStore", ".", "loadSession", "(", "self", ".", "recipientId", ",", "self", ".", "deviceId", ")", "unsignedPreKeyId", "=", ...
:type ciphertext: PreKeyWhisperMessage
[ ":", "type", "ciphertext", ":", "PreKeyWhisperMessage" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/sessioncipher.py#L91-L105
tgalal/python-axolotl
axolotl/sessioncipher.py
SessionCipher.decryptWithSessionRecord
def decryptWithSessionRecord(self, sessionRecord, cipherText): """ :type sessionRecord: SessionRecord :type cipherText: WhisperMessage """ previousStates = sessionRecord.getPreviousSessionStates() exceptions = [] try: sessionState = SessionState(sessi...
python
def decryptWithSessionRecord(self, sessionRecord, cipherText): """ :type sessionRecord: SessionRecord :type cipherText: WhisperMessage """ previousStates = sessionRecord.getPreviousSessionStates() exceptions = [] try: sessionState = SessionState(sessi...
[ "def", "decryptWithSessionRecord", "(", "self", ",", "sessionRecord", ",", "cipherText", ")", ":", "previousStates", "=", "sessionRecord", ".", "getPreviousSessionStates", "(", ")", "exceptions", "=", "[", "]", "try", ":", "sessionState", "=", "SessionState", "(",...
:type sessionRecord: SessionRecord :type cipherText: WhisperMessage
[ ":", "type", "sessionRecord", ":", "SessionRecord", ":", "type", "cipherText", ":", "WhisperMessage" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/sessioncipher.py#L107-L134
tgalal/python-axolotl
axolotl/sessioncipher.py
SessionCipher.getCiphertext
def getCiphertext(self, version, messageKeys, plainText): """ :type version: int :type messageKeys: MessageKeys :type plainText: bytearray """ cipher = None if version >= 3: cipher = self.getCipher(messageKeys.getCipherKey(), messageKeys.getIv()) ...
python
def getCiphertext(self, version, messageKeys, plainText): """ :type version: int :type messageKeys: MessageKeys :type plainText: bytearray """ cipher = None if version >= 3: cipher = self.getCipher(messageKeys.getCipherKey(), messageKeys.getIv()) ...
[ "def", "getCiphertext", "(", "self", ",", "version", ",", "messageKeys", ",", "plainText", ")", ":", "cipher", "=", "None", "if", "version", ">=", "3", ":", "cipher", "=", "self", ".", "getCipher", "(", "messageKeys", ".", "getCipherKey", "(", ")", ",", ...
:type version: int :type messageKeys: MessageKeys :type plainText: bytearray
[ ":", "type", "version", ":", "int", ":", "type", "messageKeys", ":", "MessageKeys", ":", "type", "plainText", ":", "bytearray" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/sessioncipher.py#L197-L209
tgalal/python-axolotl
axolotl/ecc/curve.py
Curve.calculateAgreement
def calculateAgreement(publicKey, privateKey): """ :type publicKey: ECPublicKey :type privateKey: ECPrivateKey """ if publicKey.getType() != privateKey.getType(): raise InvalidKeyException("Public and private keys must be of the same type!") if publicKey.getT...
python
def calculateAgreement(publicKey, privateKey): """ :type publicKey: ECPublicKey :type privateKey: ECPrivateKey """ if publicKey.getType() != privateKey.getType(): raise InvalidKeyException("Public and private keys must be of the same type!") if publicKey.getT...
[ "def", "calculateAgreement", "(", "publicKey", ",", "privateKey", ")", ":", "if", "publicKey", ".", "getType", "(", ")", "!=", "privateKey", ".", "getType", "(", ")", ":", "raise", "InvalidKeyException", "(", "\"Public and private keys must be of the same type!\"", ...
:type publicKey: ECPublicKey :type privateKey: ECPrivateKey
[ ":", "type", "publicKey", ":", "ECPublicKey", ":", "type", "privateKey", ":", "ECPrivateKey" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/ecc/curve.py#L53-L64
tgalal/python-axolotl
axolotl/ecc/curve.py
Curve.verifySignature
def verifySignature(ecPublicSigningKey, message, signature): """ :type ecPublicSigningKey: ECPublicKey :type message: bytearray :type signature: bytearray """ if ecPublicSigningKey.getType() == Curve.DJB_TYPE: result = _curve.verifySignature(ecPublicSigningKe...
python
def verifySignature(ecPublicSigningKey, message, signature): """ :type ecPublicSigningKey: ECPublicKey :type message: bytearray :type signature: bytearray """ if ecPublicSigningKey.getType() == Curve.DJB_TYPE: result = _curve.verifySignature(ecPublicSigningKe...
[ "def", "verifySignature", "(", "ecPublicSigningKey", ",", "message", ",", "signature", ")", ":", "if", "ecPublicSigningKey", ".", "getType", "(", ")", "==", "Curve", ".", "DJB_TYPE", ":", "result", "=", "_curve", ".", "verifySignature", "(", "ecPublicSigningKey"...
:type ecPublicSigningKey: ECPublicKey :type message: bytearray :type signature: bytearray
[ ":", "type", "ecPublicSigningKey", ":", "ECPublicKey", ":", "type", "message", ":", "bytearray", ":", "type", "signature", ":", "bytearray" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/ecc/curve.py#L67-L78
tgalal/python-axolotl
axolotl/ecc/curve.py
Curve.calculateSignature
def calculateSignature(privateSigningKey, message): """ :type privateSigningKey: ECPrivateKey :type message: bytearray """ if privateSigningKey.getType() == Curve.DJB_TYPE: rand = os.urandom(64) res = _curve.calculateSignature(rand, privateSigningKey.getP...
python
def calculateSignature(privateSigningKey, message): """ :type privateSigningKey: ECPrivateKey :type message: bytearray """ if privateSigningKey.getType() == Curve.DJB_TYPE: rand = os.urandom(64) res = _curve.calculateSignature(rand, privateSigningKey.getP...
[ "def", "calculateSignature", "(", "privateSigningKey", ",", "message", ")", ":", "if", "privateSigningKey", ".", "getType", "(", ")", "==", "Curve", ".", "DJB_TYPE", ":", "rand", "=", "os", ".", "urandom", "(", "64", ")", "res", "=", "_curve", ".", "calc...
:type privateSigningKey: ECPrivateKey :type message: bytearray
[ ":", "type", "privateSigningKey", ":", "ECPrivateKey", ":", "type", "message", ":", "bytearray" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/ecc/curve.py#L81-L91
tgalal/python-axolotl
axolotl/groups/groupcipher.py
GroupCipher.encrypt
def encrypt(self, paddedPlaintext): """ :type paddedPlaintext: str """ # TODO: make this less ugly and python 2 and 3 compatible # paddedMessage = bytearray(paddedMessage.encode() if (sys.version_info >= (3, 0) and not type(paddedMessage) in (bytes, bytearray)) or type(paddedMess...
python
def encrypt(self, paddedPlaintext): """ :type paddedPlaintext: str """ # TODO: make this less ugly and python 2 and 3 compatible # paddedMessage = bytearray(paddedMessage.encode() if (sys.version_info >= (3, 0) and not type(paddedMessage) in (bytes, bytearray)) or type(paddedMess...
[ "def", "encrypt", "(", "self", ",", "paddedPlaintext", ")", ":", "# TODO: make this less ugly and python 2 and 3 compatible", "# paddedMessage = bytearray(paddedMessage.encode() if (sys.version_info >= (3, 0) and not type(paddedMessage) in (bytes, bytearray)) or type(paddedMessage) is unicode else...
:type paddedPlaintext: str
[ ":", "type", "paddedPlaintext", ":", "str" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/groups/groupcipher.py#L23-L50
tgalal/python-axolotl
axolotl/groups/groupcipher.py
GroupCipher.decrypt
def decrypt(self, senderKeyMessageBytes): """ :type senderKeyMessageBytes: bytearray """ try: record = self.senderKeyStore.loadSenderKey(self.senderKeyName) if record.isEmpty(): raise NoSessionException("No sender key for: %s" % self.senderKeyName)...
python
def decrypt(self, senderKeyMessageBytes): """ :type senderKeyMessageBytes: bytearray """ try: record = self.senderKeyStore.loadSenderKey(self.senderKeyName) if record.isEmpty(): raise NoSessionException("No sender key for: %s" % self.senderKeyName)...
[ "def", "decrypt", "(", "self", ",", "senderKeyMessageBytes", ")", ":", "try", ":", "record", "=", "self", ".", "senderKeyStore", ".", "loadSenderKey", "(", "self", ".", "senderKeyName", ")", "if", "record", ".", "isEmpty", "(", ")", ":", "raise", "NoSessio...
:type senderKeyMessageBytes: bytearray
[ ":", "type", "senderKeyMessageBytes", ":", "bytearray" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/groups/groupcipher.py#L52-L73
tgalal/python-axolotl
axolotl/groups/groupcipher.py
GroupCipher.getPlainText
def getPlainText(self, iv, key, ciphertext): """ :type iv: bytearray :type key: bytearray :type ciphertext: bytearray """ try: cipher = AESCipher(key, iv) plaintext = cipher.decrypt(ciphertext) if sys.version_info >= (3, 0): ...
python
def getPlainText(self, iv, key, ciphertext): """ :type iv: bytearray :type key: bytearray :type ciphertext: bytearray """ try: cipher = AESCipher(key, iv) plaintext = cipher.decrypt(ciphertext) if sys.version_info >= (3, 0): ...
[ "def", "getPlainText", "(", "self", ",", "iv", ",", "key", ",", "ciphertext", ")", ":", "try", ":", "cipher", "=", "AESCipher", "(", "key", ",", "iv", ")", "plaintext", "=", "cipher", ".", "decrypt", "(", "ciphertext", ")", "if", "sys", ".", "version...
:type iv: bytearray :type key: bytearray :type ciphertext: bytearray
[ ":", "type", "iv", ":", "bytearray", ":", "type", "key", ":", "bytearray", ":", "type", "ciphertext", ":", "bytearray" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/groups/groupcipher.py#L95-L108
tgalal/python-axolotl
axolotl/groups/groupcipher.py
GroupCipher.getCipherText
def getCipherText(self, iv, key, plaintext): """ :type iv: bytearray :type key: bytearray :type plaintext: bytearray """ cipher = AESCipher(key, iv) return cipher.encrypt(bytes(plaintext))
python
def getCipherText(self, iv, key, plaintext): """ :type iv: bytearray :type key: bytearray :type plaintext: bytearray """ cipher = AESCipher(key, iv) return cipher.encrypt(bytes(plaintext))
[ "def", "getCipherText", "(", "self", ",", "iv", ",", "key", ",", "plaintext", ")", ":", "cipher", "=", "AESCipher", "(", "key", ",", "iv", ")", "return", "cipher", ".", "encrypt", "(", "bytes", "(", "plaintext", ")", ")" ]
:type iv: bytearray :type key: bytearray :type plaintext: bytearray
[ ":", "type", "iv", ":", "bytearray", ":", "type", "key", ":", "bytearray", ":", "type", "plaintext", ":", "bytearray" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/groups/groupcipher.py#L110-L117
tgalal/python-axolotl
axolotl/state/sessionstate.py
SessionState.setPendingKeyExchange
def setPendingKeyExchange(self, sequence, ourBaseKey, ourRatchetKey, ourIdentityKey): """ :type sequence: int :type ourBaseKey: ECKeyPair :type ourRatchetKey: ECKeyPair :type ourIdentityKey: IdentityKeyPair """ structure = self.sessionStructure.PendingKeyExchange...
python
def setPendingKeyExchange(self, sequence, ourBaseKey, ourRatchetKey, ourIdentityKey): """ :type sequence: int :type ourBaseKey: ECKeyPair :type ourRatchetKey: ECKeyPair :type ourIdentityKey: IdentityKeyPair """ structure = self.sessionStructure.PendingKeyExchange...
[ "def", "setPendingKeyExchange", "(", "self", ",", "sequence", ",", "ourBaseKey", ",", "ourRatchetKey", ",", "ourIdentityKey", ")", ":", "structure", "=", "self", ".", "sessionStructure", ".", "PendingKeyExchange", "(", ")", "structure", ".", "sequence", "=", "se...
:type sequence: int :type ourBaseKey: ECKeyPair :type ourRatchetKey: ECKeyPair :type ourIdentityKey: IdentityKeyPair
[ ":", "type", "sequence", ":", "int", ":", "type", "ourBaseKey", ":", "ECKeyPair", ":", "type", "ourRatchetKey", ":", "ECKeyPair", ":", "type", "ourIdentityKey", ":", "IdentityKeyPair" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/state/sessionstate.py#L194-L210
tgalal/python-axolotl
axolotl/state/sessionstate.py
SessionState.setUnacknowledgedPreKeyMessage
def setUnacknowledgedPreKeyMessage(self, preKeyId, signedPreKeyId, baseKey): """ :type preKeyId: int :type signedPreKeyId: int :type baseKey: ECPublicKey """ self.sessionStructure.pendingPreKey.signedPreKeyId = signedPreKeyId self.sessionStructure.pendingPreKey.ba...
python
def setUnacknowledgedPreKeyMessage(self, preKeyId, signedPreKeyId, baseKey): """ :type preKeyId: int :type signedPreKeyId: int :type baseKey: ECPublicKey """ self.sessionStructure.pendingPreKey.signedPreKeyId = signedPreKeyId self.sessionStructure.pendingPreKey.ba...
[ "def", "setUnacknowledgedPreKeyMessage", "(", "self", ",", "preKeyId", ",", "signedPreKeyId", ",", "baseKey", ")", ":", "self", ".", "sessionStructure", ".", "pendingPreKey", ".", "signedPreKeyId", "=", "signedPreKeyId", "self", ".", "sessionStructure", ".", "pendin...
:type preKeyId: int :type signedPreKeyId: int :type baseKey: ECPublicKey
[ ":", "type", "preKeyId", ":", "int", ":", "type", "signedPreKeyId", ":", "int", ":", "type", "baseKey", ":", "ECPublicKey" ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/state/sessionstate.py#L234-L244
tgalal/python-axolotl
axolotl/util/keyhelper.py
KeyHelper.generateIdentityKeyPair
def generateIdentityKeyPair(): """ Generate an identity key pair. Clients should only do this once, at install time. @return the generated IdentityKeyPair. """ keyPair = Curve.generateKeyPair() publicKey = IdentityKey(keyPair.getPublicKey()) serialized = ...
python
def generateIdentityKeyPair(): """ Generate an identity key pair. Clients should only do this once, at install time. @return the generated IdentityKeyPair. """ keyPair = Curve.generateKeyPair() publicKey = IdentityKey(keyPair.getPublicKey()) serialized = ...
[ "def", "generateIdentityKeyPair", "(", ")", ":", "keyPair", "=", "Curve", ".", "generateKeyPair", "(", ")", "publicKey", "=", "IdentityKey", "(", "keyPair", ".", "getPublicKey", "(", ")", ")", "serialized", "=", "'0a21056e8936e8367f768a7bba008ade7cf58407bdc7a6aae293e2...
Generate an identity key pair. Clients should only do this once, at install time. @return the generated IdentityKeyPair.
[ "Generate", "an", "identity", "key", "pair", ".", "Clients", "should", "only", "do", "this", "once", "at", "install", "time", "." ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/util/keyhelper.py#L21-L34
tgalal/python-axolotl
axolotl/util/keyhelper.py
KeyHelper.generatePreKeys
def generatePreKeys(start, count): """ Generate a list of PreKeys. Clients should do this at install time, and subsequently any time the list of PreKeys stored on the server runs low. PreKey IDs are shorts, so they will eventually be repeated. Clients should store PreKeys in a...
python
def generatePreKeys(start, count): """ Generate a list of PreKeys. Clients should do this at install time, and subsequently any time the list of PreKeys stored on the server runs low. PreKey IDs are shorts, so they will eventually be repeated. Clients should store PreKeys in a...
[ "def", "generatePreKeys", "(", "start", ",", "count", ")", ":", "results", "=", "[", "]", "start", "-=", "1", "for", "i", "in", "range", "(", "0", ",", "count", ")", ":", "preKeyId", "=", "(", "(", "start", "+", "i", ")", "%", "(", "Medium", "....
Generate a list of PreKeys. Clients should do this at install time, and subsequently any time the list of PreKeys stored on the server runs low. PreKey IDs are shorts, so they will eventually be repeated. Clients should store PreKeys in a circular buffer, so that they are repeated as infreque...
[ "Generate", "a", "list", "of", "PreKeys", ".", "Clients", "should", "do", "this", "at", "install", "time", "and", "subsequently", "any", "time", "the", "list", "of", "PreKeys", "stored", "on", "the", "server", "runs", "low", "." ]
train
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/util/keyhelper.py#L54-L73
5monkeys/django-enumfield
django_enumfield/enum.py
Enum.choices
def choices(cls, blank=False): """ Choices for Enum :return: List of tuples (<value>, <human-readable value>) :rtype: list """ choices = sorted([(key, value) for key, value in cls.values.items()], key=lambda x: x[0]) if blank: choices.insert(0, ('', Enum.Value...
python
def choices(cls, blank=False): """ Choices for Enum :return: List of tuples (<value>, <human-readable value>) :rtype: list """ choices = sorted([(key, value) for key, value in cls.values.items()], key=lambda x: x[0]) if blank: choices.insert(0, ('', Enum.Value...
[ "def", "choices", "(", "cls", ",", "blank", "=", "False", ")", ":", "choices", "=", "sorted", "(", "[", "(", "key", ",", "value", ")", "for", "key", ",", "value", "in", "cls", ".", "values", ".", "items", "(", ")", "]", ",", "key", "=", "lambda...
Choices for Enum :return: List of tuples (<value>, <human-readable value>) :rtype: list
[ "Choices", "for", "Enum", ":", "return", ":", "List", "of", "tuples", "(", "<value", ">", "<human", "-", "readable", "value", ">", ")", ":", "rtype", ":", "list" ]
train
https://github.com/5monkeys/django-enumfield/blob/6cf20c0fba013d39960af0f4d2c9a3b399955eb3/django_enumfield/enum.py#L69-L77
5monkeys/django-enumfield
django_enumfield/enum.py
Enum.get
def get(cls, name_or_numeric): """ Get Enum.Value object matching the value argument. :param name_or_numeric: Integer value or attribute name :type name_or_numeric: int or str :rtype: Enum.Value """ if isinstance(name_or_numeric, six.string_types): name_or_num...
python
def get(cls, name_or_numeric): """ Get Enum.Value object matching the value argument. :param name_or_numeric: Integer value or attribute name :type name_or_numeric: int or str :rtype: Enum.Value """ if isinstance(name_or_numeric, six.string_types): name_or_num...
[ "def", "get", "(", "cls", ",", "name_or_numeric", ")", ":", "if", "isinstance", "(", "name_or_numeric", ",", "six", ".", "string_types", ")", ":", "name_or_numeric", "=", "getattr", "(", "cls", ",", "name_or_numeric", ".", "upper", "(", ")", ")", "return",...
Get Enum.Value object matching the value argument. :param name_or_numeric: Integer value or attribute name :type name_or_numeric: int or str :rtype: Enum.Value
[ "Get", "Enum", ".", "Value", "object", "matching", "the", "value", "argument", ".", ":", "param", "name_or_numeric", ":", "Integer", "value", "or", "attribute", "name", ":", "type", "name_or_numeric", ":", "int", "or", "str", ":", "rtype", ":", "Enum", "."...
train
https://github.com/5monkeys/django-enumfield/blob/6cf20c0fba013d39960af0f4d2c9a3b399955eb3/django_enumfield/enum.py#L105-L114
5monkeys/django-enumfield
django_enumfield/enum.py
Enum.items
def items(cls): """ :return: List of tuples consisting of every enum value in the form [('NAME', value), ...] :rtype: list """ items = [(value.name, key) for key, value in cls.values.items()] return sorted(items, key=lambda x: x[1])
python
def items(cls): """ :return: List of tuples consisting of every enum value in the form [('NAME', value), ...] :rtype: list """ items = [(value.name, key) for key, value in cls.values.items()] return sorted(items, key=lambda x: x[1])
[ "def", "items", "(", "cls", ")", ":", "items", "=", "[", "(", "value", ".", "name", ",", "key", ")", "for", "key", ",", "value", "in", "cls", ".", "values", ".", "items", "(", ")", "]", "return", "sorted", "(", "items", ",", "key", "=", "lambda...
:return: List of tuples consisting of every enum value in the form [('NAME', value), ...] :rtype: list
[ ":", "return", ":", "List", "of", "tuples", "consisting", "of", "every", "enum", "value", "in", "the", "form", "[", "(", "NAME", "value", ")", "...", "]", ":", "rtype", ":", "list" ]
train
https://github.com/5monkeys/django-enumfield/blob/6cf20c0fba013d39960af0f4d2c9a3b399955eb3/django_enumfield/enum.py#L137-L143
5monkeys/django-enumfield
django_enumfield/enum.py
Enum.is_valid_transition
def is_valid_transition(cls, from_value, to_value): """ Will check if to_value is a valid transition from from_value. Returns true if it is a valid transition. :param from_value: Start transition point :param to_value: End transition point :type from_value: int :type to_value: in...
python
def is_valid_transition(cls, from_value, to_value): """ Will check if to_value is a valid transition from from_value. Returns true if it is a valid transition. :param from_value: Start transition point :param to_value: End transition point :type from_value: int :type to_value: in...
[ "def", "is_valid_transition", "(", "cls", ",", "from_value", ",", "to_value", ")", ":", "try", ":", "return", "from_value", "==", "to_value", "or", "from_value", "in", "cls", ".", "transition_origins", "(", "to_value", ")", "except", "KeyError", ":", "return",...
Will check if to_value is a valid transition from from_value. Returns true if it is a valid transition. :param from_value: Start transition point :param to_value: End transition point :type from_value: int :type to_value: int :return: Success flag :rtype: bool
[ "Will", "check", "if", "to_value", "is", "a", "valid", "transition", "from", "from_value", ".", "Returns", "true", "if", "it", "is", "a", "valid", "transition", ".", ":", "param", "from_value", ":", "Start", "transition", "point", ":", "param", "to_value", ...
train
https://github.com/5monkeys/django-enumfield/blob/6cf20c0fba013d39960af0f4d2c9a3b399955eb3/django_enumfield/enum.py#L146-L158
5monkeys/django-enumfield
django_enumfield/db/fields.py
EnumField._setup_validation
def _setup_validation(self, sender, **kwargs): """ User a customer setter for the field to validate new value against the old one. The current value is set as '_enum_[att_name]' on the model instance. """ att_name = self.get_attname() private_att_name = '_enum_%s' % att_n...
python
def _setup_validation(self, sender, **kwargs): """ User a customer setter for the field to validate new value against the old one. The current value is set as '_enum_[att_name]' on the model instance. """ att_name = self.get_attname() private_att_name = '_enum_%s' % att_n...
[ "def", "_setup_validation", "(", "self", ",", "sender", ",", "*", "*", "kwargs", ")", ":", "att_name", "=", "self", ".", "get_attname", "(", ")", "private_att_name", "=", "'_enum_%s'", "%", "att_name", "enum", "=", "self", ".", "enum", "def", "set_enum", ...
User a customer setter for the field to validate new value against the old one. The current value is set as '_enum_[att_name]' on the model instance.
[ "User", "a", "customer", "setter", "for", "the", "field", "to", "validate", "new", "value", "against", "the", "old", "one", ".", "The", "current", "value", "is", "set", "as", "_enum_", "[", "att_name", "]", "on", "the", "model", "instance", "." ]
train
https://github.com/5monkeys/django-enumfield/blob/6cf20c0fba013d39960af0f4d2c9a3b399955eb3/django_enumfield/db/fields.py#L27-L57
5monkeys/django-enumfield
django_enumfield/validators.py
validate_valid_transition
def validate_valid_transition(enum, from_value, to_value): """ Validate that to_value is a valid choice and that to_value is a valid transition from from_value. """ validate_available_choice(enum, to_value) if hasattr(enum, '_transitions') and not enum.is_valid_transition(from_value, to_value): ...
python
def validate_valid_transition(enum, from_value, to_value): """ Validate that to_value is a valid choice and that to_value is a valid transition from from_value. """ validate_available_choice(enum, to_value) if hasattr(enum, '_transitions') and not enum.is_valid_transition(from_value, to_value): ...
[ "def", "validate_valid_transition", "(", "enum", ",", "from_value", ",", "to_value", ")", ":", "validate_available_choice", "(", "enum", ",", "to_value", ")", "if", "hasattr", "(", "enum", ",", "'_transitions'", ")", "and", "not", "enum", ".", "is_valid_transiti...
Validate that to_value is a valid choice and that to_value is a valid transition from from_value.
[ "Validate", "that", "to_value", "is", "a", "valid", "choice", "and", "that", "to_value", "is", "a", "valid", "transition", "from", "from_value", "." ]
train
https://github.com/5monkeys/django-enumfield/blob/6cf20c0fba013d39960af0f4d2c9a3b399955eb3/django_enumfield/validators.py#L7-L18
5monkeys/django-enumfield
django_enumfield/validators.py
validate_available_choice
def validate_available_choice(enum, to_value): """ Validate that to_value is defined as a value in enum. """ if to_value is None: return if type(to_value) is not int: try: to_value = int(to_value) except ValueError: message_str = "'{value}' cannot be ...
python
def validate_available_choice(enum, to_value): """ Validate that to_value is defined as a value in enum. """ if to_value is None: return if type(to_value) is not int: try: to_value = int(to_value) except ValueError: message_str = "'{value}' cannot be ...
[ "def", "validate_available_choice", "(", "enum", ",", "to_value", ")", ":", "if", "to_value", "is", "None", ":", "return", "if", "type", "(", "to_value", ")", "is", "not", "int", ":", "try", ":", "to_value", "=", "int", "(", "to_value", ")", "except", ...
Validate that to_value is defined as a value in enum.
[ "Validate", "that", "to_value", "is", "defined", "as", "a", "value", "in", "enum", "." ]
train
https://github.com/5monkeys/django-enumfield/blob/6cf20c0fba013d39960af0f4d2c9a3b399955eb3/django_enumfield/validators.py#L21-L38