id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
41,200 | dariusbakunas/rawdisk | rawdisk/filesystems/detector.py | FilesystemDetector.register_mbr_plugin | def register_mbr_plugin(self, fs_id, plugin):
"""Used in plugin's registration routine,
to associate it's detection method with given filesystem id
Args:
fs_id: filesystem id that is read from MBR partition entry
plugin: plugin that supports this filesystem
"""
... | python | def register_mbr_plugin(self, fs_id, plugin):
"""Used in plugin's registration routine,
to associate it's detection method with given filesystem id
Args:
fs_id: filesystem id that is read from MBR partition entry
plugin: plugin that supports this filesystem
"""
... | [
"def",
"register_mbr_plugin",
"(",
"self",
",",
"fs_id",
",",
"plugin",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'MBR: {}, FS ID: {}'",
".",
"format",
"(",
"self",
".",
"__get_plugin_name",
"(",
"plugin",
")",
",",
"fs_id",
")",
")",
"self",
... | Used in plugin's registration routine,
to associate it's detection method with given filesystem id
Args:
fs_id: filesystem id that is read from MBR partition entry
plugin: plugin that supports this filesystem | [
"Used",
"in",
"plugin",
"s",
"registration",
"routine",
"to",
"associate",
"it",
"s",
"detection",
"method",
"with",
"given",
"filesystem",
"id"
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/filesystems/detector.py#L67-L77 |
41,201 | dariusbakunas/rawdisk | rawdisk/filesystems/detector.py | FilesystemDetector.register_gpt_plugin | def register_gpt_plugin(self, fs_guid, plugin):
"""Used in plugin's registration routine,
to associate it's detection method with given filesystem guid
Args:
fs_guid: filesystem guid that is read from GPT partition entry
plugin: plugin that supports this filesystem
... | python | def register_gpt_plugin(self, fs_guid, plugin):
"""Used in plugin's registration routine,
to associate it's detection method with given filesystem guid
Args:
fs_guid: filesystem guid that is read from GPT partition entry
plugin: plugin that supports this filesystem
... | [
"def",
"register_gpt_plugin",
"(",
"self",
",",
"fs_guid",
",",
"plugin",
")",
":",
"key",
"=",
"uuid",
".",
"UUID",
"(",
"fs_guid",
".",
"lower",
"(",
")",
")",
"self",
".",
"logger",
".",
"debug",
"(",
"'GPT: {}, GUID: {}'",
".",
"format",
"(",
"self... | Used in plugin's registration routine,
to associate it's detection method with given filesystem guid
Args:
fs_guid: filesystem guid that is read from GPT partition entry
plugin: plugin that supports this filesystem | [
"Used",
"in",
"plugin",
"s",
"registration",
"routine",
"to",
"associate",
"it",
"s",
"detection",
"method",
"with",
"given",
"filesystem",
"guid"
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/filesystems/detector.py#L79-L91 |
41,202 | dariusbakunas/rawdisk | rawdisk/filesystems/detector.py | FilesystemDetector.detect_mbr | def detect_mbr(self, filename, offset, fs_id):
"""Used by rawdisk.session.Session to match mbr partitions against
filesystem plugins.
Args:
filename: device or file that it will read in order to detect
the filesystem fs_id: filesystem id to match (ex. 0x07)
o... | python | def detect_mbr(self, filename, offset, fs_id):
"""Used by rawdisk.session.Session to match mbr partitions against
filesystem plugins.
Args:
filename: device or file that it will read in order to detect
the filesystem fs_id: filesystem id to match (ex. 0x07)
o... | [
"def",
"detect_mbr",
"(",
"self",
",",
"filename",
",",
"offset",
",",
"fs_id",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Detecting MBR partition type'",
")",
"if",
"fs_id",
"not",
"in",
"self",
".",
"__mbr_plugins",
":",
"return",
"None",
"els... | Used by rawdisk.session.Session to match mbr partitions against
filesystem plugins.
Args:
filename: device or file that it will read in order to detect
the filesystem fs_id: filesystem id to match (ex. 0x07)
offset: offset for the filesystem that is being matched
... | [
"Used",
"by",
"rawdisk",
".",
"session",
".",
"Session",
"to",
"match",
"mbr",
"partitions",
"against",
"filesystem",
"plugins",
"."
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/filesystems/detector.py#L98-L120 |
41,203 | dariusbakunas/rawdisk | rawdisk/filesystems/detector.py | FilesystemDetector.detect_gpt | def detect_gpt(self, filename, offset, fs_guid):
"""Used by rawdisk.session.Session to match gpt partitions agains
filesystem plugins.
Args:
filename: device or file that it will read in order to detect the
filesystem
fs_id: filesystem guid to match
... | python | def detect_gpt(self, filename, offset, fs_guid):
"""Used by rawdisk.session.Session to match gpt partitions agains
filesystem plugins.
Args:
filename: device or file that it will read in order to detect the
filesystem
fs_id: filesystem guid to match
... | [
"def",
"detect_gpt",
"(",
"self",
",",
"filename",
",",
"offset",
",",
"fs_guid",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Detecting GPT partition type'",
")",
"if",
"fs_guid",
"not",
"in",
"self",
".",
"__gpt_plugins",
":",
"return",
"None",
... | Used by rawdisk.session.Session to match gpt partitions agains
filesystem plugins.
Args:
filename: device or file that it will read in order to detect the
filesystem
fs_id: filesystem guid to match
(ex. {EBD0A0A2-B9E5-4433-87C0-68B6B72699C7})
... | [
"Used",
"by",
"rawdisk",
".",
"session",
".",
"Session",
"to",
"match",
"gpt",
"partitions",
"agains",
"filesystem",
"plugins",
"."
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/filesystems/detector.py#L122-L147 |
41,204 | xolox/python-update-dotdee | update_dotdee/__init__.py | inject_documentation | def inject_documentation(**options):
"""
Generate configuration documentation in reStructuredText_ syntax.
:param options: Any keyword arguments are passed on to the
:class:`ConfigLoader` initializer.
This methods injects the generated documentation into the output generated
by... | python | def inject_documentation(**options):
"""
Generate configuration documentation in reStructuredText_ syntax.
:param options: Any keyword arguments are passed on to the
:class:`ConfigLoader` initializer.
This methods injects the generated documentation into the output generated
by... | [
"def",
"inject_documentation",
"(",
"*",
"*",
"options",
")",
":",
"import",
"cog",
"loader",
"=",
"ConfigLoader",
"(",
"*",
"*",
"options",
")",
"cog",
".",
"out",
"(",
"\"\\n\"",
"+",
"loader",
".",
"documentation",
"+",
"\"\\n\\n\"",
")"
] | Generate configuration documentation in reStructuredText_ syntax.
:param options: Any keyword arguments are passed on to the
:class:`ConfigLoader` initializer.
This methods injects the generated documentation into the output generated
by cog_.
.. _cog: https://pypi.python.org/pypi... | [
"Generate",
"configuration",
"documentation",
"in",
"reStructuredText_",
"syntax",
"."
] | 04d5836f0d217e32778745b533beeb8159d80c32 | https://github.com/xolox/python-update-dotdee/blob/04d5836f0d217e32778745b533beeb8159d80c32/update_dotdee/__init__.py#L478-L492 |
41,205 | xolox/python-update-dotdee | update_dotdee/__init__.py | UpdateDotDee.read_file | def read_file(self, filename):
"""
Read a text file and provide feedback to the user.
:param filename: The pathname of the file to read (a string).
:returns: The contents of the file (a string).
"""
logger.info("Reading file: %s", format_path(filename))
contents ... | python | def read_file(self, filename):
"""
Read a text file and provide feedback to the user.
:param filename: The pathname of the file to read (a string).
:returns: The contents of the file (a string).
"""
logger.info("Reading file: %s", format_path(filename))
contents ... | [
"def",
"read_file",
"(",
"self",
",",
"filename",
")",
":",
"logger",
".",
"info",
"(",
"\"Reading file: %s\"",
",",
"format_path",
"(",
"filename",
")",
")",
"contents",
"=",
"self",
".",
"context",
".",
"read_file",
"(",
"filename",
")",
"num_lines",
"="... | Read a text file and provide feedback to the user.
:param filename: The pathname of the file to read (a string).
:returns: The contents of the file (a string). | [
"Read",
"a",
"text",
"file",
"and",
"provide",
"feedback",
"to",
"the",
"user",
"."
] | 04d5836f0d217e32778745b533beeb8159d80c32 | https://github.com/xolox/python-update-dotdee/blob/04d5836f0d217e32778745b533beeb8159d80c32/update_dotdee/__init__.py#L184-L197 |
41,206 | xolox/python-update-dotdee | update_dotdee/__init__.py | UpdateDotDee.execute_file | def execute_file(self, filename):
"""
Execute a file and provide feedback to the user.
:param filename: The pathname of the file to execute (a string).
:returns: Whatever the executed file returns on stdout (a string).
"""
logger.info("Executing file: %s", format_path(fi... | python | def execute_file(self, filename):
"""
Execute a file and provide feedback to the user.
:param filename: The pathname of the file to execute (a string).
:returns: Whatever the executed file returns on stdout (a string).
"""
logger.info("Executing file: %s", format_path(fi... | [
"def",
"execute_file",
"(",
"self",
",",
"filename",
")",
":",
"logger",
".",
"info",
"(",
"\"Executing file: %s\"",
",",
"format_path",
"(",
"filename",
")",
")",
"contents",
"=",
"self",
".",
"context",
".",
"execute",
"(",
"filename",
",",
"capture",
"=... | Execute a file and provide feedback to the user.
:param filename: The pathname of the file to execute (a string).
:returns: Whatever the executed file returns on stdout (a string). | [
"Execute",
"a",
"file",
"and",
"provide",
"feedback",
"to",
"the",
"user",
"."
] | 04d5836f0d217e32778745b533beeb8159d80c32 | https://github.com/xolox/python-update-dotdee/blob/04d5836f0d217e32778745b533beeb8159d80c32/update_dotdee/__init__.py#L199-L212 |
41,207 | xolox/python-update-dotdee | update_dotdee/__init__.py | UpdateDotDee.write_file | def write_file(self, filename, contents):
"""
Write a text file and provide feedback to the user.
:param filename: The pathname of the file to write (a string).
:param contents: The new contents of the file (a string).
"""
logger.info("Writing file: %s", format_path(file... | python | def write_file(self, filename, contents):
"""
Write a text file and provide feedback to the user.
:param filename: The pathname of the file to write (a string).
:param contents: The new contents of the file (a string).
"""
logger.info("Writing file: %s", format_path(file... | [
"def",
"write_file",
"(",
"self",
",",
"filename",
",",
"contents",
")",
":",
"logger",
".",
"info",
"(",
"\"Writing file: %s\"",
",",
"format_path",
"(",
"filename",
")",
")",
"contents",
"=",
"contents",
".",
"rstrip",
"(",
")",
"+",
"b\"\\n\"",
"self",
... | Write a text file and provide feedback to the user.
:param filename: The pathname of the file to write (a string).
:param contents: The new contents of the file (a string). | [
"Write",
"a",
"text",
"file",
"and",
"provide",
"feedback",
"to",
"the",
"user",
"."
] | 04d5836f0d217e32778745b533beeb8159d80c32 | https://github.com/xolox/python-update-dotdee/blob/04d5836f0d217e32778745b533beeb8159d80c32/update_dotdee/__init__.py#L214-L226 |
41,208 | mcash/merchant-api-python-sdk | mcash/mapi_client/validation.py | validate_input | def validate_input(function):
"""Decorator that validates the kwargs of the function passed to it."""
@wraps(function)
def wrapper(*args, **kwargs):
try:
name = function.__name__ + '_validator' # find validator name
globals()[name](kwargs) # call validation function
... | python | def validate_input(function):
"""Decorator that validates the kwargs of the function passed to it."""
@wraps(function)
def wrapper(*args, **kwargs):
try:
name = function.__name__ + '_validator' # find validator name
globals()[name](kwargs) # call validation function
... | [
"def",
"validate_input",
"(",
"function",
")",
":",
"@",
"wraps",
"(",
"function",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"name",
"=",
"function",
".",
"__name__",
"+",
"'_validator'",
"# find validator na... | Decorator that validates the kwargs of the function passed to it. | [
"Decorator",
"that",
"validates",
"the",
"kwargs",
"of",
"the",
"function",
"passed",
"to",
"it",
"."
] | ebe8734126790354b71077aca519ff263235944e | https://github.com/mcash/merchant-api-python-sdk/blob/ebe8734126790354b71077aca519ff263235944e/mcash/mapi_client/validation.py#L5-L16 |
41,209 | brmscheiner/ideogram | ideogram/importAnalysis.py | getModulePath | def getModulePath(project_path,module_name,verbose):
'''Searches for module_name in searchpath and returns the filepath.
If no filepath was found, returns None.'''
if not module_name:
return None
sys.path.append(project_path)
try:
package = pkgutil.get_loader(module_name)
except ... | python | def getModulePath(project_path,module_name,verbose):
'''Searches for module_name in searchpath and returns the filepath.
If no filepath was found, returns None.'''
if not module_name:
return None
sys.path.append(project_path)
try:
package = pkgutil.get_loader(module_name)
except ... | [
"def",
"getModulePath",
"(",
"project_path",
",",
"module_name",
",",
"verbose",
")",
":",
"if",
"not",
"module_name",
":",
"return",
"None",
"sys",
".",
"path",
".",
"append",
"(",
"project_path",
")",
"try",
":",
"package",
"=",
"pkgutil",
".",
"get_load... | Searches for module_name in searchpath and returns the filepath.
If no filepath was found, returns None. | [
"Searches",
"for",
"module_name",
"in",
"searchpath",
"and",
"returns",
"the",
"filepath",
".",
"If",
"no",
"filepath",
"was",
"found",
"returns",
"None",
"."
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/importAnalysis.py#L4-L44 |
41,210 | brmscheiner/ideogram | ideogram/importAnalysis.py | getImportFromObjects | def getImportFromObjects(node):
'''Returns a list of objects referenced by import from node'''
somenames = [x.asname for x in node.names if x.asname]
othernames = [x.name for x in node.names if not x.asname]
return somenames+othernames | python | def getImportFromObjects(node):
'''Returns a list of objects referenced by import from node'''
somenames = [x.asname for x in node.names if x.asname]
othernames = [x.name for x in node.names if not x.asname]
return somenames+othernames | [
"def",
"getImportFromObjects",
"(",
"node",
")",
":",
"somenames",
"=",
"[",
"x",
".",
"asname",
"for",
"x",
"in",
"node",
".",
"names",
"if",
"x",
".",
"asname",
"]",
"othernames",
"=",
"[",
"x",
".",
"name",
"for",
"x",
"in",
"node",
".",
"names"... | Returns a list of objects referenced by import from node | [
"Returns",
"a",
"list",
"of",
"objects",
"referenced",
"by",
"import",
"from",
"node"
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/importAnalysis.py#L51-L55 |
41,211 | helixyte/everest | everest/repositories/rdb/utils.py | as_slug_expression | def as_slug_expression(attr):
"""
Converts the given instrumented string attribute into an SQL expression
that can be used as a slug.
Slugs are identifiers for members in a collection that can be used in an
URL. We create slug columns by replacing non-URL characters with dashes
and lower casing... | python | def as_slug_expression(attr):
"""
Converts the given instrumented string attribute into an SQL expression
that can be used as a slug.
Slugs are identifiers for members in a collection that can be used in an
URL. We create slug columns by replacing non-URL characters with dashes
and lower casing... | [
"def",
"as_slug_expression",
"(",
"attr",
")",
":",
"slug_expr",
"=",
"sa_func",
".",
"replace",
"(",
"attr",
",",
"' '",
",",
"'-'",
")",
"slug_expr",
"=",
"sa_func",
".",
"replace",
"(",
"slug_expr",
",",
"'_'",
",",
"'-'",
")",
"slug_expr",
"=",
"sa... | Converts the given instrumented string attribute into an SQL expression
that can be used as a slug.
Slugs are identifiers for members in a collection that can be used in an
URL. We create slug columns by replacing non-URL characters with dashes
and lower casing the result. We need this at the ORM level... | [
"Converts",
"the",
"given",
"instrumented",
"string",
"attribute",
"into",
"an",
"SQL",
"expression",
"that",
"can",
"be",
"used",
"as",
"a",
"slug",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/rdb/utils.py#L90-L103 |
41,212 | helixyte/everest | everest/repositories/rdb/utils.py | mapper | def mapper(class_, local_table=None, id_attribute='id', slug_expression=None,
*args, **kwargs):
"""
Convenience wrapper around the SA mapper which will set up the hybrid
"id" and "slug" attributes required by everest after calling the SA
mapper.
If you (e.g., for testing purposes) want t... | python | def mapper(class_, local_table=None, id_attribute='id', slug_expression=None,
*args, **kwargs):
"""
Convenience wrapper around the SA mapper which will set up the hybrid
"id" and "slug" attributes required by everest after calling the SA
mapper.
If you (e.g., for testing purposes) want t... | [
"def",
"mapper",
"(",
"class_",
",",
"local_table",
"=",
"None",
",",
"id_attribute",
"=",
"'id'",
",",
"slug_expression",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"mpr",
"=",
"sa_mapper",
"(",
"class_",
",",
"local_table",
"="... | Convenience wrapper around the SA mapper which will set up the hybrid
"id" and "slug" attributes required by everest after calling the SA
mapper.
If you (e.g., for testing purposes) want to clear mappers created with
this function, use the :func:`clear_mappers` function in this module.
:param str ... | [
"Convenience",
"wrapper",
"around",
"the",
"SA",
"mapper",
"which",
"will",
"set",
"up",
"the",
"hybrid",
"id",
"and",
"slug",
"attributes",
"required",
"by",
"everest",
"after",
"calling",
"the",
"SA",
"mapper",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/rdb/utils.py#L121-L173 |
41,213 | helixyte/everest | everest/repositories/rdb/utils.py | synonym | def synonym(name):
"""
Utility function mimicking the behavior of the old SA synonym function
with the new hybrid property semantics.
"""
return hybrid_property(lambda inst: getattr(inst, name),
lambda inst, value: setattr(inst, name, value),
exp... | python | def synonym(name):
"""
Utility function mimicking the behavior of the old SA synonym function
with the new hybrid property semantics.
"""
return hybrid_property(lambda inst: getattr(inst, name),
lambda inst, value: setattr(inst, name, value),
exp... | [
"def",
"synonym",
"(",
"name",
")",
":",
"return",
"hybrid_property",
"(",
"lambda",
"inst",
":",
"getattr",
"(",
"inst",
",",
"name",
")",
",",
"lambda",
"inst",
",",
"value",
":",
"setattr",
"(",
"inst",
",",
"name",
",",
"value",
")",
",",
"expr",... | Utility function mimicking the behavior of the old SA synonym function
with the new hybrid property semantics. | [
"Utility",
"function",
"mimicking",
"the",
"behavior",
"of",
"the",
"old",
"SA",
"synonym",
"function",
"with",
"the",
"new",
"hybrid",
"property",
"semantics",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/rdb/utils.py#L176-L183 |
41,214 | helixyte/everest | everest/repositories/rdb/utils.py | map_system_entities | def map_system_entities(engine, metadata, reset):
"""
Maps all system entities.
"""
# Map the user message system entity.
msg_tbl = Table('_user_messages', metadata,
Column('guid', String, nullable=False, primary_key=True),
Column('text', String, nullable=Fals... | python | def map_system_entities(engine, metadata, reset):
"""
Maps all system entities.
"""
# Map the user message system entity.
msg_tbl = Table('_user_messages', metadata,
Column('guid', String, nullable=False, primary_key=True),
Column('text', String, nullable=Fals... | [
"def",
"map_system_entities",
"(",
"engine",
",",
"metadata",
",",
"reset",
")",
":",
"# Map the user message system entity.",
"msg_tbl",
"=",
"Table",
"(",
"'_user_messages'",
",",
"metadata",
",",
"Column",
"(",
"'guid'",
",",
"String",
",",
"nullable",
"=",
"... | Maps all system entities. | [
"Maps",
"all",
"system",
"entities",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/rdb/utils.py#L186-L200 |
41,215 | BlackEarth/bxml | bxml/schema.py | Schema.schematron | def schematron(self, fn=None, outfn=None, ext='.sch'):
"""convert the Schema to schematron and save at the given output filename or with the given extension."""
from .xslt import XSLT
from . import PATH, XML, etree
fn = fn or self.fn
if os.path.splitext(fn)[-1].lower()==ext:
... | python | def schematron(self, fn=None, outfn=None, ext='.sch'):
"""convert the Schema to schematron and save at the given output filename or with the given extension."""
from .xslt import XSLT
from . import PATH, XML, etree
fn = fn or self.fn
if os.path.splitext(fn)[-1].lower()==ext:
... | [
"def",
"schematron",
"(",
"self",
",",
"fn",
"=",
"None",
",",
"outfn",
"=",
"None",
",",
"ext",
"=",
"'.sch'",
")",
":",
"from",
".",
"xslt",
"import",
"XSLT",
"from",
".",
"import",
"PATH",
",",
"XML",
",",
"etree",
"fn",
"=",
"fn",
"or",
"self... | convert the Schema to schematron and save at the given output filename or with the given extension. | [
"convert",
"the",
"Schema",
"to",
"schematron",
"and",
"save",
"at",
"the",
"given",
"output",
"filename",
"or",
"with",
"the",
"given",
"extension",
"."
] | 8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77 | https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/schema.py#L36-L50 |
41,216 | BlackEarth/bxml | bxml/schema.py | Schema.xhtml | def xhtml(self, outfn=None, ext='.xhtml', css=None, **params):
"""convert the Schema to XHTML with the given output filename or with the given extension."""
from markdown import markdown
from copy import deepcopy
from bl.file import File
from .xslt import XSLT
from .rng i... | python | def xhtml(self, outfn=None, ext='.xhtml', css=None, **params):
"""convert the Schema to XHTML with the given output filename or with the given extension."""
from markdown import markdown
from copy import deepcopy
from bl.file import File
from .xslt import XSLT
from .rng i... | [
"def",
"xhtml",
"(",
"self",
",",
"outfn",
"=",
"None",
",",
"ext",
"=",
"'.xhtml'",
",",
"css",
"=",
"None",
",",
"*",
"*",
"params",
")",
":",
"from",
"markdown",
"import",
"markdown",
"from",
"copy",
"import",
"deepcopy",
"from",
"bl",
".",
"file"... | convert the Schema to XHTML with the given output filename or with the given extension. | [
"convert",
"the",
"Schema",
"to",
"XHTML",
"with",
"the",
"given",
"output",
"filename",
"or",
"with",
"the",
"given",
"extension",
"."
] | 8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77 | https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/schema.py#L52-L119 |
41,217 | BlackEarth/bxml | bxml/schema.py | Schema.from_tag | def from_tag(cls, tag, schemas, ext='.rnc'):
"""load a schema using an element's tag. schemas can be a string or a list of strings"""
return cls(fn=cls.filename(tag, schemas, ext=ext)) | python | def from_tag(cls, tag, schemas, ext='.rnc'):
"""load a schema using an element's tag. schemas can be a string or a list of strings"""
return cls(fn=cls.filename(tag, schemas, ext=ext)) | [
"def",
"from_tag",
"(",
"cls",
",",
"tag",
",",
"schemas",
",",
"ext",
"=",
"'.rnc'",
")",
":",
"return",
"cls",
"(",
"fn",
"=",
"cls",
".",
"filename",
"(",
"tag",
",",
"schemas",
",",
"ext",
"=",
"ext",
")",
")"
] | load a schema using an element's tag. schemas can be a string or a list of strings | [
"load",
"a",
"schema",
"using",
"an",
"element",
"s",
"tag",
".",
"schemas",
"can",
"be",
"a",
"string",
"or",
"a",
"list",
"of",
"strings"
] | 8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77 | https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/schema.py#L122-L124 |
41,218 | BlackEarth/bxml | bxml/schema.py | Schema.filename | def filename(cls, tag, schemas, ext='.rnc'):
"""given a tag and a list of schemas, return the filename of the schema.
If schemas is a string, treat it as a comma-separated list.
"""
if type(schemas)==str:
schemas = re.split("\s*,\s*", schemas)
for schema in schemas:
... | python | def filename(cls, tag, schemas, ext='.rnc'):
"""given a tag and a list of schemas, return the filename of the schema.
If schemas is a string, treat it as a comma-separated list.
"""
if type(schemas)==str:
schemas = re.split("\s*,\s*", schemas)
for schema in schemas:
... | [
"def",
"filename",
"(",
"cls",
",",
"tag",
",",
"schemas",
",",
"ext",
"=",
"'.rnc'",
")",
":",
"if",
"type",
"(",
"schemas",
")",
"==",
"str",
":",
"schemas",
"=",
"re",
".",
"split",
"(",
"\"\\s*,\\s*\"",
",",
"schemas",
")",
"for",
"schema",
"in... | given a tag and a list of schemas, return the filename of the schema.
If schemas is a string, treat it as a comma-separated list. | [
"given",
"a",
"tag",
"and",
"a",
"list",
"of",
"schemas",
"return",
"the",
"filename",
"of",
"the",
"schema",
".",
"If",
"schemas",
"is",
"a",
"string",
"treat",
"it",
"as",
"a",
"comma",
"-",
"separated",
"list",
"."
] | 8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77 | https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/schema.py#L127-L136 |
41,219 | vicalloy/lbutils | lbutils/forms.py | FormHelperMixin.errors_as_text | def errors_as_text(self):
"""
only available to Django 1.7+
"""
errors = []
errors.append(self.non_field_errors().as_text())
errors_data = self.errors.as_data()
for key, value in errors_data.items():
field_label = self.fields[key].label
err... | python | def errors_as_text(self):
"""
only available to Django 1.7+
"""
errors = []
errors.append(self.non_field_errors().as_text())
errors_data = self.errors.as_data()
for key, value in errors_data.items():
field_label = self.fields[key].label
err... | [
"def",
"errors_as_text",
"(",
"self",
")",
":",
"errors",
"=",
"[",
"]",
"errors",
".",
"append",
"(",
"self",
".",
"non_field_errors",
"(",
")",
".",
"as_text",
"(",
")",
")",
"errors_data",
"=",
"self",
".",
"errors",
".",
"as_data",
"(",
")",
"for... | only available to Django 1.7+ | [
"only",
"available",
"to",
"Django",
"1",
".",
"7",
"+"
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/forms.py#L32-L44 |
41,220 | vicalloy/lbutils | lbutils/forms.py | FormHelperMixin.add_attr2fields | def add_attr2fields(self, attr_name, attr_val, fields=[], exclude=[], include_all_if_empty=True):
"""
add attr to fields
"""
for f in self.filter_fields(fields, exclude, include_all_if_empty):
f = self.fields[f.name]
org_val = f.widget.attrs.get(attr_name, '')
... | python | def add_attr2fields(self, attr_name, attr_val, fields=[], exclude=[], include_all_if_empty=True):
"""
add attr to fields
"""
for f in self.filter_fields(fields, exclude, include_all_if_empty):
f = self.fields[f.name]
org_val = f.widget.attrs.get(attr_name, '')
... | [
"def",
"add_attr2fields",
"(",
"self",
",",
"attr_name",
",",
"attr_val",
",",
"fields",
"=",
"[",
"]",
",",
"exclude",
"=",
"[",
"]",
",",
"include_all_if_empty",
"=",
"True",
")",
":",
"for",
"f",
"in",
"self",
".",
"filter_fields",
"(",
"fields",
",... | add attr to fields | [
"add",
"attr",
"to",
"fields"
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/forms.py#L65-L72 |
41,221 | vicalloy/lbutils | lbutils/forms.py | FormHelperMixin.add_class2fields | def add_class2fields(self, html_class, fields=[], exclude=[], include_all_if_empty=True):
"""
add class to html widgets.
"""
self.add_attr2fields('class', html_class, fields, exclude) | python | def add_class2fields(self, html_class, fields=[], exclude=[], include_all_if_empty=True):
"""
add class to html widgets.
"""
self.add_attr2fields('class', html_class, fields, exclude) | [
"def",
"add_class2fields",
"(",
"self",
",",
"html_class",
",",
"fields",
"=",
"[",
"]",
",",
"exclude",
"=",
"[",
"]",
",",
"include_all_if_empty",
"=",
"True",
")",
":",
"self",
".",
"add_attr2fields",
"(",
"'class'",
",",
"html_class",
",",
"fields",
... | add class to html widgets. | [
"add",
"class",
"to",
"html",
"widgets",
"."
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/forms.py#L74-L78 |
41,222 | vicalloy/lbutils | lbutils/forms.py | FormHelperMixin.as_required_fields | def as_required_fields(self, fields=[]):
""" set required to True """
fields = self.filter_fields(fields)
for f in fields:
f = self.fields[f.name]
f.required = True | python | def as_required_fields(self, fields=[]):
""" set required to True """
fields = self.filter_fields(fields)
for f in fields:
f = self.fields[f.name]
f.required = True | [
"def",
"as_required_fields",
"(",
"self",
",",
"fields",
"=",
"[",
"]",
")",
":",
"fields",
"=",
"self",
".",
"filter_fields",
"(",
"fields",
")",
"for",
"f",
"in",
"fields",
":",
"f",
"=",
"self",
".",
"fields",
"[",
"f",
".",
"name",
"]",
"f",
... | set required to True | [
"set",
"required",
"to",
"True"
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/forms.py#L101-L106 |
41,223 | vicalloy/lbutils | lbutils/forms.py | FormHelperMixin.check_uniqe | def check_uniqe(self, obj_class, error_msg=_('Must be unique'), **kwargs):
""" check if this object is unique """
if obj_class.objects.filter(**kwargs).exclude(pk=self.instance.pk):
raise forms.ValidationError(error_msg) | python | def check_uniqe(self, obj_class, error_msg=_('Must be unique'), **kwargs):
""" check if this object is unique """
if obj_class.objects.filter(**kwargs).exclude(pk=self.instance.pk):
raise forms.ValidationError(error_msg) | [
"def",
"check_uniqe",
"(",
"self",
",",
"obj_class",
",",
"error_msg",
"=",
"_",
"(",
"'Must be unique'",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"obj_class",
".",
"objects",
".",
"filter",
"(",
"*",
"*",
"kwargs",
")",
".",
"exclude",
"(",
"pk... | check if this object is unique | [
"check",
"if",
"this",
"object",
"is",
"unique"
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/forms.py#L108-L111 |
41,224 | danbradham/scrim | setup.py | get_info | def get_info(pyfile):
'''Retrieve dunder values from a pyfile'''
info = {}
info_re = re.compile(r"^__(\w+)__ = ['\"](.*)['\"]")
with open(pyfile, 'r') as f:
for line in f.readlines():
match = info_re.search(line)
if match:
info[match.group(1)] = match.grou... | python | def get_info(pyfile):
'''Retrieve dunder values from a pyfile'''
info = {}
info_re = re.compile(r"^__(\w+)__ = ['\"](.*)['\"]")
with open(pyfile, 'r') as f:
for line in f.readlines():
match = info_re.search(line)
if match:
info[match.group(1)] = match.grou... | [
"def",
"get_info",
"(",
"pyfile",
")",
":",
"info",
"=",
"{",
"}",
"info_re",
"=",
"re",
".",
"compile",
"(",
"r\"^__(\\w+)__ = ['\\\"](.*)['\\\"]\"",
")",
"with",
"open",
"(",
"pyfile",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
".",
... | Retrieve dunder values from a pyfile | [
"Retrieve",
"dunder",
"values",
"from",
"a",
"pyfile"
] | 982a5db1db6e4ef40267f15642af2c7ea0e803ae | https://github.com/danbradham/scrim/blob/982a5db1db6e4ef40267f15642af2c7ea0e803ae/setup.py#L20-L29 |
41,225 | lsst-sqre/lander | lander/main.py | main | def main():
"""Entrypoint for ``lander`` executable."""
args = parse_args()
config_logger(args)
logger = structlog.get_logger(__name__)
if args.show_version:
# only print the version
print_version()
sys.exit(0)
version = pkg_resources.get_distribution('lander').version
... | python | def main():
"""Entrypoint for ``lander`` executable."""
args = parse_args()
config_logger(args)
logger = structlog.get_logger(__name__)
if args.show_version:
# only print the version
print_version()
sys.exit(0)
version = pkg_resources.get_distribution('lander').version
... | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"parse_args",
"(",
")",
"config_logger",
"(",
"args",
")",
"logger",
"=",
"structlog",
".",
"get_logger",
"(",
"__name__",
")",
"if",
"args",
".",
"show_version",
":",
"# only print the version",
"print_version",
"(... | Entrypoint for ``lander`` executable. | [
"Entrypoint",
"for",
"lander",
"executable",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/main.py#L171-L200 |
41,226 | brap/brap | brap/graph.py | Graph.insert_node | def insert_node(self, node):
"""
Adds node if name is available or pre-existing node
returns True if added
returns False if not added
"""
if self._is_node_reserved(node):
return False
# Put node in map
self._node_map[node.get_id()] = node
... | python | def insert_node(self, node):
"""
Adds node if name is available or pre-existing node
returns True if added
returns False if not added
"""
if self._is_node_reserved(node):
return False
# Put node in map
self._node_map[node.get_id()] = node
... | [
"def",
"insert_node",
"(",
"self",
",",
"node",
")",
":",
"if",
"self",
".",
"_is_node_reserved",
"(",
"node",
")",
":",
"return",
"False",
"# Put node in map",
"self",
".",
"_node_map",
"[",
"node",
".",
"get_id",
"(",
")",
"]",
"=",
"node",
"return",
... | Adds node if name is available or pre-existing node
returns True if added
returns False if not added | [
"Adds",
"node",
"if",
"name",
"is",
"available",
"or",
"pre",
"-",
"existing",
"node",
"returns",
"True",
"if",
"added",
"returns",
"False",
"if",
"not",
"added"
] | 227d1b6ce2799b7caf1d98d8805e821d19d0969b | https://github.com/brap/brap/blob/227d1b6ce2799b7caf1d98d8805e821d19d0969b/brap/graph.py#L16-L27 |
41,227 | Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | Locations.join | def join(self, distbase, location):
"""Join 'distbase' and 'location' in such way that the
result is a valid scp destination.
"""
sep = ''
if distbase and distbase[-1] not in (':', '/'):
sep = '/'
return distbase + sep + location | python | def join(self, distbase, location):
"""Join 'distbase' and 'location' in such way that the
result is a valid scp destination.
"""
sep = ''
if distbase and distbase[-1] not in (':', '/'):
sep = '/'
return distbase + sep + location | [
"def",
"join",
"(",
"self",
",",
"distbase",
",",
"location",
")",
":",
"sep",
"=",
"''",
"if",
"distbase",
"and",
"distbase",
"[",
"-",
"1",
"]",
"not",
"in",
"(",
"':'",
",",
"'/'",
")",
":",
"sep",
"=",
"'/'",
"return",
"distbase",
"+",
"sep",... | Join 'distbase' and 'location' in such way that the
result is a valid scp destination. | [
"Join",
"distbase",
"and",
"location",
"in",
"such",
"way",
"that",
"the",
"result",
"is",
"a",
"valid",
"scp",
"destination",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L182-L189 |
41,228 | Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | Locations.get_location | def get_location(self, location, depth=0):
"""Resolve aliases and apply distbase.
"""
if not location:
return []
if location in self.aliases:
res = []
if depth > MAXALIASDEPTH:
err_exit('Maximum alias depth exceeded: %(location)s' % loc... | python | def get_location(self, location, depth=0):
"""Resolve aliases and apply distbase.
"""
if not location:
return []
if location in self.aliases:
res = []
if depth > MAXALIASDEPTH:
err_exit('Maximum alias depth exceeded: %(location)s' % loc... | [
"def",
"get_location",
"(",
"self",
",",
"location",
",",
"depth",
"=",
"0",
")",
":",
"if",
"not",
"location",
":",
"return",
"[",
"]",
"if",
"location",
"in",
"self",
".",
"aliases",
":",
"res",
"=",
"[",
"]",
"if",
"depth",
">",
"MAXALIASDEPTH",
... | Resolve aliases and apply distbase. | [
"Resolve",
"aliases",
"and",
"apply",
"distbase",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L191-L212 |
41,229 | Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | Locations.get_default_location | def get_default_location(self):
"""Return the default location.
"""
res = []
for location in self.distdefault:
res.extend(self.get_location(location))
return res | python | def get_default_location(self):
"""Return the default location.
"""
res = []
for location in self.distdefault:
res.extend(self.get_location(location))
return res | [
"def",
"get_default_location",
"(",
"self",
")",
":",
"res",
"=",
"[",
"]",
"for",
"location",
"in",
"self",
".",
"distdefault",
":",
"res",
".",
"extend",
"(",
"self",
".",
"get_location",
"(",
"location",
")",
")",
"return",
"res"
] | Return the default location. | [
"Return",
"the",
"default",
"location",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L214-L220 |
41,230 | Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | Locations.check_empty_locations | def check_empty_locations(self, locations=None):
"""Fail if 'locations' is empty.
"""
if locations is None:
locations = self.locations
if not locations:
err_exit('mkrelease: option -d is required\n%s' % USAGE) | python | def check_empty_locations(self, locations=None):
"""Fail if 'locations' is empty.
"""
if locations is None:
locations = self.locations
if not locations:
err_exit('mkrelease: option -d is required\n%s' % USAGE) | [
"def",
"check_empty_locations",
"(",
"self",
",",
"locations",
"=",
"None",
")",
":",
"if",
"locations",
"is",
"None",
":",
"locations",
"=",
"self",
".",
"locations",
"if",
"not",
"locations",
":",
"err_exit",
"(",
"'mkrelease: option -d is required\\n%s'",
"%"... | Fail if 'locations' is empty. | [
"Fail",
"if",
"locations",
"is",
"empty",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L222-L228 |
41,231 | Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | Locations.check_valid_locations | def check_valid_locations(self, locations=None):
"""Fail if 'locations' contains bad destinations.
"""
if locations is None:
locations = self.locations
for location in locations:
if (not self.is_server(location) and
not self.is_ssh_url(location) an... | python | def check_valid_locations(self, locations=None):
"""Fail if 'locations' contains bad destinations.
"""
if locations is None:
locations = self.locations
for location in locations:
if (not self.is_server(location) and
not self.is_ssh_url(location) an... | [
"def",
"check_valid_locations",
"(",
"self",
",",
"locations",
"=",
"None",
")",
":",
"if",
"locations",
"is",
"None",
":",
"locations",
"=",
"self",
".",
"locations",
"for",
"location",
"in",
"locations",
":",
"if",
"(",
"not",
"self",
".",
"is_server",
... | Fail if 'locations' contains bad destinations. | [
"Fail",
"if",
"locations",
"contains",
"bad",
"destinations",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L230-L239 |
41,232 | Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | ReleaseMaker.list_locations | def list_locations(self):
"""Print known dist-locations and exit.
"""
known = self.defaults.get_known_locations()
for default in self.defaults.distdefault:
if default not in known:
known.add(default)
if not known:
err_exit('No locations', 0... | python | def list_locations(self):
"""Print known dist-locations and exit.
"""
known = self.defaults.get_known_locations()
for default in self.defaults.distdefault:
if default not in known:
known.add(default)
if not known:
err_exit('No locations', 0... | [
"def",
"list_locations",
"(",
"self",
")",
":",
"known",
"=",
"self",
".",
"defaults",
".",
"get_known_locations",
"(",
")",
"for",
"default",
"in",
"self",
".",
"defaults",
".",
"distdefault",
":",
"if",
"default",
"not",
"in",
"known",
":",
"known",
".... | Print known dist-locations and exit. | [
"Print",
"known",
"dist",
"-",
"locations",
"and",
"exit",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L355-L369 |
41,233 | Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | ReleaseMaker.get_uploadflags | def get_uploadflags(self, location):
"""Return uploadflags for the given server.
"""
uploadflags = []
server = self.defaults.servers[location]
if self.sign:
uploadflags.append('--sign')
elif server.sign is not None:
if server.sign:
... | python | def get_uploadflags(self, location):
"""Return uploadflags for the given server.
"""
uploadflags = []
server = self.defaults.servers[location]
if self.sign:
uploadflags.append('--sign')
elif server.sign is not None:
if server.sign:
... | [
"def",
"get_uploadflags",
"(",
"self",
",",
"location",
")",
":",
"uploadflags",
"=",
"[",
"]",
"server",
"=",
"self",
".",
"defaults",
".",
"servers",
"[",
"location",
"]",
"if",
"self",
".",
"sign",
":",
"uploadflags",
".",
"append",
"(",
"'--sign'",
... | Return uploadflags for the given server. | [
"Return",
"uploadflags",
"for",
"the",
"given",
"server",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L393-L418 |
41,234 | Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | ReleaseMaker.get_options | def get_options(self):
"""Process the command line.
"""
args = self.parse_options(self.args)
if args:
self.directory = args[0]
if self.develop:
self.skiptag = True
if not self.develop:
self.develop = self.defaults.develop
if n... | python | def get_options(self):
"""Process the command line.
"""
args = self.parse_options(self.args)
if args:
self.directory = args[0]
if self.develop:
self.skiptag = True
if not self.develop:
self.develop = self.defaults.develop
if n... | [
"def",
"get_options",
"(",
"self",
")",
":",
"args",
"=",
"self",
".",
"parse_options",
"(",
"self",
".",
"args",
")",
"if",
"args",
":",
"self",
".",
"directory",
"=",
"args",
"[",
"0",
"]",
"if",
"self",
".",
"develop",
":",
"self",
".",
"skiptag... | Process the command line. | [
"Process",
"the",
"command",
"line",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L425-L476 |
41,235 | Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | ReleaseMaker.get_package | def get_package(self):
"""Get the URL or sandbox to release.
"""
directory = self.directory
develop = self.develop
scmtype = self.scmtype
self.scm = self.scms.get_scm(scmtype, directory)
if self.scm.is_valid_url(directory):
directory = self.urlparser... | python | def get_package(self):
"""Get the URL or sandbox to release.
"""
directory = self.directory
develop = self.develop
scmtype = self.scmtype
self.scm = self.scms.get_scm(scmtype, directory)
if self.scm.is_valid_url(directory):
directory = self.urlparser... | [
"def",
"get_package",
"(",
"self",
")",
":",
"directory",
"=",
"self",
".",
"directory",
"develop",
"=",
"self",
".",
"develop",
"scmtype",
"=",
"self",
".",
"scmtype",
"self",
".",
"scm",
"=",
"self",
".",
"scms",
".",
"get_scm",
"(",
"scmtype",
",",
... | Get the URL or sandbox to release. | [
"Get",
"the",
"URL",
"or",
"sandbox",
"to",
"release",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L478-L504 |
41,236 | Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | ReleaseMaker.make_release | def make_release(self):
"""Build and distribute the package.
"""
directory = self.directory
infoflags = self.infoflags
branch = self.branch
develop = self.develop
scmtype = self.scm.name
tempdir = abspath(tempfile.mkdtemp(prefix='mkrelease-'))
try... | python | def make_release(self):
"""Build and distribute the package.
"""
directory = self.directory
infoflags = self.infoflags
branch = self.branch
develop = self.develop
scmtype = self.scm.name
tempdir = abspath(tempfile.mkdtemp(prefix='mkrelease-'))
try... | [
"def",
"make_release",
"(",
"self",
")",
":",
"directory",
"=",
"self",
".",
"directory",
"infoflags",
"=",
"self",
".",
"infoflags",
"branch",
"=",
"self",
".",
"branch",
"develop",
"=",
"self",
".",
"develop",
"scmtype",
"=",
"self",
".",
"scm",
".",
... | Build and distribute the package. | [
"Build",
"and",
"distribute",
"the",
"package",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L506-L578 |
41,237 | asphalt-framework/asphalt-py4j | asphalt/py4j/component.py | Py4JComponent.configure_gateway | def configure_gateway(
cls, launch_jvm: bool = True,
gateway: Union[GatewayParameters, Dict[str, Any]] = None,
callback_server: Union[CallbackServerParameters, Dict[str, Any]] = False,
javaopts: Iterable[str] = (), classpath: Iterable[str] = ''):
"""
Confi... | python | def configure_gateway(
cls, launch_jvm: bool = True,
gateway: Union[GatewayParameters, Dict[str, Any]] = None,
callback_server: Union[CallbackServerParameters, Dict[str, Any]] = False,
javaopts: Iterable[str] = (), classpath: Iterable[str] = ''):
"""
Confi... | [
"def",
"configure_gateway",
"(",
"cls",
",",
"launch_jvm",
":",
"bool",
"=",
"True",
",",
"gateway",
":",
"Union",
"[",
"GatewayParameters",
",",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
",",
"callback_server",
":",
"Union",
"[",
"CallbackS... | Configure a Py4J gateway.
:param launch_jvm: ``True`` to spawn a Java Virtual Machine in a subprocess and connect to
it, ``False`` to connect to an existing Py4J enabled JVM
:param gateway: either a :class:`~py4j.java_gateway.GatewayParameters` object or a
dictionary of keyword ... | [
"Configure",
"a",
"Py4J",
"gateway",
"."
] | e803c696967e9a57c84397b33d3b0651b6f2d08c | https://github.com/asphalt-framework/asphalt-py4j/blob/e803c696967e9a57c84397b33d3b0651b6f2d08c/asphalt/py4j/component.py#L48-L89 |
41,238 | dariusbakunas/rawdisk | rawdisk/plugins/filesystems/ntfs/ntfs_volume.py | NtfsVolume.load | def load(self, filename, offset):
"""Loads NTFS volume information
Args:
filename (str): Path to file/device to read the volume \
information from.
offset (uint): Valid NTFS partition offset from the beginning \
of the file/device.
Raises:
... | python | def load(self, filename, offset):
"""Loads NTFS volume information
Args:
filename (str): Path to file/device to read the volume \
information from.
offset (uint): Valid NTFS partition offset from the beginning \
of the file/device.
Raises:
... | [
"def",
"load",
"(",
"self",
",",
"filename",
",",
"offset",
")",
":",
"self",
".",
"offset",
"=",
"offset",
"self",
".",
"filename",
"=",
"filename",
"self",
".",
"bootsector",
"=",
"BootSector",
"(",
"filename",
"=",
"filename",
",",
"length",
"=",
"N... | Loads NTFS volume information
Args:
filename (str): Path to file/device to read the volume \
information from.
offset (uint): Valid NTFS partition offset from the beginning \
of the file/device.
Raises:
IOError: If source file/device does not... | [
"Loads",
"NTFS",
"volume",
"information"
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/plugins/filesystems/ntfs/ntfs_volume.py#L39-L67 |
41,239 | dariusbakunas/rawdisk | rawdisk/plugins/filesystems/ntfs/ntfs_volume.py | NtfsVolume._get_mft_zone_size | def _get_mft_zone_size(self, num_clusters, mft_zone_multiplier=1):
"""Returns mft zone size in clusters.
From ntfs_progs.1.22."""
sizes = {
4: num_clusters >> 1, # 50%
3: (num_clusters * 3) >> 3, # 37,5%
2: num_clusters >> 2, # 25%
... | python | def _get_mft_zone_size(self, num_clusters, mft_zone_multiplier=1):
"""Returns mft zone size in clusters.
From ntfs_progs.1.22."""
sizes = {
4: num_clusters >> 1, # 50%
3: (num_clusters * 3) >> 3, # 37,5%
2: num_clusters >> 2, # 25%
... | [
"def",
"_get_mft_zone_size",
"(",
"self",
",",
"num_clusters",
",",
"mft_zone_multiplier",
"=",
"1",
")",
":",
"sizes",
"=",
"{",
"4",
":",
"num_clusters",
">>",
"1",
",",
"# 50%",
"3",
":",
"(",
"num_clusters",
"*",
"3",
")",
">>",
"3",
",",
"# 37,5%"... | Returns mft zone size in clusters.
From ntfs_progs.1.22. | [
"Returns",
"mft",
"zone",
"size",
"in",
"clusters",
".",
"From",
"ntfs_progs",
".",
"1",
".",
"22",
"."
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/plugins/filesystems/ntfs/ntfs_volume.py#L88-L98 |
41,240 | childsish/lhc-python | lhc/itertools/sorted_iterator_merger.py | SortedIteratorMerger.close | def close(self):
"""
Closes all the iterators.
This is particularly important if the iterators are files.
"""
if hasattr(self, 'iterators'):
for it in self.iterators:
if hasattr(it, 'close'):
it.close() | python | def close(self):
"""
Closes all the iterators.
This is particularly important if the iterators are files.
"""
if hasattr(self, 'iterators'):
for it in self.iterators:
if hasattr(it, 'close'):
it.close() | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'iterators'",
")",
":",
"for",
"it",
"in",
"self",
".",
"iterators",
":",
"if",
"hasattr",
"(",
"it",
",",
"'close'",
")",
":",
"it",
".",
"close",
"(",
")"
] | Closes all the iterators.
This is particularly important if the iterators are files. | [
"Closes",
"all",
"the",
"iterators",
"."
] | 0a669f46a40a39f24d28665e8b5b606dc7e86beb | https://github.com/childsish/lhc-python/blob/0a669f46a40a39f24d28665e8b5b606dc7e86beb/lhc/itertools/sorted_iterator_merger.py#L38-L47 |
41,241 | childsish/lhc-python | lhc/itertools/sorted_iterator_merger.py | SortedIteratorMerger._update_sorting | def _update_sorting(self):
""" Insert new entries into the merged iterator.
:param sorted_tops: A SortedDict.
:param tops: The most recent entry from each iterator.
:param idxs: The indices to update.
"""
key = self.key
sorted_tops = self.sorted_tops
tops... | python | def _update_sorting(self):
""" Insert new entries into the merged iterator.
:param sorted_tops: A SortedDict.
:param tops: The most recent entry from each iterator.
:param idxs: The indices to update.
"""
key = self.key
sorted_tops = self.sorted_tops
tops... | [
"def",
"_update_sorting",
"(",
"self",
")",
":",
"key",
"=",
"self",
".",
"key",
"sorted_tops",
"=",
"self",
".",
"sorted_tops",
"tops",
"=",
"self",
".",
"tops",
"iterators",
"=",
"self",
".",
"iterators",
"for",
"idx",
"in",
"self",
".",
"idxs",
":",... | Insert new entries into the merged iterator.
:param sorted_tops: A SortedDict.
:param tops: The most recent entry from each iterator.
:param idxs: The indices to update. | [
"Insert",
"new",
"entries",
"into",
"the",
"merged",
"iterator",
"."
] | 0a669f46a40a39f24d28665e8b5b606dc7e86beb | https://github.com/childsish/lhc-python/blob/0a669f46a40a39f24d28665e8b5b606dc7e86beb/lhc/itertools/sorted_iterator_merger.py#L49-L72 |
41,242 | CMUSTRUDEL/strudel.utils | stutils/email_utils.py | domain_user_stats | def domain_user_stats():
# type: () -> pd.Series
""" Get number of distinct email addresses in observed domains
TODO: get up to date with new projects layout
How to build email_domain_users.csv:
from collections import defaultdict
import logging
from common import utils as common
impor... | python | def domain_user_stats():
# type: () -> pd.Series
""" Get number of distinct email addresses in observed domains
TODO: get up to date with new projects layout
How to build email_domain_users.csv:
from collections import defaultdict
import logging
from common import utils as common
impor... | [
"def",
"domain_user_stats",
"(",
")",
":",
"# type: () -> pd.Series",
"fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"\"email_domain_users.csv\"",
")",
"stats",
"=",
"pd",
".",
"read_csv",
"... | Get number of distinct email addresses in observed domains
TODO: get up to date with new projects layout
How to build email_domain_users.csv:
from collections import defaultdict
import logging
from common import utils as common
import stscraper as scraper
log = logging.getLogger("domain_u... | [
"Get",
"number",
"of",
"distinct",
"email",
"addresses",
"in",
"observed",
"domains"
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/email_utils.py#L149-L186 |
41,243 | CMUSTRUDEL/strudel.utils | stutils/email_utils.py | is_university | def is_university(addr):
# type: (Union[str, unicode]) -> bool
""" Check if provided email has a university domain
- either in .edu domain
(except public sercices like england.edu or australia.edu)
- or in .edu.TLD (non-US based institutions, like edu.au)
- or listed in a public list of uni... | python | def is_university(addr):
# type: (Union[str, unicode]) -> bool
""" Check if provided email has a university domain
- either in .edu domain
(except public sercices like england.edu or australia.edu)
- or in .edu.TLD (non-US based institutions, like edu.au)
- or listed in a public list of uni... | [
"def",
"is_university",
"(",
"addr",
")",
":",
"# type: (Union[str, unicode]) -> bool",
"addr_domain",
"=",
"domain",
"(",
"addr",
")",
"if",
"not",
"addr_domain",
":",
"# invalid email",
"return",
"False",
"chunks",
"=",
"addr_domain",
".",
"split",
"(",
"\".\"",... | Check if provided email has a university domain
- either in .edu domain
(except public sercices like england.edu or australia.edu)
- or in .edu.TLD (non-US based institutions, like edu.au)
- or listed in a public list of universities
since universities often have department addresses as wel... | [
"Check",
"if",
"provided",
"email",
"has",
"a",
"university",
"domain"
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/email_utils.py#L211-L243 |
41,244 | CMUSTRUDEL/strudel.utils | stutils/email_utils.py | is_public | def is_public(addr):
# type: (Union[str, unicode]) -> bool
""" Check if the passed email registered at a free pubic mail server
:param addr: email address to check
:return: bool
>>> is_public("john@cmu.edu")
False
>>> is_public("john@gmail.com")
True
"""
addr_domain = domain(add... | python | def is_public(addr):
# type: (Union[str, unicode]) -> bool
""" Check if the passed email registered at a free pubic mail server
:param addr: email address to check
:return: bool
>>> is_public("john@cmu.edu")
False
>>> is_public("john@gmail.com")
True
"""
addr_domain = domain(add... | [
"def",
"is_public",
"(",
"addr",
")",
":",
"# type: (Union[str, unicode]) -> bool",
"addr_domain",
"=",
"domain",
"(",
"addr",
")",
"if",
"not",
"addr_domain",
":",
"# anybody can use invalid email",
"return",
"True",
"chunks",
"=",
"addr_domain",
".",
"rsplit",
"("... | Check if the passed email registered at a free pubic mail server
:param addr: email address to check
:return: bool
>>> is_public("john@cmu.edu")
False
>>> is_public("john@gmail.com")
True | [
"Check",
"if",
"the",
"passed",
"email",
"registered",
"at",
"a",
"free",
"pubic",
"mail",
"server"
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/email_utils.py#L246-L265 |
41,245 | SeattleTestbed/seash | pyreadline/console/ironpython_console.py | Console.write_color | def write_color(self, text, attr=None):
'''write text at current cursor position and interpret color escapes.
return the number of characters written.
'''
log(u'write_color("%s", %s)' % (text, attr))
chunks = self.terminal_escape.split(text)
log(u'chunks=%s' % rep... | python | def write_color(self, text, attr=None):
'''write text at current cursor position and interpret color escapes.
return the number of characters written.
'''
log(u'write_color("%s", %s)' % (text, attr))
chunks = self.terminal_escape.split(text)
log(u'chunks=%s' % rep... | [
"def",
"write_color",
"(",
"self",
",",
"text",
",",
"attr",
"=",
"None",
")",
":",
"log",
"(",
"u'write_color(\"%s\", %s)'",
"%",
"(",
"text",
",",
"attr",
")",
")",
"chunks",
"=",
"self",
".",
"terminal_escape",
".",
"split",
"(",
"text",
")",
"log",... | write text at current cursor position and interpret color escapes.
return the number of characters written. | [
"write",
"text",
"at",
"current",
"cursor",
"position",
"and",
"interpret",
"color",
"escapes",
".",
"return",
"the",
"number",
"of",
"characters",
"written",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/ironpython_console.py#L195-L222 |
41,246 | RI-imaging/qpformat | qpformat/file_formats/series_zip_tif_holo.py | SeriesZipTifHolo.files | def files(self):
"""List of hologram data file names in the input zip file"""
if self._files is None:
self._files = SeriesZipTifHolo._index_files(self.path)
return self._files | python | def files(self):
"""List of hologram data file names in the input zip file"""
if self._files is None:
self._files = SeriesZipTifHolo._index_files(self.path)
return self._files | [
"def",
"files",
"(",
"self",
")",
":",
"if",
"self",
".",
"_files",
"is",
"None",
":",
"self",
".",
"_files",
"=",
"SeriesZipTifHolo",
".",
"_index_files",
"(",
"self",
".",
"path",
")",
"return",
"self",
".",
"_files"
] | List of hologram data file names in the input zip file | [
"List",
"of",
"hologram",
"data",
"file",
"names",
"in",
"the",
"input",
"zip",
"file"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/series_zip_tif_holo.py#L57-L61 |
41,247 | RI-imaging/qpformat | qpformat/file_formats/series_zip_tif_holo.py | SeriesZipTifHolo.get_time | def get_time(self, idx):
"""Time for each TIFF file
If there are no metadata keyword arguments defined for the
TIFF file format, then the zip file `date_time` value is
used.
"""
# first try to get the time from the TIFF file
# (possible meta data keywords)
... | python | def get_time(self, idx):
"""Time for each TIFF file
If there are no metadata keyword arguments defined for the
TIFF file format, then the zip file `date_time` value is
used.
"""
# first try to get the time from the TIFF file
# (possible meta data keywords)
... | [
"def",
"get_time",
"(",
"self",
",",
"idx",
")",
":",
"# first try to get the time from the TIFF file",
"# (possible meta data keywords)",
"ds",
"=",
"self",
".",
"_get_dataset",
"(",
"idx",
")",
"thetime",
"=",
"ds",
".",
"get_time",
"(",
")",
"if",
"np",
".",
... | Time for each TIFF file
If there are no metadata keyword arguments defined for the
TIFF file format, then the zip file `date_time` value is
used. | [
"Time",
"for",
"each",
"TIFF",
"file"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/series_zip_tif_holo.py#L63-L80 |
41,248 | asascience-open/paegan-transport | paegan/transport/parallel_manager.py | DataController.get_remote_data | def get_remote_data(self, localvars, remotevars, inds, shape):
"""
Method that does the updating of local netcdf cache
with remote data
"""
# If user specifies 'all' then entire xy domain is
# grabbed, default is 4, specified in the model_controller
if sel... | python | def get_remote_data(self, localvars, remotevars, inds, shape):
"""
Method that does the updating of local netcdf cache
with remote data
"""
# If user specifies 'all' then entire xy domain is
# grabbed, default is 4, specified in the model_controller
if sel... | [
"def",
"get_remote_data",
"(",
"self",
",",
"localvars",
",",
"remotevars",
",",
"inds",
",",
"shape",
")",
":",
"# If user specifies 'all' then entire xy domain is",
"# grabbed, default is 4, specified in the model_controller",
"if",
"self",
".",
"horiz_size",
"==",
"'all'... | Method that does the updating of local netcdf cache
with remote data | [
"Method",
"that",
"does",
"the",
"updating",
"of",
"local",
"netcdf",
"cache",
"with",
"remote",
"data"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/parallel_manager.py#L114-L153 |
41,249 | asascience-open/paegan-transport | paegan/transport/parallel_manager.py | ForceParticle.need_data | def need_data(self, i):
"""
Method to test if cache contains the data that
the particle needs
"""
# If we are not caching, we always grab data from the raw source
if self.caching is False:
return False
logger.debug("Checking cache for data av... | python | def need_data(self, i):
"""
Method to test if cache contains the data that
the particle needs
"""
# If we are not caching, we always grab data from the raw source
if self.caching is False:
return False
logger.debug("Checking cache for data av... | [
"def",
"need_data",
"(",
"self",
",",
"i",
")",
":",
"# If we are not caching, we always grab data from the raw source",
"if",
"self",
".",
"caching",
"is",
"False",
":",
"return",
"False",
"logger",
".",
"debug",
"(",
"\"Checking cache for data availability at %s.\"",
... | Method to test if cache contains the data that
the particle needs | [
"Method",
"to",
"test",
"if",
"cache",
"contains",
"the",
"data",
"that",
"the",
"particle",
"needs"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/parallel_manager.py#L485-L527 |
41,250 | asascience-open/paegan-transport | paegan/transport/parallel_manager.py | ForceParticle.linterp | def linterp(self, setx, sety, x):
"""
Linear interp of model data values between time steps
"""
if math.isnan(sety[0]) or math.isnan(setx[0]):
return np.nan
#if math.isnan(sety[0]):
# sety[0] = 0.
#if math.isnan(sety[1]):
# sety[1] = ... | python | def linterp(self, setx, sety, x):
"""
Linear interp of model data values between time steps
"""
if math.isnan(sety[0]) or math.isnan(setx[0]):
return np.nan
#if math.isnan(sety[0]):
# sety[0] = 0.
#if math.isnan(sety[1]):
# sety[1] = ... | [
"def",
"linterp",
"(",
"self",
",",
"setx",
",",
"sety",
",",
"x",
")",
":",
"if",
"math",
".",
"isnan",
"(",
"sety",
"[",
"0",
"]",
")",
"or",
"math",
".",
"isnan",
"(",
"setx",
"[",
"0",
"]",
")",
":",
"return",
"np",
".",
"nan",
"#if math.... | Linear interp of model data values between time steps | [
"Linear",
"interp",
"of",
"model",
"data",
"values",
"between",
"time",
"steps"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/parallel_manager.py#L529-L539 |
41,251 | asascience-open/paegan-transport | paegan/transport/parallel_manager.py | ForceParticle.boundary_interaction | def boundary_interaction(self, **kwargs):
"""
Returns a list of Location4D objects
"""
particle = kwargs.pop('particle')
starting = kwargs.pop('starting')
ending = kwargs.pop('ending')
# shoreline
if self.useshore:
intersection_point = sel... | python | def boundary_interaction(self, **kwargs):
"""
Returns a list of Location4D objects
"""
particle = kwargs.pop('particle')
starting = kwargs.pop('starting')
ending = kwargs.pop('ending')
# shoreline
if self.useshore:
intersection_point = sel... | [
"def",
"boundary_interaction",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"particle",
"=",
"kwargs",
".",
"pop",
"(",
"'particle'",
")",
"starting",
"=",
"kwargs",
".",
"pop",
"(",
"'starting'",
")",
"ending",
"=",
"kwargs",
".",
"pop",
"(",
"'end... | Returns a list of Location4D objects | [
"Returns",
"a",
"list",
"of",
"Location4D",
"objects"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/parallel_manager.py#L918-L967 |
41,252 | yougov/vr.common | vr/common/paths.py | get_buildfile_path | def get_buildfile_path(settings):
"""
Path to which a build tarball should be downloaded.
"""
base = os.path.basename(settings.build_url)
return os.path.join(BUILDS_ROOT, base) | python | def get_buildfile_path(settings):
"""
Path to which a build tarball should be downloaded.
"""
base = os.path.basename(settings.build_url)
return os.path.join(BUILDS_ROOT, base) | [
"def",
"get_buildfile_path",
"(",
"settings",
")",
":",
"base",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"settings",
".",
"build_url",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"BUILDS_ROOT",
",",
"base",
")"
] | Path to which a build tarball should be downloaded. | [
"Path",
"to",
"which",
"a",
"build",
"tarball",
"should",
"be",
"downloaded",
"."
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/paths.py#L52-L57 |
41,253 | brews/snakebacon | snakebacon/mcmcbackends/__init__.py | Bacon.prior_dates | def prior_dates(*args, **kwargs):
"""Get the prior distribution of calibrated radiocarbon dates"""
try:
chron = args[0]
except IndexError:
chron = kwargs['coredates']
d_r = np.array(kwargs['d_r'])
d_std = np.array(kwargs['d_std'])
t_a = np.array(k... | python | def prior_dates(*args, **kwargs):
"""Get the prior distribution of calibrated radiocarbon dates"""
try:
chron = args[0]
except IndexError:
chron = kwargs['coredates']
d_r = np.array(kwargs['d_r'])
d_std = np.array(kwargs['d_std'])
t_a = np.array(k... | [
"def",
"prior_dates",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"chron",
"=",
"args",
"[",
"0",
"]",
"except",
"IndexError",
":",
"chron",
"=",
"kwargs",
"[",
"'coredates'",
"]",
"d_r",
"=",
"np",
".",
"array",
"(",
"kwargs",... | Get the prior distribution of calibrated radiocarbon dates | [
"Get",
"the",
"prior",
"distribution",
"of",
"calibrated",
"radiocarbon",
"dates"
] | f5363d0d1225912adc30031bf2c13b54000de8f2 | https://github.com/brews/snakebacon/blob/f5363d0d1225912adc30031bf2c13b54000de8f2/snakebacon/mcmcbackends/__init__.py#L11-L49 |
41,254 | brews/snakebacon | snakebacon/mcmcbackends/__init__.py | Bacon.prior_sediment_rate | def prior_sediment_rate(*args, **kwargs):
"""Get the prior density of sediment rates
Returns
-------
y : ndarray
Array giving the density.
x : ndarray
Array of sediment accumulation values (yr/cm) over which the density was evaluated.
"""
... | python | def prior_sediment_rate(*args, **kwargs):
"""Get the prior density of sediment rates
Returns
-------
y : ndarray
Array giving the density.
x : ndarray
Array of sediment accumulation values (yr/cm) over which the density was evaluated.
"""
... | [
"def",
"prior_sediment_rate",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# PlotAccPrior @ Bacon.R ln 113 -> ln 1097-1115",
"# alpha = acc_shape, beta = acc_shape / acc_mean",
"# TODO(brews): Check that these stats are correctly translated to scipy.stats distribs.",
"acc_mean",... | Get the prior density of sediment rates
Returns
-------
y : ndarray
Array giving the density.
x : ndarray
Array of sediment accumulation values (yr/cm) over which the density was evaluated. | [
"Get",
"the",
"prior",
"density",
"of",
"sediment",
"rates"
] | f5363d0d1225912adc30031bf2c13b54000de8f2 | https://github.com/brews/snakebacon/blob/f5363d0d1225912adc30031bf2c13b54000de8f2/snakebacon/mcmcbackends/__init__.py#L52-L70 |
41,255 | brews/snakebacon | snakebacon/mcmcbackends/__init__.py | Bacon.prior_sediment_memory | def prior_sediment_memory(*args, **kwargs):
"""Get the prior density of sediment memory
Returns
-------
y : ndarray
Array giving the density.
x : ndarray
Array of Memory (ratio) values over which the density was evaluated.
"""
# "plot the ... | python | def prior_sediment_memory(*args, **kwargs):
"""Get the prior density of sediment memory
Returns
-------
y : ndarray
Array giving the density.
x : ndarray
Array of Memory (ratio) values over which the density was evaluated.
"""
# "plot the ... | [
"def",
"prior_sediment_memory",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# \"plot the prior for the memory (= accumulation rate varibility between neighbouring depths)\"",
"# PlotMemPrior @ Bacon.R ln 114 -> ln 1119 - 1141",
"# w_a = mem_strength * mem_mean, w_b = mem_strength... | Get the prior density of sediment memory
Returns
-------
y : ndarray
Array giving the density.
x : ndarray
Array of Memory (ratio) values over which the density was evaluated. | [
"Get",
"the",
"prior",
"density",
"of",
"sediment",
"memory"
] | f5363d0d1225912adc30031bf2c13b54000de8f2 | https://github.com/brews/snakebacon/blob/f5363d0d1225912adc30031bf2c13b54000de8f2/snakebacon/mcmcbackends/__init__.py#L73-L92 |
41,256 | inveniosoftware-attic/invenio-client | invenio_client/contrib/cds.py | CDSInvenioConnector._init_browser | def _init_browser(self):
"""Update this everytime the CERN SSO login form is refactored."""
self.browser = splinter.Browser('phantomjs')
self.browser.visit(self.server_url)
self.browser.find_link_by_partial_text("Sign in").click()
self.browser.fill(
'ctl00$ctl00$NICEM... | python | def _init_browser(self):
"""Update this everytime the CERN SSO login form is refactored."""
self.browser = splinter.Browser('phantomjs')
self.browser.visit(self.server_url)
self.browser.find_link_by_partial_text("Sign in").click()
self.browser.fill(
'ctl00$ctl00$NICEM... | [
"def",
"_init_browser",
"(",
"self",
")",
":",
"self",
".",
"browser",
"=",
"splinter",
".",
"Browser",
"(",
"'phantomjs'",
")",
"self",
".",
"browser",
".",
"visit",
"(",
"self",
".",
"server_url",
")",
"self",
".",
"browser",
".",
"find_link_by_partial_t... | Update this everytime the CERN SSO login form is refactored. | [
"Update",
"this",
"everytime",
"the",
"CERN",
"SSO",
"login",
"form",
"is",
"refactored",
"."
] | 3f9ddb6f3b3ce3a21d399d1098d6769bf05cdd6c | https://github.com/inveniosoftware-attic/invenio-client/blob/3f9ddb6f3b3ce3a21d399d1098d6769bf05cdd6c/invenio_client/contrib/cds.py#L46-L58 |
41,257 | koehlma/pygrooveshark | src/grooveshark/classes/song.py | Song.download | def download(self, directory='~/Music', song_name='%a - %s - %A'):
"""
Download a song to a directory.
:param directory: A system file path.
:param song_name: A name that will be formatted with :meth:`format`.
:return: The formatted song name.
"""
formatted = sel... | python | def download(self, directory='~/Music', song_name='%a - %s - %A'):
"""
Download a song to a directory.
:param directory: A system file path.
:param song_name: A name that will be formatted with :meth:`format`.
:return: The formatted song name.
"""
formatted = sel... | [
"def",
"download",
"(",
"self",
",",
"directory",
"=",
"'~/Music'",
",",
"song_name",
"=",
"'%a - %s - %A'",
")",
":",
"formatted",
"=",
"self",
".",
"format",
"(",
"song_name",
")",
"path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"directory",
")... | Download a song to a directory.
:param directory: A system file path.
:param song_name: A name that will be formatted with :meth:`format`.
:return: The formatted song name. | [
"Download",
"a",
"song",
"to",
"a",
"directory",
"."
] | 17673758ac12f54dc26ac879c30ea44f13b81057 | https://github.com/koehlma/pygrooveshark/blob/17673758ac12f54dc26ac879c30ea44f13b81057/src/grooveshark/classes/song.py#L203-L219 |
41,258 | koehlma/pygrooveshark | src/grooveshark/classes/song.py | Song.safe_download | def safe_download(self):
"""Download a song respecting Grooveshark's API.
:return: The raw song data.
"""
def _markStreamKeyOver30Seconds(stream):
self._connection.request(
'markStreamKeyOver30Seconds',
{'streamServerID': stream.ip,
... | python | def safe_download(self):
"""Download a song respecting Grooveshark's API.
:return: The raw song data.
"""
def _markStreamKeyOver30Seconds(stream):
self._connection.request(
'markStreamKeyOver30Seconds',
{'streamServerID': stream.ip,
... | [
"def",
"safe_download",
"(",
"self",
")",
":",
"def",
"_markStreamKeyOver30Seconds",
"(",
"stream",
")",
":",
"self",
".",
"_connection",
".",
"request",
"(",
"'markStreamKeyOver30Seconds'",
",",
"{",
"'streamServerID'",
":",
"stream",
".",
"ip",
",",
"'artistID... | Download a song respecting Grooveshark's API.
:return: The raw song data. | [
"Download",
"a",
"song",
"respecting",
"Grooveshark",
"s",
"API",
"."
] | 17673758ac12f54dc26ac879c30ea44f13b81057 | https://github.com/koehlma/pygrooveshark/blob/17673758ac12f54dc26ac879c30ea44f13b81057/src/grooveshark/classes/song.py#L221-L258 |
41,259 | helixyte/everest | everest/representers/config.py | RepresenterConfiguration.copy | def copy(self):
"""
Return a copy of this configuration.
"""
return self.__class__(options=self.__options,
attribute_options=self.__attribute_options) | python | def copy(self):
"""
Return a copy of this configuration.
"""
return self.__class__(options=self.__options,
attribute_options=self.__attribute_options) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"options",
"=",
"self",
".",
"__options",
",",
"attribute_options",
"=",
"self",
".",
"__attribute_options",
")"
] | Return a copy of this configuration. | [
"Return",
"a",
"copy",
"of",
"this",
"configuration",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/config.py#L78-L83 |
41,260 | helixyte/everest | everest/representers/config.py | RepresenterConfiguration.get_option | def get_option(self, name):
"""
Returns the value for the specified generic configuration option.
:returns: configuration option value or `None`, if the option was not
set.
"""
self.__validate_option_name(name)
return self.__options.get(name, None) | python | def get_option(self, name):
"""
Returns the value for the specified generic configuration option.
:returns: configuration option value or `None`, if the option was not
set.
"""
self.__validate_option_name(name)
return self.__options.get(name, None) | [
"def",
"get_option",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"__validate_option_name",
"(",
"name",
")",
"return",
"self",
".",
"__options",
".",
"get",
"(",
"name",
",",
"None",
")"
] | Returns the value for the specified generic configuration option.
:returns: configuration option value or `None`, if the option was not
set. | [
"Returns",
"the",
"value",
"for",
"the",
"specified",
"generic",
"configuration",
"option",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/config.py#L93-L101 |
41,261 | helixyte/everest | everest/representers/config.py | RepresenterConfiguration.set_option | def set_option(self, name, value):
"""
Sets the specified generic configuration option to the given value.
"""
self.__validate_option_name(name)
self.__options[name] = value | python | def set_option(self, name, value):
"""
Sets the specified generic configuration option to the given value.
"""
self.__validate_option_name(name)
self.__options[name] = value | [
"def",
"set_option",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"self",
".",
"__validate_option_name",
"(",
"name",
")",
"self",
".",
"__options",
"[",
"name",
"]",
"=",
"value"
] | Sets the specified generic configuration option to the given value. | [
"Sets",
"the",
"specified",
"generic",
"configuration",
"option",
"to",
"the",
"given",
"value",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/config.py#L103-L108 |
41,262 | helixyte/everest | everest/representers/config.py | RepresenterConfiguration.set_attribute_option | def set_attribute_option(self, attribute, option_name, option_value):
"""
Sets the given attribute option to the given value for the specified
attribute.
"""
self.__validate_attribute_option_name(option_name)
attribute_key = self.__make_key(attribute)
mp_options =... | python | def set_attribute_option(self, attribute, option_name, option_value):
"""
Sets the given attribute option to the given value for the specified
attribute.
"""
self.__validate_attribute_option_name(option_name)
attribute_key = self.__make_key(attribute)
mp_options =... | [
"def",
"set_attribute_option",
"(",
"self",
",",
"attribute",
",",
"option_name",
",",
"option_value",
")",
":",
"self",
".",
"__validate_attribute_option_name",
"(",
"option_name",
")",
"attribute_key",
"=",
"self",
".",
"__make_key",
"(",
"attribute",
")",
"mp_o... | Sets the given attribute option to the given value for the specified
attribute. | [
"Sets",
"the",
"given",
"attribute",
"option",
"to",
"the",
"given",
"value",
"for",
"the",
"specified",
"attribute",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/config.py#L116-L124 |
41,263 | helixyte/everest | everest/representers/config.py | RepresenterConfiguration.get_attribute_option | def get_attribute_option(self, attribute, option_name):
"""
Returns the value of the given attribute option for the specified
attribute.
"""
self.__validate_attribute_option_name(option_name)
attribute_key = self.__make_key(attribute)
return self.__attribute_optio... | python | def get_attribute_option(self, attribute, option_name):
"""
Returns the value of the given attribute option for the specified
attribute.
"""
self.__validate_attribute_option_name(option_name)
attribute_key = self.__make_key(attribute)
return self.__attribute_optio... | [
"def",
"get_attribute_option",
"(",
"self",
",",
"attribute",
",",
"option_name",
")",
":",
"self",
".",
"__validate_attribute_option_name",
"(",
"option_name",
")",
"attribute_key",
"=",
"self",
".",
"__make_key",
"(",
"attribute",
")",
"return",
"self",
".",
"... | Returns the value of the given attribute option for the specified
attribute. | [
"Returns",
"the",
"value",
"of",
"the",
"given",
"attribute",
"option",
"for",
"the",
"specified",
"attribute",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/config.py#L126-L133 |
41,264 | helixyte/everest | everest/representers/config.py | RepresenterConfiguration.get_attribute_options | def get_attribute_options(self, attribute=None):
"""
Returns a copy of the mapping options for the given attribute name
or a copy of all mapping options, if no attribute name is provided.
All options that were not explicitly configured are given a default
value of `None`.
... | python | def get_attribute_options(self, attribute=None):
"""
Returns a copy of the mapping options for the given attribute name
or a copy of all mapping options, if no attribute name is provided.
All options that were not explicitly configured are given a default
value of `None`.
... | [
"def",
"get_attribute_options",
"(",
"self",
",",
"attribute",
"=",
"None",
")",
":",
"attribute_key",
"=",
"self",
".",
"__make_key",
"(",
"attribute",
")",
"if",
"attribute_key",
"is",
"None",
":",
"opts",
"=",
"defaultdict",
"(",
"self",
".",
"_default_at... | Returns a copy of the mapping options for the given attribute name
or a copy of all mapping options, if no attribute name is provided.
All options that were not explicitly configured are given a default
value of `None`.
:param tuple attribute_key: attribute name or tuple specifying an
... | [
"Returns",
"a",
"copy",
"of",
"the",
"mapping",
"options",
"for",
"the",
"given",
"attribute",
"name",
"or",
"a",
"copy",
"of",
"all",
"mapping",
"options",
"if",
"no",
"attribute",
"name",
"is",
"provided",
".",
"All",
"options",
"that",
"were",
"not",
... | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/config.py#L135-L155 |
41,265 | helixyte/everest | everest/representers/config.py | RepresenterConfigTraverser.run | def run(self, visitor):
"""
Traverses this representer configuration traverser with the given
visitor.
:param visitor: :class:`RepresenterConfigVisitorBase` instance.
"""
attr_option_map = self.__config.get_attribute_options()
# Sorting the keys results in a dept... | python | def run(self, visitor):
"""
Traverses this representer configuration traverser with the given
visitor.
:param visitor: :class:`RepresenterConfigVisitorBase` instance.
"""
attr_option_map = self.__config.get_attribute_options()
# Sorting the keys results in a dept... | [
"def",
"run",
"(",
"self",
",",
"visitor",
")",
":",
"attr_option_map",
"=",
"self",
".",
"__config",
".",
"get_attribute_options",
"(",
")",
"# Sorting the keys results in a depth-first traversal, which is just",
"# what we want.",
"for",
"(",
"key",
",",
"key_attr_opt... | Traverses this representer configuration traverser with the given
visitor.
:param visitor: :class:`RepresenterConfigVisitorBase` instance. | [
"Traverses",
"this",
"representer",
"configuration",
"traverser",
"with",
"the",
"given",
"visitor",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/config.py#L200-L213 |
41,266 | expert360/cfn-params | cfnparams/resolution.py | with_retry | def with_retry(cls, methods):
"""
Wraps the given list of methods in a class with an exponential-back
retry mechanism.
"""
retry_with_backoff = retry(
retry_on_exception=lambda e: isinstance(e, BotoServerError),
wait_exponential_multiplier=1000,
wait_exponential_max=10000
... | python | def with_retry(cls, methods):
"""
Wraps the given list of methods in a class with an exponential-back
retry mechanism.
"""
retry_with_backoff = retry(
retry_on_exception=lambda e: isinstance(e, BotoServerError),
wait_exponential_multiplier=1000,
wait_exponential_max=10000
... | [
"def",
"with_retry",
"(",
"cls",
",",
"methods",
")",
":",
"retry_with_backoff",
"=",
"retry",
"(",
"retry_on_exception",
"=",
"lambda",
"e",
":",
"isinstance",
"(",
"e",
",",
"BotoServerError",
")",
",",
"wait_exponential_multiplier",
"=",
"1000",
",",
"wait_... | Wraps the given list of methods in a class with an exponential-back
retry mechanism. | [
"Wraps",
"the",
"given",
"list",
"of",
"methods",
"in",
"a",
"class",
"with",
"an",
"exponential",
"-",
"back",
"retry",
"mechanism",
"."
] | f6d9d796b8ce346e9fd916e26ed08958e5356e31 | https://github.com/expert360/cfn-params/blob/f6d9d796b8ce346e9fd916e26ed08958e5356e31/cfnparams/resolution.py#L10-L24 |
41,267 | AtomHash/evernode | evernode/classes/json.py | Json.from_file | def from_file(file_path) -> dict:
""" Load JSON file """
with io.open(file_path, 'r', encoding='utf-8') as json_stream:
return Json.parse(json_stream, True) | python | def from_file(file_path) -> dict:
""" Load JSON file """
with io.open(file_path, 'r', encoding='utf-8') as json_stream:
return Json.parse(json_stream, True) | [
"def",
"from_file",
"(",
"file_path",
")",
"->",
"dict",
":",
"with",
"io",
".",
"open",
"(",
"file_path",
",",
"'r'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"json_stream",
":",
"return",
"Json",
".",
"parse",
"(",
"json_stream",
",",
"True",
")"
... | Load JSON file | [
"Load",
"JSON",
"file"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/json.py#L55-L58 |
41,268 | AtomHash/evernode | evernode/classes/json.py | Json.safe_values | def safe_values(self, value):
""" Parse non-string values that will not serialize """
# TODO: override-able?
string_val = ""
if isinstance(value, datetime.date):
try:
string_val = value.strftime('{0}{1}{2}'.format(
current_app.config... | python | def safe_values(self, value):
""" Parse non-string values that will not serialize """
# TODO: override-able?
string_val = ""
if isinstance(value, datetime.date):
try:
string_val = value.strftime('{0}{1}{2}'.format(
current_app.config... | [
"def",
"safe_values",
"(",
"self",
",",
"value",
")",
":",
"# TODO: override-able?\r",
"string_val",
"=",
"\"\"",
"if",
"isinstance",
"(",
"value",
",",
"datetime",
".",
"date",
")",
":",
"try",
":",
"string_val",
"=",
"value",
".",
"strftime",
"(",
"'{0}{... | Parse non-string values that will not serialize | [
"Parse",
"non",
"-",
"string",
"values",
"that",
"will",
"not",
"serialize"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/json.py#L73-L91 |
41,269 | AtomHash/evernode | evernode/classes/json.py | Json.camel_case | def camel_case(self, snake_case):
""" Convert snake case to camel case """
components = snake_case.split('_')
return components[0] + "".join(x.title() for x in components[1:]) | python | def camel_case(self, snake_case):
""" Convert snake case to camel case """
components = snake_case.split('_')
return components[0] + "".join(x.title() for x in components[1:]) | [
"def",
"camel_case",
"(",
"self",
",",
"snake_case",
")",
":",
"components",
"=",
"snake_case",
".",
"split",
"(",
"'_'",
")",
"return",
"components",
"[",
"0",
"]",
"+",
"\"\"",
".",
"join",
"(",
"x",
".",
"title",
"(",
")",
"for",
"x",
"in",
"com... | Convert snake case to camel case | [
"Convert",
"snake",
"case",
"to",
"camel",
"case"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/json.py#L93-L96 |
41,270 | AtomHash/evernode | evernode/classes/json.py | Json.__find_object_children | def __find_object_children(self, obj) -> dict:
""" Convert object to flattened object """
if hasattr(obj, 'items') and \
isinstance(obj.items, types.BuiltinFunctionType):
return self.__construct_object(obj)
elif isinstance(obj, (list, tuple, set)):
r... | python | def __find_object_children(self, obj) -> dict:
""" Convert object to flattened object """
if hasattr(obj, 'items') and \
isinstance(obj.items, types.BuiltinFunctionType):
return self.__construct_object(obj)
elif isinstance(obj, (list, tuple, set)):
r... | [
"def",
"__find_object_children",
"(",
"self",
",",
"obj",
")",
"->",
"dict",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'items'",
")",
"and",
"isinstance",
"(",
"obj",
".",
"items",
",",
"types",
".",
"BuiltinFunctionType",
")",
":",
"return",
"self",
".",
... | Convert object to flattened object | [
"Convert",
"object",
"to",
"flattened",
"object"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/json.py#L98-L118 |
41,271 | AtomHash/evernode | evernode/classes/json.py | Json.__iterate_value | def __iterate_value(self, value):
""" Return value for JSON serialization """
if hasattr(value, '__dict__') or isinstance(value, dict):
return self.__find_object_children(value) # go through dict/class
elif isinstance(value, (list, tuple, set)):
return self.__constr... | python | def __iterate_value(self, value):
""" Return value for JSON serialization """
if hasattr(value, '__dict__') or isinstance(value, dict):
return self.__find_object_children(value) # go through dict/class
elif isinstance(value, (list, tuple, set)):
return self.__constr... | [
"def",
"__iterate_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"hasattr",
"(",
"value",
",",
"'__dict__'",
")",
"or",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"return",
"self",
".",
"__find_object_children",
"(",
"value",
")",
"# go through... | Return value for JSON serialization | [
"Return",
"value",
"for",
"JSON",
"serialization"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/json.py#L137-L143 |
41,272 | rajeevs1992/pyhealthvault | src/healthvaultlib/objects/vocabularykey.py | VocabularyKey.write_xml | def write_xml(self):
'''
Writes a VocabularyKey Xml as per Healthvault schema.
:returns: lxml.etree.Element representing a single VocabularyKey
'''
key = None
if self. language is not None:
lang = {}
lang['{http://www.w3.org/XML/1998/names... | python | def write_xml(self):
'''
Writes a VocabularyKey Xml as per Healthvault schema.
:returns: lxml.etree.Element representing a single VocabularyKey
'''
key = None
if self. language is not None:
lang = {}
lang['{http://www.w3.org/XML/1998/names... | [
"def",
"write_xml",
"(",
"self",
")",
":",
"key",
"=",
"None",
"if",
"self",
".",
"language",
"is",
"not",
"None",
":",
"lang",
"=",
"{",
"}",
"lang",
"[",
"'{http://www.w3.org/XML/1998/namespace}lang'",
"]",
"=",
"self",
".",
"language",
"key",
"=",
"et... | Writes a VocabularyKey Xml as per Healthvault schema.
:returns: lxml.etree.Element representing a single VocabularyKey | [
"Writes",
"a",
"VocabularyKey",
"Xml",
"as",
"per",
"Healthvault",
"schema",
"."
] | 2b6fa7c1687300bcc2e501368883fbb13dc80495 | https://github.com/rajeevs1992/pyhealthvault/blob/2b6fa7c1687300bcc2e501368883fbb13dc80495/src/healthvaultlib/objects/vocabularykey.py#L34-L67 |
41,273 | rajeevs1992/pyhealthvault | src/healthvaultlib/objects/vocabularykey.py | VocabularyKey.parse_xml | def parse_xml(self, key_xml):
'''
Parse a VocabularyKey from an Xml as per Healthvault
schema.
:param key_xml: lxml.etree.Element representing a single VocabularyKey
'''
xmlutils = XmlUtils(key_xml)
self.name = xmlutils.get_string_by_xpath('name')
... | python | def parse_xml(self, key_xml):
'''
Parse a VocabularyKey from an Xml as per Healthvault
schema.
:param key_xml: lxml.etree.Element representing a single VocabularyKey
'''
xmlutils = XmlUtils(key_xml)
self.name = xmlutils.get_string_by_xpath('name')
... | [
"def",
"parse_xml",
"(",
"self",
",",
"key_xml",
")",
":",
"xmlutils",
"=",
"XmlUtils",
"(",
"key_xml",
")",
"self",
".",
"name",
"=",
"xmlutils",
".",
"get_string_by_xpath",
"(",
"'name'",
")",
"self",
".",
"family",
"=",
"xmlutils",
".",
"get_string_by_x... | Parse a VocabularyKey from an Xml as per Healthvault
schema.
:param key_xml: lxml.etree.Element representing a single VocabularyKey | [
"Parse",
"a",
"VocabularyKey",
"from",
"an",
"Xml",
"as",
"per",
"Healthvault",
"schema",
"."
] | 2b6fa7c1687300bcc2e501368883fbb13dc80495 | https://github.com/rajeevs1992/pyhealthvault/blob/2b6fa7c1687300bcc2e501368883fbb13dc80495/src/healthvaultlib/objects/vocabularykey.py#L69-L82 |
41,274 | kxz/littlebrother | littlebrother/__main__.py | print_and_exit | def print_and_exit(results):
"""Print each result and stop the reactor."""
for success, value in results:
if success:
print value.encode(locale.getpreferredencoding())
else:
value.printTraceback() | python | def print_and_exit(results):
"""Print each result and stop the reactor."""
for success, value in results:
if success:
print value.encode(locale.getpreferredencoding())
else:
value.printTraceback() | [
"def",
"print_and_exit",
"(",
"results",
")",
":",
"for",
"success",
",",
"value",
"in",
"results",
":",
"if",
"success",
":",
"print",
"value",
".",
"encode",
"(",
"locale",
".",
"getpreferredencoding",
"(",
")",
")",
"else",
":",
"value",
".",
"printTr... | Print each result and stop the reactor. | [
"Print",
"each",
"result",
"and",
"stop",
"the",
"reactor",
"."
] | af9ec9af5c0de9a74796bb7e16a6b836286e8b9f | https://github.com/kxz/littlebrother/blob/af9ec9af5c0de9a74796bb7e16a6b836286e8b9f/littlebrother/__main__.py#L15-L21 |
41,275 | brap/brap | brap/compilers/circular_dependency_compiler.py | GraphSorter._topological_sort | def _topological_sort(self):
"""
Kahn's algorithm for Topological Sorting
- Finds cycles in graph
- Computes dependency weight
"""
sorted_graph = []
node_map = self._graph.get_nodes()
nodes = [NodeVisitor(node_map[node]) for node in node_map]
def... | python | def _topological_sort(self):
"""
Kahn's algorithm for Topological Sorting
- Finds cycles in graph
- Computes dependency weight
"""
sorted_graph = []
node_map = self._graph.get_nodes()
nodes = [NodeVisitor(node_map[node]) for node in node_map]
def... | [
"def",
"_topological_sort",
"(",
"self",
")",
":",
"sorted_graph",
"=",
"[",
"]",
"node_map",
"=",
"self",
".",
"_graph",
".",
"get_nodes",
"(",
")",
"nodes",
"=",
"[",
"NodeVisitor",
"(",
"node_map",
"[",
"node",
"]",
")",
"for",
"node",
"in",
"node_m... | Kahn's algorithm for Topological Sorting
- Finds cycles in graph
- Computes dependency weight | [
"Kahn",
"s",
"algorithm",
"for",
"Topological",
"Sorting",
"-",
"Finds",
"cycles",
"in",
"graph",
"-",
"Computes",
"dependency",
"weight"
] | 227d1b6ce2799b7caf1d98d8805e821d19d0969b | https://github.com/brap/brap/blob/227d1b6ce2799b7caf1d98d8805e821d19d0969b/brap/compilers/circular_dependency_compiler.py#L44-L85 |
41,276 | silver-castle/mach9 | mach9/config.py | Config.load_environment_vars | def load_environment_vars(self):
"""
Looks for any MACH9_ prefixed environment variables and applies
them to the configuration if present.
"""
for k, v in os.environ.items():
if k.startswith(MACH9_PREFIX):
_, config_key = k.split(MACH9_PREFIX, 1)
... | python | def load_environment_vars(self):
"""
Looks for any MACH9_ prefixed environment variables and applies
them to the configuration if present.
"""
for k, v in os.environ.items():
if k.startswith(MACH9_PREFIX):
_, config_key = k.split(MACH9_PREFIX, 1)
... | [
"def",
"load_environment_vars",
"(",
"self",
")",
":",
"for",
"k",
",",
"v",
"in",
"os",
".",
"environ",
".",
"items",
"(",
")",
":",
"if",
"k",
".",
"startswith",
"(",
"MACH9_PREFIX",
")",
":",
"_",
",",
"config_key",
"=",
"k",
".",
"split",
"(",
... | Looks for any MACH9_ prefixed environment variables and applies
them to the configuration if present. | [
"Looks",
"for",
"any",
"MACH9_",
"prefixed",
"environment",
"variables",
"and",
"applies",
"them",
"to",
"the",
"configuration",
"if",
"present",
"."
] | 7a623aab3c70d89d36ade6901b6307e115400c5e | https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/config.py#L193-L201 |
41,277 | Jazzer360/python-examine | examine/examine.py | Structure.copy | def copy(self, parent=None):
"""Copies an existing structure and all of it's children"""
new = Structure(None, parent=parent)
new.key = self.key
new.type_ = self.type_
new.val_guaranteed = self.val_guaranteed
new.key_guaranteed = self.key_guaranteed
for child in s... | python | def copy(self, parent=None):
"""Copies an existing structure and all of it's children"""
new = Structure(None, parent=parent)
new.key = self.key
new.type_ = self.type_
new.val_guaranteed = self.val_guaranteed
new.key_guaranteed = self.key_guaranteed
for child in s... | [
"def",
"copy",
"(",
"self",
",",
"parent",
"=",
"None",
")",
":",
"new",
"=",
"Structure",
"(",
"None",
",",
"parent",
"=",
"parent",
")",
"new",
".",
"key",
"=",
"self",
".",
"key",
"new",
".",
"type_",
"=",
"self",
".",
"type_",
"new",
".",
"... | Copies an existing structure and all of it's children | [
"Copies",
"an",
"existing",
"structure",
"and",
"all",
"of",
"it",
"s",
"children"
] | d71dc07ad13ad3859b94456df092d161cdbbdc69 | https://github.com/Jazzer360/python-examine/blob/d71dc07ad13ad3859b94456df092d161cdbbdc69/examine/examine.py#L168-L177 |
41,278 | Jazzer360/python-examine | examine/examine.py | Structure.generation | def generation(self):
"""Returns the number of ancestors that are dictionaries"""
if not self.parent:
return 0
elif self.parent.is_dict:
return 1 + self.parent.generation
else:
return self.parent.generation | python | def generation(self):
"""Returns the number of ancestors that are dictionaries"""
if not self.parent:
return 0
elif self.parent.is_dict:
return 1 + self.parent.generation
else:
return self.parent.generation | [
"def",
"generation",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"parent",
":",
"return",
"0",
"elif",
"self",
".",
"parent",
".",
"is_dict",
":",
"return",
"1",
"+",
"self",
".",
"parent",
".",
"generation",
"else",
":",
"return",
"self",
".",
... | Returns the number of ancestors that are dictionaries | [
"Returns",
"the",
"number",
"of",
"ancestors",
"that",
"are",
"dictionaries"
] | d71dc07ad13ad3859b94456df092d161cdbbdc69 | https://github.com/Jazzer360/python-examine/blob/d71dc07ad13ad3859b94456df092d161cdbbdc69/examine/examine.py#L180-L187 |
41,279 | Jazzer360/python-examine | examine/examine.py | Structure.type_string | def type_string(self):
"""Returns a string representing the type of the structure"""
if self.is_tuple:
subtypes = [item.type_string for item in self.children]
return '{}({})'.format(
'' if self.val_guaranteed else '*',
', '.join(subtypes))
... | python | def type_string(self):
"""Returns a string representing the type of the structure"""
if self.is_tuple:
subtypes = [item.type_string for item in self.children]
return '{}({})'.format(
'' if self.val_guaranteed else '*',
', '.join(subtypes))
... | [
"def",
"type_string",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_tuple",
":",
"subtypes",
"=",
"[",
"item",
".",
"type_string",
"for",
"item",
"in",
"self",
".",
"children",
"]",
"return",
"'{}({})'",
".",
"format",
"(",
"''",
"if",
"self",
".",
"... | Returns a string representing the type of the structure | [
"Returns",
"a",
"string",
"representing",
"the",
"type",
"of",
"the",
"structure"
] | d71dc07ad13ad3859b94456df092d161cdbbdc69 | https://github.com/Jazzer360/python-examine/blob/d71dc07ad13ad3859b94456df092d161cdbbdc69/examine/examine.py#L190-L204 |
41,280 | crccheck/dj-obj-update | obj_update.py | set_field | def set_field(obj, field_name, value):
"""Fancy setattr with debugging."""
old = getattr(obj, field_name)
field = obj._meta.get_field(field_name)
# is_relation is Django 1.8 only
if field.is_relation:
# If field_name is the `_id` field, then there is no 'pk' attr and
# old/value *is*... | python | def set_field(obj, field_name, value):
"""Fancy setattr with debugging."""
old = getattr(obj, field_name)
field = obj._meta.get_field(field_name)
# is_relation is Django 1.8 only
if field.is_relation:
# If field_name is the `_id` field, then there is no 'pk' attr and
# old/value *is*... | [
"def",
"set_field",
"(",
"obj",
",",
"field_name",
",",
"value",
")",
":",
"old",
"=",
"getattr",
"(",
"obj",
",",
"field_name",
")",
"field",
"=",
"obj",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
"# is_relation is Django 1.8 only",
"if",
"fi... | Fancy setattr with debugging. | [
"Fancy",
"setattr",
"with",
"debugging",
"."
] | 6f43ba88daeec7bb163db0d5dbcd18766dbc18cb | https://github.com/crccheck/dj-obj-update/blob/6f43ba88daeec7bb163db0d5dbcd18766dbc18cb/obj_update.py#L24-L48 |
41,281 | crccheck/dj-obj-update | obj_update.py | obj_update | def obj_update(obj, data: dict, *, update_fields=UNSET, save: bool=True) -> bool:
"""
Fancy way to update `obj` with `data` dict.
Parameters
----------
obj : Django model instance
data
The data to update ``obj`` with
update_fields
Use your ``update_fields`` instead of our ge... | python | def obj_update(obj, data: dict, *, update_fields=UNSET, save: bool=True) -> bool:
"""
Fancy way to update `obj` with `data` dict.
Parameters
----------
obj : Django model instance
data
The data to update ``obj`` with
update_fields
Use your ``update_fields`` instead of our ge... | [
"def",
"obj_update",
"(",
"obj",
",",
"data",
":",
"dict",
",",
"*",
",",
"update_fields",
"=",
"UNSET",
",",
"save",
":",
"bool",
"=",
"True",
")",
"->",
"bool",
":",
"for",
"field_name",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
... | Fancy way to update `obj` with `data` dict.
Parameters
----------
obj : Django model instance
data
The data to update ``obj`` with
update_fields
Use your ``update_fields`` instead of our generated one. If you need
an auto_now or auto_now_add field to get updated, set this to... | [
"Fancy",
"way",
"to",
"update",
"obj",
"with",
"data",
"dict",
"."
] | 6f43ba88daeec7bb163db0d5dbcd18766dbc18cb | https://github.com/crccheck/dj-obj-update/blob/6f43ba88daeec7bb163db0d5dbcd18766dbc18cb/obj_update.py#L63-L106 |
41,282 | crccheck/dj-obj-update | obj_update.py | obj_update_or_create | def obj_update_or_create(model, defaults=None, update_fields=UNSET, **kwargs):
"""
Mimic queryset.update_or_create but using obj_update.
"""
obj, created = model.objects.get_or_create(defaults=defaults, **kwargs)
if created:
logger.debug('CREATED %s %s',
model._meta.obje... | python | def obj_update_or_create(model, defaults=None, update_fields=UNSET, **kwargs):
"""
Mimic queryset.update_or_create but using obj_update.
"""
obj, created = model.objects.get_or_create(defaults=defaults, **kwargs)
if created:
logger.debug('CREATED %s %s',
model._meta.obje... | [
"def",
"obj_update_or_create",
"(",
"model",
",",
"defaults",
"=",
"None",
",",
"update_fields",
"=",
"UNSET",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
",",
"created",
"=",
"model",
".",
"objects",
".",
"get_or_create",
"(",
"defaults",
"=",
"defaults",
... | Mimic queryset.update_or_create but using obj_update. | [
"Mimic",
"queryset",
".",
"update_or_create",
"but",
"using",
"obj_update",
"."
] | 6f43ba88daeec7bb163db0d5dbcd18766dbc18cb | https://github.com/crccheck/dj-obj-update/blob/6f43ba88daeec7bb163db0d5dbcd18766dbc18cb/obj_update.py#L109-L121 |
41,283 | dariusbakunas/rawdisk | rawdisk/scheme/common.py | detect_scheme | def detect_scheme(filename):
"""Detects partitioning scheme of the source
Args:
filename (str): path to file or device for detection of \
partitioning scheme.
Returns:
SCHEME_MBR, SCHEME_GPT or SCHEME_UNKNOWN
Raises:
IOError: The file doesn't exist or cannot be opened ... | python | def detect_scheme(filename):
"""Detects partitioning scheme of the source
Args:
filename (str): path to file or device for detection of \
partitioning scheme.
Returns:
SCHEME_MBR, SCHEME_GPT or SCHEME_UNKNOWN
Raises:
IOError: The file doesn't exist or cannot be opened ... | [
"def",
"detect_scheme",
"(",
"filename",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"info",
"(",
"'Detecting partitioning scheme'",
")",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"# L... | Detects partitioning scheme of the source
Args:
filename (str): path to file or device for detection of \
partitioning scheme.
Returns:
SCHEME_MBR, SCHEME_GPT or SCHEME_UNKNOWN
Raises:
IOError: The file doesn't exist or cannot be opened for reading
>>> from rawdisk.sc... | [
"Detects",
"partitioning",
"scheme",
"of",
"the",
"source"
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/scheme/common.py#L24-L67 |
41,284 | mastro35/tyler | tyler.py | Tyler._has_file_rolled | def _has_file_rolled(self):
"""Check if the file has been rolled"""
# if the size is smaller then before, the file has
# probabilly been rolled
if self._fh:
size = self._getsize_of_current_file()
if size < self.oldsize:
return True
sel... | python | def _has_file_rolled(self):
"""Check if the file has been rolled"""
# if the size is smaller then before, the file has
# probabilly been rolled
if self._fh:
size = self._getsize_of_current_file()
if size < self.oldsize:
return True
sel... | [
"def",
"_has_file_rolled",
"(",
"self",
")",
":",
"# if the size is smaller then before, the file has",
"# probabilly been rolled",
"if",
"self",
".",
"_fh",
":",
"size",
"=",
"self",
".",
"_getsize_of_current_file",
"(",
")",
"if",
"size",
"<",
"self",
".",
"oldsiz... | Check if the file has been rolled | [
"Check",
"if",
"the",
"file",
"has",
"been",
"rolled"
] | 9f26ca4db45308a006f7848fa58079ca28eb9873 | https://github.com/mastro35/tyler/blob/9f26ca4db45308a006f7848fa58079ca28eb9873/tyler.py#L67-L78 |
41,285 | mastro35/tyler | tyler.py | Tyler._open_file | def _open_file(self, filename):
"""Open a file to be tailed"""
if not self._os_is_windows:
self._fh = open(filename, "rb")
self.filename = filename
self._fh.seek(0, os.SEEK_SET)
self.oldsize = 0
return
# if we're in Windows, we need t... | python | def _open_file(self, filename):
"""Open a file to be tailed"""
if not self._os_is_windows:
self._fh = open(filename, "rb")
self.filename = filename
self._fh.seek(0, os.SEEK_SET)
self.oldsize = 0
return
# if we're in Windows, we need t... | [
"def",
"_open_file",
"(",
"self",
",",
"filename",
")",
":",
"if",
"not",
"self",
".",
"_os_is_windows",
":",
"self",
".",
"_fh",
"=",
"open",
"(",
"filename",
",",
"\"rb\"",
")",
"self",
".",
"filename",
"=",
"filename",
"self",
".",
"_fh",
".",
"se... | Open a file to be tailed | [
"Open",
"a",
"file",
"to",
"be",
"tailed"
] | 9f26ca4db45308a006f7848fa58079ca28eb9873 | https://github.com/mastro35/tyler/blob/9f26ca4db45308a006f7848fa58079ca28eb9873/tyler.py#L80-L112 |
41,286 | mastro35/tyler | tyler.py | Tyler._filehandle | def _filehandle(self):
"""
Return a filehandle to the file being tailed
"""
# if file is opened and it has been rolled we need to close the file
# and then to reopen it
if self._fh and self._has_file_rolled():
try:
self._fh.close()
... | python | def _filehandle(self):
"""
Return a filehandle to the file being tailed
"""
# if file is opened and it has been rolled we need to close the file
# and then to reopen it
if self._fh and self._has_file_rolled():
try:
self._fh.close()
... | [
"def",
"_filehandle",
"(",
"self",
")",
":",
"# if file is opened and it has been rolled we need to close the file",
"# and then to reopen it",
"if",
"self",
".",
"_fh",
"and",
"self",
".",
"_has_file_rolled",
"(",
")",
":",
"try",
":",
"self",
".",
"_fh",
".",
"clo... | Return a filehandle to the file being tailed | [
"Return",
"a",
"filehandle",
"to",
"the",
"file",
"being",
"tailed"
] | 9f26ca4db45308a006f7848fa58079ca28eb9873 | https://github.com/mastro35/tyler/blob/9f26ca4db45308a006f7848fa58079ca28eb9873/tyler.py#L114-L136 |
41,287 | sdcooke/django_bundles | django_bundles/utils/__init__.py | get_class | def get_class(class_string):
"""
Get a class from a dotted string
"""
split_string = class_string.encode('ascii').split('.')
import_path = '.'.join(split_string[:-1])
class_name = split_string[-1]
if class_name:
try:
if import_path:
mod = __import__(impor... | python | def get_class(class_string):
"""
Get a class from a dotted string
"""
split_string = class_string.encode('ascii').split('.')
import_path = '.'.join(split_string[:-1])
class_name = split_string[-1]
if class_name:
try:
if import_path:
mod = __import__(impor... | [
"def",
"get_class",
"(",
"class_string",
")",
":",
"split_string",
"=",
"class_string",
".",
"encode",
"(",
"'ascii'",
")",
".",
"split",
"(",
"'.'",
")",
"import_path",
"=",
"'.'",
".",
"join",
"(",
"split_string",
"[",
":",
"-",
"1",
"]",
")",
"class... | Get a class from a dotted string | [
"Get",
"a",
"class",
"from",
"a",
"dotted",
"string"
] | 2810fc455ec7391283792c1f108f4e8340f5d12f | https://github.com/sdcooke/django_bundles/blob/2810fc455ec7391283792c1f108f4e8340f5d12f/django_bundles/utils/__init__.py#L1-L21 |
41,288 | Yipit/eventlib | eventlib/api.py | _register_handler | def _register_handler(event, fun, external=False):
"""Register a function to be an event handler"""
registry = core.HANDLER_REGISTRY
if external:
registry = core.EXTERNAL_HANDLER_REGISTRY
if not isinstance(event, basestring):
# If not basestring, it is a BaseEvent subclass.
# Th... | python | def _register_handler(event, fun, external=False):
"""Register a function to be an event handler"""
registry = core.HANDLER_REGISTRY
if external:
registry = core.EXTERNAL_HANDLER_REGISTRY
if not isinstance(event, basestring):
# If not basestring, it is a BaseEvent subclass.
# Th... | [
"def",
"_register_handler",
"(",
"event",
",",
"fun",
",",
"external",
"=",
"False",
")",
":",
"registry",
"=",
"core",
".",
"HANDLER_REGISTRY",
"if",
"external",
":",
"registry",
"=",
"core",
".",
"EXTERNAL_HANDLER_REGISTRY",
"if",
"not",
"isinstance",
"(",
... | Register a function to be an event handler | [
"Register",
"a",
"function",
"to",
"be",
"an",
"event",
"handler"
] | 0cf29e5251a59fcbfc727af5f5157a3bb03832e2 | https://github.com/Yipit/eventlib/blob/0cf29e5251a59fcbfc727af5f5157a3bb03832e2/eventlib/api.py#L26-L41 |
41,289 | Yipit/eventlib | eventlib/api.py | handler | def handler(param):
"""Decorator that associates a handler to an event class
This decorator works for both methods and functions. Since it only
registers the callable object and returns it without evaluating it.
The name param should be informed in a dotted notation and should
contain two informat... | python | def handler(param):
"""Decorator that associates a handler to an event class
This decorator works for both methods and functions. Since it only
registers the callable object and returns it without evaluating it.
The name param should be informed in a dotted notation and should
contain two informat... | [
"def",
"handler",
"(",
"param",
")",
":",
"if",
"isinstance",
"(",
"param",
",",
"basestring",
")",
":",
"return",
"lambda",
"f",
":",
"_register_handler",
"(",
"param",
",",
"f",
")",
"else",
":",
"core",
".",
"HANDLER_METHOD_REGISTRY",
".",
"append",
"... | Decorator that associates a handler to an event class
This decorator works for both methods and functions. Since it only
registers the callable object and returns it without evaluating it.
The name param should be informed in a dotted notation and should
contain two informations: the django app name a... | [
"Decorator",
"that",
"associates",
"a",
"handler",
"to",
"an",
"event",
"class"
] | 0cf29e5251a59fcbfc727af5f5157a3bb03832e2 | https://github.com/Yipit/eventlib/blob/0cf29e5251a59fcbfc727af5f5157a3bb03832e2/eventlib/api.py#L132-L160 |
41,290 | Yipit/eventlib | eventlib/api.py | log | def log(name, data=None):
"""Entry point for the event lib that starts the logging process
This function uses the `name` param to find the event class that
will be processed to log stuff. This name must provide two
informations separated by a dot: the app name and the event class
name. Like this:
... | python | def log(name, data=None):
"""Entry point for the event lib that starts the logging process
This function uses the `name` param to find the event class that
will be processed to log stuff. This name must provide two
informations separated by a dot: the app name and the event class
name. Like this:
... | [
"def",
"log",
"(",
"name",
",",
"data",
"=",
"None",
")",
":",
"data",
"=",
"data",
"or",
"{",
"}",
"data",
".",
"update",
"(",
"core",
".",
"get_default_values",
"(",
"data",
")",
")",
"# InvalidEventNameError, EventNotFoundError",
"event_cls",
"=",
"core... | Entry point for the event lib that starts the logging process
This function uses the `name` param to find the event class that
will be processed to log stuff. This name must provide two
informations separated by a dot: the app name and the event class
name. Like this:
>>> name = 'deal.ActionLo... | [
"Entry",
"point",
"for",
"the",
"event",
"lib",
"that",
"starts",
"the",
"logging",
"process"
] | 0cf29e5251a59fcbfc727af5f5157a3bb03832e2 | https://github.com/Yipit/eventlib/blob/0cf29e5251a59fcbfc727af5f5157a3bb03832e2/eventlib/api.py#L167-L202 |
41,291 | Yipit/eventlib | eventlib/api.py | BaseEvent.validate_keys | def validate_keys(self, *keys):
"""Validation helper to ensure that keys are present in data
This method makes sure that all of keys received here are
present in the data received from the caller.
It is better to call this method in the `validate()` method of
your event. Not in... | python | def validate_keys(self, *keys):
"""Validation helper to ensure that keys are present in data
This method makes sure that all of keys received here are
present in the data received from the caller.
It is better to call this method in the `validate()` method of
your event. Not in... | [
"def",
"validate_keys",
"(",
"self",
",",
"*",
"keys",
")",
":",
"current_keys",
"=",
"set",
"(",
"self",
".",
"data",
".",
"keys",
"(",
")",
")",
"needed_keys",
"=",
"set",
"(",
"keys",
")",
"if",
"not",
"needed_keys",
".",
"issubset",
"(",
"current... | Validation helper to ensure that keys are present in data
This method makes sure that all of keys received here are
present in the data received from the caller.
It is better to call this method in the `validate()` method of
your event. Not in the `clean()` one, since the first will be... | [
"Validation",
"helper",
"to",
"ensure",
"that",
"keys",
"are",
"present",
"in",
"data"
] | 0cf29e5251a59fcbfc727af5f5157a3bb03832e2 | https://github.com/Yipit/eventlib/blob/0cf29e5251a59fcbfc727af5f5157a3bb03832e2/eventlib/api.py#L89-L108 |
41,292 | brmscheiner/ideogram | ideogram/ideogram.py | addProject | def addProject(gh_link):
''' Adds a github project to the data folder, unzips it, and deletes the zip file.
Returns the project name and the path to the project folder. '''
name = os.path.basename(gh_link)
zipurl = gh_link+"/archive/master.zip"
outzip = os.path.join('temp_data',name+'.zip')
if n... | python | def addProject(gh_link):
''' Adds a github project to the data folder, unzips it, and deletes the zip file.
Returns the project name and the path to the project folder. '''
name = os.path.basename(gh_link)
zipurl = gh_link+"/archive/master.zip"
outzip = os.path.join('temp_data',name+'.zip')
if n... | [
"def",
"addProject",
"(",
"gh_link",
")",
":",
"name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"gh_link",
")",
"zipurl",
"=",
"gh_link",
"+",
"\"/archive/master.zip\"",
"outzip",
"=",
"os",
".",
"path",
".",
"join",
"(",
"'temp_data'",
",",
"name",... | Adds a github project to the data folder, unzips it, and deletes the zip file.
Returns the project name and the path to the project folder. | [
"Adds",
"a",
"github",
"project",
"to",
"the",
"data",
"folder",
"unzips",
"it",
"and",
"deletes",
"the",
"zip",
"file",
".",
"Returns",
"the",
"project",
"name",
"and",
"the",
"path",
"to",
"the",
"project",
"folder",
"."
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/ideogram.py#L122-L136 |
41,293 | brmscheiner/ideogram | ideogram/ideogram.py | Ideogram.cleanDir | def cleanDir(self):
''' Remove existing json datafiles in the target directory. '''
if os.path.isdir(self.outdir):
baddies = ['tout.json','nout.json','hout.json']
for file in baddies:
filepath = os.path.join(self.outdir,file)
if os.path.isfile(file... | python | def cleanDir(self):
''' Remove existing json datafiles in the target directory. '''
if os.path.isdir(self.outdir):
baddies = ['tout.json','nout.json','hout.json']
for file in baddies:
filepath = os.path.join(self.outdir,file)
if os.path.isfile(file... | [
"def",
"cleanDir",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"outdir",
")",
":",
"baddies",
"=",
"[",
"'tout.json'",
",",
"'nout.json'",
",",
"'hout.json'",
"]",
"for",
"file",
"in",
"baddies",
":",
"filepath",
"... | Remove existing json datafiles in the target directory. | [
"Remove",
"existing",
"json",
"datafiles",
"in",
"the",
"target",
"directory",
"."
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/ideogram.py#L30-L37 |
41,294 | brmscheiner/ideogram | ideogram/ideogram.py | Ideogram.makeHTML | def makeHTML(self,mustachepath,htmlpath):
'''Write an html file by applying this ideogram's attributes to a mustache template. '''
subs = dict()
if self.title:
subs["title"]=self.title
subs["has_title"]=True
else:
subs["has_title"]=False
subs["... | python | def makeHTML(self,mustachepath,htmlpath):
'''Write an html file by applying this ideogram's attributes to a mustache template. '''
subs = dict()
if self.title:
subs["title"]=self.title
subs["has_title"]=True
else:
subs["has_title"]=False
subs["... | [
"def",
"makeHTML",
"(",
"self",
",",
"mustachepath",
",",
"htmlpath",
")",
":",
"subs",
"=",
"dict",
"(",
")",
"if",
"self",
".",
"title",
":",
"subs",
"[",
"\"title\"",
"]",
"=",
"self",
".",
"title",
"subs",
"[",
"\"has_title\"",
"]",
"=",
"True",
... | Write an html file by applying this ideogram's attributes to a mustache template. | [
"Write",
"an",
"html",
"file",
"by",
"applying",
"this",
"ideogram",
"s",
"attributes",
"to",
"a",
"mustache",
"template",
"."
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/ideogram.py#L85-L101 |
41,295 | asascience-open/paegan-transport | paegan/transport/particles/particle.py | Particle.age | def age(self, **kwargs):
"""
Age this particle.
parameters (optional, only one allowed):
days (default)
hours
minutes
seconds
"""
if kwargs.get('days', None) is not None:
self._age += kwargs.get('days')
retu... | python | def age(self, **kwargs):
"""
Age this particle.
parameters (optional, only one allowed):
days (default)
hours
minutes
seconds
"""
if kwargs.get('days', None) is not None:
self._age += kwargs.get('days')
retu... | [
"def",
"age",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"'days'",
",",
"None",
")",
"is",
"not",
"None",
":",
"self",
".",
"_age",
"+=",
"kwargs",
".",
"get",
"(",
"'days'",
")",
"return",
"if",
"kwargs",
... | Age this particle.
parameters (optional, only one allowed):
days (default)
hours
minutes
seconds | [
"Age",
"this",
"particle",
"."
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/particles/particle.py#L203-L226 |
41,296 | asascience-open/paegan-transport | paegan/transport/particles/particle.py | Particle.normalized_indexes | def normalized_indexes(self, model_timesteps):
"""
This function will normalize the particles locations
to the timestep of the model that was run. This is used
in output, as we should only be outputting the model timestep
that was chosen to be run.
In most cases, the le... | python | def normalized_indexes(self, model_timesteps):
"""
This function will normalize the particles locations
to the timestep of the model that was run. This is used
in output, as we should only be outputting the model timestep
that was chosen to be run.
In most cases, the le... | [
"def",
"normalized_indexes",
"(",
"self",
",",
"model_timesteps",
")",
":",
"# Clean up locations",
"# If duplicate time instances, remove the lower index ",
"clean_locs",
"=",
"[",
"]",
"for",
"i",
",",
"loc",
"in",
"enumerate",
"(",
"self",
".",
"locations",
")",
... | This function will normalize the particles locations
to the timestep of the model that was run. This is used
in output, as we should only be outputting the model timestep
that was chosen to be run.
In most cases, the length of the model_timesteps and the
particle's locations w... | [
"This",
"function",
"will",
"normalize",
"the",
"particles",
"locations",
"to",
"the",
"timestep",
"of",
"the",
"model",
"that",
"was",
"run",
".",
"This",
"is",
"used",
"in",
"output",
"as",
"we",
"should",
"only",
"be",
"outputting",
"the",
"model",
"tim... | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/particles/particle.py#L235-L272 |
41,297 | mamrhein/specification | specification/specification.py | Specification.is_satisfied_by | def is_satisfied_by(self, candidate: Any, **kwds: Any) -> bool:
"""Return True if `candidate` satisfies the specification."""
candidate_name = self._candidate_name
context = self._context
if context:
if candidate_name in kwds:
raise ValueError(f"Candidate name... | python | def is_satisfied_by(self, candidate: Any, **kwds: Any) -> bool:
"""Return True if `candidate` satisfies the specification."""
candidate_name = self._candidate_name
context = self._context
if context:
if candidate_name in kwds:
raise ValueError(f"Candidate name... | [
"def",
"is_satisfied_by",
"(",
"self",
",",
"candidate",
":",
"Any",
",",
"*",
"*",
"kwds",
":",
"Any",
")",
"->",
"bool",
":",
"candidate_name",
"=",
"self",
".",
"_candidate_name",
"context",
"=",
"self",
".",
"_context",
"if",
"context",
":",
"if",
... | Return True if `candidate` satisfies the specification. | [
"Return",
"True",
"if",
"candidate",
"satisfies",
"the",
"specification",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/specification.py#L115-L129 |
41,298 | childsish/lhc-python | lhc/graph/graph.py | Graph.add_edge | def add_edge(self, fr, to):
""" Add an edge to the graph. Multiple edges between the same vertices will quietly be ignored. N-partite graphs
can be used to permit multiple edges by partitioning the graph into vertices and edges.
:param fr: The name of the origin vertex.
:param to: The n... | python | def add_edge(self, fr, to):
""" Add an edge to the graph. Multiple edges between the same vertices will quietly be ignored. N-partite graphs
can be used to permit multiple edges by partitioning the graph into vertices and edges.
:param fr: The name of the origin vertex.
:param to: The n... | [
"def",
"add_edge",
"(",
"self",
",",
"fr",
",",
"to",
")",
":",
"fr",
"=",
"self",
".",
"add_vertex",
"(",
"fr",
")",
"to",
"=",
"self",
".",
"add_vertex",
"(",
"to",
")",
"self",
".",
"adjacency",
"[",
"fr",
"]",
".",
"children",
".",
"add",
"... | Add an edge to the graph. Multiple edges between the same vertices will quietly be ignored. N-partite graphs
can be used to permit multiple edges by partitioning the graph into vertices and edges.
:param fr: The name of the origin vertex.
:param to: The name of the destination vertex.
:... | [
"Add",
"an",
"edge",
"to",
"the",
"graph",
".",
"Multiple",
"edges",
"between",
"the",
"same",
"vertices",
"will",
"quietly",
"be",
"ignored",
".",
"N",
"-",
"partite",
"graphs",
"can",
"be",
"used",
"to",
"permit",
"multiple",
"edges",
"by",
"partitioning... | 0a669f46a40a39f24d28665e8b5b606dc7e86beb | https://github.com/childsish/lhc-python/blob/0a669f46a40a39f24d28665e8b5b606dc7e86beb/lhc/graph/graph.py#L85-L96 |
41,299 | rackerlabs/python-lunrclient | lunrclient/storage.py | StorageVolume.clone | def clone(self, source_id, backup_id, size,
volume_id=None, source_host=None):
"""
create a volume then clone the contents of
the backup into the new volume
"""
volume_id = volume_id or str(uuid.uuid4())
return self.http_put('/volumes/%s' % volume_id,
... | python | def clone(self, source_id, backup_id, size,
volume_id=None, source_host=None):
"""
create a volume then clone the contents of
the backup into the new volume
"""
volume_id = volume_id or str(uuid.uuid4())
return self.http_put('/volumes/%s' % volume_id,
... | [
"def",
"clone",
"(",
"self",
",",
"source_id",
",",
"backup_id",
",",
"size",
",",
"volume_id",
"=",
"None",
",",
"source_host",
"=",
"None",
")",
":",
"volume_id",
"=",
"volume_id",
"or",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"return",
"s... | create a volume then clone the contents of
the backup into the new volume | [
"create",
"a",
"volume",
"then",
"clone",
"the",
"contents",
"of",
"the",
"backup",
"into",
"the",
"new",
"volume"
] | f26a450a422600f492480bfa42cbee50a5c7016f | https://github.com/rackerlabs/python-lunrclient/blob/f26a450a422600f492480bfa42cbee50a5c7016f/lunrclient/storage.py#L74-L87 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.