partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | Transformer.allpass | Apply a two-pole all-pass filter. An all-pass filter changes the
audio’s frequency to phase relationship without changing its frequency
to amplitude relationship. The filter is described in detail in at
http://musicdsp.org/files/Audio-EQ-Cookbook.txt
Parameters
----------
... | sox/transform.py | def allpass(self, frequency, width_q=2.0):
'''Apply a two-pole all-pass filter. An all-pass filter changes the
audio’s frequency to phase relationship without changing its frequency
to amplitude relationship. The filter is described in detail in at
http://musicdsp.org/files/Audio-EQ-Cook... | def allpass(self, frequency, width_q=2.0):
'''Apply a two-pole all-pass filter. An all-pass filter changes the
audio’s frequency to phase relationship without changing its frequency
to amplitude relationship. The filter is described in detail in at
http://musicdsp.org/files/Audio-EQ-Cook... | [
"Apply",
"a",
"two",
"-",
"pole",
"all",
"-",
"pass",
"filter",
".",
"An",
"all",
"-",
"pass",
"filter",
"changes",
"the",
"audio’s",
"frequency",
"to",
"phase",
"relationship",
"without",
"changing",
"its",
"frequency",
"to",
"amplitude",
"relationship",
".... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L474-L504 | [
"def",
"allpass",
"(",
"self",
",",
"frequency",
",",
"width_q",
"=",
"2.0",
")",
":",
"if",
"not",
"is_number",
"(",
"frequency",
")",
"or",
"frequency",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"frequency must be a positive number.\"",
")",
"if",
"not... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.bandpass | Apply a two-pole Butterworth band-pass filter with the given central
frequency, and (3dB-point) band-width. The filter rolls off at 6dB per
octave (20dB per decade) and is described in detail in
http://musicdsp.org/files/Audio-EQ-Cookbook.txt
Parameters
----------
freque... | sox/transform.py | def bandpass(self, frequency, width_q=2.0, constant_skirt=False):
'''Apply a two-pole Butterworth band-pass filter with the given central
frequency, and (3dB-point) band-width. The filter rolls off at 6dB per
octave (20dB per decade) and is described in detail in
http://musicdsp.org/file... | def bandpass(self, frequency, width_q=2.0, constant_skirt=False):
'''Apply a two-pole Butterworth band-pass filter with the given central
frequency, and (3dB-point) band-width. The filter rolls off at 6dB per
octave (20dB per decade) and is described in detail in
http://musicdsp.org/file... | [
"Apply",
"a",
"two",
"-",
"pole",
"Butterworth",
"band",
"-",
"pass",
"filter",
"with",
"the",
"given",
"central",
"frequency",
"and",
"(",
"3dB",
"-",
"point",
")",
"band",
"-",
"width",
".",
"The",
"filter",
"rolls",
"off",
"at",
"6dB",
"per",
"octav... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L506-L545 | [
"def",
"bandpass",
"(",
"self",
",",
"frequency",
",",
"width_q",
"=",
"2.0",
",",
"constant_skirt",
"=",
"False",
")",
":",
"if",
"not",
"is_number",
"(",
"frequency",
")",
"or",
"frequency",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"frequency must b... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.bend | Changes pitch by specified amounts at specified times.
The pitch-bending algorithm utilises the Discrete Fourier Transform
(DFT) at a particular frame rate and over-sampling rate.
Parameters
----------
n_bends : int
The number of intervals to pitch shift
star... | sox/transform.py | def bend(self, n_bends, start_times, end_times, cents, frame_rate=25,
oversample_rate=16):
'''Changes pitch by specified amounts at specified times.
The pitch-bending algorithm utilises the Discrete Fourier Transform
(DFT) at a particular frame rate and over-sampling rate.
... | def bend(self, n_bends, start_times, end_times, cents, frame_rate=25,
oversample_rate=16):
'''Changes pitch by specified amounts at specified times.
The pitch-bending algorithm utilises the Discrete Fourier Transform
(DFT) at a particular frame rate and over-sampling rate.
... | [
"Changes",
"pitch",
"by",
"specified",
"amounts",
"at",
"specified",
"times",
".",
"The",
"pitch",
"-",
"bending",
"algorithm",
"utilises",
"the",
"Discrete",
"Fourier",
"Transform",
"(",
"DFT",
")",
"at",
"a",
"particular",
"frame",
"rate",
"and",
"over",
"... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L624-L716 | [
"def",
"bend",
"(",
"self",
",",
"n_bends",
",",
"start_times",
",",
"end_times",
",",
"cents",
",",
"frame_rate",
"=",
"25",
",",
"oversample_rate",
"=",
"16",
")",
":",
"if",
"not",
"isinstance",
"(",
"n_bends",
",",
"int",
")",
"or",
"n_bends",
"<",... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.biquad | Apply a biquad IIR filter with the given coefficients.
Parameters
----------
b : list of floats
Numerator coefficients. Must be length 3
a : list of floats
Denominator coefficients. Must be length 3
See Also
--------
fir, treble, bass, eq... | sox/transform.py | def biquad(self, b, a):
'''Apply a biquad IIR filter with the given coefficients.
Parameters
----------
b : list of floats
Numerator coefficients. Must be length 3
a : list of floats
Denominator coefficients. Must be length 3
See Also
---... | def biquad(self, b, a):
'''Apply a biquad IIR filter with the given coefficients.
Parameters
----------
b : list of floats
Numerator coefficients. Must be length 3
a : list of floats
Denominator coefficients. Must be length 3
See Also
---... | [
"Apply",
"a",
"biquad",
"IIR",
"filter",
"with",
"the",
"given",
"coefficients",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L718-L759 | [
"def",
"biquad",
"(",
"self",
",",
"b",
",",
"a",
")",
":",
"if",
"not",
"isinstance",
"(",
"b",
",",
"list",
")",
":",
"raise",
"ValueError",
"(",
"'b must be a list.'",
")",
"if",
"not",
"isinstance",
"(",
"a",
",",
"list",
")",
":",
"raise",
"Va... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.channels | Change the number of channels in the audio signal. If decreasing the
number of channels it mixes channels together, if increasing the number
of channels it duplicates.
Note: This overrides arguments used in the convert effect!
Parameters
----------
n_channels : int
... | sox/transform.py | def channels(self, n_channels):
'''Change the number of channels in the audio signal. If decreasing the
number of channels it mixes channels together, if increasing the number
of channels it duplicates.
Note: This overrides arguments used in the convert effect!
Parameters
... | def channels(self, n_channels):
'''Change the number of channels in the audio signal. If decreasing the
number of channels it mixes channels together, if increasing the number
of channels it duplicates.
Note: This overrides arguments used in the convert effect!
Parameters
... | [
"Change",
"the",
"number",
"of",
"channels",
"in",
"the",
"audio",
"signal",
".",
"If",
"decreasing",
"the",
"number",
"of",
"channels",
"it",
"mixes",
"channels",
"together",
"if",
"increasing",
"the",
"number",
"of",
"channels",
"it",
"duplicates",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L761-L785 | [
"def",
"channels",
"(",
"self",
",",
"n_channels",
")",
":",
"if",
"not",
"isinstance",
"(",
"n_channels",
",",
"int",
")",
"or",
"n_channels",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"'n_channels must be a positive integer.'",
")",
"effect_args",
"=",
"["... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.chorus | Add a chorus effect to the audio. This can makeasingle vocal sound
like a chorus, but can also be applied to instrumentation.
Chorus resembles an echo effect with a short delay, but whereas with
echo the delay is constant, with chorus, it is varied using sinusoidal
or triangular modulat... | sox/transform.py | def chorus(self, gain_in=0.5, gain_out=0.9, n_voices=3, delays=None,
decays=None, speeds=None, depths=None, shapes=None):
'''Add a chorus effect to the audio. This can makeasingle vocal sound
like a chorus, but can also be applied to instrumentation.
Chorus resembles an echo effe... | def chorus(self, gain_in=0.5, gain_out=0.9, n_voices=3, delays=None,
decays=None, speeds=None, depths=None, shapes=None):
'''Add a chorus effect to the audio. This can makeasingle vocal sound
like a chorus, but can also be applied to instrumentation.
Chorus resembles an echo effe... | [
"Add",
"a",
"chorus",
"effect",
"to",
"the",
"audio",
".",
"This",
"can",
"makeasingle",
"vocal",
"sound",
"like",
"a",
"chorus",
"but",
"can",
"also",
"be",
"applied",
"to",
"instrumentation",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L787-L910 | [
"def",
"chorus",
"(",
"self",
",",
"gain_in",
"=",
"0.5",
",",
"gain_out",
"=",
"0.9",
",",
"n_voices",
"=",
"3",
",",
"delays",
"=",
"None",
",",
"decays",
"=",
"None",
",",
"speeds",
"=",
"None",
",",
"depths",
"=",
"None",
",",
"shapes",
"=",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.compand | Compand (compress or expand) the dynamic range of the audio.
Parameters
----------
attack_time : float, default=0.3
The time in seconds over which the instantaneous level of the input
signal is averaged to determine increases in volume.
decay_time : float, defaul... | sox/transform.py | def compand(self, attack_time=0.3, decay_time=0.8, soft_knee_db=6.0,
tf_points=[(-70, -70), (-60, -20), (0, 0)],
):
'''Compand (compress or expand) the dynamic range of the audio.
Parameters
----------
attack_time : float, default=0.3
The time... | def compand(self, attack_time=0.3, decay_time=0.8, soft_knee_db=6.0,
tf_points=[(-70, -70), (-60, -20), (0, 0)],
):
'''Compand (compress or expand) the dynamic range of the audio.
Parameters
----------
attack_time : float, default=0.3
The time... | [
"Compand",
"(",
"compress",
"or",
"expand",
")",
"the",
"dynamic",
"range",
"of",
"the",
"audio",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L912-L993 | [
"def",
"compand",
"(",
"self",
",",
"attack_time",
"=",
"0.3",
",",
"decay_time",
"=",
"0.8",
",",
"soft_knee_db",
"=",
"6.0",
",",
"tf_points",
"=",
"[",
"(",
"-",
"70",
",",
"-",
"70",
")",
",",
"(",
"-",
"60",
",",
"-",
"20",
")",
",",
"(",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.contrast | Comparable with compression, this effect modifies an audio signal to
make it sound louder.
Parameters
----------
amount : float
Amount of enhancement between 0 and 100.
See Also
--------
compand, mcompand | sox/transform.py | def contrast(self, amount=75):
'''Comparable with compression, this effect modifies an audio signal to
make it sound louder.
Parameters
----------
amount : float
Amount of enhancement between 0 and 100.
See Also
--------
compand, mcompand
... | def contrast(self, amount=75):
'''Comparable with compression, this effect modifies an audio signal to
make it sound louder.
Parameters
----------
amount : float
Amount of enhancement between 0 and 100.
See Also
--------
compand, mcompand
... | [
"Comparable",
"with",
"compression",
"this",
"effect",
"modifies",
"an",
"audio",
"signal",
"to",
"make",
"it",
"sound",
"louder",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L995-L1016 | [
"def",
"contrast",
"(",
"self",
",",
"amount",
"=",
"75",
")",
":",
"if",
"not",
"is_number",
"(",
"amount",
")",
"or",
"amount",
"<",
"0",
"or",
"amount",
">",
"100",
":",
"raise",
"ValueError",
"(",
"'amount must be a number between 0 and 100.'",
")",
"e... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.convert | Converts output audio to the specified format.
Parameters
----------
samplerate : float, default=None
Desired samplerate. If None, defaults to the same as input.
n_channels : int, default=None
Desired number of channels. If None, defaults to the same as input.
... | sox/transform.py | def convert(self, samplerate=None, n_channels=None, bitdepth=None):
'''Converts output audio to the specified format.
Parameters
----------
samplerate : float, default=None
Desired samplerate. If None, defaults to the same as input.
n_channels : int, default=None
... | def convert(self, samplerate=None, n_channels=None, bitdepth=None):
'''Converts output audio to the specified format.
Parameters
----------
samplerate : float, default=None
Desired samplerate. If None, defaults to the same as input.
n_channels : int, default=None
... | [
"Converts",
"output",
"audio",
"to",
"the",
"specified",
"format",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1018-L1052 | [
"def",
"convert",
"(",
"self",
",",
"samplerate",
"=",
"None",
",",
"n_channels",
"=",
"None",
",",
"bitdepth",
"=",
"None",
")",
":",
"bitdepths",
"=",
"[",
"8",
",",
"16",
",",
"24",
",",
"32",
",",
"64",
"]",
"if",
"bitdepth",
"is",
"not",
"No... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.dcshift | Apply a DC shift to the audio.
Parameters
----------
shift : float
Amount to shift audio between -2 and 2. (Audio is between -1 and 1)
See Also
--------
highpass | sox/transform.py | def dcshift(self, shift=0.0):
'''Apply a DC shift to the audio.
Parameters
----------
shift : float
Amount to shift audio between -2 and 2. (Audio is between -1 and 1)
See Also
--------
highpass
'''
if not is_number(shift) or shift <... | def dcshift(self, shift=0.0):
'''Apply a DC shift to the audio.
Parameters
----------
shift : float
Amount to shift audio between -2 and 2. (Audio is between -1 and 1)
See Also
--------
highpass
'''
if not is_number(shift) or shift <... | [
"Apply",
"a",
"DC",
"shift",
"to",
"the",
"audio",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1054-L1074 | [
"def",
"dcshift",
"(",
"self",
",",
"shift",
"=",
"0.0",
")",
":",
"if",
"not",
"is_number",
"(",
"shift",
")",
"or",
"shift",
"<",
"-",
"2",
"or",
"shift",
">",
"2",
":",
"raise",
"ValueError",
"(",
"'shift must be a number between -2 and 2.'",
")",
"ef... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.deemph | Apply Compact Disc (IEC 60908) de-emphasis (a treble attenuation
shelving filter). Pre-emphasis was applied in the mastering of some
CDs issued in the early 1980s. These included many classical music
albums, as well as now sought-after issues of albums by The Beatles,
Pink Floyd and othe... | sox/transform.py | def deemph(self):
'''Apply Compact Disc (IEC 60908) de-emphasis (a treble attenuation
shelving filter). Pre-emphasis was applied in the mastering of some
CDs issued in the early 1980s. These included many classical music
albums, as well as now sought-after issues of albums by The Beatles... | def deemph(self):
'''Apply Compact Disc (IEC 60908) de-emphasis (a treble attenuation
shelving filter). Pre-emphasis was applied in the mastering of some
CDs issued in the early 1980s. These included many classical music
albums, as well as now sought-after issues of albums by The Beatles... | [
"Apply",
"Compact",
"Disc",
"(",
"IEC",
"60908",
")",
"de",
"-",
"emphasis",
"(",
"a",
"treble",
"attenuation",
"shelving",
"filter",
")",
".",
"Pre",
"-",
"emphasis",
"was",
"applied",
"in",
"the",
"mastering",
"of",
"some",
"CDs",
"issued",
"in",
"the"... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1076-L1099 | [
"def",
"deemph",
"(",
"self",
")",
":",
"effect_args",
"=",
"[",
"'deemph'",
"]",
"self",
".",
"effects",
".",
"extend",
"(",
"effect_args",
")",
"self",
".",
"effects_log",
".",
"append",
"(",
"'deemph'",
")",
"return",
"self"
] | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.delay | Delay one or more audio channels such that they start at the given
positions.
Parameters
----------
positions: list of floats
List of times (in seconds) to delay each audio channel.
If fewer positions are given than the number of channels, the
remaini... | sox/transform.py | def delay(self, positions):
'''Delay one or more audio channels such that they start at the given
positions.
Parameters
----------
positions: list of floats
List of times (in seconds) to delay each audio channel.
If fewer positions are given than the numb... | def delay(self, positions):
'''Delay one or more audio channels such that they start at the given
positions.
Parameters
----------
positions: list of floats
List of times (in seconds) to delay each audio channel.
If fewer positions are given than the numb... | [
"Delay",
"one",
"or",
"more",
"audio",
"channels",
"such",
"that",
"they",
"start",
"at",
"the",
"given",
"positions",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1101-L1124 | [
"def",
"delay",
"(",
"self",
",",
"positions",
")",
":",
"if",
"not",
"isinstance",
"(",
"positions",
",",
"list",
")",
":",
"raise",
"ValueError",
"(",
"\"positions must be a a list of numbers\"",
")",
"if",
"not",
"all",
"(",
"(",
"is_number",
"(",
"p",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.downsample | Downsample the signal by an integer factor. Only the first out of
each factor samples is retained, the others are discarded.
No decimation filter is applied. If the input is not a properly
bandlimited baseband signal, aliasing will occur. This may be desirable
e.g., for frequency transl... | sox/transform.py | def downsample(self, factor=2):
'''Downsample the signal by an integer factor. Only the first out of
each factor samples is retained, the others are discarded.
No decimation filter is applied. If the input is not a properly
bandlimited baseband signal, aliasing will occur. This may be d... | def downsample(self, factor=2):
'''Downsample the signal by an integer factor. Only the first out of
each factor samples is retained, the others are discarded.
No decimation filter is applied. If the input is not a properly
bandlimited baseband signal, aliasing will occur. This may be d... | [
"Downsample",
"the",
"signal",
"by",
"an",
"integer",
"factor",
".",
"Only",
"the",
"first",
"out",
"of",
"each",
"factor",
"samples",
"is",
"retained",
"the",
"others",
"are",
"discarded",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1126-L1153 | [
"def",
"downsample",
"(",
"self",
",",
"factor",
"=",
"2",
")",
":",
"if",
"not",
"isinstance",
"(",
"factor",
",",
"int",
")",
"or",
"factor",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"'factor must be a positive integer.'",
")",
"effect_args",
"=",
"[",... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.earwax | Makes audio easier to listen to on headphones. Adds ‘cues’ to 44.1kHz
stereo audio so that when listened to on headphones the stereo image is
moved from inside your head (standard for headphones) to outside and in
front of the listener (standard for speakers).
Warning: Will only work pr... | sox/transform.py | def earwax(self):
'''Makes audio easier to listen to on headphones. Adds ‘cues’ to 44.1kHz
stereo audio so that when listened to on headphones the stereo image is
moved from inside your head (standard for headphones) to outside and in
front of the listener (standard for speakers).
... | def earwax(self):
'''Makes audio easier to listen to on headphones. Adds ‘cues’ to 44.1kHz
stereo audio so that when listened to on headphones the stereo image is
moved from inside your head (standard for headphones) to outside and in
front of the listener (standard for speakers).
... | [
"Makes",
"audio",
"easier",
"to",
"listen",
"to",
"on",
"headphones",
".",
"Adds",
"‘cues’",
"to",
"44",
".",
"1kHz",
"stereo",
"audio",
"so",
"that",
"when",
"listened",
"to",
"on",
"headphones",
"the",
"stereo",
"image",
"is",
"moved",
"from",
"inside",
... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1155-L1168 | [
"def",
"earwax",
"(",
"self",
")",
":",
"effect_args",
"=",
"[",
"'earwax'",
"]",
"self",
".",
"effects",
".",
"extend",
"(",
"effect_args",
")",
"self",
".",
"effects_log",
".",
"append",
"(",
"'earwax'",
")",
"return",
"self"
] | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.echo | Add echoing to the audio.
Echoes are reflected sound and can occur naturally amongst mountains
(and sometimes large buildings) when talking or shouting; digital echo
effects emulate this behav- iour and are often used to help fill out
the sound of a single instrument or vocal. The time ... | sox/transform.py | def echo(self, gain_in=0.8, gain_out=0.9, n_echos=1, delays=[60],
decays=[0.4]):
'''Add echoing to the audio.
Echoes are reflected sound and can occur naturally amongst mountains
(and sometimes large buildings) when talking or shouting; digital echo
effects emulate this beh... | def echo(self, gain_in=0.8, gain_out=0.9, n_echos=1, delays=[60],
decays=[0.4]):
'''Add echoing to the audio.
Echoes are reflected sound and can occur naturally amongst mountains
(and sometimes large buildings) when talking or shouting; digital echo
effects emulate this beh... | [
"Add",
"echoing",
"to",
"the",
"audio",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1170-L1239 | [
"def",
"echo",
"(",
"self",
",",
"gain_in",
"=",
"0.8",
",",
"gain_out",
"=",
"0.9",
",",
"n_echos",
"=",
"1",
",",
"delays",
"=",
"[",
"60",
"]",
",",
"decays",
"=",
"[",
"0.4",
"]",
")",
":",
"if",
"not",
"is_number",
"(",
"gain_in",
")",
"or... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.equalizer | Apply a two-pole peaking equalisation (EQ) filter to boost or
reduce around a given frequency.
This effect can be applied multiple times to produce complex EQ curves.
Parameters
----------
frequency : float
The filter's central frequency in Hz.
width_q : floa... | sox/transform.py | def equalizer(self, frequency, width_q, gain_db):
'''Apply a two-pole peaking equalisation (EQ) filter to boost or
reduce around a given frequency.
This effect can be applied multiple times to produce complex EQ curves.
Parameters
----------
frequency : float
... | def equalizer(self, frequency, width_q, gain_db):
'''Apply a two-pole peaking equalisation (EQ) filter to boost or
reduce around a given frequency.
This effect can be applied multiple times to produce complex EQ curves.
Parameters
----------
frequency : float
... | [
"Apply",
"a",
"two",
"-",
"pole",
"peaking",
"equalisation",
"(",
"EQ",
")",
"filter",
"to",
"boost",
"or",
"reduce",
"around",
"a",
"given",
"frequency",
".",
"This",
"effect",
"can",
"be",
"applied",
"multiple",
"times",
"to",
"produce",
"complex",
"EQ",... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1312-L1348 | [
"def",
"equalizer",
"(",
"self",
",",
"frequency",
",",
"width_q",
",",
"gain_db",
")",
":",
"if",
"not",
"is_number",
"(",
"frequency",
")",
"or",
"frequency",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"frequency must be a positive number.\"",
")",
"if",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.fade | Add a fade in and/or fade out to an audio file.
Default fade shape is 1/4 sine wave.
Parameters
----------
fade_in_len : float, default=0.0
Length of fade-in (seconds). If fade_in_len = 0,
no fade in is applied.
fade_out_len : float, defaut=0.0
... | sox/transform.py | def fade(self, fade_in_len=0.0, fade_out_len=0.0, fade_shape='q'):
'''Add a fade in and/or fade out to an audio file.
Default fade shape is 1/4 sine wave.
Parameters
----------
fade_in_len : float, default=0.0
Length of fade-in (seconds). If fade_in_len = 0,
... | def fade(self, fade_in_len=0.0, fade_out_len=0.0, fade_shape='q'):
'''Add a fade in and/or fade out to an audio file.
Default fade shape is 1/4 sine wave.
Parameters
----------
fade_in_len : float, default=0.0
Length of fade-in (seconds). If fade_in_len = 0,
... | [
"Add",
"a",
"fade",
"in",
"and",
"/",
"or",
"fade",
"out",
"to",
"an",
"audio",
"file",
".",
"Default",
"fade",
"shape",
"is",
"1",
"/",
"4",
"sine",
"wave",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1350-L1402 | [
"def",
"fade",
"(",
"self",
",",
"fade_in_len",
"=",
"0.0",
",",
"fade_out_len",
"=",
"0.0",
",",
"fade_shape",
"=",
"'q'",
")",
":",
"fade_shapes",
"=",
"[",
"'q'",
",",
"'h'",
",",
"'t'",
",",
"'l'",
",",
"'p'",
"]",
"if",
"fade_shape",
"not",
"i... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.fir | Use SoX’s FFT convolution engine with given FIR filter coefficients.
Parameters
----------
coefficients : list
fir filter coefficients | sox/transform.py | def fir(self, coefficients):
'''Use SoX’s FFT convolution engine with given FIR filter coefficients.
Parameters
----------
coefficients : list
fir filter coefficients
'''
if not isinstance(coefficients, list):
raise ValueError("coefficients must ... | def fir(self, coefficients):
'''Use SoX’s FFT convolution engine with given FIR filter coefficients.
Parameters
----------
coefficients : list
fir filter coefficients
'''
if not isinstance(coefficients, list):
raise ValueError("coefficients must ... | [
"Use",
"SoX’s",
"FFT",
"convolution",
"engine",
"with",
"given",
"FIR",
"filter",
"coefficients",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1404-L1425 | [
"def",
"fir",
"(",
"self",
",",
"coefficients",
")",
":",
"if",
"not",
"isinstance",
"(",
"coefficients",
",",
"list",
")",
":",
"raise",
"ValueError",
"(",
"\"coefficients must be a list.\"",
")",
"if",
"not",
"all",
"(",
"[",
"is_number",
"(",
"c",
")",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.flanger | Apply a flanging effect to the audio.
Parameters
----------
delay : float, default=0
Base delay (in miliseconds) between 0 and 30.
depth : float, default=2
Added swept delay (in miliseconds) between 0 and 10.
regen : float, default=0
Percentag... | sox/transform.py | def flanger(self, delay=0, depth=2, regen=0, width=71, speed=0.5,
shape='sine', phase=25, interp='linear'):
'''Apply a flanging effect to the audio.
Parameters
----------
delay : float, default=0
Base delay (in miliseconds) between 0 and 30.
depth : f... | def flanger(self, delay=0, depth=2, regen=0, width=71, speed=0.5,
shape='sine', phase=25, interp='linear'):
'''Apply a flanging effect to the audio.
Parameters
----------
delay : float, default=0
Base delay (in miliseconds) between 0 and 30.
depth : f... | [
"Apply",
"a",
"flanging",
"effect",
"to",
"the",
"audio",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1427-L1487 | [
"def",
"flanger",
"(",
"self",
",",
"delay",
"=",
"0",
",",
"depth",
"=",
"2",
",",
"regen",
"=",
"0",
",",
"width",
"=",
"71",
",",
"speed",
"=",
"0.5",
",",
"shape",
"=",
"'sine'",
",",
"phase",
"=",
"25",
",",
"interp",
"=",
"'linear'",
")",... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.gain | Apply amplification or attenuation to the audio signal.
Parameters
----------
gain_db : float, default=0.0
Gain adjustment in decibels (dB).
normalize : bool, default=True
If True, audio is normalized to gain_db relative to full scale.
If False, simpl... | sox/transform.py | def gain(self, gain_db=0.0, normalize=True, limiter=False, balance=None):
'''Apply amplification or attenuation to the audio signal.
Parameters
----------
gain_db : float, default=0.0
Gain adjustment in decibels (dB).
normalize : bool, default=True
If Tru... | def gain(self, gain_db=0.0, normalize=True, limiter=False, balance=None):
'''Apply amplification or attenuation to the audio signal.
Parameters
----------
gain_db : float, default=0.0
Gain adjustment in decibels (dB).
normalize : bool, default=True
If Tru... | [
"Apply",
"amplification",
"or",
"attenuation",
"to",
"the",
"audio",
"signal",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1489-L1547 | [
"def",
"gain",
"(",
"self",
",",
"gain_db",
"=",
"0.0",
",",
"normalize",
"=",
"True",
",",
"limiter",
"=",
"False",
",",
"balance",
"=",
"None",
")",
":",
"if",
"not",
"is_number",
"(",
"gain_db",
")",
":",
"raise",
"ValueError",
"(",
"\"gain_db must ... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.highpass | Apply a high-pass filter with 3dB point frequency. The filter can be
either single-pole or double-pole. The filters roll off at 6dB per pole
per octave (20dB per pole per decade).
Parameters
----------
frequency : float
The filter's cutoff frequency in Hz.
wi... | sox/transform.py | def highpass(self, frequency, width_q=0.707, n_poles=2):
'''Apply a high-pass filter with 3dB point frequency. The filter can be
either single-pole or double-pole. The filters roll off at 6dB per pole
per octave (20dB per pole per decade).
Parameters
----------
frequency... | def highpass(self, frequency, width_q=0.707, n_poles=2):
'''Apply a high-pass filter with 3dB point frequency. The filter can be
either single-pole or double-pole. The filters roll off at 6dB per pole
per octave (20dB per pole per decade).
Parameters
----------
frequency... | [
"Apply",
"a",
"high",
"-",
"pass",
"filter",
"with",
"3dB",
"point",
"frequency",
".",
"The",
"filter",
"can",
"be",
"either",
"single",
"-",
"pole",
"or",
"double",
"-",
"pole",
".",
"The",
"filters",
"roll",
"off",
"at",
"6dB",
"per",
"pole",
"per",
... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1549-L1588 | [
"def",
"highpass",
"(",
"self",
",",
"frequency",
",",
"width_q",
"=",
"0.707",
",",
"n_poles",
"=",
"2",
")",
":",
"if",
"not",
"is_number",
"(",
"frequency",
")",
"or",
"frequency",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"frequency must be a posit... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.hilbert | Apply an odd-tap Hilbert transform filter, phase-shifting the signal
by 90 degrees. This is used in many matrix coding schemes and for
analytic signal generation. The process is often written as a
multiplication by i (or j), the imaginary unit. An odd-tap Hilbert
transform filter has a b... | sox/transform.py | def hilbert(self, num_taps=None):
'''Apply an odd-tap Hilbert transform filter, phase-shifting the signal
by 90 degrees. This is used in many matrix coding schemes and for
analytic signal generation. The process is often written as a
multiplication by i (or j), the imaginary unit. An odd... | def hilbert(self, num_taps=None):
'''Apply an odd-tap Hilbert transform filter, phase-shifting the signal
by 90 degrees. This is used in many matrix coding schemes and for
analytic signal generation. The process is often written as a
multiplication by i (or j), the imaginary unit. An odd... | [
"Apply",
"an",
"odd",
"-",
"tap",
"Hilbert",
"transform",
"filter",
"phase",
"-",
"shifting",
"the",
"signal",
"by",
"90",
"degrees",
".",
"This",
"is",
"used",
"in",
"many",
"matrix",
"coding",
"schemes",
"and",
"for",
"analytic",
"signal",
"generation",
... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1631-L1660 | [
"def",
"hilbert",
"(",
"self",
",",
"num_taps",
"=",
"None",
")",
":",
"if",
"num_taps",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"num_taps",
",",
"int",
")",
":",
"raise",
"ValueError",
"(",
"\"num taps must be None or an odd integer.\"",
")",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.loudness | Loudness control. Similar to the gain effect, but provides
equalisation for the human auditory system.
The gain is adjusted by gain_db and the signal is equalised according
to ISO 226 w.r.t. reference_level.
Parameters
----------
gain_db : float, default=-10.0
... | sox/transform.py | def loudness(self, gain_db=-10.0, reference_level=65.0):
'''Loudness control. Similar to the gain effect, but provides
equalisation for the human auditory system.
The gain is adjusted by gain_db and the signal is equalised according
to ISO 226 w.r.t. reference_level.
Parameters... | def loudness(self, gain_db=-10.0, reference_level=65.0):
'''Loudness control. Similar to the gain effect, but provides
equalisation for the human auditory system.
The gain is adjusted by gain_db and the signal is equalised according
to ISO 226 w.r.t. reference_level.
Parameters... | [
"Loudness",
"control",
".",
"Similar",
"to",
"the",
"gain",
"effect",
"but",
"provides",
"equalisation",
"for",
"the",
"human",
"auditory",
"system",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1662-L1699 | [
"def",
"loudness",
"(",
"self",
",",
"gain_db",
"=",
"-",
"10.0",
",",
"reference_level",
"=",
"65.0",
")",
":",
"if",
"not",
"is_number",
"(",
"gain_db",
")",
":",
"raise",
"ValueError",
"(",
"'gain_db must be a number.'",
")",
"if",
"not",
"is_number",
"... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.mcompand | The multi-band compander is similar to the single-band compander but
the audio is first divided into bands using Linkwitz-Riley cross-over
filters and a separately specifiable compander run on each band.
When used with n_bands=1, this effect is identical to compand.
When using n_bands >... | sox/transform.py | def mcompand(self, n_bands=2, crossover_frequencies=[1600],
attack_time=[0.005, 0.000625], decay_time=[0.1, 0.0125],
soft_knee_db=[6.0, None],
tf_points=[[(-47, -40), (-34, -34), (-17, -33), (0, 0)],
[(-47, -40), (-34, -34), (-15, -33), (0, 0)]],
... | def mcompand(self, n_bands=2, crossover_frequencies=[1600],
attack_time=[0.005, 0.000625], decay_time=[0.1, 0.0125],
soft_knee_db=[6.0, None],
tf_points=[[(-47, -40), (-34, -34), (-17, -33), (0, 0)],
[(-47, -40), (-34, -34), (-15, -33), (0, 0)]],
... | [
"The",
"multi",
"-",
"band",
"compander",
"is",
"similar",
"to",
"the",
"single",
"-",
"band",
"compander",
"but",
"the",
"audio",
"is",
"first",
"divided",
"into",
"bands",
"using",
"Linkwitz",
"-",
"Riley",
"cross",
"-",
"over",
"filters",
"and",
"a",
... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1701-L1861 | [
"def",
"mcompand",
"(",
"self",
",",
"n_bands",
"=",
"2",
",",
"crossover_frequencies",
"=",
"[",
"1600",
"]",
",",
"attack_time",
"=",
"[",
"0.005",
",",
"0.000625",
"]",
",",
"decay_time",
"=",
"[",
"0.1",
",",
"0.0125",
"]",
",",
"soft_knee_db",
"="... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.noiseprof | Calculate a profile of the audio for use in noise reduction.
Running this command does not effect the Transformer effects
chain. When this function is called, the calculated noise profile
file is saved to the `profile_path`.
Parameters
----------
input_filepath : str
... | sox/transform.py | def noiseprof(self, input_filepath, profile_path):
'''Calculate a profile of the audio for use in noise reduction.
Running this command does not effect the Transformer effects
chain. When this function is called, the calculated noise profile
file is saved to the `profile_path`.
... | def noiseprof(self, input_filepath, profile_path):
'''Calculate a profile of the audio for use in noise reduction.
Running this command does not effect the Transformer effects
chain. When this function is called, the calculated noise profile
file is saved to the `profile_path`.
... | [
"Calculate",
"a",
"profile",
"of",
"the",
"audio",
"for",
"use",
"in",
"noise",
"reduction",
".",
"Running",
"this",
"command",
"does",
"not",
"effect",
"the",
"Transformer",
"effects",
"chain",
".",
"When",
"this",
"function",
"is",
"called",
"the",
"calcul... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1863-L1897 | [
"def",
"noiseprof",
"(",
"self",
",",
"input_filepath",
",",
"profile_path",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"profile_path",
")",
":",
"raise",
"ValueError",
"(",
"\"profile_path {} is a directory.\"",
".",
"format",
"(",
"profile_path",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.noisered | Reduce noise in the audio signal by profiling and filtering.
This effect is moderately effective at removing consistent
background noise such as hiss or hum.
Parameters
----------
profile_path : str
Path to a noise profile file.
This file can be generated... | sox/transform.py | def noisered(self, profile_path, amount=0.5):
'''Reduce noise in the audio signal by profiling and filtering.
This effect is moderately effective at removing consistent
background noise such as hiss or hum.
Parameters
----------
profile_path : str
Path to a n... | def noisered(self, profile_path, amount=0.5):
'''Reduce noise in the audio signal by profiling and filtering.
This effect is moderately effective at removing consistent
background noise such as hiss or hum.
Parameters
----------
profile_path : str
Path to a n... | [
"Reduce",
"noise",
"in",
"the",
"audio",
"signal",
"by",
"profiling",
"and",
"filtering",
".",
"This",
"effect",
"is",
"moderately",
"effective",
"at",
"removing",
"consistent",
"background",
"noise",
"such",
"as",
"hiss",
"or",
"hum",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1899-L1936 | [
"def",
"noisered",
"(",
"self",
",",
"profile_path",
",",
"amount",
"=",
"0.5",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"profile_path",
")",
":",
"raise",
"IOError",
"(",
"\"profile_path {} does not exist.\"",
".",
"format",
"(",
"pro... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.norm | Normalize an audio file to a particular db level.
This behaves identically to the gain effect with normalize=True.
Parameters
----------
db_level : float, default=-3.0
Output volume (db)
See Also
--------
gain, loudness | sox/transform.py | def norm(self, db_level=-3.0):
'''Normalize an audio file to a particular db level.
This behaves identically to the gain effect with normalize=True.
Parameters
----------
db_level : float, default=-3.0
Output volume (db)
See Also
--------
gai... | def norm(self, db_level=-3.0):
'''Normalize an audio file to a particular db level.
This behaves identically to the gain effect with normalize=True.
Parameters
----------
db_level : float, default=-3.0
Output volume (db)
See Also
--------
gai... | [
"Normalize",
"an",
"audio",
"file",
"to",
"a",
"particular",
"db",
"level",
".",
"This",
"behaves",
"identically",
"to",
"the",
"gain",
"effect",
"with",
"normalize",
"=",
"True",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1938-L1962 | [
"def",
"norm",
"(",
"self",
",",
"db_level",
"=",
"-",
"3.0",
")",
":",
"if",
"not",
"is_number",
"(",
"db_level",
")",
":",
"raise",
"ValueError",
"(",
"'db_level must be a number.'",
")",
"effect_args",
"=",
"[",
"'norm'",
",",
"'{:f}'",
".",
"format",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.oops | Out Of Phase Stereo effect. Mixes stereo to twin-mono where each
mono channel contains the difference between the left and right stereo
channels. This is sometimes known as the 'karaoke' effect as it often
has the effect of removing most or all of the vocals from a recording. | sox/transform.py | def oops(self):
'''Out Of Phase Stereo effect. Mixes stereo to twin-mono where each
mono channel contains the difference between the left and right stereo
channels. This is sometimes known as the 'karaoke' effect as it often
has the effect of removing most or all of the vocals from a rec... | def oops(self):
'''Out Of Phase Stereo effect. Mixes stereo to twin-mono where each
mono channel contains the difference between the left and right stereo
channels. This is sometimes known as the 'karaoke' effect as it often
has the effect of removing most or all of the vocals from a rec... | [
"Out",
"Of",
"Phase",
"Stereo",
"effect",
".",
"Mixes",
"stereo",
"to",
"twin",
"-",
"mono",
"where",
"each",
"mono",
"channel",
"contains",
"the",
"difference",
"between",
"the",
"left",
"and",
"right",
"stereo",
"channels",
".",
"This",
"is",
"sometimes",
... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1964-L1975 | [
"def",
"oops",
"(",
"self",
")",
":",
"effect_args",
"=",
"[",
"'oops'",
"]",
"self",
".",
"effects",
".",
"extend",
"(",
"effect_args",
")",
"self",
".",
"effects_log",
".",
"append",
"(",
"'oops'",
")",
"return",
"self"
] | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.overdrive | Apply non-linear distortion.
Parameters
----------
gain_db : float, default=20
Controls the amount of distortion (dB).
colour : float, default=20
Controls the amount of even harmonic content in the output (dB). | sox/transform.py | def overdrive(self, gain_db=20.0, colour=20.0):
'''Apply non-linear distortion.
Parameters
----------
gain_db : float, default=20
Controls the amount of distortion (dB).
colour : float, default=20
Controls the amount of even harmonic content in the output... | def overdrive(self, gain_db=20.0, colour=20.0):
'''Apply non-linear distortion.
Parameters
----------
gain_db : float, default=20
Controls the amount of distortion (dB).
colour : float, default=20
Controls the amount of even harmonic content in the output... | [
"Apply",
"non",
"-",
"linear",
"distortion",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L1977-L2002 | [
"def",
"overdrive",
"(",
"self",
",",
"gain_db",
"=",
"20.0",
",",
"colour",
"=",
"20.0",
")",
":",
"if",
"not",
"is_number",
"(",
"gain_db",
")",
":",
"raise",
"ValueError",
"(",
"'db_level must be a number.'",
")",
"if",
"not",
"is_number",
"(",
"colour"... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.pad | Add silence to the beginning or end of a file.
Calling this with the default arguments has no effect.
Parameters
----------
start_duration : float
Number of seconds of silence to add to beginning.
end_duration : float
Number of seconds of silence to add t... | sox/transform.py | def pad(self, start_duration=0.0, end_duration=0.0):
'''Add silence to the beginning or end of a file.
Calling this with the default arguments has no effect.
Parameters
----------
start_duration : float
Number of seconds of silence to add to beginning.
end_du... | def pad(self, start_duration=0.0, end_duration=0.0):
'''Add silence to the beginning or end of a file.
Calling this with the default arguments has no effect.
Parameters
----------
start_duration : float
Number of seconds of silence to add to beginning.
end_du... | [
"Add",
"silence",
"to",
"the",
"beginning",
"or",
"end",
"of",
"a",
"file",
".",
"Calling",
"this",
"with",
"the",
"default",
"arguments",
"has",
"no",
"effect",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2004-L2034 | [
"def",
"pad",
"(",
"self",
",",
"start_duration",
"=",
"0.0",
",",
"end_duration",
"=",
"0.0",
")",
":",
"if",
"not",
"is_number",
"(",
"start_duration",
")",
"or",
"start_duration",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"Start duration must be a positi... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.phaser | Apply a phasing effect to the audio.
Parameters
----------
gain_in : float, default=0.8
Input volume between 0 and 1
gain_out: float, default=0.74
Output volume between 0 and 1
delay : float, default=3
Delay in miliseconds between 0 and 5
... | sox/transform.py | def phaser(self, gain_in=0.8, gain_out=0.74, delay=3, decay=0.4, speed=0.5,
modulation_shape='sinusoidal'):
'''Apply a phasing effect to the audio.
Parameters
----------
gain_in : float, default=0.8
Input volume between 0 and 1
gain_out: float, default... | def phaser(self, gain_in=0.8, gain_out=0.74, delay=3, decay=0.4, speed=0.5,
modulation_shape='sinusoidal'):
'''Apply a phasing effect to the audio.
Parameters
----------
gain_in : float, default=0.8
Input volume between 0 and 1
gain_out: float, default... | [
"Apply",
"a",
"phasing",
"effect",
"to",
"the",
"audio",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2036-L2096 | [
"def",
"phaser",
"(",
"self",
",",
"gain_in",
"=",
"0.8",
",",
"gain_out",
"=",
"0.74",
",",
"delay",
"=",
"3",
",",
"decay",
"=",
"0.4",
",",
"speed",
"=",
"0.5",
",",
"modulation_shape",
"=",
"'sinusoidal'",
")",
":",
"if",
"not",
"is_number",
"(",... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.pitch | Pitch shift the audio without changing the tempo.
This effect uses the WSOLA algorithm. The audio is chopped up into
segments which are then shifted in the time domain and overlapped
(cross-faded) at points where their waveforms are most similar as
determined by measurement of least squ... | sox/transform.py | def pitch(self, n_semitones, quick=False):
'''Pitch shift the audio without changing the tempo.
This effect uses the WSOLA algorithm. The audio is chopped up into
segments which are then shifted in the time domain and overlapped
(cross-faded) at points where their waveforms are most sim... | def pitch(self, n_semitones, quick=False):
'''Pitch shift the audio without changing the tempo.
This effect uses the WSOLA algorithm. The audio is chopped up into
segments which are then shifted in the time domain and overlapped
(cross-faded) at points where their waveforms are most sim... | [
"Pitch",
"shift",
"the",
"audio",
"without",
"changing",
"the",
"tempo",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2098-L2140 | [
"def",
"pitch",
"(",
"self",
",",
"n_semitones",
",",
"quick",
"=",
"False",
")",
":",
"if",
"not",
"is_number",
"(",
"n_semitones",
")",
":",
"raise",
"ValueError",
"(",
"\"n_semitones must be a positive number\"",
")",
"if",
"n_semitones",
"<",
"-",
"12",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.rate | Change the audio sampling rate (i.e. resample the audio) to any
given `samplerate`. Better the resampling quality = slower runtime.
Parameters
----------
samplerate : float
Desired sample rate.
quality : str
Resampling quality. One of:
* q : ... | sox/transform.py | def rate(self, samplerate, quality='h'):
'''Change the audio sampling rate (i.e. resample the audio) to any
given `samplerate`. Better the resampling quality = slower runtime.
Parameters
----------
samplerate : float
Desired sample rate.
quality : str
... | def rate(self, samplerate, quality='h'):
'''Change the audio sampling rate (i.e. resample the audio) to any
given `samplerate`. Better the resampling quality = slower runtime.
Parameters
----------
samplerate : float
Desired sample rate.
quality : str
... | [
"Change",
"the",
"audio",
"sampling",
"rate",
"(",
"i",
".",
"e",
".",
"resample",
"the",
"audio",
")",
"to",
"any",
"given",
"samplerate",
".",
"Better",
"the",
"resampling",
"quality",
"=",
"slower",
"runtime",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2142-L2180 | [
"def",
"rate",
"(",
"self",
",",
"samplerate",
",",
"quality",
"=",
"'h'",
")",
":",
"quality_vals",
"=",
"[",
"'q'",
",",
"'l'",
",",
"'m'",
",",
"'h'",
",",
"'v'",
"]",
"if",
"not",
"is_number",
"(",
"samplerate",
")",
"or",
"samplerate",
"<=",
"... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.remix | Remix the channels of an audio file.
Note: volume options are not yet implemented
Parameters
----------
remix_dictionary : dict or None
Dictionary mapping output channel to list of input channel(s).
Empty lists indicate the corresponding output channel should be... | sox/transform.py | def remix(self, remix_dictionary=None, num_output_channels=None):
'''Remix the channels of an audio file.
Note: volume options are not yet implemented
Parameters
----------
remix_dictionary : dict or None
Dictionary mapping output channel to list of input channel(s)... | def remix(self, remix_dictionary=None, num_output_channels=None):
'''Remix the channels of an audio file.
Note: volume options are not yet implemented
Parameters
----------
remix_dictionary : dict or None
Dictionary mapping output channel to list of input channel(s)... | [
"Remix",
"the",
"channels",
"of",
"an",
"audio",
"file",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2182-L2260 | [
"def",
"remix",
"(",
"self",
",",
"remix_dictionary",
"=",
"None",
",",
"num_output_channels",
"=",
"None",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"remix_dictionary",
",",
"dict",
")",
"or",
"remix_dictionary",
"is",
"None",
")",
":",
"raise",
"Val... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.repeat | Repeat the entire audio count times.
Parameters
----------
count : int, default=1
The number of times to repeat the audio. | sox/transform.py | def repeat(self, count=1):
'''Repeat the entire audio count times.
Parameters
----------
count : int, default=1
The number of times to repeat the audio.
'''
if not isinstance(count, int) or count < 1:
raise ValueError("count must be a postive int... | def repeat(self, count=1):
'''Repeat the entire audio count times.
Parameters
----------
count : int, default=1
The number of times to repeat the audio.
'''
if not isinstance(count, int) or count < 1:
raise ValueError("count must be a postive int... | [
"Repeat",
"the",
"entire",
"audio",
"count",
"times",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2262-L2276 | [
"def",
"repeat",
"(",
"self",
",",
"count",
"=",
"1",
")",
":",
"if",
"not",
"isinstance",
"(",
"count",
",",
"int",
")",
"or",
"count",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"\"count must be a postive integer.\"",
")",
"effect_args",
"=",
"[",
"'re... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.reverb | Add reverberation to the audio using the ‘freeverb’ algorithm.
A reverberation effect is sometimes desirable for concert halls that
are too small or contain so many people that the hall’s natural
reverberance is diminished. Applying a small amount of stereo reverb
to a (dry) mono signal ... | sox/transform.py | def reverb(self, reverberance=50, high_freq_damping=50, room_scale=100,
stereo_depth=100, pre_delay=0, wet_gain=0, wet_only=False):
'''Add reverberation to the audio using the ‘freeverb’ algorithm.
A reverberation effect is sometimes desirable for concert halls that
are too small ... | def reverb(self, reverberance=50, high_freq_damping=50, room_scale=100,
stereo_depth=100, pre_delay=0, wet_gain=0, wet_only=False):
'''Add reverberation to the audio using the ‘freeverb’ algorithm.
A reverberation effect is sometimes desirable for concert halls that
are too small ... | [
"Add",
"reverberation",
"to",
"the",
"audio",
"using",
"the",
"‘freeverb’",
"algorithm",
".",
"A",
"reverberation",
"effect",
"is",
"sometimes",
"desirable",
"for",
"concert",
"halls",
"that",
"are",
"too",
"small",
"or",
"contain",
"so",
"many",
"people",
"th... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2278-L2351 | [
"def",
"reverb",
"(",
"self",
",",
"reverberance",
"=",
"50",
",",
"high_freq_damping",
"=",
"50",
",",
"room_scale",
"=",
"100",
",",
"stereo_depth",
"=",
"100",
",",
"pre_delay",
"=",
"0",
",",
"wet_gain",
"=",
"0",
",",
"wet_only",
"=",
"False",
")"... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.reverse | Reverse the audio completely | sox/transform.py | def reverse(self):
'''Reverse the audio completely
'''
effect_args = ['reverse']
self.effects.extend(effect_args)
self.effects_log.append('reverse')
return self | def reverse(self):
'''Reverse the audio completely
'''
effect_args = ['reverse']
self.effects.extend(effect_args)
self.effects_log.append('reverse')
return self | [
"Reverse",
"the",
"audio",
"completely"
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2353-L2360 | [
"def",
"reverse",
"(",
"self",
")",
":",
"effect_args",
"=",
"[",
"'reverse'",
"]",
"self",
".",
"effects",
".",
"extend",
"(",
"effect_args",
")",
"self",
".",
"effects_log",
".",
"append",
"(",
"'reverse'",
")",
"return",
"self"
] | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.silence | Removes silent regions from an audio file.
Parameters
----------
location : int, default=0
Where to remove silence. One of:
* 0 to remove silence throughout the file (default),
* 1 to remove silence from the beginning,
* -1 to remove silence fr... | sox/transform.py | def silence(self, location=0, silence_threshold=0.1,
min_silence_duration=0.1, buffer_around_silence=False):
'''Removes silent regions from an audio file.
Parameters
----------
location : int, default=0
Where to remove silence. One of:
* 0 to rem... | def silence(self, location=0, silence_threshold=0.1,
min_silence_duration=0.1, buffer_around_silence=False):
'''Removes silent regions from an audio file.
Parameters
----------
location : int, default=0
Where to remove silence. One of:
* 0 to rem... | [
"Removes",
"silent",
"regions",
"from",
"an",
"audio",
"file",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2362-L2437 | [
"def",
"silence",
"(",
"self",
",",
"location",
"=",
"0",
",",
"silence_threshold",
"=",
"0.1",
",",
"min_silence_duration",
"=",
"0.1",
",",
"buffer_around_silence",
"=",
"False",
")",
":",
"if",
"location",
"not",
"in",
"[",
"-",
"1",
",",
"0",
",",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.sinc | Apply a sinc kaiser-windowed low-pass, high-pass, band-pass, or
band-reject filter to the signal.
Parameters
----------
filter_type : str, default='high'
Type of filter. One of:
- 'high' for a high-pass filter
- 'low' for a low-pass filter
... | sox/transform.py | def sinc(self, filter_type='high', cutoff_freq=3000,
stop_band_attenuation=120, transition_bw=None,
phase_response=None):
'''Apply a sinc kaiser-windowed low-pass, high-pass, band-pass, or
band-reject filter to the signal.
Parameters
----------
filter_t... | def sinc(self, filter_type='high', cutoff_freq=3000,
stop_band_attenuation=120, transition_bw=None,
phase_response=None):
'''Apply a sinc kaiser-windowed low-pass, high-pass, band-pass, or
band-reject filter to the signal.
Parameters
----------
filter_t... | [
"Apply",
"a",
"sinc",
"kaiser",
"-",
"windowed",
"low",
"-",
"pass",
"high",
"-",
"pass",
"band",
"-",
"pass",
"or",
"band",
"-",
"reject",
"filter",
"to",
"the",
"signal",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2439-L2580 | [
"def",
"sinc",
"(",
"self",
",",
"filter_type",
"=",
"'high'",
",",
"cutoff_freq",
"=",
"3000",
",",
"stop_band_attenuation",
"=",
"120",
",",
"transition_bw",
"=",
"None",
",",
"phase_response",
"=",
"None",
")",
":",
"filter_types",
"=",
"[",
"'high'",
"... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.speed | Adjust the audio speed (pitch and tempo together).
Technically, the speed effect only changes the sample rate information,
leaving the samples themselves untouched. The rate effect is invoked
automatically to resample to the output sample rate, using its default
quality/speed. For highe... | sox/transform.py | def speed(self, factor):
'''Adjust the audio speed (pitch and tempo together).
Technically, the speed effect only changes the sample rate information,
leaving the samples themselves untouched. The rate effect is invoked
automatically to resample to the output sample rate, using its defa... | def speed(self, factor):
'''Adjust the audio speed (pitch and tempo together).
Technically, the speed effect only changes the sample rate information,
leaving the samples themselves untouched. The rate effect is invoked
automatically to resample to the output sample rate, using its defa... | [
"Adjust",
"the",
"audio",
"speed",
"(",
"pitch",
"and",
"tempo",
"together",
")",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2582-L2617 | [
"def",
"speed",
"(",
"self",
",",
"factor",
")",
":",
"if",
"not",
"is_number",
"(",
"factor",
")",
"or",
"factor",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"factor must be a positive number\"",
")",
"if",
"factor",
"<",
"0.5",
"or",
"factor",
">",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.stat | Display time and frequency domain statistical information about the
audio. Audio is passed unmodified through the SoX processing chain.
Unlike other Transformer methods, this does not modify the transformer
effects chain. Instead it computes statistics on the output file that
would be c... | sox/transform.py | def stat(self, input_filepath, scale=None, rms=False):
'''Display time and frequency domain statistical information about the
audio. Audio is passed unmodified through the SoX processing chain.
Unlike other Transformer methods, this does not modify the transformer
effects chain. Instead... | def stat(self, input_filepath, scale=None, rms=False):
'''Display time and frequency domain statistical information about the
audio. Audio is passed unmodified through the SoX processing chain.
Unlike other Transformer methods, this does not modify the transformer
effects chain. Instead... | [
"Display",
"time",
"and",
"frequency",
"domain",
"statistical",
"information",
"about",
"the",
"audio",
".",
"Audio",
"is",
"passed",
"unmodified",
"through",
"the",
"SoX",
"processing",
"chain",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2619-L2670 | [
"def",
"stat",
"(",
"self",
",",
"input_filepath",
",",
"scale",
"=",
"None",
",",
"rms",
"=",
"False",
")",
":",
"effect_args",
"=",
"[",
"'channels'",
",",
"'1'",
",",
"'stat'",
"]",
"if",
"scale",
"is",
"not",
"None",
":",
"if",
"not",
"is_number"... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.power_spectrum | Calculates the power spectrum (4096 point DFT). This method
internally invokes the stat command with the -freq option.
Note: The file is downmixed to mono prior to computation.
Parameters
----------
input_filepath : str
Path to input file to compute stats on.
... | sox/transform.py | def power_spectrum(self, input_filepath):
'''Calculates the power spectrum (4096 point DFT). This method
internally invokes the stat command with the -freq option.
Note: The file is downmixed to mono prior to computation.
Parameters
----------
input_filepath : str
... | def power_spectrum(self, input_filepath):
'''Calculates the power spectrum (4096 point DFT). This method
internally invokes the stat command with the -freq option.
Note: The file is downmixed to mono prior to computation.
Parameters
----------
input_filepath : str
... | [
"Calculates",
"the",
"power",
"spectrum",
"(",
"4096",
"point",
"DFT",
")",
".",
"This",
"method",
"internally",
"invokes",
"the",
"stat",
"command",
"with",
"the",
"-",
"freq",
"option",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2672-L2708 | [
"def",
"power_spectrum",
"(",
"self",
",",
"input_filepath",
")",
":",
"effect_args",
"=",
"[",
"'channels'",
",",
"'1'",
",",
"'stat'",
",",
"'-freq'",
"]",
"_",
",",
"_",
",",
"stat_output",
"=",
"self",
".",
"build",
"(",
"input_filepath",
",",
"None"... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.stats | Display time domain statistical information about the audio
channels. Audio is passed unmodified through the SoX processing chain.
Statistics are calculated and displayed for each audio channel
Unlike other Transformer methods, this does not modify the transformer
effects chain. Instead... | sox/transform.py | def stats(self, input_filepath):
'''Display time domain statistical information about the audio
channels. Audio is passed unmodified through the SoX processing chain.
Statistics are calculated and displayed for each audio channel
Unlike other Transformer methods, this does not modify th... | def stats(self, input_filepath):
'''Display time domain statistical information about the audio
channels. Audio is passed unmodified through the SoX processing chain.
Statistics are calculated and displayed for each audio channel
Unlike other Transformer methods, this does not modify th... | [
"Display",
"time",
"domain",
"statistical",
"information",
"about",
"the",
"audio",
"channels",
".",
"Audio",
"is",
"passed",
"unmodified",
"through",
"the",
"SoX",
"processing",
"chain",
".",
"Statistics",
"are",
"calculated",
"and",
"displayed",
"for",
"each",
... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2710-L2751 | [
"def",
"stats",
"(",
"self",
",",
"input_filepath",
")",
":",
"effect_args",
"=",
"[",
"'channels'",
",",
"'1'",
",",
"'stats'",
"]",
"_",
",",
"_",
",",
"stats_output",
"=",
"self",
".",
"build",
"(",
"input_filepath",
",",
"None",
",",
"extra_args",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.stretch | Change the audio duration (but not its pitch).
**Unless factor is close to 1, use the tempo effect instead.**
This effect is broadly equivalent to the tempo effect with search set
to zero, so in general, its results are comparatively poor; it is
retained as it can sometimes out-perform ... | sox/transform.py | def stretch(self, factor, window=20):
'''Change the audio duration (but not its pitch).
**Unless factor is close to 1, use the tempo effect instead.**
This effect is broadly equivalent to the tempo effect with search set
to zero, so in general, its results are comparatively poor; it is
... | def stretch(self, factor, window=20):
'''Change the audio duration (but not its pitch).
**Unless factor is close to 1, use the tempo effect instead.**
This effect is broadly equivalent to the tempo effect with search set
to zero, so in general, its results are comparatively poor; it is
... | [
"Change",
"the",
"audio",
"duration",
"(",
"but",
"not",
"its",
"pitch",
")",
".",
"**",
"Unless",
"factor",
"is",
"close",
"to",
"1",
"use",
"the",
"tempo",
"effect",
"instead",
".",
"**"
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2753-L2801 | [
"def",
"stretch",
"(",
"self",
",",
"factor",
",",
"window",
"=",
"20",
")",
":",
"if",
"not",
"is_number",
"(",
"factor",
")",
"or",
"factor",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"factor must be a positive number\"",
")",
"if",
"factor",
"<",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.swap | Swap stereo channels. If the input is not stereo, pairs of channels
are swapped, and a possible odd last channel passed through.
E.g., for seven channels, the output order will be 2, 1, 4, 3, 6, 5, 7.
See Also
----------
remix | sox/transform.py | def swap(self):
'''Swap stereo channels. If the input is not stereo, pairs of channels
are swapped, and a possible odd last channel passed through.
E.g., for seven channels, the output order will be 2, 1, 4, 3, 6, 5, 7.
See Also
----------
remix
'''
eff... | def swap(self):
'''Swap stereo channels. If the input is not stereo, pairs of channels
are swapped, and a possible odd last channel passed through.
E.g., for seven channels, the output order will be 2, 1, 4, 3, 6, 5, 7.
See Also
----------
remix
'''
eff... | [
"Swap",
"stereo",
"channels",
".",
"If",
"the",
"input",
"is",
"not",
"stereo",
"pairs",
"of",
"channels",
"are",
"swapped",
"and",
"a",
"possible",
"odd",
"last",
"channel",
"passed",
"through",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2803-L2818 | [
"def",
"swap",
"(",
"self",
")",
":",
"effect_args",
"=",
"[",
"'swap'",
"]",
"self",
".",
"effects",
".",
"extend",
"(",
"effect_args",
")",
"self",
".",
"effects_log",
".",
"append",
"(",
"'swap'",
")",
"return",
"self"
] | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.tempo | Time stretch audio without changing pitch.
This effect uses the WSOLA algorithm. The audio is chopped up into
segments which are then shifted in the time domain and overlapped
(cross-faded) at points where their waveforms are most similar as
determined by measurement of least squares.
... | sox/transform.py | def tempo(self, factor, audio_type=None, quick=False):
'''Time stretch audio without changing pitch.
This effect uses the WSOLA algorithm. The audio is chopped up into
segments which are then shifted in the time domain and overlapped
(cross-faded) at points where their waveforms are mos... | def tempo(self, factor, audio_type=None, quick=False):
'''Time stretch audio without changing pitch.
This effect uses the WSOLA algorithm. The audio is chopped up into
segments which are then shifted in the time domain and overlapped
(cross-faded) at points where their waveforms are mos... | [
"Time",
"stretch",
"audio",
"without",
"changing",
"pitch",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2820-L2882 | [
"def",
"tempo",
"(",
"self",
",",
"factor",
",",
"audio_type",
"=",
"None",
",",
"quick",
"=",
"False",
")",
":",
"if",
"not",
"is_number",
"(",
"factor",
")",
"or",
"factor",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"factor must be a positive number\... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.treble | Boost or cut the treble (lower) frequencies of the audio using a
two-pole shelving filter with a response similar to that of a standard
hi-fi’s tone-controls. This is also known as shelving equalisation.
The filters are described in detail in
http://musicdsp.org/files/Audio-EQ-Cookbook.... | sox/transform.py | def treble(self, gain_db, frequency=3000.0, slope=0.5):
'''Boost or cut the treble (lower) frequencies of the audio using a
two-pole shelving filter with a response similar to that of a standard
hi-fi’s tone-controls. This is also known as shelving equalisation.
The filters are describe... | def treble(self, gain_db, frequency=3000.0, slope=0.5):
'''Boost or cut the treble (lower) frequencies of the audio using a
two-pole shelving filter with a response similar to that of a standard
hi-fi’s tone-controls. This is also known as shelving equalisation.
The filters are describe... | [
"Boost",
"or",
"cut",
"the",
"treble",
"(",
"lower",
")",
"frequencies",
"of",
"the",
"audio",
"using",
"a",
"two",
"-",
"pole",
"shelving",
"filter",
"with",
"a",
"response",
"similar",
"to",
"that",
"of",
"a",
"standard",
"hi",
"-",
"fi’s",
"tone",
"... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2884-L2925 | [
"def",
"treble",
"(",
"self",
",",
"gain_db",
",",
"frequency",
"=",
"3000.0",
",",
"slope",
"=",
"0.5",
")",
":",
"if",
"not",
"is_number",
"(",
"gain_db",
")",
":",
"raise",
"ValueError",
"(",
"\"gain_db must be a number\"",
")",
"if",
"not",
"is_number"... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.tremolo | Apply a tremolo (low frequency amplitude modulation) effect to the
audio. The tremolo frequency in Hz is giv en by speed, and the depth
as a percentage by depth (default 40).
Parameters
----------
speed : float
Tremolo speed in Hz.
depth : float
T... | sox/transform.py | def tremolo(self, speed=6.0, depth=40.0):
'''Apply a tremolo (low frequency amplitude modulation) effect to the
audio. The tremolo frequency in Hz is giv en by speed, and the depth
as a percentage by depth (default 40).
Parameters
----------
speed : float
Tre... | def tremolo(self, speed=6.0, depth=40.0):
'''Apply a tremolo (low frequency amplitude modulation) effect to the
audio. The tremolo frequency in Hz is giv en by speed, and the depth
as a percentage by depth (default 40).
Parameters
----------
speed : float
Tre... | [
"Apply",
"a",
"tremolo",
"(",
"low",
"frequency",
"amplitude",
"modulation",
")",
"effect",
"to",
"the",
"audio",
".",
"The",
"tremolo",
"frequency",
"in",
"Hz",
"is",
"giv",
"en",
"by",
"speed",
"and",
"the",
"depth",
"as",
"a",
"percentage",
"by",
"dep... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2927-L2965 | [
"def",
"tremolo",
"(",
"self",
",",
"speed",
"=",
"6.0",
",",
"depth",
"=",
"40.0",
")",
":",
"if",
"not",
"is_number",
"(",
"speed",
")",
"or",
"speed",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"speed must be a positive number.\"",
")",
"if",
"not"... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.trim | Excerpt a clip from an audio file, given the start timestamp and end timestamp of the clip within the file, expressed in seconds. If the end timestamp is set to `None` or left unspecified, it defaults to the duration of the audio file.
Parameters
----------
start_time : float
Start ... | sox/transform.py | def trim(self, start_time, end_time=None):
'''Excerpt a clip from an audio file, given the start timestamp and end timestamp of the clip within the file, expressed in seconds. If the end timestamp is set to `None` or left unspecified, it defaults to the duration of the audio file.
Parameters
--... | def trim(self, start_time, end_time=None):
'''Excerpt a clip from an audio file, given the start timestamp and end timestamp of the clip within the file, expressed in seconds. If the end timestamp is set to `None` or left unspecified, it defaults to the duration of the audio file.
Parameters
--... | [
"Excerpt",
"a",
"clip",
"from",
"an",
"audio",
"file",
"given",
"the",
"start",
"timestamp",
"and",
"end",
"timestamp",
"of",
"the",
"clip",
"within",
"the",
"file",
"expressed",
"in",
"seconds",
".",
"If",
"the",
"end",
"timestamp",
"is",
"set",
"to",
"... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2967-L2997 | [
"def",
"trim",
"(",
"self",
",",
"start_time",
",",
"end_time",
"=",
"None",
")",
":",
"if",
"not",
"is_number",
"(",
"start_time",
")",
"or",
"start_time",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"start_time must be a positive number.\"",
")",
"effect_ar... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.vad | Voice Activity Detector. Attempts to trim silence and quiet
background sounds from the ends of recordings of speech. The algorithm
currently uses a simple cepstral power measurement to detect voice, so
may be fooled by other things, especially music.
The effect can trim only from the fr... | sox/transform.py | def vad(self, location=1, normalize=True, activity_threshold=7.0,
min_activity_duration=0.25, initial_search_buffer=1.0,
max_gap=0.25, initial_pad=0.0):
'''Voice Activity Detector. Attempts to trim silence and quiet
background sounds from the ends of recordings of speech. The alg... | def vad(self, location=1, normalize=True, activity_threshold=7.0,
min_activity_duration=0.25, initial_search_buffer=1.0,
max_gap=0.25, initial_pad=0.0):
'''Voice Activity Detector. Attempts to trim silence and quiet
background sounds from the ends of recordings of speech. The alg... | [
"Voice",
"Activity",
"Detector",
".",
"Attempts",
"to",
"trim",
"silence",
"and",
"quiet",
"background",
"sounds",
"from",
"the",
"ends",
"of",
"recordings",
"of",
"speech",
".",
"The",
"algorithm",
"currently",
"uses",
"a",
"simple",
"cepstral",
"power",
"mea... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L3026-L3116 | [
"def",
"vad",
"(",
"self",
",",
"location",
"=",
"1",
",",
"normalize",
"=",
"True",
",",
"activity_threshold",
"=",
"7.0",
",",
"min_activity_duration",
"=",
"0.25",
",",
"initial_search_buffer",
"=",
"1.0",
",",
"max_gap",
"=",
"0.25",
",",
"initial_pad",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.vol | Apply an amplification or an attenuation to the audio signal.
Parameters
----------
gain : float
Interpreted according to the given `gain_type`.
If `gain_type' = 'amplitude', `gain' is a positive amplitude ratio.
If `gain_type' = 'power', `gain' is a power (v... | sox/transform.py | def vol(self, gain, gain_type='amplitude', limiter_gain=None):
'''Apply an amplification or an attenuation to the audio signal.
Parameters
----------
gain : float
Interpreted according to the given `gain_type`.
If `gain_type' = 'amplitude', `gain' is a positive a... | def vol(self, gain, gain_type='amplitude', limiter_gain=None):
'''Apply an amplification or an attenuation to the audio signal.
Parameters
----------
gain : float
Interpreted according to the given `gain_type`.
If `gain_type' = 'amplitude', `gain' is a positive a... | [
"Apply",
"an",
"amplification",
"or",
"an",
"attenuation",
"to",
"the",
"audio",
"signal",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L3118-L3178 | [
"def",
"vol",
"(",
"self",
",",
"gain",
",",
"gain_type",
"=",
"'amplitude'",
",",
"limiter_gain",
"=",
"None",
")",
":",
"if",
"not",
"is_number",
"(",
"gain",
")",
":",
"raise",
"ValueError",
"(",
"'gain must be a number.'",
")",
"if",
"limiter_gain",
"i... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | NamedUsersRoomsMixin.join | Lets a user join a room on a specific Namespace. | examples/simple_pyramid_chat/chatter2/views.py | def join(self, room):
"""Lets a user join a room on a specific Namespace."""
self.socket.rooms.add(self._get_room_name(room)) | def join(self, room):
"""Lets a user join a room on a specific Namespace."""
self.socket.rooms.add(self._get_room_name(room)) | [
"Lets",
"a",
"user",
"join",
"a",
"room",
"on",
"a",
"specific",
"Namespace",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/examples/simple_pyramid_chat/chatter2/views.py#L18-L20 | [
"def",
"join",
"(",
"self",
",",
"room",
")",
":",
"self",
".",
"socket",
".",
"rooms",
".",
"add",
"(",
"self",
".",
"_get_room_name",
"(",
"room",
")",
")"
] | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | NamedUsersRoomsMixin.leave | Lets a user leave a room on a specific Namespace. | examples/simple_pyramid_chat/chatter2/views.py | def leave(self, room):
"""Lets a user leave a room on a specific Namespace."""
self.socket.rooms.remove(self._get_room_name(room)) | def leave(self, room):
"""Lets a user leave a room on a specific Namespace."""
self.socket.rooms.remove(self._get_room_name(room)) | [
"Lets",
"a",
"user",
"leave",
"a",
"room",
"on",
"a",
"specific",
"Namespace",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/examples/simple_pyramid_chat/chatter2/views.py#L22-L24 | [
"def",
"leave",
"(",
"self",
",",
"room",
")",
":",
"self",
".",
"socket",
".",
"rooms",
".",
"remove",
"(",
"self",
".",
"_get_room_name",
"(",
"room",
")",
")"
] | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | socketio_manage | Main SocketIO management function, call from within your Framework of
choice's view.
The ``environ`` variable is the WSGI ``environ``. It is used to extract
Socket object from the underlying server (as the 'socketio' key), and will
be attached to both the ``Socket`` and ``Namespace`` objects.
The... | socketio/__init__.py | def socketio_manage(environ, namespaces, request=None, error_handler=None,
json_loads=None, json_dumps=None):
"""Main SocketIO management function, call from within your Framework of
choice's view.
The ``environ`` variable is the WSGI ``environ``. It is used to extract
Socket objec... | def socketio_manage(environ, namespaces, request=None, error_handler=None,
json_loads=None, json_dumps=None):
"""Main SocketIO management function, call from within your Framework of
choice's view.
The ``environ`` variable is the WSGI ``environ``. It is used to extract
Socket objec... | [
"Main",
"SocketIO",
"management",
"function",
"call",
"from",
"within",
"your",
"Framework",
"of",
"choice",
"s",
"view",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/__init__.py#L9-L87 | [
"def",
"socketio_manage",
"(",
"environ",
",",
"namespaces",
",",
"request",
"=",
"None",
",",
"error_handler",
"=",
"None",
",",
"json_loads",
"=",
"None",
",",
"json_dumps",
"=",
"None",
")",
":",
"socket",
"=",
"environ",
"[",
"'socketio'",
"]",
"socket... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | default_error_handler | This is the default error handler, you can override this when
calling :func:`socketio.socketio_manage`.
It basically sends an event through the socket with the 'error' name.
See documentation for :meth:`Socket.error`.
:param quiet: if quiet, this handler will not send a packet to the
... | socketio/virtsocket.py | def default_error_handler(socket, error_name, error_message, endpoint,
msg_id, quiet):
"""This is the default error handler, you can override this when
calling :func:`socketio.socketio_manage`.
It basically sends an event through the socket with the 'error' name.
See document... | def default_error_handler(socket, error_name, error_message, endpoint,
msg_id, quiet):
"""This is the default error handler, you can override this when
calling :func:`socketio.socketio_manage`.
It basically sends an event through the socket with the 'error' name.
See document... | [
"This",
"is",
"the",
"default",
"error",
"handler",
"you",
"can",
"override",
"this",
"when",
"calling",
":",
"func",
":",
"socketio",
".",
"socketio_manage",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L28-L53 | [
"def",
"default_error_handler",
"(",
"socket",
",",
"error_name",
",",
"error_message",
",",
"endpoint",
",",
"msg_id",
",",
"quiet",
")",
":",
"pkt",
"=",
"dict",
"(",
"type",
"=",
"'event'",
",",
"name",
"=",
"'error'",
",",
"args",
"=",
"[",
"error_na... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | Socket._save_ack_callback | Keep a reference of the callback on this socket. | socketio/virtsocket.py | def _save_ack_callback(self, msgid, callback):
"""Keep a reference of the callback on this socket."""
if msgid in self.ack_callbacks:
return False
self.ack_callbacks[msgid] = callback | def _save_ack_callback(self, msgid, callback):
"""Keep a reference of the callback on this socket."""
if msgid in self.ack_callbacks:
return False
self.ack_callbacks[msgid] = callback | [
"Keep",
"a",
"reference",
"of",
"the",
"callback",
"on",
"this",
"socket",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L154-L158 | [
"def",
"_save_ack_callback",
"(",
"self",
",",
"msgid",
",",
"callback",
")",
":",
"if",
"msgid",
"in",
"self",
".",
"ack_callbacks",
":",
"return",
"False",
"self",
".",
"ack_callbacks",
"[",
"msgid",
"]",
"=",
"callback"
] | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | Socket._pop_ack_callback | Fetch the callback for a given msgid, if it exists, otherwise,
return None | socketio/virtsocket.py | def _pop_ack_callback(self, msgid):
"""Fetch the callback for a given msgid, if it exists, otherwise,
return None"""
if msgid not in self.ack_callbacks:
return None
return self.ack_callbacks.pop(msgid) | def _pop_ack_callback(self, msgid):
"""Fetch the callback for a given msgid, if it exists, otherwise,
return None"""
if msgid not in self.ack_callbacks:
return None
return self.ack_callbacks.pop(msgid) | [
"Fetch",
"the",
"callback",
"for",
"a",
"given",
"msgid",
"if",
"it",
"exists",
"otherwise",
"return",
"None"
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L160-L165 | [
"def",
"_pop_ack_callback",
"(",
"self",
",",
"msgid",
")",
":",
"if",
"msgid",
"not",
"in",
"self",
".",
"ack_callbacks",
":",
"return",
"None",
"return",
"self",
".",
"ack_callbacks",
".",
"pop",
"(",
"msgid",
")"
] | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | Socket.kill | This function must/will be called when a socket is to be completely
shut down, closed by connection timeout, connection error or explicit
disconnection from the client.
It will call all of the Namespace's
:meth:`~socketio.namespace.BaseNamespace.disconnect` methods
so that you c... | socketio/virtsocket.py | def kill(self, detach=False):
"""This function must/will be called when a socket is to be completely
shut down, closed by connection timeout, connection error or explicit
disconnection from the client.
It will call all of the Namespace's
:meth:`~socketio.namespace.BaseNamespace.... | def kill(self, detach=False):
"""This function must/will be called when a socket is to be completely
shut down, closed by connection timeout, connection error or explicit
disconnection from the client.
It will call all of the Namespace's
:meth:`~socketio.namespace.BaseNamespace.... | [
"This",
"function",
"must",
"/",
"will",
"be",
"called",
"when",
"a",
"socket",
"is",
"to",
"be",
"completely",
"shut",
"down",
"closed",
"by",
"connection",
"timeout",
"connection",
"error",
"or",
"explicit",
"disconnection",
"from",
"the",
"client",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L213-L236 | [
"def",
"kill",
"(",
"self",
",",
"detach",
"=",
"False",
")",
":",
"# Clear out the callbacks",
"self",
".",
"ack_callbacks",
"=",
"{",
"}",
"if",
"self",
".",
"connected",
":",
"self",
".",
"state",
"=",
"self",
".",
"STATE_DISCONNECTING",
"self",
".",
... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | Socket.detach | Detach this socket from the server. This should be done in
conjunction with kill(), once all the jobs are dead, detach the
socket for garbage collection. | socketio/virtsocket.py | def detach(self):
"""Detach this socket from the server. This should be done in
conjunction with kill(), once all the jobs are dead, detach the
socket for garbage collection."""
log.debug("Removing %s from server sockets" % self)
if self.sessid in self.server.sockets:
... | def detach(self):
"""Detach this socket from the server. This should be done in
conjunction with kill(), once all the jobs are dead, detach the
socket for garbage collection."""
log.debug("Removing %s from server sockets" % self)
if self.sessid in self.server.sockets:
... | [
"Detach",
"this",
"socket",
"from",
"the",
"server",
".",
"This",
"should",
"be",
"done",
"in",
"conjunction",
"with",
"kill",
"()",
"once",
"all",
"the",
"jobs",
"are",
"dead",
"detach",
"the",
"socket",
"for",
"garbage",
"collection",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L238-L245 | [
"def",
"detach",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"\"Removing %s from server sockets\"",
"%",
"self",
")",
"if",
"self",
".",
"sessid",
"in",
"self",
".",
"server",
".",
"sockets",
":",
"self",
".",
"server",
".",
"sockets",
".",
"pop",
... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | Socket.get_multiple_client_msgs | Get multiple messages, in case we're going through the various
XHR-polling methods, on which we can pack more than one message if the
rate is high, and encode the payload for the HTTP channel. | socketio/virtsocket.py | def get_multiple_client_msgs(self, **kwargs):
"""Get multiple messages, in case we're going through the various
XHR-polling methods, on which we can pack more than one message if the
rate is high, and encode the payload for the HTTP channel."""
client_queue = self.client_queue
ms... | def get_multiple_client_msgs(self, **kwargs):
"""Get multiple messages, in case we're going through the various
XHR-polling methods, on which we can pack more than one message if the
rate is high, and encode the payload for the HTTP channel."""
client_queue = self.client_queue
ms... | [
"Get",
"multiple",
"messages",
"in",
"case",
"we",
"re",
"going",
"through",
"the",
"various",
"XHR",
"-",
"polling",
"methods",
"on",
"which",
"we",
"can",
"pack",
"more",
"than",
"one",
"message",
"if",
"the",
"rate",
"is",
"high",
"and",
"encode",
"th... | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L265-L273 | [
"def",
"get_multiple_client_msgs",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"client_queue",
"=",
"self",
".",
"client_queue",
"msgs",
"=",
"[",
"client_queue",
".",
"get",
"(",
"*",
"*",
"kwargs",
")",
"]",
"while",
"client_queue",
".",
"qsize",
"... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | Socket.error | Send an error to the user, using the custom or default
ErrorHandler configured on the [TODO: Revise this] Socket/Handler
object.
:param error_name: is a simple string, for easy association on
the client side
:param error_message: is a human readable message, ... | socketio/virtsocket.py | def error(self, error_name, error_message, endpoint=None, msg_id=None,
quiet=False):
"""Send an error to the user, using the custom or default
ErrorHandler configured on the [TODO: Revise this] Socket/Handler
object.
:param error_name: is a simple string, for easy associat... | def error(self, error_name, error_message, endpoint=None, msg_id=None,
quiet=False):
"""Send an error to the user, using the custom or default
ErrorHandler configured on the [TODO: Revise this] Socket/Handler
object.
:param error_name: is a simple string, for easy associat... | [
"Send",
"an",
"error",
"to",
"the",
"user",
"using",
"the",
"custom",
"or",
"default",
"ErrorHandler",
"configured",
"on",
"the",
"[",
"TODO",
":",
"Revise",
"this",
"]",
"Socket",
"/",
"Handler",
"object",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L275-L299 | [
"def",
"error",
"(",
"self",
",",
"error_name",
",",
"error_message",
",",
"endpoint",
"=",
"None",
",",
"msg_id",
"=",
"None",
",",
"quiet",
"=",
"False",
")",
":",
"handler",
"=",
"self",
".",
"error_handler",
"return",
"handler",
"(",
"self",
",",
"... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | Socket.disconnect | Calling this method will call the
:meth:`~socketio.namespace.BaseNamespace.disconnect` method on
all the active Namespaces that were open, killing all their
jobs and sending 'disconnect' packets for each of them.
Normally, the Global namespace (endpoint = '') has special meaning,
... | socketio/virtsocket.py | def disconnect(self, silent=False):
"""Calling this method will call the
:meth:`~socketio.namespace.BaseNamespace.disconnect` method on
all the active Namespaces that were open, killing all their
jobs and sending 'disconnect' packets for each of them.
Normally, the Global namesp... | def disconnect(self, silent=False):
"""Calling this method will call the
:meth:`~socketio.namespace.BaseNamespace.disconnect` method on
all the active Namespaces that were open, killing all their
jobs and sending 'disconnect' packets for each of them.
Normally, the Global namesp... | [
"Calling",
"this",
"method",
"will",
"call",
"the",
":",
"meth",
":",
"~socketio",
".",
"namespace",
".",
"BaseNamespace",
".",
"disconnect",
"method",
"on",
"all",
"the",
"active",
"Namespaces",
"that",
"were",
"open",
"killing",
"all",
"their",
"jobs",
"an... | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L302-L316 | [
"def",
"disconnect",
"(",
"self",
",",
"silent",
"=",
"False",
")",
":",
"for",
"ns_name",
",",
"ns",
"in",
"list",
"(",
"six",
".",
"iteritems",
"(",
"self",
".",
"active_ns",
")",
")",
":",
"ns",
".",
"recv_disconnect",
"(",
")"
] | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | Socket.remove_namespace | This removes a Namespace object from the socket.
This is usually called by
:meth:`~socketio.namespace.BaseNamespace.disconnect`. | socketio/virtsocket.py | def remove_namespace(self, namespace):
"""This removes a Namespace object from the socket.
This is usually called by
:meth:`~socketio.namespace.BaseNamespace.disconnect`.
"""
if namespace in self.active_ns:
del self.active_ns[namespace]
if len(self.active_n... | def remove_namespace(self, namespace):
"""This removes a Namespace object from the socket.
This is usually called by
:meth:`~socketio.namespace.BaseNamespace.disconnect`.
"""
if namespace in self.active_ns:
del self.active_ns[namespace]
if len(self.active_n... | [
"This",
"removes",
"a",
"Namespace",
"object",
"from",
"the",
"socket",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L318-L329 | [
"def",
"remove_namespace",
"(",
"self",
",",
"namespace",
")",
":",
"if",
"namespace",
"in",
"self",
".",
"active_ns",
":",
"del",
"self",
".",
"active_ns",
"[",
"namespace",
"]",
"if",
"len",
"(",
"self",
".",
"active_ns",
")",
"==",
"0",
"and",
"self... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | Socket.send_packet | Low-level interface to queue a packet on the wire (encoded as wire
protocol | socketio/virtsocket.py | def send_packet(self, pkt):
"""Low-level interface to queue a packet on the wire (encoded as wire
protocol"""
self.put_client_msg(packet.encode(pkt, self.json_dumps)) | def send_packet(self, pkt):
"""Low-level interface to queue a packet on the wire (encoded as wire
protocol"""
self.put_client_msg(packet.encode(pkt, self.json_dumps)) | [
"Low",
"-",
"level",
"interface",
"to",
"queue",
"a",
"packet",
"on",
"the",
"wire",
"(",
"encoded",
"as",
"wire",
"protocol"
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L331-L334 | [
"def",
"send_packet",
"(",
"self",
",",
"pkt",
")",
":",
"self",
".",
"put_client_msg",
"(",
"packet",
".",
"encode",
"(",
"pkt",
",",
"self",
".",
"json_dumps",
")",
")"
] | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | Socket.spawn | Spawn a new Greenlet, attached to this Socket instance.
It will be monitored by the "watcher" method | socketio/virtsocket.py | def spawn(self, fn, *args, **kwargs):
"""Spawn a new Greenlet, attached to this Socket instance.
It will be monitored by the "watcher" method
"""
log.debug("Spawning sub-Socket Greenlet: %s" % fn.__name__)
job = gevent.spawn(fn, *args, **kwargs)
self.jobs.append(job)
... | def spawn(self, fn, *args, **kwargs):
"""Spawn a new Greenlet, attached to this Socket instance.
It will be monitored by the "watcher" method
"""
log.debug("Spawning sub-Socket Greenlet: %s" % fn.__name__)
job = gevent.spawn(fn, *args, **kwargs)
self.jobs.append(job)
... | [
"Spawn",
"a",
"new",
"Greenlet",
"attached",
"to",
"this",
"Socket",
"instance",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L336-L345 | [
"def",
"spawn",
"(",
"self",
",",
"fn",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"debug",
"(",
"\"Spawning sub-Socket Greenlet: %s\"",
"%",
"fn",
".",
"__name__",
")",
"job",
"=",
"gevent",
".",
"spawn",
"(",
"fn",
",",
"*",
... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | Socket._receiver_loop | This is the loop that takes messages from the queue for the server
to consume, decodes them and dispatches them.
It is the main loop for a socket. We join on this process before
returning control to the web framework.
This process is not tracked by the socket itself, it is not going
... | socketio/virtsocket.py | def _receiver_loop(self):
"""This is the loop that takes messages from the queue for the server
to consume, decodes them and dispatches them.
It is the main loop for a socket. We join on this process before
returning control to the web framework.
This process is not tracked by... | def _receiver_loop(self):
"""This is the loop that takes messages from the queue for the server
to consume, decodes them and dispatches them.
It is the main loop for a socket. We join on this process before
returning control to the web framework.
This process is not tracked by... | [
"This",
"is",
"the",
"loop",
"that",
"takes",
"messages",
"from",
"the",
"queue",
"for",
"the",
"server",
"to",
"consume",
"decodes",
"them",
"and",
"dispatches",
"them",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L347-L422 | [
"def",
"_receiver_loop",
"(",
"self",
")",
":",
"while",
"True",
":",
"rawdata",
"=",
"self",
".",
"get_server_msg",
"(",
")",
"if",
"not",
"rawdata",
":",
"continue",
"# or close the connection ?",
"try",
":",
"pkt",
"=",
"packet",
".",
"decode",
"(",
"ra... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | Socket._spawn_receiver_loop | Spawns the reader loop. This is called internall by
socketio_manage(). | socketio/virtsocket.py | def _spawn_receiver_loop(self):
"""Spawns the reader loop. This is called internall by
socketio_manage().
"""
job = gevent.spawn(self._receiver_loop)
self.jobs.append(job)
return job | def _spawn_receiver_loop(self):
"""Spawns the reader loop. This is called internall by
socketio_manage().
"""
job = gevent.spawn(self._receiver_loop)
self.jobs.append(job)
return job | [
"Spawns",
"the",
"reader",
"loop",
".",
"This",
"is",
"called",
"internall",
"by",
"socketio_manage",
"()",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L424-L430 | [
"def",
"_spawn_receiver_loop",
"(",
"self",
")",
":",
"job",
"=",
"gevent",
".",
"spawn",
"(",
"self",
".",
"_receiver_loop",
")",
"self",
".",
"jobs",
".",
"append",
"(",
"job",
")",
"return",
"job"
] | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | Socket._watcher | Watch out if we've been disconnected, in that case, kill
all the jobs. | socketio/virtsocket.py | def _watcher(self):
"""Watch out if we've been disconnected, in that case, kill
all the jobs.
"""
while True:
gevent.sleep(1.0)
if not self.connected:
for ns_name, ns in list(six.iteritems(self.active_ns)):
ns.recv_disconnect()... | def _watcher(self):
"""Watch out if we've been disconnected, in that case, kill
all the jobs.
"""
while True:
gevent.sleep(1.0)
if not self.connected:
for ns_name, ns in list(six.iteritems(self.active_ns)):
ns.recv_disconnect()... | [
"Watch",
"out",
"if",
"we",
"ve",
"been",
"disconnected",
"in",
"that",
"case",
"kill",
"all",
"the",
"jobs",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L432-L444 | [
"def",
"_watcher",
"(",
"self",
")",
":",
"while",
"True",
":",
"gevent",
".",
"sleep",
"(",
"1.0",
")",
"if",
"not",
"self",
".",
"connected",
":",
"for",
"ns_name",
",",
"ns",
"in",
"list",
"(",
"six",
".",
"iteritems",
"(",
"self",
".",
"active_... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | Socket._heartbeat | Start the heartbeat Greenlet to check connection health. | socketio/virtsocket.py | def _heartbeat(self):
"""Start the heartbeat Greenlet to check connection health."""
interval = self.config['heartbeat_interval']
while self.connected:
gevent.sleep(interval)
# TODO: this process could use a timeout object like the disconnect
# timeout t... | def _heartbeat(self):
"""Start the heartbeat Greenlet to check connection health."""
interval = self.config['heartbeat_interval']
while self.connected:
gevent.sleep(interval)
# TODO: this process could use a timeout object like the disconnect
# timeout t... | [
"Start",
"the",
"heartbeat",
"Greenlet",
"to",
"check",
"connection",
"health",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L452-L462 | [
"def",
"_heartbeat",
"(",
"self",
")",
":",
"interval",
"=",
"self",
".",
"config",
"[",
"'heartbeat_interval'",
"]",
"while",
"self",
".",
"connected",
":",
"gevent",
".",
"sleep",
"(",
"interval",
")",
"# TODO: this process could use a timeout object like the disc... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | Socket._spawn_heartbeat | This functions returns a list of jobs | socketio/virtsocket.py | def _spawn_heartbeat(self):
"""This functions returns a list of jobs"""
self.spawn(self._heartbeat)
self.spawn(self._heartbeat_timeout) | def _spawn_heartbeat(self):
"""This functions returns a list of jobs"""
self.spawn(self._heartbeat)
self.spawn(self._heartbeat_timeout) | [
"This",
"functions",
"returns",
"a",
"list",
"of",
"jobs"
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L477-L480 | [
"def",
"_spawn_heartbeat",
"(",
"self",
")",
":",
"self",
".",
"spawn",
"(",
"self",
".",
"_heartbeat",
")",
"self",
".",
"spawn",
"(",
"self",
".",
"_heartbeat_timeout",
")"
] | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | encode | Encode an attribute dict into a byte string. | socketio/packet.py | def encode(data, json_dumps=default_json_dumps):
"""
Encode an attribute dict into a byte string.
"""
payload = ''
msg = str(MSG_TYPES[data['type']])
if msg in ['0', '1']:
# '1::' [path] [query]
msg += '::' + data['endpoint']
if 'qs' in data and data['qs'] != '':
... | def encode(data, json_dumps=default_json_dumps):
"""
Encode an attribute dict into a byte string.
"""
payload = ''
msg = str(MSG_TYPES[data['type']])
if msg in ['0', '1']:
# '1::' [path] [query]
msg += '::' + data['endpoint']
if 'qs' in data and data['qs'] != '':
... | [
"Encode",
"an",
"attribute",
"dict",
"into",
"a",
"byte",
"string",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/packet.py#L36-L103 | [
"def",
"encode",
"(",
"data",
",",
"json_dumps",
"=",
"default_json_dumps",
")",
":",
"payload",
"=",
"''",
"msg",
"=",
"str",
"(",
"MSG_TYPES",
"[",
"data",
"[",
"'type'",
"]",
"]",
")",
"if",
"msg",
"in",
"[",
"'0'",
",",
"'1'",
"]",
":",
"# '1::... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | decode | Decode a rawstr packet arriving from the socket into a dict. | socketio/packet.py | def decode(rawstr, json_loads=default_json_loads):
"""
Decode a rawstr packet arriving from the socket into a dict.
"""
decoded_msg = {}
try:
# Handle decoding in Python<3.
rawstr = rawstr.decode('utf-8')
except AttributeError:
pass
split_data = rawstr.split(":", 3)
... | def decode(rawstr, json_loads=default_json_loads):
"""
Decode a rawstr packet arriving from the socket into a dict.
"""
decoded_msg = {}
try:
# Handle decoding in Python<3.
rawstr = rawstr.decode('utf-8')
except AttributeError:
pass
split_data = rawstr.split(":", 3)
... | [
"Decode",
"a",
"rawstr",
"packet",
"arriving",
"from",
"the",
"socket",
"into",
"a",
"dict",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/packet.py#L106-L196 | [
"def",
"decode",
"(",
"rawstr",
",",
"json_loads",
"=",
"default_json_loads",
")",
":",
"decoded_msg",
"=",
"{",
"}",
"try",
":",
"# Handle decoding in Python<3.",
"rawstr",
"=",
"rawstr",
".",
"decode",
"(",
"'utf-8'",
")",
"except",
"AttributeError",
":",
"p... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | BaseNamespace.add_acl_method | ACL system: make the method_name accessible to the current socket | socketio/namespace.py | def add_acl_method(self, method_name):
"""ACL system: make the method_name accessible to the current socket"""
if isinstance(self.allowed_methods, set):
self.allowed_methods.add(method_name)
else:
self.allowed_methods = set([method_name]) | def add_acl_method(self, method_name):
"""ACL system: make the method_name accessible to the current socket"""
if isinstance(self.allowed_methods, set):
self.allowed_methods.add(method_name)
else:
self.allowed_methods = set([method_name]) | [
"ACL",
"system",
":",
"make",
"the",
"method_name",
"accessible",
"to",
"the",
"current",
"socket"
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/namespace.py#L70-L76 | [
"def",
"add_acl_method",
"(",
"self",
",",
"method_name",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"allowed_methods",
",",
"set",
")",
":",
"self",
".",
"allowed_methods",
".",
"add",
"(",
"method_name",
")",
"else",
":",
"self",
".",
"allowed_metho... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | BaseNamespace.del_acl_method | ACL system: ensure the user will not have access to that method. | socketio/namespace.py | def del_acl_method(self, method_name):
"""ACL system: ensure the user will not have access to that method."""
if self.allowed_methods is None:
raise ValueError(
"Trying to delete an ACL method, but none were"
+ " defined yet! Or: No ACL restrictions yet, why w... | def del_acl_method(self, method_name):
"""ACL system: ensure the user will not have access to that method."""
if self.allowed_methods is None:
raise ValueError(
"Trying to delete an ACL method, but none were"
+ " defined yet! Or: No ACL restrictions yet, why w... | [
"ACL",
"system",
":",
"ensure",
"the",
"user",
"will",
"not",
"have",
"access",
"to",
"that",
"method",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/namespace.py#L78-L87 | [
"def",
"del_acl_method",
"(",
"self",
",",
"method_name",
")",
":",
"if",
"self",
".",
"allowed_methods",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Trying to delete an ACL method, but none were\"",
"+",
"\" defined yet! Or: No ACL restrictions yet, why would you\"",
... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | BaseNamespace.process_packet | If you override this, NONE of the functions in this class
will be called. It is responsible for dispatching to
:meth:`process_event` (which in turn calls ``on_*()`` and
``recv_*()`` methods).
If the packet arrived here, it is because it belongs to this endpoint.
For each packe... | socketio/namespace.py | def process_packet(self, packet):
"""If you override this, NONE of the functions in this class
will be called. It is responsible for dispatching to
:meth:`process_event` (which in turn calls ``on_*()`` and
``recv_*()`` methods).
If the packet arrived here, it is because it belo... | def process_packet(self, packet):
"""If you override this, NONE of the functions in this class
will be called. It is responsible for dispatching to
:meth:`process_event` (which in turn calls ``on_*()`` and
``recv_*()`` methods).
If the packet arrived here, it is because it belo... | [
"If",
"you",
"override",
"this",
"NONE",
"of",
"the",
"functions",
"in",
"this",
"class",
"will",
"be",
"called",
".",
"It",
"is",
"responsible",
"for",
"dispatching",
"to",
":",
"meth",
":",
"process_event",
"(",
"which",
"in",
"turn",
"calls",
"on_",
"... | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/namespace.py#L134-L177 | [
"def",
"process_packet",
"(",
"self",
",",
"packet",
")",
":",
"packet_type",
"=",
"packet",
"[",
"'type'",
"]",
"if",
"packet_type",
"==",
"'event'",
":",
"return",
"self",
".",
"process_event",
"(",
"packet",
")",
"elif",
"packet_type",
"==",
"'message'",
... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | BaseNamespace.process_event | This function dispatches ``event`` messages to the correct
functions. You should override this method only if you are not
satisfied with the automatic dispatching to
``on_``-prefixed methods. You could then implement your own dispatch.
See the source code for inspiration.
There... | socketio/namespace.py | def process_event(self, packet):
"""This function dispatches ``event`` messages to the correct
functions. You should override this method only if you are not
satisfied with the automatic dispatching to
``on_``-prefixed methods. You could then implement your own dispatch.
See the... | def process_event(self, packet):
"""This function dispatches ``event`` messages to the correct
functions. You should override this method only if you are not
satisfied with the automatic dispatching to
``on_``-prefixed methods. You could then implement your own dispatch.
See the... | [
"This",
"function",
"dispatches",
"event",
"messages",
"to",
"the",
"correct",
"functions",
".",
"You",
"should",
"override",
"this",
"method",
"only",
"if",
"you",
"are",
"not",
"satisfied",
"with",
"the",
"automatic",
"dispatching",
"to",
"on_",
"-",
"prefix... | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/namespace.py#L180-L225 | [
"def",
"process_event",
"(",
"self",
",",
"packet",
")",
":",
"args",
"=",
"packet",
"[",
"'args'",
"]",
"name",
"=",
"packet",
"[",
"'name'",
"]",
"if",
"not",
"allowed_event_name_regex",
".",
"match",
"(",
"name",
")",
":",
"self",
".",
"error",
"(",... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | BaseNamespace.call_method_with_acl | You should always use this function to call the methods,
as it checks if the user is allowed according to the ACLs.
If you override :meth:`process_packet` or
:meth:`process_event`, you should definitely want to use this
instead of ``getattr(self, 'my_method')()`` | socketio/namespace.py | def call_method_with_acl(self, method_name, packet, *args):
"""You should always use this function to call the methods,
as it checks if the user is allowed according to the ACLs.
If you override :meth:`process_packet` or
:meth:`process_event`, you should definitely want to use this
... | def call_method_with_acl(self, method_name, packet, *args):
"""You should always use this function to call the methods,
as it checks if the user is allowed according to the ACLs.
If you override :meth:`process_packet` or
:meth:`process_event`, you should definitely want to use this
... | [
"You",
"should",
"always",
"use",
"this",
"function",
"to",
"call",
"the",
"methods",
"as",
"it",
"checks",
"if",
"the",
"user",
"is",
"allowed",
"according",
"to",
"the",
"ACLs",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/namespace.py#L227-L240 | [
"def",
"call_method_with_acl",
"(",
"self",
",",
"method_name",
",",
"packet",
",",
"*",
"args",
")",
":",
"if",
"not",
"self",
".",
"is_method_allowed",
"(",
"method_name",
")",
":",
"self",
".",
"error",
"(",
"'method_access_denied'",
",",
"'You do not have ... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | BaseNamespace.call_method | This function is used to implement the two behaviors on dispatched
``on_*()`` and ``recv_*()`` method calls.
Those are the two behaviors:
* If there is only one parameter on the dispatched method and
it is named ``packet``, then pass in the packet dict as the
sole parameter... | socketio/namespace.py | def call_method(self, method_name, packet, *args):
"""This function is used to implement the two behaviors on dispatched
``on_*()`` and ``recv_*()`` method calls.
Those are the two behaviors:
* If there is only one parameter on the dispatched method and
it is named ``packet``... | def call_method(self, method_name, packet, *args):
"""This function is used to implement the two behaviors on dispatched
``on_*()`` and ``recv_*()`` method calls.
Those are the two behaviors:
* If there is only one parameter on the dispatched method and
it is named ``packet``... | [
"This",
"function",
"is",
"used",
"to",
"implement",
"the",
"two",
"behaviors",
"on",
"dispatched",
"on_",
"*",
"()",
"and",
"recv_",
"*",
"()",
"method",
"calls",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/namespace.py#L242-L282 | [
"def",
"call_method",
"(",
"self",
",",
"method_name",
",",
"packet",
",",
"*",
"args",
")",
":",
"method",
"=",
"getattr",
"(",
"self",
",",
"method_name",
",",
"None",
")",
"if",
"method",
"is",
"None",
":",
"self",
".",
"error",
"(",
"'no_such_metho... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | BaseNamespace.error | Use this to use the configured ``error_handler`` yield an
error message to your application.
:param error_name: is a short string, to associate messages to recovery
methods
:param error_message: is some human-readable text, describing the error
:param msg_id: ... | socketio/namespace.py | def error(self, error_name, error_message, msg_id=None, quiet=False):
"""Use this to use the configured ``error_handler`` yield an
error message to your application.
:param error_name: is a short string, to associate messages to recovery
methods
:param error_m... | def error(self, error_name, error_message, msg_id=None, quiet=False):
"""Use this to use the configured ``error_handler`` yield an
error message to your application.
:param error_name: is a short string, to associate messages to recovery
methods
:param error_m... | [
"Use",
"this",
"to",
"use",
"the",
"configured",
"error_handler",
"yield",
"an",
"error",
"message",
"to",
"your",
"application",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/namespace.py#L365-L378 | [
"def",
"error",
"(",
"self",
",",
"error_name",
",",
"error_message",
",",
"msg_id",
"=",
"None",
",",
"quiet",
"=",
"False",
")",
":",
"self",
".",
"socket",
".",
"error",
"(",
"error_name",
",",
"error_message",
",",
"endpoint",
"=",
"self",
".",
"ns... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | BaseNamespace.send | Use send to send a simple string message.
If ``json`` is True, the message will be encoded as a JSON object
on the wire, and decoded on the other side.
This is mostly for backwards compatibility. ``emit()`` is more fun.
:param callback: This is a callback function that will be
... | socketio/namespace.py | def send(self, message, json=False, callback=None):
"""Use send to send a simple string message.
If ``json`` is True, the message will be encoded as a JSON object
on the wire, and decoded on the other side.
This is mostly for backwards compatibility. ``emit()`` is more fun.
:... | def send(self, message, json=False, callback=None):
"""Use send to send a simple string message.
If ``json`` is True, the message will be encoded as a JSON object
on the wire, and decoded on the other side.
This is mostly for backwards compatibility. ``emit()`` is more fun.
:... | [
"Use",
"send",
"to",
"send",
"a",
"simple",
"string",
"message",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/namespace.py#L380-L409 | [
"def",
"send",
"(",
"self",
",",
"message",
",",
"json",
"=",
"False",
",",
"callback",
"=",
"None",
")",
":",
"pkt",
"=",
"dict",
"(",
"type",
"=",
"\"message\"",
",",
"data",
"=",
"message",
",",
"endpoint",
"=",
"self",
".",
"ns_name",
")",
"if"... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | BaseNamespace.emit | Use this to send a structured event, with a name and arguments, to
the client.
By default, it uses this namespace's endpoint. You can send messages on
other endpoints with something like:
``self.socket['/other_endpoint'].emit()``.
However, it is possible that the ``'/other... | socketio/namespace.py | def emit(self, event, *args, **kwargs):
"""Use this to send a structured event, with a name and arguments, to
the client.
By default, it uses this namespace's endpoint. You can send messages on
other endpoints with something like:
``self.socket['/other_endpoint'].emit()``.
... | def emit(self, event, *args, **kwargs):
"""Use this to send a structured event, with a name and arguments, to
the client.
By default, it uses this namespace's endpoint. You can send messages on
other endpoints with something like:
``self.socket['/other_endpoint'].emit()``.
... | [
"Use",
"this",
"to",
"send",
"a",
"structured",
"event",
"with",
"a",
"name",
"and",
"arguments",
"to",
"the",
"client",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/namespace.py#L411-L460 | [
"def",
"emit",
"(",
"self",
",",
"event",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"callback",
"=",
"kwargs",
".",
"pop",
"(",
"'callback'",
",",
"None",
")",
"if",
"kwargs",
":",
"raise",
"ValueError",
"(",
"\"emit() only supports positional... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | BaseNamespace.spawn | Spawn a new process, attached to this Namespace.
It will be monitored by the "watcher" process in the Socket. If the
socket disconnects, all these greenlets are going to be killed, after
calling BaseNamespace.disconnect()
This method uses the ``exception_handler_decorator``. See
... | socketio/namespace.py | def spawn(self, fn, *args, **kwargs):
"""Spawn a new process, attached to this Namespace.
It will be monitored by the "watcher" process in the Socket. If the
socket disconnects, all these greenlets are going to be killed, after
calling BaseNamespace.disconnect()
This method use... | def spawn(self, fn, *args, **kwargs):
"""Spawn a new process, attached to this Namespace.
It will be monitored by the "watcher" process in the Socket. If the
socket disconnects, all these greenlets are going to be killed, after
calling BaseNamespace.disconnect()
This method use... | [
"Spawn",
"a",
"new",
"process",
"attached",
"to",
"this",
"Namespace",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/namespace.py#L462-L478 | [
"def",
"spawn",
"(",
"self",
",",
"fn",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# self.log.debug(\"Spawning sub-Namespace Greenlet: %s\" % fn.__name__)",
"if",
"hasattr",
"(",
"self",
",",
"'exception_handler_decorator'",
")",
":",
"fn",
"=",
"self",... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | BaseNamespace.disconnect | Send a 'disconnect' packet, so that the user knows it has been
disconnected (booted actually). This will trigger an onDisconnect()
call on the client side.
Over here, we will kill all ``spawn``ed processes and remove the
namespace from the Socket object.
:param silent: do not ... | socketio/namespace.py | def disconnect(self, silent=False):
"""Send a 'disconnect' packet, so that the user knows it has been
disconnected (booted actually). This will trigger an onDisconnect()
call on the client side.
Over here, we will kill all ``spawn``ed processes and remove the
namespace from the... | def disconnect(self, silent=False):
"""Send a 'disconnect' packet, so that the user knows it has been
disconnected (booted actually). This will trigger an onDisconnect()
call on the client side.
Over here, we will kill all ``spawn``ed processes and remove the
namespace from the... | [
"Send",
"a",
"disconnect",
"packet",
"so",
"that",
"the",
"user",
"knows",
"it",
"has",
"been",
"disconnected",
"(",
"booted",
"actually",
")",
".",
"This",
"will",
"trigger",
"an",
"onDisconnect",
"()",
"call",
"on",
"the",
"client",
"side",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/namespace.py#L480-L501 | [
"def",
"disconnect",
"(",
"self",
",",
"silent",
"=",
"False",
")",
":",
"if",
"not",
"silent",
":",
"packet",
"=",
"{",
"\"type\"",
":",
"\"disconnect\"",
",",
"\"endpoint\"",
":",
"self",
".",
"ns_name",
"}",
"self",
".",
"socket",
".",
"send_packet",
... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | SocketIOServer.get_socket | Return an existing or new client Socket. | socketio/server.py | def get_socket(self, sessid=''):
"""Return an existing or new client Socket."""
socket = self.sockets.get(sessid)
if sessid and not socket:
return None # you ask for a session that doesn't exist!
if socket is None:
socket = Socket(self, self.config)
... | def get_socket(self, sessid=''):
"""Return an existing or new client Socket."""
socket = self.sockets.get(sessid)
if sessid and not socket:
return None # you ask for a session that doesn't exist!
if socket is None:
socket = Socket(self, self.config)
... | [
"Return",
"an",
"existing",
"or",
"new",
"client",
"Socket",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/server.py#L126-L139 | [
"def",
"get_socket",
"(",
"self",
",",
"sessid",
"=",
"''",
")",
":",
"socket",
"=",
"self",
".",
"sockets",
".",
"get",
"(",
"sessid",
")",
"if",
"sessid",
"and",
"not",
"socket",
":",
"return",
"None",
"# you ask for a session that doesn't exist!",
"if",
... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | create | Handles post from the "Add room" form on the homepage, and
redirects to the new room. | examples/flask_chat/chat.py | def create():
"""
Handles post from the "Add room" form on the homepage, and
redirects to the new room.
"""
name = request.form.get("name")
if name:
room, created = get_or_create(ChatRoom, name=name)
return redirect(url_for('room', slug=room.slug))
return redirect(url_for('ro... | def create():
"""
Handles post from the "Add room" form on the homepage, and
redirects to the new room.
"""
name = request.form.get("name")
if name:
room, created = get_or_create(ChatRoom, name=name)
return redirect(url_for('room', slug=room.slug))
return redirect(url_for('ro... | [
"Handles",
"post",
"from",
"the",
"Add",
"room",
"form",
"on",
"the",
"homepage",
"and",
"redirects",
"to",
"the",
"new",
"room",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/examples/flask_chat/chat.py#L99-L108 | [
"def",
"create",
"(",
")",
":",
"name",
"=",
"request",
".",
"form",
".",
"get",
"(",
"\"name\"",
")",
"if",
"name",
":",
"room",
",",
"created",
"=",
"get_or_create",
"(",
"ChatRoom",
",",
"name",
"=",
"name",
")",
"return",
"redirect",
"(",
"url_fo... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | autodiscover | Auto-discover INSTALLED_APPS sockets.py modules and fail silently when
not present. NOTE: socketio_autodiscover was inspired/copied from
django.contrib.admin autodiscover | socketio/sdjango.py | def autodiscover():
"""
Auto-discover INSTALLED_APPS sockets.py modules and fail silently when
not present. NOTE: socketio_autodiscover was inspired/copied from
django.contrib.admin autodiscover
"""
global LOADING_SOCKETIO
if LOADING_SOCKETIO:
return
LOADING_SOCKETIO = True
... | def autodiscover():
"""
Auto-discover INSTALLED_APPS sockets.py modules and fail silently when
not present. NOTE: socketio_autodiscover was inspired/copied from
django.contrib.admin autodiscover
"""
global LOADING_SOCKETIO
if LOADING_SOCKETIO:
return
LOADING_SOCKETIO = True
... | [
"Auto",
"-",
"discover",
"INSTALLED_APPS",
"sockets",
".",
"py",
"modules",
"and",
"fail",
"silently",
"when",
"not",
"present",
".",
"NOTE",
":",
"socketio_autodiscover",
"was",
"inspired",
"/",
"copied",
"from",
"django",
".",
"contrib",
".",
"admin",
"autod... | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/sdjango.py#L23-L51 | [
"def",
"autodiscover",
"(",
")",
":",
"global",
"LOADING_SOCKETIO",
"if",
"LOADING_SOCKETIO",
":",
"return",
"LOADING_SOCKETIO",
"=",
"True",
"import",
"imp",
"from",
"django",
".",
"conf",
"import",
"settings",
"for",
"app",
"in",
"settings",
".",
"INSTALLED_AP... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | SocketIOHandler.handle_one_response | This function deals with *ONE INCOMING REQUEST* from the web.
It will wire and exchange message to the queues for long-polling
methods, otherwise, will stay alive for websockets. | socketio/handler.py | def handle_one_response(self):
"""This function deals with *ONE INCOMING REQUEST* from the web.
It will wire and exchange message to the queues for long-polling
methods, otherwise, will stay alive for websockets.
"""
path = self.environ.get('PATH_INFO')
# Kick non-sock... | def handle_one_response(self):
"""This function deals with *ONE INCOMING REQUEST* from the web.
It will wire and exchange message to the queues for long-polling
methods, otherwise, will stay alive for websockets.
"""
path = self.environ.get('PATH_INFO')
# Kick non-sock... | [
"This",
"function",
"deals",
"with",
"*",
"ONE",
"INCOMING",
"REQUEST",
"*",
"from",
"the",
"web",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/handler.py#L93-L209 | [
"def",
"handle_one_response",
"(",
"self",
")",
":",
"path",
"=",
"self",
".",
"environ",
".",
"get",
"(",
"'PATH_INFO'",
")",
"# Kick non-socket.io requests to our superclass",
"if",
"not",
"path",
".",
"lstrip",
"(",
"'/'",
")",
".",
"startswith",
"(",
"self... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | XHRPollingTransport.get_messages_payload | This will fetch the messages from the Socket's queue, and if
there are many messes, pack multiple messages in one payload and return | socketio/transports.py | def get_messages_payload(self, socket, timeout=None):
"""This will fetch the messages from the Socket's queue, and if
there are many messes, pack multiple messages in one payload and return
"""
try:
msgs = socket.get_multiple_client_msgs(timeout=timeout)
data = se... | def get_messages_payload(self, socket, timeout=None):
"""This will fetch the messages from the Socket's queue, and if
there are many messes, pack multiple messages in one payload and return
"""
try:
msgs = socket.get_multiple_client_msgs(timeout=timeout)
data = se... | [
"This",
"will",
"fetch",
"the",
"messages",
"from",
"the",
"Socket",
"s",
"queue",
"and",
"if",
"there",
"are",
"many",
"messes",
"pack",
"multiple",
"messages",
"in",
"one",
"payload",
"and",
"return"
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/transports.py#L84-L93 | [
"def",
"get_messages_payload",
"(",
"self",
",",
"socket",
",",
"timeout",
"=",
"None",
")",
":",
"try",
":",
"msgs",
"=",
"socket",
".",
"get_multiple_client_msgs",
"(",
"timeout",
"=",
"timeout",
")",
"data",
"=",
"self",
".",
"encode_payload",
"(",
"msg... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | XHRPollingTransport.encode_payload | Encode list of messages. Expects messages to be unicode.
``messages`` - List of raw messages to encode, if necessary | socketio/transports.py | def encode_payload(self, messages):
"""Encode list of messages. Expects messages to be unicode.
``messages`` - List of raw messages to encode, if necessary
"""
if not messages or messages[0] is None:
return ''
if len(messages) == 1:
return messages[0].e... | def encode_payload(self, messages):
"""Encode list of messages. Expects messages to be unicode.
``messages`` - List of raw messages to encode, if necessary
"""
if not messages or messages[0] is None:
return ''
if len(messages) == 1:
return messages[0].e... | [
"Encode",
"list",
"of",
"messages",
".",
"Expects",
"messages",
"to",
"be",
"unicode",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/transports.py#L95-L112 | [
"def",
"encode_payload",
"(",
"self",
",",
"messages",
")",
":",
"if",
"not",
"messages",
"or",
"messages",
"[",
"0",
"]",
"is",
"None",
":",
"return",
"''",
"if",
"len",
"(",
"messages",
")",
"==",
"1",
":",
"return",
"messages",
"[",
"0",
"]",
".... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | XHRPollingTransport.decode_payload | This function can extract multiple messages from one HTTP payload.
Some times, the XHR/JSONP/.. transports can pack more than one message
on a single packet. They are encoding following the WebSocket
semantics, which need to be reproduced here to unwrap the messages.
The semantics are:... | socketio/transports.py | def decode_payload(self, payload):
"""This function can extract multiple messages from one HTTP payload.
Some times, the XHR/JSONP/.. transports can pack more than one message
on a single packet. They are encoding following the WebSocket
semantics, which need to be reproduced here to un... | def decode_payload(self, payload):
"""This function can extract multiple messages from one HTTP payload.
Some times, the XHR/JSONP/.. transports can pack more than one message
on a single packet. They are encoding following the WebSocket
semantics, which need to be reproduced here to un... | [
"This",
"function",
"can",
"extract",
"multiple",
"messages",
"from",
"one",
"HTTP",
"payload",
".",
"Some",
"times",
"the",
"XHR",
"/",
"JSONP",
"/",
"..",
"transports",
"can",
"pack",
"more",
"than",
"one",
"message",
"on",
"a",
"single",
"packet",
".",
... | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/transports.py#L114-L141 | [
"def",
"decode_payload",
"(",
"self",
",",
"payload",
")",
":",
"payload",
"=",
"payload",
".",
"decode",
"(",
"'utf-8'",
")",
"if",
"payload",
"[",
"0",
"]",
"==",
"u\"\\ufffd\"",
":",
"ret",
"=",
"[",
"]",
"while",
"len",
"(",
"payload",
")",
"!=",... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | JSONPolling.write | Just quote out stuff before sending it out | socketio/transports.py | def write(self, data):
"""Just quote out stuff before sending it out"""
args = parse_qs(self.handler.environ.get("QUERY_STRING"))
if "i" in args:
i = args["i"]
else:
i = "0"
# TODO: don't we need to quote this data in here ?
super(JSONPolling, self... | def write(self, data):
"""Just quote out stuff before sending it out"""
args = parse_qs(self.handler.environ.get("QUERY_STRING"))
if "i" in args:
i = args["i"]
else:
i = "0"
# TODO: don't we need to quote this data in here ?
super(JSONPolling, self... | [
"Just",
"quote",
"out",
"stuff",
"before",
"sending",
"it",
"out"
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/transports.py#L176-L184 | [
"def",
"write",
"(",
"self",
",",
"data",
")",
":",
"args",
"=",
"parse_qs",
"(",
"self",
".",
"handler",
".",
"environ",
".",
"get",
"(",
"\"QUERY_STRING\"",
")",
")",
"if",
"\"i\"",
"in",
"args",
":",
"i",
"=",
"args",
"[",
"\"i\"",
"]",
"else",
... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | RoomsMixin.emit_to_room | This is sent to all in the room (in this particular Namespace) | socketio/mixins.py | def emit_to_room(self, room, event, *args):
"""This is sent to all in the room (in this particular Namespace)"""
pkt = dict(type="event",
name=event,
args=args,
endpoint=self.ns_name)
room_name = self._get_room_name(room)
for sessi... | def emit_to_room(self, room, event, *args):
"""This is sent to all in the room (in this particular Namespace)"""
pkt = dict(type="event",
name=event,
args=args,
endpoint=self.ns_name)
room_name = self._get_room_name(room)
for sessi... | [
"This",
"is",
"sent",
"to",
"all",
"in",
"the",
"room",
"(",
"in",
"this",
"particular",
"Namespace",
")"
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/mixins.py#L28-L39 | [
"def",
"emit_to_room",
"(",
"self",
",",
"room",
",",
"event",
",",
"*",
"args",
")",
":",
"pkt",
"=",
"dict",
"(",
"type",
"=",
"\"event\"",
",",
"name",
"=",
"event",
",",
"args",
"=",
"args",
",",
"endpoint",
"=",
"self",
".",
"ns_name",
")",
... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | BroadcastMixin.broadcast_event | This is sent to all in the sockets in this particular Namespace,
including itself. | socketio/mixins.py | def broadcast_event(self, event, *args):
"""
This is sent to all in the sockets in this particular Namespace,
including itself.
"""
pkt = dict(type="event",
name=event,
args=args,
endpoint=self.ns_name)
for sessid,... | def broadcast_event(self, event, *args):
"""
This is sent to all in the sockets in this particular Namespace,
including itself.
"""
pkt = dict(type="event",
name=event,
args=args,
endpoint=self.ns_name)
for sessid,... | [
"This",
"is",
"sent",
"to",
"all",
"in",
"the",
"sockets",
"in",
"this",
"particular",
"Namespace",
"including",
"itself",
"."
] | abourget/gevent-socketio | python | https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/mixins.py#L50-L61 | [
"def",
"broadcast_event",
"(",
"self",
",",
"event",
",",
"*",
"args",
")",
":",
"pkt",
"=",
"dict",
"(",
"type",
"=",
"\"event\"",
",",
"name",
"=",
"event",
",",
"args",
"=",
"args",
",",
"endpoint",
"=",
"self",
".",
"ns_name",
")",
"for",
"sess... | 1cdb1594a315326987a17ce0924ea448a82fab01 |
valid | RoleMixin.add_parent | Add a parent to this role,
and add role itself to the parent's children set.
you should override this function if neccessary.
Example::
logged_user = RoleMixin('logged_user')
student = RoleMixin('student')
student.add_parent(logged_user)
:param pare... | flask_rbac/model.py | def add_parent(self, parent):
"""Add a parent to this role,
and add role itself to the parent's children set.
you should override this function if neccessary.
Example::
logged_user = RoleMixin('logged_user')
student = RoleMixin('student')
student.add... | def add_parent(self, parent):
"""Add a parent to this role,
and add role itself to the parent's children set.
you should override this function if neccessary.
Example::
logged_user = RoleMixin('logged_user')
student = RoleMixin('student')
student.add... | [
"Add",
"a",
"parent",
"to",
"this",
"role",
"and",
"add",
"role",
"itself",
"to",
"the",
"parent",
"s",
"children",
"set",
".",
"you",
"should",
"override",
"this",
"function",
"if",
"neccessary",
"."
] | shonenada/flask-rbac | python | https://github.com/shonenada/flask-rbac/blob/e085121ff11825114e2d6f8419f0b6de6f9ba476/flask_rbac/model.py#L22-L36 | [
"def",
"add_parent",
"(",
"self",
",",
"parent",
")",
":",
"parent",
".",
"children",
".",
"add",
"(",
"self",
")",
"self",
".",
"parents",
".",
"add",
"(",
"parent",
")"
] | e085121ff11825114e2d6f8419f0b6de6f9ba476 |
valid | AccessControlList.allow | Add allowing rules.
:param role: Role of this rule.
:param method: Method to allow in rule, include GET, POST, PUT etc.
:param resource: Resource also view function.
:param with_children: Allow role's children in rule as well
if with_children is `True` | flask_rbac/__init__.py | def allow(self, role, method, resource, with_children=True):
"""Add allowing rules.
:param role: Role of this rule.
:param method: Method to allow in rule, include GET, POST, PUT etc.
:param resource: Resource also view function.
:param with_children: Allow role's children in ru... | def allow(self, role, method, resource, with_children=True):
"""Add allowing rules.
:param role: Role of this rule.
:param method: Method to allow in rule, include GET, POST, PUT etc.
:param resource: Resource also view function.
:param with_children: Allow role's children in ru... | [
"Add",
"allowing",
"rules",
"."
] | shonenada/flask-rbac | python | https://github.com/shonenada/flask-rbac/blob/e085121ff11825114e2d6f8419f0b6de6f9ba476/flask_rbac/__init__.py#L44-L63 | [
"def",
"allow",
"(",
"self",
",",
"role",
",",
"method",
",",
"resource",
",",
"with_children",
"=",
"True",
")",
":",
"if",
"with_children",
":",
"for",
"r",
"in",
"role",
".",
"get_children",
"(",
")",
":",
"permission",
"=",
"(",
"r",
".",
"get_na... | e085121ff11825114e2d6f8419f0b6de6f9ba476 |
valid | AccessControlList.deny | Add denying rules.
:param role: Role of this rule.
:param method: Method to deny in rule, include GET, POST, PUT etc.
:param resource: Resource also view function.
:param with_children: Deny role's children in rule as well
if with_children is `True` | flask_rbac/__init__.py | def deny(self, role, method, resource, with_children=False):
"""Add denying rules.
:param role: Role of this rule.
:param method: Method to deny in rule, include GET, POST, PUT etc.
:param resource: Resource also view function.
:param with_children: Deny role's children in rule ... | def deny(self, role, method, resource, with_children=False):
"""Add denying rules.
:param role: Role of this rule.
:param method: Method to deny in rule, include GET, POST, PUT etc.
:param resource: Resource also view function.
:param with_children: Deny role's children in rule ... | [
"Add",
"denying",
"rules",
"."
] | shonenada/flask-rbac | python | https://github.com/shonenada/flask-rbac/blob/e085121ff11825114e2d6f8419f0b6de6f9ba476/flask_rbac/__init__.py#L65-L81 | [
"def",
"deny",
"(",
"self",
",",
"role",
",",
"method",
",",
"resource",
",",
"with_children",
"=",
"False",
")",
":",
"if",
"with_children",
":",
"for",
"r",
"in",
"role",
".",
"get_children",
"(",
")",
":",
"permission",
"=",
"(",
"r",
".",
"get_na... | e085121ff11825114e2d6f8419f0b6de6f9ba476 |
valid | AccessControlList.exempt | Exempt a view function from being checked permission
:param resource: The view function exempt from checking. | flask_rbac/__init__.py | def exempt(self, resource):
"""Exempt a view function from being checked permission
:param resource: The view function exempt from checking.
"""
if resource not in self._exempt:
self._exempt.append(resource) | def exempt(self, resource):
"""Exempt a view function from being checked permission
:param resource: The view function exempt from checking.
"""
if resource not in self._exempt:
self._exempt.append(resource) | [
"Exempt",
"a",
"view",
"function",
"from",
"being",
"checked",
"permission"
] | shonenada/flask-rbac | python | https://github.com/shonenada/flask-rbac/blob/e085121ff11825114e2d6f8419f0b6de6f9ba476/flask_rbac/__init__.py#L83-L89 | [
"def",
"exempt",
"(",
"self",
",",
"resource",
")",
":",
"if",
"resource",
"not",
"in",
"self",
".",
"_exempt",
":",
"self",
".",
"_exempt",
".",
"append",
"(",
"resource",
")"
] | e085121ff11825114e2d6f8419f0b6de6f9ba476 |
valid | AccessControlList.is_allowed | Check whether role is allowed to access resource
:param role: Role to be checked.
:param method: Method to be checked.
:param resource: View function to be checked. | flask_rbac/__init__.py | def is_allowed(self, role, method, resource):
"""Check whether role is allowed to access resource
:param role: Role to be checked.
:param method: Method to be checked.
:param resource: View function to be checked.
"""
return (role, method, resource) in self._allowed | def is_allowed(self, role, method, resource):
"""Check whether role is allowed to access resource
:param role: Role to be checked.
:param method: Method to be checked.
:param resource: View function to be checked.
"""
return (role, method, resource) in self._allowed | [
"Check",
"whether",
"role",
"is",
"allowed",
"to",
"access",
"resource"
] | shonenada/flask-rbac | python | https://github.com/shonenada/flask-rbac/blob/e085121ff11825114e2d6f8419f0b6de6f9ba476/flask_rbac/__init__.py#L91-L98 | [
"def",
"is_allowed",
"(",
"self",
",",
"role",
",",
"method",
",",
"resource",
")",
":",
"return",
"(",
"role",
",",
"method",
",",
"resource",
")",
"in",
"self",
".",
"_allowed"
] | e085121ff11825114e2d6f8419f0b6de6f9ba476 |
valid | AccessControlList.is_denied | Check wherther role is denied to access resource
:param role: Role to be checked.
:param method: Method to be checked.
:param resource: View function to be checked. | flask_rbac/__init__.py | def is_denied(self, role, method, resource):
"""Check wherther role is denied to access resource
:param role: Role to be checked.
:param method: Method to be checked.
:param resource: View function to be checked.
"""
return (role, method, resource) in self._denied | def is_denied(self, role, method, resource):
"""Check wherther role is denied to access resource
:param role: Role to be checked.
:param method: Method to be checked.
:param resource: View function to be checked.
"""
return (role, method, resource) in self._denied | [
"Check",
"wherther",
"role",
"is",
"denied",
"to",
"access",
"resource"
] | shonenada/flask-rbac | python | https://github.com/shonenada/flask-rbac/blob/e085121ff11825114e2d6f8419f0b6de6f9ba476/flask_rbac/__init__.py#L100-L107 | [
"def",
"is_denied",
"(",
"self",
",",
"role",
",",
"method",
",",
"resource",
")",
":",
"return",
"(",
"role",
",",
"method",
",",
"resource",
")",
"in",
"self",
".",
"_denied"
] | e085121ff11825114e2d6f8419f0b6de6f9ba476 |
valid | RBAC.init_app | Initialize application in Flask-RBAC.
Adds (RBAC, app) to flask extensions.
Adds hook to authenticate permission before request.
:param app: Flask object | flask_rbac/__init__.py | def init_app(self, app):
"""Initialize application in Flask-RBAC.
Adds (RBAC, app) to flask extensions.
Adds hook to authenticate permission before request.
:param app: Flask object
"""
app.config.setdefault('RBAC_USE_WHITE', False)
self.use_white = app.config['... | def init_app(self, app):
"""Initialize application in Flask-RBAC.
Adds (RBAC, app) to flask extensions.
Adds hook to authenticate permission before request.
:param app: Flask object
"""
app.config.setdefault('RBAC_USE_WHITE', False)
self.use_white = app.config['... | [
"Initialize",
"application",
"in",
"Flask",
"-",
"RBAC",
".",
"Adds",
"(",
"RBAC",
"app",
")",
"to",
"flask",
"extensions",
".",
"Adds",
"hook",
"to",
"authenticate",
"permission",
"before",
"request",
"."
] | shonenada/flask-rbac | python | https://github.com/shonenada/flask-rbac/blob/e085121ff11825114e2d6f8419f0b6de6f9ba476/flask_rbac/__init__.py#L162-L180 | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"app",
".",
"config",
".",
"setdefault",
"(",
"'RBAC_USE_WHITE'",
",",
"False",
")",
"self",
".",
"use_white",
"=",
"app",
".",
"config",
"[",
"'RBAC_USE_WHITE'",
"]",
"if",
"not",
"hasattr",
"(",
"... | e085121ff11825114e2d6f8419f0b6de6f9ba476 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.