id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
52,400 | Divirad/PythonTranslate | pythontranslate/__init__.py | Translator.get_lang_dict | def get_lang_dict(self):
"""gets supported langs as an dictionary"""
r = self.yandex_translate_request("getLangs")
self.handle_errors(r)
return r.json()["langs"] | python | def get_lang_dict(self):
"""gets supported langs as an dictionary"""
r = self.yandex_translate_request("getLangs")
self.handle_errors(r)
return r.json()["langs"] | [
"def",
"get_lang_dict",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"yandex_translate_request",
"(",
"\"getLangs\"",
")",
"self",
".",
"handle_errors",
"(",
"r",
")",
"return",
"r",
".",
"json",
"(",
")",
"[",
"\"langs\"",
"]"
] | gets supported langs as an dictionary | [
"gets",
"supported",
"langs",
"as",
"an",
"dictionary"
] | 625e97563bb586692f4a128b284a2aa79f82c279 | https://github.com/Divirad/PythonTranslate/blob/625e97563bb586692f4a128b284a2aa79f82c279/pythontranslate/__init__.py#L42-L47 |
52,401 | the01/python-floscraper | floscraper/webscraper.py | WebScraper._browser_init | def _browser_init(self):
"""
Init the browsing instance if not setup
:rtype: None
"""
if self.session:
return
self.session = requests.Session()
headers = {}
if self.user_agent:
headers['User-agent'] = self.user_agent
self... | python | def _browser_init(self):
"""
Init the browsing instance if not setup
:rtype: None
"""
if self.session:
return
self.session = requests.Session()
headers = {}
if self.user_agent:
headers['User-agent'] = self.user_agent
self... | [
"def",
"_browser_init",
"(",
"self",
")",
":",
"if",
"self",
".",
"session",
":",
"return",
"self",
".",
"session",
"=",
"requests",
".",
"Session",
"(",
")",
"headers",
"=",
"{",
"}",
"if",
"self",
".",
"user_agent",
":",
"headers",
"[",
"'User-agent'... | Init the browsing instance if not setup
:rtype: None | [
"Init",
"the",
"browsing",
"instance",
"if",
"not",
"setup"
] | d578cd3d6381070d9a07dade1e10387ae33e9a65 | https://github.com/the01/python-floscraper/blob/d578cd3d6381070d9a07dade1e10387ae33e9a65/floscraper/webscraper.py#L111-L129 |
52,402 | the01/python-floscraper | floscraper/webscraper.py | WebScraper.load_scrap | def load_scrap(self, path):
"""
Load scraper settings from file
:param path: Path to file
:type path: str
:rtype: None
:raises WEBFileException: Failed to load settings
:raises WEBParameterException: Missing parameters in file
"""
try:
... | python | def load_scrap(self, path):
"""
Load scraper settings from file
:param path: Path to file
:type path: str
:rtype: None
:raises WEBFileException: Failed to load settings
:raises WEBParameterException: Missing parameters in file
"""
try:
... | [
"def",
"load_scrap",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"conf",
"=",
"self",
".",
"load_settings",
"(",
"path",
")",
"except",
":",
"# Should only be IOError",
"self",
".",
"exception",
"(",
"\"Failed to load file\"",
")",
"raise",
"WEBFileExcepti... | Load scraper settings from file
:param path: Path to file
:type path: str
:rtype: None
:raises WEBFileException: Failed to load settings
:raises WEBParameterException: Missing parameters in file | [
"Load",
"scraper",
"settings",
"from",
"file"
] | d578cd3d6381070d9a07dade1e10387ae33e9a65 | https://github.com/the01/python-floscraper/blob/d578cd3d6381070d9a07dade1e10387ae33e9a65/floscraper/webscraper.py#L152-L182 |
52,403 | the01/python-floscraper | floscraper/webscraper.py | WebScraper.request | def request(
self, method, url, timeout=None,
headers=None, data=None, params=None
):
"""
Make a request using the requests library
:param method: Which http method to use (GET/POST)
:type method: str | unicode
:param url: Url to make request to
... | python | def request(
self, method, url, timeout=None,
headers=None, data=None, params=None
):
"""
Make a request using the requests library
:param method: Which http method to use (GET/POST)
:type method: str | unicode
:param url: Url to make request to
... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"url",
",",
"timeout",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"data",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"if",
"headers",
"is",
"None",
":",
"headers",
"=",
"{",
"}",
"if"... | Make a request using the requests library
:param method: Which http method to use (GET/POST)
:type method: str | unicode
:param url: Url to make request to
:type url: str | unicode
:param timeout: Timeout for request (default: None)
None -> infinite timeout
:... | [
"Make",
"a",
"request",
"using",
"the",
"requests",
"library"
] | d578cd3d6381070d9a07dade1e10387ae33e9a65 | https://github.com/the01/python-floscraper/blob/d578cd3d6381070d9a07dade1e10387ae33e9a65/floscraper/webscraper.py#L184-L238 |
52,404 | the01/python-floscraper | floscraper/webscraper.py | WebScraper.scrap | def scrap(self,
url=None, scheme=None, timeout=None,
html_parser=None, cache_ext=None
):
"""
Scrap a url and parse the content according to scheme
:param url: Url to parse (default: self._url)
:type url: str
:param scheme: Scheme to apply to html ... | python | def scrap(self,
url=None, scheme=None, timeout=None,
html_parser=None, cache_ext=None
):
"""
Scrap a url and parse the content according to scheme
:param url: Url to parse (default: self._url)
:type url: str
:param scheme: Scheme to apply to html ... | [
"def",
"scrap",
"(",
"self",
",",
"url",
"=",
"None",
",",
"scheme",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"html_parser",
"=",
"None",
",",
"cache_ext",
"=",
"None",
")",
":",
"if",
"not",
"url",
":",
"url",
"=",
"self",
".",
"url",
"if"... | Scrap a url and parse the content according to scheme
:param url: Url to parse (default: self._url)
:type url: str
:param scheme: Scheme to apply to html (default: self._scheme)
:type scheme: dict
:param timeout: Timeout for http operation (default: self._timout)
:type t... | [
"Scrap",
"a",
"url",
"and",
"parse",
"the",
"content",
"according",
"to",
"scheme"
] | d578cd3d6381070d9a07dade1e10387ae33e9a65 | https://github.com/the01/python-floscraper/blob/d578cd3d6381070d9a07dade1e10387ae33e9a65/floscraper/webscraper.py#L561-L598 |
52,405 | the01/python-floscraper | floscraper/webscraper.py | WebScraper._shrink_list | def _shrink_list(self, shrink):
"""
Shrink list down to essentials
:param shrink: List to shrink
:type shrink: list
:return: Shrunk list
:rtype: list
"""
res = []
if len(shrink) == 1:
return self.shrink(shrink[0])
else:
... | python | def _shrink_list(self, shrink):
"""
Shrink list down to essentials
:param shrink: List to shrink
:type shrink: list
:return: Shrunk list
:rtype: list
"""
res = []
if len(shrink) == 1:
return self.shrink(shrink[0])
else:
... | [
"def",
"_shrink_list",
"(",
"self",
",",
"shrink",
")",
":",
"res",
"=",
"[",
"]",
"if",
"len",
"(",
"shrink",
")",
"==",
"1",
":",
"return",
"self",
".",
"shrink",
"(",
"shrink",
"[",
"0",
"]",
")",
"else",
":",
"for",
"a",
"in",
"shrink",
":"... | Shrink list down to essentials
:param shrink: List to shrink
:type shrink: list
:return: Shrunk list
:rtype: list | [
"Shrink",
"list",
"down",
"to",
"essentials"
] | d578cd3d6381070d9a07dade1e10387ae33e9a65 | https://github.com/the01/python-floscraper/blob/d578cd3d6381070d9a07dade1e10387ae33e9a65/floscraper/webscraper.py#L600-L619 |
52,406 | the01/python-floscraper | floscraper/webscraper.py | WebScraper._shrink_dict | def _shrink_dict(self, shrink):
"""
Shrink dict down to essentials
:param shrink: Dict to shrink
:type shrink: dict
:return: Shrunk dict
:rtype: dict
"""
res = {}
if len(shrink.keys()) == 1 and "value" in shrink:
return self.shrink(sh... | python | def _shrink_dict(self, shrink):
"""
Shrink dict down to essentials
:param shrink: Dict to shrink
:type shrink: dict
:return: Shrunk dict
:rtype: dict
"""
res = {}
if len(shrink.keys()) == 1 and "value" in shrink:
return self.shrink(sh... | [
"def",
"_shrink_dict",
"(",
"self",
",",
"shrink",
")",
":",
"res",
"=",
"{",
"}",
"if",
"len",
"(",
"shrink",
".",
"keys",
"(",
")",
")",
"==",
"1",
"and",
"\"value\"",
"in",
"shrink",
":",
"return",
"self",
".",
"shrink",
"(",
"shrink",
"[",
"'... | Shrink dict down to essentials
:param shrink: Dict to shrink
:type shrink: dict
:return: Shrunk dict
:rtype: dict | [
"Shrink",
"dict",
"down",
"to",
"essentials"
] | d578cd3d6381070d9a07dade1e10387ae33e9a65 | https://github.com/the01/python-floscraper/blob/d578cd3d6381070d9a07dade1e10387ae33e9a65/floscraper/webscraper.py#L621-L640 |
52,407 | the01/python-floscraper | floscraper/webscraper.py | WebScraper.shrink | def shrink(self, shrink):
"""
Remove unnecessary parts
:param shrink: Object to shringk
:type shrink: dict | list
:return: Shrunk object
:rtype: dict | list
"""
if isinstance(shrink, list):
return self._shrink_list(shrink)
if isinstanc... | python | def shrink(self, shrink):
"""
Remove unnecessary parts
:param shrink: Object to shringk
:type shrink: dict | list
:return: Shrunk object
:rtype: dict | list
"""
if isinstance(shrink, list):
return self._shrink_list(shrink)
if isinstanc... | [
"def",
"shrink",
"(",
"self",
",",
"shrink",
")",
":",
"if",
"isinstance",
"(",
"shrink",
",",
"list",
")",
":",
"return",
"self",
".",
"_shrink_list",
"(",
"shrink",
")",
"if",
"isinstance",
"(",
"shrink",
",",
"dict",
")",
":",
"return",
"self",
".... | Remove unnecessary parts
:param shrink: Object to shringk
:type shrink: dict | list
:return: Shrunk object
:rtype: dict | list | [
"Remove",
"unnecessary",
"parts"
] | d578cd3d6381070d9a07dade1e10387ae33e9a65 | https://github.com/the01/python-floscraper/blob/d578cd3d6381070d9a07dade1e10387ae33e9a65/floscraper/webscraper.py#L642-L655 |
52,408 | moschlar/tw2.codemirror | tw2/codemirror/widgets.py | mode_name | def mode_name(mode):
'''Tries best-effortly to get the right mode name'''
if mode:
l = mode.lower()
if l in ('java', ):
return ('clike', 'text/x-java')
if l in ('c', ):
return ('clike', 'text/x-csrc')
if l in ('c++', 'cxx'):
return ('clike', ... | python | def mode_name(mode):
'''Tries best-effortly to get the right mode name'''
if mode:
l = mode.lower()
if l in ('java', ):
return ('clike', 'text/x-java')
if l in ('c', ):
return ('clike', 'text/x-csrc')
if l in ('c++', 'cxx'):
return ('clike', ... | [
"def",
"mode_name",
"(",
"mode",
")",
":",
"if",
"mode",
":",
"l",
"=",
"mode",
".",
"lower",
"(",
")",
"if",
"l",
"in",
"(",
"'java'",
",",
")",
":",
"return",
"(",
"'clike'",
",",
"'text/x-java'",
")",
"if",
"l",
"in",
"(",
"'c'",
",",
")",
... | Tries best-effortly to get the right mode name | [
"Tries",
"best",
"-",
"effortly",
"to",
"get",
"the",
"right",
"mode",
"name"
] | 7740d278afa69d6070c58116c84fb0b3883baa73 | https://github.com/moschlar/tw2.codemirror/blob/7740d278afa69d6070c58116c84fb0b3883baa73/tw2/codemirror/widgets.py#L66-L87 |
52,409 | RI-imaging/qpsphere | qpsphere/models/__init__.py | simulate | def simulate(radius=5e-6, sphere_index=1.339, medium_index=1.333,
wavelength=550e-9, grid_size=(80, 80), model="projection",
pixel_size=None, center=None):
"""Simulate scattering at a sphere
Parameters
----------
radius: float
Radius of the sphere [m]
sphere_index:... | python | def simulate(radius=5e-6, sphere_index=1.339, medium_index=1.333,
wavelength=550e-9, grid_size=(80, 80), model="projection",
pixel_size=None, center=None):
"""Simulate scattering at a sphere
Parameters
----------
radius: float
Radius of the sphere [m]
sphere_index:... | [
"def",
"simulate",
"(",
"radius",
"=",
"5e-6",
",",
"sphere_index",
"=",
"1.339",
",",
"medium_index",
"=",
"1.333",
",",
"wavelength",
"=",
"550e-9",
",",
"grid_size",
"=",
"(",
"80",
",",
"80",
")",
",",
"model",
"=",
"\"projection\"",
",",
"pixel_size... | Simulate scattering at a sphere
Parameters
----------
radius: float
Radius of the sphere [m]
sphere_index: float
Refractive index of the object
medium_index: float
Refractive index of the surrounding medium
wavelength: float
Vacuum wavelength of the imaging light... | [
"Simulate",
"scattering",
"at",
"a",
"sphere"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/models/__init__.py#L21-L86 |
52,410 | RI-imaging/qpsphere | qpsphere/imagefit/interp.py | SpherePhaseInterpolator.params | def params(self):
"""Current interpolation parameter dictionary"""
par = {"radius": self.radius,
"sphere_index": self.sphere_index,
"pha_offset": self.pha_offset,
"center": [self.posx_offset, self.posy_offset]
}
return par | python | def params(self):
"""Current interpolation parameter dictionary"""
par = {"radius": self.radius,
"sphere_index": self.sphere_index,
"pha_offset": self.pha_offset,
"center": [self.posx_offset, self.posy_offset]
}
return par | [
"def",
"params",
"(",
"self",
")",
":",
"par",
"=",
"{",
"\"radius\"",
":",
"self",
".",
"radius",
",",
"\"sphere_index\"",
":",
"self",
".",
"sphere_index",
",",
"\"pha_offset\"",
":",
"self",
".",
"pha_offset",
",",
"\"center\"",
":",
"[",
"self",
".",... | Current interpolation parameter dictionary | [
"Current",
"interpolation",
"parameter",
"dictionary"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/imagefit/interp.py#L82-L89 |
52,411 | RI-imaging/qpsphere | qpsphere/imagefit/interp.py | SpherePhaseInterpolator.range_n | def range_n(self):
"""Current interpolation range of refractive index"""
return self.sphere_index - self.dn, self.sphere_index + self.dn | python | def range_n(self):
"""Current interpolation range of refractive index"""
return self.sphere_index - self.dn, self.sphere_index + self.dn | [
"def",
"range_n",
"(",
"self",
")",
":",
"return",
"self",
".",
"sphere_index",
"-",
"self",
".",
"dn",
",",
"self",
".",
"sphere_index",
"+",
"self",
".",
"dn"
] | Current interpolation range of refractive index | [
"Current",
"interpolation",
"range",
"of",
"refractive",
"index"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/imagefit/interp.py#L92-L94 |
52,412 | RI-imaging/qpsphere | qpsphere/imagefit/interp.py | SpherePhaseInterpolator.range_r | def range_r(self):
"""Current interpolation range of radius"""
return self.radius - self.dr, self.radius + self.dr | python | def range_r(self):
"""Current interpolation range of radius"""
return self.radius - self.dr, self.radius + self.dr | [
"def",
"range_r",
"(",
"self",
")",
":",
"return",
"self",
".",
"radius",
"-",
"self",
".",
"dr",
",",
"self",
".",
"radius",
"+",
"self",
".",
"dr"
] | Current interpolation range of radius | [
"Current",
"interpolation",
"range",
"of",
"radius"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/imagefit/interp.py#L97-L99 |
52,413 | RI-imaging/qpsphere | qpsphere/imagefit/interp.py | SpherePhaseInterpolator.compute_qpi | def compute_qpi(self):
"""Compute model data with current parameters
Returns
-------
qpi: qpimage.QPImage
Modeled phase data
Notes
-----
The model image might deviate from the fitted image
because of interpolation during the fitting process.
... | python | def compute_qpi(self):
"""Compute model data with current parameters
Returns
-------
qpi: qpimage.QPImage
Modeled phase data
Notes
-----
The model image might deviate from the fitted image
because of interpolation during the fitting process.
... | [
"def",
"compute_qpi",
"(",
"self",
")",
":",
"kwargs",
"=",
"self",
".",
"model_kwargs",
".",
"copy",
"(",
")",
"kwargs",
"[",
"\"radius\"",
"]",
"=",
"self",
".",
"radius",
"kwargs",
"[",
"\"sphere_index\"",
"]",
"=",
"self",
".",
"sphere_index",
"kwarg... | Compute model data with current parameters
Returns
-------
qpi: qpimage.QPImage
Modeled phase data
Notes
-----
The model image might deviate from the fitted image
because of interpolation during the fitting process. | [
"Compute",
"model",
"data",
"with",
"current",
"parameters"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/imagefit/interp.py#L101-L122 |
52,414 | RI-imaging/qpsphere | qpsphere/imagefit/interp.py | SpherePhaseInterpolator.get_border_phase | def get_border_phase(self, idn=0, idr=0):
"""Return one of nine border fields
Parameters
----------
idn: int
Index for refractive index.
One of -1 (left), 0 (center), 1 (right)
idr: int
Index for radius.
One of -1 (left), 0 (center... | python | def get_border_phase(self, idn=0, idr=0):
"""Return one of nine border fields
Parameters
----------
idn: int
Index for refractive index.
One of -1 (left), 0 (center), 1 (right)
idr: int
Index for radius.
One of -1 (left), 0 (center... | [
"def",
"get_border_phase",
"(",
"self",
",",
"idn",
"=",
"0",
",",
"idr",
"=",
"0",
")",
":",
"assert",
"idn",
"in",
"[",
"-",
"1",
",",
"0",
",",
"1",
"]",
"assert",
"idr",
"in",
"[",
"-",
"1",
",",
"0",
",",
"1",
"]",
"n",
"=",
"self",
... | Return one of nine border fields
Parameters
----------
idn: int
Index for refractive index.
One of -1 (left), 0 (center), 1 (right)
idr: int
Index for radius.
One of -1 (left), 0 (center), 1 (right) | [
"Return",
"one",
"of",
"nine",
"border",
"fields"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/imagefit/interp.py#L124-L167 |
52,415 | RI-imaging/qpsphere | qpsphere/imagefit/interp.py | SpherePhaseInterpolator.get_phase | def get_phase(self, nintp=None, rintp=None,
delta_offset_x=0, delta_offset_y=0):
"""Interpolate from the border fields to new coordinates
Parameters
----------
nintp: float or None
Refractive index of the sphere
rintp: float or None
Radi... | python | def get_phase(self, nintp=None, rintp=None,
delta_offset_x=0, delta_offset_y=0):
"""Interpolate from the border fields to new coordinates
Parameters
----------
nintp: float or None
Refractive index of the sphere
rintp: float or None
Radi... | [
"def",
"get_phase",
"(",
"self",
",",
"nintp",
"=",
"None",
",",
"rintp",
"=",
"None",
",",
"delta_offset_x",
"=",
"0",
",",
"delta_offset_y",
"=",
"0",
")",
":",
"if",
"nintp",
"is",
"None",
":",
"nintp",
"=",
"self",
".",
"sphere_index",
"if",
"rin... | Interpolate from the border fields to new coordinates
Parameters
----------
nintp: float or None
Refractive index of the sphere
rintp: float or None
Radius of sphere [m]
delta_offset_x: float
Offset in x-direction [px]
delta_offset_y: ... | [
"Interpolate",
"from",
"the",
"border",
"fields",
"to",
"new",
"coordinates"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/imagefit/interp.py#L169-L251 |
52,416 | sci-bots/pygtkhelpers | pygtkhelpers/ui/widgets.py | EmptyTextViewFiller.set_empty_text | def set_empty_text(self):
"""Display the empty text
"""
self.buffer.insert_with_tags_by_name(
self.buffer.get_start_iter(),
self.empty_text, 'empty-text') | python | def set_empty_text(self):
"""Display the empty text
"""
self.buffer.insert_with_tags_by_name(
self.buffer.get_start_iter(),
self.empty_text, 'empty-text') | [
"def",
"set_empty_text",
"(",
"self",
")",
":",
"self",
".",
"buffer",
".",
"insert_with_tags_by_name",
"(",
"self",
".",
"buffer",
".",
"get_start_iter",
"(",
")",
",",
"self",
".",
"empty_text",
",",
"'empty-text'",
")"
] | Display the empty text | [
"Display",
"the",
"empty",
"text"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/widgets.py#L226-L231 |
52,417 | lvh/txeasymail | txeasymail/mime.py | buildMessage | def buildMessage(headers, parts):
"""
Builds a message from some headers and MIME parts.
"""
message = multipart.MIMEMultipart('alternative')
for name, value in headers.iteritems():
name = name.title()
if name == "From":
multipart[name] = _encodeAddress(value)
el... | python | def buildMessage(headers, parts):
"""
Builds a message from some headers and MIME parts.
"""
message = multipart.MIMEMultipart('alternative')
for name, value in headers.iteritems():
name = name.title()
if name == "From":
multipart[name] = _encodeAddress(value)
el... | [
"def",
"buildMessage",
"(",
"headers",
",",
"parts",
")",
":",
"message",
"=",
"multipart",
".",
"MIMEMultipart",
"(",
"'alternative'",
")",
"for",
"name",
",",
"value",
"in",
"headers",
".",
"iteritems",
"(",
")",
":",
"name",
"=",
"name",
".",
"title",... | Builds a message from some headers and MIME parts. | [
"Builds",
"a",
"message",
"from",
"some",
"headers",
"and",
"MIME",
"parts",
"."
] | 7b845a5238b1371824854468646d54653a426f09 | https://github.com/lvh/txeasymail/blob/7b845a5238b1371824854468646d54653a426f09/txeasymail/mime.py#L15-L34 |
52,418 | lvh/txeasymail | txeasymail/mime.py | _encodeHeader | def _encodeHeader(headerValue):
"""
Encodes a header value.
Returns ASCII if possible, else returns an UTF-8 encoded e-mail header.
"""
try:
return headerValue.encode('ascii', 'strict')
except UnicodeError:
encoded = headerValue.encode("utf-8")
return header.Header(encod... | python | def _encodeHeader(headerValue):
"""
Encodes a header value.
Returns ASCII if possible, else returns an UTF-8 encoded e-mail header.
"""
try:
return headerValue.encode('ascii', 'strict')
except UnicodeError:
encoded = headerValue.encode("utf-8")
return header.Header(encod... | [
"def",
"_encodeHeader",
"(",
"headerValue",
")",
":",
"try",
":",
"return",
"headerValue",
".",
"encode",
"(",
"'ascii'",
",",
"'strict'",
")",
"except",
"UnicodeError",
":",
"encoded",
"=",
"headerValue",
".",
"encode",
"(",
"\"utf-8\"",
")",
"return",
"hea... | Encodes a header value.
Returns ASCII if possible, else returns an UTF-8 encoded e-mail header. | [
"Encodes",
"a",
"header",
"value",
"."
] | 7b845a5238b1371824854468646d54653a426f09 | https://github.com/lvh/txeasymail/blob/7b845a5238b1371824854468646d54653a426f09/txeasymail/mime.py#L37-L47 |
52,419 | lvh/txeasymail | txeasymail/mime.py | messageToFile | def messageToFile(message):
"""
Flattens a message into a file-like object.
"""
outFile = StringIO()
messageGenerator = generator.Generator(outFile, False)
messageGenerator.flatten(message)
outFile.seek(0, 0)
return outFile | python | def messageToFile(message):
"""
Flattens a message into a file-like object.
"""
outFile = StringIO()
messageGenerator = generator.Generator(outFile, False)
messageGenerator.flatten(message)
outFile.seek(0, 0)
return outFile | [
"def",
"messageToFile",
"(",
"message",
")",
":",
"outFile",
"=",
"StringIO",
"(",
")",
"messageGenerator",
"=",
"generator",
".",
"Generator",
"(",
"outFile",
",",
"False",
")",
"messageGenerator",
".",
"flatten",
"(",
"message",
")",
"outFile",
".",
"seek"... | Flattens a message into a file-like object. | [
"Flattens",
"a",
"message",
"into",
"a",
"file",
"-",
"like",
"object",
"."
] | 7b845a5238b1371824854468646d54653a426f09 | https://github.com/lvh/txeasymail/blob/7b845a5238b1371824854468646d54653a426f09/txeasymail/mime.py#L73-L81 |
52,420 | RI-imaging/qpsphere | qpsphere/edgefit.py | analyze | def analyze(qpi, r0, edgekw={}, ret_center=False, ret_edge=False):
"""Determine refractive index and radius using Canny edge detection
Compute the refractive index of a spherical phase object by
detection of an edge in the phase image, a subsequent circle
fit to the edge, and finally a weighted average... | python | def analyze(qpi, r0, edgekw={}, ret_center=False, ret_edge=False):
"""Determine refractive index and radius using Canny edge detection
Compute the refractive index of a spherical phase object by
detection of an edge in the phase image, a subsequent circle
fit to the edge, and finally a weighted average... | [
"def",
"analyze",
"(",
"qpi",
",",
"r0",
",",
"edgekw",
"=",
"{",
"}",
",",
"ret_center",
"=",
"False",
",",
"ret_edge",
"=",
"False",
")",
":",
"nmed",
"=",
"qpi",
"[",
"\"medium index\"",
"]",
"px_m",
"=",
"qpi",
"[",
"\"pixel size\"",
"]",
"wl_m",... | Determine refractive index and radius using Canny edge detection
Compute the refractive index of a spherical phase object by
detection of an edge in the phase image, a subsequent circle
fit to the edge, and finally a weighted average over the phase
image assuming a parabolic phase profile.
Paramet... | [
"Determine",
"refractive",
"index",
"and",
"radius",
"using",
"Canny",
"edge",
"detection"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/edgefit.py#L21-L74 |
52,421 | RI-imaging/qpsphere | qpsphere/edgefit.py | average_sphere | def average_sphere(image, center, radius, weighted=True, ret_crop=False):
"""Compute the weighted average phase from a phase image of a sphere
Parameters
----------
image: 2d ndarray
Quantitative phase image of a sphere
center: tuble (x,y)
Center of the sphere in `image` in ndarray ... | python | def average_sphere(image, center, radius, weighted=True, ret_crop=False):
"""Compute the weighted average phase from a phase image of a sphere
Parameters
----------
image: 2d ndarray
Quantitative phase image of a sphere
center: tuble (x,y)
Center of the sphere in `image` in ndarray ... | [
"def",
"average_sphere",
"(",
"image",
",",
"center",
",",
"radius",
",",
"weighted",
"=",
"True",
",",
"ret_crop",
"=",
"False",
")",
":",
"sx",
",",
"sy",
"=",
"image",
".",
"shape",
"x",
"=",
"np",
".",
"arange",
"(",
"sx",
")",
".",
"reshape",
... | Compute the weighted average phase from a phase image of a sphere
Parameters
----------
image: 2d ndarray
Quantitative phase image of a sphere
center: tuble (x,y)
Center of the sphere in `image` in ndarray coordinates
radius: float
Radius of the sphere in pixels
weighted... | [
"Compute",
"the",
"weighted",
"average",
"phase",
"from",
"a",
"phase",
"image",
"of",
"a",
"sphere"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/edgefit.py#L77-L127 |
52,422 | RI-imaging/qpsphere | qpsphere/edgefit.py | circle_fit | def circle_fit(edge, ret_dev=False):
"""Fit a circle to a boolean edge image
Parameters
----------
edge: 2d boolean ndarray
Edge image
ret_dev: bool
Return the average deviation of the distance from contour to
center of the fitted circle.
Returns
-------
center:... | python | def circle_fit(edge, ret_dev=False):
"""Fit a circle to a boolean edge image
Parameters
----------
edge: 2d boolean ndarray
Edge image
ret_dev: bool
Return the average deviation of the distance from contour to
center of the fitted circle.
Returns
-------
center:... | [
"def",
"circle_fit",
"(",
"edge",
",",
"ret_dev",
"=",
"False",
")",
":",
"sx",
",",
"sy",
"=",
"edge",
".",
"shape",
"x",
"=",
"np",
".",
"linspace",
"(",
"0",
",",
"sx",
",",
"sx",
",",
"endpoint",
"=",
"False",
")",
".",
"reshape",
"(",
"-",... | Fit a circle to a boolean edge image
Parameters
----------
edge: 2d boolean ndarray
Edge image
ret_dev: bool
Return the average deviation of the distance from contour to
center of the fitted circle.
Returns
-------
center: tuple of (float, float)
Coordinates... | [
"Fit",
"a",
"circle",
"to",
"a",
"boolean",
"edge",
"image"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/edgefit.py#L130-L171 |
52,423 | RI-imaging/qpsphere | qpsphere/edgefit.py | circle_radii | def circle_radii(params, xedge, yedge):
"""Compute the distance to the center from cartesian coordinates
This method is used for fitting a circle to a set of contour
points.
Parameters
----------
params: lmfit.Parameters
Must contain the keys:
- "cx": origin of x coordinate [p... | python | def circle_radii(params, xedge, yedge):
"""Compute the distance to the center from cartesian coordinates
This method is used for fitting a circle to a set of contour
points.
Parameters
----------
params: lmfit.Parameters
Must contain the keys:
- "cx": origin of x coordinate [p... | [
"def",
"circle_radii",
"(",
"params",
",",
"xedge",
",",
"yedge",
")",
":",
"cx",
"=",
"params",
"[",
"\"cx\"",
"]",
".",
"value",
"cy",
"=",
"params",
"[",
"\"cy\"",
"]",
".",
"value",
"radii",
"=",
"np",
".",
"sqrt",
"(",
"(",
"cx",
"-",
"xedge... | Compute the distance to the center from cartesian coordinates
This method is used for fitting a circle to a set of contour
points.
Parameters
----------
params: lmfit.Parameters
Must contain the keys:
- "cx": origin of x coordinate [px]
- "cy": origin of y coordinate [px]
... | [
"Compute",
"the",
"distance",
"to",
"the",
"center",
"from",
"cartesian",
"coordinates"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/edgefit.py#L174-L200 |
52,424 | RI-imaging/qpsphere | qpsphere/edgefit.py | circle_residual | def circle_residual(params, xedge, yedge):
"""Residuals for circle fitting
Parameters
----------
params: lmfit.Parameters
Must contain the keys:
- "cx": origin of x coordinate [px]
- "cy": origin of y coordinate [px]
xedge: 1D np.ndarray
Edge coordinates x [px]
... | python | def circle_residual(params, xedge, yedge):
"""Residuals for circle fitting
Parameters
----------
params: lmfit.Parameters
Must contain the keys:
- "cx": origin of x coordinate [px]
- "cy": origin of y coordinate [px]
xedge: 1D np.ndarray
Edge coordinates x [px]
... | [
"def",
"circle_residual",
"(",
"params",
",",
"xedge",
",",
"yedge",
")",
":",
"radii",
"=",
"circle_radii",
"(",
"params",
",",
"xedge",
",",
"yedge",
")",
"return",
"radii",
"-",
"np",
".",
"mean",
"(",
"radii",
")"
] | Residuals for circle fitting
Parameters
----------
params: lmfit.Parameters
Must contain the keys:
- "cx": origin of x coordinate [px]
- "cy": origin of y coordinate [px]
xedge: 1D np.ndarray
Edge coordinates x [px]
yedge: 1D np.ndarray
Edge coordinates y [p... | [
"Residuals",
"for",
"circle",
"fitting"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/edgefit.py#L203-L224 |
52,425 | sci-bots/pygtkhelpers | pygtkhelpers/ui/views/command_textview.py | get_run_command_dialog | def get_run_command_dialog(command, shell=False, title='', data_callback=None,
parent=None, **kwargs):
'''
Launch command in a subprocess and create a dialog window to monitor the
output of the process.
Parameters
----------
command : list or str
Subprocess co... | python | def get_run_command_dialog(command, shell=False, title='', data_callback=None,
parent=None, **kwargs):
'''
Launch command in a subprocess and create a dialog window to monitor the
output of the process.
Parameters
----------
command : list or str
Subprocess co... | [
"def",
"get_run_command_dialog",
"(",
"command",
",",
"shell",
"=",
"False",
",",
"title",
"=",
"''",
",",
"data_callback",
"=",
"None",
",",
"parent",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"dialog",
"=",
"gtk",
".",
"Dialog",
"(",
"title",
... | Launch command in a subprocess and create a dialog window to monitor the
output of the process.
Parameters
----------
command : list or str
Subprocess command to execute.
shell : bool, optional
If :data:`shell` is ``False``, :data:`command` **must** be a
:class:`list`.
... | [
"Launch",
"command",
"in",
"a",
"subprocess",
"and",
"create",
"a",
"dialog",
"window",
"to",
"monitor",
"the",
"output",
"of",
"the",
"process",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/views/command_textview.py#L95-L187 |
52,426 | ktdreyer/txbugzilla | txbugzilla/__init__.py | api_key_from_file | def api_key_from_file(url):
""" Check bugzillarc for an API key for this Bugzilla URL. """
path = os.path.expanduser('~/.config/python-bugzilla/bugzillarc')
cfg = SafeConfigParser()
cfg.read(path)
domain = urlparse(url)[1]
if domain not in cfg.sections():
return None
if not cfg.has_o... | python | def api_key_from_file(url):
""" Check bugzillarc for an API key for this Bugzilla URL. """
path = os.path.expanduser('~/.config/python-bugzilla/bugzillarc')
cfg = SafeConfigParser()
cfg.read(path)
domain = urlparse(url)[1]
if domain not in cfg.sections():
return None
if not cfg.has_o... | [
"def",
"api_key_from_file",
"(",
"url",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/.config/python-bugzilla/bugzillarc'",
")",
"cfg",
"=",
"SafeConfigParser",
"(",
")",
"cfg",
".",
"read",
"(",
"path",
")",
"domain",
"=",
"urlparse"... | Check bugzillarc for an API key for this Bugzilla URL. | [
"Check",
"bugzillarc",
"for",
"an",
"API",
"key",
"for",
"this",
"Bugzilla",
"URL",
"."
] | ccfc6667ce9d696b08b468b25c813cc2b68d30d6 | https://github.com/ktdreyer/txbugzilla/blob/ccfc6667ce9d696b08b468b25c813cc2b68d30d6/txbugzilla/__init__.py#L27-L37 |
52,427 | ktdreyer/txbugzilla | txbugzilla/__init__.py | Connection.call | def call(self, action, payload):
"""
Make an XML-RPC call to the server. This method will automatically
authenticate the call with self.api_key, if that is set.
returns: deferred that when fired returns a dict with data from this
XML-RPC call.
"""
if sel... | python | def call(self, action, payload):
"""
Make an XML-RPC call to the server. This method will automatically
authenticate the call with self.api_key, if that is set.
returns: deferred that when fired returns a dict with data from this
XML-RPC call.
"""
if sel... | [
"def",
"call",
"(",
"self",
",",
"action",
",",
"payload",
")",
":",
"if",
"self",
".",
"api_key",
":",
"payload",
"[",
"'Bugzilla_api_key'",
"]",
"=",
"self",
".",
"api_key",
"d",
"=",
"self",
".",
"proxy",
".",
"callRemote",
"(",
"action",
",",
"pa... | Make an XML-RPC call to the server. This method will automatically
authenticate the call with self.api_key, if that is set.
returns: deferred that when fired returns a dict with data from this
XML-RPC call. | [
"Make",
"an",
"XML",
"-",
"RPC",
"call",
"to",
"the",
"server",
".",
"This",
"method",
"will",
"automatically",
"authenticate",
"the",
"call",
"with",
"self",
".",
"api_key",
"if",
"that",
"is",
"set",
"."
] | ccfc6667ce9d696b08b468b25c813cc2b68d30d6 | https://github.com/ktdreyer/txbugzilla/blob/ccfc6667ce9d696b08b468b25c813cc2b68d30d6/txbugzilla/__init__.py#L47-L59 |
52,428 | ktdreyer/txbugzilla | txbugzilla/__init__.py | Connection.assign | def assign(self, bugids, user):
"""
Assign a bug to a user.
param bugid: ``int``, bug ID number.
param user: ``str``, the login name of the user to whom the bug is
assigned
returns: deferred that when fired returns True if the change succeeded,
... | python | def assign(self, bugids, user):
"""
Assign a bug to a user.
param bugid: ``int``, bug ID number.
param user: ``str``, the login name of the user to whom the bug is
assigned
returns: deferred that when fired returns True if the change succeeded,
... | [
"def",
"assign",
"(",
"self",
",",
"bugids",
",",
"user",
")",
":",
"payload",
"=",
"{",
"'ids'",
":",
"(",
"bugids",
",",
")",
",",
"'assigned_to'",
":",
"user",
"}",
"d",
"=",
"self",
".",
"call",
"(",
"'Bug.update'",
",",
"payload",
")",
"d",
... | Assign a bug to a user.
param bugid: ``int``, bug ID number.
param user: ``str``, the login name of the user to whom the bug is
assigned
returns: deferred that when fired returns True if the change succeeded,
False if the change was unnecessary (because the ... | [
"Assign",
"a",
"bug",
"to",
"a",
"user",
"."
] | ccfc6667ce9d696b08b468b25c813cc2b68d30d6 | https://github.com/ktdreyer/txbugzilla/blob/ccfc6667ce9d696b08b468b25c813cc2b68d30d6/txbugzilla/__init__.py#L100-L114 |
52,429 | ktdreyer/txbugzilla | txbugzilla/__init__.py | Connection.find_by_external_tracker | def find_by_external_tracker(self, url, id_):
"""
Find a list of bugs by searching an external tracker URL and ID.
param url: ``str``, the external ticket URL, eg
"http://tracker.ceph.com". (Note this is the base URL.)
param id_: ``str``, the external ticket ID, eg "1... | python | def find_by_external_tracker(self, url, id_):
"""
Find a list of bugs by searching an external tracker URL and ID.
param url: ``str``, the external ticket URL, eg
"http://tracker.ceph.com". (Note this is the base URL.)
param id_: ``str``, the external ticket ID, eg "1... | [
"def",
"find_by_external_tracker",
"(",
"self",
",",
"url",
",",
"id_",
")",
":",
"payload",
"=",
"{",
"'include_fields'",
":",
"[",
"'id'",
",",
"'summary'",
",",
"'status'",
"]",
",",
"'f1'",
":",
"'external_bugzilla.url'",
",",
"'o1'",
":",
"'substring'",... | Find a list of bugs by searching an external tracker URL and ID.
param url: ``str``, the external ticket URL, eg
"http://tracker.ceph.com". (Note this is the base URL.)
param id_: ``str``, the external ticket ID, eg "18812".
returns: deferred that when fired returns a list of... | [
"Find",
"a",
"list",
"of",
"bugs",
"by",
"searching",
"an",
"external",
"tracker",
"URL",
"and",
"ID",
"."
] | ccfc6667ce9d696b08b468b25c813cc2b68d30d6 | https://github.com/ktdreyer/txbugzilla/blob/ccfc6667ce9d696b08b468b25c813cc2b68d30d6/txbugzilla/__init__.py#L116-L137 |
52,430 | ktdreyer/txbugzilla | txbugzilla/__init__.py | Connection._parse_bugs_callback | def _parse_bugs_callback(self, value):
"""
Fires when we get bug information back from the XML-RPC server.
param value: dict of data from XML-RPC server. The "bugs" dict element
contains a list of bugs.
returns: ``list`` of ``AttrDict``
"""
return li... | python | def _parse_bugs_callback(self, value):
"""
Fires when we get bug information back from the XML-RPC server.
param value: dict of data from XML-RPC server. The "bugs" dict element
contains a list of bugs.
returns: ``list`` of ``AttrDict``
"""
return li... | [
"def",
"_parse_bugs_callback",
"(",
"self",
",",
"value",
")",
":",
"return",
"list",
"(",
"map",
"(",
"lambda",
"x",
":",
"self",
".",
"_parse_bug",
"(",
"x",
")",
",",
"value",
"[",
"'bugs'",
"]",
")",
")"
] | Fires when we get bug information back from the XML-RPC server.
param value: dict of data from XML-RPC server. The "bugs" dict element
contains a list of bugs.
returns: ``list`` of ``AttrDict`` | [
"Fires",
"when",
"we",
"get",
"bug",
"information",
"back",
"from",
"the",
"XML",
"-",
"RPC",
"server",
"."
] | ccfc6667ce9d696b08b468b25c813cc2b68d30d6 | https://github.com/ktdreyer/txbugzilla/blob/ccfc6667ce9d696b08b468b25c813cc2b68d30d6/txbugzilla/__init__.py#L149-L157 |
52,431 | the01/paps-settings | app/pluginProtocol.py | PluginServerProtocol.onSettingsChange | def onSettingsChange(self, plugin_name, data):
"""
The plugin has been changed by the frontend
:param plugin_name: Name of plugin that changed
:type plugin_name: str
:param data: Complete data (changed and unchanged)
:type data: dict
:rtype: None
"""
... | python | def onSettingsChange(self, plugin_name, data):
"""
The plugin has been changed by the frontend
:param plugin_name: Name of plugin that changed
:type plugin_name: str
:param data: Complete data (changed and unchanged)
:type data: dict
:rtype: None
"""
... | [
"def",
"onSettingsChange",
"(",
"self",
",",
"plugin_name",
",",
"data",
")",
":",
"logger",
".",
"info",
"(",
"u\"onSettingsChange: {}\"",
".",
"format",
"(",
"data",
")",
")",
"if",
"not",
"plugin_name",
":",
"logger",
".",
"error",
"(",
"\"Missing plugin ... | The plugin has been changed by the frontend
:param plugin_name: Name of plugin that changed
:type plugin_name: str
:param data: Complete data (changed and unchanged)
:type data: dict
:rtype: None | [
"The",
"plugin",
"has",
"been",
"changed",
"by",
"the",
"frontend"
] | 48fb65eb0fa7929a0bb381c6dad28d0197b44c83 | https://github.com/the01/paps-settings/blob/48fb65eb0fa7929a0bb381c6dad28d0197b44c83/app/pluginProtocol.py#L85-L112 |
52,432 | the01/paps-settings | app/pluginProtocol.py | PluginServerProtocol.onRefreshPluginData | def onRefreshPluginData(self, plugin_name, data):
"""
Frontend requests a data refresh
:param plugin_name: Name of plugin that changed
:type plugin_name: str
:param data: Additional data
:type data: None
:rtype: None
"""
logger.info(u"onRefreshPlu... | python | def onRefreshPluginData(self, plugin_name, data):
"""
Frontend requests a data refresh
:param plugin_name: Name of plugin that changed
:type plugin_name: str
:param data: Additional data
:type data: None
:rtype: None
"""
logger.info(u"onRefreshPlu... | [
"def",
"onRefreshPluginData",
"(",
"self",
",",
"plugin_name",
",",
"data",
")",
":",
"logger",
".",
"info",
"(",
"u\"onRefreshPluginData: {}\"",
".",
"format",
"(",
"plugin_name",
")",
")",
"if",
"not",
"plugin_name",
":",
"logger",
".",
"error",
"(",
"\"Mi... | Frontend requests a data refresh
:param plugin_name: Name of plugin that changed
:type plugin_name: str
:param data: Additional data
:type data: None
:rtype: None | [
"Frontend",
"requests",
"a",
"data",
"refresh"
] | 48fb65eb0fa7929a0bb381c6dad28d0197b44c83 | https://github.com/the01/paps-settings/blob/48fb65eb0fa7929a0bb381c6dad28d0197b44c83/app/pluginProtocol.py#L114-L131 |
52,433 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClient.connect | def connect(self,soft_reset=False,**options):
""" This just creates the websocket connection
"""
self._state = STATE_CONNECTING
logger.debug("About to connect to {}".format(self.url))
m = re.search('(ws+)://([\w\.]+)(:?:(\d+))?',self.url)
options['subprotocols'] = ['wam... | python | def connect(self,soft_reset=False,**options):
""" This just creates the websocket connection
"""
self._state = STATE_CONNECTING
logger.debug("About to connect to {}".format(self.url))
m = re.search('(ws+)://([\w\.]+)(:?:(\d+))?',self.url)
options['subprotocols'] = ['wam... | [
"def",
"connect",
"(",
"self",
",",
"soft_reset",
"=",
"False",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"_state",
"=",
"STATE_CONNECTING",
"logger",
".",
"debug",
"(",
"\"About to connect to {}\"",
".",
"format",
"(",
"self",
".",
"url",
")",
")... | This just creates the websocket connection | [
"This",
"just",
"creates",
"the",
"websocket",
"connection"
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L152-L222 |
52,434 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClient.hello | def hello(self,details=None):
""" Say hello to the server and wait for the welcome
message before proceeding
"""
self._welcome_queue = queue.Queue()
if details is None:
details = {}
if self.authid:
details.setdefault('authid', self.authid)
... | python | def hello(self,details=None):
""" Say hello to the server and wait for the welcome
message before proceeding
"""
self._welcome_queue = queue.Queue()
if details is None:
details = {}
if self.authid:
details.setdefault('authid', self.authid)
... | [
"def",
"hello",
"(",
"self",
",",
"details",
"=",
"None",
")",
":",
"self",
".",
"_welcome_queue",
"=",
"queue",
".",
"Queue",
"(",
")",
"if",
"details",
"is",
"None",
":",
"details",
"=",
"{",
"}",
"if",
"self",
".",
"authid",
":",
"details",
".",... | Say hello to the server and wait for the welcome
message before proceeding | [
"Say",
"hello",
"to",
"the",
"server",
"and",
"wait",
"for",
"the",
"welcome",
"message",
"before",
"proceeding"
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L273-L311 |
52,435 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClient.call | def call(self, uri, *args, **kwargs ):
""" Sends a RPC request to the WAMP server
"""
if self._state == STATE_DISCONNECTED:
raise Exception("WAMP is currently disconnected!")
options = {
'disclose_me': True
}
uri = self.get_full_uri(uri)
me... | python | def call(self, uri, *args, **kwargs ):
""" Sends a RPC request to the WAMP server
"""
if self._state == STATE_DISCONNECTED:
raise Exception("WAMP is currently disconnected!")
options = {
'disclose_me': True
}
uri = self.get_full_uri(uri)
me... | [
"def",
"call",
"(",
"self",
",",
"uri",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_state",
"==",
"STATE_DISCONNECTED",
":",
"raise",
"Exception",
"(",
"\"WAMP is currently disconnected!\"",
")",
"options",
"=",
"{",
"'disclos... | Sends a RPC request to the WAMP server | [
"Sends",
"a",
"RPC",
"request",
"to",
"the",
"WAMP",
"server"
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L313-L339 |
52,436 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClient.send_message | def send_message(self,message):
""" Send awamp message to the server. We don't wait
for a response here. Just fire out a message
"""
if self._state == STATE_DISCONNECTED:
raise Exception("WAMP is currently disconnected!")
message = message.as_str()
logger.... | python | def send_message(self,message):
""" Send awamp message to the server. We don't wait
for a response here. Just fire out a message
"""
if self._state == STATE_DISCONNECTED:
raise Exception("WAMP is currently disconnected!")
message = message.as_str()
logger.... | [
"def",
"send_message",
"(",
"self",
",",
"message",
")",
":",
"if",
"self",
".",
"_state",
"==",
"STATE_DISCONNECTED",
":",
"raise",
"Exception",
"(",
"\"WAMP is currently disconnected!\"",
")",
"message",
"=",
"message",
".",
"as_str",
"(",
")",
"logger",
"."... | Send awamp message to the server. We don't wait
for a response here. Just fire out a message | [
"Send",
"awamp",
"message",
"to",
"the",
"server",
".",
"We",
"don",
"t",
"wait",
"for",
"a",
"response",
"here",
".",
"Just",
"fire",
"out",
"a",
"message"
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L341-L351 |
52,437 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClient.send_and_await_response | def send_and_await_response(self,request):
""" Used by most things. Sends out a request then awaits a response
keyed by the request_id
"""
if self._state == STATE_DISCONNECTED:
raise Exception("WAMP is currently disconnected!")
wait_queue = queue.Queue()
r... | python | def send_and_await_response(self,request):
""" Used by most things. Sends out a request then awaits a response
keyed by the request_id
"""
if self._state == STATE_DISCONNECTED:
raise Exception("WAMP is currently disconnected!")
wait_queue = queue.Queue()
r... | [
"def",
"send_and_await_response",
"(",
"self",
",",
"request",
")",
":",
"if",
"self",
".",
"_state",
"==",
"STATE_DISCONNECTED",
":",
"raise",
"Exception",
"(",
"\"WAMP is currently disconnected!\"",
")",
"wait_queue",
"=",
"queue",
".",
"Queue",
"(",
")",
"req... | Used by most things. Sends out a request then awaits a response
keyed by the request_id | [
"Used",
"by",
"most",
"things",
".",
"Sends",
"out",
"a",
"request",
"then",
"awaits",
"a",
"response",
"keyed",
"by",
"the",
"request_id"
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L353-L366 |
52,438 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClient.dispatch_to_awaiting | def dispatch_to_awaiting(self,result):
""" Send dat ato the appropriate queues
"""
# If we are awaiting to login, then we might also get
# an abort message. Handle that here....
if self._state == STATE_AUTHENTICATING:
# If the authentication message is something unex... | python | def dispatch_to_awaiting(self,result):
""" Send dat ato the appropriate queues
"""
# If we are awaiting to login, then we might also get
# an abort message. Handle that here....
if self._state == STATE_AUTHENTICATING:
# If the authentication message is something unex... | [
"def",
"dispatch_to_awaiting",
"(",
"self",
",",
"result",
")",
":",
"# If we are awaiting to login, then we might also get",
"# an abort message. Handle that here....",
"if",
"self",
".",
"_state",
"==",
"STATE_AUTHENTICATING",
":",
"# If the authentication message is something un... | Send dat ato the appropriate queues | [
"Send",
"dat",
"ato",
"the",
"appropriate",
"queues"
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L368-L389 |
52,439 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClient.handle_abort | def handle_abort(self, reason):
""" We're out?
"""
self._welcome_queue.put(reason)
self.close()
self.disconnect() | python | def handle_abort(self, reason):
""" We're out?
"""
self._welcome_queue.put(reason)
self.close()
self.disconnect() | [
"def",
"handle_abort",
"(",
"self",
",",
"reason",
")",
":",
"self",
".",
"_welcome_queue",
".",
"put",
"(",
"reason",
")",
"self",
".",
"close",
"(",
")",
"self",
".",
"disconnect",
"(",
")"
] | We're out? | [
"We",
"re",
"out?"
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L426-L431 |
52,440 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClient.handle_invocation | def handle_invocation(self, message):
""" Passes the invocation request to the appropriate
callback.
"""
req_id = message.request_id
reg_id = message.registration_id
if reg_id in self._registered_calls:
handler = self._registered_calls[reg_id][REGISTERED_C... | python | def handle_invocation(self, message):
""" Passes the invocation request to the appropriate
callback.
"""
req_id = message.request_id
reg_id = message.registration_id
if reg_id in self._registered_calls:
handler = self._registered_calls[reg_id][REGISTERED_C... | [
"def",
"handle_invocation",
"(",
"self",
",",
"message",
")",
":",
"req_id",
"=",
"message",
".",
"request_id",
"reg_id",
"=",
"message",
".",
"registration_id",
"if",
"reg_id",
"in",
"self",
".",
"_registered_calls",
":",
"handler",
"=",
"self",
".",
"_regi... | Passes the invocation request to the appropriate
callback. | [
"Passes",
"the",
"invocation",
"request",
"to",
"the",
"appropriate",
"callback",
"."
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L433-L450 |
52,441 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClient.handle_event | def handle_event(self, event):
""" Send the event to the subclass or simply reject
"""
subscription_id = event.subscription_id
if subscription_id in self._subscriptions:
# FIXME: [1] should be a constant
handler = self._subscriptions[subscription_id][SUBSCRIPTION_... | python | def handle_event(self, event):
""" Send the event to the subclass or simply reject
"""
subscription_id = event.subscription_id
if subscription_id in self._subscriptions:
# FIXME: [1] should be a constant
handler = self._subscriptions[subscription_id][SUBSCRIPTION_... | [
"def",
"handle_event",
"(",
"self",
",",
"event",
")",
":",
"subscription_id",
"=",
"event",
".",
"subscription_id",
"if",
"subscription_id",
"in",
"self",
".",
"_subscriptions",
":",
"# FIXME: [1] should be a constant",
"handler",
"=",
"self",
".",
"_subscriptions"... | Send the event to the subclass or simply reject | [
"Send",
"the",
"event",
"to",
"the",
"subclass",
"or",
"simply",
"reject"
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L452-L459 |
52,442 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClient.subscribe | def subscribe(self,topic,callback=None,options=None):
""" Subscribe to a uri for events from a publisher
"""
full_topic = self.get_full_uri(topic)
result = self.send_and_await_response(SUBSCRIBE(
options=options or {},
... | python | def subscribe(self,topic,callback=None,options=None):
""" Subscribe to a uri for events from a publisher
"""
full_topic = self.get_full_uri(topic)
result = self.send_and_await_response(SUBSCRIBE(
options=options or {},
... | [
"def",
"subscribe",
"(",
"self",
",",
"topic",
",",
"callback",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"full_topic",
"=",
"self",
".",
"get_full_uri",
"(",
"topic",
")",
"result",
"=",
"self",
".",
"send_and_await_response",
"(",
"SUBSCRIBE",
... | Subscribe to a uri for events from a publisher | [
"Subscribe",
"to",
"a",
"uri",
"for",
"events",
"from",
"a",
"publisher"
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L468-L479 |
52,443 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClient.publish | def publish(self,topic,options=None,args=None,kwargs=None):
""" Publishes a messages to the server
"""
topic = self.get_full_uri(topic)
if options is None:
options = {'acknowledge':True}
if options.get('acknowledge'):
request = PUBLISH(
... | python | def publish(self,topic,options=None,args=None,kwargs=None):
""" Publishes a messages to the server
"""
topic = self.get_full_uri(topic)
if options is None:
options = {'acknowledge':True}
if options.get('acknowledge'):
request = PUBLISH(
... | [
"def",
"publish",
"(",
"self",
",",
"topic",
",",
"options",
"=",
"None",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"topic",
"=",
"self",
".",
"get_full_uri",
"(",
"topic",
")",
"if",
"options",
"is",
"None",
":",
"options",
"... | Publishes a messages to the server | [
"Publishes",
"a",
"messages",
"to",
"the",
"server"
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L481-L504 |
52,444 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClient.disconnect | def disconnect(self):
""" Disconnect from the websocket and pause the process
till we reconnect
"""
logger.debug("Disconnecting")
# Close off the websocket
if self.ws:
try:
if self._state == STATE_CONNECTED:
self.handle... | python | def disconnect(self):
""" Disconnect from the websocket and pause the process
till we reconnect
"""
logger.debug("Disconnecting")
# Close off the websocket
if self.ws:
try:
if self._state == STATE_CONNECTED:
self.handle... | [
"def",
"disconnect",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Disconnecting\"",
")",
"# Close off the websocket",
"if",
"self",
".",
"ws",
":",
"try",
":",
"if",
"self",
".",
"_state",
"==",
"STATE_CONNECTED",
":",
"self",
".",
"handle_leave",
... | Disconnect from the websocket and pause the process
till we reconnect | [
"Disconnect",
"from",
"the",
"websocket",
"and",
"pause",
"the",
"process",
"till",
"we",
"reconnect"
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L506-L546 |
52,445 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClient.shutdown | def shutdown(self):
""" Request the system to shutdown the main loop and shutdown the system
This is a one-way trip! Reconnecting requires a new connection
to be made!
"""
self._request_shutdown = True
for i in range(100):
if self._state == STATE_DISCO... | python | def shutdown(self):
""" Request the system to shutdown the main loop and shutdown the system
This is a one-way trip! Reconnecting requires a new connection
to be made!
"""
self._request_shutdown = True
for i in range(100):
if self._state == STATE_DISCO... | [
"def",
"shutdown",
"(",
"self",
")",
":",
"self",
".",
"_request_shutdown",
"=",
"True",
"for",
"i",
"in",
"range",
"(",
"100",
")",
":",
"if",
"self",
".",
"_state",
"==",
"STATE_DISCONNECTED",
":",
"break",
"time",
".",
"sleep",
"(",
"0.1",
")"
] | Request the system to shutdown the main loop and shutdown the system
This is a one-way trip! Reconnecting requires a new connection
to be made! | [
"Request",
"the",
"system",
"to",
"shutdown",
"the",
"main",
"loop",
"and",
"shutdown",
"the",
"system",
"This",
"is",
"a",
"one",
"-",
"way",
"trip!",
"Reconnecting",
"requires",
"a",
"new",
"connection",
"to",
"be",
"made!"
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L548-L557 |
52,446 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClient.start | def start(self):
""" Initialize websockets, say hello, and start listening for events
"""
self.connect()
if not self.isAlive():
super(WAMPClient,self).start()
self.hello()
return self | python | def start(self):
""" Initialize websockets, say hello, and start listening for events
"""
self.connect()
if not self.isAlive():
super(WAMPClient,self).start()
self.hello()
return self | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"connect",
"(",
")",
"if",
"not",
"self",
".",
"isAlive",
"(",
")",
":",
"super",
"(",
"WAMPClient",
",",
"self",
")",
".",
"start",
"(",
")",
"self",
".",
"hello",
"(",
")",
"return",
"self"
] | Initialize websockets, say hello, and start listening for events | [
"Initialize",
"websockets",
"say",
"hello",
"and",
"start",
"listening",
"for",
"events"
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L559-L566 |
52,447 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClient.run | def run(self):
""" Waits and receives messages from the server. This
function somewhat needs to block so is executed in its
own thread until self._request_shutdown is called.
"""
while not self._request_shutdown:
# Find out if we have any data pending from th... | python | def run(self):
""" Waits and receives messages from the server. This
function somewhat needs to block so is executed in its
own thread until self._request_shutdown is called.
"""
while not self._request_shutdown:
# Find out if we have any data pending from th... | [
"def",
"run",
"(",
"self",
")",
":",
"while",
"not",
"self",
".",
"_request_shutdown",
":",
"# Find out if we have any data pending from the",
"# server",
"try",
":",
"# If we've been asked to stop running the",
"# request loop. We'll just sit and wait",
"# till we get asked to r... | Waits and receives messages from the server. This
function somewhat needs to block so is executed in its
own thread until self._request_shutdown is called. | [
"Waits",
"and",
"receives",
"messages",
"from",
"the",
"server",
".",
"This",
"function",
"somewhat",
"needs",
"to",
"block",
"so",
"is",
"executed",
"in",
"its",
"own",
"thread",
"until",
"self",
".",
"_request_shutdown",
"is",
"called",
"."
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L591-L658 |
52,448 | zabertech/python-swampyer | swampyer/__init__.py | WAMPClientTicket.handle_challenge | def handle_challenge(self,data):
""" Executed when the server requests additional
authentication
"""
# Send challenge response
self.send_message(AUTHENTICATE(
signature = self.password,
extra = {}
)) | python | def handle_challenge(self,data):
""" Executed when the server requests additional
authentication
"""
# Send challenge response
self.send_message(AUTHENTICATE(
signature = self.password,
extra = {}
)) | [
"def",
"handle_challenge",
"(",
"self",
",",
"data",
")",
":",
"# Send challenge response",
"self",
".",
"send_message",
"(",
"AUTHENTICATE",
"(",
"signature",
"=",
"self",
".",
"password",
",",
"extra",
"=",
"{",
"}",
")",
")"
] | Executed when the server requests additional
authentication | [
"Executed",
"when",
"the",
"server",
"requests",
"additional",
"authentication"
] | 31b040e7570455718709a496d6d9faacfb372a00 | https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L692-L700 |
52,449 | brews/erebusfall | erebusfall/core.py | icevol_correction | def icevol_correction(age, proxyvalue, proxytype='d18o', timeunit='ya',
benthic_stack=None):
"""Correct isotopic proxy data for ice-volume contribution
This function uses the LR04 benthic stack [1]_ scaled
such that the LGM-present change is assumed to be 1.0 ‰ in accordance
with... | python | def icevol_correction(age, proxyvalue, proxytype='d18o', timeunit='ya',
benthic_stack=None):
"""Correct isotopic proxy data for ice-volume contribution
This function uses the LR04 benthic stack [1]_ scaled
such that the LGM-present change is assumed to be 1.0 ‰ in accordance
with... | [
"def",
"icevol_correction",
"(",
"age",
",",
"proxyvalue",
",",
"proxytype",
"=",
"'d18o'",
",",
"timeunit",
"=",
"'ya'",
",",
"benthic_stack",
"=",
"None",
")",
":",
"age",
"=",
"np",
".",
"array",
"(",
"age",
")",
"proxyvalue",
"=",
"np",
".",
"array... | Correct isotopic proxy data for ice-volume contribution
This function uses the LR04 benthic stack [1]_ scaled
such that the LGM-present change is assumed to be 1.0 ‰ in accordance
with the pore-water estimate from [2]_. This correction method
is adapted from [3]_.
Parameters
----------
age... | [
"Correct",
"isotopic",
"proxy",
"data",
"for",
"ice",
"-",
"volume",
"contribution"
] | 4b1ae484bf8ba728cc063ebd53f83a3d98bc9194 | https://github.com/brews/erebusfall/blob/4b1ae484bf8ba728cc063ebd53f83a3d98bc9194/erebusfall/core.py#L6-L97 |
52,450 | tundish/turberfield-dialogue | turberfield/dialogue/player.py | rehearse | def rehearse(
folders, references, handler,
repeat=0, roles=1, strict=False,
loop=None
):
"""Cast a set of objects into a sequence of scene scripts. Deliver the performance.
:param folders: A sequence of
:py:class:`turberfield.dialogue.model.SceneScript.Folder` objects.
:param reference... | python | def rehearse(
folders, references, handler,
repeat=0, roles=1, strict=False,
loop=None
):
"""Cast a set of objects into a sequence of scene scripts. Deliver the performance.
:param folders: A sequence of
:py:class:`turberfield.dialogue.model.SceneScript.Folder` objects.
:param reference... | [
"def",
"rehearse",
"(",
"folders",
",",
"references",
",",
"handler",
",",
"repeat",
"=",
"0",
",",
"roles",
"=",
"1",
",",
"strict",
"=",
"False",
",",
"loop",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"folders",
",",
"SceneScript",
".",
"Fold... | Cast a set of objects into a sequence of scene scripts. Deliver the performance.
:param folders: A sequence of
:py:class:`turberfield.dialogue.model.SceneScript.Folder` objects.
:param references: A sequence of Python objects.
:param handler: A callable object. This will be invoked with every event... | [
"Cast",
"a",
"set",
"of",
"objects",
"into",
"a",
"sequence",
"of",
"scene",
"scripts",
".",
"Deliver",
"the",
"performance",
"."
] | e7ccf7c19ae162e2f315ddf2642394e858529b4a | https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/player.py#L45-L95 |
52,451 | MatiasSM/fcb | fcb/processing/filesystem/Compressor.py | _BlockFragmenter.can_add_new_content | def can_add_new_content(self, block, file_info):
"""
new content from file_info can be added into block iff
- file count limit hasn't been reached for the block
- there is enough space to completely fit the info into the block
- OR the info can be split and some info can fit into... | python | def can_add_new_content(self, block, file_info):
"""
new content from file_info can be added into block iff
- file count limit hasn't been reached for the block
- there is enough space to completely fit the info into the block
- OR the info can be split and some info can fit into... | [
"def",
"can_add_new_content",
"(",
"self",
",",
"block",
",",
"file_info",
")",
":",
"return",
"(",
"(",
"self",
".",
"_max_files_per_container",
"==",
"0",
"or",
"self",
".",
"_max_files_per_container",
">",
"len",
"(",
"block",
".",
"content_file_infos",
")"... | new content from file_info can be added into block iff
- file count limit hasn't been reached for the block
- there is enough space to completely fit the info into the block
- OR the info can be split and some info can fit into the block | [
"new",
"content",
"from",
"file_info",
"can",
"be",
"added",
"into",
"block",
"iff",
"-",
"file",
"count",
"limit",
"hasn",
"t",
"been",
"reached",
"for",
"the",
"block",
"-",
"there",
"is",
"enough",
"space",
"to",
"completely",
"fit",
"the",
"info",
"i... | 92a6c535287ea1c1ef986954a5d66e7905fb6221 | https://github.com/MatiasSM/fcb/blob/92a6c535287ea1c1ef986954a5d66e7905fb6221/fcb/processing/filesystem/Compressor.py#L110-L123 |
52,452 | MatiasSM/fcb | fcb/processing/filesystem/Compressor.py | Compressor.do_init | def do_init(self, fs_settings, global_quota):
fs_settings = deepcopy(fs_settings) # because we store some of the info, we need a deep copy
'''
If the same restrictions are applied for many destinations, we use the same job to avoid processing
files twice
'''
for sender_s... | python | def do_init(self, fs_settings, global_quota):
fs_settings = deepcopy(fs_settings) # because we store some of the info, we need a deep copy
'''
If the same restrictions are applied for many destinations, we use the same job to avoid processing
files twice
'''
for sender_s... | [
"def",
"do_init",
"(",
"self",
",",
"fs_settings",
",",
"global_quota",
")",
":",
"fs_settings",
"=",
"deepcopy",
"(",
"fs_settings",
")",
"# because we store some of the info, we need a deep copy",
"for",
"sender_spec",
"in",
"fs_settings",
".",
"sender_specs",
":",
... | If the same restrictions are applied for many destinations, we use the same job to avoid processing
files twice | [
"If",
"the",
"same",
"restrictions",
"are",
"applied",
"for",
"many",
"destinations",
"we",
"use",
"the",
"same",
"job",
"to",
"avoid",
"processing",
"files",
"twice"
] | 92a6c535287ea1c1ef986954a5d66e7905fb6221 | https://github.com/MatiasSM/fcb/blob/92a6c535287ea1c1ef986954a5d66e7905fb6221/fcb/processing/filesystem/Compressor.py#L324-L342 |
52,453 | WalletGuild/desw | desw/server.py | get_last_nonce | def get_last_nonce(app, key, nonce):
"""
Get the last_nonce used by the given key from the SQLAlchemy database.
Update the last_nonce to nonce at the same time.
:param str key: the public key the nonce belongs to
:param int nonce: the last nonce used by this key
"""
uk = ses.query(um.UserKe... | python | def get_last_nonce(app, key, nonce):
"""
Get the last_nonce used by the given key from the SQLAlchemy database.
Update the last_nonce to nonce at the same time.
:param str key: the public key the nonce belongs to
:param int nonce: the last nonce used by this key
"""
uk = ses.query(um.UserKe... | [
"def",
"get_last_nonce",
"(",
"app",
",",
"key",
",",
"nonce",
")",
":",
"uk",
"=",
"ses",
".",
"query",
"(",
"um",
".",
"UserKey",
")",
".",
"filter",
"(",
"um",
".",
"UserKey",
".",
"key",
"==",
"key",
")",
".",
"filter",
"(",
"um",
".",
"Use... | Get the last_nonce used by the given key from the SQLAlchemy database.
Update the last_nonce to nonce at the same time.
:param str key: the public key the nonce belongs to
:param int nonce: the last nonce used by this key | [
"Get",
"the",
"last_nonce",
"used",
"by",
"the",
"given",
"key",
"from",
"the",
"SQLAlchemy",
"database",
".",
"Update",
"the",
"last_nonce",
"to",
"nonce",
"at",
"the",
"same",
"time",
"."
] | f966c612e675961d9dbd8268749e349ba10a47c2 | https://github.com/WalletGuild/desw/blob/f966c612e675961d9dbd8268749e349ba10a47c2/desw/server.py#L27-L48 |
52,454 | WalletGuild/desw | desw/server.py | get_user_by_key | def get_user_by_key(app, key):
"""
An SQLAlchemy User getting function. Get a user by public key.
:param str key: the public key the user belongs to
"""
user = ses.query(um.User).join(um.UserKey).filter(um.UserKey.key==key).first()
return user | python | def get_user_by_key(app, key):
"""
An SQLAlchemy User getting function. Get a user by public key.
:param str key: the public key the user belongs to
"""
user = ses.query(um.User).join(um.UserKey).filter(um.UserKey.key==key).first()
return user | [
"def",
"get_user_by_key",
"(",
"app",
",",
"key",
")",
":",
"user",
"=",
"ses",
".",
"query",
"(",
"um",
".",
"User",
")",
".",
"join",
"(",
"um",
".",
"UserKey",
")",
".",
"filter",
"(",
"um",
".",
"UserKey",
".",
"key",
"==",
"key",
")",
".",... | An SQLAlchemy User getting function. Get a user by public key.
:param str key: the public key the user belongs to | [
"An",
"SQLAlchemy",
"User",
"getting",
"function",
".",
"Get",
"a",
"user",
"by",
"public",
"key",
"."
] | f966c612e675961d9dbd8268749e349ba10a47c2 | https://github.com/WalletGuild/desw/blob/f966c612e675961d9dbd8268749e349ba10a47c2/desw/server.py#L51-L58 |
52,455 | WalletGuild/desw | desw/server.py | get_user | def get_user():
"""
Get your user object.
Users may only get their own info, not others'.
---
responses:
'200':
description: user response
schema:
$ref: '#/definitions/User'
default:
description: unexpected error
schema:
$ref: '#/defin... | python | def get_user():
"""
Get your user object.
Users may only get their own info, not others'.
---
responses:
'200':
description: user response
schema:
$ref: '#/definitions/User'
default:
description: unexpected error
schema:
$ref: '#/defin... | [
"def",
"get_user",
"(",
")",
":",
"userdict",
"=",
"json",
".",
"loads",
"(",
"jsonify2",
"(",
"current_user",
".",
"dbuser",
",",
"'User'",
")",
")",
"return",
"current_app",
".",
"bitjws",
".",
"create_response",
"(",
"userdict",
")"
] | Get your user object.
Users may only get their own info, not others'.
---
responses:
'200':
description: user response
schema:
$ref: '#/definitions/User'
default:
description: unexpected error
schema:
$ref: '#/definitions/errorModel'
descr... | [
"Get",
"your",
"user",
"object",
"."
] | f966c612e675961d9dbd8268749e349ba10a47c2 | https://github.com/WalletGuild/desw/blob/f966c612e675961d9dbd8268749e349ba10a47c2/desw/server.py#L430-L453 |
52,456 | sci-bots/pygtkhelpers | pygtkhelpers/proxy.py | proxy_for | def proxy_for(widget):
"""Create a proxy for a Widget
:param widget: A gtk.Widget to proxy
This will raise a KeyError if there is no proxy type registered for the
widget type.
"""
proxy_type = widget_proxies.get(widget.__class__)
if proxy_type is None:
raise KeyError('There is no p... | python | def proxy_for(widget):
"""Create a proxy for a Widget
:param widget: A gtk.Widget to proxy
This will raise a KeyError if there is no proxy type registered for the
widget type.
"""
proxy_type = widget_proxies.get(widget.__class__)
if proxy_type is None:
raise KeyError('There is no p... | [
"def",
"proxy_for",
"(",
"widget",
")",
":",
"proxy_type",
"=",
"widget_proxies",
".",
"get",
"(",
"widget",
".",
"__class__",
")",
"if",
"proxy_type",
"is",
"None",
":",
"raise",
"KeyError",
"(",
"'There is no proxy type registered for %r'",
"%",
"widget",
")",... | Create a proxy for a Widget
:param widget: A gtk.Widget to proxy
This will raise a KeyError if there is no proxy type registered for the
widget type. | [
"Create",
"a",
"proxy",
"for",
"a",
"Widget"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/proxy.py#L329-L340 |
52,457 | sci-bots/pygtkhelpers | pygtkhelpers/proxy.py | GObjectProxy.update | def update(self, value):
"""Update the widget's value
"""
self.update_internal(value)
self.emit('changed', self.get_widget_value()) | python | def update(self, value):
"""Update the widget's value
"""
self.update_internal(value)
self.emit('changed', self.get_widget_value()) | [
"def",
"update",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"update_internal",
"(",
"value",
")",
"self",
".",
"emit",
"(",
"'changed'",
",",
"self",
".",
"get_widget_value",
"(",
")",
")"
] | Update the widget's value | [
"Update",
"the",
"widget",
"s",
"value"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/proxy.py#L68-L72 |
52,458 | sci-bots/pygtkhelpers | pygtkhelpers/proxy.py | GObjectProxy.update_internal | def update_internal(self, value):
"""Update the widget's value without firing a changed signal
"""
self.block()
self.set_widget_value(value)
self.unblock() | python | def update_internal(self, value):
"""Update the widget's value without firing a changed signal
"""
self.block()
self.set_widget_value(value)
self.unblock() | [
"def",
"update_internal",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"block",
"(",
")",
"self",
".",
"set_widget_value",
"(",
"value",
")",
"self",
".",
"unblock",
"(",
")"
] | Update the widget's value without firing a changed signal | [
"Update",
"the",
"widget",
"s",
"value",
"without",
"firing",
"a",
"changed",
"signal"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/proxy.py#L89-L94 |
52,459 | sci-bots/pygtkhelpers | pygtkhelpers/proxy.py | GObjectProxy.connect_widget | def connect_widget(self):
"""Perform the initial connection of the widget
the default implementation will connect to the widgets signal
based on self.signal_name
"""
if self.signal_name is not None:
# None for read only widgets
sid = self.widget.connect(s... | python | def connect_widget(self):
"""Perform the initial connection of the widget
the default implementation will connect to the widgets signal
based on self.signal_name
"""
if self.signal_name is not None:
# None for read only widgets
sid = self.widget.connect(s... | [
"def",
"connect_widget",
"(",
"self",
")",
":",
"if",
"self",
".",
"signal_name",
"is",
"not",
"None",
":",
"# None for read only widgets",
"sid",
"=",
"self",
".",
"widget",
".",
"connect",
"(",
"self",
".",
"signal_name",
",",
"self",
".",
"widget_changed"... | Perform the initial connection of the widget
the default implementation will connect to the widgets signal
based on self.signal_name | [
"Perform",
"the",
"initial",
"connection",
"of",
"the",
"widget"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/proxy.py#L124-L133 |
52,460 | sci-bots/pygtkhelpers | pygtkhelpers/proxy.py | ProxyGroup.add_proxy_for | def add_proxy_for(self, name, widget):
"""Create a proxy for a widget and add it to this group
:param name: The name or key of the proxy, which will be emitted with
the changed signal
:param widget: The widget to create a proxy for
"""
proxy = proxy_for(widg... | python | def add_proxy_for(self, name, widget):
"""Create a proxy for a widget and add it to this group
:param name: The name or key of the proxy, which will be emitted with
the changed signal
:param widget: The widget to create a proxy for
"""
proxy = proxy_for(widg... | [
"def",
"add_proxy_for",
"(",
"self",
",",
"name",
",",
"widget",
")",
":",
"proxy",
"=",
"proxy_for",
"(",
"widget",
")",
"self",
".",
"add_proxy",
"(",
"name",
",",
"proxy",
")"
] | Create a proxy for a widget and add it to this group
:param name: The name or key of the proxy, which will be emitted with
the changed signal
:param widget: The widget to create a proxy for | [
"Create",
"a",
"proxy",
"for",
"a",
"widget",
"and",
"add",
"it",
"to",
"this",
"group"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/proxy.py#L364-L372 |
52,461 | klmitch/requiem | requiem/decorators.py | _urljoin | def _urljoin(left, right):
"""Join two URLs.
Takes URLs specified by left and right and joins them into a
single URL. If right is an absolute URL, it is returned directly.
This differs from urlparse.urljoin() in that the latter always
chops off the left-most component of left unless it is trailed ... | python | def _urljoin(left, right):
"""Join two URLs.
Takes URLs specified by left and right and joins them into a
single URL. If right is an absolute URL, it is returned directly.
This differs from urlparse.urljoin() in that the latter always
chops off the left-most component of left unless it is trailed ... | [
"def",
"_urljoin",
"(",
"left",
",",
"right",
")",
":",
"# Handle the tricky case of right being a full URL",
"tmp",
"=",
"urlparse",
".",
"urlparse",
"(",
"right",
")",
"if",
"tmp",
".",
"scheme",
"or",
"tmp",
".",
"netloc",
":",
"# Go ahead and use urlparse.urlj... | Join two URLs.
Takes URLs specified by left and right and joins them into a
single URL. If right is an absolute URL, it is returned directly.
This differs from urlparse.urljoin() in that the latter always
chops off the left-most component of left unless it is trailed by
'/', which is not the behav... | [
"Join",
"two",
"URLs",
"."
] | 0b3b5252e1b3487af732a8666b3bdc2e7035fef5 | https://github.com/klmitch/requiem/blob/0b3b5252e1b3487af732a8666b3bdc2e7035fef5/requiem/decorators.py#L150-L176 |
52,462 | klmitch/requiem | requiem/decorators.py | restmethod | def restmethod(method, reluri, *qargs, **headers):
"""Decorate a method to inject an HTTPRequest.
Generates an HTTPRequest using the given HTTP method and relative
URI. If additional positional arguments are present, they are
expected to be strings that name function arguments that should be
inclu... | python | def restmethod(method, reluri, *qargs, **headers):
"""Decorate a method to inject an HTTPRequest.
Generates an HTTPRequest using the given HTTP method and relative
URI. If additional positional arguments are present, they are
expected to be strings that name function arguments that should be
inclu... | [
"def",
"restmethod",
"(",
"method",
",",
"reluri",
",",
"*",
"qargs",
",",
"*",
"*",
"headers",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"... | Decorate a method to inject an HTTPRequest.
Generates an HTTPRequest using the given HTTP method and relative
URI. If additional positional arguments are present, they are
expected to be strings that name function arguments that should be
included as the query parameters of the URL. If additional
... | [
"Decorate",
"a",
"method",
"to",
"inject",
"an",
"HTTPRequest",
"."
] | 0b3b5252e1b3487af732a8666b3bdc2e7035fef5 | https://github.com/klmitch/requiem/blob/0b3b5252e1b3487af732a8666b3bdc2e7035fef5/requiem/decorators.py#L179-L236 |
52,463 | sci-bots/pygtkhelpers | pygtkhelpers/addons.py | apply_addons | def apply_addons(widget, *addon_types, **named_addon_types):
"""Apply some addons to a widget.
:param widget: The widget to apply addons to.
:param addon_types: A list of addon types, which will be instantiated
and applied to the widget with the default name of
... | python | def apply_addons(widget, *addon_types, **named_addon_types):
"""Apply some addons to a widget.
:param widget: The widget to apply addons to.
:param addon_types: A list of addon types, which will be instantiated
and applied to the widget with the default name of
... | [
"def",
"apply_addons",
"(",
"widget",
",",
"*",
"addon_types",
",",
"*",
"*",
"named_addon_types",
")",
":",
"for",
"addon_type",
"in",
"addon_types",
":",
"addon_type",
"(",
"widget",
")",
"for",
"name",
",",
"addon_type",
"in",
"named_addon_types",
".",
"i... | Apply some addons to a widget.
:param widget: The widget to apply addons to.
:param addon_types: A list of addon types, which will be instantiated
and applied to the widget with the default name of
the addon.
:param named_addon_types: A named list of addons... | [
"Apply",
"some",
"addons",
"to",
"a",
"widget",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/addons.py#L17-L38 |
52,464 | dev-pipeline/dev-pipeline-core | lib/devpipeline_core/paths.py | make_path | def make_path(config, *endings):
"""
Create a path based on component configuration.
All paths are relative to the component's configuration directory; usually
this will be the same for an entire session, but this function supuports
component-specific configuration directories.
Arguments:
... | python | def make_path(config, *endings):
"""
Create a path based on component configuration.
All paths are relative to the component's configuration directory; usually
this will be the same for an entire session, but this function supuports
component-specific configuration directories.
Arguments:
... | [
"def",
"make_path",
"(",
"config",
",",
"*",
"endings",
")",
":",
"config_dir",
"=",
"config",
".",
"get",
"(",
"\"dp.config_dir\"",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"config_dir",
",",
"*",
"endings",
")"
] | Create a path based on component configuration.
All paths are relative to the component's configuration directory; usually
this will be the same for an entire session, but this function supuports
component-specific configuration directories.
Arguments:
config - the configuration object for a compo... | [
"Create",
"a",
"path",
"based",
"on",
"component",
"configuration",
"."
] | fa40c050a56202485070b0300bb8695e9388c34f | https://github.com/dev-pipeline/dev-pipeline-core/blob/fa40c050a56202485070b0300bb8695e9388c34f/lib/devpipeline_core/paths.py#L8-L22 |
52,465 | dcaune/perseus-lib-python-common | majormode/perseus/model/contact.py | Contact.from_json | def from_json(payload):
"""
Convert the JSON expression of a contact information into an instance
`Contact.
@param payload: a JSON expression representing a contact information:
[ type:ContactName, value:string, [is_primary:boolean, [is_verified:boolean]] ]
@retu... | python | def from_json(payload):
"""
Convert the JSON expression of a contact information into an instance
`Contact.
@param payload: a JSON expression representing a contact information:
[ type:ContactName, value:string, [is_primary:boolean, [is_verified:boolean]] ]
@retu... | [
"def",
"from_json",
"(",
"payload",
")",
":",
"contact_item_number",
"=",
"len",
"(",
"payload",
")",
"assert",
"2",
"<=",
"contact_item_number",
"<=",
"4",
",",
"'Invalid contact information format'",
"is_primary",
"=",
"is_verified",
"=",
"None",
"# Unpack the con... | Convert the JSON expression of a contact information into an instance
`Contact.
@param payload: a JSON expression representing a contact information:
[ type:ContactName, value:string, [is_primary:boolean, [is_verified:boolean]] ]
@return: an instance `Contact`.
@raise ... | [
"Convert",
"the",
"JSON",
"expression",
"of",
"a",
"contact",
"information",
"into",
"an",
"instance",
"Contact",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/model/contact.py#L153-L188 |
52,466 | dcaune/perseus-lib-python-common | majormode/perseus/model/contact.py | Contact.from_object | def from_object(obj):
"""
Convert an object representing a contact information to an instance
`Contact`.
@param obj: an object containg the following attributes:
* `name`: an item of the enumeration `ContactName` representing the
type of this contact informat... | python | def from_object(obj):
"""
Convert an object representing a contact information to an instance
`Contact`.
@param obj: an object containg the following attributes:
* `name`: an item of the enumeration `ContactName` representing the
type of this contact informat... | [
"def",
"from_object",
"(",
"obj",
")",
":",
"return",
"obj",
"if",
"isinstance",
"(",
"obj",
",",
"Contact",
")",
"else",
"Contact",
"(",
"cast",
".",
"string_to_enum",
"(",
"obj",
".",
"name",
",",
"Contact",
".",
"ContactName",
")",
",",
"obj",
".",
... | Convert an object representing a contact information to an instance
`Contact`.
@param obj: an object containg the following attributes:
* `name`: an item of the enumeration `ContactName` representing the
type of this contact information.
* `value`: value of this... | [
"Convert",
"an",
"object",
"representing",
"a",
"contact",
"information",
"to",
"an",
"instance",
"Contact",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/model/contact.py#L191-L223 |
52,467 | ParthKolekar/django-answerdiff | answerdiff/views.py | QuestionDetails.post | def post(self, request, question_level, question_number, format=None):
"""
Use this Function to submit.
"""
user = User.objects.get(username=request.user.username)
question = Question.objects.filter(question_level=question_level).filter(question_number=question_number)
i... | python | def post(self, request, question_level, question_number, format=None):
"""
Use this Function to submit.
"""
user = User.objects.get(username=request.user.username)
question = Question.objects.filter(question_level=question_level).filter(question_number=question_number)
i... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"question_level",
",",
"question_number",
",",
"format",
"=",
"None",
")",
":",
"user",
"=",
"User",
".",
"objects",
".",
"get",
"(",
"username",
"=",
"request",
".",
"user",
".",
"username",
")",
"quest... | Use this Function to submit. | [
"Use",
"this",
"Function",
"to",
"submit",
"."
] | af4dd31db04431e76384581c3d6c8fbdfba0faf9 | https://github.com/ParthKolekar/django-answerdiff/blob/af4dd31db04431e76384581c3d6c8fbdfba0faf9/answerdiff/views.py#L149-L191 |
52,468 | ParthKolekar/django-answerdiff | answerdiff/views.py | CommentDetails.post | def post(self, request, question_level, question_number, format=None):
"""
Use this Function to submit Comment.
"""
user = User.objects.get(username=request.user.username)
question = Question.objects.filter(question_level=question_level).filter(question_number=question_number)
... | python | def post(self, request, question_level, question_number, format=None):
"""
Use this Function to submit Comment.
"""
user = User.objects.get(username=request.user.username)
question = Question.objects.filter(question_level=question_level).filter(question_number=question_number)
... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"question_level",
",",
"question_number",
",",
"format",
"=",
"None",
")",
":",
"user",
"=",
"User",
".",
"objects",
".",
"get",
"(",
"username",
"=",
"request",
".",
"user",
".",
"username",
")",
"quest... | Use this Function to submit Comment. | [
"Use",
"this",
"Function",
"to",
"submit",
"Comment",
"."
] | af4dd31db04431e76384581c3d6c8fbdfba0faf9 | https://github.com/ParthKolekar/django-answerdiff/blob/af4dd31db04431e76384581c3d6c8fbdfba0faf9/answerdiff/views.py#L214-L248 |
52,469 | dcaune/perseus-lib-python-common | majormode/perseus/utils/key_util.py | calculate_base_sequence | def calculate_base_sequence(base_offsets):
"""
Return a sequence of characters corresponding to the specified base.
Example::
>>> calculate_base_sequence([ ('0', '9'), ('A', 'F') ])
'0123456789ABCDEF'
@param base_offsets: a list of character offsets in the form of tuples
``... | python | def calculate_base_sequence(base_offsets):
"""
Return a sequence of characters corresponding to the specified base.
Example::
>>> calculate_base_sequence([ ('0', '9'), ('A', 'F') ])
'0123456789ABCDEF'
@param base_offsets: a list of character offsets in the form of tuples
``... | [
"def",
"calculate_base_sequence",
"(",
"base_offsets",
")",
":",
"return",
"''",
".",
"join",
"(",
"[",
"chr",
"(",
"c",
")",
"for",
"c",
"in",
"list",
"(",
"itertools",
".",
"chain",
".",
"from_iterable",
"(",
"[",
"range",
"(",
"ord",
"(",
"x",
")"... | Return a sequence of characters corresponding to the specified base.
Example::
>>> calculate_base_sequence([ ('0', '9'), ('A', 'F') ])
'0123456789ABCDEF'
@param base_offsets: a list of character offsets in the form of tuples
``(x, y)`` where ``x`` corresponds to the first character... | [
"Return",
"a",
"sequence",
"of",
"characters",
"corresponding",
"to",
"the",
"specified",
"base",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/key_util.py#L24-L41 |
52,470 | dcaune/perseus-lib-python-common | majormode/perseus/utils/key_util.py | generate_secured_key | def generate_secured_key(value,
key_nonce_separator='.',
nonce_length=4,
base=BASE62):
"""
Generate a secured key composed of the integer value encoded in Base62
and a nonce.
@param value: an integer value.
@param key_nonce_separator: the character that is used to separate ... | python | def generate_secured_key(value,
key_nonce_separator='.',
nonce_length=4,
base=BASE62):
"""
Generate a secured key composed of the integer value encoded in Base62
and a nonce.
@param value: an integer value.
@param key_nonce_separator: the character that is used to separate ... | [
"def",
"generate_secured_key",
"(",
"value",
",",
"key_nonce_separator",
"=",
"'.'",
",",
"nonce_length",
"=",
"4",
",",
"base",
"=",
"BASE62",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"long",
")",
")",
":",
"raise",
"Va... | Generate a secured key composed of the integer value encoded in Base62
and a nonce.
@param value: an integer value.
@param key_nonce_separator: the character that is used to separate the
key and the nonce to form the secured key.
@param nonce_length: the number of characters to compose the no... | [
"Generate",
"a",
"secured",
"key",
"composed",
"of",
"the",
"integer",
"value",
"encoded",
"in",
"Base62",
"and",
"a",
"nonce",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/key_util.py#L47-L78 |
52,471 | dcaune/perseus-lib-python-common | majormode/perseus/utils/key_util.py | int_to_key | def int_to_key(value, base=BASE62):
"""
Convert the specified integer to a key using the given base.
@param value: a positive integer.
@param base: a sequence of characters that is used to encode the
integer value.
@return: a key expressed in the specified base.
"""
def key_seq... | python | def int_to_key(value, base=BASE62):
"""
Convert the specified integer to a key using the given base.
@param value: a positive integer.
@param base: a sequence of characters that is used to encode the
integer value.
@return: a key expressed in the specified base.
"""
def key_seq... | [
"def",
"int_to_key",
"(",
"value",
",",
"base",
"=",
"BASE62",
")",
":",
"def",
"key_sequence_generator",
"(",
"value",
",",
"base",
")",
":",
"\"\"\"\n Generator for producing sequence of characters of a key providing an\n integer value and a base of characters for... | Convert the specified integer to a key using the given base.
@param value: a positive integer.
@param base: a sequence of characters that is used to encode the
integer value.
@return: a key expressed in the specified base. | [
"Convert",
"the",
"specified",
"integer",
"to",
"a",
"key",
"using",
"the",
"given",
"base",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/key_util.py#L81-L112 |
52,472 | dcaune/perseus-lib-python-common | majormode/perseus/utils/key_util.py | key_to_int | def key_to_int(key, base=BASE62):
"""
Convert the following key to an integer.
@param key: a key.
@param base: a sequence of characters that was used to encode the
integer value.
@return: the integer value corresponding to the given key.
@raise ValueError: if one character of the s... | python | def key_to_int(key, base=BASE62):
"""
Convert the following key to an integer.
@param key: a key.
@param base: a sequence of characters that was used to encode the
integer value.
@return: the integer value corresponding to the given key.
@raise ValueError: if one character of the s... | [
"def",
"key_to_int",
"(",
"key",
",",
"base",
"=",
"BASE62",
")",
":",
"base_length",
"=",
"len",
"(",
"base",
")",
"value",
"=",
"0",
"for",
"c",
"in",
"reversed",
"(",
"key",
")",
":",
"value",
"=",
"(",
"value",
"*",
"base_length",
")",
"+",
"... | Convert the following key to an integer.
@param key: a key.
@param base: a sequence of characters that was used to encode the
integer value.
@return: the integer value corresponding to the given key.
@raise ValueError: if one character of the specified key doesn't match
any char... | [
"Convert",
"the",
"following",
"key",
"to",
"an",
"integer",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/key_util.py#L115-L134 |
52,473 | dcaune/perseus-lib-python-common | majormode/perseus/utils/key_util.py | parse_secured_key | def parse_secured_key(secured_key,
key_nonce_separator='.',
nonce_length=4,
base=BASE62):
"""
Parse a given secured key and return its associated integer, the key
itself, and the embedded nonce.
@param secured_key a string representation of a secured key composed
of a... | python | def parse_secured_key(secured_key,
key_nonce_separator='.',
nonce_length=4,
base=BASE62):
"""
Parse a given secured key and return its associated integer, the key
itself, and the embedded nonce.
@param secured_key a string representation of a secured key composed
of a... | [
"def",
"parse_secured_key",
"(",
"secured_key",
",",
"key_nonce_separator",
"=",
"'.'",
",",
"nonce_length",
"=",
"4",
",",
"base",
"=",
"BASE62",
")",
":",
"parts",
"=",
"secured_key",
".",
"split",
"(",
"key_nonce_separator",
")",
"if",
"len",
"(",
"parts"... | Parse a given secured key and return its associated integer, the key
itself, and the embedded nonce.
@param secured_key a string representation of a secured key composed
of a key in Base62, a separator character, and a nonce.
@param key_nonce_separator: the character that is used to separate th... | [
"Parse",
"a",
"given",
"secured",
"key",
"and",
"return",
"its",
"associated",
"integer",
"the",
"key",
"itself",
"and",
"the",
"embedded",
"nonce",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/key_util.py#L137-L173 |
52,474 | alphagov/estools | estools/command/template.py | get | def get(args):
"""
Get a template by name.
"""
m = TemplateManager(args.hosts)
t = m.get(args.name)
if t:
print(json.dumps(t, indent=2))
else:
sys.exit(1) | python | def get(args):
"""
Get a template by name.
"""
m = TemplateManager(args.hosts)
t = m.get(args.name)
if t:
print(json.dumps(t, indent=2))
else:
sys.exit(1) | [
"def",
"get",
"(",
"args",
")",
":",
"m",
"=",
"TemplateManager",
"(",
"args",
".",
"hosts",
")",
"t",
"=",
"m",
".",
"get",
"(",
"args",
".",
"name",
")",
"if",
"t",
":",
"print",
"(",
"json",
".",
"dumps",
"(",
"t",
",",
"indent",
"=",
"2",... | Get a template by name. | [
"Get",
"a",
"template",
"by",
"name",
"."
] | ee016ceb14cd83ee61e338fe0e226998914df97c | https://github.com/alphagov/estools/blob/ee016ceb14cd83ee61e338fe0e226998914df97c/estools/command/template.py#L53-L62 |
52,475 | alphagov/estools | estools/command/template.py | delete | def delete(args):
"""
Delete a template by name
"""
m = TemplateManager(args.hosts)
m.delete(args.name) | python | def delete(args):
"""
Delete a template by name
"""
m = TemplateManager(args.hosts)
m.delete(args.name) | [
"def",
"delete",
"(",
"args",
")",
":",
"m",
"=",
"TemplateManager",
"(",
"args",
".",
"hosts",
")",
"m",
".",
"delete",
"(",
"args",
".",
"name",
")"
] | Delete a template by name | [
"Delete",
"a",
"template",
"by",
"name"
] | ee016ceb14cd83ee61e338fe0e226998914df97c | https://github.com/alphagov/estools/blob/ee016ceb14cd83ee61e338fe0e226998914df97c/estools/command/template.py#L76-L81 |
52,476 | arindampradhan/yaaHN | yaaHN/helpers.py | user_parser | def user_parser(user):
"""
Parses a user object
"""
if __is_deleted(user):
return deleted_parser(user)
if user['id'] in item_types:
raise Exception('Not a user name')
if type(user['id']) == int:
raise Exception('Not a user name')
return User(
user['id'],
... | python | def user_parser(user):
"""
Parses a user object
"""
if __is_deleted(user):
return deleted_parser(user)
if user['id'] in item_types:
raise Exception('Not a user name')
if type(user['id']) == int:
raise Exception('Not a user name')
return User(
user['id'],
... | [
"def",
"user_parser",
"(",
"user",
")",
":",
"if",
"__is_deleted",
"(",
"user",
")",
":",
"return",
"deleted_parser",
"(",
"user",
")",
"if",
"user",
"[",
"'id'",
"]",
"in",
"item_types",
":",
"raise",
"Exception",
"(",
"'Not a user name'",
")",
"if",
"t... | Parses a user object | [
"Parses",
"a",
"user",
"object"
] | 680e9fed49ef6b325ed7ca1b325aaae12290f314 | https://github.com/arindampradhan/yaaHN/blob/680e9fed49ef6b325ed7ca1b325aaae12290f314/yaaHN/helpers.py#L25-L44 |
52,477 | arindampradhan/yaaHN | yaaHN/helpers.py | story_parser | def story_parser(story):
"""
Parses a story object
"""
if __is_deleted(story):
return deleted_parser(story)
if story['type'] != 'story':
return item_parser(story)
return Story(
__check_key('id', story),
__check_key('by', story),
__check_key('kids', story),... | python | def story_parser(story):
"""
Parses a story object
"""
if __is_deleted(story):
return deleted_parser(story)
if story['type'] != 'story':
return item_parser(story)
return Story(
__check_key('id', story),
__check_key('by', story),
__check_key('kids', story),... | [
"def",
"story_parser",
"(",
"story",
")",
":",
"if",
"__is_deleted",
"(",
"story",
")",
":",
"return",
"deleted_parser",
"(",
"story",
")",
"if",
"story",
"[",
"'type'",
"]",
"!=",
"'story'",
":",
"return",
"item_parser",
"(",
"story",
")",
"return",
"St... | Parses a story object | [
"Parses",
"a",
"story",
"object"
] | 680e9fed49ef6b325ed7ca1b325aaae12290f314 | https://github.com/arindampradhan/yaaHN/blob/680e9fed49ef6b325ed7ca1b325aaae12290f314/yaaHN/helpers.py#L48-L65 |
52,478 | arindampradhan/yaaHN | yaaHN/helpers.py | comment_parser | def comment_parser(comment):
"""
Parses a comment object
"""
try:
if comment['type'] != 'comment':
return item_parser(comment)
except KeyError:
return deleted_parser(comment)
return Comment(
comment['id'],
comment['by'],
__check_key('kids', com... | python | def comment_parser(comment):
"""
Parses a comment object
"""
try:
if comment['type'] != 'comment':
return item_parser(comment)
except KeyError:
return deleted_parser(comment)
return Comment(
comment['id'],
comment['by'],
__check_key('kids', com... | [
"def",
"comment_parser",
"(",
"comment",
")",
":",
"try",
":",
"if",
"comment",
"[",
"'type'",
"]",
"!=",
"'comment'",
":",
"return",
"item_parser",
"(",
"comment",
")",
"except",
"KeyError",
":",
"return",
"deleted_parser",
"(",
"comment",
")",
"return",
... | Parses a comment object | [
"Parses",
"a",
"comment",
"object"
] | 680e9fed49ef6b325ed7ca1b325aaae12290f314 | https://github.com/arindampradhan/yaaHN/blob/680e9fed49ef6b325ed7ca1b325aaae12290f314/yaaHN/helpers.py#L70-L87 |
52,479 | arindampradhan/yaaHN | yaaHN/helpers.py | poll_parser | def poll_parser(poll):
"""
Parses a poll object
"""
if __is_deleted(poll):
return deleted_parser(poll)
if poll['type'] not in poll_types:
raise Exception('Not a poll type')
return Poll(
poll['id'],
poll['by'],
__check_key('kids', poll), # poll and pollopt... | python | def poll_parser(poll):
"""
Parses a poll object
"""
if __is_deleted(poll):
return deleted_parser(poll)
if poll['type'] not in poll_types:
raise Exception('Not a poll type')
return Poll(
poll['id'],
poll['by'],
__check_key('kids', poll), # poll and pollopt... | [
"def",
"poll_parser",
"(",
"poll",
")",
":",
"if",
"__is_deleted",
"(",
"poll",
")",
":",
"return",
"deleted_parser",
"(",
"poll",
")",
"if",
"poll",
"[",
"'type'",
"]",
"not",
"in",
"poll_types",
":",
"raise",
"Exception",
"(",
"'Not a poll type'",
")",
... | Parses a poll object | [
"Parses",
"a",
"poll",
"object"
] | 680e9fed49ef6b325ed7ca1b325aaae12290f314 | https://github.com/arindampradhan/yaaHN/blob/680e9fed49ef6b325ed7ca1b325aaae12290f314/yaaHN/helpers.py#L92-L110 |
52,480 | arindampradhan/yaaHN | yaaHN/helpers.py | item_parser | def item_parser(item):
"""
Parses a item object
It gives None for the property not present
Used when some item types do not get parsed easily when using gevent
"""
if __is_deleted(item):
return deleted_parser(item)
return Item(
__check_key('id', item),
__check_key('de... | python | def item_parser(item):
"""
Parses a item object
It gives None for the property not present
Used when some item types do not get parsed easily when using gevent
"""
if __is_deleted(item):
return deleted_parser(item)
return Item(
__check_key('id', item),
__check_key('de... | [
"def",
"item_parser",
"(",
"item",
")",
":",
"if",
"__is_deleted",
"(",
"item",
")",
":",
"return",
"deleted_parser",
"(",
"item",
")",
"return",
"Item",
"(",
"__check_key",
"(",
"'id'",
",",
"item",
")",
",",
"__check_key",
"(",
"'deleted'",
",",
"item"... | Parses a item object
It gives None for the property not present
Used when some item types do not get parsed easily when using gevent | [
"Parses",
"a",
"item",
"object",
"It",
"gives",
"None",
"for",
"the",
"property",
"not",
"present",
"Used",
"when",
"some",
"item",
"types",
"do",
"not",
"get",
"parsed",
"easily",
"when",
"using",
"gevent"
] | 680e9fed49ef6b325ed7ca1b325aaae12290f314 | https://github.com/arindampradhan/yaaHN/blob/680e9fed49ef6b325ed7ca1b325aaae12290f314/yaaHN/helpers.py#L114-L136 |
52,481 | dcaune/perseus-lib-python-common | majormode/perseus/utils/cast.py | json_to_string | def json_to_string(value, null_string_repr='[]', trimable=False):
"""
Return a string representation of the specified JSON object.
@param value: a JSON object.
@param null_string_rep: the string representation of the null
object.
@return: a string representation of the specified JSON obje... | python | def json_to_string(value, null_string_repr='[]', trimable=False):
"""
Return a string representation of the specified JSON object.
@param value: a JSON object.
@param null_string_rep: the string representation of the null
object.
@return: a string representation of the specified JSON obje... | [
"def",
"json_to_string",
"(",
"value",
",",
"null_string_repr",
"=",
"'[]'",
",",
"trimable",
"=",
"False",
")",
":",
"return",
"null_string_repr",
"if",
"is_undefined",
"(",
"value",
")",
"else",
"obj",
".",
"jsonify",
"(",
"value",
",",
"trimable",
"=",
... | Return a string representation of the specified JSON object.
@param value: a JSON object.
@param null_string_rep: the string representation of the null
object.
@return: a string representation of the specified JSON object. | [
"Return",
"a",
"string",
"representation",
"of",
"the",
"specified",
"JSON",
"object",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/cast.py#L125-L137 |
52,482 | dcaune/perseus-lib-python-common | majormode/perseus/utils/cast.py | string_to_boolean | def string_to_boolean(value, strict=False, default_value=False):
"""
Return a boolean with a value represented by the specified string.
@param value: a string representation of a boolean.
@param strict: indicate whether the specified string MUST be of a
valid boolean representation.
@retu... | python | def string_to_boolean(value, strict=False, default_value=False):
"""
Return a boolean with a value represented by the specified string.
@param value: a string representation of a boolean.
@param strict: indicate whether the specified string MUST be of a
valid boolean representation.
@retu... | [
"def",
"string_to_boolean",
"(",
"value",
",",
"strict",
"=",
"False",
",",
"default_value",
"=",
"False",
")",
":",
"if",
"is_undefined",
"(",
"value",
")",
"and",
"default_value",
":",
"return",
"default_value",
"if",
"isinstance",
"(",
"value",
",",
"bool... | Return a boolean with a value represented by the specified string.
@param value: a string representation of a boolean.
@param strict: indicate whether the specified string MUST be of a
valid boolean representation.
@return: the boolean value represented by the string.
@raise ValueError: if t... | [
"Return",
"a",
"boolean",
"with",
"a",
"value",
"represented",
"by",
"the",
"specified",
"string",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/cast.py#L140-L169 |
52,483 | dcaune/perseus-lib-python-common | majormode/perseus/utils/cast.py | string_to_date | def string_to_date(value):
"""
Return a Python date that corresponds to the specified string
representation.
@param value: string representation of a date.
@return: an instance ``datetime.datetime`` represented by the string.
"""
if isinstance(value, datetime.date):
return value
... | python | def string_to_date(value):
"""
Return a Python date that corresponds to the specified string
representation.
@param value: string representation of a date.
@return: an instance ``datetime.datetime`` represented by the string.
"""
if isinstance(value, datetime.date):
return value
... | [
"def",
"string_to_date",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"datetime",
".",
"date",
")",
":",
"return",
"value",
"return",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"value",
")",
".",
"date",
"(",
")"
] | Return a Python date that corresponds to the specified string
representation.
@param value: string representation of a date.
@return: an instance ``datetime.datetime`` represented by the string. | [
"Return",
"a",
"Python",
"date",
"that",
"corresponds",
"to",
"the",
"specified",
"string",
"representation",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/cast.py#L172-L184 |
52,484 | dcaune/perseus-lib-python-common | majormode/perseus/utils/cast.py | string_to_decimal | def string_to_decimal(value, strict=True):
"""
Return a decimal corresponding to the string representation of a
number.
@param value: a string representation of an decimal number.
@param strict: indicate whether the specified string MUST be of a
valid decimal number representation.
@... | python | def string_to_decimal(value, strict=True):
"""
Return a decimal corresponding to the string representation of a
number.
@param value: a string representation of an decimal number.
@param strict: indicate whether the specified string MUST be of a
valid decimal number representation.
@... | [
"def",
"string_to_decimal",
"(",
"value",
",",
"strict",
"=",
"True",
")",
":",
"if",
"is_undefined",
"(",
"value",
")",
":",
"if",
"strict",
":",
"raise",
"ValueError",
"(",
"'The value cannot be null'",
")",
"return",
"None",
"try",
":",
"return",
"float",... | Return a decimal corresponding to the string representation of a
number.
@param value: a string representation of an decimal number.
@param strict: indicate whether the specified string MUST be of a
valid decimal number representation.
@return: the decimal value represented by the string.
... | [
"Return",
"a",
"decimal",
"corresponding",
"to",
"the",
"string",
"representation",
"of",
"a",
"number",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/cast.py#L187-L212 |
52,485 | dcaune/perseus-lib-python-common | majormode/perseus/utils/cast.py | string_to_enum | def string_to_enum(value, enumeration, strict=True, default_value=None):
"""
Return the item of an enumeration that corresponds to the specified
string representation.
@param value: string representation of an item of a Python
enumeration.
@param enumeration: a Python enumeration.
@pa... | python | def string_to_enum(value, enumeration, strict=True, default_value=None):
"""
Return the item of an enumeration that corresponds to the specified
string representation.
@param value: string representation of an item of a Python
enumeration.
@param enumeration: a Python enumeration.
@pa... | [
"def",
"string_to_enum",
"(",
"value",
",",
"enumeration",
",",
"strict",
"=",
"True",
",",
"default_value",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"enumeration",
",",
"Enum",
")",
":",
"raise",
"ValueError",
"(",
"'The specified enumeration is... | Return the item of an enumeration that corresponds to the specified
string representation.
@param value: string representation of an item of a Python
enumeration.
@param enumeration: a Python enumeration.
@param strict: indicate whether the value must correspond to an
item of the spec... | [
"Return",
"the",
"item",
"of",
"an",
"enumeration",
"that",
"corresponds",
"to",
"the",
"specified",
"string",
"representation",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/cast.py#L215-L253 |
52,486 | dcaune/perseus-lib-python-common | majormode/perseus/utils/cast.py | string_to_integer | def string_to_integer(value, strict=False):
"""
Return an integer corresponding to the string representation of a
number.
@param value: a string representation of an integer number.
@param strict: indicate whether the specified string MUST be of a
valid integer number representation.
... | python | def string_to_integer(value, strict=False):
"""
Return an integer corresponding to the string representation of a
number.
@param value: a string representation of an integer number.
@param strict: indicate whether the specified string MUST be of a
valid integer number representation.
... | [
"def",
"string_to_integer",
"(",
"value",
",",
"strict",
"=",
"False",
")",
":",
"if",
"is_undefined",
"(",
"value",
")",
":",
"if",
"strict",
":",
"raise",
"ValueError",
"(",
"'The value cannot be null'",
")",
"return",
"None",
"try",
":",
"return",
"int",
... | Return an integer corresponding to the string representation of a
number.
@param value: a string representation of an integer number.
@param strict: indicate whether the specified string MUST be of a
valid integer number representation.
@return: the integer value represented by the string.
... | [
"Return",
"an",
"integer",
"corresponding",
"to",
"the",
"string",
"representation",
"of",
"a",
"number",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/cast.py#L256-L280 |
52,487 | dcaune/perseus-lib-python-common | majormode/perseus/utils/cast.py | string_to_ipv4 | def string_to_ipv4(value, strict=False):
"""
Return a tuple corresponding to the string representation of an IPv4
address.
An IPv4 address is canonically represented in dot-decimal notation,
which consists of four decimal numbers, each ranging from 0 to 255,
separated by dots, e.g., ``172.16.25... | python | def string_to_ipv4(value, strict=False):
"""
Return a tuple corresponding to the string representation of an IPv4
address.
An IPv4 address is canonically represented in dot-decimal notation,
which consists of four decimal numbers, each ranging from 0 to 255,
separated by dots, e.g., ``172.16.25... | [
"def",
"string_to_ipv4",
"(",
"value",
",",
"strict",
"=",
"False",
")",
":",
"if",
"is_undefined",
"(",
"value",
")",
":",
"if",
"strict",
":",
"raise",
"ValueError",
"(",
"'The value cannot be null'",
")",
"return",
"None",
"if",
"not",
"REGEX_IPV4",
".",
... | Return a tuple corresponding to the string representation of an IPv4
address.
An IPv4 address is canonically represented in dot-decimal notation,
which consists of four decimal numbers, each ranging from 0 to 255,
separated by dots, e.g., ``172.16.254.1``.
@param value: a dotted-decimal notation ... | [
"Return",
"a",
"tuple",
"corresponding",
"to",
"the",
"string",
"representation",
"of",
"an",
"IPv4",
"address",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/cast.py#L283-L316 |
52,488 | dcaune/perseus-lib-python-common | majormode/perseus/utils/cast.py | string_to_time | def string_to_time(value):
"""
Return an instance ``datetime.time`` that corresponds to the specified
string representation.
@param value: a string representation of a time ``HH:MM[:SS]``, where:
* ``HH``: hour (24-hour clock) as a zero-padded decimal number.
* ``MM``: minute as a zer... | python | def string_to_time(value):
"""
Return an instance ``datetime.time`` that corresponds to the specified
string representation.
@param value: a string representation of a time ``HH:MM[:SS]``, where:
* ``HH``: hour (24-hour clock) as a zero-padded decimal number.
* ``MM``: minute as a zer... | [
"def",
"string_to_time",
"(",
"value",
")",
":",
"try",
":",
"return",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"value",
",",
"'%H:%M:%S'",
")",
".",
"time",
"(",
")",
"except",
"ValueError",
":",
"return",
"datetime",
".",
"datetime",
".",
"st... | Return an instance ``datetime.time`` that corresponds to the specified
string representation.
@param value: a string representation of a time ``HH:MM[:SS]``, where:
* ``HH``: hour (24-hour clock) as a zero-padded decimal number.
* ``MM``: minute as a zero-padded decimal number.
* ``S... | [
"Return",
"an",
"instance",
"datetime",
".",
"time",
"that",
"corresponds",
"to",
"the",
"specified",
"string",
"representation",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/cast.py#L435-L456 |
52,489 | dcaune/perseus-lib-python-common | majormode/perseus/utils/cast.py | string_to_timestamp | def string_to_timestamp(value,
second_digits=3,
default_utc_offset=None,
rounding_method=TimestampRoundingMethod.ceiling):
"""
Return the ISO 8601 date time that corresponds to the specified string
representation.
When the required precision is lower than microsecond, the functi... | python | def string_to_timestamp(value,
second_digits=3,
default_utc_offset=None,
rounding_method=TimestampRoundingMethod.ceiling):
"""
Return the ISO 8601 date time that corresponds to the specified string
representation.
When the required precision is lower than microsecond, the functi... | [
"def",
"string_to_timestamp",
"(",
"value",
",",
"second_digits",
"=",
"3",
",",
"default_utc_offset",
"=",
"None",
",",
"rounding_method",
"=",
"TimestampRoundingMethod",
".",
"ceiling",
")",
":",
"if",
"second_digits",
"<",
"0",
"or",
"second_digits",
">",
"6"... | Return the ISO 8601 date time that corresponds to the specified string
representation.
When the required precision is lower than microsecond, the function
rounds the sub-second time to the specified number of digits.
By default, when possible, it returns the smallest value greater than
or equal to... | [
"Return",
"the",
"ISO",
"8601",
"date",
"time",
"that",
"corresponds",
"to",
"the",
"specified",
"string",
"representation",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/cast.py#L459-L538 |
52,490 | the01/paps-settings | app/flaskApp.py | create_app | def create_app(debug=False):
"""
Create the flask app
:param debug: Use debug mode
:type debug: bool
:return: Created app
:rtype: flask.Flask
"""
app = Flask(__name__)
app.secret_key = str(uuid.uuid4())
app.json_encoder = DateTimeEncoder
app.register_blueprint(page)
Bowe... | python | def create_app(debug=False):
"""
Create the flask app
:param debug: Use debug mode
:type debug: bool
:return: Created app
:rtype: flask.Flask
"""
app = Flask(__name__)
app.secret_key = str(uuid.uuid4())
app.json_encoder = DateTimeEncoder
app.register_blueprint(page)
Bowe... | [
"def",
"create_app",
"(",
"debug",
"=",
"False",
")",
":",
"app",
"=",
"Flask",
"(",
"__name__",
")",
"app",
".",
"secret_key",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"app",
".",
"json_encoder",
"=",
"DateTimeEncoder",
"app",
".",
"reg... | Create the flask app
:param debug: Use debug mode
:type debug: bool
:return: Created app
:rtype: flask.Flask | [
"Create",
"the",
"flask",
"app"
] | 48fb65eb0fa7929a0bb381c6dad28d0197b44c83 | https://github.com/the01/paps-settings/blob/48fb65eb0fa7929a0bb381c6dad28d0197b44c83/app/flaskApp.py#L32-L73 |
52,491 | the01/paps-settings | app/flaskApp.py | plugin | def plugin(plugin_key=None):
"""
Serve plugin page
:param plugin_key: Which plugin page to server; if None -> landing page
(default: None)
:type plugin_key: None | unicode
"""
p = None
if plugin_key:
try:
p = db_plugin_instance.plugin_get(plugin_key)
... | python | def plugin(plugin_key=None):
"""
Serve plugin page
:param plugin_key: Which plugin page to server; if None -> landing page
(default: None)
:type plugin_key: None | unicode
"""
p = None
if plugin_key:
try:
p = db_plugin_instance.plugin_get(plugin_key)
... | [
"def",
"plugin",
"(",
"plugin_key",
"=",
"None",
")",
":",
"p",
"=",
"None",
"if",
"plugin_key",
":",
"try",
":",
"p",
"=",
"db_plugin_instance",
".",
"plugin_get",
"(",
"plugin_key",
")",
"except",
"KeyError",
":",
"logger",
".",
"error",
"(",
"u\"Plugi... | Serve plugin page
:param plugin_key: Which plugin page to server; if None -> landing page
(default: None)
:type plugin_key: None | unicode | [
"Serve",
"plugin",
"page"
] | 48fb65eb0fa7929a0bb381c6dad28d0197b44c83 | https://github.com/the01/paps-settings/blob/48fb65eb0fa7929a0bb381c6dad28d0197b44c83/app/flaskApp.py#L88-L103 |
52,492 | XiaochenCui/cxc-gis | cxc_gis/flat_geometry.py | on_segment | def on_segment(point_p, point_q, point_r):
"""
Given three colinear points p, q, r, the function checks if point q
lies on line segment "pr"
:param point_p:
:type point_p: models.Point
:param point_q:
:type point_q: models.Point
:param point_r:
:type point_r: models.Point
:retur... | python | def on_segment(point_p, point_q, point_r):
"""
Given three colinear points p, q, r, the function checks if point q
lies on line segment "pr"
:param point_p:
:type point_p: models.Point
:param point_q:
:type point_q: models.Point
:param point_r:
:type point_r: models.Point
:retur... | [
"def",
"on_segment",
"(",
"point_p",
",",
"point_q",
",",
"point_r",
")",
":",
"if",
"(",
"point_q",
".",
"x",
"<=",
"max",
"(",
"point_p",
".",
"x",
",",
"point_r",
".",
"x",
")",
"and",
"point_q",
".",
"x",
">=",
"min",
"(",
"point_p",
".",
"x"... | Given three colinear points p, q, r, the function checks if point q
lies on line segment "pr"
:param point_p:
:type point_p: models.Point
:param point_q:
:type point_q: models.Point
:param point_r:
:type point_r: models.Point
:return: if point r on line segment "pr"
:rtype: bool | [
"Given",
"three",
"colinear",
"points",
"p",
"q",
"r",
"the",
"function",
"checks",
"if",
"point",
"q",
"lies",
"on",
"line",
"segment",
"pr"
] | 6186e0cbe61f1b037afa39839b6da2e0519c9cf8 | https://github.com/XiaochenCui/cxc-gis/blob/6186e0cbe61f1b037afa39839b6da2e0519c9cf8/cxc_gis/flat_geometry.py#L4-L23 |
52,493 | XiaochenCui/cxc-gis | cxc_gis/flat_geometry.py | is_intersect | def is_intersect(line_a, line_b):
"""
Determine if lina_a intersect with line_b
:param lina_a:
:type lina_a: models.Line
:param lina_b:
:type line_b: models.Line
:return:
:rtype: bool
"""
# Find the four orientations needed for general and special cases
orientation_1 = orien... | python | def is_intersect(line_a, line_b):
"""
Determine if lina_a intersect with line_b
:param lina_a:
:type lina_a: models.Line
:param lina_b:
:type line_b: models.Line
:return:
:rtype: bool
"""
# Find the four orientations needed for general and special cases
orientation_1 = orien... | [
"def",
"is_intersect",
"(",
"line_a",
",",
"line_b",
")",
":",
"# Find the four orientations needed for general and special cases",
"orientation_1",
"=",
"orientation",
"(",
"line_a",
".",
"endpoint_a",
",",
"line_a",
".",
"endpoint_b",
",",
"line_b",
".",
"endpoint_a",... | Determine if lina_a intersect with line_b
:param lina_a:
:type lina_a: models.Line
:param lina_b:
:type line_b: models.Line
:return:
:rtype: bool | [
"Determine",
"if",
"lina_a",
"intersect",
"with",
"line_b"
] | 6186e0cbe61f1b037afa39839b6da2e0519c9cf8 | https://github.com/XiaochenCui/cxc-gis/blob/6186e0cbe61f1b037afa39839b6da2e0519c9cf8/cxc_gis/flat_geometry.py#L50-L89 |
52,494 | XiaochenCui/cxc-gis | cxc_gis/flat_geometry.py | is_inside | def is_inside(point, region):
"""
Detemine if point is in region
:param point:
:type point: models.Point
:param region:
:type region: Region
"""
points = region.vertices
extrame = models.Point(x=1000000, y=point.y)
points = points + [points[0]]
intersect_count = 0
for i... | python | def is_inside(point, region):
"""
Detemine if point is in region
:param point:
:type point: models.Point
:param region:
:type region: Region
"""
points = region.vertices
extrame = models.Point(x=1000000, y=point.y)
points = points + [points[0]]
intersect_count = 0
for i... | [
"def",
"is_inside",
"(",
"point",
",",
"region",
")",
":",
"points",
"=",
"region",
".",
"vertices",
"extrame",
"=",
"models",
".",
"Point",
"(",
"x",
"=",
"1000000",
",",
"y",
"=",
"point",
".",
"y",
")",
"points",
"=",
"points",
"+",
"[",
"points... | Detemine if point is in region
:param point:
:type point: models.Point
:param region:
:type region: Region | [
"Detemine",
"if",
"point",
"is",
"in",
"region"
] | 6186e0cbe61f1b037afa39839b6da2e0519c9cf8 | https://github.com/XiaochenCui/cxc-gis/blob/6186e0cbe61f1b037afa39839b6da2e0519c9cf8/cxc_gis/flat_geometry.py#L92-L110 |
52,495 | RI-imaging/qpsphere | qpsphere/cnvnc.py | analyze | def analyze(qpi, r0, method="edge", model="projection", edgekw={}, imagekw={},
ret_center=False, ret_pha_offset=False, ret_qpi=False):
"""Determine refractive index and radius of a spherical object
Parameters
----------
qpi: qpimage.QPImage
Quantitative phase image data
r0: floa... | python | def analyze(qpi, r0, method="edge", model="projection", edgekw={}, imagekw={},
ret_center=False, ret_pha_offset=False, ret_qpi=False):
"""Determine refractive index and radius of a spherical object
Parameters
----------
qpi: qpimage.QPImage
Quantitative phase image data
r0: floa... | [
"def",
"analyze",
"(",
"qpi",
",",
"r0",
",",
"method",
"=",
"\"edge\"",
",",
"model",
"=",
"\"projection\"",
",",
"edgekw",
"=",
"{",
"}",
",",
"imagekw",
"=",
"{",
"}",
",",
"ret_center",
"=",
"False",
",",
"ret_pha_offset",
"=",
"False",
",",
"ret... | Determine refractive index and radius of a spherical object
Parameters
----------
qpi: qpimage.QPImage
Quantitative phase image data
r0: float
Approximate radius of the sphere [m]
method: str
The method used to determine the refractive index
can either be "edge" (det... | [
"Determine",
"refractive",
"index",
"and",
"radius",
"of",
"a",
"spherical",
"object"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/cnvnc.py#L8-L109 |
52,496 | RI-imaging/qpsphere | qpsphere/cnvnc.py | bg_phase_mask_from_sim | def bg_phase_mask_from_sim(sim, radial_clearance=1.1):
"""Return the background phase mask of a qpsphere simulation
Parameters
----------
sim: qpimage.QPImage
Quantitative phase data simulated with qpsphere;
The simulation keyword arguments "sim center", "sim radius",
and "pixel... | python | def bg_phase_mask_from_sim(sim, radial_clearance=1.1):
"""Return the background phase mask of a qpsphere simulation
Parameters
----------
sim: qpimage.QPImage
Quantitative phase data simulated with qpsphere;
The simulation keyword arguments "sim center", "sim radius",
and "pixel... | [
"def",
"bg_phase_mask_from_sim",
"(",
"sim",
",",
"radial_clearance",
"=",
"1.1",
")",
":",
"# Mask values around the object",
"cx",
",",
"cy",
"=",
"sim",
"[",
"\"sim center\"",
"]",
"radius",
"=",
"sim",
"[",
"\"sim radius\"",
"]",
"px_um",
"=",
"sim",
"[",
... | Return the background phase mask of a qpsphere simulation
Parameters
----------
sim: qpimage.QPImage
Quantitative phase data simulated with qpsphere;
The simulation keyword arguments "sim center", "sim radius",
and "pixel size" must be present in `sim.meta`.
radial_clearance: fl... | [
"Return",
"the",
"background",
"phase",
"mask",
"of",
"a",
"qpsphere",
"simulation"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/cnvnc.py#L112-L142 |
52,497 | RI-imaging/qpsphere | qpsphere/cnvnc.py | bg_phase_mask_for_qpi | def bg_phase_mask_for_qpi(qpi, r0, method="edge", model="projection",
edgekw={}, imagekw={}, radial_clearance=1.1):
"""Determine the background phase mask for a spherical phase object
The position and radius of the phase object are determined with
:func:`analyze`, to which the cor... | python | def bg_phase_mask_for_qpi(qpi, r0, method="edge", model="projection",
edgekw={}, imagekw={}, radial_clearance=1.1):
"""Determine the background phase mask for a spherical phase object
The position and radius of the phase object are determined with
:func:`analyze`, to which the cor... | [
"def",
"bg_phase_mask_for_qpi",
"(",
"qpi",
",",
"r0",
",",
"method",
"=",
"\"edge\"",
",",
"model",
"=",
"\"projection\"",
",",
"edgekw",
"=",
"{",
"}",
",",
"imagekw",
"=",
"{",
"}",
",",
"radial_clearance",
"=",
"1.1",
")",
":",
"# fit sphere",
"_",
... | Determine the background phase mask for a spherical phase object
The position and radius of the phase object are determined with
:func:`analyze`, to which the corresponding keyword arguments
are passed. A binary mask is created from the simulation results
via :func:`bg_phase_mask_from_sim`.
Parame... | [
"Determine",
"the",
"background",
"phase",
"mask",
"for",
"a",
"spherical",
"phase",
"object"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/cnvnc.py#L145-L200 |
52,498 | DemocracyClub/uk-election-ids | uk_election_ids/election_ids.py | IdBuilder.with_subtype | def with_subtype(self, subtype):
"""Add a subtype segment
Args:
subtype (str): May be one of ``['a', 'c', 'r']``. See the
`Reference Definition <https://elections.democracyclub.org.uk/reference_definition>`_.
for valid election type/subtype combinations.
... | python | def with_subtype(self, subtype):
"""Add a subtype segment
Args:
subtype (str): May be one of ``['a', 'c', 'r']``. See the
`Reference Definition <https://elections.democracyclub.org.uk/reference_definition>`_.
for valid election type/subtype combinations.
... | [
"def",
"with_subtype",
"(",
"self",
",",
"subtype",
")",
":",
"self",
".",
"_validate_subtype",
"(",
"subtype",
")",
"self",
".",
"subtype",
"=",
"subtype",
"return",
"self"
] | Add a subtype segment
Args:
subtype (str): May be one of ``['a', 'c', 'r']``. See the
`Reference Definition <https://elections.democracyclub.org.uk/reference_definition>`_.
for valid election type/subtype combinations.
Returns:
IdBuilder
... | [
"Add",
"a",
"subtype",
"segment"
] | 566895e15b539e8a7fa3bebb680d5cd326cf6b6b | https://github.com/DemocracyClub/uk-election-ids/blob/566895e15b539e8a7fa3bebb680d5cd326cf6b6b/uk_election_ids/election_ids.py#L62-L78 |
52,499 | DemocracyClub/uk-election-ids | uk_election_ids/election_ids.py | IdBuilder.with_organisation | def with_organisation(self, organisation):
"""Add an organisation segment.
Args:
organisation (str): Official name of an administrative body
holding an election.
Returns:
IdBuilder
Raises:
ValueError
"""
if organisati... | python | def with_organisation(self, organisation):
"""Add an organisation segment.
Args:
organisation (str): Official name of an administrative body
holding an election.
Returns:
IdBuilder
Raises:
ValueError
"""
if organisati... | [
"def",
"with_organisation",
"(",
"self",
",",
"organisation",
")",
":",
"if",
"organisation",
"is",
"None",
":",
"organisation",
"=",
"''",
"organisation",
"=",
"slugify",
"(",
"organisation",
")",
"self",
".",
"_validate_organisation",
"(",
"organisation",
")",... | Add an organisation segment.
Args:
organisation (str): Official name of an administrative body
holding an election.
Returns:
IdBuilder
Raises:
ValueError | [
"Add",
"an",
"organisation",
"segment",
"."
] | 566895e15b539e8a7fa3bebb680d5cd326cf6b6b | https://github.com/DemocracyClub/uk-election-ids/blob/566895e15b539e8a7fa3bebb680d5cd326cf6b6b/uk_election_ids/election_ids.py#L80-L98 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.