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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
248,600 | Valuehorizon/valuehorizon-people | people/models.py | Person.full_name | def full_name(self):
"""
Return the title and full name
"""
return "%s %s %s %s" % (self.get_title_display(),
self.first_name,
self.other_names.replace(",", ""),
self.last_name) | python | def full_name(self):
"""
Return the title and full name
"""
return "%s %s %s %s" % (self.get_title_display(),
self.first_name,
self.other_names.replace(",", ""),
self.last_name) | [
"def",
"full_name",
"(",
"self",
")",
":",
"return",
"\"%s %s %s %s\"",
"%",
"(",
"self",
".",
"get_title_display",
"(",
")",
",",
"self",
".",
"first_name",
",",
"self",
".",
"other_names",
".",
"replace",
"(",
"\",\"",
",",
"\"\"",
")",
",",
"self",
... | Return the title and full name | [
"Return",
"the",
"title",
"and",
"full",
"name"
] | f32d9f1349c1a9384bae5ea61d10c1b1e0318401 | https://github.com/Valuehorizon/valuehorizon-people/blob/f32d9f1349c1a9384bae5ea61d10c1b1e0318401/people/models.py#L89-L96 |
248,601 | Valuehorizon/valuehorizon-people | people/models.py | Person.save | def save(self, *args, **kwargs):
"""
If date of death is specified, set is_deceased to true
"""
if self.date_of_death != None:
self.is_deceased = True
# Since we often copy and paste names from strange sources, do some basic cleanup
self.first_nam... | python | def save(self, *args, **kwargs):
"""
If date of death is specified, set is_deceased to true
"""
if self.date_of_death != None:
self.is_deceased = True
# Since we often copy and paste names from strange sources, do some basic cleanup
self.first_nam... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"date_of_death",
"!=",
"None",
":",
"self",
".",
"is_deceased",
"=",
"True",
"# Since we often copy and paste names from strange sources, do some basic cleanup",
"s... | If date of death is specified, set is_deceased to true | [
"If",
"date",
"of",
"death",
"is",
"specified",
"set",
"is_deceased",
"to",
"true"
] | f32d9f1349c1a9384bae5ea61d10c1b1e0318401 | https://github.com/Valuehorizon/valuehorizon-people/blob/f32d9f1349c1a9384bae5ea61d10c1b1e0318401/people/models.py#L102-L115 |
248,602 | awacha/credolib | credolib/persistence.py | storedata | def storedata(filename=None):
"""Store the state of the current credolib workspace in a pickle file."""
if filename is None:
filename = 'credolib_state.pickle'
ns = get_ipython().user_ns
with open(filename, 'wb') as f:
d = {}
for var in ['_headers', '_loaders', '_data1d', '_data2... | python | def storedata(filename=None):
"""Store the state of the current credolib workspace in a pickle file."""
if filename is None:
filename = 'credolib_state.pickle'
ns = get_ipython().user_ns
with open(filename, 'wb') as f:
d = {}
for var in ['_headers', '_loaders', '_data1d', '_data2... | [
"def",
"storedata",
"(",
"filename",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"'credolib_state.pickle'",
"ns",
"=",
"get_ipython",
"(",
")",
".",
"user_ns",
"with",
"open",
"(",
"filename",
",",
"'wb'",
")",
"as",
"f",... | Store the state of the current credolib workspace in a pickle file. | [
"Store",
"the",
"state",
"of",
"the",
"current",
"credolib",
"workspace",
"in",
"a",
"pickle",
"file",
"."
] | 11c0be3eea7257d3d6e13697d3e76ce538f2f1b2 | https://github.com/awacha/credolib/blob/11c0be3eea7257d3d6e13697d3e76ce538f2f1b2/credolib/persistence.py#L8-L24 |
248,603 | awacha/credolib | credolib/persistence.py | restoredata | def restoredata(filename=None):
"""Restore the state of the credolib workspace from a pickle file."""
if filename is None:
filename = 'credolib_state.pickle'
ns = get_ipython().user_ns
with open(filename, 'rb') as f:
d = pickle.load(f)
for k in d.keys():
ns[k] = d[k] | python | def restoredata(filename=None):
"""Restore the state of the credolib workspace from a pickle file."""
if filename is None:
filename = 'credolib_state.pickle'
ns = get_ipython().user_ns
with open(filename, 'rb') as f:
d = pickle.load(f)
for k in d.keys():
ns[k] = d[k] | [
"def",
"restoredata",
"(",
"filename",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"'credolib_state.pickle'",
"ns",
"=",
"get_ipython",
"(",
")",
".",
"user_ns",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f... | Restore the state of the credolib workspace from a pickle file. | [
"Restore",
"the",
"state",
"of",
"the",
"credolib",
"workspace",
"from",
"a",
"pickle",
"file",
"."
] | 11c0be3eea7257d3d6e13697d3e76ce538f2f1b2 | https://github.com/awacha/credolib/blob/11c0be3eea7257d3d6e13697d3e76ce538f2f1b2/credolib/persistence.py#L27-L35 |
248,604 | TheOneHyer/arandomness | build/lib.linux-x86_64-3.6/arandomness/str/autocorrect.py | autocorrect | def autocorrect(query, possibilities, delta=0.75):
"""Attempts to figure out what possibility the query is
This autocorrect function is rather simple right now with plans for later
improvement. Right now, it just attempts to finish spelling a word as much
as possible, and then determines which possibil... | python | def autocorrect(query, possibilities, delta=0.75):
"""Attempts to figure out what possibility the query is
This autocorrect function is rather simple right now with plans for later
improvement. Right now, it just attempts to finish spelling a word as much
as possible, and then determines which possibil... | [
"def",
"autocorrect",
"(",
"query",
",",
"possibilities",
",",
"delta",
"=",
"0.75",
")",
":",
"# TODO: Make this way more robust and awesome using probability, n-grams?",
"possibilities",
"=",
"[",
"possibility",
".",
"lower",
"(",
")",
"for",
"possibility",
"in",
"p... | Attempts to figure out what possibility the query is
This autocorrect function is rather simple right now with plans for later
improvement. Right now, it just attempts to finish spelling a word as much
as possible, and then determines which possibility is closest to said word.
Args:
query (un... | [
"Attempts",
"to",
"figure",
"out",
"what",
"possibility",
"the",
"query",
"is"
] | ae9f630e9a1d67b0eb6d61644a49756de8a5268c | https://github.com/TheOneHyer/arandomness/blob/ae9f630e9a1d67b0eb6d61644a49756de8a5268c/build/lib.linux-x86_64-3.6/arandomness/str/autocorrect.py#L34-L88 |
248,605 | nir0s/serv | serv/init/base.py | Base.generate | def generate(self, overwrite):
"""Generate service files.
This exposes several comforts.
`self.files` is a list into which all generated file paths will be
appended. It is later returned by `generate` to be consumed by any
program that wants to do something with it.
`s... | python | def generate(self, overwrite):
"""Generate service files.
This exposes several comforts.
`self.files` is a list into which all generated file paths will be
appended. It is later returned by `generate` to be consumed by any
program that wants to do something with it.
`s... | [
"def",
"generate",
"(",
"self",
",",
"overwrite",
")",
":",
"self",
".",
"files",
"=",
"[",
"]",
"tmp",
"=",
"utils",
".",
"get_tmp_dir",
"(",
"self",
".",
"init_system",
",",
"self",
".",
"name",
")",
"self",
".",
"templates",
"=",
"os",
".",
"pat... | Generate service files.
This exposes several comforts.
`self.files` is a list into which all generated file paths will be
appended. It is later returned by `generate` to be consumed by any
program that wants to do something with it.
`self.templates` is the directory in which a... | [
"Generate",
"service",
"files",
"."
] | 7af724ed49c0eb766c37c4b5287b043a8cf99e9c | https://github.com/nir0s/serv/blob/7af724ed49c0eb766c37c4b5287b043a8cf99e9c/serv/init/base.py#L78-L109 |
248,606 | nir0s/serv | serv/init/base.py | Base.status | def status(self, **kwargs):
"""Retrieve the status of a service `name` or all services
for the current init system.
"""
self.services = dict(
init_system=self.init_system,
services=[]
) | python | def status(self, **kwargs):
"""Retrieve the status of a service `name` or all services
for the current init system.
"""
self.services = dict(
init_system=self.init_system,
services=[]
) | [
"def",
"status",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"services",
"=",
"dict",
"(",
"init_system",
"=",
"self",
".",
"init_system",
",",
"services",
"=",
"[",
"]",
")"
] | Retrieve the status of a service `name` or all services
for the current init system. | [
"Retrieve",
"the",
"status",
"of",
"a",
"service",
"name",
"or",
"all",
"services",
"for",
"the",
"current",
"init",
"system",
"."
] | 7af724ed49c0eb766c37c4b5287b043a8cf99e9c | https://github.com/nir0s/serv/blob/7af724ed49c0eb766c37c4b5287b043a8cf99e9c/serv/init/base.py#L139-L146 |
248,607 | nir0s/serv | serv/init/base.py | Base.generate_file_from_template | def generate_file_from_template(self, template, destination):
"""Generate a file from a Jinja2 `template` and writes it to
`destination` using `params`.
`overwrite` allows to overwrite existing files. It is passed to
the `generate` method.
This is used by the different init imp... | python | def generate_file_from_template(self, template, destination):
"""Generate a file from a Jinja2 `template` and writes it to
`destination` using `params`.
`overwrite` allows to overwrite existing files. It is passed to
the `generate` method.
This is used by the different init imp... | [
"def",
"generate_file_from_template",
"(",
"self",
",",
"template",
",",
"destination",
")",
":",
"# We cast the object to a string before passing it on as py3.x",
"# will fail on Jinja2 if there are ints/bytes (not strings) in the",
"# template which will not allow `env.from_string(template... | Generate a file from a Jinja2 `template` and writes it to
`destination` using `params`.
`overwrite` allows to overwrite existing files. It is passed to
the `generate` method.
This is used by the different init implementations to generate
init scripts/configs and deploy them to ... | [
"Generate",
"a",
"file",
"from",
"a",
"Jinja2",
"template",
"and",
"writes",
"it",
"to",
"destination",
"using",
"params",
"."
] | 7af724ed49c0eb766c37c4b5287b043a8cf99e9c | https://github.com/nir0s/serv/blob/7af724ed49c0eb766c37c4b5287b043a8cf99e9c/serv/init/base.py#L163-L198 |
248,608 | KnowledgeLinks/rdfframework | rdfframework/rdfclass/esconversion.py | convert_value_to_es | def convert_value_to_es(value, ranges, obj, method=None):
"""
Takes an value and converts it to an elasticsearch representation
args:
value: the value to convert
ranges: the list of ranges
method: convertion method to use
'None': default -> converts the value to its ... | python | def convert_value_to_es(value, ranges, obj, method=None):
"""
Takes an value and converts it to an elasticsearch representation
args:
value: the value to convert
ranges: the list of ranges
method: convertion method to use
'None': default -> converts the value to its ... | [
"def",
"convert_value_to_es",
"(",
"value",
",",
"ranges",
",",
"obj",
",",
"method",
"=",
"None",
")",
":",
"def",
"sub_convert",
"(",
"val",
")",
":",
"\"\"\"\n Returns the json value for a simple datatype or the subject uri if the\n value is a rdfclass\n\n ... | Takes an value and converts it to an elasticsearch representation
args:
value: the value to convert
ranges: the list of ranges
method: convertion method to use
'None': default -> converts the value to its json value
'missing_obj': adds attributes as if the va... | [
"Takes",
"an",
"value",
"and",
"converts",
"it",
"to",
"an",
"elasticsearch",
"representation"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L24-L65 |
248,609 | KnowledgeLinks/rdfframework | rdfframework/rdfclass/esconversion.py | get_idx_types | def get_idx_types(rng_def, ranges):
"""
Returns the elasticsearch index types for the obj
args:
rng_def: the range defintion dictionay
ranges: rdfproperty ranges
"""
idx_types = rng_def.get('kds_esIndexType', []).copy()
if not idx_types:
nested = False
for rng in... | python | def get_idx_types(rng_def, ranges):
"""
Returns the elasticsearch index types for the obj
args:
rng_def: the range defintion dictionay
ranges: rdfproperty ranges
"""
idx_types = rng_def.get('kds_esIndexType', []).copy()
if not idx_types:
nested = False
for rng in... | [
"def",
"get_idx_types",
"(",
"rng_def",
",",
"ranges",
")",
":",
"idx_types",
"=",
"rng_def",
".",
"get",
"(",
"'kds_esIndexType'",
",",
"[",
"]",
")",
".",
"copy",
"(",
")",
"if",
"not",
"idx_types",
":",
"nested",
"=",
"False",
"for",
"rng",
"in",
... | Returns the elasticsearch index types for the obj
args:
rng_def: the range defintion dictionay
ranges: rdfproperty ranges | [
"Returns",
"the",
"elasticsearch",
"index",
"types",
"for",
"the",
"obj"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L67-L83 |
248,610 | KnowledgeLinks/rdfframework | rdfframework/rdfclass/esconversion.py | get_prop_range_defs | def get_prop_range_defs(class_names, def_list):
"""
Filters the range defitions based on the bound class
args:
obj: the rdffroperty instance
"""
try:
cls_options = set(class_names + ['kdr_AllClasses'])
return [rng_def for rng_def in def_list \
if not isinsta... | python | def get_prop_range_defs(class_names, def_list):
"""
Filters the range defitions based on the bound class
args:
obj: the rdffroperty instance
"""
try:
cls_options = set(class_names + ['kdr_AllClasses'])
return [rng_def for rng_def in def_list \
if not isinsta... | [
"def",
"get_prop_range_defs",
"(",
"class_names",
",",
"def_list",
")",
":",
"try",
":",
"cls_options",
"=",
"set",
"(",
"class_names",
"+",
"[",
"'kdr_AllClasses'",
"]",
")",
"return",
"[",
"rng_def",
"for",
"rng_def",
"in",
"def_list",
"if",
"not",
"isinst... | Filters the range defitions based on the bound class
args:
obj: the rdffroperty instance | [
"Filters",
"the",
"range",
"defitions",
"based",
"on",
"the",
"bound",
"class"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L85-L101 |
248,611 | KnowledgeLinks/rdfframework | rdfframework/rdfclass/esconversion.py | range_is_obj | def range_is_obj(rng, rdfclass):
""" Test to see if range for the class should be an object
or a litteral
"""
if rng == 'rdfs_Literal':
return False
if hasattr(rdfclass, rng):
mod_class = getattr(rdfclass, rng)
for item in mod_class.cls_defs['rdf_type']:
try:
... | python | def range_is_obj(rng, rdfclass):
""" Test to see if range for the class should be an object
or a litteral
"""
if rng == 'rdfs_Literal':
return False
if hasattr(rdfclass, rng):
mod_class = getattr(rdfclass, rng)
for item in mod_class.cls_defs['rdf_type']:
try:
... | [
"def",
"range_is_obj",
"(",
"rng",
",",
"rdfclass",
")",
":",
"if",
"rng",
"==",
"'rdfs_Literal'",
":",
"return",
"False",
"if",
"hasattr",
"(",
"rdfclass",
",",
"rng",
")",
":",
"mod_class",
"=",
"getattr",
"(",
"rdfclass",
",",
"rng",
")",
"for",
"it... | Test to see if range for the class should be an object
or a litteral | [
"Test",
"to",
"see",
"if",
"range",
"for",
"the",
"class",
"should",
"be",
"an",
"object",
"or",
"a",
"litteral"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L118-L135 |
248,612 | KnowledgeLinks/rdfframework | rdfframework/rdfclass/esconversion.py | get_es_value | def get_es_value(obj, def_obj):
"""
Returns the value for an object that goes into the elacticsearch 'value'
field
args:
obj: data object to update
def_obj: the class instance that has defintion values
"""
def get_dict_val(item):
"""
Returns the string representa... | python | def get_es_value(obj, def_obj):
"""
Returns the value for an object that goes into the elacticsearch 'value'
field
args:
obj: data object to update
def_obj: the class instance that has defintion values
"""
def get_dict_val(item):
"""
Returns the string representa... | [
"def",
"get_es_value",
"(",
"obj",
",",
"def_obj",
")",
":",
"def",
"get_dict_val",
"(",
"item",
")",
":",
"\"\"\"\n Returns the string representation of the dict item\n \"\"\"",
"if",
"isinstance",
"(",
"item",
",",
"dict",
")",
":",
"return",
"str",
... | Returns the value for an object that goes into the elacticsearch 'value'
field
args:
obj: data object to update
def_obj: the class instance that has defintion values | [
"Returns",
"the",
"value",
"for",
"an",
"object",
"that",
"goes",
"into",
"the",
"elacticsearch",
"value",
"field"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L141-L184 |
248,613 | KnowledgeLinks/rdfframework | rdfframework/rdfclass/esconversion.py | get_es_label | def get_es_label(obj, def_obj):
"""
Returns object with label for an object that goes into the elacticsearch
'label' field
args:
obj: data object to update
def_obj: the class instance that has defintion values
"""
label_flds = LABEL_FIELDS
if def_obj.es_defs.get('kds_esLabel... | python | def get_es_label(obj, def_obj):
"""
Returns object with label for an object that goes into the elacticsearch
'label' field
args:
obj: data object to update
def_obj: the class instance that has defintion values
"""
label_flds = LABEL_FIELDS
if def_obj.es_defs.get('kds_esLabel... | [
"def",
"get_es_label",
"(",
"obj",
",",
"def_obj",
")",
":",
"label_flds",
"=",
"LABEL_FIELDS",
"if",
"def_obj",
".",
"es_defs",
".",
"get",
"(",
"'kds_esLabel'",
")",
":",
"label_flds",
"=",
"def_obj",
".",
"es_defs",
"[",
"'kds_esLabel'",
"]",
"+",
"LABE... | Returns object with label for an object that goes into the elacticsearch
'label' field
args:
obj: data object to update
def_obj: the class instance that has defintion values | [
"Returns",
"object",
"with",
"label",
"for",
"an",
"object",
"that",
"goes",
"into",
"the",
"elacticsearch",
"label",
"field"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L186-L213 |
248,614 | KnowledgeLinks/rdfframework | rdfframework/rdfclass/esconversion.py | get_es_ids | def get_es_ids(obj, def_obj):
"""
Returns the object updated with the 'id' and 'uri' fields for the
elasticsearch document
args:
obj: data object to update
def_obj: the class instance that has defintion values
"""
try:
path = ""
for base in [def_obj.__class__] + ... | python | def get_es_ids(obj, def_obj):
"""
Returns the object updated with the 'id' and 'uri' fields for the
elasticsearch document
args:
obj: data object to update
def_obj: the class instance that has defintion values
"""
try:
path = ""
for base in [def_obj.__class__] + ... | [
"def",
"get_es_ids",
"(",
"obj",
",",
"def_obj",
")",
":",
"try",
":",
"path",
"=",
"\"\"",
"for",
"base",
"in",
"[",
"def_obj",
".",
"__class__",
"]",
"+",
"list",
"(",
"def_obj",
".",
"__class__",
".",
"__bases__",
")",
":",
"if",
"hasattr",
"(",
... | Returns the object updated with the 'id' and 'uri' fields for the
elasticsearch document
args:
obj: data object to update
def_obj: the class instance that has defintion values | [
"Returns",
"the",
"object",
"updated",
"with",
"the",
"id",
"and",
"uri",
"fields",
"for",
"the",
"elasticsearch",
"document"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L215-L241 |
248,615 | KnowledgeLinks/rdfframework | rdfframework/rdfclass/esconversion.py | make_es_id | def make_es_id(uri):
"""
Creates the id based off of the uri value
Args:
-----
uri: the uri to conver to an elasticsearch id
"""
try:
uri = uri.clean_uri
except AttributeError:
pass
return sha1(uri.encode()).hexdigest() | python | def make_es_id(uri):
"""
Creates the id based off of the uri value
Args:
-----
uri: the uri to conver to an elasticsearch id
"""
try:
uri = uri.clean_uri
except AttributeError:
pass
return sha1(uri.encode()).hexdigest() | [
"def",
"make_es_id",
"(",
"uri",
")",
":",
"try",
":",
"uri",
"=",
"uri",
".",
"clean_uri",
"except",
"AttributeError",
":",
"pass",
"return",
"sha1",
"(",
"uri",
".",
"encode",
"(",
")",
")",
".",
"hexdigest",
"(",
")"
] | Creates the id based off of the uri value
Args:
-----
uri: the uri to conver to an elasticsearch id | [
"Creates",
"the",
"id",
"based",
"off",
"of",
"the",
"uri",
"value"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L243-L255 |
248,616 | tschaume/ccsgp_get_started | ccsgp_get_started/examples/gp_background.py | gp_norm | def gp_norm(infile):
"""indentify normalization region"""
inDir, outDir = getWorkDirs()
data, titles = [], []
for eidx,energy in enumerate(['19', '27', '39', '62']):
file_url = os.path.realpath(os.path.join(
inDir, 'rawdata', energy, 'pt-integrated', infile+'.dat'
))
... | python | def gp_norm(infile):
"""indentify normalization region"""
inDir, outDir = getWorkDirs()
data, titles = [], []
for eidx,energy in enumerate(['19', '27', '39', '62']):
file_url = os.path.realpath(os.path.join(
inDir, 'rawdata', energy, 'pt-integrated', infile+'.dat'
))
... | [
"def",
"gp_norm",
"(",
"infile",
")",
":",
"inDir",
",",
"outDir",
"=",
"getWorkDirs",
"(",
")",
"data",
",",
"titles",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"eidx",
",",
"energy",
"in",
"enumerate",
"(",
"[",
"'19'",
",",
"'27'",
",",
"'39'",
","... | indentify normalization region | [
"indentify",
"normalization",
"region"
] | e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2 | https://github.com/tschaume/ccsgp_get_started/blob/e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2/ccsgp_get_started/examples/gp_background.py#L201-L245 |
248,617 | hamfist/sj | setup.py | get_version | def get_version():
"""
Get the version from the source, but without importing.
"""
with open('sj.py') as source:
for node in ast.walk(ast.parse(source.read(), 'sj.py')):
if node.__class__.__name__ == 'Assign' and \
node.targets[0].__class__.__name__ == 'Name' and \
... | python | def get_version():
"""
Get the version from the source, but without importing.
"""
with open('sj.py') as source:
for node in ast.walk(ast.parse(source.read(), 'sj.py')):
if node.__class__.__name__ == 'Assign' and \
node.targets[0].__class__.__name__ == 'Name' and \
... | [
"def",
"get_version",
"(",
")",
":",
"with",
"open",
"(",
"'sj.py'",
")",
"as",
"source",
":",
"for",
"node",
"in",
"ast",
".",
"walk",
"(",
"ast",
".",
"parse",
"(",
"source",
".",
"read",
"(",
")",
",",
"'sj.py'",
")",
")",
":",
"if",
"node",
... | Get the version from the source, but without importing. | [
"Get",
"the",
"version",
"from",
"the",
"source",
"but",
"without",
"importing",
"."
] | a4c4b30285723651a1fe82c6d85b85a979d85cfc | https://github.com/hamfist/sj/blob/a4c4b30285723651a1fe82c6d85b85a979d85cfc/setup.py#L12-L21 |
248,618 | minhhoit/yacms | yacms/conf/forms.py | SettingsForm._init_field | def _init_field(self, setting, field_class, name, code=None):
"""
Initialize a field whether it is built with a custom name for a
specific translation language or not.
"""
kwargs = {
"label": setting["label"] + ":",
"required": setting["type"] in (int, flo... | python | def _init_field(self, setting, field_class, name, code=None):
"""
Initialize a field whether it is built with a custom name for a
specific translation language or not.
"""
kwargs = {
"label": setting["label"] + ":",
"required": setting["type"] in (int, flo... | [
"def",
"_init_field",
"(",
"self",
",",
"setting",
",",
"field_class",
",",
"name",
",",
"code",
"=",
"None",
")",
":",
"kwargs",
"=",
"{",
"\"label\"",
":",
"setting",
"[",
"\"label\"",
"]",
"+",
"\":\"",
",",
"\"required\"",
":",
"setting",
"[",
"\"t... | Initialize a field whether it is built with a custom name for a
specific translation language or not. | [
"Initialize",
"a",
"field",
"whether",
"it",
"is",
"built",
"with",
"a",
"custom",
"name",
"for",
"a",
"specific",
"translation",
"language",
"or",
"not",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/conf/forms.py#L52-L72 |
248,619 | minhhoit/yacms | yacms/conf/forms.py | SettingsForm.save | def save(self):
"""
Save each of the settings to the DB.
"""
active_language = get_language()
for (name, value) in self.cleaned_data.items():
if name not in registry:
name, code = name.rsplit('_modeltranslation_', 1)
else:
c... | python | def save(self):
"""
Save each of the settings to the DB.
"""
active_language = get_language()
for (name, value) in self.cleaned_data.items():
if name not in registry:
name, code = name.rsplit('_modeltranslation_', 1)
else:
c... | [
"def",
"save",
"(",
"self",
")",
":",
"active_language",
"=",
"get_language",
"(",
")",
"for",
"(",
"name",
",",
"value",
")",
"in",
"self",
".",
"cleaned_data",
".",
"items",
"(",
")",
":",
"if",
"name",
"not",
"in",
"registry",
":",
"name",
",",
... | Save each of the settings to the DB. | [
"Save",
"each",
"of",
"the",
"settings",
"to",
"the",
"DB",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/conf/forms.py#L91-L119 |
248,620 | minhhoit/yacms | yacms/conf/forms.py | SettingsForm.format_help | def format_help(self, description):
"""
Format the setting's description into HTML.
"""
for bold in ("``", "*"):
parts = []
if description is None:
description = ""
for i, s in enumerate(description.split(bold)):
parts.a... | python | def format_help(self, description):
"""
Format the setting's description into HTML.
"""
for bold in ("``", "*"):
parts = []
if description is None:
description = ""
for i, s in enumerate(description.split(bold)):
parts.a... | [
"def",
"format_help",
"(",
"self",
",",
"description",
")",
":",
"for",
"bold",
"in",
"(",
"\"``\"",
",",
"\"*\"",
")",
":",
"parts",
"=",
"[",
"]",
"if",
"description",
"is",
"None",
":",
"description",
"=",
"\"\"",
"for",
"i",
",",
"s",
"in",
"en... | Format the setting's description into HTML. | [
"Format",
"the",
"setting",
"s",
"description",
"into",
"HTML",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/conf/forms.py#L121-L133 |
248,621 | calvinku96/labreporthelper | labreporthelper/bestfit/polyfit.py | PolyFit.bestfit_func | def bestfit_func(self, bestfit_x):
"""
Returns bestfit_y value
args:
bestfit_x: scalar, array_like
x value
return: scalar, array_like
bestfit y value
"""
bestfit_x = np.array(bestfit_x)
if not self.done_bestfit:
... | python | def bestfit_func(self, bestfit_x):
"""
Returns bestfit_y value
args:
bestfit_x: scalar, array_like
x value
return: scalar, array_like
bestfit y value
"""
bestfit_x = np.array(bestfit_x)
if not self.done_bestfit:
... | [
"def",
"bestfit_func",
"(",
"self",
",",
"bestfit_x",
")",
":",
"bestfit_x",
"=",
"np",
".",
"array",
"(",
"bestfit_x",
")",
"if",
"not",
"self",
".",
"done_bestfit",
":",
"raise",
"KeyError",
"(",
"\"Do do_bestfit first\"",
")",
"bestfit_y",
"=",
"0",
"fo... | Returns bestfit_y value
args:
bestfit_x: scalar, array_like
x value
return: scalar, array_like
bestfit y value | [
"Returns",
"bestfit_y",
"value"
] | 4d436241f389c02eb188c313190df62ab28c3763 | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/bestfit/polyfit.py#L36-L53 |
248,622 | minhhoit/yacms | yacms/accounts/views.py | login | def login(request, template="accounts/account_login.html",
form_class=LoginForm, extra_context=None):
"""
Login form.
"""
form = form_class(request.POST or None)
if request.method == "POST" and form.is_valid():
authenticated_user = form.save()
info(request, _("Successfully ... | python | def login(request, template="accounts/account_login.html",
form_class=LoginForm, extra_context=None):
"""
Login form.
"""
form = form_class(request.POST or None)
if request.method == "POST" and form.is_valid():
authenticated_user = form.save()
info(request, _("Successfully ... | [
"def",
"login",
"(",
"request",
",",
"template",
"=",
"\"accounts/account_login.html\"",
",",
"form_class",
"=",
"LoginForm",
",",
"extra_context",
"=",
"None",
")",
":",
"form",
"=",
"form_class",
"(",
"request",
".",
"POST",
"or",
"None",
")",
"if",
"reque... | Login form. | [
"Login",
"form",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/views.py#L22-L35 |
248,623 | minhhoit/yacms | yacms/accounts/views.py | signup | def signup(request, template="accounts/account_signup.html",
extra_context=None):
"""
Signup form.
"""
profile_form = get_profile_form()
form = profile_form(request.POST or None, request.FILES or None)
if request.method == "POST" and form.is_valid():
new_user = form.save()
... | python | def signup(request, template="accounts/account_signup.html",
extra_context=None):
"""
Signup form.
"""
profile_form = get_profile_form()
form = profile_form(request.POST or None, request.FILES or None)
if request.method == "POST" and form.is_valid():
new_user = form.save()
... | [
"def",
"signup",
"(",
"request",
",",
"template",
"=",
"\"accounts/account_signup.html\"",
",",
"extra_context",
"=",
"None",
")",
":",
"profile_form",
"=",
"get_profile_form",
"(",
")",
"form",
"=",
"profile_form",
"(",
"request",
".",
"POST",
"or",
"None",
"... | Signup form. | [
"Signup",
"form",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/views.py#L47-L72 |
248,624 | minhhoit/yacms | yacms/accounts/views.py | signup_verify | def signup_verify(request, uidb36=None, token=None):
"""
View for the link in the verification email sent to a new user
when they create an account and ``ACCOUNTS_VERIFICATION_REQUIRED``
is set to ``True``. Activates the user and logs them in,
redirecting to the URL they tried to access when signing... | python | def signup_verify(request, uidb36=None, token=None):
"""
View for the link in the verification email sent to a new user
when they create an account and ``ACCOUNTS_VERIFICATION_REQUIRED``
is set to ``True``. Activates the user and logs them in,
redirecting to the URL they tried to access when signing... | [
"def",
"signup_verify",
"(",
"request",
",",
"uidb36",
"=",
"None",
",",
"token",
"=",
"None",
")",
":",
"user",
"=",
"authenticate",
"(",
"uidb36",
"=",
"uidb36",
",",
"token",
"=",
"token",
",",
"is_active",
"=",
"False",
")",
"if",
"user",
"is",
"... | View for the link in the verification email sent to a new user
when they create an account and ``ACCOUNTS_VERIFICATION_REQUIRED``
is set to ``True``. Activates the user and logs them in,
redirecting to the URL they tried to access when signing up. | [
"View",
"for",
"the",
"link",
"in",
"the",
"verification",
"email",
"sent",
"to",
"a",
"new",
"user",
"when",
"they",
"create",
"an",
"account",
"and",
"ACCOUNTS_VERIFICATION_REQUIRED",
"is",
"set",
"to",
"True",
".",
"Activates",
"the",
"user",
"and",
"logs... | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/views.py#L75-L91 |
248,625 | minhhoit/yacms | yacms/accounts/views.py | profile | def profile(request, username, template="accounts/account_profile.html",
extra_context=None):
"""
Display a profile.
"""
lookup = {"username__iexact": username, "is_active": True}
context = {"profile_user": get_object_or_404(User, **lookup)}
context.update(extra_context or {})
re... | python | def profile(request, username, template="accounts/account_profile.html",
extra_context=None):
"""
Display a profile.
"""
lookup = {"username__iexact": username, "is_active": True}
context = {"profile_user": get_object_or_404(User, **lookup)}
context.update(extra_context or {})
re... | [
"def",
"profile",
"(",
"request",
",",
"username",
",",
"template",
"=",
"\"accounts/account_profile.html\"",
",",
"extra_context",
"=",
"None",
")",
":",
"lookup",
"=",
"{",
"\"username__iexact\"",
":",
"username",
",",
"\"is_active\"",
":",
"True",
"}",
"conte... | Display a profile. | [
"Display",
"a",
"profile",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/views.py#L103-L111 |
248,626 | minhhoit/yacms | yacms/accounts/views.py | profile_update | def profile_update(request, template="accounts/account_profile_update.html",
extra_context=None):
"""
Profile update form.
"""
profile_form = get_profile_form()
form = profile_form(request.POST or None, request.FILES or None,
instance=request.user)
if r... | python | def profile_update(request, template="accounts/account_profile_update.html",
extra_context=None):
"""
Profile update form.
"""
profile_form = get_profile_form()
form = profile_form(request.POST or None, request.FILES or None,
instance=request.user)
if r... | [
"def",
"profile_update",
"(",
"request",
",",
"template",
"=",
"\"accounts/account_profile_update.html\"",
",",
"extra_context",
"=",
"None",
")",
":",
"profile_form",
"=",
"get_profile_form",
"(",
")",
"form",
"=",
"profile_form",
"(",
"request",
".",
"POST",
"or... | Profile update form. | [
"Profile",
"update",
"form",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/views.py#L124-L141 |
248,627 | jtpaasch/simplygithub | simplygithub/branches.py | get_branch_sha | def get_branch_sha(profile, name):
"""Get the SHA a branch's HEAD points to.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
... | python | def get_branch_sha(profile, name):
"""Get the SHA a branch's HEAD points to.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
... | [
"def",
"get_branch_sha",
"(",
"profile",
",",
"name",
")",
":",
"ref",
"=",
"\"heads/\"",
"+",
"name",
"data",
"=",
"refs",
".",
"get_ref",
"(",
"profile",
",",
"ref",
")",
"head",
"=",
"data",
".",
"get",
"(",
"\"head\"",
")",
"sha",
"=",
"head",
... | Get the SHA a branch's HEAD points to.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
name
The name of the branch... | [
"Get",
"the",
"SHA",
"a",
"branch",
"s",
"HEAD",
"points",
"to",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/branches.py#L8-L29 |
248,628 | jtpaasch/simplygithub | simplygithub/branches.py | get_branch | def get_branch(profile, name):
"""Fetch a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
name
The nam... | python | def get_branch(profile, name):
"""Fetch a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
name
The nam... | [
"def",
"get_branch",
"(",
"profile",
",",
"name",
")",
":",
"ref",
"=",
"\"heads/\"",
"+",
"name",
"data",
"=",
"refs",
".",
"get_ref",
"(",
"profile",
",",
"ref",
")",
"return",
"data"
] | Fetch a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
name
The name of the branch to fetch.
Returns... | [
"Fetch",
"a",
"branch",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/branches.py#L50-L69 |
248,629 | jtpaasch/simplygithub | simplygithub/branches.py | create_branch | def create_branch(profile, name, branch_off):
"""Create a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
name
... | python | def create_branch(profile, name, branch_off):
"""Create a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
name
... | [
"def",
"create_branch",
"(",
"profile",
",",
"name",
",",
"branch_off",
")",
":",
"branch_off_sha",
"=",
"get_branch_sha",
"(",
"profile",
",",
"branch_off",
")",
"ref",
"=",
"\"heads/\"",
"+",
"name",
"data",
"=",
"refs",
".",
"create_ref",
"(",
"profile",
... | Create a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
name
The name of the new branch.
branch_... | [
"Create",
"a",
"branch",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/branches.py#L72-L95 |
248,630 | jtpaasch/simplygithub | simplygithub/branches.py | update_branch | def update_branch(profile, name, sha):
"""Move a branch's HEAD to a new SHA.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
... | python | def update_branch(profile, name, sha):
"""Move a branch's HEAD to a new SHA.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
... | [
"def",
"update_branch",
"(",
"profile",
",",
"name",
",",
"sha",
")",
":",
"ref",
"=",
"\"heads/\"",
"+",
"name",
"data",
"=",
"refs",
".",
"update_ref",
"(",
"profile",
",",
"ref",
",",
"sha",
")",
"return",
"data"
] | Move a branch's HEAD to a new SHA.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
name
The name of the branch to ... | [
"Move",
"a",
"branch",
"s",
"HEAD",
"to",
"a",
"new",
"SHA",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/branches.py#L98-L120 |
248,631 | jtpaasch/simplygithub | simplygithub/branches.py | delete_branch | def delete_branch(profile, name):
"""Delete a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
name
The... | python | def delete_branch(profile, name):
"""Delete a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
name
The... | [
"def",
"delete_branch",
"(",
"profile",
",",
"name",
")",
":",
"ref",
"=",
"\"heads/\"",
"+",
"name",
"data",
"=",
"refs",
".",
"delete_ref",
"(",
"profile",
",",
"ref",
")",
"return",
"data"
] | Delete a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
name
The name of the branch to delete.
Retur... | [
"Delete",
"a",
"branch",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/branches.py#L123-L142 |
248,632 | jtpaasch/simplygithub | simplygithub/branches.py | merge | def merge(profile, branch, merge_into):
"""Merge a branch into another branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
... | python | def merge(profile, branch, merge_into):
"""Merge a branch into another branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
... | [
"def",
"merge",
"(",
"profile",
",",
"branch",
",",
"merge_into",
")",
":",
"data",
"=",
"merges",
".",
"merge",
"(",
"profile",
",",
"branch",
",",
"merge_into",
")",
"return",
"data"
] | Merge a branch into another branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
branch
The name of the branch ... | [
"Merge",
"a",
"branch",
"into",
"another",
"branch",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/branches.py#L145-L166 |
248,633 | 20c/xbahn | xbahn/mixins.py | EventMixin.has_callbacks | def has_callbacks(self, name):
"""
Returns True if there are callbacks attached to the specified
event name.
Returns False if not
"""
r = self.event_listeners.get(name)
if not r:
return False
return len(r) > 0 | python | def has_callbacks(self, name):
"""
Returns True if there are callbacks attached to the specified
event name.
Returns False if not
"""
r = self.event_listeners.get(name)
if not r:
return False
return len(r) > 0 | [
"def",
"has_callbacks",
"(",
"self",
",",
"name",
")",
":",
"r",
"=",
"self",
".",
"event_listeners",
".",
"get",
"(",
"name",
")",
"if",
"not",
"r",
":",
"return",
"False",
"return",
"len",
"(",
"r",
")",
">",
"0"
] | Returns True if there are callbacks attached to the specified
event name.
Returns False if not | [
"Returns",
"True",
"if",
"there",
"are",
"callbacks",
"attached",
"to",
"the",
"specified",
"event",
"name",
"."
] | afb27b0576841338a366d7cac0200a782bd84be6 | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/mixins.py#L35-L45 |
248,634 | 20c/xbahn | xbahn/mixins.py | EventMixin.on | def on(self, name, callback, once=False):
"""
Adds a callback to the event specified by name
once <bool> if True the callback will be removed once it's been
triggered
"""
if name not in self.event_listeners:
self.event_listeners[name] = []
self.event... | python | def on(self, name, callback, once=False):
"""
Adds a callback to the event specified by name
once <bool> if True the callback will be removed once it's been
triggered
"""
if name not in self.event_listeners:
self.event_listeners[name] = []
self.event... | [
"def",
"on",
"(",
"self",
",",
"name",
",",
"callback",
",",
"once",
"=",
"False",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"event_listeners",
":",
"self",
".",
"event_listeners",
"[",
"name",
"]",
"=",
"[",
"]",
"self",
".",
"event_listener... | Adds a callback to the event specified by name
once <bool> if True the callback will be removed once it's been
triggered | [
"Adds",
"a",
"callback",
"to",
"the",
"event",
"specified",
"by",
"name"
] | afb27b0576841338a366d7cac0200a782bd84be6 | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/mixins.py#L47-L57 |
248,635 | 20c/xbahn | xbahn/mixins.py | EventMixin.off | def off(self, name, callback, once=False):
"""
Removes callback to the event specified by name
"""
if name not in self.event_listeners:
return
self.event_listeners[name].remove((callback, once)) | python | def off(self, name, callback, once=False):
"""
Removes callback to the event specified by name
"""
if name not in self.event_listeners:
return
self.event_listeners[name].remove((callback, once)) | [
"def",
"off",
"(",
"self",
",",
"name",
",",
"callback",
",",
"once",
"=",
"False",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"event_listeners",
":",
"return",
"self",
".",
"event_listeners",
"[",
"name",
"]",
".",
"remove",
"(",
"(",
"callba... | Removes callback to the event specified by name | [
"Removes",
"callback",
"to",
"the",
"event",
"specified",
"by",
"name"
] | afb27b0576841338a366d7cac0200a782bd84be6 | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/mixins.py#L59-L67 |
248,636 | 20c/xbahn | xbahn/mixins.py | EventMixin.trigger | def trigger(self, name, *args, **kwargs):
"""
Triggers the event specified by name and passes
self in keyword argument "event_origin"
All additional arguments and keyword arguments are passed
through as well
"""
mark_remove = []
for callback, once in sel... | python | def trigger(self, name, *args, **kwargs):
"""
Triggers the event specified by name and passes
self in keyword argument "event_origin"
All additional arguments and keyword arguments are passed
through as well
"""
mark_remove = []
for callback, once in sel... | [
"def",
"trigger",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"mark_remove",
"=",
"[",
"]",
"for",
"callback",
",",
"once",
"in",
"self",
".",
"event_listeners",
".",
"get",
"(",
"name",
",",
"[",
"]",
")",
":",... | Triggers the event specified by name and passes
self in keyword argument "event_origin"
All additional arguments and keyword arguments are passed
through as well | [
"Triggers",
"the",
"event",
"specified",
"by",
"name",
"and",
"passes",
"self",
"in",
"keyword",
"argument",
"event_origin"
] | afb27b0576841338a366d7cac0200a782bd84be6 | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/mixins.py#L69-L85 |
248,637 | ludeeus/pyruter | pyruter/api.py | Departures.get_final_destination | async def get_final_destination(self):
"""Get a list of final destinations for a stop."""
dest = []
await self.get_departures()
for departure in self._departures:
dep = {}
dep['line'] = departure.get('line')
dep['destination'] = departure.get('destinat... | python | async def get_final_destination(self):
"""Get a list of final destinations for a stop."""
dest = []
await self.get_departures()
for departure in self._departures:
dep = {}
dep['line'] = departure.get('line')
dep['destination'] = departure.get('destinat... | [
"async",
"def",
"get_final_destination",
"(",
"self",
")",
":",
"dest",
"=",
"[",
"]",
"await",
"self",
".",
"get_departures",
"(",
")",
"for",
"departure",
"in",
"self",
".",
"_departures",
":",
"dep",
"=",
"{",
"}",
"dep",
"[",
"'line'",
"]",
"=",
... | Get a list of final destinations for a stop. | [
"Get",
"a",
"list",
"of",
"final",
"destinations",
"for",
"a",
"stop",
"."
] | 415d8b9c8bfd48caa82c1a1201bfd3beb670a117 | https://github.com/ludeeus/pyruter/blob/415d8b9c8bfd48caa82c1a1201bfd3beb670a117/pyruter/api.py#L55-L64 |
248,638 | cogniteev/docido-python-sdk | docido_sdk/toolbox/loader.py | resolve_name | def resolve_name(name, module=None):
"""Resolve a dotted name to a module and its parts. This is stolen
wholesale from unittest.TestLoader.loadTestByName.
"""
parts = name.split('.')
parts_copy = parts[:]
if module is None:
while parts_copy: # pragma: no cover
try:
... | python | def resolve_name(name, module=None):
"""Resolve a dotted name to a module and its parts. This is stolen
wholesale from unittest.TestLoader.loadTestByName.
"""
parts = name.split('.')
parts_copy = parts[:]
if module is None:
while parts_copy: # pragma: no cover
try:
... | [
"def",
"resolve_name",
"(",
"name",
",",
"module",
"=",
"None",
")",
":",
"parts",
"=",
"name",
".",
"split",
"(",
"'.'",
")",
"parts_copy",
"=",
"parts",
"[",
":",
"]",
"if",
"module",
"is",
"None",
":",
"while",
"parts_copy",
":",
"# pragma: no cover... | Resolve a dotted name to a module and its parts. This is stolen
wholesale from unittest.TestLoader.loadTestByName. | [
"Resolve",
"a",
"dotted",
"name",
"to",
"a",
"module",
"and",
"its",
"parts",
".",
"This",
"is",
"stolen",
"wholesale",
"from",
"unittest",
".",
"TestLoader",
".",
"loadTestByName",
"."
] | 58ecb6c6f5757fd40c0601657ab18368da7ddf33 | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/loader.py#L2-L21 |
248,639 | django-xxx/django-mobi2 | mobi2/decorators.py | detect_mobile | def detect_mobile(view):
"""View Decorator that adds a "mobile" attribute to the request which is
True or False depending on whether the request should be considered
to come from a small-screen device such as a phone or a PDA"""
@wraps(view)
def detected(request, *args, **kwargs):
Mob... | python | def detect_mobile(view):
"""View Decorator that adds a "mobile" attribute to the request which is
True or False depending on whether the request should be considered
to come from a small-screen device such as a phone or a PDA"""
@wraps(view)
def detected(request, *args, **kwargs):
Mob... | [
"def",
"detect_mobile",
"(",
"view",
")",
":",
"@",
"wraps",
"(",
"view",
")",
"def",
"detected",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"MobileDetectionMiddleware",
".",
"process_request",
"(",
"request",
")",
"return",
"vi... | View Decorator that adds a "mobile" attribute to the request which is
True or False depending on whether the request should be considered
to come from a small-screen device such as a phone or a PDA | [
"View",
"Decorator",
"that",
"adds",
"a",
"mobile",
"attribute",
"to",
"the",
"request",
"which",
"is",
"True",
"or",
"False",
"depending",
"on",
"whether",
"the",
"request",
"should",
"be",
"considered",
"to",
"come",
"from",
"a",
"small",
"-",
"screen",
... | 7ac323faa1a9599f3cd39acd3c49626819ce0538 | https://github.com/django-xxx/django-mobi2/blob/7ac323faa1a9599f3cd39acd3c49626819ce0538/mobi2/decorators.py#L8-L18 |
248,640 | tomnor/channelpack | channelpack/datautils.py | masked | def masked(a, b):
"""Return a numpy array with values from a where elements in b are
not False. Populate with numpy.nan where b is False. When plotting,
those elements look like missing, which can be a desired result.
"""
if np.any([a.dtype.kind.startswith(c) for c in ['i', 'u', 'f', 'c']]):
... | python | def masked(a, b):
"""Return a numpy array with values from a where elements in b are
not False. Populate with numpy.nan where b is False. When plotting,
those elements look like missing, which can be a desired result.
"""
if np.any([a.dtype.kind.startswith(c) for c in ['i', 'u', 'f', 'c']]):
... | [
"def",
"masked",
"(",
"a",
",",
"b",
")",
":",
"if",
"np",
".",
"any",
"(",
"[",
"a",
".",
"dtype",
".",
"kind",
".",
"startswith",
"(",
"c",
")",
"for",
"c",
"in",
"[",
"'i'",
",",
"'u'",
",",
"'f'",
",",
"'c'",
"]",
"]",
")",
":",
"n",
... | Return a numpy array with values from a where elements in b are
not False. Populate with numpy.nan where b is False. When plotting,
those elements look like missing, which can be a desired result. | [
"Return",
"a",
"numpy",
"array",
"with",
"values",
"from",
"a",
"where",
"elements",
"in",
"b",
"are",
"not",
"False",
".",
"Populate",
"with",
"numpy",
".",
"nan",
"where",
"b",
"is",
"False",
".",
"When",
"plotting",
"those",
"elements",
"look",
"like"... | 9ad3cd11c698aed4c0fc178385b2ba38a7d0efae | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/datautils.py#L16-L28 |
248,641 | tomnor/channelpack | channelpack/datautils.py | duration_bool | def duration_bool(b, rule, samplerate=None):
"""
Mask the parts in b being True but does not meet the duration
rules. Return an updated copy of b.
b: 1d array with True or False elements.
rule: str
The rule including the string 'dur' to be evaled.
samplerate: None or float
Has... | python | def duration_bool(b, rule, samplerate=None):
"""
Mask the parts in b being True but does not meet the duration
rules. Return an updated copy of b.
b: 1d array with True or False elements.
rule: str
The rule including the string 'dur' to be evaled.
samplerate: None or float
Has... | [
"def",
"duration_bool",
"(",
"b",
",",
"rule",
",",
"samplerate",
"=",
"None",
")",
":",
"if",
"rule",
"is",
"None",
":",
"return",
"b",
"slicelst",
"=",
"slicelist",
"(",
"b",
")",
"b2",
"=",
"np",
".",
"array",
"(",
"b",
")",
"if",
"samplerate",
... | Mask the parts in b being True but does not meet the duration
rules. Return an updated copy of b.
b: 1d array with True or False elements.
rule: str
The rule including the string 'dur' to be evaled.
samplerate: None or float
Has an effect on the result.
For each part of b that is... | [
"Mask",
"the",
"parts",
"in",
"b",
"being",
"True",
"but",
"does",
"not",
"meet",
"the",
"duration",
"rules",
".",
"Return",
"an",
"updated",
"copy",
"of",
"b",
"."
] | 9ad3cd11c698aed4c0fc178385b2ba38a7d0efae | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/datautils.py#L31-L63 |
248,642 | tomnor/channelpack | channelpack/datautils.py | startstop_bool | def startstop_bool(pack):
"""Make a bool array based on start and stop conditions.
pack:
pack.ChannelPack instance
If there is start conditions but no stop conditions, this is legal,
the True section will begin at first start and remain the rest of
the array. Likewise, if there is stop con... | python | def startstop_bool(pack):
"""Make a bool array based on start and stop conditions.
pack:
pack.ChannelPack instance
If there is start conditions but no stop conditions, this is legal,
the True section will begin at first start and remain the rest of
the array. Likewise, if there is stop con... | [
"def",
"startstop_bool",
"(",
"pack",
")",
":",
"b_TRUE",
"=",
"np",
".",
"ones",
"(",
"pack",
".",
"rec_cnt",
")",
"==",
"True",
"# NOQA",
"start_list",
"=",
"pack",
".",
"conconf",
".",
"conditions_list",
"(",
"'startcond'",
")",
"stop_list",
"=",
"pac... | Make a bool array based on start and stop conditions.
pack:
pack.ChannelPack instance
If there is start conditions but no stop conditions, this is legal,
the True section will begin at first start and remain the rest of
the array. Likewise, if there is stop conditions but no start
conditio... | [
"Make",
"a",
"bool",
"array",
"based",
"on",
"start",
"and",
"stop",
"conditions",
"."
] | 9ad3cd11c698aed4c0fc178385b2ba38a7d0efae | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/datautils.py#L66-L113 |
248,643 | tomnor/channelpack | channelpack/datautils.py | _startstop_bool | def _startstop_bool(startb, stopb, runflag, stopextend):
"""Return boolean array based on start and stop conditions.
startb, stopb: Numpy 1D arrays of the same length.
Boolean arrays for start and stop conditions being fullfilled or not.
"""
# All false at start
res = np.zeros(len(startb))... | python | def _startstop_bool(startb, stopb, runflag, stopextend):
"""Return boolean array based on start and stop conditions.
startb, stopb: Numpy 1D arrays of the same length.
Boolean arrays for start and stop conditions being fullfilled or not.
"""
# All false at start
res = np.zeros(len(startb))... | [
"def",
"_startstop_bool",
"(",
"startb",
",",
"stopb",
",",
"runflag",
",",
"stopextend",
")",
":",
"# All false at start",
"res",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"startb",
")",
")",
"==",
"True",
"# NOQA",
"start_slices",
"=",
"slicelist",
"(",
... | Return boolean array based on start and stop conditions.
startb, stopb: Numpy 1D arrays of the same length.
Boolean arrays for start and stop conditions being fullfilled or not. | [
"Return",
"boolean",
"array",
"based",
"on",
"start",
"and",
"stop",
"conditions",
"."
] | 9ad3cd11c698aed4c0fc178385b2ba38a7d0efae | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/datautils.py#L116-L171 |
248,644 | tomnor/channelpack | channelpack/datautils.py | slicelist | def slicelist(b):
"""Produce a list of slices given the boolean array b.
Start and stop in each slice describe the True sections in b."""
slicelst = []
started = False
for i, e in enumerate(b):
if e and not started:
start = i
started = True
elif not e and st... | python | def slicelist(b):
"""Produce a list of slices given the boolean array b.
Start and stop in each slice describe the True sections in b."""
slicelst = []
started = False
for i, e in enumerate(b):
if e and not started:
start = i
started = True
elif not e and st... | [
"def",
"slicelist",
"(",
"b",
")",
":",
"slicelst",
"=",
"[",
"]",
"started",
"=",
"False",
"for",
"i",
",",
"e",
"in",
"enumerate",
"(",
"b",
")",
":",
"if",
"e",
"and",
"not",
"started",
":",
"start",
"=",
"i",
"started",
"=",
"True",
"elif",
... | Produce a list of slices given the boolean array b.
Start and stop in each slice describe the True sections in b. | [
"Produce",
"a",
"list",
"of",
"slices",
"given",
"the",
"boolean",
"array",
"b",
"."
] | 9ad3cd11c698aed4c0fc178385b2ba38a7d0efae | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/datautils.py#L174-L192 |
248,645 | edeposit/edeposit.amqp.storage | src/edeposit/amqp/storage/archive_storage.py | save_archive | def save_archive(archive):
"""
Save `archive` into database and into proper indexes.
Attr:
archive (obj): Instance of the :class:`.DBArchive`.
Returns:
obj: :class:`.DBArchive` without data.
Raises:
InvalidType: When the `archive` is not instance of :class:`.DBArchive`.
... | python | def save_archive(archive):
"""
Save `archive` into database and into proper indexes.
Attr:
archive (obj): Instance of the :class:`.DBArchive`.
Returns:
obj: :class:`.DBArchive` without data.
Raises:
InvalidType: When the `archive` is not instance of :class:`.DBArchive`.
... | [
"def",
"save_archive",
"(",
"archive",
")",
":",
"_assert_obj_type",
"(",
"archive",
",",
"obj_type",
"=",
"DBArchive",
")",
"_get_handler",
"(",
")",
".",
"store_object",
"(",
"archive",
")",
"return",
"archive",
".",
"to_comm",
"(",
"light_request",
"=",
"... | Save `archive` into database and into proper indexes.
Attr:
archive (obj): Instance of the :class:`.DBArchive`.
Returns:
obj: :class:`.DBArchive` without data.
Raises:
InvalidType: When the `archive` is not instance of :class:`.DBArchive`.
UnindexablePublication: When ther... | [
"Save",
"archive",
"into",
"database",
"and",
"into",
"proper",
"indexes",
"."
] | fb6bd326249847de04b17b64e856c878665cea92 | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/archive_storage.py#L29-L48 |
248,646 | rorr73/LifeSOSpy | lifesospy/__main__.py | main | def main(argv):
"""
Basic command line script for testing library.
"""
# Parse command line arguments
parser = argparse.ArgumentParser(
description="LifeSOSpy v{} - {}".format(
PROJECT_VERSION, PROJECT_DESCRIPTION))
parser.add_argument(
'-H', '--host',
help="... | python | def main(argv):
"""
Basic command line script for testing library.
"""
# Parse command line arguments
parser = argparse.ArgumentParser(
description="LifeSOSpy v{} - {}".format(
PROJECT_VERSION, PROJECT_DESCRIPTION))
parser.add_argument(
'-H', '--host',
help="... | [
"def",
"main",
"(",
"argv",
")",
":",
"# Parse command line arguments",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"LifeSOSpy v{} - {}\"",
".",
"format",
"(",
"PROJECT_VERSION",
",",
"PROJECT_DESCRIPTION",
")",
")",
"parser",
".",
... | Basic command line script for testing library. | [
"Basic",
"command",
"line",
"script",
"for",
"testing",
"library",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/__main__.py#L23-L71 |
248,647 | laysakura/relshell | relshell/timestamp.py | Timestamp.datetime | def datetime(self):
"""Return `datetime` object"""
return dt.datetime(
self.year(), self.month(), self.day(),
self.hour(), self.minute(), self.second(),
int(self.millisecond() * 1e3)) | python | def datetime(self):
"""Return `datetime` object"""
return dt.datetime(
self.year(), self.month(), self.day(),
self.hour(), self.minute(), self.second(),
int(self.millisecond() * 1e3)) | [
"def",
"datetime",
"(",
"self",
")",
":",
"return",
"dt",
".",
"datetime",
"(",
"self",
".",
"year",
"(",
")",
",",
"self",
".",
"month",
"(",
")",
",",
"self",
".",
"day",
"(",
")",
",",
"self",
".",
"hour",
"(",
")",
",",
"self",
".",
"minu... | Return `datetime` object | [
"Return",
"datetime",
"object"
] | 9ca5c03a34c11cb763a4a75595f18bf4383aa8cc | https://github.com/laysakura/relshell/blob/9ca5c03a34c11cb763a4a75595f18bf4383aa8cc/relshell/timestamp.py#L63-L68 |
248,648 | malthe/pop | src/pop/control.py | CommandConfiguration.get_command | def get_command(self, name):
"""Wrap command class in constructor."""
def command(options):
client = ZookeeperClient(
"%s:%d" % (options.pop('host'), options.pop('port')),
session_timeout=1000
)
path = options.pop('path_prefix')
... | python | def get_command(self, name):
"""Wrap command class in constructor."""
def command(options):
client = ZookeeperClient(
"%s:%d" % (options.pop('host'), options.pop('port')),
session_timeout=1000
)
path = options.pop('path_prefix')
... | [
"def",
"get_command",
"(",
"self",
",",
"name",
")",
":",
"def",
"command",
"(",
"options",
")",
":",
"client",
"=",
"ZookeeperClient",
"(",
"\"%s:%d\"",
"%",
"(",
"options",
".",
"pop",
"(",
"'host'",
")",
",",
"options",
".",
"pop",
"(",
"'port'",
... | Wrap command class in constructor. | [
"Wrap",
"command",
"class",
"in",
"constructor",
"."
] | 3b58b91b41d8b9bee546eb40dc280a57500b8bed | https://github.com/malthe/pop/blob/3b58b91b41d8b9bee546eb40dc280a57500b8bed/src/pop/control.py#L61-L83 |
248,649 | naphatkrit/easyci | easyci/version.py | get_installed_version | def get_installed_version(vcs):
"""Get the installed version for this project.
Args:
vcs (easyci.vcs.base.Vcs)
Returns:
str - version number
Raises:
VersionNotInstalledError
"""
version_path = _get_version_path(vcs)
if not os.path.exists(version_path):
rais... | python | def get_installed_version(vcs):
"""Get the installed version for this project.
Args:
vcs (easyci.vcs.base.Vcs)
Returns:
str - version number
Raises:
VersionNotInstalledError
"""
version_path = _get_version_path(vcs)
if not os.path.exists(version_path):
rais... | [
"def",
"get_installed_version",
"(",
"vcs",
")",
":",
"version_path",
"=",
"_get_version_path",
"(",
"vcs",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"version_path",
")",
":",
"raise",
"VersionNotInstalledError",
"with",
"open",
"(",
"version_pa... | Get the installed version for this project.
Args:
vcs (easyci.vcs.base.Vcs)
Returns:
str - version number
Raises:
VersionNotInstalledError | [
"Get",
"the",
"installed",
"version",
"for",
"this",
"project",
"."
] | 7aee8d7694fe4e2da42ce35b0f700bc840c8b95f | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/version.py#L12-L28 |
248,650 | naphatkrit/easyci | easyci/version.py | set_installed_version | def set_installed_version(vcs, version):
"""Set the installed version for this project.
Args:
vcs (easyci.vcs.base.Vcs)
version (str)
"""
version_path = _get_version_path(vcs)
with open(version_path, 'w') as f:
f.write(version) | python | def set_installed_version(vcs, version):
"""Set the installed version for this project.
Args:
vcs (easyci.vcs.base.Vcs)
version (str)
"""
version_path = _get_version_path(vcs)
with open(version_path, 'w') as f:
f.write(version) | [
"def",
"set_installed_version",
"(",
"vcs",
",",
"version",
")",
":",
"version_path",
"=",
"_get_version_path",
"(",
"vcs",
")",
"with",
"open",
"(",
"version_path",
",",
"'w'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"version",
")"
] | Set the installed version for this project.
Args:
vcs (easyci.vcs.base.Vcs)
version (str) | [
"Set",
"the",
"installed",
"version",
"for",
"this",
"project",
"."
] | 7aee8d7694fe4e2da42ce35b0f700bc840c8b95f | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/version.py#L31-L40 |
248,651 | minhhoit/yacms | yacms/core/sitemaps.py | DisplayableSitemap.get_urls | def get_urls(self, **kwargs):
"""
Ensure the correct host by injecting the current site.
"""
kwargs["site"] = Site.objects.get(id=current_site_id())
return super(DisplayableSitemap, self).get_urls(**kwargs) | python | def get_urls(self, **kwargs):
"""
Ensure the correct host by injecting the current site.
"""
kwargs["site"] = Site.objects.get(id=current_site_id())
return super(DisplayableSitemap, self).get_urls(**kwargs) | [
"def",
"get_urls",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"\"site\"",
"]",
"=",
"Site",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"current_site_id",
"(",
")",
")",
"return",
"super",
"(",
"DisplayableSitemap",
",",
"self",
"... | Ensure the correct host by injecting the current site. | [
"Ensure",
"the",
"correct",
"host",
"by",
"injecting",
"the",
"current",
"site",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/sitemaps.py#L33-L38 |
248,652 | dossier/dossier.web | dossier/extraction/usernames.py | usernames | def usernames(urls):
'''Take an iterable of `urls` of normalized URL or file paths and
attempt to extract usernames. Returns a list.
'''
usernames = StringCounter()
for url, count in urls.items():
uparse = urlparse(url)
path = uparse.path
hostname = uparse.hostname
... | python | def usernames(urls):
'''Take an iterable of `urls` of normalized URL or file paths and
attempt to extract usernames. Returns a list.
'''
usernames = StringCounter()
for url, count in urls.items():
uparse = urlparse(url)
path = uparse.path
hostname = uparse.hostname
... | [
"def",
"usernames",
"(",
"urls",
")",
":",
"usernames",
"=",
"StringCounter",
"(",
")",
"for",
"url",
",",
"count",
"in",
"urls",
".",
"items",
"(",
")",
":",
"uparse",
"=",
"urlparse",
"(",
"url",
")",
"path",
"=",
"uparse",
".",
"path",
"hostname",... | Take an iterable of `urls` of normalized URL or file paths and
attempt to extract usernames. Returns a list. | [
"Take",
"an",
"iterable",
"of",
"urls",
"of",
"normalized",
"URL",
"or",
"file",
"paths",
"and",
"attempt",
"to",
"extract",
"usernames",
".",
"Returns",
"a",
"list",
"."
] | 1cad1cce3c37d3a4e956abc710a2bc1afe16a092 | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/extraction/usernames.py#L15-L30 |
248,653 | PSU-OIT-ARC/elasticmodels | elasticmodels/forms.py | BaseSearchForm.cleaned_data | def cleaned_data(self):
"""
When cleaned_data is initially accessed, we want to ensure the form
gets validated which has the side effect of setting cleaned_data to
something.
"""
if not hasattr(self, "_cleaned_data"):
self._cleaned_data = {}
self.i... | python | def cleaned_data(self):
"""
When cleaned_data is initially accessed, we want to ensure the form
gets validated which has the side effect of setting cleaned_data to
something.
"""
if not hasattr(self, "_cleaned_data"):
self._cleaned_data = {}
self.i... | [
"def",
"cleaned_data",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_cleaned_data\"",
")",
":",
"self",
".",
"_cleaned_data",
"=",
"{",
"}",
"self",
".",
"is_valid",
"(",
")",
"return",
"self",
".",
"_cleaned_data"
] | When cleaned_data is initially accessed, we want to ensure the form
gets validated which has the side effect of setting cleaned_data to
something. | [
"When",
"cleaned_data",
"is",
"initially",
"accessed",
"we",
"want",
"to",
"ensure",
"the",
"form",
"gets",
"validated",
"which",
"has",
"the",
"side",
"effect",
"of",
"setting",
"cleaned_data",
"to",
"something",
"."
] | 67870508096f66123ef10b89789bbac06571cc80 | https://github.com/PSU-OIT-ARC/elasticmodels/blob/67870508096f66123ef10b89789bbac06571cc80/elasticmodels/forms.py#L32-L41 |
248,654 | PSU-OIT-ARC/elasticmodels | elasticmodels/forms.py | BaseSearchForm.search | def search(self):
"""
This should return an elasticsearch-DSL Search instance, list or
queryset based on the values in self.cleaned_data.
"""
results = self.index.objects.all()
# reduce the results based on the q field
if self.cleaned_data.get("q"):
re... | python | def search(self):
"""
This should return an elasticsearch-DSL Search instance, list or
queryset based on the values in self.cleaned_data.
"""
results = self.index.objects.all()
# reduce the results based on the q field
if self.cleaned_data.get("q"):
re... | [
"def",
"search",
"(",
"self",
")",
":",
"results",
"=",
"self",
".",
"index",
".",
"objects",
".",
"all",
"(",
")",
"# reduce the results based on the q field",
"if",
"self",
".",
"cleaned_data",
".",
"get",
"(",
"\"q\"",
")",
":",
"results",
"=",
"results... | This should return an elasticsearch-DSL Search instance, list or
queryset based on the values in self.cleaned_data. | [
"This",
"should",
"return",
"an",
"elasticsearch",
"-",
"DSL",
"Search",
"instance",
"list",
"or",
"queryset",
"based",
"on",
"the",
"values",
"in",
"self",
".",
"cleaned_data",
"."
] | 67870508096f66123ef10b89789bbac06571cc80 | https://github.com/PSU-OIT-ARC/elasticmodels/blob/67870508096f66123ef10b89789bbac06571cc80/elasticmodels/forms.py#L62-L79 |
248,655 | quasipedia/simpleactors | simpleactors.py | on | def on(message):
'''Decorator that register a class method as callback for a message.'''
def decorator(function):
try:
function._callback_messages.append(message)
except AttributeError:
function._callback_messages = [message]
return function
return decorator | python | def on(message):
'''Decorator that register a class method as callback for a message.'''
def decorator(function):
try:
function._callback_messages.append(message)
except AttributeError:
function._callback_messages = [message]
return function
return decorator | [
"def",
"on",
"(",
"message",
")",
":",
"def",
"decorator",
"(",
"function",
")",
":",
"try",
":",
"function",
".",
"_callback_messages",
".",
"append",
"(",
"message",
")",
"except",
"AttributeError",
":",
"function",
".",
"_callback_messages",
"=",
"[",
"... | Decorator that register a class method as callback for a message. | [
"Decorator",
"that",
"register",
"a",
"class",
"method",
"as",
"callback",
"for",
"a",
"message",
"."
] | 4253da2d10b3df080b5e7b3fbee03aa6dd10db07 | https://github.com/quasipedia/simpleactors/blob/4253da2d10b3df080b5e7b3fbee03aa6dd10db07/simpleactors.py#L43-L51 |
248,656 | quasipedia/simpleactors | simpleactors.py | Actor.plug | def plug(self):
'''Add the actor's methods to the callback registry.'''
if self.__plugged:
return
for _, method in inspect.getmembers(self, predicate=inspect.ismethod):
if hasattr(method, '_callback_messages'):
for message in method._callback_messages:
... | python | def plug(self):
'''Add the actor's methods to the callback registry.'''
if self.__plugged:
return
for _, method in inspect.getmembers(self, predicate=inspect.ismethod):
if hasattr(method, '_callback_messages'):
for message in method._callback_messages:
... | [
"def",
"plug",
"(",
"self",
")",
":",
"if",
"self",
".",
"__plugged",
":",
"return",
"for",
"_",
",",
"method",
"in",
"inspect",
".",
"getmembers",
"(",
"self",
",",
"predicate",
"=",
"inspect",
".",
"ismethod",
")",
":",
"if",
"hasattr",
"(",
"metho... | Add the actor's methods to the callback registry. | [
"Add",
"the",
"actor",
"s",
"methods",
"to",
"the",
"callback",
"registry",
"."
] | 4253da2d10b3df080b5e7b3fbee03aa6dd10db07 | https://github.com/quasipedia/simpleactors/blob/4253da2d10b3df080b5e7b3fbee03aa6dd10db07/simpleactors.py#L74-L82 |
248,657 | quasipedia/simpleactors | simpleactors.py | Actor.unplug | def unplug(self):
'''Remove the actor's methods from the callback registry.'''
if not self.__plugged:
return
members = set([method for _, method
in inspect.getmembers(self, predicate=inspect.ismethod)])
for message in global_callbacks:
global... | python | def unplug(self):
'''Remove the actor's methods from the callback registry.'''
if not self.__plugged:
return
members = set([method for _, method
in inspect.getmembers(self, predicate=inspect.ismethod)])
for message in global_callbacks:
global... | [
"def",
"unplug",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"__plugged",
":",
"return",
"members",
"=",
"set",
"(",
"[",
"method",
"for",
"_",
",",
"method",
"in",
"inspect",
".",
"getmembers",
"(",
"self",
",",
"predicate",
"=",
"inspect",
"."... | Remove the actor's methods from the callback registry. | [
"Remove",
"the",
"actor",
"s",
"methods",
"from",
"the",
"callback",
"registry",
"."
] | 4253da2d10b3df080b5e7b3fbee03aa6dd10db07 | https://github.com/quasipedia/simpleactors/blob/4253da2d10b3df080b5e7b3fbee03aa6dd10db07/simpleactors.py#L84-L92 |
248,658 | quasipedia/simpleactors | simpleactors.py | Director.run | def run(self):
'''Run until there are no events to be processed.'''
# We left-append rather than emit (right-append) because some message
# may have been already queued for execution before the director runs.
global_event_queue.appendleft((INITIATE, self, (), {}))
while global_ev... | python | def run(self):
'''Run until there are no events to be processed.'''
# We left-append rather than emit (right-append) because some message
# may have been already queued for execution before the director runs.
global_event_queue.appendleft((INITIATE, self, (), {}))
while global_ev... | [
"def",
"run",
"(",
"self",
")",
":",
"# We left-append rather than emit (right-append) because some message",
"# may have been already queued for execution before the director runs.",
"global_event_queue",
".",
"appendleft",
"(",
"(",
"INITIATE",
",",
"self",
",",
"(",
")",
","... | Run until there are no events to be processed. | [
"Run",
"until",
"there",
"are",
"no",
"events",
"to",
"be",
"processed",
"."
] | 4253da2d10b3df080b5e7b3fbee03aa6dd10db07 | https://github.com/quasipedia/simpleactors/blob/4253da2d10b3df080b5e7b3fbee03aa6dd10db07/simpleactors.py#L115-L121 |
248,659 | quasipedia/simpleactors | simpleactors.py | Director.halt | def halt(self, message, emitter, *args, **kwargs):
'''Halt the execution of the loop.'''
self.process_event((FINISH, self, (), {}))
global_event_queue.clear() | python | def halt(self, message, emitter, *args, **kwargs):
'''Halt the execution of the loop.'''
self.process_event((FINISH, self, (), {}))
global_event_queue.clear() | [
"def",
"halt",
"(",
"self",
",",
"message",
",",
"emitter",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"process_event",
"(",
"(",
"FINISH",
",",
"self",
",",
"(",
")",
",",
"{",
"}",
")",
")",
"global_event_queue",
".",
"cl... | Halt the execution of the loop. | [
"Halt",
"the",
"execution",
"of",
"the",
"loop",
"."
] | 4253da2d10b3df080b5e7b3fbee03aa6dd10db07 | https://github.com/quasipedia/simpleactors/blob/4253da2d10b3df080b5e7b3fbee03aa6dd10db07/simpleactors.py#L135-L138 |
248,660 | dossier/dossier.web | dossier/web/builder.py | create_injector | def create_injector(param_name, fun_param_value):
'''Dependency injection with Bottle.
This creates a simple dependency injector that will map
``param_name`` in routes to the value ``fun_param_value()``
each time the route is invoked.
``fun_param_value`` is a closure so that it is lazily evaluated... | python | def create_injector(param_name, fun_param_value):
'''Dependency injection with Bottle.
This creates a simple dependency injector that will map
``param_name`` in routes to the value ``fun_param_value()``
each time the route is invoked.
``fun_param_value`` is a closure so that it is lazily evaluated... | [
"def",
"create_injector",
"(",
"param_name",
",",
"fun_param_value",
")",
":",
"class",
"_",
"(",
"object",
")",
":",
"api",
"=",
"2",
"def",
"apply",
"(",
"self",
",",
"callback",
",",
"route",
")",
":",
"if",
"param_name",
"not",
"in",
"inspect",
"."... | Dependency injection with Bottle.
This creates a simple dependency injector that will map
``param_name`` in routes to the value ``fun_param_value()``
each time the route is invoked.
``fun_param_value`` is a closure so that it is lazily evaluated.
This is useful for handling thread local services l... | [
"Dependency",
"injection",
"with",
"Bottle",
"."
] | 1cad1cce3c37d3a4e956abc710a2bc1afe16a092 | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/builder.py#L295-L327 |
248,661 | dossier/dossier.web | dossier/web/builder.py | WebBuilder.get_app | def get_app(self):
'''Eliminate the builder by producing a new Bottle application.
This should be the final call in your method chain. It uses all
of the built up options to create a new Bottle application.
:rtype: :class:`bottle.Bottle`
'''
if self.config is None:
... | python | def get_app(self):
'''Eliminate the builder by producing a new Bottle application.
This should be the final call in your method chain. It uses all
of the built up options to create a new Bottle application.
:rtype: :class:`bottle.Bottle`
'''
if self.config is None:
... | [
"def",
"get_app",
"(",
"self",
")",
":",
"if",
"self",
".",
"config",
"is",
"None",
":",
"# If the user never sets a config instance, then just create",
"# a default.",
"self",
".",
"config",
"=",
"Config",
"(",
")",
"if",
"self",
".",
"mount_prefix",
"is",
"Non... | Eliminate the builder by producing a new Bottle application.
This should be the final call in your method chain. It uses all
of the built up options to create a new Bottle application.
:rtype: :class:`bottle.Bottle` | [
"Eliminate",
"the",
"builder",
"by",
"producing",
"a",
"new",
"Bottle",
"application",
"."
] | 1cad1cce3c37d3a4e956abc710a2bc1afe16a092 | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/builder.py#L81-L136 |
248,662 | dossier/dossier.web | dossier/web/builder.py | WebBuilder.add_search_engine | def add_search_engine(self, name, engine):
'''Adds a search engine with the given name.
``engine`` must be the **class** object rather than
an instance. The class *must* be a subclass of
:class:`dossier.web.SearchEngine`, which should provide a means
of obtaining recommendations... | python | def add_search_engine(self, name, engine):
'''Adds a search engine with the given name.
``engine`` must be the **class** object rather than
an instance. The class *must* be a subclass of
:class:`dossier.web.SearchEngine`, which should provide a means
of obtaining recommendations... | [
"def",
"add_search_engine",
"(",
"self",
",",
"name",
",",
"engine",
")",
":",
"if",
"engine",
"is",
"None",
":",
"self",
".",
"search_engines",
".",
"pop",
"(",
"name",
",",
"None",
")",
"self",
".",
"search_engines",
"[",
"name",
"]",
"=",
"engine",
... | Adds a search engine with the given name.
``engine`` must be the **class** object rather than
an instance. The class *must* be a subclass of
:class:`dossier.web.SearchEngine`, which should provide a means
of obtaining recommendations given a query.
The ``engine`` must be a clas... | [
"Adds",
"a",
"search",
"engine",
"with",
"the",
"given",
"name",
"."
] | 1cad1cce3c37d3a4e956abc710a2bc1afe16a092 | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/builder.py#L164-L189 |
248,663 | dossier/dossier.web | dossier/web/builder.py | WebBuilder.add_filter | def add_filter(self, name, filter):
'''Adds a filter with the given name.
``filter`` must be the **class** object rather than
an instance. The class *must* be a subclass of
:class:`dossier.web.Filter`, which should provide a means
of creating a predicate function.
The `... | python | def add_filter(self, name, filter):
'''Adds a filter with the given name.
``filter`` must be the **class** object rather than
an instance. The class *must* be a subclass of
:class:`dossier.web.Filter`, which should provide a means
of creating a predicate function.
The `... | [
"def",
"add_filter",
"(",
"self",
",",
"name",
",",
"filter",
")",
":",
"if",
"name",
"is",
"None",
":",
"self",
".",
"filters",
".",
"pop",
"(",
"name",
",",
"None",
")",
"self",
".",
"filters",
"[",
"name",
"]",
"=",
"filter",
"return",
"self"
] | Adds a filter with the given name.
``filter`` must be the **class** object rather than
an instance. The class *must* be a subclass of
:class:`dossier.web.Filter`, which should provide a means
of creating a predicate function.
The ``filter`` must be a class so that its dependenc... | [
"Adds",
"a",
"filter",
"with",
"the",
"given",
"name",
"."
] | 1cad1cce3c37d3a4e956abc710a2bc1afe16a092 | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/builder.py#L191-L214 |
248,664 | dossier/dossier.web | dossier/web/builder.py | WebBuilder.add_routes | def add_routes(self, routes):
'''Merges a Bottle application into this one.
:param routes: A Bottle application or a sequence of routes.
:type routes: :class:`bottle.Bottle` or `[bottle route]`.
:rtype: :class:`WebBuilder`
'''
# Basically the same as `self.app.merge(rout... | python | def add_routes(self, routes):
'''Merges a Bottle application into this one.
:param routes: A Bottle application or a sequence of routes.
:type routes: :class:`bottle.Bottle` or `[bottle route]`.
:rtype: :class:`WebBuilder`
'''
# Basically the same as `self.app.merge(rout... | [
"def",
"add_routes",
"(",
"self",
",",
"routes",
")",
":",
"# Basically the same as `self.app.merge(routes)`, except this",
"# changes the owner of the route so that plugins on `self.app`",
"# apply to the routes given here.",
"if",
"isinstance",
"(",
"routes",
",",
"bottle",
".",
... | Merges a Bottle application into this one.
:param routes: A Bottle application or a sequence of routes.
:type routes: :class:`bottle.Bottle` or `[bottle route]`.
:rtype: :class:`WebBuilder` | [
"Merges",
"a",
"Bottle",
"application",
"into",
"this",
"one",
"."
] | 1cad1cce3c37d3a4e956abc710a2bc1afe16a092 | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/builder.py#L216-L231 |
248,665 | dossier/dossier.web | dossier/web/builder.py | WebBuilder.enable_cors | def enable_cors(self):
'''Enables Cross Origin Resource Sharing.
This makes sure the necessary headers are set so that this
web application's routes can be accessed from other origins.
:rtype: :class:`WebBuilder`
'''
def access_control_headers():
bottle.resp... | python | def enable_cors(self):
'''Enables Cross Origin Resource Sharing.
This makes sure the necessary headers are set so that this
web application's routes can be accessed from other origins.
:rtype: :class:`WebBuilder`
'''
def access_control_headers():
bottle.resp... | [
"def",
"enable_cors",
"(",
"self",
")",
":",
"def",
"access_control_headers",
"(",
")",
":",
"bottle",
".",
"response",
".",
"headers",
"[",
"'Access-Control-Allow-Origin'",
"]",
"=",
"'*'",
"bottle",
".",
"response",
".",
"headers",
"[",
"'Access-Control-Allow-... | Enables Cross Origin Resource Sharing.
This makes sure the necessary headers are set so that this
web application's routes can be accessed from other origins.
:rtype: :class:`WebBuilder` | [
"Enables",
"Cross",
"Origin",
"Resource",
"Sharing",
"."
] | 1cad1cce3c37d3a4e956abc710a2bc1afe16a092 | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/builder.py#L251-L282 |
248,666 | pygalle-io/pygalle.core.base.klass | src/pygalle/core/base/klass/__init__.py | PygalleBaseClass.init_properties | def init_properties(self) -> 'PygalleBaseClass':
""" Initialize the Pigalle properties.
# Returns:
PygalleBaseClass: The current instance.
"""
self._pigalle = {
PygalleBaseClass.__KEYS.INTERNALS: dict(),
PygalleBaseClass.__KEYS.PUBLIC: dict()
... | python | def init_properties(self) -> 'PygalleBaseClass':
""" Initialize the Pigalle properties.
# Returns:
PygalleBaseClass: The current instance.
"""
self._pigalle = {
PygalleBaseClass.__KEYS.INTERNALS: dict(),
PygalleBaseClass.__KEYS.PUBLIC: dict()
... | [
"def",
"init_properties",
"(",
"self",
")",
"->",
"'PygalleBaseClass'",
":",
"self",
".",
"_pigalle",
"=",
"{",
"PygalleBaseClass",
".",
"__KEYS",
".",
"INTERNALS",
":",
"dict",
"(",
")",
",",
"PygalleBaseClass",
".",
"__KEYS",
".",
"PUBLIC",
":",
"dict",
... | Initialize the Pigalle properties.
# Returns:
PygalleBaseClass: The current instance. | [
"Initialize",
"the",
"Pigalle",
"properties",
"."
] | fa683f7f88b63ca46a0970af81a558c9efbbe942 | https://github.com/pygalle-io/pygalle.core.base.klass/blob/fa683f7f88b63ca46a0970af81a558c9efbbe942/src/pygalle/core/base/klass/__init__.py#L66-L76 |
248,667 | pygalle-io/pygalle.core.base.klass | src/pygalle/core/base/klass/__init__.py | PygalleBaseClass.set | def set(self, key: str, value: Any) -> 'PygalleBaseClass':
""" Define a public property.
:param key:
:param value:
:return:
"""
self.public()[key] = value
return self | python | def set(self, key: str, value: Any) -> 'PygalleBaseClass':
""" Define a public property.
:param key:
:param value:
:return:
"""
self.public()[key] = value
return self | [
"def",
"set",
"(",
"self",
",",
"key",
":",
"str",
",",
"value",
":",
"Any",
")",
"->",
"'PygalleBaseClass'",
":",
"self",
".",
"public",
"(",
")",
"[",
"key",
"]",
"=",
"value",
"return",
"self"
] | Define a public property.
:param key:
:param value:
:return: | [
"Define",
"a",
"public",
"property",
"."
] | fa683f7f88b63ca46a0970af81a558c9efbbe942 | https://github.com/pygalle-io/pygalle.core.base.klass/blob/fa683f7f88b63ca46a0970af81a558c9efbbe942/src/pygalle/core/base/klass/__init__.py#L121-L129 |
248,668 | pygalle-io/pygalle.core.base.klass | src/pygalle/core/base/klass/__init__.py | PygalleBaseClass.set_category | def set_category(self, category: str = None) -> 'PygalleBaseClass':
""" Define the category of the class.
# Arguments
category: The name of category.
# Returns:
PygalleBaseClass: An instance of :class:`PygalleBaseClass`
"""
return self.set_internal(Pygal... | python | def set_category(self, category: str = None) -> 'PygalleBaseClass':
""" Define the category of the class.
# Arguments
category: The name of category.
# Returns:
PygalleBaseClass: An instance of :class:`PygalleBaseClass`
"""
return self.set_internal(Pygal... | [
"def",
"set_category",
"(",
"self",
",",
"category",
":",
"str",
"=",
"None",
")",
"->",
"'PygalleBaseClass'",
":",
"return",
"self",
".",
"set_internal",
"(",
"PygalleBaseClass",
".",
"__KEYS",
".",
"CATEGORY",
",",
"category",
")"
] | Define the category of the class.
# Arguments
category: The name of category.
# Returns:
PygalleBaseClass: An instance of :class:`PygalleBaseClass` | [
"Define",
"the",
"category",
"of",
"the",
"class",
"."
] | fa683f7f88b63ca46a0970af81a558c9efbbe942 | https://github.com/pygalle-io/pygalle.core.base.klass/blob/fa683f7f88b63ca46a0970af81a558c9efbbe942/src/pygalle/core/base/klass/__init__.py#L180-L189 |
248,669 | pygalle-io/pygalle.core.base.klass | src/pygalle/core/base/klass/__init__.py | PygalleBaseClass.instance_of | def instance_of(self, kls: Any) -> bool:
""" Return true if the current object is an instance of passed type.
# Arguments
kls: The class.
# Returns:
bool:
* Return true if the current object is an instance of passed type.
* False else.
... | python | def instance_of(self, kls: Any) -> bool:
""" Return true if the current object is an instance of passed type.
# Arguments
kls: The class.
# Returns:
bool:
* Return true if the current object is an instance of passed type.
* False else.
... | [
"def",
"instance_of",
"(",
"self",
",",
"kls",
":",
"Any",
")",
"->",
"bool",
":",
"if",
"not",
"kls",
":",
"raise",
"ValueError",
"return",
"isinstance",
"(",
"self",
",",
"kls",
")"
] | Return true if the current object is an instance of passed type.
# Arguments
kls: The class.
# Returns:
bool:
* Return true if the current object is an instance of passed type.
* False else. | [
"Return",
"true",
"if",
"the",
"current",
"object",
"is",
"an",
"instance",
"of",
"passed",
"type",
"."
] | fa683f7f88b63ca46a0970af81a558c9efbbe942 | https://github.com/pygalle-io/pygalle.core.base.klass/blob/fa683f7f88b63ca46a0970af81a558c9efbbe942/src/pygalle/core/base/klass/__init__.py#L245-L258 |
248,670 | pygalle-io/pygalle.core.base.klass | src/pygalle/core/base/klass/__init__.py | PygalleBaseClass.is_pigalle_class | def is_pigalle_class(kls: ClassVar) -> bool:
""" Return true if the passed object as argument is a class being to the Pigalle framework.
# Arguments
kls: The class to check.
# Returns:
bool:
* True if class is Pigalle.
* False else.
... | python | def is_pigalle_class(kls: ClassVar) -> bool:
""" Return true if the passed object as argument is a class being to the Pigalle framework.
# Arguments
kls: The class to check.
# Returns:
bool:
* True if class is Pigalle.
* False else.
... | [
"def",
"is_pigalle_class",
"(",
"kls",
":",
"ClassVar",
")",
"->",
"bool",
":",
"return",
"(",
"kls",
"is",
"PygalleBaseClass",
")",
"or",
"(",
"issubclass",
"(",
"type",
"(",
"kls",
")",
",",
"PygalleBaseClass",
")",
")"
] | Return true if the passed object as argument is a class being to the Pigalle framework.
# Arguments
kls: The class to check.
# Returns:
bool:
* True if class is Pigalle.
* False else. | [
"Return",
"true",
"if",
"the",
"passed",
"object",
"as",
"argument",
"is",
"a",
"class",
"being",
"to",
"the",
"Pigalle",
"framework",
"."
] | fa683f7f88b63ca46a0970af81a558c9efbbe942 | https://github.com/pygalle-io/pygalle.core.base.klass/blob/fa683f7f88b63ca46a0970af81a558c9efbbe942/src/pygalle/core/base/klass/__init__.py#L276-L287 |
248,671 | pygalle-io/pygalle.core.base.klass | src/pygalle/core/base/klass/__init__.py | PygalleBaseClass.is_pigalle | def is_pigalle(obj: Any) -> bool:
""" Return true if the passed object as argument is a class or an
instance of class being to the Pigalle framework.
# Arguments
obj: The class or object to test.
# Returns:
bool:
* True if class or object is Piga... | python | def is_pigalle(obj: Any) -> bool:
""" Return true if the passed object as argument is a class or an
instance of class being to the Pigalle framework.
# Arguments
obj: The class or object to test.
# Returns:
bool:
* True if class or object is Piga... | [
"def",
"is_pigalle",
"(",
"obj",
":",
"Any",
")",
"->",
"bool",
":",
"return",
"PygalleBaseClass",
".",
"is_pigalle_class",
"(",
"obj",
")",
"or",
"PygalleBaseClass",
".",
"is_pigalle_instance",
"(",
"obj",
")"
] | Return true if the passed object as argument is a class or an
instance of class being to the Pigalle framework.
# Arguments
obj: The class or object to test.
# Returns:
bool:
* True if class or object is Pigalle.
* False else. | [
"Return",
"true",
"if",
"the",
"passed",
"object",
"as",
"argument",
"is",
"a",
"class",
"or",
"an",
"instance",
"of",
"class",
"being",
"to",
"the",
"Pigalle",
"framework",
"."
] | fa683f7f88b63ca46a0970af81a558c9efbbe942 | https://github.com/pygalle-io/pygalle.core.base.klass/blob/fa683f7f88b63ca46a0970af81a558c9efbbe942/src/pygalle/core/base/klass/__init__.py#L290-L303 |
248,672 | pygalle-io/pygalle.core.base.klass | src/pygalle/core/base/klass/__init__.py | PygalleBaseClass.has_method | def has_method(self, key: str) -> bool:
""" Return if a method exists for the current instance.
# Arguments
key: The method name.
# Returns:
bool:
* True if the current instance has the provided method.
* False else.
"""
... | python | def has_method(self, key: str) -> bool:
""" Return if a method exists for the current instance.
# Arguments
key: The method name.
# Returns:
bool:
* True if the current instance has the provided method.
* False else.
"""
... | [
"def",
"has_method",
"(",
"self",
",",
"key",
":",
"str",
")",
"->",
"bool",
":",
"return",
"hasattr",
"(",
"self",
".",
"__class__",
",",
"key",
")",
"and",
"callable",
"(",
"getattr",
"(",
"self",
".",
"__class__",
",",
"key",
")",
")"
] | Return if a method exists for the current instance.
# Arguments
key: The method name.
# Returns:
bool:
* True if the current instance has the provided method.
* False else. | [
"Return",
"if",
"a",
"method",
"exists",
"for",
"the",
"current",
"instance",
"."
] | fa683f7f88b63ca46a0970af81a558c9efbbe942 | https://github.com/pygalle-io/pygalle.core.base.klass/blob/fa683f7f88b63ca46a0970af81a558c9efbbe942/src/pygalle/core/base/klass/__init__.py#L319-L331 |
248,673 | inspirehep/plotextractor | plotextractor/extractor.py | extract_context | def extract_context(tex_file, extracted_image_data):
"""Extract context.
Given a .tex file and a label name, this function will extract the text
before and after for all the references made to this label in the text.
The number of characters to extract before and after is configurable.
:param tex_... | python | def extract_context(tex_file, extracted_image_data):
"""Extract context.
Given a .tex file and a label name, this function will extract the text
before and after for all the references made to this label in the text.
The number of characters to extract before and after is configurable.
:param tex_... | [
"def",
"extract_context",
"(",
"tex_file",
",",
"extracted_image_data",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"tex_file",
")",
"or",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"tex_file",
")",
":",
"return",
"[",
"]",
"lines",
"=",
... | Extract context.
Given a .tex file and a label name, this function will extract the text
before and after for all the references made to this label in the text.
The number of characters to extract before and after is configurable.
:param tex_file (list): path to .tex file
:param extracted_image_da... | [
"Extract",
"context",
"."
] | 12a65350fb9f32d496f9ea57908d9a2771b20474 | https://github.com/inspirehep/plotextractor/blob/12a65350fb9f32d496f9ea57908d9a2771b20474/plotextractor/extractor.py#L118-L165 |
248,674 | inspirehep/plotextractor | plotextractor/extractor.py | intelligently_find_filenames | def intelligently_find_filenames(line, TeX=False, ext=False,
commas_okay=False):
"""Intelligently find filenames.
Find the filename in the line. We don't support all filenames! Just eps
and ps for now.
:param: line (string): the line we want to get a filename out of
... | python | def intelligently_find_filenames(line, TeX=False, ext=False,
commas_okay=False):
"""Intelligently find filenames.
Find the filename in the line. We don't support all filenames! Just eps
and ps for now.
:param: line (string): the line we want to get a filename out of
... | [
"def",
"intelligently_find_filenames",
"(",
"line",
",",
"TeX",
"=",
"False",
",",
"ext",
"=",
"False",
",",
"commas_okay",
"=",
"False",
")",
":",
"files_included",
"=",
"[",
"'ERROR'",
"]",
"if",
"commas_okay",
":",
"valid_for_filename",
"=",
"'\\\\s*[A-Za-z... | Intelligently find filenames.
Find the filename in the line. We don't support all filenames! Just eps
and ps for now.
:param: line (string): the line we want to get a filename out of
:return: filename ([string, ...]): what is probably the name of the file(s) | [
"Intelligently",
"find",
"filenames",
"."
] | 12a65350fb9f32d496f9ea57908d9a2771b20474 | https://github.com/inspirehep/plotextractor/blob/12a65350fb9f32d496f9ea57908d9a2771b20474/plotextractor/extractor.py#L774-L869 |
248,675 | inspirehep/plotextractor | plotextractor/extractor.py | get_lines_from_file | def get_lines_from_file(filepath, encoding="UTF-8"):
"""Return an iterator over lines."""
try:
fd = codecs.open(filepath, 'r', encoding)
lines = fd.readlines()
except UnicodeDecodeError:
# Fall back to 'ISO-8859-1'
fd = codecs.open(filepath, 'r', 'ISO-8859-1')
lines =... | python | def get_lines_from_file(filepath, encoding="UTF-8"):
"""Return an iterator over lines."""
try:
fd = codecs.open(filepath, 'r', encoding)
lines = fd.readlines()
except UnicodeDecodeError:
# Fall back to 'ISO-8859-1'
fd = codecs.open(filepath, 'r', 'ISO-8859-1')
lines =... | [
"def",
"get_lines_from_file",
"(",
"filepath",
",",
"encoding",
"=",
"\"UTF-8\"",
")",
":",
"try",
":",
"fd",
"=",
"codecs",
".",
"open",
"(",
"filepath",
",",
"'r'",
",",
"encoding",
")",
"lines",
"=",
"fd",
".",
"readlines",
"(",
")",
"except",
"Unic... | Return an iterator over lines. | [
"Return",
"an",
"iterator",
"over",
"lines",
"."
] | 12a65350fb9f32d496f9ea57908d9a2771b20474 | https://github.com/inspirehep/plotextractor/blob/12a65350fb9f32d496f9ea57908d9a2771b20474/plotextractor/extractor.py#L872-L883 |
248,676 | glenbot/campbx | campbx/campbx.py | CampBX._make_request | def _make_request(self, conf, post_params={}):
"""Make a request to the API and return data in a pythonic object"""
endpoint, requires_auth = conf
# setup the url and the request objects
url = '%s%s.php' % (self.api_url, endpoint)
log.debug('Setting url to %s' % url)
req... | python | def _make_request(self, conf, post_params={}):
"""Make a request to the API and return data in a pythonic object"""
endpoint, requires_auth = conf
# setup the url and the request objects
url = '%s%s.php' % (self.api_url, endpoint)
log.debug('Setting url to %s' % url)
req... | [
"def",
"_make_request",
"(",
"self",
",",
"conf",
",",
"post_params",
"=",
"{",
"}",
")",
":",
"endpoint",
",",
"requires_auth",
"=",
"conf",
"# setup the url and the request objects",
"url",
"=",
"'%s%s.php'",
"%",
"(",
"self",
".",
"api_url",
",",
"endpoint"... | Make a request to the API and return data in a pythonic object | [
"Make",
"a",
"request",
"to",
"the",
"API",
"and",
"return",
"data",
"in",
"a",
"pythonic",
"object"
] | b2e34c59ac1d645969e3a56551a1dcd755516094 | https://github.com/glenbot/campbx/blob/b2e34c59ac1d645969e3a56551a1dcd755516094/campbx/campbx.py#L81-L112 |
248,677 | glenbot/campbx | campbx/campbx.py | CampBX._create_endpoints | def _create_endpoints(self):
"""Create all api endpoints using self.endpoint and partial from functools"""
for k, v in self.endpoints.items():
_repr = '%s.%s' % (self.__class__.__name__, k)
self.__dict__[k] = EndPointPartial(self._make_request, v, _repr) | python | def _create_endpoints(self):
"""Create all api endpoints using self.endpoint and partial from functools"""
for k, v in self.endpoints.items():
_repr = '%s.%s' % (self.__class__.__name__, k)
self.__dict__[k] = EndPointPartial(self._make_request, v, _repr) | [
"def",
"_create_endpoints",
"(",
"self",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"endpoints",
".",
"items",
"(",
")",
":",
"_repr",
"=",
"'%s.%s'",
"%",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"k",
")",
"self",
".",
"__dict_... | Create all api endpoints using self.endpoint and partial from functools | [
"Create",
"all",
"api",
"endpoints",
"using",
"self",
".",
"endpoint",
"and",
"partial",
"from",
"functools"
] | b2e34c59ac1d645969e3a56551a1dcd755516094 | https://github.com/glenbot/campbx/blob/b2e34c59ac1d645969e3a56551a1dcd755516094/campbx/campbx.py#L114-L118 |
248,678 | monkeython/scriba | scriba/content_types/scriba_zip.py | parse | def parse(binary, **params):
"""Turns a ZIP file into a frozen sample."""
binary = io.BytesIO(binary)
collection = list()
with zipfile.ZipFile(binary, 'r') as zip_:
for zip_info in zip_.infolist():
content_type, encoding = mimetypes.guess_type(zip_info.filename)
content =... | python | def parse(binary, **params):
"""Turns a ZIP file into a frozen sample."""
binary = io.BytesIO(binary)
collection = list()
with zipfile.ZipFile(binary, 'r') as zip_:
for zip_info in zip_.infolist():
content_type, encoding = mimetypes.guess_type(zip_info.filename)
content =... | [
"def",
"parse",
"(",
"binary",
",",
"*",
"*",
"params",
")",
":",
"binary",
"=",
"io",
".",
"BytesIO",
"(",
"binary",
")",
"collection",
"=",
"list",
"(",
")",
"with",
"zipfile",
".",
"ZipFile",
"(",
"binary",
",",
"'r'",
")",
"as",
"zip_",
":",
... | Turns a ZIP file into a frozen sample. | [
"Turns",
"a",
"ZIP",
"file",
"into",
"a",
"frozen",
"sample",
"."
] | fb8e7636ed07c3d035433fdd153599ac8b24dfc4 | https://github.com/monkeython/scriba/blob/fb8e7636ed07c3d035433fdd153599ac8b24dfc4/scriba/content_types/scriba_zip.py#L13-L24 |
248,679 | monkeython/scriba | scriba/content_types/scriba_zip.py | format | def format(collection, **params):
"""Truns a python object into a ZIP file."""
binary = io.BytesIO()
with zipfile.ZipFile(binary, 'w') as zip_:
now = datetime.datetime.utcnow().timetuple()
for filename, content in collection:
content_type, encoding = mimetypes.guess_type(filename... | python | def format(collection, **params):
"""Truns a python object into a ZIP file."""
binary = io.BytesIO()
with zipfile.ZipFile(binary, 'w') as zip_:
now = datetime.datetime.utcnow().timetuple()
for filename, content in collection:
content_type, encoding = mimetypes.guess_type(filename... | [
"def",
"format",
"(",
"collection",
",",
"*",
"*",
"params",
")",
":",
"binary",
"=",
"io",
".",
"BytesIO",
"(",
")",
"with",
"zipfile",
".",
"ZipFile",
"(",
"binary",
",",
"'w'",
")",
"as",
"zip_",
":",
"now",
"=",
"datetime",
".",
"datetime",
"."... | Truns a python object into a ZIP file. | [
"Truns",
"a",
"python",
"object",
"into",
"a",
"ZIP",
"file",
"."
] | fb8e7636ed07c3d035433fdd153599ac8b24dfc4 | https://github.com/monkeython/scriba/blob/fb8e7636ed07c3d035433fdd153599ac8b24dfc4/scriba/content_types/scriba_zip.py#L27-L40 |
248,680 | minhhoit/yacms | yacms/generic/templatetags/keyword_tags.py | keywords_for | def keywords_for(*args):
"""
Return a list of ``Keyword`` objects for the given model instance
or a model class. In the case of a model class, retrieve all
keywords for all instances of the model and apply a ``weight``
attribute that can be used to create a tag cloud.
"""
# Handle a model i... | python | def keywords_for(*args):
"""
Return a list of ``Keyword`` objects for the given model instance
or a model class. In the case of a model class, retrieve all
keywords for all instances of the model and apply a ``weight``
attribute that can be used to create a tag cloud.
"""
# Handle a model i... | [
"def",
"keywords_for",
"(",
"*",
"args",
")",
":",
"# Handle a model instance.",
"if",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"Model",
")",
":",
"obj",
"=",
"args",
"[",
"0",
"]",
"if",
"getattr",
"(",
"obj",
",",
"\"content_model\"",
",",
"Non... | Return a list of ``Keyword`` objects for the given model instance
or a model class. In the case of a model class, retrieve all
keywords for all instances of the model and apply a ``weight``
attribute that can be used to create a tag cloud. | [
"Return",
"a",
"list",
"of",
"Keyword",
"objects",
"for",
"the",
"given",
"model",
"instance",
"or",
"a",
"model",
"class",
".",
"In",
"the",
"case",
"of",
"a",
"model",
"class",
"retrieve",
"all",
"keywords",
"for",
"all",
"instances",
"of",
"the",
"mod... | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/templatetags/keyword_tags.py#L16-L57 |
248,681 | tBaxter/tango-comments | build/lib/tango_comments/views/moderation.py | flag | def flag(request, comment_id, next=None):
"""
Flags a comment. Confirmation on GET, action on POST.
Templates: :template:`comments/flag.html`,
Context:
comment
the flagged `comments.comment` object
"""
comment = get_object_or_404(comments.get_model(), pk=comment_id, site__pk... | python | def flag(request, comment_id, next=None):
"""
Flags a comment. Confirmation on GET, action on POST.
Templates: :template:`comments/flag.html`,
Context:
comment
the flagged `comments.comment` object
"""
comment = get_object_or_404(comments.get_model(), pk=comment_id, site__pk... | [
"def",
"flag",
"(",
"request",
",",
"comment_id",
",",
"next",
"=",
"None",
")",
":",
"comment",
"=",
"get_object_or_404",
"(",
"comments",
".",
"get_model",
"(",
")",
",",
"pk",
"=",
"comment_id",
",",
"site__pk",
"=",
"settings",
".",
"SITE_ID",
")",
... | Flags a comment. Confirmation on GET, action on POST.
Templates: :template:`comments/flag.html`,
Context:
comment
the flagged `comments.comment` object | [
"Flags",
"a",
"comment",
".",
"Confirmation",
"on",
"GET",
"action",
"on",
"POST",
"."
] | 1fd335c6fc9e81bba158e42e1483f1a149622ab4 | https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/views/moderation.py#L15-L37 |
248,682 | tBaxter/tango-comments | build/lib/tango_comments/views/moderation.py | perform_flag | def perform_flag(request, comment):
"""
Actually perform the flagging of a comment from a request.
"""
flag, created = comments.models.CommentFlag.objects.get_or_create(
comment = comment,
user = request.user,
flag = comments.models.CommentFlag.SUGGEST_REMOVAL
)
sig... | python | def perform_flag(request, comment):
"""
Actually perform the flagging of a comment from a request.
"""
flag, created = comments.models.CommentFlag.objects.get_or_create(
comment = comment,
user = request.user,
flag = comments.models.CommentFlag.SUGGEST_REMOVAL
)
sig... | [
"def",
"perform_flag",
"(",
"request",
",",
"comment",
")",
":",
"flag",
",",
"created",
"=",
"comments",
".",
"models",
".",
"CommentFlag",
".",
"objects",
".",
"get_or_create",
"(",
"comment",
"=",
"comment",
",",
"user",
"=",
"request",
".",
"user",
"... | Actually perform the flagging of a comment from a request. | [
"Actually",
"perform",
"the",
"flagging",
"of",
"a",
"comment",
"from",
"a",
"request",
"."
] | 1fd335c6fc9e81bba158e42e1483f1a149622ab4 | https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/views/moderation.py#L99-L114 |
248,683 | florianpaquet/mease | mease/server.py | MeaseWebSocketServerProtocol.onConnect | def onConnect(self, request):
"""
Called when a client opens a websocket connection
"""
logger.debug("Connection opened ({peer})".format(peer=self.peer))
self.storage = {}
self._client_id = str(uuid1()) | python | def onConnect(self, request):
"""
Called when a client opens a websocket connection
"""
logger.debug("Connection opened ({peer})".format(peer=self.peer))
self.storage = {}
self._client_id = str(uuid1()) | [
"def",
"onConnect",
"(",
"self",
",",
"request",
")",
":",
"logger",
".",
"debug",
"(",
"\"Connection opened ({peer})\"",
".",
"format",
"(",
"peer",
"=",
"self",
".",
"peer",
")",
")",
"self",
".",
"storage",
"=",
"{",
"}",
"self",
".",
"_client_id",
... | Called when a client opens a websocket connection | [
"Called",
"when",
"a",
"client",
"opens",
"a",
"websocket",
"connection"
] | b9fbd08bbe162c8890c2a2124674371170c319ef | https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/server.py#L18-L25 |
248,684 | florianpaquet/mease | mease/server.py | MeaseWebSocketServerProtocol.onOpen | def onOpen(self):
"""
Called when a client has opened a websocket connection
"""
self.factory.add_client(self)
# Publish ON_OPEN message
self.factory.mease.publisher.publish(
message_type=ON_OPEN, client_id=self._client_id, client_storage=self.storage) | python | def onOpen(self):
"""
Called when a client has opened a websocket connection
"""
self.factory.add_client(self)
# Publish ON_OPEN message
self.factory.mease.publisher.publish(
message_type=ON_OPEN, client_id=self._client_id, client_storage=self.storage) | [
"def",
"onOpen",
"(",
"self",
")",
":",
"self",
".",
"factory",
".",
"add_client",
"(",
"self",
")",
"# Publish ON_OPEN message",
"self",
".",
"factory",
".",
"mease",
".",
"publisher",
".",
"publish",
"(",
"message_type",
"=",
"ON_OPEN",
",",
"client_id",
... | Called when a client has opened a websocket connection | [
"Called",
"when",
"a",
"client",
"has",
"opened",
"a",
"websocket",
"connection"
] | b9fbd08bbe162c8890c2a2124674371170c319ef | https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/server.py#L27-L35 |
248,685 | florianpaquet/mease | mease/server.py | MeaseWebSocketServerProtocol.onClose | def onClose(self, was_clean, code, reason):
"""
Called when a client closes a websocket connection
"""
logger.debug("Connection closed ({peer})".format(peer=self.peer))
# Publish ON_CLOSE message
self.factory.mease.publisher.publish(
message_type=ON_CLOSE, cl... | python | def onClose(self, was_clean, code, reason):
"""
Called when a client closes a websocket connection
"""
logger.debug("Connection closed ({peer})".format(peer=self.peer))
# Publish ON_CLOSE message
self.factory.mease.publisher.publish(
message_type=ON_CLOSE, cl... | [
"def",
"onClose",
"(",
"self",
",",
"was_clean",
",",
"code",
",",
"reason",
")",
":",
"logger",
".",
"debug",
"(",
"\"Connection closed ({peer})\"",
".",
"format",
"(",
"peer",
"=",
"self",
".",
"peer",
")",
")",
"# Publish ON_CLOSE message",
"self",
".",
... | Called when a client closes a websocket connection | [
"Called",
"when",
"a",
"client",
"closes",
"a",
"websocket",
"connection"
] | b9fbd08bbe162c8890c2a2124674371170c319ef | https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/server.py#L37-L47 |
248,686 | florianpaquet/mease | mease/server.py | MeaseWebSocketServerProtocol.onMessage | def onMessage(self, payload, is_binary):
"""
Called when a client sends a message
"""
if not is_binary:
payload = payload.decode('utf-8')
logger.debug("Incoming message ({peer}) : {message}".format(
peer=self.peer, message=payload))
#... | python | def onMessage(self, payload, is_binary):
"""
Called when a client sends a message
"""
if not is_binary:
payload = payload.decode('utf-8')
logger.debug("Incoming message ({peer}) : {message}".format(
peer=self.peer, message=payload))
#... | [
"def",
"onMessage",
"(",
"self",
",",
"payload",
",",
"is_binary",
")",
":",
"if",
"not",
"is_binary",
":",
"payload",
"=",
"payload",
".",
"decode",
"(",
"'utf-8'",
")",
"logger",
".",
"debug",
"(",
"\"Incoming message ({peer}) : {message}\"",
".",
"format",
... | Called when a client sends a message | [
"Called",
"when",
"a",
"client",
"sends",
"a",
"message"
] | b9fbd08bbe162c8890c2a2124674371170c319ef | https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/server.py#L49-L64 |
248,687 | florianpaquet/mease | mease/server.py | MeaseWebSocketServerProtocol.send | def send(self, payload, *args, **kwargs):
"""
Alias for WebSocketServerProtocol `sendMessage` method
"""
if isinstance(payload, (list, dict)):
payload = json.dumps(payload)
self.sendMessage(payload.encode(), *args, **kwargs) | python | def send(self, payload, *args, **kwargs):
"""
Alias for WebSocketServerProtocol `sendMessage` method
"""
if isinstance(payload, (list, dict)):
payload = json.dumps(payload)
self.sendMessage(payload.encode(), *args, **kwargs) | [
"def",
"send",
"(",
"self",
",",
"payload",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"payload",
",",
"(",
"list",
",",
"dict",
")",
")",
":",
"payload",
"=",
"json",
".",
"dumps",
"(",
"payload",
")",
"self",
... | Alias for WebSocketServerProtocol `sendMessage` method | [
"Alias",
"for",
"WebSocketServerProtocol",
"sendMessage",
"method"
] | b9fbd08bbe162c8890c2a2124674371170c319ef | https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/server.py#L75-L82 |
248,688 | florianpaquet/mease | mease/server.py | MeaseWebSocketServerFactory.run_server | def run_server(self):
"""
Runs the WebSocket server
"""
self.protocol = MeaseWebSocketServerProtocol
reactor.listenTCP(port=self.port, factory=self, interface=self.host)
logger.info("Websocket server listening on {address}".format(
address=self.address))
... | python | def run_server(self):
"""
Runs the WebSocket server
"""
self.protocol = MeaseWebSocketServerProtocol
reactor.listenTCP(port=self.port, factory=self, interface=self.host)
logger.info("Websocket server listening on {address}".format(
address=self.address))
... | [
"def",
"run_server",
"(",
"self",
")",
":",
"self",
".",
"protocol",
"=",
"MeaseWebSocketServerProtocol",
"reactor",
".",
"listenTCP",
"(",
"port",
"=",
"self",
".",
"port",
",",
"factory",
"=",
"self",
",",
"interface",
"=",
"self",
".",
"host",
")",
"l... | Runs the WebSocket server | [
"Runs",
"the",
"WebSocket",
"server"
] | b9fbd08bbe162c8890c2a2124674371170c319ef | https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/server.py#L129-L140 |
248,689 | blubberdiblub/eztemplate | eztemplate/engines/empy_engine.py | SubsystemWrapper.open | def open(self, name, *args, **kwargs):
"""Open file, possibly relative to a base directory."""
if self.basedir is not None:
name = os.path.join(self.basedir, name)
return em.Subsystem.open(self, name, *args, **kwargs) | python | def open(self, name, *args, **kwargs):
"""Open file, possibly relative to a base directory."""
if self.basedir is not None:
name = os.path.join(self.basedir, name)
return em.Subsystem.open(self, name, *args, **kwargs) | [
"def",
"open",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"basedir",
"is",
"not",
"None",
":",
"name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"basedir",
",",
"name",
")",
... | Open file, possibly relative to a base directory. | [
"Open",
"file",
"possibly",
"relative",
"to",
"a",
"base",
"directory",
"."
] | ab5b2b4987c045116d130fd83e216704b8edfb5d | https://github.com/blubberdiblub/eztemplate/blob/ab5b2b4987c045116d130fd83e216704b8edfb5d/eztemplate/engines/empy_engine.py#L32-L37 |
248,690 | Aslan11/wilos-cli | wilos/main.py | get_live_weather | def get_live_weather(lat, lon, writer):
"""Gets the live weather via lat and long"""
requrl = FORECAST_BASE_URL+forecast_api_token+'/'+str(lat)+','+str(lon)
req = requests.get(requrl)
if req.status_code == requests.codes.ok:
weather = req.json()
if not weather['currently']:
c... | python | def get_live_weather(lat, lon, writer):
"""Gets the live weather via lat and long"""
requrl = FORECAST_BASE_URL+forecast_api_token+'/'+str(lat)+','+str(lon)
req = requests.get(requrl)
if req.status_code == requests.codes.ok:
weather = req.json()
if not weather['currently']:
c... | [
"def",
"get_live_weather",
"(",
"lat",
",",
"lon",
",",
"writer",
")",
":",
"requrl",
"=",
"FORECAST_BASE_URL",
"+",
"forecast_api_token",
"+",
"'/'",
"+",
"str",
"(",
"lat",
")",
"+",
"','",
"+",
"str",
"(",
"lon",
")",
"req",
"=",
"requests",
".",
... | Gets the live weather via lat and long | [
"Gets",
"the",
"live",
"weather",
"via",
"lat",
"and",
"long"
] | 2c3da3589f685e95b4f73237a1bfe56373ea4574 | https://github.com/Aslan11/wilos-cli/blob/2c3da3589f685e95b4f73237a1bfe56373ea4574/wilos/main.py#L53-L64 |
248,691 | markomanninen/abnum | romanize/grc.py | convert | def convert(string, sanitize=False):
"""
Swap characters from script to transliterated version and vice versa.
Optionally sanitize string by using preprocess function.
:param sanitize:
:param string:
:return:
"""
return r.convert(string, (preprocess if sanitize else False)) | python | def convert(string, sanitize=False):
"""
Swap characters from script to transliterated version and vice versa.
Optionally sanitize string by using preprocess function.
:param sanitize:
:param string:
:return:
"""
return r.convert(string, (preprocess if sanitize else False)) | [
"def",
"convert",
"(",
"string",
",",
"sanitize",
"=",
"False",
")",
":",
"return",
"r",
".",
"convert",
"(",
"string",
",",
"(",
"preprocess",
"if",
"sanitize",
"else",
"False",
")",
")"
] | Swap characters from script to transliterated version and vice versa.
Optionally sanitize string by using preprocess function.
:param sanitize:
:param string:
:return: | [
"Swap",
"characters",
"from",
"script",
"to",
"transliterated",
"version",
"and",
"vice",
"versa",
".",
"Optionally",
"sanitize",
"string",
"by",
"using",
"preprocess",
"function",
"."
] | 9bfc8f06f34d9a51aab038638f87e2bb5f9f4c99 | https://github.com/markomanninen/abnum/blob/9bfc8f06f34d9a51aab038638f87e2bb5f9f4c99/romanize/grc.py#L204-L213 |
248,692 | kubernauts/pyk | pyk/util.py | load_yaml | def load_yaml(filename):
"""
Loads a YAML-formatted file.
"""
with open(filename) as f:
ydoc = yaml.safe_load(f.read())
return (ydoc, serialize_tojson(ydoc)) | python | def load_yaml(filename):
"""
Loads a YAML-formatted file.
"""
with open(filename) as f:
ydoc = yaml.safe_load(f.read())
return (ydoc, serialize_tojson(ydoc)) | [
"def",
"load_yaml",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"ydoc",
"=",
"yaml",
".",
"safe_load",
"(",
"f",
".",
"read",
"(",
")",
")",
"return",
"(",
"ydoc",
",",
"serialize_tojson",
"(",
"ydoc",
")",
")"
... | Loads a YAML-formatted file. | [
"Loads",
"a",
"YAML",
"-",
"formatted",
"file",
"."
] | 88531b1f09f23c049b3ad7aa9caebfc02a4a420d | https://github.com/kubernauts/pyk/blob/88531b1f09f23c049b3ad7aa9caebfc02a4a420d/pyk/util.py#L12-L18 |
248,693 | kubernauts/pyk | pyk/util.py | serialize_yaml_tofile | def serialize_yaml_tofile(filename, resource):
"""
Serializes a K8S resource to YAML-formatted file.
"""
stream = file(filename, "w")
yaml.dump(resource, stream, default_flow_style=False) | python | def serialize_yaml_tofile(filename, resource):
"""
Serializes a K8S resource to YAML-formatted file.
"""
stream = file(filename, "w")
yaml.dump(resource, stream, default_flow_style=False) | [
"def",
"serialize_yaml_tofile",
"(",
"filename",
",",
"resource",
")",
":",
"stream",
"=",
"file",
"(",
"filename",
",",
"\"w\"",
")",
"yaml",
".",
"dump",
"(",
"resource",
",",
"stream",
",",
"default_flow_style",
"=",
"False",
")"
] | Serializes a K8S resource to YAML-formatted file. | [
"Serializes",
"a",
"K8S",
"resource",
"to",
"YAML",
"-",
"formatted",
"file",
"."
] | 88531b1f09f23c049b3ad7aa9caebfc02a4a420d | https://github.com/kubernauts/pyk/blob/88531b1f09f23c049b3ad7aa9caebfc02a4a420d/pyk/util.py#L20-L25 |
248,694 | monkeython/scriba | scriba/content_types/scriba_json.py | parse | def parse(binary, **params):
"""Turns a JSON structure into a python object."""
encoding = params.get('charset', 'UTF-8')
return json.loads(binary, encoding=encoding) | python | def parse(binary, **params):
"""Turns a JSON structure into a python object."""
encoding = params.get('charset', 'UTF-8')
return json.loads(binary, encoding=encoding) | [
"def",
"parse",
"(",
"binary",
",",
"*",
"*",
"params",
")",
":",
"encoding",
"=",
"params",
".",
"get",
"(",
"'charset'",
",",
"'UTF-8'",
")",
"return",
"json",
".",
"loads",
"(",
"binary",
",",
"encoding",
"=",
"encoding",
")"
] | Turns a JSON structure into a python object. | [
"Turns",
"a",
"JSON",
"structure",
"into",
"a",
"python",
"object",
"."
] | fb8e7636ed07c3d035433fdd153599ac8b24dfc4 | https://github.com/monkeython/scriba/blob/fb8e7636ed07c3d035433fdd153599ac8b24dfc4/scriba/content_types/scriba_json.py#L6-L9 |
248,695 | monkeython/scriba | scriba/content_types/scriba_json.py | format | def format(item, **params):
"""Truns a python object into a JSON structure."""
encoding = params.get('charset', 'UTF-8')
return json.dumps(item, encoding=encoding) | python | def format(item, **params):
"""Truns a python object into a JSON structure."""
encoding = params.get('charset', 'UTF-8')
return json.dumps(item, encoding=encoding) | [
"def",
"format",
"(",
"item",
",",
"*",
"*",
"params",
")",
":",
"encoding",
"=",
"params",
".",
"get",
"(",
"'charset'",
",",
"'UTF-8'",
")",
"return",
"json",
".",
"dumps",
"(",
"item",
",",
"encoding",
"=",
"encoding",
")"
] | Truns a python object into a JSON structure. | [
"Truns",
"a",
"python",
"object",
"into",
"a",
"JSON",
"structure",
"."
] | fb8e7636ed07c3d035433fdd153599ac8b24dfc4 | https://github.com/monkeython/scriba/blob/fb8e7636ed07c3d035433fdd153599ac8b24dfc4/scriba/content_types/scriba_json.py#L12-L15 |
248,696 | naphatkrit/easyci | easyci/results.py | save_results | def save_results(vcs, signature, result_path, patterns):
"""Save results matching `patterns` at `result_path`.
Args:
vcs (easyci.vcs.base.Vcs) - the VCS object for the actual project
(not the disposable copy)
signature (str) - the project state signature
... | python | def save_results(vcs, signature, result_path, patterns):
"""Save results matching `patterns` at `result_path`.
Args:
vcs (easyci.vcs.base.Vcs) - the VCS object for the actual project
(not the disposable copy)
signature (str) - the project state signature
... | [
"def",
"save_results",
"(",
"vcs",
",",
"signature",
",",
"result_path",
",",
"patterns",
")",
":",
"results_directory",
"=",
"_get_results_directory",
"(",
"vcs",
",",
"signature",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"results_directory",
... | Save results matching `patterns` at `result_path`.
Args:
vcs (easyci.vcs.base.Vcs) - the VCS object for the actual project
(not the disposable copy)
signature (str) - the project state signature
result_path (str) - the path containing the result, usually
... | [
"Save",
"results",
"matching",
"patterns",
"at",
"result_path",
"."
] | 7aee8d7694fe4e2da42ce35b0f700bc840c8b95f | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/results.py#L14-L38 |
248,697 | naphatkrit/easyci | easyci/results.py | sync_results | def sync_results(vcs, signature):
"""Sync the saved results for `signature` back to the project.
Args:
vcs (easyci.vcs.base.Vcs)
signature (str)
Raises:
ResultsNotFoundError
"""
results_directory = _get_results_directory(vcs, signature)
if not os.path.exists(results_dire... | python | def sync_results(vcs, signature):
"""Sync the saved results for `signature` back to the project.
Args:
vcs (easyci.vcs.base.Vcs)
signature (str)
Raises:
ResultsNotFoundError
"""
results_directory = _get_results_directory(vcs, signature)
if not os.path.exists(results_dire... | [
"def",
"sync_results",
"(",
"vcs",
",",
"signature",
")",
":",
"results_directory",
"=",
"_get_results_directory",
"(",
"vcs",
",",
"signature",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"results_directory",
")",
":",
"raise",
"ResultsNotFoundEr... | Sync the saved results for `signature` back to the project.
Args:
vcs (easyci.vcs.base.Vcs)
signature (str)
Raises:
ResultsNotFoundError | [
"Sync",
"the",
"saved",
"results",
"for",
"signature",
"back",
"to",
"the",
"project",
"."
] | 7aee8d7694fe4e2da42ce35b0f700bc840c8b95f | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/results.py#L41-L61 |
248,698 | naphatkrit/easyci | easyci/results.py | remove_results | def remove_results(vcs, signature):
"""Removed saved results for this signature
Args:
vcs (easyci.vcs.base.Vcs)
signature (str)
Raises:
ResultsNotFoundError
"""
results_directory = _get_results_directory(vcs, signature)
if not os.path.exists(results_directory):
r... | python | def remove_results(vcs, signature):
"""Removed saved results for this signature
Args:
vcs (easyci.vcs.base.Vcs)
signature (str)
Raises:
ResultsNotFoundError
"""
results_directory = _get_results_directory(vcs, signature)
if not os.path.exists(results_directory):
r... | [
"def",
"remove_results",
"(",
"vcs",
",",
"signature",
")",
":",
"results_directory",
"=",
"_get_results_directory",
"(",
"vcs",
",",
"signature",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"results_directory",
")",
":",
"raise",
"ResultsNotFound... | Removed saved results for this signature
Args:
vcs (easyci.vcs.base.Vcs)
signature (str)
Raises:
ResultsNotFoundError | [
"Removed",
"saved",
"results",
"for",
"this",
"signature"
] | 7aee8d7694fe4e2da42ce35b0f700bc840c8b95f | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/results.py#L64-L76 |
248,699 | naphatkrit/easyci | easyci/results.py | get_signatures_with_results | def get_signatures_with_results(vcs):
"""Returns the list of signatures for which test results are saved.
Args:
vcs (easyci.vcs.base.Vcs)
Returns:
List[str]
"""
results_dir = os.path.join(vcs.private_dir(), 'results')
if not os.path.exists(results_dir):
return []
re... | python | def get_signatures_with_results(vcs):
"""Returns the list of signatures for which test results are saved.
Args:
vcs (easyci.vcs.base.Vcs)
Returns:
List[str]
"""
results_dir = os.path.join(vcs.private_dir(), 'results')
if not os.path.exists(results_dir):
return []
re... | [
"def",
"get_signatures_with_results",
"(",
"vcs",
")",
":",
"results_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"vcs",
".",
"private_dir",
"(",
")",
",",
"'results'",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"results_dir",
")",
":"... | Returns the list of signatures for which test results are saved.
Args:
vcs (easyci.vcs.base.Vcs)
Returns:
List[str] | [
"Returns",
"the",
"list",
"of",
"signatures",
"for",
"which",
"test",
"results",
"are",
"saved",
"."
] | 7aee8d7694fe4e2da42ce35b0f700bc840c8b95f | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/results.py#L79-L92 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.