repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
MacHu-GWU/windtalker-project | windtalker/cipher.py | BaseCipher.encrypt_text | def encrypt_text(self, text, *args, **kwargs):
"""
Encrypt a string.
input: unicode str, output: unicode str
"""
b = text.encode("utf-8")
token = self.encrypt(b, *args, **kwargs)
return base64.b64encode(token).decode("utf-8") | python | def encrypt_text(self, text, *args, **kwargs):
"""
Encrypt a string.
input: unicode str, output: unicode str
"""
b = text.encode("utf-8")
token = self.encrypt(b, *args, **kwargs)
return base64.b64encode(token).decode("utf-8") | [
"def",
"encrypt_text",
"(",
"self",
",",
"text",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"b",
"=",
"text",
".",
"encode",
"(",
"\"utf-8\"",
")",
"token",
"=",
"self",
".",
"encrypt",
"(",
"b",
",",
"*",
"args",
",",
"*",
"*",
"kwar... | Encrypt a string.
input: unicode str, output: unicode str | [
"Encrypt",
"a",
"string",
"."
] | train | https://github.com/MacHu-GWU/windtalker-project/blob/1dcff7c3692d5883cf1b55d1ea745723cfc6c3ce/windtalker/cipher.py#L67-L75 |
MacHu-GWU/windtalker-project | windtalker/cipher.py | BaseCipher.decrypt_text | def decrypt_text(self, text, *args, **kwargs):
"""
Decrypt a string.
input: unicode str, output: unicode str
"""
b = text.encode("utf-8")
token = base64.b64decode(b)
return self.decrypt(token, *args, **kwargs).decode("utf-8") | python | def decrypt_text(self, text, *args, **kwargs):
"""
Decrypt a string.
input: unicode str, output: unicode str
"""
b = text.encode("utf-8")
token = base64.b64decode(b)
return self.decrypt(token, *args, **kwargs).decode("utf-8") | [
"def",
"decrypt_text",
"(",
"self",
",",
"text",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"b",
"=",
"text",
".",
"encode",
"(",
"\"utf-8\"",
")",
"token",
"=",
"base64",
".",
"b64decode",
"(",
"b",
")",
"return",
"self",
".",
"decrypt",... | Decrypt a string.
input: unicode str, output: unicode str | [
"Decrypt",
"a",
"string",
"."
] | train | https://github.com/MacHu-GWU/windtalker-project/blob/1dcff7c3692d5883cf1b55d1ea745723cfc6c3ce/windtalker/cipher.py#L77-L85 |
MacHu-GWU/windtalker-project | windtalker/cipher.py | BaseCipher._show | def _show(self, message, indent=0, enable_verbose=True): # pragma: no cover
"""Message printer.
"""
if enable_verbose:
print(" " * indent + message) | python | def _show(self, message, indent=0, enable_verbose=True): # pragma: no cover
"""Message printer.
"""
if enable_verbose:
print(" " * indent + message) | [
"def",
"_show",
"(",
"self",
",",
"message",
",",
"indent",
"=",
"0",
",",
"enable_verbose",
"=",
"True",
")",
":",
"# pragma: no cover",
"if",
"enable_verbose",
":",
"print",
"(",
"\" \"",
"*",
"indent",
"+",
"message",
")"
] | Message printer. | [
"Message",
"printer",
"."
] | train | https://github.com/MacHu-GWU/windtalker-project/blob/1dcff7c3692d5883cf1b55d1ea745723cfc6c3ce/windtalker/cipher.py#L87-L91 |
MacHu-GWU/windtalker-project | windtalker/cipher.py | BaseCipher.encrypt_file | def encrypt_file(self,
path,
output_path=None,
overwrite=False,
stream=True,
enable_verbose=True,
**kwargs):
"""
Encrypt a file. If output_path are not given, then try to use the... | python | def encrypt_file(self,
path,
output_path=None,
overwrite=False,
stream=True,
enable_verbose=True,
**kwargs):
"""
Encrypt a file. If output_path are not given, then try to use the... | [
"def",
"encrypt_file",
"(",
"self",
",",
"path",
",",
"output_path",
"=",
"None",
",",
"overwrite",
"=",
"False",
",",
"stream",
"=",
"True",
",",
"enable_verbose",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"path",
",",
"output_path",
"=",
"files... | Encrypt a file. If output_path are not given, then try to use the
path with a surfix appended. The default automatical file path handling
is defined here :meth:`windtalker.files.get_encrypted_file_path`
:param path: path of the file you need to encrypt
:param output_path: encrypted file... | [
"Encrypt",
"a",
"file",
".",
"If",
"output_path",
"are",
"not",
"given",
"then",
"try",
"to",
"use",
"the",
"path",
"with",
"a",
"surfix",
"appended",
".",
"The",
"default",
"automatical",
"file",
"path",
"handling",
"is",
"defined",
"here",
":",
"meth",
... | train | https://github.com/MacHu-GWU/windtalker-project/blob/1dcff7c3692d5883cf1b55d1ea745723cfc6c3ce/windtalker/cipher.py#L93-L125 |
MacHu-GWU/windtalker-project | windtalker/cipher.py | BaseCipher.decrypt_file | def decrypt_file(self,
path,
output_path=None,
overwrite=False,
stream=True,
enable_verbose=True,
**kwargs):
"""
Decrypt a file. If output_path are not given, then try to use the... | python | def decrypt_file(self,
path,
output_path=None,
overwrite=False,
stream=True,
enable_verbose=True,
**kwargs):
"""
Decrypt a file. If output_path are not given, then try to use the... | [
"def",
"decrypt_file",
"(",
"self",
",",
"path",
",",
"output_path",
"=",
"None",
",",
"overwrite",
"=",
"False",
",",
"stream",
"=",
"True",
",",
"enable_verbose",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"path",
",",
"output_path",
"=",
"files... | Decrypt a file. If output_path are not given, then try to use the
path with a surfix appended. The default automatical file path handling
is defined here :meth:`windtalker.files.recover_path`
:param path: path of the file you need to decrypt
:param output_path: decrypted file output pat... | [
"Decrypt",
"a",
"file",
".",
"If",
"output_path",
"are",
"not",
"given",
"then",
"try",
"to",
"use",
"the",
"path",
"with",
"a",
"surfix",
"appended",
".",
"The",
"default",
"automatical",
"file",
"path",
"handling",
"is",
"defined",
"here",
":",
"meth",
... | train | https://github.com/MacHu-GWU/windtalker-project/blob/1dcff7c3692d5883cf1b55d1ea745723cfc6c3ce/windtalker/cipher.py#L127-L159 |
MacHu-GWU/windtalker-project | windtalker/cipher.py | BaseCipher.encrypt_dir | def encrypt_dir(self,
path,
output_path=None,
overwrite=False,
stream=True,
enable_verbose=True):
"""
Encrypt everything in a directory.
:param path: path of the dir you need to encrypt
:... | python | def encrypt_dir(self,
path,
output_path=None,
overwrite=False,
stream=True,
enable_verbose=True):
"""
Encrypt everything in a directory.
:param path: path of the dir you need to encrypt
:... | [
"def",
"encrypt_dir",
"(",
"self",
",",
"path",
",",
"output_path",
"=",
"None",
",",
"overwrite",
"=",
"False",
",",
"stream",
"=",
"True",
",",
"enable_verbose",
"=",
"True",
")",
":",
"path",
",",
"output_path",
"=",
"files",
".",
"process_dst_overwrite... | Encrypt everything in a directory.
:param path: path of the dir you need to encrypt
:param output_path: encrypted dir output path
:param overwrite: if True, then silently overwrite output file if exists
:param stream: if it is a very big file, stream mode can avoid using
too m... | [
"Encrypt",
"everything",
"in",
"a",
"directory",
"."
] | train | https://github.com/MacHu-GWU/windtalker-project/blob/1dcff7c3692d5883cf1b55d1ea745723cfc6c3ce/windtalker/cipher.py#L161-L198 |
davisd50/sparc.cache | sparc/cache/item.py | schema_map | def schema_map(schema):
"""Return a valid ICachedItemMapper.map for schema"""
mapper = {}
for name in getFieldNames(schema):
mapper[name] = name
return mapper | python | def schema_map(schema):
"""Return a valid ICachedItemMapper.map for schema"""
mapper = {}
for name in getFieldNames(schema):
mapper[name] = name
return mapper | [
"def",
"schema_map",
"(",
"schema",
")",
":",
"mapper",
"=",
"{",
"}",
"for",
"name",
"in",
"getFieldNames",
"(",
"schema",
")",
":",
"mapper",
"[",
"name",
"]",
"=",
"name",
"return",
"mapper"
] | Return a valid ICachedItemMapper.map for schema | [
"Return",
"a",
"valid",
"ICachedItemMapper",
".",
"map",
"for",
"schema"
] | train | https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/item.py#L14-L19 |
edeposit/edeposit.amqp.storage | src/edeposit/amqp/storage/structures/db/db_archive.py | DBArchive.from_comm | def from_comm(cls, pub):
'''
Convert communication namedtuple to this class.
Args:
pub (obj): :class:`.Archive` instance which will be converted.
Returns:
obj: :class:`DBArchive` instance.
'''
filename = None
if pub.b64_data:
... | python | def from_comm(cls, pub):
'''
Convert communication namedtuple to this class.
Args:
pub (obj): :class:`.Archive` instance which will be converted.
Returns:
obj: :class:`DBArchive` instance.
'''
filename = None
if pub.b64_data:
... | [
"def",
"from_comm",
"(",
"cls",
",",
"pub",
")",
":",
"filename",
"=",
"None",
"if",
"pub",
".",
"b64_data",
":",
"filename",
"=",
"cls",
".",
"_save_to_unique_filename",
"(",
"pub",
")",
"return",
"cls",
"(",
"isbn",
"=",
"pub",
".",
"isbn",
",",
"u... | Convert communication namedtuple to this class.
Args:
pub (obj): :class:`.Archive` instance which will be converted.
Returns:
obj: :class:`DBArchive` instance. | [
"Convert",
"communication",
"namedtuple",
"to",
"this",
"class",
"."
] | train | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/structures/db/db_archive.py#L74-L94 |
edeposit/edeposit.amqp.storage | src/edeposit/amqp/storage/structures/db/db_archive.py | DBArchive.to_comm | def to_comm(self, light_request=False):
'''
Convert `self` to :class:`.Archive`.
Returns:
obj: :class:`.Archive` instance.
'''
data = None
if not light_request:
tmp_fn = path_to_zip(self.dir_pointer)
data = read_as_base64(tmp_fn)
... | python | def to_comm(self, light_request=False):
'''
Convert `self` to :class:`.Archive`.
Returns:
obj: :class:`.Archive` instance.
'''
data = None
if not light_request:
tmp_fn = path_to_zip(self.dir_pointer)
data = read_as_base64(tmp_fn)
... | [
"def",
"to_comm",
"(",
"self",
",",
"light_request",
"=",
"False",
")",
":",
"data",
"=",
"None",
"if",
"not",
"light_request",
":",
"tmp_fn",
"=",
"path_to_zip",
"(",
"self",
".",
"dir_pointer",
")",
"data",
"=",
"read_as_base64",
"(",
"tmp_fn",
")",
"o... | Convert `self` to :class:`.Archive`.
Returns:
obj: :class:`.Archive` instance. | [
"Convert",
"self",
"to",
":",
"class",
":",
".",
"Archive",
"."
] | train | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/structures/db/db_archive.py#L113-L133 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/module_docs.py | get_docstring | def get_docstring(filename, verbose=False):
"""
Search for assignment of the DOCUMENTATION variable in the given file.
Parse that from YAML and return the YAML doc or None.
"""
doc = None
try:
# Thank you, Habbie, for this bit of code :-)
M = ast.parse(''.join(open(filename)))
... | python | def get_docstring(filename, verbose=False):
"""
Search for assignment of the DOCUMENTATION variable in the given file.
Parse that from YAML and return the YAML doc or None.
"""
doc = None
try:
# Thank you, Habbie, for this bit of code :-)
M = ast.parse(''.join(open(filename)))
... | [
"def",
"get_docstring",
"(",
"filename",
",",
"verbose",
"=",
"False",
")",
":",
"doc",
"=",
"None",
"try",
":",
"# Thank you, Habbie, for this bit of code :-)",
"M",
"=",
"ast",
".",
"parse",
"(",
"''",
".",
"join",
"(",
"open",
"(",
"filename",
")",
")",... | Search for assignment of the DOCUMENTATION variable in the given file.
Parse that from YAML and return the YAML doc or None. | [
"Search",
"for",
"assignment",
"of",
"the",
"DOCUMENTATION",
"variable",
"in",
"the",
"given",
"file",
".",
"Parse",
"that",
"from",
"YAML",
"and",
"return",
"the",
"YAML",
"doc",
"or",
"None",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/module_docs.py#L31-L50 |
zakdoek/django-simple-resizer | simple_resizer/__init__.py | _normalize_params | def _normalize_params(image, width, height, crop):
"""
Normalize params and calculate aspect.
"""
if width is None and height is None:
raise ValueError("Either width or height must be set. Otherwise "
"resizing is useless.")
if width is None or height is None:
... | python | def _normalize_params(image, width, height, crop):
"""
Normalize params and calculate aspect.
"""
if width is None and height is None:
raise ValueError("Either width or height must be set. Otherwise "
"resizing is useless.")
if width is None or height is None:
... | [
"def",
"_normalize_params",
"(",
"image",
",",
"width",
",",
"height",
",",
"crop",
")",
":",
"if",
"width",
"is",
"None",
"and",
"height",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Either width or height must be set. Otherwise \"",
"\"resizing is useless.\"... | Normalize params and calculate aspect. | [
"Normalize",
"params",
"and",
"calculate",
"aspect",
"."
] | train | https://github.com/zakdoek/django-simple-resizer/blob/5614eb1717948c65d179c3d1567439a8c90a4d44/simple_resizer/__init__.py#L25-L45 |
zakdoek/django-simple-resizer | simple_resizer/__init__.py | _get_resized_name | def _get_resized_name(image, width, height, crop, namespace):
"""
Get the name of the resized file when assumed it exists.
"""
path, name = os.path.split(image.name)
name_part = "%s/%ix%i" % (namespace, width, height)
if crop:
name_part += "_cropped"
return os.path.join(path, name_p... | python | def _get_resized_name(image, width, height, crop, namespace):
"""
Get the name of the resized file when assumed it exists.
"""
path, name = os.path.split(image.name)
name_part = "%s/%ix%i" % (namespace, width, height)
if crop:
name_part += "_cropped"
return os.path.join(path, name_p... | [
"def",
"_get_resized_name",
"(",
"image",
",",
"width",
",",
"height",
",",
"crop",
",",
"namespace",
")",
":",
"path",
",",
"name",
"=",
"os",
".",
"path",
".",
"split",
"(",
"image",
".",
"name",
")",
"name_part",
"=",
"\"%s/%ix%i\"",
"%",
"(",
"na... | Get the name of the resized file when assumed it exists. | [
"Get",
"the",
"name",
"of",
"the",
"resized",
"file",
"when",
"assumed",
"it",
"exists",
"."
] | train | https://github.com/zakdoek/django-simple-resizer/blob/5614eb1717948c65d179c3d1567439a8c90a4d44/simple_resizer/__init__.py#L48-L57 |
zakdoek/django-simple-resizer | simple_resizer/__init__.py | _resize | def _resize(image, width, height, crop):
"""
Resize the image with respect to the aspect ratio
"""
ext = os.path.splitext(image.name)[1].strip(".")
with Image(file=image, format=ext) as b_image:
# Account for orientation
if ORIENTATION_TYPES.index(b_image.orientation) > 4:
... | python | def _resize(image, width, height, crop):
"""
Resize the image with respect to the aspect ratio
"""
ext = os.path.splitext(image.name)[1].strip(".")
with Image(file=image, format=ext) as b_image:
# Account for orientation
if ORIENTATION_TYPES.index(b_image.orientation) > 4:
... | [
"def",
"_resize",
"(",
"image",
",",
"width",
",",
"height",
",",
"crop",
")",
":",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"image",
".",
"name",
")",
"[",
"1",
"]",
".",
"strip",
"(",
"\".\"",
")",
"with",
"Image",
"(",
"file",
"=... | Resize the image with respect to the aspect ratio | [
"Resize",
"the",
"image",
"with",
"respect",
"to",
"the",
"aspect",
"ratio"
] | train | https://github.com/zakdoek/django-simple-resizer/blob/5614eb1717948c65d179c3d1567439a8c90a4d44/simple_resizer/__init__.py#L60-L144 |
zakdoek/django-simple-resizer | simple_resizer/__init__.py | resize | def resize(image, width=None, height=None, crop=False):
"""
Resize an image and return the resized file.
"""
# First normalize params to determine which file to get
width, height, crop = _normalize_params(image, width, height, crop)
try:
# Check the image file state for clean close
... | python | def resize(image, width=None, height=None, crop=False):
"""
Resize an image and return the resized file.
"""
# First normalize params to determine which file to get
width, height, crop = _normalize_params(image, width, height, crop)
try:
# Check the image file state for clean close
... | [
"def",
"resize",
"(",
"image",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
",",
"crop",
"=",
"False",
")",
":",
"# First normalize params to determine which file to get",
"width",
",",
"height",
",",
"crop",
"=",
"_normalize_params",
"(",
"image",
"... | Resize an image and return the resized file. | [
"Resize",
"an",
"image",
"and",
"return",
"the",
"resized",
"file",
"."
] | train | https://github.com/zakdoek/django-simple-resizer/blob/5614eb1717948c65d179c3d1567439a8c90a4d44/simple_resizer/__init__.py#L147-L169 |
zakdoek/django-simple-resizer | simple_resizer/__init__.py | resize_lazy | def resize_lazy(image, width=None, height=None, crop=False, force=False,
namespace="resized", storage=default_storage,
as_url=False):
"""
Returns the name of the resized file. Returns the url if as_url is True
"""
# First normalize params to determine which file to get
... | python | def resize_lazy(image, width=None, height=None, crop=False, force=False,
namespace="resized", storage=default_storage,
as_url=False):
"""
Returns the name of the resized file. Returns the url if as_url is True
"""
# First normalize params to determine which file to get
... | [
"def",
"resize_lazy",
"(",
"image",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
",",
"crop",
"=",
"False",
",",
"force",
"=",
"False",
",",
"namespace",
"=",
"\"resized\"",
",",
"storage",
"=",
"default_storage",
",",
"as_url",
"=",
"False",
... | Returns the name of the resized file. Returns the url if as_url is True | [
"Returns",
"the",
"name",
"of",
"the",
"resized",
"file",
".",
"Returns",
"the",
"url",
"if",
"as_url",
"is",
"True"
] | train | https://github.com/zakdoek/django-simple-resizer/blob/5614eb1717948c65d179c3d1567439a8c90a4d44/simple_resizer/__init__.py#L173-L203 |
zakdoek/django-simple-resizer | simple_resizer/__init__.py | resized | def resized(*args, **kwargs):
"""
Auto file closing resize function
"""
resized_image = None
try:
resized_image = resize(*args, **kwargs)
yield resized_image
finally:
if resized_image is not None:
resized_image.close() | python | def resized(*args, **kwargs):
"""
Auto file closing resize function
"""
resized_image = None
try:
resized_image = resize(*args, **kwargs)
yield resized_image
finally:
if resized_image is not None:
resized_image.close() | [
"def",
"resized",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"resized_image",
"=",
"None",
"try",
":",
"resized_image",
"=",
"resize",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"yield",
"resized_image",
"finally",
":",
"if",
"resized_im... | Auto file closing resize function | [
"Auto",
"file",
"closing",
"resize",
"function"
] | train | https://github.com/zakdoek/django-simple-resizer/blob/5614eb1717948c65d179c3d1567439a8c90a4d44/simple_resizer/__init__.py#L208-L218 |
thespacedoctor/neddy | neddy/conesearch.py | conesearch.get | def get(self):
"""
*get the conesearch object*
**Return:**
- ``conesearch``
.. todo::
- @review: when complete, clean get method
- @review: when complete add logging
"""
self.log.info('starting the ``get`` method')
# SEARCH ... | python | def get(self):
"""
*get the conesearch object*
**Return:**
- ``conesearch``
.. todo::
- @review: when complete, clean get method
- @review: when complete add logging
"""
self.log.info('starting the ``get`` method')
# SEARCH ... | [
"def",
"get",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``get`` method'",
")",
"# SEARCH NED WITH SINGLE CONESEARCHES TO RETURN LIST OF MATCHED NAMES",
"names",
",",
"searchParams",
"=",
"self",
".",
"get_crossmatch_names",
"(",
"listOf... | *get the conesearch object*
**Return:**
- ``conesearch``
.. todo::
- @review: when complete, clean get method
- @review: when complete add logging | [
"*",
"get",
"the",
"conesearch",
"object",
"*"
] | train | https://github.com/thespacedoctor/neddy/blob/f32653b7d6a39a2c46c5845f83b3a29056311e5e/neddy/conesearch.py#L99-L131 |
thespacedoctor/neddy | neddy/conesearch.py | conesearch._get_ned_query_url | def _get_ned_query_url(
self,
raDeg,
decDeg,
arcsec):
"""
*single ned conesearch*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _get_ned_query_url method
... | python | def _get_ned_query_url(
self,
raDeg,
decDeg,
arcsec):
"""
*single ned conesearch*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _get_ned_query_url method
... | [
"def",
"_get_ned_query_url",
"(",
"self",
",",
"raDeg",
",",
"decDeg",
",",
"arcsec",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_get_ned_query_url`` method'",
")",
"radArcMin",
"=",
"float",
"(",
"arcsec",
")",
"/",
"(",
"60.",
")",
... | *single ned conesearch*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _get_ned_query_url method
- @review: when complete add logging | [
"*",
"single",
"ned",
"conesearch",
"*"
] | train | https://github.com/thespacedoctor/neddy/blob/f32653b7d6a39a2c46c5845f83b3a29056311e5e/neddy/conesearch.py#L134-L203 |
thespacedoctor/neddy | neddy/conesearch.py | conesearch.get_crossmatch_names | def get_crossmatch_names(
self,
listOfCoordinates=False,
radiusArcsec=False):
"""
*get corssmatch names*
**Key Arguments:**
- ``listOfCoordinates`` -- list of the coordinates to conesearch
- ``radiusArcsec`` -- the search radius
... | python | def get_crossmatch_names(
self,
listOfCoordinates=False,
radiusArcsec=False):
"""
*get corssmatch names*
**Key Arguments:**
- ``listOfCoordinates`` -- list of the coordinates to conesearch
- ``radiusArcsec`` -- the search radius
... | [
"def",
"get_crossmatch_names",
"(",
"self",
",",
"listOfCoordinates",
"=",
"False",
",",
"radiusArcsec",
"=",
"False",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``get_crossmatch_names`` method'",
")",
"if",
"listOfCoordinates",
"==",
"False",
... | *get corssmatch names*
**Key Arguments:**
- ``listOfCoordinates`` -- list of the coordinates to conesearch
- ``radiusArcsec`` -- the search radius
**Return:**
- None
.. todo::
- @review: when complete, clean get_crossmatch_names method
... | [
"*",
"get",
"corssmatch",
"names",
"*"
] | train | https://github.com/thespacedoctor/neddy/blob/f32653b7d6a39a2c46c5845f83b3a29056311e5e/neddy/conesearch.py#L206-L293 |
thespacedoctor/neddy | neddy/conesearch.py | conesearch._oversized_subqueries | def _oversized_subqueries(
self,
coordinate,
radiusArcsec):
"""
*subdivide oversized query*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _oversized_subqueries method... | python | def _oversized_subqueries(
self,
coordinate,
radiusArcsec):
"""
*subdivide oversized query*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _oversized_subqueries method... | [
"def",
"_oversized_subqueries",
"(",
"self",
",",
"coordinate",
",",
"radiusArcsec",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_oversized_subqueries`` method'",
")",
"import",
"math",
"smallerRadiusArcsec",
"=",
"radiusArcsec",
"/",
"2.",
"pri... | *subdivide oversized query*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _oversized_subqueries method
- @review: when complete add logging | [
"*",
"subdivide",
"oversized",
"query",
"*"
] | train | https://github.com/thespacedoctor/neddy/blob/f32653b7d6a39a2c46c5845f83b3a29056311e5e/neddy/conesearch.py#L296-L347 |
Tinche/django-bower-cache | registry/bowerlib.py | get_package | def get_package(repo_url, pkg_name, timeout=1):
"""Retrieve package information from a Bower registry at repo_url.
Returns a dict of package data."""
url = repo_url + "/packages/" + pkg_name
headers = {'accept': 'application/json'}
resp = requests.get(url, headers=headers, timeout=timeout)
i... | python | def get_package(repo_url, pkg_name, timeout=1):
"""Retrieve package information from a Bower registry at repo_url.
Returns a dict of package data."""
url = repo_url + "/packages/" + pkg_name
headers = {'accept': 'application/json'}
resp = requests.get(url, headers=headers, timeout=timeout)
i... | [
"def",
"get_package",
"(",
"repo_url",
",",
"pkg_name",
",",
"timeout",
"=",
"1",
")",
":",
"url",
"=",
"repo_url",
"+",
"\"/packages/\"",
"+",
"pkg_name",
"headers",
"=",
"{",
"'accept'",
":",
"'application/json'",
"}",
"resp",
"=",
"requests",
".",
"get"... | Retrieve package information from a Bower registry at repo_url.
Returns a dict of package data. | [
"Retrieve",
"package",
"information",
"from",
"a",
"Bower",
"registry",
"at",
"repo_url",
"."
] | train | https://github.com/Tinche/django-bower-cache/blob/5245b2ee80c33c09d85ce0bf8f047825d9df2118/registry/bowerlib.py#L5-L14 |
jtpaasch/simplygithub | simplygithub/internals/commits.py | prepare | def prepare(data):
"""Restructure/prepare data about commits for output."""
message = data.get("message")
sha = data.get("sha")
tree = data.get("tree")
tree_sha = tree.get("sha")
return {"message": message, "sha": sha, "tree": {"sha": tree_sha}} | python | def prepare(data):
"""Restructure/prepare data about commits for output."""
message = data.get("message")
sha = data.get("sha")
tree = data.get("tree")
tree_sha = tree.get("sha")
return {"message": message, "sha": sha, "tree": {"sha": tree_sha}} | [
"def",
"prepare",
"(",
"data",
")",
":",
"message",
"=",
"data",
".",
"get",
"(",
"\"message\"",
")",
"sha",
"=",
"data",
".",
"get",
"(",
"\"sha\"",
")",
"tree",
"=",
"data",
".",
"get",
"(",
"\"tree\"",
")",
"tree_sha",
"=",
"tree",
".",
"get",
... | Restructure/prepare data about commits for output. | [
"Restructure",
"/",
"prepare",
"data",
"about",
"commits",
"for",
"output",
"."
] | train | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/commits.py#L8-L14 |
jtpaasch/simplygithub | simplygithub/internals/commits.py | get_commit | def get_commit(profile, sha):
"""Fetch a commit.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
sha
The SHA o... | python | def get_commit(profile, sha):
"""Fetch a commit.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
sha
The SHA o... | [
"def",
"get_commit",
"(",
"profile",
",",
"sha",
")",
":",
"resource",
"=",
"\"/commits/\"",
"+",
"sha",
"data",
"=",
"api",
".",
"get_request",
"(",
"profile",
",",
"resource",
")",
"return",
"prepare",
"(",
"data",
")"
] | Fetch a commit.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
sha
The SHA of the commit to fetch.
Returns:
... | [
"Fetch",
"a",
"commit",
"."
] | train | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/commits.py#L17-L36 |
jtpaasch/simplygithub | simplygithub/internals/commits.py | create_commit | def create_commit(profile, message, tree, parents):
"""Create a commit.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
me... | python | def create_commit(profile, message, tree, parents):
"""Create a commit.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
me... | [
"def",
"create_commit",
"(",
"profile",
",",
"message",
",",
"tree",
",",
"parents",
")",
":",
"resource",
"=",
"\"/commits\"",
"payload",
"=",
"{",
"\"message\"",
":",
"message",
",",
"\"tree\"",
":",
"tree",
",",
"\"parents\"",
":",
"parents",
"}",
"data... | Create a commit.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
message
The commit message to give to the commit.... | [
"Create",
"a",
"commit",
"."
] | train | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/commits.py#L39-L65 |
praekelt/unicore-gitmodels | unicore_gitmodels/models.py | SlugifyMixin.slugify | def slugify(self, value):
"""
Normalizes string, converts to lowercase, removes non-alpha characters,
and converts spaces to hyphens.
"""
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
value = unicode(re.sub('[^\w\s-]', '', value).strip().lower())
... | python | def slugify(self, value):
"""
Normalizes string, converts to lowercase, removes non-alpha characters,
and converts spaces to hyphens.
"""
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
value = unicode(re.sub('[^\w\s-]', '', value).strip().lower())
... | [
"def",
"slugify",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"unicodedata",
".",
"normalize",
"(",
"'NFKD'",
",",
"value",
")",
".",
"encode",
"(",
"'ascii'",
",",
"'ignore'",
")",
"value",
"=",
"unicode",
"(",
"re",
".",
"sub",
"(",
"'[^\\w\... | Normalizes string, converts to lowercase, removes non-alpha characters,
and converts spaces to hyphens. | [
"Normalizes",
"string",
"converts",
"to",
"lowercase",
"removes",
"non",
"-",
"alpha",
"characters",
"and",
"converts",
"spaces",
"to",
"hyphens",
"."
] | train | https://github.com/praekelt/unicore-gitmodels/blob/bdfb673b99e9ec3ca0d0dcb55ba061c2deb247d5/unicore_gitmodels/models.py#L25-L32 |
edeposit/edeposit.amqp.storage | src/edeposit/amqp/storage/structures/comm/tree.py | Tree.collect_publications | def collect_publications(self):
"""
Recursively collect list of all publications referenced in this
tree and all sub-trees.
Returns:
list: List of UUID strings.
"""
pubs = list(self.sub_publications)
for sub_tree in self.sub_trees:
pubs.e... | python | def collect_publications(self):
"""
Recursively collect list of all publications referenced in this
tree and all sub-trees.
Returns:
list: List of UUID strings.
"""
pubs = list(self.sub_publications)
for sub_tree in self.sub_trees:
pubs.e... | [
"def",
"collect_publications",
"(",
"self",
")",
":",
"pubs",
"=",
"list",
"(",
"self",
".",
"sub_publications",
")",
"for",
"sub_tree",
"in",
"self",
".",
"sub_trees",
":",
"pubs",
".",
"extend",
"(",
"sub_tree",
".",
"collect_publications",
"(",
")",
")"... | Recursively collect list of all publications referenced in this
tree and all sub-trees.
Returns:
list: List of UUID strings. | [
"Recursively",
"collect",
"list",
"of",
"all",
"publications",
"referenced",
"in",
"this",
"tree",
"and",
"all",
"sub",
"-",
"trees",
"."
] | train | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/structures/comm/tree.py#L113-L126 |
lehins/python-wepay | wepay/api.py | WePay.call | def call(self, uri, params=None, access_token=None, api_version=None, timeout=None):
"""Calls wepay.com/v2/``uri`` with ``params`` and returns the JSON
response as a python `dict`. The optional ``access_token`` parameter
takes precedence over instance's ``access_token`` if it is
set. Ess... | python | def call(self, uri, params=None, access_token=None, api_version=None, timeout=None):
"""Calls wepay.com/v2/``uri`` with ``params`` and returns the JSON
response as a python `dict`. The optional ``access_token`` parameter
takes precedence over instance's ``access_token`` if it is
set. Ess... | [
"def",
"call",
"(",
"self",
",",
"uri",
",",
"params",
"=",
"None",
",",
"access_token",
"=",
"None",
",",
"api_version",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"api_endpoint",
"+",
"uri",
"params",
"=",
"params"... | Calls wepay.com/v2/``uri`` with ``params`` and returns the JSON
response as a python `dict`. The optional ``access_token`` parameter
takes precedence over instance's ``access_token`` if it is
set. Essentially this is the place for all api calls.
:param str uri: API uri to call
:... | [
"Calls",
"wepay",
".",
"com",
"/",
"v2",
"/",
"uri",
"with",
"params",
"and",
"returns",
"the",
"JSON",
"response",
"as",
"a",
"python",
"dict",
".",
"The",
"optional",
"access_token",
"parameter",
"takes",
"precedence",
"over",
"instance",
"s",
"access_toke... | train | https://github.com/lehins/python-wepay/blob/414d25a1a8d0ecb22a3ddd1f16c60b805bb52a1f/wepay/api.py#L161-L194 |
opinkerfi/nago | nago/settings/__init__.py | get_option | def get_option(option_name, section_name="main", default=_sentinel, cfg_file=cfg_file):
""" Returns a specific option specific in a config file
Arguments:
option_name -- Name of the option (example host_name)
section_name -- Which section of the config (default: name)
examples:
>>> ge... | python | def get_option(option_name, section_name="main", default=_sentinel, cfg_file=cfg_file):
""" Returns a specific option specific in a config file
Arguments:
option_name -- Name of the option (example host_name)
section_name -- Which section of the config (default: name)
examples:
>>> ge... | [
"def",
"get_option",
"(",
"option_name",
",",
"section_name",
"=",
"\"main\"",
",",
"default",
"=",
"_sentinel",
",",
"cfg_file",
"=",
"cfg_file",
")",
":",
"defaults",
"=",
"get_defaults",
"(",
")",
"# As a quality issue, we strictly disallow looking up an option that ... | Returns a specific option specific in a config file
Arguments:
option_name -- Name of the option (example host_name)
section_name -- Which section of the config (default: name)
examples:
>>> get_option("some option", default="default result")
'default result' | [
"Returns",
"a",
"specific",
"option",
"specific",
"in",
"a",
"config",
"file"
] | train | https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/settings/__init__.py#L17-L44 |
opinkerfi/nago | nago/settings/__init__.py | get_parser | def get_parser(cfg_file=cfg_file):
""" Returns a ConfigParser.ConfigParser() object for our cfg_file """
if not os.path.exists(cfg_file):
generate_configfile(cfg_file=cfg_file, defaults=defaults)
config = ConfigParser.ConfigParser()
config.read(cfg_file)
return config | python | def get_parser(cfg_file=cfg_file):
""" Returns a ConfigParser.ConfigParser() object for our cfg_file """
if not os.path.exists(cfg_file):
generate_configfile(cfg_file=cfg_file, defaults=defaults)
config = ConfigParser.ConfigParser()
config.read(cfg_file)
return config | [
"def",
"get_parser",
"(",
"cfg_file",
"=",
"cfg_file",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"cfg_file",
")",
":",
"generate_configfile",
"(",
"cfg_file",
"=",
"cfg_file",
",",
"defaults",
"=",
"defaults",
")",
"config",
"=",
"Con... | Returns a ConfigParser.ConfigParser() object for our cfg_file | [
"Returns",
"a",
"ConfigParser",
".",
"ConfigParser",
"()",
"object",
"for",
"our",
"cfg_file"
] | train | https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/settings/__init__.py#L52-L58 |
opinkerfi/nago | nago/settings/__init__.py | set_option | def set_option(section='main', cfg_file=cfg_file, **kwargs):
""" Change an option in our configuration file """
parser = get_parser(cfg_file=cfg_file)
if section not in parser.sections():
parser.add_section(section)
for k, v in kwargs.items():
parser.set(section=section, option=k, value... | python | def set_option(section='main', cfg_file=cfg_file, **kwargs):
""" Change an option in our configuration file """
parser = get_parser(cfg_file=cfg_file)
if section not in parser.sections():
parser.add_section(section)
for k, v in kwargs.items():
parser.set(section=section, option=k, value... | [
"def",
"set_option",
"(",
"section",
"=",
"'main'",
",",
"cfg_file",
"=",
"cfg_file",
",",
"*",
"*",
"kwargs",
")",
":",
"parser",
"=",
"get_parser",
"(",
"cfg_file",
"=",
"cfg_file",
")",
"if",
"section",
"not",
"in",
"parser",
".",
"sections",
"(",
"... | Change an option in our configuration file | [
"Change",
"an",
"option",
"in",
"our",
"configuration",
"file"
] | train | https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/settings/__init__.py#L61-L72 |
opinkerfi/nago | nago/settings/__init__.py | get_section | def get_section(section_name, cfg_file=cfg_file):
""" Returns a dictionary of an entire section """
parser = get_parser(cfg_file=cfg_file)
options = parser.options(section_name)
result = {}
for option in options:
result[option] = parser.get(section=section_name, option=option)
return res... | python | def get_section(section_name, cfg_file=cfg_file):
""" Returns a dictionary of an entire section """
parser = get_parser(cfg_file=cfg_file)
options = parser.options(section_name)
result = {}
for option in options:
result[option] = parser.get(section=section_name, option=option)
return res... | [
"def",
"get_section",
"(",
"section_name",
",",
"cfg_file",
"=",
"cfg_file",
")",
":",
"parser",
"=",
"get_parser",
"(",
"cfg_file",
"=",
"cfg_file",
")",
"options",
"=",
"parser",
".",
"options",
"(",
"section_name",
")",
"result",
"=",
"{",
"}",
"for",
... | Returns a dictionary of an entire section | [
"Returns",
"a",
"dictionary",
"of",
"an",
"entire",
"section"
] | train | https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/settings/__init__.py#L75-L82 |
opinkerfi/nago | nago/settings/__init__.py | _mkdir_for_config | def _mkdir_for_config(cfg_file=cfg_file):
""" Given a path to a filename, make sure the directory exists """
dirname, filename = os.path.split(cfg_file)
try:
os.makedirs(dirname)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(dirname):
pass
else... | python | def _mkdir_for_config(cfg_file=cfg_file):
""" Given a path to a filename, make sure the directory exists """
dirname, filename = os.path.split(cfg_file)
try:
os.makedirs(dirname)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(dirname):
pass
else... | [
"def",
"_mkdir_for_config",
"(",
"cfg_file",
"=",
"cfg_file",
")",
":",
"dirname",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"cfg_file",
")",
"try",
":",
"os",
".",
"makedirs",
"(",
"dirname",
")",
"except",
"OSError",
"as",
"exc",
":... | Given a path to a filename, make sure the directory exists | [
"Given",
"a",
"path",
"to",
"a",
"filename",
"make",
"sure",
"the",
"directory",
"exists"
] | train | https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/settings/__init__.py#L84-L93 |
opinkerfi/nago | nago/settings/__init__.py | generate_configfile | def generate_configfile(cfg_file,defaults=defaults):
""" Write a new nago.ini config file from the defaults.
Arguments:
cfg_file -- File that is written to like /etc/nago/nago.ini
defaults -- Dictionary with default values to use
"""
# Create a directory if needed and write an empty f... | python | def generate_configfile(cfg_file,defaults=defaults):
""" Write a new nago.ini config file from the defaults.
Arguments:
cfg_file -- File that is written to like /etc/nago/nago.ini
defaults -- Dictionary with default values to use
"""
# Create a directory if needed and write an empty f... | [
"def",
"generate_configfile",
"(",
"cfg_file",
",",
"defaults",
"=",
"defaults",
")",
":",
"# Create a directory if needed and write an empty file",
"_mkdir_for_config",
"(",
"cfg_file",
"=",
"cfg_file",
")",
"with",
"open",
"(",
"cfg_file",
",",
"'w'",
")",
"as",
"... | Write a new nago.ini config file from the defaults.
Arguments:
cfg_file -- File that is written to like /etc/nago/nago.ini
defaults -- Dictionary with default values to use | [
"Write",
"a",
"new",
"nago",
".",
"ini",
"config",
"file",
"from",
"the",
"defaults",
"."
] | train | https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/settings/__init__.py#L96-L108 |
roaet/wafflehaus.neutron | wafflehaus/neutron/ip_policy/create_default.py | filter_factory | def filter_factory(global_conf, **local_conf):
"""Returns a WSGI filter app for use with paste.deploy."""
conf = global_conf.copy()
conf.update(local_conf)
def block_resource(app):
return DefaultIPPolicy(app, conf)
return block_resource | python | def filter_factory(global_conf, **local_conf):
"""Returns a WSGI filter app for use with paste.deploy."""
conf = global_conf.copy()
conf.update(local_conf)
def block_resource(app):
return DefaultIPPolicy(app, conf)
return block_resource | [
"def",
"filter_factory",
"(",
"global_conf",
",",
"*",
"*",
"local_conf",
")",
":",
"conf",
"=",
"global_conf",
".",
"copy",
"(",
")",
"conf",
".",
"update",
"(",
"local_conf",
")",
"def",
"block_resource",
"(",
"app",
")",
":",
"return",
"DefaultIPPolicy"... | Returns a WSGI filter app for use with paste.deploy. | [
"Returns",
"a",
"WSGI",
"filter",
"app",
"for",
"use",
"with",
"paste",
".",
"deploy",
"."
] | train | https://github.com/roaet/wafflehaus.neutron/blob/01f6d69ae759ec2f24f2f7cf9dcfa4a4734f7e1c/wafflehaus/neutron/ip_policy/create_default.py#L170-L177 |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/utilities.py | strip_commands | def strip_commands(commands):
""" Strips a sequence of commands.
Strips down the sequence of commands by removing comments and
surrounding whitespace around each individual command and then
removing blank commands.
Parameters
----------
commands : iterable of strings
Iterable of co... | python | def strip_commands(commands):
""" Strips a sequence of commands.
Strips down the sequence of commands by removing comments and
surrounding whitespace around each individual command and then
removing blank commands.
Parameters
----------
commands : iterable of strings
Iterable of co... | [
"def",
"strip_commands",
"(",
"commands",
")",
":",
"# Go through each command one by one, stripping it and adding it to",
"# a growing list if it is not blank. Each command needs to be",
"# converted to an str if it is a bytes.",
"stripped_commands",
"=",
"[",
"]",
"for",
"v",
"in",
... | Strips a sequence of commands.
Strips down the sequence of commands by removing comments and
surrounding whitespace around each individual command and then
removing blank commands.
Parameters
----------
commands : iterable of strings
Iterable of commands to strip.
Returns
----... | [
"Strips",
"a",
"sequence",
"of",
"commands",
"."
] | train | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/utilities.py#L22-L50 |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/utilities.py | UnitConverter.to_motor_distance | def to_motor_distance(self, distance):
""" Convert distance/s to motor units.
Converts distance/s to units of motor encoder counts, which is
what the drive requires when given move instructions.
Parameters
----------
distance : int, float, or iterable of ints and floats... | python | def to_motor_distance(self, distance):
""" Convert distance/s to motor units.
Converts distance/s to units of motor encoder counts, which is
what the drive requires when given move instructions.
Parameters
----------
distance : int, float, or iterable of ints and floats... | [
"def",
"to_motor_distance",
"(",
"self",
",",
"distance",
")",
":",
"if",
"isinstance",
"(",
"distance",
",",
"collections",
".",
"Iterable",
")",
":",
"return",
"[",
"(",
"x",
"*",
"self",
".",
"_distance_to_motor",
")",
"for",
"x",
"in",
"distance",
"]... | Convert distance/s to motor units.
Converts distance/s to units of motor encoder counts, which is
what the drive requires when given move instructions.
Parameters
----------
distance : int, float, or iterable of ints and floats
The distance/s to convert.
Re... | [
"Convert",
"distance",
"/",
"s",
"to",
"motor",
"units",
"."
] | train | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/utilities.py#L79-L99 |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/utilities.py | UnitConverter.to_motor_velocity_acceleration | def to_motor_velocity_acceleration(self, va):
""" Convert velocities/accelerations to motor units.
Converts velocity/ies and/or acceleration/s to units of motor
pitch per second (or second squared), which is what the drive
requires when given move instructions.
Parameters
... | python | def to_motor_velocity_acceleration(self, va):
""" Convert velocities/accelerations to motor units.
Converts velocity/ies and/or acceleration/s to units of motor
pitch per second (or second squared), which is what the drive
requires when given move instructions.
Parameters
... | [
"def",
"to_motor_velocity_acceleration",
"(",
"self",
",",
"va",
")",
":",
"if",
"isinstance",
"(",
"va",
",",
"collections",
".",
"Iterable",
")",
":",
"return",
"[",
"(",
"x",
"*",
"self",
".",
"_va_to_motor",
")",
"for",
"x",
"in",
"va",
"]",
"else"... | Convert velocities/accelerations to motor units.
Converts velocity/ies and/or acceleration/s to units of motor
pitch per second (or second squared), which is what the drive
requires when given move instructions.
Parameters
----------
va : int, float, or iterable of ints... | [
"Convert",
"velocities",
"/",
"accelerations",
"to",
"motor",
"units",
"."
] | train | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/utilities.py#L101-L122 |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/utilities.py | UnitConverter.to_unit_distance | def to_unit_distance(self, distance):
""" Convert distance/s to units of UnitConverter.
Converts distance/s from motor encoder counts to that of this
UnitConverter.
Parameters
----------
distance : int, float, or iterable of ints and floats
The distance/s to... | python | def to_unit_distance(self, distance):
""" Convert distance/s to units of UnitConverter.
Converts distance/s from motor encoder counts to that of this
UnitConverter.
Parameters
----------
distance : int, float, or iterable of ints and floats
The distance/s to... | [
"def",
"to_unit_distance",
"(",
"self",
",",
"distance",
")",
":",
"if",
"isinstance",
"(",
"distance",
",",
"collections",
".",
"Iterable",
")",
":",
"return",
"[",
"(",
"x",
"/",
"self",
".",
"_distance_to_motor",
")",
"for",
"x",
"in",
"distance",
"]"... | Convert distance/s to units of UnitConverter.
Converts distance/s from motor encoder counts to that of this
UnitConverter.
Parameters
----------
distance : int, float, or iterable of ints and floats
The distance/s to convert.
Returns
-------
... | [
"Convert",
"distance",
"/",
"s",
"to",
"units",
"of",
"UnitConverter",
"."
] | train | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/utilities.py#L124-L144 |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/utilities.py | UnitConverter.to_unit_velocity_acceleration | def to_unit_velocity_acceleration(self, va):
""" Convert velocities/accelerations to units of UnitConverter.
Converts velocity/ies and/or acceleration/s from units of motor
pitch per second (or second squared) to that of this
UnitConverter.
Parameters
----------
... | python | def to_unit_velocity_acceleration(self, va):
""" Convert velocities/accelerations to units of UnitConverter.
Converts velocity/ies and/or acceleration/s from units of motor
pitch per second (or second squared) to that of this
UnitConverter.
Parameters
----------
... | [
"def",
"to_unit_velocity_acceleration",
"(",
"self",
",",
"va",
")",
":",
"if",
"isinstance",
"(",
"va",
",",
"collections",
".",
"Iterable",
")",
":",
"return",
"[",
"(",
"x",
"/",
"self",
".",
"_va_to_motor",
")",
"for",
"x",
"in",
"va",
"]",
"else",... | Convert velocities/accelerations to units of UnitConverter.
Converts velocity/ies and/or acceleration/s from units of motor
pitch per second (or second squared) to that of this
UnitConverter.
Parameters
----------
va : int, float, or iterable of ints and floats
... | [
"Convert",
"velocities",
"/",
"accelerations",
"to",
"units",
"of",
"UnitConverter",
"."
] | train | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/utilities.py#L146-L167 |
OpenVolunteeringPlatform/django-ovp-core | ovp_core/views.py | startup | def startup(request):
""" This view provides initial data to the client, such as available skills and causes """
with translation.override(translation.get_language_from_request(request)):
skills = serializers.SkillSerializer(models.Skill.objects.all(), many=True)
causes = serializers.CauseSerializer(models.... | python | def startup(request):
""" This view provides initial data to the client, such as available skills and causes """
with translation.override(translation.get_language_from_request(request)):
skills = serializers.SkillSerializer(models.Skill.objects.all(), many=True)
causes = serializers.CauseSerializer(models.... | [
"def",
"startup",
"(",
"request",
")",
":",
"with",
"translation",
".",
"override",
"(",
"translation",
".",
"get_language_from_request",
"(",
"request",
")",
")",
":",
"skills",
"=",
"serializers",
".",
"SkillSerializer",
"(",
"models",
".",
"Skill",
".",
"... | This view provides initial data to the client, such as available skills and causes | [
"This",
"view",
"provides",
"initial",
"data",
"to",
"the",
"client",
"such",
"as",
"available",
"skills",
"and",
"causes"
] | train | https://github.com/OpenVolunteeringPlatform/django-ovp-core/blob/c81b868a0a4b317f7b1ec0718cabc34f7794dd20/ovp_core/views.py#L12-L23 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _comment_type_from_line | def _comment_type_from_line(line):
"""Return the "comment header" (' * ', '# ', 'rem ', '// ', '/* ').
This header goes before the content of a start of the
line in a replacement.
"""
regex = re.compile(r"^{0}".format(_ALL_COMMENT))
match = regex.match(line)
if match:
return "{0} ".... | python | def _comment_type_from_line(line):
"""Return the "comment header" (' * ', '# ', 'rem ', '// ', '/* ').
This header goes before the content of a start of the
line in a replacement.
"""
regex = re.compile(r"^{0}".format(_ALL_COMMENT))
match = regex.match(line)
if match:
return "{0} ".... | [
"def",
"_comment_type_from_line",
"(",
"line",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"r\"^{0}\"",
".",
"format",
"(",
"_ALL_COMMENT",
")",
")",
"match",
"=",
"regex",
".",
"match",
"(",
"line",
")",
"if",
"match",
":",
"return",
"\"{0} \"",
... | Return the "comment header" (' * ', '# ', 'rem ', '// ', '/* ').
This header goes before the content of a start of the
line in a replacement. | [
"Return",
"the",
"comment",
"header",
"(",
"*",
"#",
"rem",
"//",
"/",
"*",
")",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L61-L72 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _end_comment_type_from_line | def _end_comment_type_from_line(line):
"""Return the "comment footer" (eg ' */'').
This header goes after the content of a start of the
line in a replacement that would be at the end of a header block.
"""
regex = re.compile(r"^{0}".format(_FTR_COMMENT))
match = regex.match(line)
if match:
... | python | def _end_comment_type_from_line(line):
"""Return the "comment footer" (eg ' */'').
This header goes after the content of a start of the
line in a replacement that would be at the end of a header block.
"""
regex = re.compile(r"^{0}".format(_FTR_COMMENT))
match = regex.match(line)
if match:
... | [
"def",
"_end_comment_type_from_line",
"(",
"line",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"r\"^{0}\"",
".",
"format",
"(",
"_FTR_COMMENT",
")",
")",
"match",
"=",
"regex",
".",
"match",
"(",
"line",
")",
"if",
"match",
":",
"return",
"\" */\"... | Return the "comment footer" (eg ' */'').
This header goes after the content of a start of the
line in a replacement that would be at the end of a header block. | [
"Return",
"the",
"comment",
"footer",
"(",
"eg",
"*",
"/",
")",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L75-L86 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _line_is_shebang | def _line_is_shebang(line):
"""Return true if line is a shebang."""
regex = re.compile(r"^(#!|@echo off).*$")
if regex.match(line):
return True
return False | python | def _line_is_shebang(line):
"""Return true if line is a shebang."""
regex = re.compile(r"^(#!|@echo off).*$")
if regex.match(line):
return True
return False | [
"def",
"_line_is_shebang",
"(",
"line",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"r\"^(#!|@echo off).*$\"",
")",
"if",
"regex",
".",
"match",
"(",
"line",
")",
":",
"return",
"True",
"return",
"False"
] | Return true if line is a shebang. | [
"Return",
"true",
"if",
"line",
"is",
"a",
"shebang",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L92-L98 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _filename_in_headerblock | def _filename_in_headerblock(relative_path, contents, linter_options):
"""Check for a filename in a header block.
like such:
# /path/to/filename
"""
del linter_options
check_index = 0
if len(contents) > 0:
if _line_is_shebang(contents[0]):
check_index = 1
if len(co... | python | def _filename_in_headerblock(relative_path, contents, linter_options):
"""Check for a filename in a header block.
like such:
# /path/to/filename
"""
del linter_options
check_index = 0
if len(contents) > 0:
if _line_is_shebang(contents[0]):
check_index = 1
if len(co... | [
"def",
"_filename_in_headerblock",
"(",
"relative_path",
",",
"contents",
",",
"linter_options",
")",
":",
"del",
"linter_options",
"check_index",
"=",
"0",
"if",
"len",
"(",
"contents",
")",
">",
"0",
":",
"if",
"_line_is_shebang",
"(",
"contents",
"[",
"0",
... | Check for a filename in a header block.
like such:
# /path/to/filename | [
"Check",
"for",
"a",
"filename",
"in",
"a",
"header",
"block",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L101-L128 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _match_space_at_line | def _match_space_at_line(line):
"""Return a re.match object if an empty comment was found on line."""
regex = re.compile(r"^{0}$".format(_MDL_COMMENT))
return regex.match(line) | python | def _match_space_at_line(line):
"""Return a re.match object if an empty comment was found on line."""
regex = re.compile(r"^{0}$".format(_MDL_COMMENT))
return regex.match(line) | [
"def",
"_match_space_at_line",
"(",
"line",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"r\"^{0}$\"",
".",
"format",
"(",
"_MDL_COMMENT",
")",
")",
"return",
"regex",
".",
"match",
"(",
"line",
")"
] | Return a re.match object if an empty comment was found on line. | [
"Return",
"a",
"re",
".",
"match",
"object",
"if",
"an",
"empty",
"comment",
"was",
"found",
"on",
"line",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L131-L134 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _space_in_headerblock | def _space_in_headerblock(relative_path, contents, linter_options):
"""Check for space between the filename in a header block and description.
like such:
# /path/to/filename
#
# Description
"""
del relative_path
del linter_options
check_index = 1
if len(contents) > 0:
... | python | def _space_in_headerblock(relative_path, contents, linter_options):
"""Check for space between the filename in a header block and description.
like such:
# /path/to/filename
#
# Description
"""
del relative_path
del linter_options
check_index = 1
if len(contents) > 0:
... | [
"def",
"_space_in_headerblock",
"(",
"relative_path",
",",
"contents",
",",
"linter_options",
")",
":",
"del",
"relative_path",
"del",
"linter_options",
"check_index",
"=",
"1",
"if",
"len",
"(",
"contents",
")",
">",
"0",
":",
"if",
"_line_is_shebang",
"(",
"... | Check for space between the filename in a header block and description.
like such:
# /path/to/filename
#
# Description | [
"Check",
"for",
"space",
"between",
"the",
"filename",
"in",
"a",
"header",
"block",
"and",
"description",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L137-L165 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _find_last_line_index | def _find_last_line_index(contents):
"""Find the last line of the headerblock in contents."""
lineno = 0
headerblock = re.compile(r"^{0}.*$".format(_ALL_COMMENT))
if not len(contents):
raise RuntimeError("""File does not not have any contents""")
while headerblock.match(contents[lineno]):
... | python | def _find_last_line_index(contents):
"""Find the last line of the headerblock in contents."""
lineno = 0
headerblock = re.compile(r"^{0}.*$".format(_ALL_COMMENT))
if not len(contents):
raise RuntimeError("""File does not not have any contents""")
while headerblock.match(contents[lineno]):
... | [
"def",
"_find_last_line_index",
"(",
"contents",
")",
":",
"lineno",
"=",
"0",
"headerblock",
"=",
"re",
".",
"compile",
"(",
"r\"^{0}.*$\"",
".",
"format",
"(",
"_ALL_COMMENT",
")",
")",
"if",
"not",
"len",
"(",
"contents",
")",
":",
"raise",
"RuntimeErro... | Find the last line of the headerblock in contents. | [
"Find",
"the",
"last",
"line",
"of",
"the",
"headerblock",
"in",
"contents",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L168-L184 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _space_before_copyright | def _space_before_copyright(relative_path, contents, linter_options):
"""Check for a space between the last line and description.
like such
# Description
#
# Last Line
"""
del relative_path
del linter_options
last_line = _find_last_line_index(contents)
if not _match_space_at_li... | python | def _space_before_copyright(relative_path, contents, linter_options):
"""Check for a space between the last line and description.
like such
# Description
#
# Last Line
"""
del relative_path
del linter_options
last_line = _find_last_line_index(contents)
if not _match_space_at_li... | [
"def",
"_space_before_copyright",
"(",
"relative_path",
",",
"contents",
",",
"linter_options",
")",
":",
"del",
"relative_path",
"del",
"linter_options",
"last_line",
"=",
"_find_last_line_index",
"(",
"contents",
")",
"if",
"not",
"_match_space_at_line",
"(",
"conte... | Check for a space between the last line and description.
like such
# Description
#
# Last Line | [
"Check",
"for",
"a",
"space",
"between",
"the",
"last",
"line",
"and",
"description",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L187-L203 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _copyright_end_of_headerblock | def _copyright_end_of_headerblock(relative_path, contents, linter_options):
"""Check for copyright notice at end of headerblock."""
del relative_path
del linter_options
lineno = _find_last_line_index(contents)
notice = "See /LICENCE.md for Copyright information"
regex = re.compile(r"^{0} {1}( .... | python | def _copyright_end_of_headerblock(relative_path, contents, linter_options):
"""Check for copyright notice at end of headerblock."""
del relative_path
del linter_options
lineno = _find_last_line_index(contents)
notice = "See /LICENCE.md for Copyright information"
regex = re.compile(r"^{0} {1}( .... | [
"def",
"_copyright_end_of_headerblock",
"(",
"relative_path",
",",
"contents",
",",
"linter_options",
")",
":",
"del",
"relative_path",
"del",
"linter_options",
"lineno",
"=",
"_find_last_line_index",
"(",
"contents",
")",
"notice",
"=",
"\"See /LICENCE.md for Copyright i... | Check for copyright notice at end of headerblock. | [
"Check",
"for",
"copyright",
"notice",
"at",
"end",
"of",
"headerblock",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L206-L235 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _newline_end_of_file | def _newline_end_of_file(relative_path, contents, linter_options):
r"""Check that every file ends with a single \n."""
del relative_path
del linter_options
last_line = len(contents) - 1
if not len(contents) or not contents[last_line].endswith("\n"):
if len(contents):
last_line_re... | python | def _newline_end_of_file(relative_path, contents, linter_options):
r"""Check that every file ends with a single \n."""
del relative_path
del linter_options
last_line = len(contents) - 1
if not len(contents) or not contents[last_line].endswith("\n"):
if len(contents):
last_line_re... | [
"def",
"_newline_end_of_file",
"(",
"relative_path",
",",
"contents",
",",
"linter_options",
")",
":",
"del",
"relative_path",
"del",
"linter_options",
"last_line",
"=",
"len",
"(",
"contents",
")",
"-",
"1",
"if",
"not",
"len",
"(",
"contents",
")",
"or",
"... | r"""Check that every file ends with a single \n. | [
"r",
"Check",
"that",
"every",
"file",
"ends",
"with",
"a",
"single",
"\\",
"n",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L238-L250 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _no_trailing_whitespace | def _no_trailing_whitespace(relative_path, contents, linter_options):
r"""Check that every file ends with a single \n."""
del relative_path
del linter_options
trailing_whitespace = re.compile(r"(?<![ \t\r\n])[ \t]+$")
for index, line in enumerate(contents):
for space in trailing_whitespace... | python | def _no_trailing_whitespace(relative_path, contents, linter_options):
r"""Check that every file ends with a single \n."""
del relative_path
del linter_options
trailing_whitespace = re.compile(r"(?<![ \t\r\n])[ \t]+$")
for index, line in enumerate(contents):
for space in trailing_whitespace... | [
"def",
"_no_trailing_whitespace",
"(",
"relative_path",
",",
"contents",
",",
"linter_options",
")",
":",
"del",
"relative_path",
"del",
"linter_options",
"trailing_whitespace",
"=",
"re",
".",
"compile",
"(",
"r\"(?<![ \\t\\r\\n])[ \\t]+$\"",
")",
"for",
"index",
","... | r"""Check that every file ends with a single \n. | [
"r",
"Check",
"that",
"every",
"file",
"ends",
"with",
"a",
"single",
"\\",
"n",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L253-L265 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _populate_spelling_error | def _populate_spelling_error(word,
suggestions,
contents,
line_offset,
column_offset,
message_start):
"""Create a LinterFailure for word.
This function takes suggesti... | python | def _populate_spelling_error(word,
suggestions,
contents,
line_offset,
column_offset,
message_start):
"""Create a LinterFailure for word.
This function takes suggesti... | [
"def",
"_populate_spelling_error",
"(",
"word",
",",
"suggestions",
",",
"contents",
",",
"line_offset",
",",
"column_offset",
",",
"message_start",
")",
":",
"error_line",
"=",
"contents",
"[",
"line_offset",
"]",
"if",
"len",
"(",
"suggestions",
")",
":",
"c... | Create a LinterFailure for word.
This function takes suggestions from :suggestions: and uses it to
populate the message and candidate replacement. The replacement will
be a line in :contents:, as determined by :line_offset: and
:column_offset:. | [
"Create",
"a",
"LinterFailure",
"for",
"word",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L272-L303 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _find_spelling_errors_in_chunks | def _find_spelling_errors_in_chunks(chunks,
contents,
valid_words_dictionary=None,
technical_words_dictionary=None,
user_dictionary_words=None):
"""For each chunk and a set... | python | def _find_spelling_errors_in_chunks(chunks,
contents,
valid_words_dictionary=None,
technical_words_dictionary=None,
user_dictionary_words=None):
"""For each chunk and a set... | [
"def",
"_find_spelling_errors_in_chunks",
"(",
"chunks",
",",
"contents",
",",
"valid_words_dictionary",
"=",
"None",
",",
"technical_words_dictionary",
"=",
"None",
",",
"user_dictionary_words",
"=",
"None",
")",
":",
"for",
"chunk",
"in",
"chunks",
":",
"for",
"... | For each chunk and a set of valid and technical words, find errors. | [
"For",
"each",
"chunk",
"and",
"a",
"set",
"of",
"valid",
"and",
"technical",
"words",
"find",
"errors",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L321-L342 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _create_technical_words_dictionary | def _create_technical_words_dictionary(spellchecker_cache_path,
relative_path,
user_words,
shadow):
"""Create Dictionary at spellchecker_cache_path with technical words."""
technical_terms_set = ... | python | def _create_technical_words_dictionary(spellchecker_cache_path,
relative_path,
user_words,
shadow):
"""Create Dictionary at spellchecker_cache_path with technical words."""
technical_terms_set = ... | [
"def",
"_create_technical_words_dictionary",
"(",
"spellchecker_cache_path",
",",
"relative_path",
",",
"user_words",
",",
"shadow",
")",
":",
"technical_terms_set",
"=",
"(",
"user_words",
"|",
"technical_words_from_shadow_contents",
"(",
"shadow",
")",
")",
"technical_w... | Create Dictionary at spellchecker_cache_path with technical words. | [
"Create",
"Dictionary",
"at",
"spellchecker_cache_path",
"with",
"technical",
"words",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L346-L358 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _construct_user_dictionary | def _construct_user_dictionary(global_options, tool_options):
"""Cause dictionary with valid and user words to be cached on disk."""
del global_options
spellchecker_cache_path = tool_options.get("spellcheck_cache", None)
valid_words_dictionary_helper.create(spellchecker_cache_path) | python | def _construct_user_dictionary(global_options, tool_options):
"""Cause dictionary with valid and user words to be cached on disk."""
del global_options
spellchecker_cache_path = tool_options.get("spellcheck_cache", None)
valid_words_dictionary_helper.create(spellchecker_cache_path) | [
"def",
"_construct_user_dictionary",
"(",
"global_options",
",",
"tool_options",
")",
":",
"del",
"global_options",
"spellchecker_cache_path",
"=",
"tool_options",
".",
"get",
"(",
"\"spellcheck_cache\"",
",",
"None",
")",
"valid_words_dictionary_helper",
".",
"create",
... | Cause dictionary with valid and user words to be cached on disk. | [
"Cause",
"dictionary",
"with",
"valid",
"and",
"user",
"words",
"to",
"be",
"cached",
"on",
"disk",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L361-L366 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _drain | def _drain(queue_to_drain, sentinel=None):
"""Remove all values from queue_to_drain and return as list.
This uses the trick from
http://stackoverflow.com/questions/
1540822/dumping-a-multiprocessing-queue-into-a-list in order to ensure that
the queue is fully drained.
"""
queue_to_drain.put... | python | def _drain(queue_to_drain, sentinel=None):
"""Remove all values from queue_to_drain and return as list.
This uses the trick from
http://stackoverflow.com/questions/
1540822/dumping-a-multiprocessing-queue-into-a-list in order to ensure that
the queue is fully drained.
"""
queue_to_drain.put... | [
"def",
"_drain",
"(",
"queue_to_drain",
",",
"sentinel",
"=",
"None",
")",
":",
"queue_to_drain",
".",
"put",
"(",
"sentinel",
")",
"queued_items",
"=",
"[",
"i",
"for",
"i",
"in",
"iter",
"(",
"queue_to_drain",
".",
"get",
",",
"None",
")",
"]",
"retu... | Remove all values from queue_to_drain and return as list.
This uses the trick from
http://stackoverflow.com/questions/
1540822/dumping-a-multiprocessing-queue-into-a-list in order to ensure that
the queue is fully drained. | [
"Remove",
"all",
"values",
"from",
"queue_to_drain",
"and",
"return",
"as",
"list",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L369-L379 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _maybe_log_technical_terms | def _maybe_log_technical_terms(global_options, tool_options):
"""Log technical terms as appropriate if the user requested it.
As a side effect, if --log-technical-terms-to is passed to the linter
then open up the file specified (or create it) and then merge the set
of technical words that we have now w... | python | def _maybe_log_technical_terms(global_options, tool_options):
"""Log technical terms as appropriate if the user requested it.
As a side effect, if --log-technical-terms-to is passed to the linter
then open up the file specified (or create it) and then merge the set
of technical words that we have now w... | [
"def",
"_maybe_log_technical_terms",
"(",
"global_options",
",",
"tool_options",
")",
":",
"log_technical_terms_to_path",
"=",
"global_options",
".",
"get",
"(",
"\"log_technical_terms_to\"",
",",
"None",
")",
"log_technical_terms_to_queue",
"=",
"tool_options",
".",
"get... | Log technical terms as appropriate if the user requested it.
As a side effect, if --log-technical-terms-to is passed to the linter
then open up the file specified (or create it) and then merge the set
of technical words that we have now with the technical words already
in it. | [
"Log",
"technical",
"terms",
"as",
"appropriate",
"if",
"the",
"user",
"requested",
"it",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L382-L417 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _no_spelling_errors | def _no_spelling_errors(relative_path, contents, linter_options):
"""No spelling errors in strings, comments or anything of the like."""
block_regexps = linter_options.get("block_regexps", None)
chunks, shadow = spellcheckable_and_shadow_contents(contents,
... | python | def _no_spelling_errors(relative_path, contents, linter_options):
"""No spelling errors in strings, comments or anything of the like."""
block_regexps = linter_options.get("block_regexps", None)
chunks, shadow = spellcheckable_and_shadow_contents(contents,
... | [
"def",
"_no_spelling_errors",
"(",
"relative_path",
",",
"contents",
",",
"linter_options",
")",
":",
"block_regexps",
"=",
"linter_options",
".",
"get",
"(",
"\"block_regexps\"",
",",
"None",
")",
"chunks",
",",
"shadow",
"=",
"spellcheckable_and_shadow_contents",
... | No spelling errors in strings, comments or anything of the like. | [
"No",
"spelling",
"errors",
"in",
"strings",
"comments",
"or",
"anything",
"of",
"the",
"like",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L420-L439 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _line_suppresses_error_code | def _line_suppresses_error_code(line, code):
"""Check if line contains necessary content to suppress code.
A line suppresses code if it is in the format suppress(code1,code2) etc.
"""
match = re.compile(r"suppress\((.*)\)").match(line)
if match:
codes = match.group(1).split(",")
ret... | python | def _line_suppresses_error_code(line, code):
"""Check if line contains necessary content to suppress code.
A line suppresses code if it is in the format suppress(code1,code2) etc.
"""
match = re.compile(r"suppress\((.*)\)").match(line)
if match:
codes = match.group(1).split(",")
ret... | [
"def",
"_line_suppresses_error_code",
"(",
"line",
",",
"code",
")",
":",
"match",
"=",
"re",
".",
"compile",
"(",
"r\"suppress\\((.*)\\)\"",
")",
".",
"match",
"(",
"line",
")",
"if",
"match",
":",
"codes",
"=",
"match",
".",
"group",
"(",
"1",
")",
"... | Check if line contains necessary content to suppress code.
A line suppresses code if it is in the format suppress(code1,code2) etc. | [
"Check",
"if",
"line",
"contains",
"necessary",
"content",
"to",
"suppress",
"code",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L442-L452 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _error_is_suppressed | def _error_is_suppressed(error, code, contents):
"""Return true if error is suppressed by an inline suppression."""
if len(contents) == 0:
return False
if error.line > 1:
# Check above, and then to the side for suppressions
above = contents[error.line - 2].split("#")
if len(... | python | def _error_is_suppressed(error, code, contents):
"""Return true if error is suppressed by an inline suppression."""
if len(contents) == 0:
return False
if error.line > 1:
# Check above, and then to the side for suppressions
above = contents[error.line - 2].split("#")
if len(... | [
"def",
"_error_is_suppressed",
"(",
"error",
",",
"code",
",",
"contents",
")",
":",
"if",
"len",
"(",
"contents",
")",
"==",
"0",
":",
"return",
"False",
"if",
"error",
".",
"line",
">",
"1",
":",
"# Check above, and then to the side for suppressions",
"above... | Return true if error is suppressed by an inline suppression. | [
"Return",
"true",
"if",
"error",
"is",
"suppressed",
"by",
"an",
"inline",
"suppression",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L455-L471 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | lint | def lint(relative_path_to_file,
contents,
linter_functions,
**kwargs):
r"""Actually lints some file contents.
relative_path_to_file should contain the relative path to the file being
linted from the root source directory. Contents should be a raw string
with \n's.
"""
... | python | def lint(relative_path_to_file,
contents,
linter_functions,
**kwargs):
r"""Actually lints some file contents.
relative_path_to_file should contain the relative path to the file being
linted from the root source directory. Contents should be a raw string
with \n's.
"""
... | [
"def",
"lint",
"(",
"relative_path_to_file",
",",
"contents",
",",
"linter_functions",
",",
"*",
"*",
"kwargs",
")",
":",
"lines",
"=",
"contents",
".",
"splitlines",
"(",
"True",
")",
"errors",
"=",
"list",
"(",
")",
"for",
"(",
"code",
",",
"info",
"... | r"""Actually lints some file contents.
relative_path_to_file should contain the relative path to the file being
linted from the root source directory. Contents should be a raw string
with \n's. | [
"r",
"Actually",
"lints",
"some",
"file",
"contents",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L506-L528 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | linter_functions_from_filters | def linter_functions_from_filters(whitelist=None,
blacklist=None):
"""Yield tuples of _LinterFunction matching whitelist but not blacklist."""
def _keyvalue_pair_if(dictionary, condition):
"""Return a key-value pair in dictionary if condition matched."""
return ... | python | def linter_functions_from_filters(whitelist=None,
blacklist=None):
"""Yield tuples of _LinterFunction matching whitelist but not blacklist."""
def _keyvalue_pair_if(dictionary, condition):
"""Return a key-value pair in dictionary if condition matched."""
return ... | [
"def",
"linter_functions_from_filters",
"(",
"whitelist",
"=",
"None",
",",
"blacklist",
"=",
"None",
")",
":",
"def",
"_keyvalue_pair_if",
"(",
"dictionary",
",",
"condition",
")",
":",
"\"\"\"Return a key-value pair in dictionary if condition matched.\"\"\"",
"return",
... | Yield tuples of _LinterFunction matching whitelist but not blacklist. | [
"Yield",
"tuples",
"of",
"_LinterFunction",
"matching",
"whitelist",
"but",
"not",
"blacklist",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L531-L557 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _parse_arguments | def _parse_arguments(arguments=None):
"""Return a parser context result."""
dir_hash = hashlib.sha1(os.getcwd().encode("utf-8")).hexdigest()
parser = argparse.ArgumentParser(description="""Lint for Polysquare """
"""style guide""")
parser.add_argument("--checks",
... | python | def _parse_arguments(arguments=None):
"""Return a parser context result."""
dir_hash = hashlib.sha1(os.getcwd().encode("utf-8")).hexdigest()
parser = argparse.ArgumentParser(description="""Lint for Polysquare """
"""style guide""")
parser.add_argument("--checks",
... | [
"def",
"_parse_arguments",
"(",
"arguments",
"=",
"None",
")",
":",
"dir_hash",
"=",
"hashlib",
".",
"sha1",
"(",
"os",
".",
"getcwd",
"(",
")",
".",
"encode",
"(",
"\"utf-8\"",
")",
")",
".",
"hexdigest",
"(",
")",
"parser",
"=",
"argparse",
".",
"A... | Return a parser context result. | [
"Return",
"a",
"parser",
"context",
"result",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L573-L618 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _report_lint_error | def _report_lint_error(error, file_path):
"""Report a linter error."""
line = error[1].line
code = error[0]
description = error[1].description
sys.stdout.write("{0}:{1} [{2}] {3}\n".format(file_path,
line,
... | python | def _report_lint_error(error, file_path):
"""Report a linter error."""
line = error[1].line
code = error[0]
description = error[1].description
sys.stdout.write("{0}:{1} [{2}] {3}\n".format(file_path,
line,
... | [
"def",
"_report_lint_error",
"(",
"error",
",",
"file_path",
")",
":",
"line",
"=",
"error",
"[",
"1",
"]",
".",
"line",
"code",
"=",
"error",
"[",
"0",
"]",
"description",
"=",
"error",
"[",
"1",
"]",
".",
"description",
"sys",
".",
"stdout",
".",
... | Report a linter error. | [
"Report",
"a",
"linter",
"error",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L621-L629 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _apply_replacement | def _apply_replacement(error, found_file, file_lines):
"""Apply a single replacement."""
fixed_lines = file_lines
fixed_lines[error[1].line - 1] = error[1].replacement
concatenated_fixed_lines = "".join(fixed_lines)
# Only fix one error at a time
found_file.seek(0)
found_file.write(concaten... | python | def _apply_replacement(error, found_file, file_lines):
"""Apply a single replacement."""
fixed_lines = file_lines
fixed_lines[error[1].line - 1] = error[1].replacement
concatenated_fixed_lines = "".join(fixed_lines)
# Only fix one error at a time
found_file.seek(0)
found_file.write(concaten... | [
"def",
"_apply_replacement",
"(",
"error",
",",
"found_file",
",",
"file_lines",
")",
":",
"fixed_lines",
"=",
"file_lines",
"fixed_lines",
"[",
"error",
"[",
"1",
"]",
".",
"line",
"-",
"1",
"]",
"=",
"error",
"[",
"1",
"]",
".",
"replacement",
"concate... | Apply a single replacement. | [
"Apply",
"a",
"single",
"replacement",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L632-L641 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _obtain_queue | def _obtain_queue(num_jobs):
"""Return queue type most appropriate for runtime model.
If we are using multiprocessing, that should be
multiprocessing.Manager().Queue. If we are just using a
single process, then use a normal queue type.
"""
if _should_use_multiprocessing(num_jobs):
retur... | python | def _obtain_queue(num_jobs):
"""Return queue type most appropriate for runtime model.
If we are using multiprocessing, that should be
multiprocessing.Manager().Queue. If we are just using a
single process, then use a normal queue type.
"""
if _should_use_multiprocessing(num_jobs):
retur... | [
"def",
"_obtain_queue",
"(",
"num_jobs",
")",
":",
"if",
"_should_use_multiprocessing",
"(",
"num_jobs",
")",
":",
"return",
"ReprQueue",
"(",
"multiprocessing",
".",
"Manager",
"(",
")",
".",
"Queue",
"(",
")",
")",
"return",
"ReprQueue",
"(",
"Queue",
"(",... | Return queue type most appropriate for runtime model.
If we are using multiprocessing, that should be
multiprocessing.Manager().Queue. If we are just using a
single process, then use a normal queue type. | [
"Return",
"queue",
"type",
"most",
"appropriate",
"for",
"runtime",
"model",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L676-L686 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | tool_options_from_global | def tool_options_from_global(global_options, num_jobs):
"""From an argparse namespace, get a dict of options for the tools."""
internal_opt = ["whitelist", "blacklist", "fix_what_you_can"]
queue_object = _obtain_queue(num_jobs)
translate = defaultdict(lambda: (lambda x: x),
l... | python | def tool_options_from_global(global_options, num_jobs):
"""From an argparse namespace, get a dict of options for the tools."""
internal_opt = ["whitelist", "blacklist", "fix_what_you_can"]
queue_object = _obtain_queue(num_jobs)
translate = defaultdict(lambda: (lambda x: x),
l... | [
"def",
"tool_options_from_global",
"(",
"global_options",
",",
"num_jobs",
")",
":",
"internal_opt",
"=",
"[",
"\"whitelist\"",
",",
"\"blacklist\"",
",",
"\"fix_what_you_can\"",
"]",
"queue_object",
"=",
"_obtain_queue",
"(",
"num_jobs",
")",
"translate",
"=",
"def... | From an argparse namespace, get a dict of options for the tools. | [
"From",
"an",
"argparse",
"namespace",
"get",
"a",
"dict",
"of",
"options",
"for",
"the",
"tools",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L689-L702 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _run_lint_on_file | def _run_lint_on_file(file_path,
linter_functions,
tool_options,
fix_what_you_can):
"""Run each function in linter_functions on filename.
If fix_what_you_can is specified, then the first error that has a
possible replacement will be automati... | python | def _run_lint_on_file(file_path,
linter_functions,
tool_options,
fix_what_you_can):
"""Run each function in linter_functions on filename.
If fix_what_you_can is specified, then the first error that has a
possible replacement will be automati... | [
"def",
"_run_lint_on_file",
"(",
"file_path",
",",
"linter_functions",
",",
"tool_options",
",",
"fix_what_you_can",
")",
":",
"with",
"io",
".",
"open",
"(",
"file_path",
",",
"\"r+\"",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"as",
"found_file",
":",
"file_co... | Run each function in linter_functions on filename.
If fix_what_you_can is specified, then the first error that has a
possible replacement will be automatically fixed on this file. | [
"Run",
"each",
"function",
"in",
"linter_functions",
"on",
"filename",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L716-L750 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _run_lint_on_file_exceptions | def _run_lint_on_file_exceptions(file_path,
linter_functions,
tool_options,
fix_what_you_can):
"""Run except function in :linter_functions: on file_path.
This function calls through to _run_lint_on_file, but prin... | python | def _run_lint_on_file_exceptions(file_path,
linter_functions,
tool_options,
fix_what_you_can):
"""Run except function in :linter_functions: on file_path.
This function calls through to _run_lint_on_file, but prin... | [
"def",
"_run_lint_on_file_exceptions",
"(",
"file_path",
",",
"linter_functions",
",",
"tool_options",
",",
"fix_what_you_can",
")",
":",
"try",
":",
"return",
"_run_lint_on_file",
"(",
"file_path",
",",
"linter_functions",
",",
"tool_options",
",",
"fix_what_you_can",
... | Run except function in :linter_functions: on file_path.
This function calls through to _run_lint_on_file, but prints a traceback
for any exceptions encountered. It is intended to be used with parmap. | [
"Run",
"except",
"function",
"in",
":",
"linter_functions",
":",
"on",
"file_path",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L753-L771 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _run_lint_on_file_stamped_args | def _run_lint_on_file_stamped_args(file_path, # suppress(too-many-arguments)
stamp_file_path,
log_technical_terms_to,
linter_functions,
tool_options,
... | python | def _run_lint_on_file_stamped_args(file_path, # suppress(too-many-arguments)
stamp_file_path,
log_technical_terms_to,
linter_functions,
tool_options,
... | [
"def",
"_run_lint_on_file_stamped_args",
"(",
"file_path",
",",
"# suppress(too-many-arguments)",
"stamp_file_path",
",",
"log_technical_terms_to",
",",
"linter_functions",
",",
"tool_options",
",",
"fix_what_you_can",
")",
":",
"dictionary_path",
"=",
"os",
".",
"path",
... | Return tuple of args and kwargs that function would be called with. | [
"Return",
"tuple",
"of",
"args",
"and",
"kwargs",
"that",
"function",
"would",
"be",
"called",
"with",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L774-L798 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _run_lint_on_file_stamped | def _run_lint_on_file_stamped(*args):
"""Run linter functions on file_path, stamping in stamp_file_path."""
# We pass an empty dictionary as keyword arguments here to work
# around a bug in frosted, which crashes when no keyword arguments
# are passed
#
# suppress(E204)
stamp_args, stamp_kwa... | python | def _run_lint_on_file_stamped(*args):
"""Run linter functions on file_path, stamping in stamp_file_path."""
# We pass an empty dictionary as keyword arguments here to work
# around a bug in frosted, which crashes when no keyword arguments
# are passed
#
# suppress(E204)
stamp_args, stamp_kwa... | [
"def",
"_run_lint_on_file_stamped",
"(",
"*",
"args",
")",
":",
"# We pass an empty dictionary as keyword arguments here to work",
"# around a bug in frosted, which crashes when no keyword arguments",
"# are passed",
"#",
"# suppress(E204)",
"stamp_args",
",",
"stamp_kwargs",
"=",
"_... | Run linter functions on file_path, stamping in stamp_file_path. | [
"Run",
"linter",
"functions",
"on",
"file_path",
"stamping",
"in",
"stamp_file_path",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L801-L813 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _ordered | def _ordered(generator, *args, **kwargs):
"""Sort keys of unordered_dict and store in OrderedDict."""
unordered_dict = {k: v for k, v in generator(*args, **kwargs)}
keys = sorted(list(dict(unordered_dict).keys()))
result = OrderedDict()
for key in keys:
result[key] = unordered_dict[key]
... | python | def _ordered(generator, *args, **kwargs):
"""Sort keys of unordered_dict and store in OrderedDict."""
unordered_dict = {k: v for k, v in generator(*args, **kwargs)}
keys = sorted(list(dict(unordered_dict).keys()))
result = OrderedDict()
for key in keys:
result[key] = unordered_dict[key]
... | [
"def",
"_ordered",
"(",
"generator",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"unordered_dict",
"=",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"generator",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"}",
"keys",
"=",
"sor... | Sort keys of unordered_dict and store in OrderedDict. | [
"Sort",
"keys",
"of",
"unordered_dict",
"and",
"store",
"in",
"OrderedDict",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L816-L824 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | _any_would_run | def _any_would_run(func, filenames, *args):
"""True if a linter function would be called on any of filenames."""
if os.environ.get("_POLYSQUARE_GENERIC_FILE_LINTER_NO_STAMPING", None):
return True
for filename in filenames:
# suppress(E204)
stamp_args, stamp_kwargs = _run_lint_on_fi... | python | def _any_would_run(func, filenames, *args):
"""True if a linter function would be called on any of filenames."""
if os.environ.get("_POLYSQUARE_GENERIC_FILE_LINTER_NO_STAMPING", None):
return True
for filename in filenames:
# suppress(E204)
stamp_args, stamp_kwargs = _run_lint_on_fi... | [
"def",
"_any_would_run",
"(",
"func",
",",
"filenames",
",",
"*",
"args",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"\"_POLYSQUARE_GENERIC_FILE_LINTER_NO_STAMPING\"",
",",
"None",
")",
":",
"return",
"True",
"for",
"filename",
"in",
"filenames",
... | True if a linter function would be called on any of filenames. | [
"True",
"if",
"a",
"linter",
"function",
"would",
"be",
"called",
"on",
"any",
"of",
"filenames",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L827-L844 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | main | def main(arguments=None): # suppress(unused-function)
"""Entry point for the linter."""
result = _parse_arguments(arguments)
linter_funcs = _ordered(linter_functions_from_filters,
result.whitelist,
result.blacklist)
global_options = vars(result)
... | python | def main(arguments=None): # suppress(unused-function)
"""Entry point for the linter."""
result = _parse_arguments(arguments)
linter_funcs = _ordered(linter_functions_from_filters,
result.whitelist,
result.blacklist)
global_options = vars(result)
... | [
"def",
"main",
"(",
"arguments",
"=",
"None",
")",
":",
"# suppress(unused-function)",
"result",
"=",
"_parse_arguments",
"(",
"arguments",
")",
"linter_funcs",
"=",
"_ordered",
"(",
"linter_functions_from_filters",
",",
"result",
".",
"whitelist",
",",
"result",
... | Entry point for the linter. | [
"Entry",
"point",
"for",
"the",
"linter",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L847-L894 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | ReprQueue.put | def put(self, item, block=True, timeout=None):
"""Put item into underlying queue."""
return self._queue.put(item, block, timeout) | python | def put(self, item, block=True, timeout=None):
"""Put item into underlying queue."""
return self._queue.put(item, block, timeout) | [
"def",
"put",
"(",
"self",
",",
"item",
",",
"block",
"=",
"True",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"_queue",
".",
"put",
"(",
"item",
",",
"block",
",",
"timeout",
")"
] | Put item into underlying queue. | [
"Put",
"item",
"into",
"underlying",
"queue",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L663-L665 |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | ReprQueue.get | def get(self, block=True, timeout=None):
"""Get item from underlying queue."""
return self._queue.get(block, timeout) | python | def get(self, block=True, timeout=None):
"""Get item from underlying queue."""
return self._queue.get(block, timeout) | [
"def",
"get",
"(",
"self",
",",
"block",
"=",
"True",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"_queue",
".",
"get",
"(",
"block",
",",
"timeout",
")"
] | Get item from underlying queue. | [
"Get",
"item",
"from",
"underlying",
"queue",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L667-L669 |
rojopolis/lycanthropy | lycanthropy/lycanthropy.py | snake_to_camel | def snake_to_camel(snake_str):
'''
Convert `snake_str` from snake_case to camelCase
'''
components = snake_str.split('_')
if len(components) > 1:
camel = (components[0].lower() +
''.join(x.title() for x in components[1:]))
return camel
# Not snake_case
return... | python | def snake_to_camel(snake_str):
'''
Convert `snake_str` from snake_case to camelCase
'''
components = snake_str.split('_')
if len(components) > 1:
camel = (components[0].lower() +
''.join(x.title() for x in components[1:]))
return camel
# Not snake_case
return... | [
"def",
"snake_to_camel",
"(",
"snake_str",
")",
":",
"components",
"=",
"snake_str",
".",
"split",
"(",
"'_'",
")",
"if",
"len",
"(",
"components",
")",
">",
"1",
":",
"camel",
"=",
"(",
"components",
"[",
"0",
"]",
".",
"lower",
"(",
")",
"+",
"''... | Convert `snake_str` from snake_case to camelCase | [
"Convert",
"snake_str",
"from",
"snake_case",
"to",
"camelCase"
] | train | https://github.com/rojopolis/lycanthropy/blob/1a5ce2828714fc0e34780ac866532d4106d1a05b/lycanthropy/lycanthropy.py#L7-L17 |
rojopolis/lycanthropy | lycanthropy/lycanthropy.py | snake_to_pascal | def snake_to_pascal(snake_str):
'''
Convert `snake_str` from snake_case to PascalCase
'''
components = snake_str.split('_')
if len(components) > 1:
camel = ''.join(x.title() for x in components)
return camel
# Not snake_case
return snake_str | python | def snake_to_pascal(snake_str):
'''
Convert `snake_str` from snake_case to PascalCase
'''
components = snake_str.split('_')
if len(components) > 1:
camel = ''.join(x.title() for x in components)
return camel
# Not snake_case
return snake_str | [
"def",
"snake_to_pascal",
"(",
"snake_str",
")",
":",
"components",
"=",
"snake_str",
".",
"split",
"(",
"'_'",
")",
"if",
"len",
"(",
"components",
")",
">",
"1",
":",
"camel",
"=",
"''",
".",
"join",
"(",
"x",
".",
"title",
"(",
")",
"for",
"x",
... | Convert `snake_str` from snake_case to PascalCase | [
"Convert",
"snake_str",
"from",
"snake_case",
"to",
"PascalCase"
] | train | https://github.com/rojopolis/lycanthropy/blob/1a5ce2828714fc0e34780ac866532d4106d1a05b/lycanthropy/lycanthropy.py#L24-L33 |
rojopolis/lycanthropy | lycanthropy/lycanthropy.py | camel_to_snake | def camel_to_snake(camel_str):
'''
Convert `camel_str` from camelCase to snake_case
'''
# Attribution: https://stackoverflow.com/a/1176023/633213
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', camel_str)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | python | def camel_to_snake(camel_str):
'''
Convert `camel_str` from camelCase to snake_case
'''
# Attribution: https://stackoverflow.com/a/1176023/633213
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', camel_str)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | [
"def",
"camel_to_snake",
"(",
"camel_str",
")",
":",
"# Attribution: https://stackoverflow.com/a/1176023/633213",
"s1",
"=",
"re",
".",
"sub",
"(",
"'(.)([A-Z][a-z]+)'",
",",
"r'\\1_\\2'",
",",
"camel_str",
")",
"return",
"re",
".",
"sub",
"(",
"'([a-z0-9])([A-Z])'",
... | Convert `camel_str` from camelCase to snake_case | [
"Convert",
"camel_str",
"from",
"camelCase",
"to",
"snake_case"
] | train | https://github.com/rojopolis/lycanthropy/blob/1a5ce2828714fc0e34780ac866532d4106d1a05b/lycanthropy/lycanthropy.py#L40-L46 |
rojopolis/lycanthropy | lycanthropy/lycanthropy.py | morph_dict | def morph_dict(d, convert_function):
"""
Convert a nested dictionary from one convention to another.
Args:
d (dict): dictionary (nested or not) to be converted.
convert_function (func): function that takes the string in one
convention and returns it in the other one.
Returns:
... | python | def morph_dict(d, convert_function):
"""
Convert a nested dictionary from one convention to another.
Args:
d (dict): dictionary (nested or not) to be converted.
convert_function (func): function that takes the string in one
convention and returns it in the other one.
Returns:
... | [
"def",
"morph_dict",
"(",
"d",
",",
"convert_function",
")",
":",
"# Attribution: https://stackoverflow.com/a/33668421/633213",
"new",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"d",
")",
":",
"new_v",
"=",
"v",
"if",
"isinstanc... | Convert a nested dictionary from one convention to another.
Args:
d (dict): dictionary (nested or not) to be converted.
convert_function (func): function that takes the string in one
convention and returns it in the other one.
Returns:
Dictionary with the new keys. | [
"Convert",
"a",
"nested",
"dictionary",
"from",
"one",
"convention",
"to",
"another",
".",
"Args",
":",
"d",
"(",
"dict",
")",
":",
"dictionary",
"(",
"nested",
"or",
"not",
")",
"to",
"be",
"converted",
".",
"convert_function",
"(",
"func",
")",
":",
... | train | https://github.com/rojopolis/lycanthropy/blob/1a5ce2828714fc0e34780ac866532d4106d1a05b/lycanthropy/lycanthropy.py#L53-L76 |
fstab50/metal | metal/cli.py | set_logging | def set_logging(cfg_obj):
"""
Enable or disable logging per config object parameter
"""
log_status = cfg_obj['LOGGING']['ENABLE_LOGGING']
if log_status:
logger.disabled = False
elif not log_status:
logger.info(
'%s: Logging disabled per local configuration file (%s) ... | python | def set_logging(cfg_obj):
"""
Enable or disable logging per config object parameter
"""
log_status = cfg_obj['LOGGING']['ENABLE_LOGGING']
if log_status:
logger.disabled = False
elif not log_status:
logger.info(
'%s: Logging disabled per local configuration file (%s) ... | [
"def",
"set_logging",
"(",
"cfg_obj",
")",
":",
"log_status",
"=",
"cfg_obj",
"[",
"'LOGGING'",
"]",
"[",
"'ENABLE_LOGGING'",
"]",
"if",
"log_status",
":",
"logger",
".",
"disabled",
"=",
"False",
"elif",
"not",
"log_status",
":",
"logger",
".",
"info",
"(... | Enable or disable logging per config object parameter | [
"Enable",
"or",
"disable",
"logging",
"per",
"config",
"object",
"parameter"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/cli.py#L64-L78 |
fstab50/metal | metal/cli.py | precheck | def precheck():
"""
Verify project runtime dependencies
"""
cfg_path = local_config['PROJECT']['CONFIG_PATH']
# enable or disable logging based on config/ defaults
logging = set_logging(local_config)
if os.path.exists(cfg_path):
logger.info('%s: config_path parameter: %s' % (inspect... | python | def precheck():
"""
Verify project runtime dependencies
"""
cfg_path = local_config['PROJECT']['CONFIG_PATH']
# enable or disable logging based on config/ defaults
logging = set_logging(local_config)
if os.path.exists(cfg_path):
logger.info('%s: config_path parameter: %s' % (inspect... | [
"def",
"precheck",
"(",
")",
":",
"cfg_path",
"=",
"local_config",
"[",
"'PROJECT'",
"]",
"[",
"'CONFIG_PATH'",
"]",
"# enable or disable logging based on config/ defaults",
"logging",
"=",
"set_logging",
"(",
"local_config",
")",
"if",
"os",
".",
"path",
".",
"ex... | Verify project runtime dependencies | [
"Verify",
"project",
"runtime",
"dependencies"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/cli.py#L81-L107 |
fstab50/metal | metal/cli.py | main | def main(operation, profile, auto, debug, user_name=''):
"""
End-to-end renew of access keys for a specific profile in local awscli config
"""
if user_name:
logger.info('user_name parameter given (%s) as surrogate' % user_name)
try:
if operation in VALID_INSTALL:
print(op... | python | def main(operation, profile, auto, debug, user_name=''):
"""
End-to-end renew of access keys for a specific profile in local awscli config
"""
if user_name:
logger.info('user_name parameter given (%s) as surrogate' % user_name)
try:
if operation in VALID_INSTALL:
print(op... | [
"def",
"main",
"(",
"operation",
",",
"profile",
",",
"auto",
",",
"debug",
",",
"user_name",
"=",
"''",
")",
":",
"if",
"user_name",
":",
"logger",
".",
"info",
"(",
"'user_name parameter given (%s) as surrogate'",
"%",
"user_name",
")",
"try",
":",
"if",
... | End-to-end renew of access keys for a specific profile in local awscli config | [
"End",
"-",
"to",
"-",
"end",
"renew",
"of",
"access",
"keys",
"for",
"a",
"specific",
"profile",
"in",
"local",
"awscli",
"config"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/cli.py#L141-L181 |
fstab50/metal | metal/cli.py | options | def options(parser, help_menu=False):
"""
Summary:
parse cli parameter options
Returns:
TYPE: argparse object, parser argument set
"""
parser.add_argument("-p", "--profile", nargs='?', default="default",
required=False, help="type (default: %(default)s)"... | python | def options(parser, help_menu=False):
"""
Summary:
parse cli parameter options
Returns:
TYPE: argparse object, parser argument set
"""
parser.add_argument("-p", "--profile", nargs='?', default="default",
required=False, help="type (default: %(default)s)"... | [
"def",
"options",
"(",
"parser",
",",
"help_menu",
"=",
"False",
")",
":",
"parser",
".",
"add_argument",
"(",
"\"-p\"",
",",
"\"--profile\"",
",",
"nargs",
"=",
"'?'",
",",
"default",
"=",
"\"default\"",
",",
"required",
"=",
"False",
",",
"help",
"=",
... | Summary:
parse cli parameter options
Returns:
TYPE: argparse object, parser argument set | [
"Summary",
":",
"parse",
"cli",
"parameter",
"options",
"Returns",
":",
"TYPE",
":",
"argparse",
"object",
"parser",
"argument",
"set"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/cli.py#L184-L199 |
fstab50/metal | metal/cli.py | option_configure | def option_configure(debug=False, path=None):
"""
Summary:
Initiate configuration menu to customize metal runtime options.
Console script ```keyconfig``` invokes this option_configure directly
in debug mode to display the contents of the local config file (if exists)
Args:
:p... | python | def option_configure(debug=False, path=None):
"""
Summary:
Initiate configuration menu to customize metal runtime options.
Console script ```keyconfig``` invokes this option_configure directly
in debug mode to display the contents of the local config file (if exists)
Args:
:p... | [
"def",
"option_configure",
"(",
"debug",
"=",
"False",
",",
"path",
"=",
"None",
")",
":",
"if",
"CONFIG_SCRIPT",
"in",
"sys",
".",
"argv",
"[",
"0",
"]",
":",
"debug",
"=",
"True",
"# set debug mode if invoked from CONFIG_SCRIPT",
"if",
"path",
"is",
"None"... | Summary:
Initiate configuration menu to customize metal runtime options.
Console script ```keyconfig``` invokes this option_configure directly
in debug mode to display the contents of the local config file (if exists)
Args:
:path (str): full path to default local configuration file l... | [
"Summary",
":",
"Initiate",
"configuration",
"menu",
"to",
"customize",
"metal",
"runtime",
"options",
".",
"Console",
"script",
"keyconfig",
"invokes",
"this",
"option_configure",
"directly",
"in",
"debug",
"mode",
"to",
"display",
"the",
"contents",
"of",
"the",... | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/cli.py#L229-L255 |
fstab50/metal | metal/cli.py | rkhunter | def rkhunter(caller='console_script'):
"""
Summary:
- Console Script target for rkhunter installer
- Called from either invoking console script "rkinstaller" directly,
or metal with the --install rkhunter parameter
Returns:
Success | Failure, TYPE: bool
"""
if calle... | python | def rkhunter(caller='console_script'):
"""
Summary:
- Console Script target for rkhunter installer
- Called from either invoking console script "rkinstaller" directly,
or metal with the --install rkhunter parameter
Returns:
Success | Failure, TYPE: bool
"""
if calle... | [
"def",
"rkhunter",
"(",
"caller",
"=",
"'console_script'",
")",
":",
"if",
"caller",
"==",
"'console_script'",
":",
"cmd",
"=",
"'sudo sh rkinstaller.sh '",
"+",
"parameters",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
"else",
":",
"cmd",
"=",
"'s... | Summary:
- Console Script target for rkhunter installer
- Called from either invoking console script "rkinstaller" directly,
or metal with the --install rkhunter parameter
Returns:
Success | Failure, TYPE: bool | [
"Summary",
":",
"-",
"Console",
"Script",
"target",
"for",
"rkhunter",
"installer",
"-",
"Called",
"from",
"either",
"invoking",
"console",
"script",
"rkinstaller",
"directly",
"or",
"metal",
"with",
"the",
"--",
"install",
"rkhunter",
"parameter",
"Returns",
":... | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/cli.py#L265-L287 |
fstab50/metal | metal/cli.py | chooser_menu | def chooser_menu():
""" Master jump off point to ancillary functionality """
title = TITLE + "The" + Colors.ORANGE + " Metal" + Colors.RESET + TITLE + " Menu" + RESET
menu = """
________________________________________________________________
""" + title + """
__________________... | python | def chooser_menu():
""" Master jump off point to ancillary functionality """
title = TITLE + "The" + Colors.ORANGE + " Metal" + Colors.RESET + TITLE + " Menu" + RESET
menu = """
________________________________________________________________
""" + title + """
__________________... | [
"def",
"chooser_menu",
"(",
")",
":",
"title",
"=",
"TITLE",
"+",
"\"The\"",
"+",
"Colors",
".",
"ORANGE",
"+",
"\" Metal\"",
"+",
"Colors",
".",
"RESET",
"+",
"TITLE",
"+",
"\" Menu\"",
"+",
"RESET",
"menu",
"=",
"\"\"\"\n _____________________________... | Master jump off point to ancillary functionality | [
"Master",
"jump",
"off",
"point",
"to",
"ancillary",
"functionality"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/cli.py#L290-L324 |
fstab50/metal | metal/cli.py | SetLogging.set | def set(self, mode, disable):
""" create logger object, enable or disable logging """
global logger
try:
if logger:
if disable:
logger.disabled = True
else:
if mode in ('STREAM', 'FILE'):
logger = log... | python | def set(self, mode, disable):
""" create logger object, enable or disable logging """
global logger
try:
if logger:
if disable:
logger.disabled = True
else:
if mode in ('STREAM', 'FILE'):
logger = log... | [
"def",
"set",
"(",
"self",
",",
"mode",
",",
"disable",
")",
":",
"global",
"logger",
"try",
":",
"if",
"logger",
":",
"if",
"disable",
":",
"logger",
".",
"disabled",
"=",
"True",
"else",
":",
"if",
"mode",
"in",
"(",
"'STREAM'",
",",
"'FILE'",
")... | create logger object, enable or disable logging | [
"create",
"logger",
"object",
"enable",
"or",
"disable",
"logging"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/cli.py#L123-L138 |
eliangcs/bisheng | bisheng/jianfan.py | _translate | def _translate(unistr, table):
'''Replace characters using a table.'''
if type(unistr) is str:
try:
unistr = unistr.decode('utf-8')
# Python 3 returns AttributeError when .decode() is called on a str
# This means it is already unicode.
except AttributeError:
... | python | def _translate(unistr, table):
'''Replace characters using a table.'''
if type(unistr) is str:
try:
unistr = unistr.decode('utf-8')
# Python 3 returns AttributeError when .decode() is called on a str
# This means it is already unicode.
except AttributeError:
... | [
"def",
"_translate",
"(",
"unistr",
",",
"table",
")",
":",
"if",
"type",
"(",
"unistr",
")",
"is",
"str",
":",
"try",
":",
"unistr",
"=",
"unistr",
".",
"decode",
"(",
"'utf-8'",
")",
"# Python 3 returns AttributeError when .decode() is called on a str",
"# Thi... | Replace characters using a table. | [
"Replace",
"characters",
"using",
"a",
"table",
"."
] | train | https://github.com/eliangcs/bisheng/blob/cbb9b1fcfee7598ea96b6412742a273e17537195/bisheng/jianfan.py#L50-L70 |
EdwinvO/pyutillib | pyutillib/math_utils.py | div | def div(numerator, denominator):
'''
Returns numerator / denominator, but instead of a ZeroDivisionError:
0 / 0 = 0.
x / 0 = float('inf')
This is not mathematically correct, but often practically OK.
Args:
numerator (float or int)
denominator (float or int)
Returns:
... | python | def div(numerator, denominator):
'''
Returns numerator / denominator, but instead of a ZeroDivisionError:
0 / 0 = 0.
x / 0 = float('inf')
This is not mathematically correct, but often practically OK.
Args:
numerator (float or int)
denominator (float or int)
Returns:
... | [
"def",
"div",
"(",
"numerator",
",",
"denominator",
")",
":",
"try",
":",
"return",
"numerator",
"/",
"denominator",
"except",
"ZeroDivisionError",
":",
"if",
"numerator",
"==",
"0",
":",
"return",
"0.",
"elif",
"denominator",
"==",
"0",
":",
"return",
"fl... | Returns numerator / denominator, but instead of a ZeroDivisionError:
0 / 0 = 0.
x / 0 = float('inf')
This is not mathematically correct, but often practically OK.
Args:
numerator (float or int)
denominator (float or int)
Returns:
(float)
Raises:
- | [
"Returns",
"numerator",
"/",
"denominator",
"but",
"instead",
"of",
"a",
"ZeroDivisionError",
":",
"0",
"/",
"0",
"=",
"0",
".",
"x",
"/",
"0",
"=",
"float",
"(",
"inf",
")",
"This",
"is",
"not",
"mathematically",
"correct",
"but",
"often",
"practically"... | train | https://github.com/EdwinvO/pyutillib/blob/6d773c31d1f27cc5256d47feb8afb5c3ae5f0db5/pyutillib/math_utils.py#L27-L51 |
EdwinvO/pyutillib | pyutillib/math_utils.py | eval_conditions | def eval_conditions(conditions=None, data={}):
'''
Evaluates conditions and returns Boolean value.
Args:
conditions (tuple) for the format of the tuple, see below
data (dict) the keys of which can be used in conditions
Returns:
(boolea)
Raises:
ValueError if an inval... | python | def eval_conditions(conditions=None, data={}):
'''
Evaluates conditions and returns Boolean value.
Args:
conditions (tuple) for the format of the tuple, see below
data (dict) the keys of which can be used in conditions
Returns:
(boolea)
Raises:
ValueError if an inval... | [
"def",
"eval_conditions",
"(",
"conditions",
"=",
"None",
",",
"data",
"=",
"{",
"}",
")",
":",
"#CONSIDER: implementing addition/subtraction/multiplication/division",
"if",
"not",
"conditions",
":",
"return",
"True",
"if",
"isinstance",
"(",
"conditions",
",",
"str... | Evaluates conditions and returns Boolean value.
Args:
conditions (tuple) for the format of the tuple, see below
data (dict) the keys of which can be used in conditions
Returns:
(boolea)
Raises:
ValueError if an invalid operator value is specified
TypeError if:
... | [
"Evaluates",
"conditions",
"and",
"returns",
"Boolean",
"value",
"."
] | train | https://github.com/EdwinvO/pyutillib/blob/6d773c31d1f27cc5256d47feb8afb5c3ae5f0db5/pyutillib/math_utils.py#L54-L114 |
minhhoit/yacms | yacms/utils/docs.py | deep_force_unicode | def deep_force_unicode(value):
"""
Recursively call force_text on value.
"""
if isinstance(value, (list, tuple, set)):
value = type(value)(map(deep_force_unicode, value))
elif isinstance(value, dict):
value = type(value)(map(deep_force_unicode, value.items()))
elif isinstance(val... | python | def deep_force_unicode(value):
"""
Recursively call force_text on value.
"""
if isinstance(value, (list, tuple, set)):
value = type(value)(map(deep_force_unicode, value))
elif isinstance(value, dict):
value = type(value)(map(deep_force_unicode, value.items()))
elif isinstance(val... | [
"def",
"deep_force_unicode",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"tuple",
",",
"set",
")",
")",
":",
"value",
"=",
"type",
"(",
"value",
")",
"(",
"map",
"(",
"deep_force_unicode",
",",
"value",
")",
")",
... | Recursively call force_text on value. | [
"Recursively",
"call",
"force_text",
"on",
"value",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/docs.py#L25-L35 |
minhhoit/yacms | yacms/utils/docs.py | build_settings_docs | def build_settings_docs(docs_path, prefix=None):
"""
Converts names, descriptions and defaults for settings in
``yacms.conf.registry`` into RST format for use in docs,
optionally filtered by setting names with the given prefix.
"""
# String to use instead of setting value for dynamic defaults
... | python | def build_settings_docs(docs_path, prefix=None):
"""
Converts names, descriptions and defaults for settings in
``yacms.conf.registry`` into RST format for use in docs,
optionally filtered by setting names with the given prefix.
"""
# String to use instead of setting value for dynamic defaults
... | [
"def",
"build_settings_docs",
"(",
"docs_path",
",",
"prefix",
"=",
"None",
")",
":",
"# String to use instead of setting value for dynamic defaults",
"dynamic",
"=",
"\"[dynamic]\"",
"lines",
"=",
"[",
"\".. THIS DOCUMENT IS AUTO GENERATED VIA conf.py\"",
"]",
"for",
"name",... | Converts names, descriptions and defaults for settings in
``yacms.conf.registry`` into RST format for use in docs,
optionally filtered by setting names with the given prefix. | [
"Converts",
"names",
"descriptions",
"and",
"defaults",
"for",
"settings",
"in",
"yacms",
".",
"conf",
".",
"registry",
"into",
"RST",
"format",
"for",
"use",
"in",
"docs",
"optionally",
"filtered",
"by",
"setting",
"names",
"with",
"the",
"given",
"prefix",
... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/docs.py#L38-L75 |
minhhoit/yacms | yacms/utils/docs.py | build_changelog | def build_changelog(docs_path, package_name="yacms"):
"""
Converts Mercurial commits into a changelog in RST format.
"""
project_path = os.path.join(docs_path, "..")
version_file = os.path.join(package_name, "__init__.py")
version_var = "__version__"
changelog_filename = "CHANGELOG"
cha... | python | def build_changelog(docs_path, package_name="yacms"):
"""
Converts Mercurial commits into a changelog in RST format.
"""
project_path = os.path.join(docs_path, "..")
version_file = os.path.join(package_name, "__init__.py")
version_var = "__version__"
changelog_filename = "CHANGELOG"
cha... | [
"def",
"build_changelog",
"(",
"docs_path",
",",
"package_name",
"=",
"\"yacms\"",
")",
":",
"project_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"docs_path",
",",
"\"..\"",
")",
"version_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"package_name"... | Converts Mercurial commits into a changelog in RST format. | [
"Converts",
"Mercurial",
"commits",
"into",
"a",
"changelog",
"in",
"RST",
"format",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/docs.py#L98-L233 |
minhhoit/yacms | yacms/utils/docs.py | build_modelgraph | def build_modelgraph(docs_path, package_name="yacms"):
"""
Creates a diagram of all the models for yacms and the given
package name, generates a smaller version and add it to the
docs directory for use in model-graph.rst
"""
to_path = os.path.join(docs_path, "img", "graph.png")
build_path = ... | python | def build_modelgraph(docs_path, package_name="yacms"):
"""
Creates a diagram of all the models for yacms and the given
package name, generates a smaller version and add it to the
docs directory for use in model-graph.rst
"""
to_path = os.path.join(docs_path, "img", "graph.png")
build_path = ... | [
"def",
"build_modelgraph",
"(",
"docs_path",
",",
"package_name",
"=",
"\"yacms\"",
")",
":",
"to_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"docs_path",
",",
"\"img\"",
",",
"\"graph.png\"",
")",
"build_path",
"=",
"os",
".",
"path",
".",
"join",
... | Creates a diagram of all the models for yacms and the given
package name, generates a smaller version and add it to the
docs directory for use in model-graph.rst | [
"Creates",
"a",
"diagram",
"of",
"all",
"the",
"models",
"for",
"yacms",
"and",
"the",
"given",
"package",
"name",
"generates",
"a",
"smaller",
"version",
"and",
"add",
"it",
"to",
"the",
"docs",
"directory",
"for",
"use",
"in",
"model",
"-",
"graph",
".... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/docs.py#L236-L285 |
minhhoit/yacms | yacms/utils/docs.py | build_requirements | def build_requirements(docs_path, package_name="yacms"):
"""
Updates the requirements file with yacms's version number.
"""
mezz_string = "yacms=="
project_path = os.path.join(docs_path, "..")
requirements_file = os.path.join(project_path, package_name,
"proj... | python | def build_requirements(docs_path, package_name="yacms"):
"""
Updates the requirements file with yacms's version number.
"""
mezz_string = "yacms=="
project_path = os.path.join(docs_path, "..")
requirements_file = os.path.join(project_path, package_name,
"proj... | [
"def",
"build_requirements",
"(",
"docs_path",
",",
"package_name",
"=",
"\"yacms\"",
")",
":",
"mezz_string",
"=",
"\"yacms==\"",
"project_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"docs_path",
",",
"\"..\"",
")",
"requirements_file",
"=",
"os",
".",
... | Updates the requirements file with yacms's version number. | [
"Updates",
"the",
"requirements",
"file",
"with",
"yacms",
"s",
"version",
"number",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/docs.py#L288-L302 |
pjanis/funtool | funtool/state_measure.py | _wrap_measure | def _wrap_measure(individual_state_measure_process, state_measure, loaded_processes):
"""
Creates a function on a state_collection, which creates analysis_collections for each state in the collection.
Optionally sorts the collection if the state_measure has a sort_by parameter (see funtool.lib.general... | python | def _wrap_measure(individual_state_measure_process, state_measure, loaded_processes):
"""
Creates a function on a state_collection, which creates analysis_collections for each state in the collection.
Optionally sorts the collection if the state_measure has a sort_by parameter (see funtool.lib.general... | [
"def",
"_wrap_measure",
"(",
"individual_state_measure_process",
",",
"state_measure",
",",
"loaded_processes",
")",
":",
"def",
"wrapped_measure",
"(",
"state_collection",
",",
"overriding_parameters",
"=",
"None",
",",
"loggers",
"=",
"None",
")",
":",
"if",
"logg... | Creates a function on a state_collection, which creates analysis_collections for each state in the collection.
Optionally sorts the collection if the state_measure has a sort_by parameter (see funtool.lib.general.sort_states for details) | [
"Creates",
"a",
"function",
"on",
"a",
"state_collection",
"which",
"creates",
"analysis_collections",
"for",
"each",
"state",
"in",
"the",
"collection",
".",
"Optionally",
"sorts",
"the",
"collection",
"if",
"the",
"state_measure",
"has",
"a",
"sort_by",
"paramet... | train | https://github.com/pjanis/funtool/blob/231851238f0a62bc3682d8fa937db9053378c53d/funtool/state_measure.py#L42-L70 |
pjanis/funtool | funtool/state_measure.py | analysis_collection_and_parameter_measure | def analysis_collection_and_parameter_measure(state_measure_function):
"""
Decorator for State Measures that only require the analysis_collection and parameters
Saves return value to analysis_collection.state.measures with the State Measure's name as the key
"""
def wrapped_function(state_measure, ... | python | def analysis_collection_and_parameter_measure(state_measure_function):
"""
Decorator for State Measures that only require the analysis_collection and parameters
Saves return value to analysis_collection.state.measures with the State Measure's name as the key
"""
def wrapped_function(state_measure, ... | [
"def",
"analysis_collection_and_parameter_measure",
"(",
"state_measure_function",
")",
":",
"def",
"wrapped_function",
"(",
"state_measure",
",",
"analysis_collection",
",",
"state_collection",
",",
"overriding_parameters",
"=",
"None",
")",
":",
"measure_parameters",
"=",... | Decorator for State Measures that only require the analysis_collection and parameters
Saves return value to analysis_collection.state.measures with the State Measure's name as the key | [
"Decorator",
"for",
"State",
"Measures",
"that",
"only",
"require",
"the",
"analysis_collection",
"and",
"parameters"
] | train | https://github.com/pjanis/funtool/blob/231851238f0a62bc3682d8fa937db9053378c53d/funtool/state_measure.py#L113-L124 |
pjanis/funtool | funtool/state_measure.py | analysis_collection_and_parameter_meta | def analysis_collection_and_parameter_meta(state_measure_function):
"""
Decorator for State Measures that only require the analysis_collection and parameters
Saves return value to analysis_collection.state.meta with the State Measure's name as the key
"""
def wrapped_function(state_measure, analysi... | python | def analysis_collection_and_parameter_meta(state_measure_function):
"""
Decorator for State Measures that only require the analysis_collection and parameters
Saves return value to analysis_collection.state.meta with the State Measure's name as the key
"""
def wrapped_function(state_measure, analysi... | [
"def",
"analysis_collection_and_parameter_meta",
"(",
"state_measure_function",
")",
":",
"def",
"wrapped_function",
"(",
"state_measure",
",",
"analysis_collection",
",",
"state_collection",
",",
"overriding_parameters",
"=",
"None",
")",
":",
"measure_parameters",
"=",
... | Decorator for State Measures that only require the analysis_collection and parameters
Saves return value to analysis_collection.state.meta with the State Measure's name as the key | [
"Decorator",
"for",
"State",
"Measures",
"that",
"only",
"require",
"the",
"analysis_collection",
"and",
"parameters"
] | train | https://github.com/pjanis/funtool/blob/231851238f0a62bc3682d8fa937db9053378c53d/funtool/state_measure.py#L126-L137 |
pjanis/funtool | funtool/state_measure.py | analysis_collection_and_parameter_data | def analysis_collection_and_parameter_data(state_measure_function):
"""
Decorator for State Measures that only require the analysis_collection and parameters
Saves return value to analysis_collection.state.data with the State Measure's name as the key
"""
def wrapped_function(state_measure, analysi... | python | def analysis_collection_and_parameter_data(state_measure_function):
"""
Decorator for State Measures that only require the analysis_collection and parameters
Saves return value to analysis_collection.state.data with the State Measure's name as the key
"""
def wrapped_function(state_measure, analysi... | [
"def",
"analysis_collection_and_parameter_data",
"(",
"state_measure_function",
")",
":",
"def",
"wrapped_function",
"(",
"state_measure",
",",
"analysis_collection",
",",
"state_collection",
",",
"overriding_parameters",
"=",
"None",
")",
":",
"measure_parameters",
"=",
... | Decorator for State Measures that only require the analysis_collection and parameters
Saves return value to analysis_collection.state.data with the State Measure's name as the key | [
"Decorator",
"for",
"State",
"Measures",
"that",
"only",
"require",
"the",
"analysis_collection",
"and",
"parameters"
] | train | https://github.com/pjanis/funtool/blob/231851238f0a62bc3682d8fa937db9053378c53d/funtool/state_measure.py#L139-L150 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.