repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
giancosta86/Iris
info/gianlucacosta/iris/maven.py
MavenRepository.getArtifactPath
def getArtifactPath(self, artifact, suffix=None, extension="jar"): """ Joins the root path of the repository with the relative path returned by the artifact's getPath() method """ return os.path.join(self._rootPath, artifact.getPath(suffix, extension, os.sep))
python
def getArtifactPath(self, artifact, suffix=None, extension="jar"): """ Joins the root path of the repository with the relative path returned by the artifact's getPath() method """ return os.path.join(self._rootPath, artifact.getPath(suffix, extension, os.sep))
[ "def", "getArtifactPath", "(", "self", ",", "artifact", ",", "suffix", "=", "None", ",", "extension", "=", "\"jar\"", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "_rootPath", ",", "artifact", ".", "getPath", "(", "suffix", ","...
Joins the root path of the repository with the relative path returned by the artifact's getPath() method
[ "Joins", "the", "root", "path", "of", "the", "repository", "with", "the", "relative", "path", "returned", "by", "the", "artifact", "s", "getPath", "()", "method" ]
b3d92cca5cce3653519bd032346b211c46a57d05
https://github.com/giancosta86/Iris/blob/b3d92cca5cce3653519bd032346b211c46a57d05/info/gianlucacosta/iris/maven.py#L136-L141
train
Returns the absolute path of the artifact.
pyQode/pyqode.cobol
pyqode/cobol/modes/margins.py
MarginsMode.on_state_changed
def on_state_changed(self, state): """ Connects/Disconnects to the painted event of the editor. :param state: Enable state """ if state: self.editor.painted.connect(self._paint_margins) self.editor.key_pressed.connect(self._on_key_pressed) sel...
python
def on_state_changed(self, state): """ Connects/Disconnects to the painted event of the editor. :param state: Enable state """ if state: self.editor.painted.connect(self._paint_margins) self.editor.key_pressed.connect(self._on_key_pressed) sel...
[ "def", "on_state_changed", "(", "self", ",", "state", ")", ":", "if", "state", ":", "self", ".", "editor", ".", "painted", ".", "connect", "(", "self", ".", "_paint_margins", ")", "self", ".", "editor", ".", "key_pressed", ".", "connect", "(", "self", ...
Connects/Disconnects to the painted event of the editor. :param state: Enable state
[ "Connects", "/", "Disconnects", "to", "the", "painted", "event", "of", "the", "editor", "." ]
eedae4e320a4b2d0c44abb2c3061091321648fb7
https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/modes/margins.py#L63-L76
train
Connects and disconnects to the painted event of the editor.
pyQode/pyqode.cobol
pyqode/cobol/modes/margins.py
MarginsMode._paint_margins
def _paint_margins(self, event): """ Paints the right margin after editor paint event. """ font = QtGui.QFont(self.editor.font_name, self.editor.font_size + self.editor.zoom_level) metrics = QtGui.QFontMetricsF(font) painter = QtGui.QPainter(self.editor.viewpor...
python
def _paint_margins(self, event): """ Paints the right margin after editor paint event. """ font = QtGui.QFont(self.editor.font_name, self.editor.font_size + self.editor.zoom_level) metrics = QtGui.QFontMetricsF(font) painter = QtGui.QPainter(self.editor.viewpor...
[ "def", "_paint_margins", "(", "self", ",", "event", ")", ":", "font", "=", "QtGui", ".", "QFont", "(", "self", ".", "editor", ".", "font_name", ",", "self", ".", "editor", ".", "font_size", "+", "self", ".", "editor", ".", "zoom_level", ")", "metrics",...
Paints the right margin after editor paint event.
[ "Paints", "the", "right", "margin", "after", "editor", "paint", "event", "." ]
eedae4e320a4b2d0c44abb2c3061091321648fb7
https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/modes/margins.py#L78-L92
train
Paints the right margin after editor paint event.
openvax/varlens
varlens/support.py
allele_support_df
def allele_support_df(loci, sources): """ Returns a DataFrame of allele counts for all given loci in the read sources """ return pandas.DataFrame( allele_support_rows(loci, sources), columns=EXPECTED_COLUMNS)
python
def allele_support_df(loci, sources): """ Returns a DataFrame of allele counts for all given loci in the read sources """ return pandas.DataFrame( allele_support_rows(loci, sources), columns=EXPECTED_COLUMNS)
[ "def", "allele_support_df", "(", "loci", ",", "sources", ")", ":", "return", "pandas", ".", "DataFrame", "(", "allele_support_rows", "(", "loci", ",", "sources", ")", ",", "columns", "=", "EXPECTED_COLUMNS", ")" ]
Returns a DataFrame of allele counts for all given loci in the read sources
[ "Returns", "a", "DataFrame", "of", "allele", "counts", "for", "all", "given", "loci", "in", "the", "read", "sources" ]
715d3ede5893757b2fcba4117515621bca7b1e5d
https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/support.py#L29-L35
train
Returns a DataFrame of all the allele counts for all given loci in the read sources
openvax/varlens
varlens/support.py
variant_support
def variant_support(variants, allele_support_df, ignore_missing=False): ''' Collect the read evidence support for the given variants. Parameters ---------- variants : iterable of varcode.Variant allele_support_df : dataframe Allele support dataframe, as output by the varlens-allele-su...
python
def variant_support(variants, allele_support_df, ignore_missing=False): ''' Collect the read evidence support for the given variants. Parameters ---------- variants : iterable of varcode.Variant allele_support_df : dataframe Allele support dataframe, as output by the varlens-allele-su...
[ "def", "variant_support", "(", "variants", ",", "allele_support_df", ",", "ignore_missing", "=", "False", ")", ":", "missing", "=", "[", "c", "for", "c", "in", "EXPECTED_COLUMNS", "if", "c", "not", "in", "allele_support_df", ".", "columns", "]", "if", "missi...
Collect the read evidence support for the given variants. Parameters ---------- variants : iterable of varcode.Variant allele_support_df : dataframe Allele support dataframe, as output by the varlens-allele-support tool. It should have columns: source, contig, interbase_start, interba...
[ "Collect", "the", "read", "evidence", "support", "for", "the", "given", "variants", "." ]
715d3ede5893757b2fcba4117515621bca7b1e5d
https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/support.py#L57-L153
train
Returns a DataFrame containing the read evidence support for the given variants.
cloudmesh-cmd3/cmd3
cmd3/plugins/timer.py
timer.do_timer
def do_timer(self, args, arguments): """ :: Usage: timer on timer off timer list timer start NAME timer stop NAME timer resume NAME timer reset [NAME] ...
python
def do_timer(self, args, arguments): """ :: Usage: timer on timer off timer list timer start NAME timer stop NAME timer resume NAME timer reset [NAME] ...
[ "def", "do_timer", "(", "self", ",", "args", ",", "arguments", ")", ":", "# print arguments", "# print \"args\", args", "args", "=", "args", ".", "lower", "(", ")", "if", "args", "in", "(", "\"on\"", ",", "\"off\"", ")", ":", "self", ".", "with_timers", ...
:: Usage: timer on timer off timer list timer start NAME timer stop NAME timer resume NAME timer reset [NAME] Description (NOT IMPLEMENTED YET): ...
[ "::", "Usage", ":", "timer", "on", "timer", "off", "timer", "list", "timer", "start", "NAME", "timer", "stop", "NAME", "timer", "resume", "NAME", "timer", "reset", "[", "NAME", "]" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/timer.py#L14-L64
train
Command for timer command
gesellkammer/sndfileio
sndfileio/sndfileio.py
sndread
def sndread(path:str) -> Tuple[np.ndarray, int]: """ Read a soundfile as a numpy array. This is a float array defined between -1 and 1, independently of the format of the soundfile Returns (data:ndarray, sr:int) """ backend = _getBackend(path) logger.debug(f"sndread: using backend {bac...
python
def sndread(path:str) -> Tuple[np.ndarray, int]: """ Read a soundfile as a numpy array. This is a float array defined between -1 and 1, independently of the format of the soundfile Returns (data:ndarray, sr:int) """ backend = _getBackend(path) logger.debug(f"sndread: using backend {bac...
[ "def", "sndread", "(", "path", ":", "str", ")", "->", "Tuple", "[", "np", ".", "ndarray", ",", "int", "]", ":", "backend", "=", "_getBackend", "(", "path", ")", "logger", ".", "debug", "(", "f\"sndread: using backend {backend.name}\"", ")", "return", "back...
Read a soundfile as a numpy array. This is a float array defined between -1 and 1, independently of the format of the soundfile Returns (data:ndarray, sr:int)
[ "Read", "a", "soundfile", "as", "a", "numpy", "array", ".", "This", "is", "a", "float", "array", "defined", "between", "-", "1", "and", "1", "independently", "of", "the", "format", "of", "the", "soundfile", "Returns", "(", "data", ":", "ndarray", "sr", ...
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/sndfileio.py#L190-L199
train
Read a soundfile as a numpy array.
gesellkammer/sndfileio
sndfileio/sndfileio.py
sndread_chunked
def sndread_chunked(path:str, frames:int=_CHUNKSIZE) -> Iterator[np.ndarray]: """ Returns a generator yielding numpy arrays (float64) of at most `frames` frames """ backend = _getBackend(path, key=lambda backend: backend.can_read_chunked) if backend: logger.debug(f"sndread_chunked: using...
python
def sndread_chunked(path:str, frames:int=_CHUNKSIZE) -> Iterator[np.ndarray]: """ Returns a generator yielding numpy arrays (float64) of at most `frames` frames """ backend = _getBackend(path, key=lambda backend: backend.can_read_chunked) if backend: logger.debug(f"sndread_chunked: using...
[ "def", "sndread_chunked", "(", "path", ":", "str", ",", "frames", ":", "int", "=", "_CHUNKSIZE", ")", "->", "Iterator", "[", "np", ".", "ndarray", "]", ":", "backend", "=", "_getBackend", "(", "path", ",", "key", "=", "lambda", "backend", ":", "backend...
Returns a generator yielding numpy arrays (float64) of at most `frames` frames
[ "Returns", "a", "generator", "yielding", "numpy", "arrays", "(", "float64", ")", "of", "at", "most", "frames", "frames" ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/sndfileio.py#L202-L212
train
Read a file in chunks.
gesellkammer/sndfileio
sndfileio/sndfileio.py
sndinfo
def sndinfo(path:str) -> SndInfo: """ Get info about a soundfile path (str): the path to a soundfile RETURNS --> an instance of SndInfo: samplerate, nframes, channels, encoding, fileformat """ backend = _getBackend(path) logger.debug(f"sndinfo: using backend {backend.name}") return bac...
python
def sndinfo(path:str) -> SndInfo: """ Get info about a soundfile path (str): the path to a soundfile RETURNS --> an instance of SndInfo: samplerate, nframes, channels, encoding, fileformat """ backend = _getBackend(path) logger.debug(f"sndinfo: using backend {backend.name}") return bac...
[ "def", "sndinfo", "(", "path", ":", "str", ")", "->", "SndInfo", ":", "backend", "=", "_getBackend", "(", "path", ")", "logger", ".", "debug", "(", "f\"sndinfo: using backend {backend.name}\"", ")", "return", "backend", ".", "getinfo", "(", "path", ")" ]
Get info about a soundfile path (str): the path to a soundfile RETURNS --> an instance of SndInfo: samplerate, nframes, channels, encoding, fileformat
[ "Get", "info", "about", "a", "soundfile" ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/sndfileio.py#L215-L225
train
Get info about a soundfile
gesellkammer/sndfileio
sndfileio/sndfileio.py
sndwrite
def sndwrite(samples:np.ndarray, sr:int, outfile:str, encoding:str='auto') -> None: """ samples --> Array-like. the actual samples, shape=(nframes, channels) sr --> Sampling-rate outfile --> The name of the outfile. the extension will determine the file-format. ...
python
def sndwrite(samples:np.ndarray, sr:int, outfile:str, encoding:str='auto') -> None: """ samples --> Array-like. the actual samples, shape=(nframes, channels) sr --> Sampling-rate outfile --> The name of the outfile. the extension will determine the file-format. ...
[ "def", "sndwrite", "(", "samples", ":", "np", ".", "ndarray", ",", "sr", ":", "int", ",", "outfile", ":", "str", ",", "encoding", ":", "str", "=", "'auto'", ")", "->", "None", ":", "if", "encoding", "in", "(", "'auto'", ",", "None", ")", ":", "en...
samples --> Array-like. the actual samples, shape=(nframes, channels) sr --> Sampling-rate outfile --> The name of the outfile. the extension will determine the file-format. The formats supported depend on the available backends Without additional backe...
[ "samples", "--", ">", "Array", "-", "like", ".", "the", "actual", "samples", "shape", "=", "(", "nframes", "channels", ")", "sr", "--", ">", "Sampling", "-", "rate", "outfile", "--", ">", "The", "name", "of", "the", "outfile", ".", "the", "extension", ...
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/sndfileio.py#L228-L268
train
Write samples to a file using the specified samplerate.
gesellkammer/sndfileio
sndfileio/sndfileio.py
sndwrite_chunked
def sndwrite_chunked(sr: int, outfile: str, encoding: str) -> _SndWriter: """ Returns a SndWriter. Call its .write(samples) method to write samples --> Array-like. the actual samples, shape=(nframes, channels) sr --> Sampling-rate outfile --> The name of the outfile. the extension will...
python
def sndwrite_chunked(sr: int, outfile: str, encoding: str) -> _SndWriter: """ Returns a SndWriter. Call its .write(samples) method to write samples --> Array-like. the actual samples, shape=(nframes, channels) sr --> Sampling-rate outfile --> The name of the outfile. the extension will...
[ "def", "sndwrite_chunked", "(", "sr", ":", "int", ",", "outfile", ":", "str", ",", "encoding", ":", "str", ")", "->", "_SndWriter", ":", "backends", "=", "[", "backend", "for", "backend", "in", "_getBackends", "(", ")", "if", "backend", ".", "can_write_c...
Returns a SndWriter. Call its .write(samples) method to write samples --> Array-like. the actual samples, shape=(nframes, channels) sr --> Sampling-rate outfile --> The name of the outfile. the extension will determine the file-format. The formats supported de...
[ "Returns", "a", "SndWriter", ".", "Call", "its", ".", "write", "(", "samples", ")", "method", "to", "write" ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/sndfileio.py#L271-L295
train
Returns a SndWriter that writes samples to a file in chunks.
gesellkammer/sndfileio
sndfileio/sndfileio.py
asmono
def asmono(samples:np.ndarray, channel:Union[int, str]=0) -> np.ndarray: """ convert samples to mono if they are not mono already. The returned array will always have the shape (numframes,) channel: the channel number to use, or 'mix' to mix-down all channels """ if numchannels(sa...
python
def asmono(samples:np.ndarray, channel:Union[int, str]=0) -> np.ndarray: """ convert samples to mono if they are not mono already. The returned array will always have the shape (numframes,) channel: the channel number to use, or 'mix' to mix-down all channels """ if numchannels(sa...
[ "def", "asmono", "(", "samples", ":", "np", ".", "ndarray", ",", "channel", ":", "Union", "[", "int", ",", "str", "]", "=", "0", ")", "->", "np", ".", "ndarray", ":", "if", "numchannels", "(", "samples", ")", "==", "1", ":", "# it could be [1,2,3,4,....
convert samples to mono if they are not mono already. The returned array will always have the shape (numframes,) channel: the channel number to use, or 'mix' to mix-down all channels
[ "convert", "samples", "to", "mono", "if", "they", "are", "not", "mono", "already", "." ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/sndfileio.py#L298-L322
train
Convert samples to mono if they are not mono already.
gesellkammer/sndfileio
sndfileio/sndfileio.py
getchannel
def getchannel(samples: np.ndarray, ch:int) -> np.ndarray: """ Returns a view into a channel of samples. samples : a numpy array representing the audio data ch : the channel to extract (channels begin with 0) """ N = numchannels(samples) if ch > (N - 1): raise ValueError(...
python
def getchannel(samples: np.ndarray, ch:int) -> np.ndarray: """ Returns a view into a channel of samples. samples : a numpy array representing the audio data ch : the channel to extract (channels begin with 0) """ N = numchannels(samples) if ch > (N - 1): raise ValueError(...
[ "def", "getchannel", "(", "samples", ":", "np", ".", "ndarray", ",", "ch", ":", "int", ")", "->", "np", ".", "ndarray", ":", "N", "=", "numchannels", "(", "samples", ")", "if", "ch", ">", "(", "N", "-", "1", ")", ":", "raise", "ValueError", "(", ...
Returns a view into a channel of samples. samples : a numpy array representing the audio data ch : the channel to extract (channels begin with 0)
[ "Returns", "a", "view", "into", "a", "channel", "of", "samples", "." ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/sndfileio.py#L325-L337
train
Returns a view into a channel of samples.
gesellkammer/sndfileio
sndfileio/sndfileio.py
bitdepth
def bitdepth(data:np.ndarray, snap:bool=True) -> int: """ returns the number of bits actually used to represent the data. data: a numpy.array (mono or multi-channel) snap: snap to 8, 16, 24 or 32 bits. """ data = asmono(data) maxitems = min(4096, data.shape[0]) maxbits = max(x.as_intege...
python
def bitdepth(data:np.ndarray, snap:bool=True) -> int: """ returns the number of bits actually used to represent the data. data: a numpy.array (mono or multi-channel) snap: snap to 8, 16, 24 or 32 bits. """ data = asmono(data) maxitems = min(4096, data.shape[0]) maxbits = max(x.as_intege...
[ "def", "bitdepth", "(", "data", ":", "np", ".", "ndarray", ",", "snap", ":", "bool", "=", "True", ")", "->", "int", ":", "data", "=", "asmono", "(", "data", ")", "maxitems", "=", "min", "(", "4096", ",", "data", ".", "shape", "[", "0", "]", ")"...
returns the number of bits actually used to represent the data. data: a numpy.array (mono or multi-channel) snap: snap to 8, 16, 24 or 32 bits.
[ "returns", "the", "number", "of", "bits", "actually", "used", "to", "represent", "the", "data", "." ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/sndfileio.py#L340-L362
train
Returns the number of bits actually used to represent the data.
gesellkammer/sndfileio
sndfileio/sndfileio.py
sndwrite_like
def sndwrite_like(samples:np.ndarray, likefile:str, outfile:str) -> None: """ Write samples to outfile with samplerate and encoding taken from likefile """ info = sndinfo(likefile) sndwrite(samples, info.samplerate, outfile, encoding=info.encoding)
python
def sndwrite_like(samples:np.ndarray, likefile:str, outfile:str) -> None: """ Write samples to outfile with samplerate and encoding taken from likefile """ info = sndinfo(likefile) sndwrite(samples, info.samplerate, outfile, encoding=info.encoding)
[ "def", "sndwrite_like", "(", "samples", ":", "np", ".", "ndarray", ",", "likefile", ":", "str", ",", "outfile", ":", "str", ")", "->", "None", ":", "info", "=", "sndinfo", "(", "likefile", ")", "sndwrite", "(", "samples", ",", "info", ".", "samplerate"...
Write samples to outfile with samplerate and encoding taken from likefile
[ "Write", "samples", "to", "outfile", "with", "samplerate", "and", "encoding", "taken", "from", "likefile" ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/sndfileio.py#L365-L371
train
Write samples to outfile with samplerate and encoding taken from likefile
gesellkammer/sndfileio
sndfileio/sndfileio.py
_wavReadData
def _wavReadData(fid, size:int, channels:int, encoding:str, bigendian:bool) -> np.ndarray: """ adapted from scipy.io.wavfile._read_data_chunk assume we are at the data (after having read the size) """ bits = int(encoding[3:]) ...
python
def _wavReadData(fid, size:int, channels:int, encoding:str, bigendian:bool) -> np.ndarray: """ adapted from scipy.io.wavfile._read_data_chunk assume we are at the data (after having read the size) """ bits = int(encoding[3:]) ...
[ "def", "_wavReadData", "(", "fid", ",", "size", ":", "int", ",", "channels", ":", "int", ",", "encoding", ":", "str", ",", "bigendian", ":", "bool", ")", "->", "np", ".", "ndarray", ":", "bits", "=", "int", "(", "encoding", "[", "3", ":", "]", ")...
adapted from scipy.io.wavfile._read_data_chunk assume we are at the data (after having read the size)
[ "adapted", "from", "scipy", ".", "io", ".", "wavfile", ".", "_read_data_chunk" ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/sndfileio.py#L788-L832
train
Read the data from a wav file.
gesellkammer/sndfileio
sndfileio/sndfileio.py
_wavGetInfo
def _wavGetInfo(f:Union[IO, str]) -> Tuple[SndInfo, Dict[str, Any]]: """ Read the info of a wav file. taken mostly from scipy.io.wavfile if extended: returns also fsize and bigendian """ if isinstance(f, (str, bytes)): f = open(f, 'rb') needsclosing = True else: needsclo...
python
def _wavGetInfo(f:Union[IO, str]) -> Tuple[SndInfo, Dict[str, Any]]: """ Read the info of a wav file. taken mostly from scipy.io.wavfile if extended: returns also fsize and bigendian """ if isinstance(f, (str, bytes)): f = open(f, 'rb') needsclosing = True else: needsclo...
[ "def", "_wavGetInfo", "(", "f", ":", "Union", "[", "IO", ",", "str", "]", ")", "->", "Tuple", "[", "SndInfo", ",", "Dict", "[", "str", ",", "Any", "]", "]", ":", "if", "isinstance", "(", "f", ",", "(", "str", ",", "bytes", ")", ")", ":", "f",...
Read the info of a wav file. taken mostly from scipy.io.wavfile if extended: returns also fsize and bigendian
[ "Read", "the", "info", "of", "a", "wav", "file", ".", "taken", "mostly", "from", "scipy", ".", "io", ".", "wavfile" ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/sndfileio.py#L866-L896
train
Read the info of a wav file. taken mostly from scipy. io. wavfile ArcGIS
gesellkammer/sndfileio
sndfileio/sndfileio.py
_numpy24to32bit
def _numpy24to32bit(data:np.ndarray, bigendian:bool=False) -> np.ndarray: """ data is a ubyte array of shape = (size,) (interleaved channels if multichannel) """ target = np.zeros((data.shape[0] * 4 / 3,), dtype=np.ubyte) if not bigendian: target[3::4] = data[2::3] target[2::4] ...
python
def _numpy24to32bit(data:np.ndarray, bigendian:bool=False) -> np.ndarray: """ data is a ubyte array of shape = (size,) (interleaved channels if multichannel) """ target = np.zeros((data.shape[0] * 4 / 3,), dtype=np.ubyte) if not bigendian: target[3::4] = data[2::3] target[2::4] ...
[ "def", "_numpy24to32bit", "(", "data", ":", "np", ".", "ndarray", ",", "bigendian", ":", "bool", "=", "False", ")", "->", "np", ".", "ndarray", ":", "target", "=", "np", ".", "zeros", "(", "(", "data", ".", "shape", "[", "0", "]", "*", "4", "/", ...
data is a ubyte array of shape = (size,) (interleaved channels if multichannel)
[ "data", "is", "a", "ubyte", "array", "of", "shape", "=", "(", "size", ")", "(", "interleaved", "channels", "if", "multichannel", ")" ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/sndfileio.py#L940-L958
train
Convert numpy array to 32 - bit integer array.
gesellkammer/sndfileio
sndfileio/sndfileio.py
_getBackend
def _getBackend(path=None, key=None): """ key: a function (backend -> bool) signaling if the backend is suitable for a specific task example ======= # Get available backends which can read in chunks >>> backend = _getBackend('file.flac', key=lambda backend:backend.can_read_chunked) ...
python
def _getBackend(path=None, key=None): """ key: a function (backend -> bool) signaling if the backend is suitable for a specific task example ======= # Get available backends which can read in chunks >>> backend = _getBackend('file.flac', key=lambda backend:backend.can_read_chunked) ...
[ "def", "_getBackend", "(", "path", "=", "None", ",", "key", "=", "None", ")", ":", "ext", "=", "_os", ".", "path", ".", "splitext", "(", "path", ")", "[", "1", "]", ".", "lower", "(", ")", "if", "path", "else", "None", "backends", "=", "_getBacke...
key: a function (backend -> bool) signaling if the backend is suitable for a specific task example ======= # Get available backends which can read in chunks >>> backend = _getBackend('file.flac', key=lambda backend:backend.can_read_chunked)
[ "key", ":", "a", "function", "(", "backend", "-", ">", "bool", ")", "signaling", "if", "the", "backend", "is", "suitable", "for", "a", "specific", "task" ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/sndfileio.py#L965-L984
train
Get a backend for a specific task.
bacher09/xrcon
xrcon/client.py
QuakeProtocol.connect
def connect(self): "Create connection to server" family, stype, proto, cname, sockaddr = self.best_connection_params( self.host, self.port) self.sock = socket.socket(family, stype) self.sock.settimeout(self.timeout) self.sock.connect(sockaddr)
python
def connect(self): "Create connection to server" family, stype, proto, cname, sockaddr = self.best_connection_params( self.host, self.port) self.sock = socket.socket(family, stype) self.sock.settimeout(self.timeout) self.sock.connect(sockaddr)
[ "def", "connect", "(", "self", ")", ":", "family", ",", "stype", ",", "proto", ",", "cname", ",", "sockaddr", "=", "self", ".", "best_connection_params", "(", "self", ".", "host", ",", "self", ".", "port", ")", "self", ".", "sock", "=", "socket", "."...
Create connection to server
[ "Create", "connection", "to", "server" ]
6a883f780265cbca31af7a379dc7cb28fdd8b73f
https://github.com/bacher09/xrcon/blob/6a883f780265cbca31af7a379dc7cb28fdd8b73f/xrcon/client.py#L53-L59
train
Create connection to server
bacher09/xrcon
xrcon/client.py
QuakeProtocol.getchallenge
def getchallenge(self): "Return server challenge" self.sock.send(CHALLENGE_PACKET) # wait challenge response for packet in self.read_iterator(self.CHALLENGE_TIMEOUT): if packet.startswith(CHALLENGE_RESPONSE_HEADER): return parse_challenge_response(packet)
python
def getchallenge(self): "Return server challenge" self.sock.send(CHALLENGE_PACKET) # wait challenge response for packet in self.read_iterator(self.CHALLENGE_TIMEOUT): if packet.startswith(CHALLENGE_RESPONSE_HEADER): return parse_challenge_response(packet)
[ "def", "getchallenge", "(", "self", ")", ":", "self", ".", "sock", ".", "send", "(", "CHALLENGE_PACKET", ")", "# wait challenge response", "for", "packet", "in", "self", ".", "read_iterator", "(", "self", ".", "CHALLENGE_TIMEOUT", ")", ":", "if", "packet", "...
Return server challenge
[ "Return", "server", "challenge" ]
6a883f780265cbca31af7a379dc7cb28fdd8b73f
https://github.com/bacher09/xrcon/blob/6a883f780265cbca31af7a379dc7cb28fdd8b73f/xrcon/client.py#L86-L92
train
Return server challenge
bacher09/xrcon
xrcon/client.py
XRcon.send
def send(self, command): "Send rcon command to server" if self.secure_rcon == self.RCON_NOSECURE: self.sock.send(rcon_nosecure_packet(self.password, command)) elif self.secure_rcon == self.RCON_SECURE_TIME: self.sock.send(rcon_secure_time_packet(self.password, command)) ...
python
def send(self, command): "Send rcon command to server" if self.secure_rcon == self.RCON_NOSECURE: self.sock.send(rcon_nosecure_packet(self.password, command)) elif self.secure_rcon == self.RCON_SECURE_TIME: self.sock.send(rcon_secure_time_packet(self.password, command)) ...
[ "def", "send", "(", "self", ",", "command", ")", ":", "if", "self", ".", "secure_rcon", "==", "self", ".", "RCON_NOSECURE", ":", "self", ".", "sock", ".", "send", "(", "rcon_nosecure_packet", "(", "self", ".", "password", ",", "command", ")", ")", "eli...
Send rcon command to server
[ "Send", "rcon", "command", "to", "server" ]
6a883f780265cbca31af7a379dc7cb28fdd8b73f
https://github.com/bacher09/xrcon/blob/6a883f780265cbca31af7a379dc7cb28fdd8b73f/xrcon/client.py#L174-L185
train
Send rcon command to server
bacher09/xrcon
xrcon/client.py
XRcon.execute
def execute(self, command, timeout=1): """Execute rcon command on server and fetch result Args: command --- executed command timeout --- read timeout Returns: bytes response """ self.send(command) return self.read_untill(timeout)
python
def execute(self, command, timeout=1): """Execute rcon command on server and fetch result Args: command --- executed command timeout --- read timeout Returns: bytes response """ self.send(command) return self.read_untill(timeout)
[ "def", "execute", "(", "self", ",", "command", ",", "timeout", "=", "1", ")", ":", "self", ".", "send", "(", "command", ")", "return", "self", ".", "read_untill", "(", "timeout", ")" ]
Execute rcon command on server and fetch result Args: command --- executed command timeout --- read timeout Returns: bytes response
[ "Execute", "rcon", "command", "on", "server", "and", "fetch", "result", "Args", ":", "command", "---", "executed", "command", "timeout", "---", "read", "timeout" ]
6a883f780265cbca31af7a379dc7cb28fdd8b73f
https://github.com/bacher09/xrcon/blob/6a883f780265cbca31af7a379dc7cb28fdd8b73f/xrcon/client.py#L207-L216
train
Execute a command on the server and return the response.
romankoblov/leaf
leaf/__init__.py
parse
def parse(html_string, wrapper=Parser, *args, **kwargs): """ Parse html with wrapper """ return Parser(lxml.html.fromstring(html_string), *args, **kwargs)
python
def parse(html_string, wrapper=Parser, *args, **kwargs): """ Parse html with wrapper """ return Parser(lxml.html.fromstring(html_string), *args, **kwargs)
[ "def", "parse", "(", "html_string", ",", "wrapper", "=", "Parser", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "Parser", "(", "lxml", ".", "html", ".", "fromstring", "(", "html_string", ")", ",", "*", "args", ",", "*", "*", "kwar...
Parse html with wrapper
[ "Parse", "html", "with", "wrapper" ]
e042d91ec462c834318d03f199fcc4a9f565cb84
https://github.com/romankoblov/leaf/blob/e042d91ec462c834318d03f199fcc4a9f565cb84/leaf/__init__.py#L112-L114
train
Parse html with wrapper
romankoblov/leaf
leaf/__init__.py
str2int
def str2int(string_with_int): """ Collect digits from a string """ return int("".join([char for char in string_with_int if char in string.digits]) or 0)
python
def str2int(string_with_int): """ Collect digits from a string """ return int("".join([char for char in string_with_int if char in string.digits]) or 0)
[ "def", "str2int", "(", "string_with_int", ")", ":", "return", "int", "(", "\"\"", ".", "join", "(", "[", "char", "for", "char", "in", "string_with_int", "if", "char", "in", "string", ".", "digits", "]", ")", "or", "0", ")" ]
Collect digits from a string
[ "Collect", "digits", "from", "a", "string" ]
e042d91ec462c834318d03f199fcc4a9f565cb84
https://github.com/romankoblov/leaf/blob/e042d91ec462c834318d03f199fcc4a9f565cb84/leaf/__init__.py#L117-L119
train
Convert a string to an integer.
romankoblov/leaf
leaf/__init__.py
to_unicode
def to_unicode(obj, encoding='utf-8'): """ Convert string to unicode string """ if isinstance(obj, string_types) or isinstance(obj, binary_type): if not isinstance(obj, text_type): obj = text_type(obj, encoding) return obj
python
def to_unicode(obj, encoding='utf-8'): """ Convert string to unicode string """ if isinstance(obj, string_types) or isinstance(obj, binary_type): if not isinstance(obj, text_type): obj = text_type(obj, encoding) return obj
[ "def", "to_unicode", "(", "obj", ",", "encoding", "=", "'utf-8'", ")", ":", "if", "isinstance", "(", "obj", ",", "string_types", ")", "or", "isinstance", "(", "obj", ",", "binary_type", ")", ":", "if", "not", "isinstance", "(", "obj", ",", "text_type", ...
Convert string to unicode string
[ "Convert", "string", "to", "unicode", "string" ]
e042d91ec462c834318d03f199fcc4a9f565cb84
https://github.com/romankoblov/leaf/blob/e042d91ec462c834318d03f199fcc4a9f565cb84/leaf/__init__.py#L122-L127
train
Convert string to unicode string
romankoblov/leaf
leaf/__init__.py
strip_accents
def strip_accents(s, pass_symbols=(u'й', u'Й', u'\n')): """ Strip accents from a string """ result = [] for char in s: # Pass these symbols without processing if char in pass_symbols: result.append(char) continue for c in unicodedata.normalize('NFD', char): ...
python
def strip_accents(s, pass_symbols=(u'й', u'Й', u'\n')): """ Strip accents from a string """ result = [] for char in s: # Pass these symbols without processing if char in pass_symbols: result.append(char) continue for c in unicodedata.normalize('NFD', char): ...
[ "def", "strip_accents", "(", "s", ",", "pass_symbols", "=", "(", "u'й',", " ", "'Й', ", "u", "\\n'))", ":", "", "", "result", "=", "[", "]", "for", "char", "in", "s", ":", "# Pass these symbols without processing", "if", "char", "in", "pass_symbols", ":", ...
Strip accents from a string
[ "Strip", "accents", "from", "a", "string" ]
e042d91ec462c834318d03f199fcc4a9f565cb84
https://github.com/romankoblov/leaf/blob/e042d91ec462c834318d03f199fcc4a9f565cb84/leaf/__init__.py#L130-L142
train
Strip accents from a string
romankoblov/leaf
leaf/__init__.py
strip_symbols
def strip_symbols(s, pass_symbols=(u'й', u'Й', u'\n')): """ Strip ugly unicode symbols from a string """ result = [] for char in s: # Pass these symbols without processing if char in pass_symbols: result.append(char) continue for c in unicodedata.normalize('NF...
python
def strip_symbols(s, pass_symbols=(u'й', u'Й', u'\n')): """ Strip ugly unicode symbols from a string """ result = [] for char in s: # Pass these symbols without processing if char in pass_symbols: result.append(char) continue for c in unicodedata.normalize('NF...
[ "def", "strip_symbols", "(", "s", ",", "pass_symbols", "=", "(", "u'й',", " ", "'Й', ", "u", "\\n'))", ":", "", "", "result", "=", "[", "]", "for", "char", "in", "s", ":", "# Pass these symbols without processing", "if", "char", "in", "pass_symbols", ":", ...
Strip ugly unicode symbols from a string
[ "Strip", "ugly", "unicode", "symbols", "from", "a", "string" ]
e042d91ec462c834318d03f199fcc4a9f565cb84
https://github.com/romankoblov/leaf/blob/e042d91ec462c834318d03f199fcc4a9f565cb84/leaf/__init__.py#L145-L159
train
Strip ugly unicode symbols from a string
romankoblov/leaf
leaf/__init__.py
strip_spaces
def strip_spaces(s): """ Strip excess spaces from a string """ return u" ".join([c for c in s.split(u' ') if c])
python
def strip_spaces(s): """ Strip excess spaces from a string """ return u" ".join([c for c in s.split(u' ') if c])
[ "def", "strip_spaces", "(", "s", ")", ":", "return", "u\" \"", ".", "join", "(", "[", "c", "for", "c", "in", "s", ".", "split", "(", "u' '", ")", "if", "c", "]", ")" ]
Strip excess spaces from a string
[ "Strip", "excess", "spaces", "from", "a", "string" ]
e042d91ec462c834318d03f199fcc4a9f565cb84
https://github.com/romankoblov/leaf/blob/e042d91ec462c834318d03f199fcc4a9f565cb84/leaf/__init__.py#L162-L164
train
Strip excess spaces from a string
romankoblov/leaf
leaf/__init__.py
strip_linebreaks
def strip_linebreaks(s): """ Strip excess line breaks from a string """ return u"\n".join([c for c in s.split(u'\n') if c])
python
def strip_linebreaks(s): """ Strip excess line breaks from a string """ return u"\n".join([c for c in s.split(u'\n') if c])
[ "def", "strip_linebreaks", "(", "s", ")", ":", "return", "u\"\\n\"", ".", "join", "(", "[", "c", "for", "c", "in", "s", ".", "split", "(", "u'\\n'", ")", "if", "c", "]", ")" ]
Strip excess line breaks from a string
[ "Strip", "excess", "line", "breaks", "from", "a", "string" ]
e042d91ec462c834318d03f199fcc4a9f565cb84
https://github.com/romankoblov/leaf/blob/e042d91ec462c834318d03f199fcc4a9f565cb84/leaf/__init__.py#L167-L169
train
Strip excess line breaks from a string
romankoblov/leaf
leaf/__init__.py
Parser.get
def get(self, selector, index=0, default=None): """ Get first element from CSSSelector """ elements = self(selector) if elements: try: return elements[index] except (IndexError): pass return default
python
def get(self, selector, index=0, default=None): """ Get first element from CSSSelector """ elements = self(selector) if elements: try: return elements[index] except (IndexError): pass return default
[ "def", "get", "(", "self", ",", "selector", ",", "index", "=", "0", ",", "default", "=", "None", ")", ":", "elements", "=", "self", "(", "selector", ")", "if", "elements", ":", "try", ":", "return", "elements", "[", "index", "]", "except", "(", "In...
Get first element from CSSSelector
[ "Get", "first", "element", "from", "CSSSelector" ]
e042d91ec462c834318d03f199fcc4a9f565cb84
https://github.com/romankoblov/leaf/blob/e042d91ec462c834318d03f199fcc4a9f565cb84/leaf/__init__.py#L26-L34
train
Get first element from CSSSelector
romankoblov/leaf
leaf/__init__.py
Parser.html
def html(self, unicode=False): """ Return HTML of element """ html = lxml.html.tostring(self.element, encoding=self.encoding) if unicode: html = html.decode(self.encoding) return html
python
def html(self, unicode=False): """ Return HTML of element """ html = lxml.html.tostring(self.element, encoding=self.encoding) if unicode: html = html.decode(self.encoding) return html
[ "def", "html", "(", "self", ",", "unicode", "=", "False", ")", ":", "html", "=", "lxml", ".", "html", ".", "tostring", "(", "self", ".", "element", ",", "encoding", "=", "self", ".", "encoding", ")", "if", "unicode", ":", "html", "=", "html", ".", ...
Return HTML of element
[ "Return", "HTML", "of", "element" ]
e042d91ec462c834318d03f199fcc4a9f565cb84
https://github.com/romankoblov/leaf/blob/e042d91ec462c834318d03f199fcc4a9f565cb84/leaf/__init__.py#L36-L41
train
Return HTML of element
romankoblov/leaf
leaf/__init__.py
Parser.parse
def parse(self, func, *args, **kwargs): """ Parse element with given function""" result = [] for element in self.xpath('child::node()'): if isinstance(element, Parser): children = element.parse(func, *args, **kwargs) element_result = func(element, chil...
python
def parse(self, func, *args, **kwargs): """ Parse element with given function""" result = [] for element in self.xpath('child::node()'): if isinstance(element, Parser): children = element.parse(func, *args, **kwargs) element_result = func(element, chil...
[ "def", "parse", "(", "self", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "[", "]", "for", "element", "in", "self", ".", "xpath", "(", "'child::node()'", ")", ":", "if", "isinstance", "(", "element", ",", "Parser...
Parse element with given function
[ "Parse", "element", "with", "given", "function" ]
e042d91ec462c834318d03f199fcc4a9f565cb84
https://github.com/romankoblov/leaf/blob/e042d91ec462c834318d03f199fcc4a9f565cb84/leaf/__init__.py#L55-L66
train
Parse element with given function
romankoblov/leaf
leaf/__init__.py
Parser._wrap_result
def _wrap_result(self, func): """ Wrap result in Parser instance """ def wrapper(*args): result = func(*args) if hasattr(result, '__iter__') and not isinstance(result, etree._Element): return [self._wrap_element(element) for element in result] else: ...
python
def _wrap_result(self, func): """ Wrap result in Parser instance """ def wrapper(*args): result = func(*args) if hasattr(result, '__iter__') and not isinstance(result, etree._Element): return [self._wrap_element(element) for element in result] else: ...
[ "def", "_wrap_result", "(", "self", ",", "func", ")", ":", "def", "wrapper", "(", "*", "args", ")", ":", "result", "=", "func", "(", "*", "args", ")", "if", "hasattr", "(", "result", ",", "'__iter__'", ")", "and", "not", "isinstance", "(", "result", ...
Wrap result in Parser instance
[ "Wrap", "result", "in", "Parser", "instance" ]
e042d91ec462c834318d03f199fcc4a9f565cb84
https://github.com/romankoblov/leaf/blob/e042d91ec462c834318d03f199fcc4a9f565cb84/leaf/__init__.py#L68-L76
train
Wrap result in Parser instance
romankoblov/leaf
leaf/__init__.py
Parser._wrap_element
def _wrap_element(self, result): """ Wrap single element in Parser instance """ if isinstance(result, lxml.html.HtmlElement): return Parser(result) else: return result
python
def _wrap_element(self, result): """ Wrap single element in Parser instance """ if isinstance(result, lxml.html.HtmlElement): return Parser(result) else: return result
[ "def", "_wrap_element", "(", "self", ",", "result", ")", ":", "if", "isinstance", "(", "result", ",", "lxml", ".", "html", ".", "HtmlElement", ")", ":", "return", "Parser", "(", "result", ")", "else", ":", "return", "result" ]
Wrap single element in Parser instance
[ "Wrap", "single", "element", "in", "Parser", "instance" ]
e042d91ec462c834318d03f199fcc4a9f565cb84
https://github.com/romankoblov/leaf/blob/e042d91ec462c834318d03f199fcc4a9f565cb84/leaf/__init__.py#L78-L83
train
Wrap single element in Parser instance
frostming/marko
marko/block.py
BlockElement.parse_inline
def parse_inline(self): """Inline parsing is postponed so that all link references are seen before that. """ if self.inline_children: self.children = parser.parse_inline(self.children) elif isinstance(getattr(self, 'children', None), list): for child in se...
python
def parse_inline(self): """Inline parsing is postponed so that all link references are seen before that. """ if self.inline_children: self.children = parser.parse_inline(self.children) elif isinstance(getattr(self, 'children', None), list): for child in se...
[ "def", "parse_inline", "(", "self", ")", ":", "if", "self", ".", "inline_children", ":", "self", ".", "children", "=", "parser", ".", "parse_inline", "(", "self", ".", "children", ")", "elif", "isinstance", "(", "getattr", "(", "self", ",", "'children'", ...
Inline parsing is postponed so that all link references are seen before that.
[ "Inline", "parsing", "is", "postponed", "so", "that", "all", "link", "references", "are", "seen", "before", "that", "." ]
1cd030b665fa37bad1f8b3a25a89ce1a7c491dde
https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/block.py#L59-L68
train
Parses inline elements of this element.
COALAIP/pycoalaip
coalaip/models.py
work_model_factory
def work_model_factory(*, validator=validators.is_work_model, **kwargs): """Generate a Work model. Expects ``data``, ``validator``, ``model_cls``, and ``ld_context`` as keyword arguments. Raises: :exc:`ModelError`: If a non-'AbstractWork' ``ld_type`` keyword argument is given. ...
python
def work_model_factory(*, validator=validators.is_work_model, **kwargs): """Generate a Work model. Expects ``data``, ``validator``, ``model_cls``, and ``ld_context`` as keyword arguments. Raises: :exc:`ModelError`: If a non-'AbstractWork' ``ld_type`` keyword argument is given. ...
[ "def", "work_model_factory", "(", "*", ",", "validator", "=", "validators", ".", "is_work_model", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'ld_type'", "]", "=", "'AbstractWork'", "return", "_model_factory", "(", "validator", "=", "validator", ",", ...
Generate a Work model. Expects ``data``, ``validator``, ``model_cls``, and ``ld_context`` as keyword arguments. Raises: :exc:`ModelError`: If a non-'AbstractWork' ``ld_type`` keyword argument is given.
[ "Generate", "a", "Work", "model", "." ]
cecc8f6ff4733f0525fafcee63647753e832f0be
https://github.com/COALAIP/pycoalaip/blob/cecc8f6ff4733f0525fafcee63647753e832f0be/coalaip/models.py#L241-L252
train
Generates a Work model.
COALAIP/pycoalaip
coalaip/models.py
manifestation_model_factory
def manifestation_model_factory(*, validator=validators.is_manifestation_model, ld_type='CreativeWork', **kwargs): """Generate a Manifestation model. Expects ``data``, ``validator``, ``model_cls``, ``ld_type``, and ``ld_context`` as keyword arguments. """ return _mod...
python
def manifestation_model_factory(*, validator=validators.is_manifestation_model, ld_type='CreativeWork', **kwargs): """Generate a Manifestation model. Expects ``data``, ``validator``, ``model_cls``, ``ld_type``, and ``ld_context`` as keyword arguments. """ return _mod...
[ "def", "manifestation_model_factory", "(", "*", ",", "validator", "=", "validators", ".", "is_manifestation_model", ",", "ld_type", "=", "'CreativeWork'", ",", "*", "*", "kwargs", ")", ":", "return", "_model_factory", "(", "validator", "=", "validator", ",", "ld...
Generate a Manifestation model. Expects ``data``, ``validator``, ``model_cls``, ``ld_type``, and ``ld_context`` as keyword arguments.
[ "Generate", "a", "Manifestation", "model", "." ]
cecc8f6ff4733f0525fafcee63647753e832f0be
https://github.com/COALAIP/pycoalaip/blob/cecc8f6ff4733f0525fafcee63647753e832f0be/coalaip/models.py#L255-L262
train
Generate a manifestation model.
COALAIP/pycoalaip
coalaip/models.py
right_model_factory
def right_model_factory(*, validator=validators.is_right_model, ld_type='Right', **kwargs): """Generate a Right model. Expects ``data``, ``validator``, ``model_cls``, ``ld_type``, and ``ld_context`` as keyword arguments. """ return _model_factory(validator=validator, ld_type...
python
def right_model_factory(*, validator=validators.is_right_model, ld_type='Right', **kwargs): """Generate a Right model. Expects ``data``, ``validator``, ``model_cls``, ``ld_type``, and ``ld_context`` as keyword arguments. """ return _model_factory(validator=validator, ld_type...
[ "def", "right_model_factory", "(", "*", ",", "validator", "=", "validators", ".", "is_right_model", ",", "ld_type", "=", "'Right'", ",", "*", "*", "kwargs", ")", ":", "return", "_model_factory", "(", "validator", "=", "validator", ",", "ld_type", "=", "ld_ty...
Generate a Right model. Expects ``data``, ``validator``, ``model_cls``, ``ld_type``, and ``ld_context`` as keyword arguments.
[ "Generate", "a", "Right", "model", "." ]
cecc8f6ff4733f0525fafcee63647753e832f0be
https://github.com/COALAIP/pycoalaip/blob/cecc8f6ff4733f0525fafcee63647753e832f0be/coalaip/models.py#L265-L272
train
Generate a Right model.
COALAIP/pycoalaip
coalaip/models.py
copyright_model_factory
def copyright_model_factory(*, validator=validators.is_copyright_model, **kwargs): """Generate a Copyright model. Expects ``data``, ``validator``, ``model_cls``, and ``ld_context`` as keyword arguments. Raises: :exc:`ModelError`: If a non-'Copyright' ``ld_type`` key...
python
def copyright_model_factory(*, validator=validators.is_copyright_model, **kwargs): """Generate a Copyright model. Expects ``data``, ``validator``, ``model_cls``, and ``ld_context`` as keyword arguments. Raises: :exc:`ModelError`: If a non-'Copyright' ``ld_type`` key...
[ "def", "copyright_model_factory", "(", "*", ",", "validator", "=", "validators", ".", "is_copyright_model", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'ld_type'", "]", "=", "'Copyright'", "return", "_model_factory", "(", "validator", "=", "validator", ...
Generate a Copyright model. Expects ``data``, ``validator``, ``model_cls``, and ``ld_context`` as keyword arguments. Raises: :exc:`ModelError`: If a non-'Copyright' ``ld_type`` keyword argument is given.
[ "Generate", "a", "Copyright", "model", "." ]
cecc8f6ff4733f0525fafcee63647753e832f0be
https://github.com/COALAIP/pycoalaip/blob/cecc8f6ff4733f0525fafcee63647753e832f0be/coalaip/models.py#L276-L288
train
Generate a Copyright model.
Pylons/pyramid_retry
src/pyramid_retry/__init__.py
RetryableExecutionPolicy
def RetryableExecutionPolicy(attempts=3, activate_hook=None): """ Create a :term:`execution policy` that catches any :term:`retryable error` and sends it through the pipeline again up to a maximum of ``attempts`` attempts. If ``activate_hook`` is set it will be consulted prior to each request t...
python
def RetryableExecutionPolicy(attempts=3, activate_hook=None): """ Create a :term:`execution policy` that catches any :term:`retryable error` and sends it through the pipeline again up to a maximum of ``attempts`` attempts. If ``activate_hook`` is set it will be consulted prior to each request t...
[ "def", "RetryableExecutionPolicy", "(", "attempts", "=", "3", ",", "activate_hook", "=", "None", ")", ":", "assert", "attempts", ">", "0", "def", "retry_policy", "(", "environ", ",", "router", ")", ":", "# make the original request", "request_ctx", "=", "router"...
Create a :term:`execution policy` that catches any :term:`retryable error` and sends it through the pipeline again up to a maximum of ``attempts`` attempts. If ``activate_hook`` is set it will be consulted prior to each request to determine if retries should be enabled. It should return a number > 0 ...
[ "Create", "a", ":", "term", ":", "execution", "policy", "that", "catches", "any", ":", "term", ":", "retryable", "error", "and", "sends", "it", "through", "the", "pipeline", "again", "up", "to", "a", "maximum", "of", "attempts", "attempts", "." ]
4518d0655159fcf5cf79c0d7d4c86e8315f16082
https://github.com/Pylons/pyramid_retry/blob/4518d0655159fcf5cf79c0d7d4c86e8315f16082/src/pyramid_retry/__init__.py#L59-L146
train
Returns a new execution policy that catches any failed or failed request.
Pylons/pyramid_retry
src/pyramid_retry/__init__.py
mark_error_retryable
def mark_error_retryable(error): """ Mark an exception instance or type as retryable. If this exception is caught by ``pyramid_retry`` then it may retry the request. """ if isinstance(error, Exception): alsoProvides(error, IRetryableError) elif inspect.isclass(error) and issubclass(erro...
python
def mark_error_retryable(error): """ Mark an exception instance or type as retryable. If this exception is caught by ``pyramid_retry`` then it may retry the request. """ if isinstance(error, Exception): alsoProvides(error, IRetryableError) elif inspect.isclass(error) and issubclass(erro...
[ "def", "mark_error_retryable", "(", "error", ")", ":", "if", "isinstance", "(", "error", ",", "Exception", ")", ":", "alsoProvides", "(", "error", ",", "IRetryableError", ")", "elif", "inspect", ".", "isclass", "(", "error", ")", "and", "issubclass", "(", ...
Mark an exception instance or type as retryable. If this exception is caught by ``pyramid_retry`` then it may retry the request.
[ "Mark", "an", "exception", "instance", "or", "type", "as", "retryable", ".", "If", "this", "exception", "is", "caught", "by", "pyramid_retry", "then", "it", "may", "retry", "the", "request", "." ]
4518d0655159fcf5cf79c0d7d4c86e8315f16082
https://github.com/Pylons/pyramid_retry/blob/4518d0655159fcf5cf79c0d7d4c86e8315f16082/src/pyramid_retry/__init__.py#L149-L161
train
Mark an exception instance or type as retryable.
Pylons/pyramid_retry
src/pyramid_retry/__init__.py
is_error_retryable
def is_error_retryable(request, exc): """ Return ``True`` if the exception is recognized as :term:`retryable error`. This will return ``False`` if the request is on its last attempt. This will return ``False`` if ``pyramid_retry`` is inactive for the request. """ if is_last_attempt(request...
python
def is_error_retryable(request, exc): """ Return ``True`` if the exception is recognized as :term:`retryable error`. This will return ``False`` if the request is on its last attempt. This will return ``False`` if ``pyramid_retry`` is inactive for the request. """ if is_last_attempt(request...
[ "def", "is_error_retryable", "(", "request", ",", "exc", ")", ":", "if", "is_last_attempt", "(", "request", ")", ":", "return", "False", "return", "(", "isinstance", "(", "exc", ",", "RetryableException", ")", "or", "IRetryableError", ".", "providedBy", "(", ...
Return ``True`` if the exception is recognized as :term:`retryable error`. This will return ``False`` if the request is on its last attempt. This will return ``False`` if ``pyramid_retry`` is inactive for the request.
[ "Return", "True", "if", "the", "exception", "is", "recognized", "as", ":", "term", ":", "retryable", "error", "." ]
4518d0655159fcf5cf79c0d7d4c86e8315f16082
https://github.com/Pylons/pyramid_retry/blob/4518d0655159fcf5cf79c0d7d4c86e8315f16082/src/pyramid_retry/__init__.py#L164-L179
train
Return True if the exception is recognized as retryable error.
Pylons/pyramid_retry
src/pyramid_retry/__init__.py
is_last_attempt
def is_last_attempt(request): """ Return ``True`` if the request is on its last attempt, meaning that ``pyramid_retry`` will not be issuing any new attempts, regardless of what happens when executing this request. This will return ``True`` if ``pyramid_retry`` is inactive for the request. ...
python
def is_last_attempt(request): """ Return ``True`` if the request is on its last attempt, meaning that ``pyramid_retry`` will not be issuing any new attempts, regardless of what happens when executing this request. This will return ``True`` if ``pyramid_retry`` is inactive for the request. ...
[ "def", "is_last_attempt", "(", "request", ")", ":", "environ", "=", "request", ".", "environ", "attempt", "=", "environ", ".", "get", "(", "'retry.attempt'", ")", "attempts", "=", "environ", ".", "get", "(", "'retry.attempts'", ")", "if", "attempt", "is", ...
Return ``True`` if the request is on its last attempt, meaning that ``pyramid_retry`` will not be issuing any new attempts, regardless of what happens when executing this request. This will return ``True`` if ``pyramid_retry`` is inactive for the request.
[ "Return", "True", "if", "the", "request", "is", "on", "its", "last", "attempt", "meaning", "that", "pyramid_retry", "will", "not", "be", "issuing", "any", "new", "attempts", "regardless", "of", "what", "happens", "when", "executing", "this", "request", "." ]
4518d0655159fcf5cf79c0d7d4c86e8315f16082
https://github.com/Pylons/pyramid_retry/blob/4518d0655159fcf5cf79c0d7d4c86e8315f16082/src/pyramid_retry/__init__.py#L182-L198
train
Returns True if the request is on its last attempt.
Pylons/pyramid_retry
src/pyramid_retry/__init__.py
includeme
def includeme(config): """ Activate the ``pyramid_retry`` execution policy in your application. This will add the :func:`pyramid_retry.RetryableErrorPolicy` with ``attempts`` pulled from the ``retry.attempts`` setting. The ``last_retry_attempt`` and ``retryable_error`` view predicates are regi...
python
def includeme(config): """ Activate the ``pyramid_retry`` execution policy in your application. This will add the :func:`pyramid_retry.RetryableErrorPolicy` with ``attempts`` pulled from the ``retry.attempts`` setting. The ``last_retry_attempt`` and ``retryable_error`` view predicates are regi...
[ "def", "includeme", "(", "config", ")", ":", "settings", "=", "config", ".", "get_settings", "(", ")", "config", ".", "add_view_predicate", "(", "'last_retry_attempt'", ",", "LastAttemptPredicate", ")", "config", ".", "add_view_predicate", "(", "'retryable_error'", ...
Activate the ``pyramid_retry`` execution policy in your application. This will add the :func:`pyramid_retry.RetryableErrorPolicy` with ``attempts`` pulled from the ``retry.attempts`` setting. The ``last_retry_attempt`` and ``retryable_error`` view predicates are registered. This should be include...
[ "Activate", "the", "pyramid_retry", "execution", "policy", "in", "your", "application", "." ]
4518d0655159fcf5cf79c0d7d4c86e8315f16082
https://github.com/Pylons/pyramid_retry/blob/4518d0655159fcf5cf79c0d7d4c86e8315f16082/src/pyramid_retry/__init__.py#L259-L292
train
Include pyramid_retry in Pyramid application.
gesellkammer/sndfileio
sndfileio/dsp.py
lowpass_cheby2
def lowpass_cheby2(samples, freq, sr, maxorder=12): # type: (np.ndarray, float, int, int) -> np.ndarray """ Cheby2-Lowpass Filter Filter data by passing data only below a certain frequency. The main purpose of this cheby2 filter is downsampling. This method will iteratively design a filter...
python
def lowpass_cheby2(samples, freq, sr, maxorder=12): # type: (np.ndarray, float, int, int) -> np.ndarray """ Cheby2-Lowpass Filter Filter data by passing data only below a certain frequency. The main purpose of this cheby2 filter is downsampling. This method will iteratively design a filter...
[ "def", "lowpass_cheby2", "(", "samples", ",", "freq", ",", "sr", ",", "maxorder", "=", "12", ")", ":", "# type: (np.ndarray, float, int, int) -> np.ndarray", "if", "freq", ">", "sr", "*", "0.5", ":", "raise", "ValueError", "(", "\"Can't filter freq. above nyquist\""...
Cheby2-Lowpass Filter Filter data by passing data only below a certain frequency. The main purpose of this cheby2 filter is downsampling. This method will iteratively design a filter, whose pass band frequency is determined dynamically, such that the values above the stop band frequency are lo...
[ "Cheby2", "-", "Lowpass", "Filter" ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/dsp.py#L8-L29
train
This method uses the cheby2 filter to filter data by passing data below a certain frequency sr and maxorder.
gesellkammer/sndfileio
sndfileio/dsp.py
lowpass_cheby2_coeffs
def lowpass_cheby2_coeffs(freq, sr, maxorder=12): # type: (float, int, int) -> Tuple[np.ndarray, np.ndarray, float] """ freq : The frequency above which signals are attenuated with 95 dB sr : Sampling rate in Hz. maxorder: Maximal order of the designed cheby2 filter Return...
python
def lowpass_cheby2_coeffs(freq, sr, maxorder=12): # type: (float, int, int) -> Tuple[np.ndarray, np.ndarray, float] """ freq : The frequency above which signals are attenuated with 95 dB sr : Sampling rate in Hz. maxorder: Maximal order of the designed cheby2 filter Return...
[ "def", "lowpass_cheby2_coeffs", "(", "freq", ",", "sr", ",", "maxorder", "=", "12", ")", ":", "# type: (float, int, int) -> Tuple[np.ndarray, np.ndarray, float]", "nyquist", "=", "sr", "*", "0.5", "# rp - maximum ripple of passband, rs - attenuation of stopband", "rp", ",", ...
freq : The frequency above which signals are attenuated with 95 dB sr : Sampling rate in Hz. maxorder: Maximal order of the designed cheby2 filter Returns --> (b coeffs, a coeffs, freq_passband)
[ "freq", ":", "The", "frequency", "above", "which", "signals", "are", "attenuated", "with", "95", "dB", "sr", ":", "Sampling", "rate", "in", "Hz", ".", "maxorder", ":", "Maximal", "order", "of", "the", "designed", "cheby2", "filter" ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/dsp.py#L32-L60
train
low - passcheby2 filter for a given frequency sr
gesellkammer/sndfileio
sndfileio/dsp.py
filter_butter_coeffs
def filter_butter_coeffs(filtertype, freq, samplerate, order=5): # type: (str, Union[float, Tuple[float, float]], int, int) -> Tuple[np.ndarray, np.ndarray] """ calculates the coefficients for a digital butterworth filter filtertype: 'low', 'high', 'band' freq : cutoff freq. in...
python
def filter_butter_coeffs(filtertype, freq, samplerate, order=5): # type: (str, Union[float, Tuple[float, float]], int, int) -> Tuple[np.ndarray, np.ndarray] """ calculates the coefficients for a digital butterworth filter filtertype: 'low', 'high', 'band' freq : cutoff freq. in...
[ "def", "filter_butter_coeffs", "(", "filtertype", ",", "freq", ",", "samplerate", ",", "order", "=", "5", ")", ":", "# type: (str, Union[float, Tuple[float, float]], int, int) -> Tuple[np.ndarray, np.ndarray]", "assert", "filtertype", "in", "(", "'low'", ",", "'high'", ",...
calculates the coefficients for a digital butterworth filter filtertype: 'low', 'high', 'band' freq : cutoff freq. in the case of 'band': (low, high) Returns --> (b, a)
[ "calculates", "the", "coefficients", "for", "a", "digital", "butterworth", "filter" ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/dsp.py#L63-L85
train
This function calculates the coefficients for a digital butterworth filter.
gesellkammer/sndfileio
sndfileio/dsp.py
filter_butter
def filter_butter(samples, samplerate, filtertype, freq, order=5): # type: (np.ndarray, int, str, float, int) -> np.ndarray """ Filters the samples with a digital butterworth filter samples : mono samples filtertype: 'low', 'band', 'high' freq : for low or high, the cutoff freq ...
python
def filter_butter(samples, samplerate, filtertype, freq, order=5): # type: (np.ndarray, int, str, float, int) -> np.ndarray """ Filters the samples with a digital butterworth filter samples : mono samples filtertype: 'low', 'band', 'high' freq : for low or high, the cutoff freq ...
[ "def", "filter_butter", "(", "samples", ",", "samplerate", ",", "filtertype", ",", "freq", ",", "order", "=", "5", ")", ":", "# type: (np.ndarray, int, str, float, int) -> np.ndarray", "assert", "filtertype", "in", "(", "'low'", ",", "'high'", ",", "'band'", ")", ...
Filters the samples with a digital butterworth filter samples : mono samples filtertype: 'low', 'band', 'high' freq : for low or high, the cutoff freq for band, (low, high) samplerate: the sampling-rate order : the order of the butterworth filter Returns --> the filt...
[ "Filters", "the", "samples", "with", "a", "digital", "butterworth", "filter" ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/dsp.py#L88-L106
train
Filter the samples with a digital butterworth filter
gesellkammer/sndfileio
sndfileio/dsp.py
filter_butter_plot_freqresponse
def filter_butter_plot_freqresponse(b, a, samplerate, numpoints=2000): # type: (Seq[float], Seq[float], int, int) -> None """ Plot the freq. response of the digital butterw. filter defined by the coeffs. (b, a) at `samplerate` Returns --> nothing See also: filter_butter_coeffs """ imp...
python
def filter_butter_plot_freqresponse(b, a, samplerate, numpoints=2000): # type: (Seq[float], Seq[float], int, int) -> None """ Plot the freq. response of the digital butterw. filter defined by the coeffs. (b, a) at `samplerate` Returns --> nothing See also: filter_butter_coeffs """ imp...
[ "def", "filter_butter_plot_freqresponse", "(", "b", ",", "a", ",", "samplerate", ",", "numpoints", "=", "2000", ")", ":", "# type: (Seq[float], Seq[float], int, int) -> None", "import", "matplotlib", ".", "pyplot", "as", "plt", "plt", ".", "figure", "(", "1", ")",...
Plot the freq. response of the digital butterw. filter defined by the coeffs. (b, a) at `samplerate` Returns --> nothing See also: filter_butter_coeffs
[ "Plot", "the", "freq", ".", "response", "of", "the", "digital", "butterw", ".", "filter", "defined", "by", "the", "coeffs", ".", "(", "b", "a", ")", "at", "samplerate" ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/dsp.py#L109-L127
train
Plot the freq. response of the digital butterw. filter
johnnoone/aioconsul
aioconsul/api.py
extract_blocking
def extract_blocking(obj): """Extract index and watch from :class:`Blocking` Parameters: obj (Blocking): the blocking object Returns: tuple: index and watch """ if isinstance(obj, tuple): try: a, b = obj except: raise TypeError("Not a Blocking...
python
def extract_blocking(obj): """Extract index and watch from :class:`Blocking` Parameters: obj (Blocking): the blocking object Returns: tuple: index and watch """ if isinstance(obj, tuple): try: a, b = obj except: raise TypeError("Not a Blocking...
[ "def", "extract_blocking", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "tuple", ")", ":", "try", ":", "a", ",", "b", "=", "obj", "except", ":", "raise", "TypeError", "(", "\"Not a Blocking object\"", ")", "else", ":", "a", ",", "b", "=...
Extract index and watch from :class:`Blocking` Parameters: obj (Blocking): the blocking object Returns: tuple: index and watch
[ "Extract", "index", "and", "watch", "from", ":", "class", ":", "Blocking" ]
02f7a529d7dc2e49bed942111067aa5faf320e90
https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/api.py#L110-L125
train
Extract index and watch from a blocking object.
johnnoone/aioconsul
aioconsul/api.py
consistency_middleware
def consistency_middleware(ctx, get_response): """Set consistency Order: 1. consistency request 2. "stale" / "consistent" parameters 3. ctx consistency """ async def middleware(request): params = request.setdefault("params", {}) consistency = request.pop("consistency", None...
python
def consistency_middleware(ctx, get_response): """Set consistency Order: 1. consistency request 2. "stale" / "consistent" parameters 3. ctx consistency """ async def middleware(request): params = request.setdefault("params", {}) consistency = request.pop("consistency", None...
[ "def", "consistency_middleware", "(", "ctx", ",", "get_response", ")", ":", "async", "def", "middleware", "(", "request", ")", ":", "params", "=", "request", ".", "setdefault", "(", "\"params\"", ",", "{", "}", ")", "consistency", "=", "request", ".", "pop...
Set consistency Order: 1. consistency request 2. "stale" / "consistent" parameters 3. ctx consistency
[ "Set", "consistency" ]
02f7a529d7dc2e49bed942111067aa5faf320e90
https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/api.py#L193-L209
train
A middleware that sets the consistency of the current context.
johnnoone/aioconsul
aioconsul/api.py
token_middleware
def token_middleware(ctx, get_response): """Reinject token and consistency into requests. """ async def middleware(request): params = request.setdefault('params', {}) if params.get("token") is None: params['token'] = ctx.token return await get_response(request) return...
python
def token_middleware(ctx, get_response): """Reinject token and consistency into requests. """ async def middleware(request): params = request.setdefault('params', {}) if params.get("token") is None: params['token'] = ctx.token return await get_response(request) return...
[ "def", "token_middleware", "(", "ctx", ",", "get_response", ")", ":", "async", "def", "middleware", "(", "request", ")", ":", "params", "=", "request", ".", "setdefault", "(", "'params'", ",", "{", "}", ")", "if", "params", ".", "get", "(", "\"token\"", ...
Reinject token and consistency into requests.
[ "Reinject", "token", "and", "consistency", "into", "requests", "." ]
02f7a529d7dc2e49bed942111067aa5faf320e90
https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/api.py#L212-L220
train
Reinject token and consistency into requests.
bitesofcode/projexui
projexui/widgets/xkeyvaluetreewidget.py
XKeyValueTreeWidget.addEntry
def addEntry(self, key='', value=''): """ Creates a new entry item for this widget. :param key | <str> value | <variant> """ img = resources.find('img/close.png') new_item = XTreeWidgetItem() new_item.setText(1, nat...
python
def addEntry(self, key='', value=''): """ Creates a new entry item for this widget. :param key | <str> value | <variant> """ img = resources.find('img/close.png') new_item = XTreeWidgetItem() new_item.setText(1, nat...
[ "def", "addEntry", "(", "self", ",", "key", "=", "''", ",", "value", "=", "''", ")", ":", "img", "=", "resources", ".", "find", "(", "'img/close.png'", ")", "new_item", "=", "XTreeWidgetItem", "(", ")", "new_item", ".", "setText", "(", "1", ",", "nat...
Creates a new entry item for this widget. :param key | <str> value | <variant>
[ "Creates", "a", "new", "entry", "item", "for", "this", "widget", ".", ":", "param", "key", "|", "<str", ">", "value", "|", "<variant", ">" ]
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xkeyvaluetreewidget.py#L41-L56
train
Adds a new entry item for this widget.
bitesofcode/projexui
projexui/widgets/xkeyvaluetreewidget.py
XKeyValueTreeWidget.dictionary
def dictionary(self): """ Returns a dictionary of the key/value pairing for the items in this widget. :return {<str> key: <str> value, ..} """ output = {} for i in range(self.topLevelItemCount() - 1): item = self.topLevelItem(i) ...
python
def dictionary(self): """ Returns a dictionary of the key/value pairing for the items in this widget. :return {<str> key: <str> value, ..} """ output = {} for i in range(self.topLevelItemCount() - 1): item = self.topLevelItem(i) ...
[ "def", "dictionary", "(", "self", ")", ":", "output", "=", "{", "}", "for", "i", "in", "range", "(", "self", ".", "topLevelItemCount", "(", ")", "-", "1", ")", ":", "item", "=", "self", ".", "topLevelItem", "(", "i", ")", "output", "[", "nativestri...
Returns a dictionary of the key/value pairing for the items in this widget. :return {<str> key: <str> value, ..}
[ "Returns", "a", "dictionary", "of", "the", "key", "/", "value", "pairing", "for", "the", "items", "in", "this", "widget", ".", ":", "return", "{", "<str", ">", "key", ":", "<str", ">", "value", "..", "}" ]
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xkeyvaluetreewidget.py#L58-L69
train
Returns a dictionary of the key value pairing for the items in this widget.
bitesofcode/projexui
projexui/widgets/xkeyvaluetreewidget.py
XKeyValueTreeWidget.handleClick
def handleClick(self, item, column): """ Handles when the user clicks on an item -- this method will listen for when the user clicks the 'add another item' item or when the user clicks on the remove icon next to the item. """ if item.text(0) == 'add another item': ...
python
def handleClick(self, item, column): """ Handles when the user clicks on an item -- this method will listen for when the user clicks the 'add another item' item or when the user clicks on the remove icon next to the item. """ if item.text(0) == 'add another item': ...
[ "def", "handleClick", "(", "self", ",", "item", ",", "column", ")", ":", "if", "item", ".", "text", "(", "0", ")", "==", "'add another item'", ":", "new_item", "=", "self", ".", "addEntry", "(", ")", "self", ".", "setCurrentItem", "(", "new_item", ",",...
Handles when the user clicks on an item -- this method will listen for when the user clicks the 'add another item' item or when the user clicks on the remove icon next to the item.
[ "Handles", "when", "the", "user", "clicks", "on", "an", "item", "--", "this", "method", "will", "listen", "for", "when", "the", "user", "clicks", "the", "add", "another", "item", "item", "or", "when", "the", "user", "clicks", "on", "the", "remove", "icon...
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xkeyvaluetreewidget.py#L71-L83
train
Handles the click event on an item.
bitesofcode/projexui
projexui/widgets/xkeyvaluetreewidget.py
XKeyValueTreeWidget.setDictionary
def setDictionary(self, props): """ Sets a dictionary of the key/value pairing for the items in this widget. :param props | {<str> key: <str> value, ..} """ if not self._initialized: self.setColumns(['', 'Property', 'Value']) ...
python
def setDictionary(self, props): """ Sets a dictionary of the key/value pairing for the items in this widget. :param props | {<str> key: <str> value, ..} """ if not self._initialized: self.setColumns(['', 'Property', 'Value']) ...
[ "def", "setDictionary", "(", "self", ",", "props", ")", ":", "if", "not", "self", ".", "_initialized", ":", "self", ".", "setColumns", "(", "[", "''", ",", "'Property'", ",", "'Value'", "]", ")", "self", ".", "setColumnWidth", "(", "0", ",", "22", ")...
Sets a dictionary of the key/value pairing for the items in this widget. :param props | {<str> key: <str> value, ..}
[ "Sets", "a", "dictionary", "of", "the", "key", "/", "value", "pairing", "for", "the", "items", "in", "this", "widget", ".", ":", "param", "props", "|", "{", "<str", ">", "key", ":", "<str", ">", "value", "..", "}" ]
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xkeyvaluetreewidget.py#L91-L115
train
Sets the dictionary of the key value pairing for the items in this widget.
bitesofcode/projexui
projexui/widgets/xganttwidget/xganttdepitem.py
XGanttDepItem.paint
def paint( self, painter, option, widget ): """ Overloads the paint method from QGraphicsPathItem to \ handle custom drawing of the path using this items \ pens and polygons. :param painter <QPainter> :param option <QGraphicsItemStyleOption> ...
python
def paint( self, painter, option, widget ): """ Overloads the paint method from QGraphicsPathItem to \ handle custom drawing of the path using this items \ pens and polygons. :param painter <QPainter> :param option <QGraphicsItemStyleOption> ...
[ "def", "paint", "(", "self", ",", "painter", ",", "option", ",", "widget", ")", ":", "super", "(", "XGanttDepItem", ",", "self", ")", ".", "paint", "(", "painter", ",", "option", ",", "widget", ")", "# redraw the poly to force-fill it", "if", "(", "self", ...
Overloads the paint method from QGraphicsPathItem to \ handle custom drawing of the path using this items \ pens and polygons. :param painter <QPainter> :param option <QGraphicsItemStyleOption> :param widget <QWidget>
[ "Overloads", "the", "paint", "method", "from", "QGraphicsPathItem", "to", "\\", "handle", "custom", "drawing", "of", "the", "path", "using", "this", "items", "\\", "pens", "and", "polygons", ".", ":", "param", "painter", "<QPainter", ">", ":", "param", "opti...
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xganttwidget/xganttdepitem.py#L42-L58
train
Override paint method to handle custom drawing of the path using the items defined in the constructor.
bitesofcode/projexui
projexui/widgets/xganttwidget/xganttdepitem.py
XGanttDepItem.rebuild
def rebuild( self ): """ Rebuilds the dependency path for this item. """ scene = self.scene() if ( not scene ): return sourcePos = self.sourceItem().viewItem().pos() sourceRect = self.sourceItem().viewItem().rect() ...
python
def rebuild( self ): """ Rebuilds the dependency path for this item. """ scene = self.scene() if ( not scene ): return sourcePos = self.sourceItem().viewItem().pos() sourceRect = self.sourceItem().viewItem().rect() ...
[ "def", "rebuild", "(", "self", ")", ":", "scene", "=", "self", ".", "scene", "(", ")", "if", "(", "not", "scene", ")", ":", "return", "sourcePos", "=", "self", ".", "sourceItem", "(", ")", ".", "viewItem", "(", ")", ".", "pos", "(", ")", "sourceR...
Rebuilds the dependency path for this item.
[ "Rebuilds", "the", "dependency", "path", "for", "this", "item", "." ]
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xganttwidget/xganttdepitem.py#L60-L95
train
Rebuilds the dependency path for this item.
kimdhamilton/merkle-proofs
merkleproof/utils.py
validate_proof
def validate_proof(proof, target_hash, merkle_root, hash_f=sha256): """ Takes a proof array, a target hash value, and a merkle root. Checks the validity of the proof and return true or false. :param proof: :param target_hash: :param merkle_root: :param hash_f: :return: whether proof is v...
python
def validate_proof(proof, target_hash, merkle_root, hash_f=sha256): """ Takes a proof array, a target hash value, and a merkle root. Checks the validity of the proof and return true or false. :param proof: :param target_hash: :param merkle_root: :param hash_f: :return: whether proof is v...
[ "def", "validate_proof", "(", "proof", ",", "target_hash", ",", "merkle_root", ",", "hash_f", "=", "sha256", ")", ":", "if", "not", "proof", ":", "# no siblings, single item tree, so the hash should also be the root", "return", "target_hash", "==", "merkle_root", "targe...
Takes a proof array, a target hash value, and a merkle root. Checks the validity of the proof and return true or false. :param proof: :param target_hash: :param merkle_root: :param hash_f: :return: whether proof is valid, Boolean
[ "Takes", "a", "proof", "array", "a", "target", "hash", "value", "and", "a", "merkle", "root", ".", "Checks", "the", "validity", "of", "the", "proof", "and", "return", "true", "or", "false", ".", ":", "param", "proof", ":", ":", "param", "target_hash", ...
77551cc65f72b50ac203f10a5069cb1a5b3ffb49
https://github.com/kimdhamilton/merkle-proofs/blob/77551cc65f72b50ac203f10a5069cb1a5b3ffb49/merkleproof/utils.py#L23-L53
train
Validate a single item tree proof.
starling-lab/rnlp
rnlp/parse.py
_writeBlock
def _writeBlock(block, blockID): '''writes the block to a file with the id''' with open("blockIDs.txt", "a") as fp: fp.write("blockID: " + str(blockID) + "\n") sentences = "" for sentence in block: sentences += sentence+"," fp.write("block sentences: "+sentences[:-1]+...
python
def _writeBlock(block, blockID): '''writes the block to a file with the id''' with open("blockIDs.txt", "a") as fp: fp.write("blockID: " + str(blockID) + "\n") sentences = "" for sentence in block: sentences += sentence+"," fp.write("block sentences: "+sentences[:-1]+...
[ "def", "_writeBlock", "(", "block", ",", "blockID", ")", ":", "with", "open", "(", "\"blockIDs.txt\"", ",", "\"a\"", ")", "as", "fp", ":", "fp", ".", "write", "(", "\"blockID: \"", "+", "str", "(", "blockID", ")", "+", "\"\\n\"", ")", "sentences", "=",...
writes the block to a file with the id
[ "writes", "the", "block", "to", "a", "file", "with", "the", "id" ]
72054cc2c0cbaea1d281bf3d56b271d4da29fc4a
https://github.com/starling-lab/rnlp/blob/72054cc2c0cbaea1d281bf3d56b271d4da29fc4a/rnlp/parse.py#L38-L46
train
writes the block to a file with the id
starling-lab/rnlp
rnlp/parse.py
_writeSentenceInBlock
def _writeSentenceInBlock(sentence, blockID, sentenceID): '''writes the sentence in a block to a file with the id''' with open("sentenceIDs.txt", "a") as fp: fp.write("sentenceID: "+str(blockID)+"_"+str(sentenceID)+"\n") fp.write("sentence string: "+sentence+"\n") fp.write("\n")
python
def _writeSentenceInBlock(sentence, blockID, sentenceID): '''writes the sentence in a block to a file with the id''' with open("sentenceIDs.txt", "a") as fp: fp.write("sentenceID: "+str(blockID)+"_"+str(sentenceID)+"\n") fp.write("sentence string: "+sentence+"\n") fp.write("\n")
[ "def", "_writeSentenceInBlock", "(", "sentence", ",", "blockID", ",", "sentenceID", ")", ":", "with", "open", "(", "\"sentenceIDs.txt\"", ",", "\"a\"", ")", "as", "fp", ":", "fp", ".", "write", "(", "\"sentenceID: \"", "+", "str", "(", "blockID", ")", "+",...
writes the sentence in a block to a file with the id
[ "writes", "the", "sentence", "in", "a", "block", "to", "a", "file", "with", "the", "id" ]
72054cc2c0cbaea1d281bf3d56b271d4da29fc4a
https://github.com/starling-lab/rnlp/blob/72054cc2c0cbaea1d281bf3d56b271d4da29fc4a/rnlp/parse.py#L49-L54
train
writes the sentence in a block to a file with the id
starling-lab/rnlp
rnlp/parse.py
_writeWordFromSentenceInBlock
def _writeWordFromSentenceInBlock(word, blockID, sentenceID, wordID): '''writes the word from a sentence in a block to a file with the id''' with open("wordIDs.txt", "a") as fp: fp.write("wordID: " + str(blockID) + "_" + str(sentenceID) + "_" + str(wordID) + "\n") fp.write("word...
python
def _writeWordFromSentenceInBlock(word, blockID, sentenceID, wordID): '''writes the word from a sentence in a block to a file with the id''' with open("wordIDs.txt", "a") as fp: fp.write("wordID: " + str(blockID) + "_" + str(sentenceID) + "_" + str(wordID) + "\n") fp.write("word...
[ "def", "_writeWordFromSentenceInBlock", "(", "word", ",", "blockID", ",", "sentenceID", ",", "wordID", ")", ":", "with", "open", "(", "\"wordIDs.txt\"", ",", "\"a\"", ")", "as", "fp", ":", "fp", ".", "write", "(", "\"wordID: \"", "+", "str", "(", "blockID"...
writes the word from a sentence in a block to a file with the id
[ "writes", "the", "word", "from", "a", "sentence", "in", "a", "block", "to", "a", "file", "with", "the", "id" ]
72054cc2c0cbaea1d281bf3d56b271d4da29fc4a
https://github.com/starling-lab/rnlp/blob/72054cc2c0cbaea1d281bf3d56b271d4da29fc4a/rnlp/parse.py#L57-L63
train
writes the word from a sentence in a block to a file with the id
starling-lab/rnlp
rnlp/parse.py
_writeBk
def _writeBk(target="sentenceContainsTarget(+SID,+WID).", treeDepth="3", nodeSize="3", numOfClauses="8"): """ Writes a background file to disk. :param target: Target predicate with modes. :type target: str. :param treeDepth: Depth of the tree. :type treeDepth: str. :param nodeS...
python
def _writeBk(target="sentenceContainsTarget(+SID,+WID).", treeDepth="3", nodeSize="3", numOfClauses="8"): """ Writes a background file to disk. :param target: Target predicate with modes. :type target: str. :param treeDepth: Depth of the tree. :type treeDepth: str. :param nodeS...
[ "def", "_writeBk", "(", "target", "=", "\"sentenceContainsTarget(+SID,+WID).\"", ",", "treeDepth", "=", "\"3\"", ",", "nodeSize", "=", "\"3\"", ",", "numOfClauses", "=", "\"8\"", ")", ":", "with", "open", "(", "'bk.txt'", ",", "'w'", ")", "as", "bk", ":", ...
Writes a background file to disk. :param target: Target predicate with modes. :type target: str. :param treeDepth: Depth of the tree. :type treeDepth: str. :param nodeSize: Maximum size of each node in the tree. :type nodeSize: str. :param numOfClauses: Number of clauses in total. :type...
[ "Writes", "a", "background", "file", "to", "disk", "." ]
72054cc2c0cbaea1d281bf3d56b271d4da29fc4a
https://github.com/starling-lab/rnlp/blob/72054cc2c0cbaea1d281bf3d56b271d4da29fc4a/rnlp/parse.py#L72-L111
train
Writes a background file to disk.
starling-lab/rnlp
rnlp/parse.py
makeIdentifiers
def makeIdentifiers(blocks, target="sentenceContainsTarget(+SID,+WID).", treeDepth="3", nodeSize="3", numOfClauses="8"): """ Make unique identifiers for components of the block and write to files. :param blocks: Blocks of sentences (likely the output of ``textprocessi...
python
def makeIdentifiers(blocks, target="sentenceContainsTarget(+SID,+WID).", treeDepth="3", nodeSize="3", numOfClauses="8"): """ Make unique identifiers for components of the block and write to files. :param blocks: Blocks of sentences (likely the output of ``textprocessi...
[ "def", "makeIdentifiers", "(", "blocks", ",", "target", "=", "\"sentenceContainsTarget(+SID,+WID).\"", ",", "treeDepth", "=", "\"3\"", ",", "nodeSize", "=", "\"3\"", ",", "numOfClauses", "=", "\"8\"", ")", ":", "blockID", ",", "sentenceID", ",", "wordID", "=", ...
Make unique identifiers for components of the block and write to files. :param blocks: Blocks of sentences (likely the output of ``textprocessing.getBlocks``). :type blocks: list :param target: Target to write to the background file (another option might be ``blockCont...
[ "Make", "unique", "identifiers", "for", "components", "of", "the", "block", "and", "write", "to", "files", "." ]
72054cc2c0cbaea1d281bf3d56b271d4da29fc4a
https://github.com/starling-lab/rnlp/blob/72054cc2c0cbaea1d281bf3d56b271d4da29fc4a/rnlp/parse.py#L114-L278
train
This function creates unique identifiers for the blocks of sentences and writes to files.
mikhaildubov/AST-text-analysis
east/asts/easa.py
EnhancedAnnotatedSuffixArray.traverse_depth_first_pre_order
def traverse_depth_first_pre_order(self, callback): """Visits the internal "nodes" of the enhanced suffix array in depth-first pre-order. Based on Abouelhoda et al. (2004). """ n = len(self.suftab) root = [0, 0, n - 1, ""] # <l, i, j, char> def _traverse_top_down(inter...
python
def traverse_depth_first_pre_order(self, callback): """Visits the internal "nodes" of the enhanced suffix array in depth-first pre-order. Based on Abouelhoda et al. (2004). """ n = len(self.suftab) root = [0, 0, n - 1, ""] # <l, i, j, char> def _traverse_top_down(inter...
[ "def", "traverse_depth_first_pre_order", "(", "self", ",", "callback", ")", ":", "n", "=", "len", "(", "self", ".", "suftab", ")", "root", "=", "[", "0", ",", "0", ",", "n", "-", "1", ",", "\"\"", "]", "# <l, i, j, char>", "def", "_traverse_top_down", ...
Visits the internal "nodes" of the enhanced suffix array in depth-first pre-order. Based on Abouelhoda et al. (2004).
[ "Visits", "the", "internal", "nodes", "of", "the", "enhanced", "suffix", "array", "in", "depth", "-", "first", "pre", "-", "order", "." ]
055ad8d2492c100bbbaa25309ec1074bdf1dfaa5
https://github.com/mikhaildubov/AST-text-analysis/blob/055ad8d2492c100bbbaa25309ec1074bdf1dfaa5/east/asts/easa.py#L38-L55
train
Visits the internal nodes of the enhanced suffix array in depth - first pre - order.
mikhaildubov/AST-text-analysis
east/asts/easa.py
EnhancedAnnotatedSuffixArray.traverse_depth_first_post_order
def traverse_depth_first_post_order(self, callback): """Visits the internal "nodes" of the enhanced suffix array in depth-first post-order. Kasai et. al. (2001), Abouelhoda et al. (2004). """ # a. Reimplement without python lists?.. # b. Interface will require it to have not int...
python
def traverse_depth_first_post_order(self, callback): """Visits the internal "nodes" of the enhanced suffix array in depth-first post-order. Kasai et. al. (2001), Abouelhoda et al. (2004). """ # a. Reimplement without python lists?.. # b. Interface will require it to have not int...
[ "def", "traverse_depth_first_post_order", "(", "self", ",", "callback", ")", ":", "# a. Reimplement without python lists?..", "# b. Interface will require it to have not internal nodes only?..", "# (but actually this implementation gives a ~2x gain of performance)", "last_interval", "=", ...
Visits the internal "nodes" of the enhanced suffix array in depth-first post-order. Kasai et. al. (2001), Abouelhoda et al. (2004).
[ "Visits", "the", "internal", "nodes", "of", "the", "enhanced", "suffix", "array", "in", "depth", "-", "first", "post", "-", "order", "." ]
055ad8d2492c100bbbaa25309ec1074bdf1dfaa5
https://github.com/mikhaildubov/AST-text-analysis/blob/055ad8d2492c100bbbaa25309ec1074bdf1dfaa5/east/asts/easa.py#L57-L85
train
Visit the internal nodes of the enhanced suffix array in depth - first post - order.
mikhaildubov/AST-text-analysis
east/asts/easa.py
EnhancedAnnotatedSuffixArray._compute_suftab
def _compute_suftab(self, string): """Computes the suffix array of a string in O(n). The code is based on that from the pysuffix library (https://code.google.com/p/pysuffix/). Kärkkäinen & Sanders (2003). """ n = len(string) string += (unichr(1) * 3) suftab = np...
python
def _compute_suftab(self, string): """Computes the suffix array of a string in O(n). The code is based on that from the pysuffix library (https://code.google.com/p/pysuffix/). Kärkkäinen & Sanders (2003). """ n = len(string) string += (unichr(1) * 3) suftab = np...
[ "def", "_compute_suftab", "(", "self", ",", "string", ")", ":", "n", "=", "len", "(", "string", ")", "string", "+=", "(", "unichr", "(", "1", ")", "*", "3", ")", "suftab", "=", "np", ".", "zeros", "(", "n", ",", "dtype", "=", "np", ".", "int", ...
Computes the suffix array of a string in O(n). The code is based on that from the pysuffix library (https://code.google.com/p/pysuffix/). Kärkkäinen & Sanders (2003).
[ "Computes", "the", "suffix", "array", "of", "a", "string", "in", "O", "(", "n", ")", "." ]
055ad8d2492c100bbbaa25309ec1074bdf1dfaa5
https://github.com/mikhaildubov/AST-text-analysis/blob/055ad8d2492c100bbbaa25309ec1074bdf1dfaa5/east/asts/easa.py#L141-L153
train
Computes the suffix array of a string in O ( n ).
mikhaildubov/AST-text-analysis
east/asts/easa.py
EnhancedAnnotatedSuffixArray._compute_lcptab
def _compute_lcptab(self, string, suftab): """Computes the LCP array in O(n) based on the input string & its suffix array. Kasai et al. (2001). """ n = len(suftab) rank = [0] * n for i in xrange(n): rank[suftab[i]] = i lcptab = np.zeros(n, dtype=np.in...
python
def _compute_lcptab(self, string, suftab): """Computes the LCP array in O(n) based on the input string & its suffix array. Kasai et al. (2001). """ n = len(suftab) rank = [0] * n for i in xrange(n): rank[suftab[i]] = i lcptab = np.zeros(n, dtype=np.in...
[ "def", "_compute_lcptab", "(", "self", ",", "string", ",", "suftab", ")", ":", "n", "=", "len", "(", "suftab", ")", "rank", "=", "[", "0", "]", "*", "n", "for", "i", "in", "xrange", "(", "n", ")", ":", "rank", "[", "suftab", "[", "i", "]", "]...
Computes the LCP array in O(n) based on the input string & its suffix array. Kasai et al. (2001).
[ "Computes", "the", "LCP", "array", "in", "O", "(", "n", ")", "based", "on", "the", "input", "string", "&", "its", "suffix", "array", "." ]
055ad8d2492c100bbbaa25309ec1074bdf1dfaa5
https://github.com/mikhaildubov/AST-text-analysis/blob/055ad8d2492c100bbbaa25309ec1074bdf1dfaa5/east/asts/easa.py#L247-L266
train
Computes the LCP array in O ( n ) based on the input string and its suffix array.
mikhaildubov/AST-text-analysis
east/asts/easa.py
EnhancedAnnotatedSuffixArray._compute_childtab
def _compute_childtab(self, lcptab): """Computes the child 'up' and 'down' arrays in O(n) based on the LCP table. Abouelhoda et al. (2004). """ last_index = -1 stack = [0] n = len(lcptab) childtab_up = np.zeros(n, dtype=np.int) # Zeros / -1 ? childtab_do...
python
def _compute_childtab(self, lcptab): """Computes the child 'up' and 'down' arrays in O(n) based on the LCP table. Abouelhoda et al. (2004). """ last_index = -1 stack = [0] n = len(lcptab) childtab_up = np.zeros(n, dtype=np.int) # Zeros / -1 ? childtab_do...
[ "def", "_compute_childtab", "(", "self", ",", "lcptab", ")", ":", "last_index", "=", "-", "1", "stack", "=", "[", "0", "]", "n", "=", "len", "(", "lcptab", ")", "childtab_up", "=", "np", ".", "zeros", "(", "n", ",", "dtype", "=", "np", ".", "int"...
Computes the child 'up' and 'down' arrays in O(n) based on the LCP table. Abouelhoda et al. (2004).
[ "Computes", "the", "child", "up", "and", "down", "arrays", "in", "O", "(", "n", ")", "based", "on", "the", "LCP", "table", "." ]
055ad8d2492c100bbbaa25309ec1074bdf1dfaa5
https://github.com/mikhaildubov/AST-text-analysis/blob/055ad8d2492c100bbbaa25309ec1074bdf1dfaa5/east/asts/easa.py#L268-L287
train
Computes the child up and down arrays in O ( n ) based on the LCP table.
mikhaildubov/AST-text-analysis
east/asts/easa.py
EnhancedAnnotatedSuffixArray._compute_childtab_next_l_index
def _compute_childtab_next_l_index(self, lcptab): """Computes the child 'next l index' array in O(n) based on the LCP table. Abouelhoda et al. (2004). """ stack = [0] n = len(lcptab) childtab_next_l_index = np.zeros(n, dtype=np.int) # Zeros / -1 ? for i in xrang...
python
def _compute_childtab_next_l_index(self, lcptab): """Computes the child 'next l index' array in O(n) based on the LCP table. Abouelhoda et al. (2004). """ stack = [0] n = len(lcptab) childtab_next_l_index = np.zeros(n, dtype=np.int) # Zeros / -1 ? for i in xrang...
[ "def", "_compute_childtab_next_l_index", "(", "self", ",", "lcptab", ")", ":", "stack", "=", "[", "0", "]", "n", "=", "len", "(", "lcptab", ")", "childtab_next_l_index", "=", "np", ".", "zeros", "(", "n", ",", "dtype", "=", "np", ".", "int", ")", "# ...
Computes the child 'next l index' array in O(n) based on the LCP table. Abouelhoda et al. (2004).
[ "Computes", "the", "child", "next", "l", "index", "array", "in", "O", "(", "n", ")", "based", "on", "the", "LCP", "table", "." ]
055ad8d2492c100bbbaa25309ec1074bdf1dfaa5
https://github.com/mikhaildubov/AST-text-analysis/blob/055ad8d2492c100bbbaa25309ec1074bdf1dfaa5/east/asts/easa.py#L289-L304
train
Computes the child next l index array in O ( n ) based on the LCP table.
mikhaildubov/AST-text-analysis
east/asts/easa.py
EnhancedAnnotatedSuffixArray._compute_anntab
def _compute_anntab(self, suftab, lcptab): """Computes the annotations array in O(n) by "traversing" the suffix array. Based on ideas from Abouelhoda et al. (2004) and Dubov & Chernyak (2013). """ n = len(suftab) anntab = np.zeros(n, dtype=np.int) # Zeros / -1 ? def pr...
python
def _compute_anntab(self, suftab, lcptab): """Computes the annotations array in O(n) by "traversing" the suffix array. Based on ideas from Abouelhoda et al. (2004) and Dubov & Chernyak (2013). """ n = len(suftab) anntab = np.zeros(n, dtype=np.int) # Zeros / -1 ? def pr...
[ "def", "_compute_anntab", "(", "self", ",", "suftab", ",", "lcptab", ")", ":", "n", "=", "len", "(", "suftab", ")", "anntab", "=", "np", ".", "zeros", "(", "n", ",", "dtype", "=", "np", ".", "int", ")", "# Zeros / -1 ?", "def", "process_node", "(", ...
Computes the annotations array in O(n) by "traversing" the suffix array. Based on ideas from Abouelhoda et al. (2004) and Dubov & Chernyak (2013).
[ "Computes", "the", "annotations", "array", "in", "O", "(", "n", ")", "by", "traversing", "the", "suffix", "array", "." ]
055ad8d2492c100bbbaa25309ec1074bdf1dfaa5
https://github.com/mikhaildubov/AST-text-analysis/blob/055ad8d2492c100bbbaa25309ec1074bdf1dfaa5/east/asts/easa.py#L306-L331
train
Computes the annotations array in O ( n ) by traversing the suffix array and computing the annotation array in O ( n ) by traversing the suffix array and computing the annotation array in O ( n ) by computing the annotations array in O ( n ) by traversing the suffix array.
talkincode/txradius
txradius/radius/packet.py
Packet.CreateReply
def CreateReply(self, **attributes): """Create a new packet as a reply to this one. This method makes sure the authenticator and secret are copied over to the new instance. """ return Packet(id=self.id, secret=self.secret, authenticator=self.authenticator, d...
python
def CreateReply(self, **attributes): """Create a new packet as a reply to this one. This method makes sure the authenticator and secret are copied over to the new instance. """ return Packet(id=self.id, secret=self.secret, authenticator=self.authenticator, d...
[ "def", "CreateReply", "(", "self", ",", "*", "*", "attributes", ")", ":", "return", "Packet", "(", "id", "=", "self", ".", "id", ",", "secret", "=", "self", ".", "secret", ",", "authenticator", "=", "self", ".", "authenticator", ",", "dict", "=", "se...
Create a new packet as a reply to this one. This method makes sure the authenticator and secret are copied over to the new instance.
[ "Create", "a", "new", "packet", "as", "a", "reply", "to", "this", "one", ".", "This", "method", "makes", "sure", "the", "authenticator", "and", "secret", "are", "copied", "over", "to", "the", "new", "instance", "." ]
b86fdbc9be41183680b82b07d3a8e8ea10926e01
https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/radius/packet.py#L103-L110
train
Create a new packet as a reply to this one.
talkincode/txradius
txradius/radius/packet.py
Packet._DecodeKey
def _DecodeKey(self, key): """Turn a key into a string if possible""" if self.dict.attrindex.HasBackward(key): return self.dict.attrindex.GetBackward(key) return key
python
def _DecodeKey(self, key): """Turn a key into a string if possible""" if self.dict.attrindex.HasBackward(key): return self.dict.attrindex.GetBackward(key) return key
[ "def", "_DecodeKey", "(", "self", ",", "key", ")", ":", "if", "self", ".", "dict", ".", "attrindex", ".", "HasBackward", "(", "key", ")", ":", "return", "self", ".", "dict", ".", "attrindex", ".", "GetBackward", "(", "key", ")", "return", "key" ]
Turn a key into a string if possible
[ "Turn", "a", "key", "into", "a", "string", "if", "possible" ]
b86fdbc9be41183680b82b07d3a8e8ea10926e01
https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/radius/packet.py#L146-L151
train
Turn a key into a string if possible
talkincode/txradius
txradius/radius/packet.py
Packet.AddAttribute
def AddAttribute(self, key, value): """Add an attribute to the packet. :param key: attribute name or identification :type key: string, attribute code or (vendor code, attribute code) tuple :param value: value :type value: depends on type of attribute ...
python
def AddAttribute(self, key, value): """Add an attribute to the packet. :param key: attribute name or identification :type key: string, attribute code or (vendor code, attribute code) tuple :param value: value :type value: depends on type of attribute ...
[ "def", "AddAttribute", "(", "self", ",", "key", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "list", ")", ":", "values", "=", "value", "else", ":", "values", "=", "[", "value", "]", "(", "key", ",", "values", ")", "=", "self", "...
Add an attribute to the packet. :param key: attribute name or identification :type key: string, attribute code or (vendor code, attribute code) tuple :param value: value :type value: depends on type of attribute
[ "Add", "an", "attribute", "to", "the", "packet", "." ]
b86fdbc9be41183680b82b07d3a8e8ea10926e01
https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/radius/packet.py#L153-L167
train
Add an attribute to the packet.
talkincode/txradius
txradius/radius/packet.py
Packet.CreateAuthenticator
def CreateAuthenticator(): """Create a packet autenticator. All RADIUS packets contain a sixteen byte authenticator which is used to authenticate replies from the RADIUS server and in the password hiding algorithm. This function returns a suitable random string that can be used as an aut...
python
def CreateAuthenticator(): """Create a packet autenticator. All RADIUS packets contain a sixteen byte authenticator which is used to authenticate replies from the RADIUS server and in the password hiding algorithm. This function returns a suitable random string that can be used as an aut...
[ "def", "CreateAuthenticator", "(", ")", ":", "data", "=", "[", "]", "for", "i", "in", "range", "(", "16", ")", ":", "data", ".", "append", "(", "random_generator", ".", "randrange", "(", "0", ",", "256", ")", ")", "if", "six", ".", "PY3", ":", "r...
Create a packet autenticator. All RADIUS packets contain a sixteen byte authenticator which is used to authenticate replies from the RADIUS server and in the password hiding algorithm. This function returns a suitable random string that can be used as an authenticator. :return: valid pa...
[ "Create", "a", "packet", "autenticator", ".", "All", "RADIUS", "packets", "contain", "a", "sixteen", "byte", "authenticator", "which", "is", "used", "to", "authenticate", "replies", "from", "the", "RADIUS", "server", "and", "in", "the", "password", "hiding", "...
b86fdbc9be41183680b82b07d3a8e8ea10926e01
https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/radius/packet.py#L208-L224
train
Create a packet authenticator which can be used to authenticate replies from the RADIUS server and in the password hiding algorithm.
talkincode/txradius
txradius/radius/packet.py
Packet.ReplyPacket
def ReplyPacket(self): """Create a ready-to-transmit authentication reply packet. Returns a RADIUS packet which can be directly transmitted to a RADIUS server. This differs with Packet() in how the authenticator is calculated. :return: raw packet :rtype: string ...
python
def ReplyPacket(self): """Create a ready-to-transmit authentication reply packet. Returns a RADIUS packet which can be directly transmitted to a RADIUS server. This differs with Packet() in how the authenticator is calculated. :return: raw packet :rtype: string ...
[ "def", "ReplyPacket", "(", "self", ")", ":", "assert", "(", "self", ".", "authenticator", ")", "assert", "(", "self", ".", "secret", "is", "not", "None", ")", "attr", "=", "self", ".", "_PktEncodeAttributes", "(", ")", "header", "=", "struct", ".", "pa...
Create a ready-to-transmit authentication reply packet. Returns a RADIUS packet which can be directly transmitted to a RADIUS server. This differs with Packet() in how the authenticator is calculated. :return: raw packet :rtype: string
[ "Create", "a", "ready", "-", "to", "-", "transmit", "authentication", "reply", "packet", ".", "Returns", "a", "RADIUS", "packet", "which", "can", "be", "directly", "transmitted", "to", "a", "RADIUS", "server", ".", "This", "differs", "with", "Packet", "()", ...
b86fdbc9be41183680b82b07d3a8e8ea10926e01
https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/radius/packet.py#L237-L254
train
Create a ready - to - transmit authentication reply packet.
talkincode/txradius
txradius/radius/packet.py
Packet.DecodePacket
def DecodePacket(self, packet): """Initialize the object from raw packet data. Decode a packet as received from the network and decode it. :param packet: raw packet :type packet: string""" try: (self.code, self.id, length, self.authenticator) = \ ...
python
def DecodePacket(self, packet): """Initialize the object from raw packet data. Decode a packet as received from the network and decode it. :param packet: raw packet :type packet: string""" try: (self.code, self.id, length, self.authenticator) = \ ...
[ "def", "DecodePacket", "(", "self", ",", "packet", ")", ":", "try", ":", "(", "self", ".", "code", ",", "self", ".", "id", ",", "length", ",", "self", ".", "authenticator", ")", "=", "struct", ".", "unpack", "(", "'!BBH16s'", ",", "packet", "[", "0...
Initialize the object from raw packet data. Decode a packet as received from the network and decode it. :param packet: raw packet :type packet: string
[ "Initialize", "the", "object", "from", "raw", "packet", "data", ".", "Decode", "a", "packet", "as", "received", "from", "the", "network", "and", "decode", "it", "." ]
b86fdbc9be41183680b82b07d3a8e8ea10926e01
https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/radius/packet.py#L308-L350
train
Decode a packet into a dictionary.
talkincode/txradius
txradius/radius/packet.py
AuthPacket.RequestPacket
def RequestPacket(self): """Create a ready-to-transmit authentication request packet. Return a RADIUS packet which can be directly transmitted to a RADIUS server. :return: raw packet :rtype: string """ attr = self._PktEncodeAttributes() if self.authenti...
python
def RequestPacket(self): """Create a ready-to-transmit authentication request packet. Return a RADIUS packet which can be directly transmitted to a RADIUS server. :return: raw packet :rtype: string """ attr = self._PktEncodeAttributes() if self.authenti...
[ "def", "RequestPacket", "(", "self", ")", ":", "attr", "=", "self", ".", "_PktEncodeAttributes", "(", ")", "if", "self", ".", "authenticator", "is", "None", ":", "self", ".", "authenticator", "=", "self", ".", "CreateAuthenticator", "(", ")", "if", "self",...
Create a ready-to-transmit authentication request packet. Return a RADIUS packet which can be directly transmitted to a RADIUS server. :return: raw packet :rtype: string
[ "Create", "a", "ready", "-", "to", "-", "transmit", "authentication", "request", "packet", ".", "Return", "a", "RADIUS", "packet", "which", "can", "be", "directly", "transmitted", "to", "a", "RADIUS", "server", "." ]
b86fdbc9be41183680b82b07d3a8e8ea10926e01
https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/radius/packet.py#L383-L402
train
Create a ready - to - transmit authentication request packet.
talkincode/txradius
txradius/radius/packet.py
AuthPacket.PwDecrypt
def PwDecrypt(self, password): """Unobfuscate a RADIUS password. RADIUS hides passwords in packets by using an algorithm based on the MD5 hash of the packet authenticator and RADIUS secret. This function reverses the obfuscation process. :param password: obfuscated form of password ...
python
def PwDecrypt(self, password): """Unobfuscate a RADIUS password. RADIUS hides passwords in packets by using an algorithm based on the MD5 hash of the packet authenticator and RADIUS secret. This function reverses the obfuscation process. :param password: obfuscated form of password ...
[ "def", "PwDecrypt", "(", "self", ",", "password", ")", ":", "buf", "=", "password", "pw", "=", "six", ".", "b", "(", "''", ")", "last", "=", "self", ".", "authenticator", "while", "buf", ":", "hash", "=", "md5_constructor", "(", "self", ".", "secret"...
Unobfuscate a RADIUS password. RADIUS hides passwords in packets by using an algorithm based on the MD5 hash of the packet authenticator and RADIUS secret. This function reverses the obfuscation process. :param password: obfuscated form of password :type password: binary string ...
[ "Unobfuscate", "a", "RADIUS", "password", ".", "RADIUS", "hides", "passwords", "in", "packets", "by", "using", "an", "algorithm", "based", "on", "the", "MD5", "hash", "of", "the", "packet", "authenticator", "and", "RADIUS", "secret", ".", "This", "function", ...
b86fdbc9be41183680b82b07d3a8e8ea10926e01
https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/radius/packet.py#L404-L432
train
This function decrypts a RADIUS password.
talkincode/txradius
txradius/radius/packet.py
AuthPacket.PwCrypt
def PwCrypt(self, password): """Obfuscate password. RADIUS hides passwords in packets by using an algorithm based on the MD5 hash of the packet authenticator and RADIUS secret. If no authenticator has been set before calling PwCrypt one is created automatically. Changing the auth...
python
def PwCrypt(self, password): """Obfuscate password. RADIUS hides passwords in packets by using an algorithm based on the MD5 hash of the packet authenticator and RADIUS secret. If no authenticator has been set before calling PwCrypt one is created automatically. Changing the auth...
[ "def", "PwCrypt", "(", "self", ",", "password", ")", ":", "if", "self", ".", "authenticator", "is", "None", ":", "self", ".", "authenticator", "=", "self", ".", "CreateAuthenticator", "(", ")", "if", "isinstance", "(", "password", ",", "six", ".", "text_...
Obfuscate password. RADIUS hides passwords in packets by using an algorithm based on the MD5 hash of the packet authenticator and RADIUS secret. If no authenticator has been set before calling PwCrypt one is created automatically. Changing the authenticator after setting a passwo...
[ "Obfuscate", "password", ".", "RADIUS", "hides", "passwords", "in", "packets", "by", "using", "an", "algorithm", "based", "on", "the", "MD5", "hash", "of", "the", "packet", "authenticator", "and", "RADIUS", "secret", ".", "If", "no", "authenticator", "has", ...
b86fdbc9be41183680b82b07d3a8e8ea10926e01
https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/radius/packet.py#L434-L474
train
Obfuscate a password using an MD5 hash of the authenticator and RADIUS - specific secret.
talkincode/txradius
txradius/radius/packet.py
AcctPacket.CreateReply
def CreateReply(self, **attributes): """Create a new packet as a reply to this one. This method makes sure the authenticator and secret are copied over to the new instance. """ return AcctPacket(AccountingResponse, self.id, self.secret, self.authenticator, dict=self.d...
python
def CreateReply(self, **attributes): """Create a new packet as a reply to this one. This method makes sure the authenticator and secret are copied over to the new instance. """ return AcctPacket(AccountingResponse, self.id, self.secret, self.authenticator, dict=self.d...
[ "def", "CreateReply", "(", "self", ",", "*", "*", "attributes", ")", ":", "return", "AcctPacket", "(", "AccountingResponse", ",", "self", ".", "id", ",", "self", ".", "secret", ",", "self", ".", "authenticator", ",", "dict", "=", "self", ".", "dict", "...
Create a new packet as a reply to this one. This method makes sure the authenticator and secret are copied over to the new instance.
[ "Create", "a", "new", "packet", "as", "a", "reply", "to", "this", "one", ".", "This", "method", "makes", "sure", "the", "authenticator", "and", "secret", "are", "copied", "over", "to", "the", "new", "instance", "." ]
b86fdbc9be41183680b82b07d3a8e8ea10926e01
https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/radius/packet.py#L501-L508
train
Create a new packet as a reply to this one.
talkincode/txradius
txradius/radius/packet.py
AcctPacket.RequestPacket
def RequestPacket(self): """Create a ready-to-transmit authentication request packet. Return a RADIUS packet which can be directly transmitted to a RADIUS server. :return: raw packet :rtype: string """ attr = self._PktEncodeAttributes() if self.id is N...
python
def RequestPacket(self): """Create a ready-to-transmit authentication request packet. Return a RADIUS packet which can be directly transmitted to a RADIUS server. :return: raw packet :rtype: string """ attr = self._PktEncodeAttributes() if self.id is N...
[ "def", "RequestPacket", "(", "self", ")", ":", "attr", "=", "self", ".", "_PktEncodeAttributes", "(", ")", "if", "self", ".", "id", "is", "None", ":", "self", ".", "id", "=", "self", ".", "CreateID", "(", ")", "header", "=", "struct", ".", "pack", ...
Create a ready-to-transmit authentication request packet. Return a RADIUS packet which can be directly transmitted to a RADIUS server. :return: raw packet :rtype: string
[ "Create", "a", "ready", "-", "to", "-", "transmit", "authentication", "request", "packet", ".", "Return", "a", "RADIUS", "packet", "which", "can", "be", "directly", "transmitted", "to", "a", "RADIUS", "server", "." ]
b86fdbc9be41183680b82b07d3a8e8ea10926e01
https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/radius/packet.py#L521-L538
train
Create a ready - to - transmit authentication request packet.
talkincode/txradius
txradius/radius/packet.py
CoAPacket.CreateReply
def CreateReply(self, **attributes): """Create a new packet as a reply to this one. This method makes sure the authenticator and secret are copied over to the new instance. """ return CoAPacket(CoAACK, self.id, self.secret, self.authenticator, dict=self.dict, ...
python
def CreateReply(self, **attributes): """Create a new packet as a reply to this one. This method makes sure the authenticator and secret are copied over to the new instance. """ return CoAPacket(CoAACK, self.id, self.secret, self.authenticator, dict=self.dict, ...
[ "def", "CreateReply", "(", "self", ",", "*", "*", "attributes", ")", ":", "return", "CoAPacket", "(", "CoAACK", ",", "self", ".", "id", ",", "self", ".", "secret", ",", "self", ".", "authenticator", ",", "dict", "=", "self", ".", "dict", ",", "*", ...
Create a new packet as a reply to this one. This method makes sure the authenticator and secret are copied over to the new instance.
[ "Create", "a", "new", "packet", "as", "a", "reply", "to", "this", "one", ".", "This", "method", "makes", "sure", "the", "authenticator", "and", "secret", "are", "copied", "over", "to", "the", "new", "instance", "." ]
b86fdbc9be41183680b82b07d3a8e8ea10926e01
https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/radius/packet.py#L564-L571
train
Create a new reply to this one.
talkincode/txradius
txradius/radius/packet.py
CoAPacket.VerifyCoARequest
def VerifyCoARequest(self): """Verify request authenticator. :return: True if verification failed else False :rtype: boolean """ assert(self.raw_packet) hash = md5_constructor(self.raw_packet[0:4] + 16 * six.b('\x00') + self.raw_packet[20:] + self.secret)....
python
def VerifyCoARequest(self): """Verify request authenticator. :return: True if verification failed else False :rtype: boolean """ assert(self.raw_packet) hash = md5_constructor(self.raw_packet[0:4] + 16 * six.b('\x00') + self.raw_packet[20:] + self.secret)....
[ "def", "VerifyCoARequest", "(", "self", ")", ":", "assert", "(", "self", ".", "raw_packet", ")", "hash", "=", "md5_constructor", "(", "self", ".", "raw_packet", "[", "0", ":", "4", "]", "+", "16", "*", "six", ".", "b", "(", "'\\x00'", ")", "+", "se...
Verify request authenticator. :return: True if verification failed else False :rtype: boolean
[ "Verify", "request", "authenticator", ".", ":", "return", ":", "True", "if", "verification", "failed", "else", "False", ":", "rtype", ":", "boolean" ]
b86fdbc9be41183680b82b07d3a8e8ea10926e01
https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/radius/packet.py#L573-L581
train
Verify the request authenticator.
bitesofcode/projexui
projexui/widgets/xtoolbar.py
XToolBar.clear
def clear(self): """ Clears out this toolbar from the system. """ # preserve the collapse button super(XToolBar, self).clear() # clears out the toolbar if self.isCollapsable(): self._collapseButton = QToolButton(self) self._collaps...
python
def clear(self): """ Clears out this toolbar from the system. """ # preserve the collapse button super(XToolBar, self).clear() # clears out the toolbar if self.isCollapsable(): self._collapseButton = QToolButton(self) self._collaps...
[ "def", "clear", "(", "self", ")", ":", "# preserve the collapse button", "super", "(", "XToolBar", ",", "self", ")", ".", "clear", "(", ")", "# clears out the toolbar", "if", "self", ".", "isCollapsable", "(", ")", ":", "self", ".", "_collapseButton", "=", "...
Clears out this toolbar from the system.
[ "Clears", "out", "this", "toolbar", "from", "the", "system", "." ]
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtoolbar.py#L64-L87
train
Clears out the toolbar from the system.
bitesofcode/projexui
projexui/widgets/xtoolbar.py
XToolBar.refreshButton
def refreshButton(self): """ Refreshes the button for this toolbar. """ collapsed = self.isCollapsed() btn = self._collapseButton if not btn: return btn.setMaximumSize(MAX_SIZE, MAX_SIZE) # set up a vertical...
python
def refreshButton(self): """ Refreshes the button for this toolbar. """ collapsed = self.isCollapsed() btn = self._collapseButton if not btn: return btn.setMaximumSize(MAX_SIZE, MAX_SIZE) # set up a vertical...
[ "def", "refreshButton", "(", "self", ")", ":", "collapsed", "=", "self", ".", "isCollapsed", "(", ")", "btn", "=", "self", ".", "_collapseButton", "if", "not", "btn", ":", "return", "btn", ".", "setMaximumSize", "(", "MAX_SIZE", ",", "MAX_SIZE", ")", "# ...
Refreshes the button for this toolbar.
[ "Refreshes", "the", "button", "for", "this", "toolbar", "." ]
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtoolbar.py#L138-L194
train
Refreshes the button for this toolbar.
bitesofcode/projexui
projexui/widgets/xtoolbar.py
XToolBar.setCollapsed
def setCollapsed(self, state): """ Sets whether or not this toolbar is in a collapsed state. :return <bool> changed """ if state == self._collapsed: return False self._collapsed = state self.refreshButton() if not...
python
def setCollapsed(self, state): """ Sets whether or not this toolbar is in a collapsed state. :return <bool> changed """ if state == self._collapsed: return False self._collapsed = state self.refreshButton() if not...
[ "def", "setCollapsed", "(", "self", ",", "state", ")", ":", "if", "state", "==", "self", ".", "_collapsed", ":", "return", "False", "self", ".", "_collapsed", "=", "state", "self", ".", "refreshButton", "(", ")", "if", "not", "self", ".", "signalsBlocked...
Sets whether or not this toolbar is in a collapsed state. :return <bool> changed
[ "Sets", "whether", "or", "not", "this", "toolbar", "is", "in", "a", "collapsed", "state", ".", ":", "return", "<bool", ">", "changed" ]
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtoolbar.py#L213-L228
train
Sets whether or not this toolbar is in a collapsed state.
bitesofcode/projexui
projexui/widgets/xtoolbar.py
XToolBar.setCollapsable
def setCollapsable(self, state): """ Sets whether or not this toolbar is collapsable. :param state | <bool> """ if self._collapsable == state: return self._collapsable = state self.clear()
python
def setCollapsable(self, state): """ Sets whether or not this toolbar is collapsable. :param state | <bool> """ if self._collapsable == state: return self._collapsable = state self.clear()
[ "def", "setCollapsable", "(", "self", ",", "state", ")", ":", "if", "self", ".", "_collapsable", "==", "state", ":", "return", "self", ".", "_collapsable", "=", "state", "self", ".", "clear", "(", ")" ]
Sets whether or not this toolbar is collapsable. :param state | <bool>
[ "Sets", "whether", "or", "not", "this", "toolbar", "is", "collapsable", ".", ":", "param", "state", "|", "<bool", ">" ]
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtoolbar.py#L230-L240
train
Sets whether or not this toolbar is collapsable.
bitesofcode/projexui
projexui/widgets/xtoolbar.py
XToolBar.setOrientation
def setOrientation( self, orientation ): """ Sets the orientation for this toolbar to the inputed value, and \ updates the contents margins and collapse button based on the vaule. :param orientation | <Qt.Orientation> """ super(XToolBar, self).setOrientation...
python
def setOrientation( self, orientation ): """ Sets the orientation for this toolbar to the inputed value, and \ updates the contents margins and collapse button based on the vaule. :param orientation | <Qt.Orientation> """ super(XToolBar, self).setOrientation...
[ "def", "setOrientation", "(", "self", ",", "orientation", ")", ":", "super", "(", "XToolBar", ",", "self", ")", ".", "setOrientation", "(", "orientation", ")", "self", ".", "refreshButton", "(", ")" ]
Sets the orientation for this toolbar to the inputed value, and \ updates the contents margins and collapse button based on the vaule. :param orientation | <Qt.Orientation>
[ "Sets", "the", "orientation", "for", "this", "toolbar", "to", "the", "inputed", "value", "and", "\\", "updates", "the", "contents", "margins", "and", "collapse", "button", "based", "on", "the", "vaule", ".", ":", "param", "orientation", "|", "<Qt", ".", "O...
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtoolbar.py#L242-L250
train
Sets the orientation for this toolbar to the inputed value.
bitesofcode/projexui
projexui/widgets/xtoolbar.py
XToolBar.setShadowed
def setShadowed(self, state): """ Sets whether or not this toolbar is shadowed. :param state | <bool> """ self._shadowed = state if state: self._colored = False for child in self.findChildren(XToolButton): child.setSh...
python
def setShadowed(self, state): """ Sets whether or not this toolbar is shadowed. :param state | <bool> """ self._shadowed = state if state: self._colored = False for child in self.findChildren(XToolButton): child.setSh...
[ "def", "setShadowed", "(", "self", ",", "state", ")", ":", "self", ".", "_shadowed", "=", "state", "if", "state", ":", "self", ".", "_colored", "=", "False", "for", "child", "in", "self", ".", "findChildren", "(", "XToolButton", ")", ":", "child", ".",...
Sets whether or not this toolbar is shadowed. :param state | <bool>
[ "Sets", "whether", "or", "not", "this", "toolbar", "is", "shadowed", ".", ":", "param", "state", "|", "<bool", ">" ]
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtoolbar.py#L252-L263
train
Sets whether or not this toolbar is shadowed.
bitesofcode/projexui
projexui/widgets/xchart/renderers/xbarrenderer.py
XBarRenderer.calculateDatasets
def calculateDatasets(self, scene, axes, datasets): """ Builds the datasets for this renderer. Each renderer will need to subclass and implemenent this method, otherwise, no data will be shown in the chart. :param scene | <XChartScene> ax...
python
def calculateDatasets(self, scene, axes, datasets): """ Builds the datasets for this renderer. Each renderer will need to subclass and implemenent this method, otherwise, no data will be shown in the chart. :param scene | <XChartScene> ax...
[ "def", "calculateDatasets", "(", "self", ",", "scene", ",", "axes", ",", "datasets", ")", ":", "items", "=", "self", ".", "calculateDatasetItems", "(", "scene", ",", "datasets", ")", "if", "not", "items", ":", "scene", ".", "clear", "(", ")", "return", ...
Builds the datasets for this renderer. Each renderer will need to subclass and implemenent this method, otherwise, no data will be shown in the chart. :param scene | <XChartScene> axes | [< datasets | [<XChartDataset>, ..]
[ "Builds", "the", "datasets", "for", "this", "renderer", ".", "Each", "renderer", "will", "need", "to", "subclass", "and", "implemenent", "this", "method", "otherwise", "no", "data", "will", "be", "shown", "in", "the", "chart", ".", ":", "param", "scene", "...
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/renderers/xbarrenderer.py#L38-L91
train
Calculates the datasets for the given scene and axes and datasets.
bitesofcode/projexui
projexui/widgets/xchart/renderers/xbarrenderer.py
XBarRenderer.drawItem
def drawItem(self, item, painter, option): """ Draws the inputed item as a bar graph. :param item | <XChartDatasetItem> painter | <QPainter> option | <QStyleOptionGraphicsItem> """ dataset = item.dataset() ...
python
def drawItem(self, item, painter, option): """ Draws the inputed item as a bar graph. :param item | <XChartDatasetItem> painter | <QPainter> option | <QStyleOptionGraphicsItem> """ dataset = item.dataset() ...
[ "def", "drawItem", "(", "self", ",", "item", ",", "painter", ",", "option", ")", ":", "dataset", "=", "item", ".", "dataset", "(", ")", "painter", ".", "save", "(", ")", "painter", ".", "setRenderHint", "(", "painter", ".", "Antialiasing", ")", "pen", ...
Draws the inputed item as a bar graph. :param item | <XChartDatasetItem> painter | <QPainter> option | <QStyleOptionGraphicsItem>
[ "Draws", "the", "inputed", "item", "as", "a", "bar", "graph", ".", ":", "param", "item", "|", "<XChartDatasetItem", ">", "painter", "|", "<QPainter", ">", "option", "|", "<QStyleOptionGraphicsItem", ">" ]
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/renderers/xbarrenderer.py#L93-L131
train
Draws the item as a bar graph.
ubernostrum/django-soapbox
soapbox/models.py
MessageManager.match
def match(self, url): """ Return a list of all active Messages which match the given URL. """ return list({ message for message in self.active() if message.is_global or message.match(url) })
python
def match(self, url): """ Return a list of all active Messages which match the given URL. """ return list({ message for message in self.active() if message.is_global or message.match(url) })
[ "def", "match", "(", "self", ",", "url", ")", ":", "return", "list", "(", "{", "message", "for", "message", "in", "self", ".", "active", "(", ")", "if", "message", ".", "is_global", "or", "message", ".", "match", "(", "url", ")", "}", ")" ]
Return a list of all active Messages which match the given URL.
[ "Return", "a", "list", "of", "all", "active", "Messages", "which", "match", "the", "given", "URL", "." ]
f9189e1ddf47175f2392b92c7a0a902817ee1e93
https://github.com/ubernostrum/django-soapbox/blob/f9189e1ddf47175f2392b92c7a0a902817ee1e93/soapbox/models.py#L36-L45
train
Return a list of all active Messages which match the given URL.
bitesofcode/projexui
projexui/widgets/xchart/xchartdatasetitem.py
XChartDatasetItem.mousePressEvent
def mousePressEvent(self, event): """ Creates the drag event for this item. :param event | <QMousePressEvent> """ ddata = self.dataset().dragData() if ddata: self.startDrag(ddata) super(XChartDatasetItem, self).mousePre...
python
def mousePressEvent(self, event): """ Creates the drag event for this item. :param event | <QMousePressEvent> """ ddata = self.dataset().dragData() if ddata: self.startDrag(ddata) super(XChartDatasetItem, self).mousePre...
[ "def", "mousePressEvent", "(", "self", ",", "event", ")", ":", "ddata", "=", "self", ".", "dataset", "(", ")", ".", "dragData", "(", ")", "if", "ddata", ":", "self", ".", "startDrag", "(", "ddata", ")", "super", "(", "XChartDatasetItem", ",", "self", ...
Creates the drag event for this item. :param event | <QMousePressEvent>
[ "Creates", "the", "drag", "event", "for", "this", "item", ".", ":", "param", "event", "|", "<QMousePressEvent", ">" ]
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/xchartdatasetitem.py#L66-L76
train
Creates the drag event for this item.
bitesofcode/projexui
projexui/widgets/xchart/xchartdatasetitem.py
XChartDatasetItem.paint
def paint(self, painter, option, widget): """ Draws this item with the inputed painter. This will call the scene's renderer to draw this item. """ scene = self.scene() if not scene: return scene.chart().renderer().drawItem(self, pain...
python
def paint(self, painter, option, widget): """ Draws this item with the inputed painter. This will call the scene's renderer to draw this item. """ scene = self.scene() if not scene: return scene.chart().renderer().drawItem(self, pain...
[ "def", "paint", "(", "self", ",", "painter", ",", "option", ",", "widget", ")", ":", "scene", "=", "self", ".", "scene", "(", ")", "if", "not", "scene", ":", "return", "scene", ".", "chart", "(", ")", ".", "renderer", "(", ")", ".", "drawItem", "...
Draws this item with the inputed painter. This will call the scene's renderer to draw this item.
[ "Draws", "this", "item", "with", "the", "inputed", "painter", ".", "This", "will", "call", "the", "scene", "s", "renderer", "to", "draw", "this", "item", "." ]
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/xchartdatasetitem.py#L78-L87
train
Draws this item with the inputed painter.
bitesofcode/projexui
projexui/widgets/xchart/xchartdatasetitem.py
XChartDatasetItem.setDataset
def setDataset(self, dataset): """ Sets the dataset instance associated with this item. :param dataset | <XChartDataset> """ self._dataset = dataset # setup the tooltip tip = [] tip.append('<b>%s</b>' % dataset.name()) ...
python
def setDataset(self, dataset): """ Sets the dataset instance associated with this item. :param dataset | <XChartDataset> """ self._dataset = dataset # setup the tooltip tip = [] tip.append('<b>%s</b>' % dataset.name()) ...
[ "def", "setDataset", "(", "self", ",", "dataset", ")", ":", "self", ".", "_dataset", "=", "dataset", "# setup the tooltip\r", "tip", "=", "[", "]", "tip", ".", "append", "(", "'<b>%s</b>'", "%", "dataset", ".", "name", "(", ")", ")", "for", "value", "i...
Sets the dataset instance associated with this item. :param dataset | <XChartDataset>
[ "Sets", "the", "dataset", "instance", "associated", "with", "this", "item", ".", ":", "param", "dataset", "|", "<XChartDataset", ">" ]
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/xchartdatasetitem.py#L99-L122
train
Sets the dataset associated with this item.
bitesofcode/projexui
projexui/widgets/xchart/xchartdatasetitem.py
XChartDatasetItem.startDrag
def startDrag(self, dragData): """ Starts a new drag with the inputed data. :param dragData | <dict> """ # create the mime data mimeData = QMimeData() for key, value in dragData.items(): mimeData.setData('application/x-%s' % key,...
python
def startDrag(self, dragData): """ Starts a new drag with the inputed data. :param dragData | <dict> """ # create the mime data mimeData = QMimeData() for key, value in dragData.items(): mimeData.setData('application/x-%s' % key,...
[ "def", "startDrag", "(", "self", ",", "dragData", ")", ":", "# create the mime data\r", "mimeData", "=", "QMimeData", "(", ")", "for", "key", ",", "value", "in", "dragData", ".", "items", "(", ")", ":", "mimeData", ".", "setData", "(", "'application/x-%s'", ...
Starts a new drag with the inputed data. :param dragData | <dict>
[ "Starts", "a", "new", "drag", "with", "the", "inputed", "data", ".", ":", "param", "dragData", "|", "<dict", ">" ]
f18a73bec84df90b034ca69b9deea118dbedfc4d
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/xchartdatasetitem.py#L124-L138
train
Starts a new drag with the inputed data.
scottwoodall/python-pgextras
pgextras/__init__.py
PgExtras.pg_stat_statement
def pg_stat_statement(self): """ Some queries require the pg_stat_statement module to be installed. http://www.postgresql.org/docs/current/static/pgstatstatements.html :returns: boolean """ if self._pg_stat_statement is None: results = self.execute(sql.PG_ST...
python
def pg_stat_statement(self): """ Some queries require the pg_stat_statement module to be installed. http://www.postgresql.org/docs/current/static/pgstatstatements.html :returns: boolean """ if self._pg_stat_statement is None: results = self.execute(sql.PG_ST...
[ "def", "pg_stat_statement", "(", "self", ")", ":", "if", "self", ".", "_pg_stat_statement", "is", "None", ":", "results", "=", "self", ".", "execute", "(", "sql", ".", "PG_STAT_STATEMENT", ")", "is_available", "=", "results", "[", "0", "]", ".", "available...
Some queries require the pg_stat_statement module to be installed. http://www.postgresql.org/docs/current/static/pgstatstatements.html :returns: boolean
[ "Some", "queries", "require", "the", "pg_stat_statement", "module", "to", "be", "installed", ".", "http", ":", "//", "www", ".", "postgresql", ".", "org", "/", "docs", "/", "current", "/", "static", "/", "pgstatstatements", ".", "html" ]
d3aa83081d41b14b7c1f003cd837c812a2b5fff5
https://github.com/scottwoodall/python-pgextras/blob/d3aa83081d41b14b7c1f003cd837c812a2b5fff5/pgextras/__init__.py#L71-L88
train
Returns a boolean value that indicates whether the stat_statement module is installed.
scottwoodall/python-pgextras
pgextras/__init__.py
PgExtras.is_pg_at_least_nine_two
def is_pg_at_least_nine_two(self): """ Some queries have different syntax depending what version of postgres we are querying against. :returns: boolean """ if self._is_pg_at_least_nine_two is None: results = self.version() regex = re.compile("Pos...
python
def is_pg_at_least_nine_two(self): """ Some queries have different syntax depending what version of postgres we are querying against. :returns: boolean """ if self._is_pg_at_least_nine_two is None: results = self.version() regex = re.compile("Pos...
[ "def", "is_pg_at_least_nine_two", "(", "self", ")", ":", "if", "self", ".", "_is_pg_at_least_nine_two", "is", "None", ":", "results", "=", "self", ".", "version", "(", ")", "regex", "=", "re", ".", "compile", "(", "\"PostgreSQL (\\d+\\.\\d+\\.\\d+) on\"", ")", ...
Some queries have different syntax depending what version of postgres we are querying against. :returns: boolean
[ "Some", "queries", "have", "different", "syntax", "depending", "what", "version", "of", "postgres", "we", "are", "querying", "against", "." ]
d3aa83081d41b14b7c1f003cd837c812a2b5fff5
https://github.com/scottwoodall/python-pgextras/blob/d3aa83081d41b14b7c1f003cd837c812a2b5fff5/pgextras/__init__.py#L104-L123
train
Returns True if postgres version is greater than 9. 2. 0 and False otherwise.