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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
53,700 | oasiswork/zimsoap | zimsoap/zobjects.py | ZObject.property | def property(self, property_name, default=Ellipsis):
""" Returns a property value
:param: default will return that value if the property is not found,
else, will raise a KeyError.
"""
try:
return self._a_tags[property_name]
except KeyError:
... | python | def property(self, property_name, default=Ellipsis):
""" Returns a property value
:param: default will return that value if the property is not found,
else, will raise a KeyError.
"""
try:
return self._a_tags[property_name]
except KeyError:
... | [
"def",
"property",
"(",
"self",
",",
"property_name",
",",
"default",
"=",
"Ellipsis",
")",
":",
"try",
":",
"return",
"self",
".",
"_a_tags",
"[",
"property_name",
"]",
"except",
"KeyError",
":",
"if",
"default",
"!=",
"Ellipsis",
":",
"return",
"default"... | Returns a property value
:param: default will return that value if the property is not found,
else, will raise a KeyError. | [
"Returns",
"a",
"property",
"value"
] | d1ea2eb4d50f263c9a16e5549af03f1eff3e295e | https://github.com/oasiswork/zimsoap/blob/d1ea2eb4d50f263c9a16e5549af03f1eff3e295e/zimsoap/zobjects.py#L117-L129 |
53,701 | oasiswork/zimsoap | zimsoap/zobjects.py | ZObject._unparse_a_tags | def _unparse_a_tags(cls, attrs_dict):
""" Iterates over the dictionary
:param: attrs_dict a dict of attributes
:returns: a SimpleXMLElement list containing <a> tags
"""
prop_tags = []
for k, v in attrs_dict.items():
node = {cls.ATTRNAME_PROPERTY: k, '_cont... | python | def _unparse_a_tags(cls, attrs_dict):
""" Iterates over the dictionary
:param: attrs_dict a dict of attributes
:returns: a SimpleXMLElement list containing <a> tags
"""
prop_tags = []
for k, v in attrs_dict.items():
node = {cls.ATTRNAME_PROPERTY: k, '_cont... | [
"def",
"_unparse_a_tags",
"(",
"cls",
",",
"attrs_dict",
")",
":",
"prop_tags",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"attrs_dict",
".",
"items",
"(",
")",
":",
"node",
"=",
"{",
"cls",
".",
"ATTRNAME_PROPERTY",
":",
"k",
",",
"'_content'",
":",... | Iterates over the dictionary
:param: attrs_dict a dict of attributes
:returns: a SimpleXMLElement list containing <a> tags | [
"Iterates",
"over",
"the",
"dictionary"
] | d1ea2eb4d50f263c9a16e5549af03f1eff3e295e | https://github.com/oasiswork/zimsoap/blob/d1ea2eb4d50f263c9a16e5549af03f1eff3e295e/zimsoap/zobjects.py#L193-L205 |
53,702 | oasiswork/zimsoap | zimsoap/zobjects.py | Identity.to_creator | def to_creator(self):
""" Returns the dict suitable for CreateIdentity or ModifyIdentity
"""
o = {}
for prop in ('name', 'id'):
if hasattr(self, prop):
o[prop] = getattr(self, prop)
try:
if len(self.a) > 0:
o['a'] = []
... | python | def to_creator(self):
""" Returns the dict suitable for CreateIdentity or ModifyIdentity
"""
o = {}
for prop in ('name', 'id'):
if hasattr(self, prop):
o[prop] = getattr(self, prop)
try:
if len(self.a) > 0:
o['a'] = []
... | [
"def",
"to_creator",
"(",
"self",
")",
":",
"o",
"=",
"{",
"}",
"for",
"prop",
"in",
"(",
"'name'",
",",
"'id'",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"prop",
")",
":",
"o",
"[",
"prop",
"]",
"=",
"getattr",
"(",
"self",
",",
"prop",
"... | Returns the dict suitable for CreateIdentity or ModifyIdentity | [
"Returns",
"the",
"dict",
"suitable",
"for",
"CreateIdentity",
"or",
"ModifyIdentity"
] | d1ea2eb4d50f263c9a16e5549af03f1eff3e295e | https://github.com/oasiswork/zimsoap/blob/d1ea2eb4d50f263c9a16e5549af03f1eff3e295e/zimsoap/zobjects.py#L340-L356 |
53,703 | oasiswork/zimsoap | zimsoap/zobjects.py | DistributionList.from_dict | def from_dict(cls, d):
""" Override default, adding the capture of members.
"""
o = super(DistributionList, cls).from_dict(d)
o.members = []
if 'dlm' in d:
o.members = [utils.get_content(member)
for member in utils.as_list(d["dlm"])]
r... | python | def from_dict(cls, d):
""" Override default, adding the capture of members.
"""
o = super(DistributionList, cls).from_dict(d)
o.members = []
if 'dlm' in d:
o.members = [utils.get_content(member)
for member in utils.as_list(d["dlm"])]
r... | [
"def",
"from_dict",
"(",
"cls",
",",
"d",
")",
":",
"o",
"=",
"super",
"(",
"DistributionList",
",",
"cls",
")",
".",
"from_dict",
"(",
"d",
")",
"o",
".",
"members",
"=",
"[",
"]",
"if",
"'dlm'",
"in",
"d",
":",
"o",
".",
"members",
"=",
"[",
... | Override default, adding the capture of members. | [
"Override",
"default",
"adding",
"the",
"capture",
"of",
"members",
"."
] | d1ea2eb4d50f263c9a16e5549af03f1eff3e295e | https://github.com/oasiswork/zimsoap/blob/d1ea2eb4d50f263c9a16e5549af03f1eff3e295e/zimsoap/zobjects.py#L415-L423 |
53,704 | oasiswork/zimsoap | zimsoap/zobjects.py | Signature.from_dict | def from_dict(cls, d):
""" Override default, adding the capture of content and contenttype.
"""
o = super(Signature, cls).from_dict(d)
if 'content' in d:
# Sometimes, several contents, (one txt, other html), take last
try:
o._content = d['content'... | python | def from_dict(cls, d):
""" Override default, adding the capture of content and contenttype.
"""
o = super(Signature, cls).from_dict(d)
if 'content' in d:
# Sometimes, several contents, (one txt, other html), take last
try:
o._content = d['content'... | [
"def",
"from_dict",
"(",
"cls",
",",
"d",
")",
":",
"o",
"=",
"super",
"(",
"Signature",
",",
"cls",
")",
".",
"from_dict",
"(",
"d",
")",
"if",
"'content'",
"in",
"d",
":",
"# Sometimes, several contents, (one txt, other html), take last",
"try",
":",
"o",... | Override default, adding the capture of content and contenttype. | [
"Override",
"default",
"adding",
"the",
"capture",
"of",
"content",
"and",
"contenttype",
"."
] | d1ea2eb4d50f263c9a16e5549af03f1eff3e295e | https://github.com/oasiswork/zimsoap/blob/d1ea2eb4d50f263c9a16e5549af03f1eff3e295e/zimsoap/zobjects.py#L431-L444 |
53,705 | oasiswork/zimsoap | zimsoap/zobjects.py | Signature.to_creator | def to_creator(self, for_modify=False):
""" Returns a dict object suitable for a 'CreateSignature'.
A signature object for creation is like :
<signature name="unittest">
<content type="text/plain">My signature content</content>
</signature>
which is :
... | python | def to_creator(self, for_modify=False):
""" Returns a dict object suitable for a 'CreateSignature'.
A signature object for creation is like :
<signature name="unittest">
<content type="text/plain">My signature content</content>
</signature>
which is :
... | [
"def",
"to_creator",
"(",
"self",
",",
"for_modify",
"=",
"False",
")",
":",
"signature",
"=",
"{",
"}",
"if",
"for_modify",
":",
"try",
":",
"# we should have an ID",
"signature",
"[",
"'id'",
"]",
"=",
"self",
".",
"id",
"except",
"AttributeError",
":",
... | Returns a dict object suitable for a 'CreateSignature'.
A signature object for creation is like :
<signature name="unittest">
<content type="text/plain">My signature content</content>
</signature>
which is :
{
'name' : 'unittest',
... | [
"Returns",
"a",
"dict",
"object",
"suitable",
"for",
"a",
"CreateSignature",
"."
] | d1ea2eb4d50f263c9a16e5549af03f1eff3e295e | https://github.com/oasiswork/zimsoap/blob/d1ea2eb4d50f263c9a16e5549af03f1eff3e295e/zimsoap/zobjects.py#L471-L530 |
53,706 | oasiswork/zimsoap | zimsoap/zobjects.py | Task.to_creator | def to_creator(self, subject, desc):
""" Return a python-zimbra dict for CreateTaskRequest
Example :
<CreateTaskRequest>
<m su="Task subject">
<inv>
<comp name="Task subject">
<fr>Task comment</fr>
<... | python | def to_creator(self, subject, desc):
""" Return a python-zimbra dict for CreateTaskRequest
Example :
<CreateTaskRequest>
<m su="Task subject">
<inv>
<comp name="Task subject">
<fr>Task comment</fr>
<... | [
"def",
"to_creator",
"(",
"self",
",",
"subject",
",",
"desc",
")",
":",
"task",
"=",
"{",
"'m'",
":",
"{",
"'su'",
":",
"subject",
",",
"'inv'",
":",
"{",
"'comp'",
":",
"{",
"'name'",
":",
"subject",
",",
"'fr'",
":",
"{",
"'_content'",
":",
"d... | Return a python-zimbra dict for CreateTaskRequest
Example :
<CreateTaskRequest>
<m su="Task subject">
<inv>
<comp name="Task subject">
<fr>Task comment</fr>
<desc>Task comment</desc>
</co... | [
"Return",
"a",
"python",
"-",
"zimbra",
"dict",
"for",
"CreateTaskRequest"
] | d1ea2eb4d50f263c9a16e5549af03f1eff3e295e | https://github.com/oasiswork/zimsoap/blob/d1ea2eb4d50f263c9a16e5549af03f1eff3e295e/zimsoap/zobjects.py#L550-L586 |
53,707 | wummel/dosage | setup.py | get_authors | def get_authors():
"""Read list of authors from a text file, filtering comments."""
authors = []
authorfile = os.path.join('doc', 'authors.txt')
with codecs.open(authorfile, 'r', 'utf-8') as f:
for line in f:
line = line.strip()
if line and not line.startswith(u'#'):
... | python | def get_authors():
"""Read list of authors from a text file, filtering comments."""
authors = []
authorfile = os.path.join('doc', 'authors.txt')
with codecs.open(authorfile, 'r', 'utf-8') as f:
for line in f:
line = line.strip()
if line and not line.startswith(u'#'):
... | [
"def",
"get_authors",
"(",
")",
":",
"authors",
"=",
"[",
"]",
"authorfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"'doc'",
",",
"'authors.txt'",
")",
"with",
"codecs",
".",
"open",
"(",
"authorfile",
",",
"'r'",
",",
"'utf-8'",
")",
"as",
"f",
... | Read list of authors from a text file, filtering comments. | [
"Read",
"list",
"of",
"authors",
"from",
"a",
"text",
"file",
"filtering",
"comments",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/setup.py#L12-L21 |
53,708 | synw/dataswim | dataswim/data/__init__.py | Df.clone_ | def clone_(self, quiet=False):
"""
Clone the DataSwim instance
"""
ds2 = self._duplicate_(quiet=True)
if ds2 is None:
self.err("Can not clone instance")
else:
if quiet is False:
self.ok("Instance cloned")
return ds2 | python | def clone_(self, quiet=False):
"""
Clone the DataSwim instance
"""
ds2 = self._duplicate_(quiet=True)
if ds2 is None:
self.err("Can not clone instance")
else:
if quiet is False:
self.ok("Instance cloned")
return ds2 | [
"def",
"clone_",
"(",
"self",
",",
"quiet",
"=",
"False",
")",
":",
"ds2",
"=",
"self",
".",
"_duplicate_",
"(",
"quiet",
"=",
"True",
")",
"if",
"ds2",
"is",
"None",
":",
"self",
".",
"err",
"(",
"\"Can not clone instance\"",
")",
"else",
":",
"if",... | Clone the DataSwim instance | [
"Clone",
"the",
"DataSwim",
"instance"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/__init__.py#L55-L65 |
53,709 | synw/dataswim | dataswim/data/__init__.py | Df.backup | def backup(self):
"""
Backup the main dataframe
"""
try:
self.backup_df = self.df.copy()
except Exception as e:
self.err(e, "Can not backup data")
return
self.ok("Dataframe backed up") | python | def backup(self):
"""
Backup the main dataframe
"""
try:
self.backup_df = self.df.copy()
except Exception as e:
self.err(e, "Can not backup data")
return
self.ok("Dataframe backed up") | [
"def",
"backup",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"backup_df",
"=",
"self",
".",
"df",
".",
"copy",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"err",
"(",
"e",
",",
"\"Can not backup data\"",
")",
"return",
"self",
... | Backup the main dataframe | [
"Backup",
"the",
"main",
"dataframe"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/__init__.py#L67-L76 |
53,710 | synw/dataswim | dataswim/data/__init__.py | Df.restore | def restore(self):
"""
Restore the main dataframe
"""
if self.backup_df is None:
self.warning("No dataframe is backed up: nothing restore")
return
self.df = self.backup_df
self.ok("Dataframe is restored") | python | def restore(self):
"""
Restore the main dataframe
"""
if self.backup_df is None:
self.warning("No dataframe is backed up: nothing restore")
return
self.df = self.backup_df
self.ok("Dataframe is restored") | [
"def",
"restore",
"(",
"self",
")",
":",
"if",
"self",
".",
"backup_df",
"is",
"None",
":",
"self",
".",
"warning",
"(",
"\"No dataframe is backed up: nothing restore\"",
")",
"return",
"self",
".",
"df",
"=",
"self",
".",
"backup_df",
"self",
".",
"ok",
"... | Restore the main dataframe | [
"Restore",
"the",
"main",
"dataframe"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/__init__.py#L78-L86 |
53,711 | synw/dataswim | dataswim/data/__init__.py | Df.load_json | def load_json(self, path, **kwargs):
"""Load data in the main dataframe from json
:param filepath: url of the csv file to load,
can be absolute if it starts with ``/``
or relative if it starts with ``./``
:type fi... | python | def load_json(self, path, **kwargs):
"""Load data in the main dataframe from json
:param filepath: url of the csv file to load,
can be absolute if it starts with ``/``
or relative if it starts with ``./``
:type fi... | [
"def",
"load_json",
"(",
"self",
",",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"df",
"=",
"pd",
".",
"read_json",
"(",
"path",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"df",
"=",
"df",
"except",
"Exception",
"as",
"e",
":",
"sel... | Load data in the main dataframe from json
:param filepath: url of the csv file to load,
can be absolute if it starts with ``/``
or relative if it starts with ``./``
:type filepath: str
:param kwargs: keyword argu... | [
"Load",
"data",
"in",
"the",
"main",
"dataframe",
"from",
"json"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/__init__.py#L88-L105 |
53,712 | synw/dataswim | dataswim/data/__init__.py | Df.load_h5 | def load_h5(self, filepath):
"""Load a Hdf5 file to the main dataframe
:param filepath: url of the csv file to load,
can be absolute if it starts with ``/``
or relative if it starts with ``./``
:type filepath: str... | python | def load_h5(self, filepath):
"""Load a Hdf5 file to the main dataframe
:param filepath: url of the csv file to load,
can be absolute if it starts with ``/``
or relative if it starts with ``./``
:type filepath: str... | [
"def",
"load_h5",
"(",
"self",
",",
"filepath",
")",
":",
"try",
":",
"self",
".",
"start",
"(",
"\"Loading Hdf5 data...\"",
")",
"self",
".",
"df",
"=",
"dd",
".",
"io",
".",
"load",
"(",
"filepath",
")",
"self",
".",
"end",
"(",
"\"Finished loading H... | Load a Hdf5 file to the main dataframe
:param filepath: url of the csv file to load,
can be absolute if it starts with ``/``
or relative if it starts with ``./``
:type filepath: str
:example: ``ds.load_h5("./myfi... | [
"Load",
"a",
"Hdf5",
"file",
"to",
"the",
"main",
"dataframe"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/__init__.py#L107-L122 |
53,713 | synw/dataswim | dataswim/data/__init__.py | Df.load_excel | def load_excel(self, filepath, **kwargs):
"""Set the main dataframe with the content of an Excel file
:param filepath: url of the csv file to load,
can be absolute if it starts with ``/``
or relative if it starts with ``./``
:type filepath: str
... | python | def load_excel(self, filepath, **kwargs):
"""Set the main dataframe with the content of an Excel file
:param filepath: url of the csv file to load,
can be absolute if it starts with ``/``
or relative if it starts with ``./``
:type filepath: str
... | [
"def",
"load_excel",
"(",
"self",
",",
"filepath",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"df",
"=",
"pd",
".",
"read_excel",
"(",
"filepath",
",",
"*",
"*",
"kwargs",
")",
"if",
"len",
"(",
"df",
".",
"index",
")",
"==",
"0",
":",
"sel... | Set the main dataframe with the content of an Excel file
:param filepath: url of the csv file to load,
can be absolute if it starts with ``/``
or relative if it starts with ``./``
:type filepath: str
:param kwargs: keyword arguments to pass to
... | [
"Set",
"the",
"main",
"dataframe",
"with",
"the",
"content",
"of",
"an",
"Excel",
"file"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/__init__.py#L124-L144 |
53,714 | synw/dataswim | dataswim/data/__init__.py | Df.load_csv | def load_csv(self, url, **kwargs):
"""Loads csv data in the main dataframe
:param url: url of the csv file to load:
can be absolute if it starts with ``/``
or relative if it starts with ``./``
:type url: str
:param kwargs: ... | python | def load_csv(self, url, **kwargs):
"""Loads csv data in the main dataframe
:param url: url of the csv file to load:
can be absolute if it starts with ``/``
or relative if it starts with ``./``
:type url: str
:param kwargs: ... | [
"def",
"load_csv",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"start",
"(",
"\"Loading csv...\"",
")",
"try",
":",
"if",
"self",
".",
"datapath",
"is",
"not",
"None",
"and",
"url",
".",
"startswith",
"(",
"\"/\"",
")",
... | Loads csv data in the main dataframe
:param url: url of the csv file to load:
can be absolute if it starts with ``/``
or relative if it starts with ``./``
:type url: str
:param kwargs: keyword arguments to pass to Pandas
... | [
"Loads",
"csv",
"data",
"in",
"the",
"main",
"dataframe"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/__init__.py#L146-L171 |
53,715 | synw/dataswim | dataswim/data/__init__.py | Df.dateparser | def dateparser(self, dformat='%d/%m/%Y'):
"""
Returns a date parser for pandas
"""
def dateparse(dates):
return [pd.datetime.strptime(d, dformat) for d in dates]
return dateparse | python | def dateparser(self, dformat='%d/%m/%Y'):
"""
Returns a date parser for pandas
"""
def dateparse(dates):
return [pd.datetime.strptime(d, dformat) for d in dates]
return dateparse | [
"def",
"dateparser",
"(",
"self",
",",
"dformat",
"=",
"'%d/%m/%Y'",
")",
":",
"def",
"dateparse",
"(",
"dates",
")",
":",
"return",
"[",
"pd",
".",
"datetime",
".",
"strptime",
"(",
"d",
",",
"dformat",
")",
"for",
"d",
"in",
"dates",
"]",
"return",... | Returns a date parser for pandas | [
"Returns",
"a",
"date",
"parser",
"for",
"pandas"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/__init__.py#L173-L181 |
53,716 | gmr/tinman | tinman/auth/mixins.py | OAuth2Mixin.authenticate_redirect | def authenticate_redirect(self, callback_uri=None, cancel_uri=None,
extended_permissions=None, callback=None):
"""Perform the authentication redirect to GitHub
"""
self.require_setting(self._CLIENT_ID_SETTING, self._API_NAME)
scope = self._BASE_SCOPE
... | python | def authenticate_redirect(self, callback_uri=None, cancel_uri=None,
extended_permissions=None, callback=None):
"""Perform the authentication redirect to GitHub
"""
self.require_setting(self._CLIENT_ID_SETTING, self._API_NAME)
scope = self._BASE_SCOPE
... | [
"def",
"authenticate_redirect",
"(",
"self",
",",
"callback_uri",
"=",
"None",
",",
"cancel_uri",
"=",
"None",
",",
"extended_permissions",
"=",
"None",
",",
"callback",
"=",
"None",
")",
":",
"self",
".",
"require_setting",
"(",
"self",
".",
"_CLIENT_ID_SETTI... | Perform the authentication redirect to GitHub | [
"Perform",
"the",
"authentication",
"redirect",
"to",
"GitHub"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/auth/mixins.py#L36-L66 |
53,717 | gmr/tinman | tinman/auth/mixins.py | OAuth2Mixin.get_authenticated_user | def get_authenticated_user(self, callback):
""" Fetches the authenticated user
:param method callback: The callback method to invoke
"""
self.require_setting(self._CLIENT_ID_SETTING, self._API_NAME)
self.require_setting(self._CLIENT_SECRET_SETTING, self._API_NAME)
if s... | python | def get_authenticated_user(self, callback):
""" Fetches the authenticated user
:param method callback: The callback method to invoke
"""
self.require_setting(self._CLIENT_ID_SETTING, self._API_NAME)
self.require_setting(self._CLIENT_SECRET_SETTING, self._API_NAME)
if s... | [
"def",
"get_authenticated_user",
"(",
"self",
",",
"callback",
")",
":",
"self",
".",
"require_setting",
"(",
"self",
".",
"_CLIENT_ID_SETTING",
",",
"self",
".",
"_API_NAME",
")",
"self",
".",
"require_setting",
"(",
"self",
".",
"_CLIENT_SECRET_SETTING",
",",
... | Fetches the authenticated user
:param method callback: The callback method to invoke | [
"Fetches",
"the",
"authenticated",
"user"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/auth/mixins.py#L69-L98 |
53,718 | gmr/tinman | tinman/auth/mixins.py | GithubMixin._on_access_token | def _on_access_token(self, future, response):
"""Invoked as a callback when GitHub has returned a response to the
access token request.
:param method future: The callback method to pass along
:param tornado.httpclient.HTTPResponse response: The HTTP response
"""
content... | python | def _on_access_token(self, future, response):
"""Invoked as a callback when GitHub has returned a response to the
access token request.
:param method future: The callback method to pass along
:param tornado.httpclient.HTTPResponse response: The HTTP response
"""
content... | [
"def",
"_on_access_token",
"(",
"self",
",",
"future",
",",
"response",
")",
":",
"content",
"=",
"escape",
".",
"json_decode",
"(",
"response",
".",
"body",
")",
"if",
"'error'",
"in",
"content",
":",
"LOGGER",
".",
"error",
"(",
"'Error fetching access tok... | Invoked as a callback when GitHub has returned a response to the
access token request.
:param method future: The callback method to pass along
:param tornado.httpclient.HTTPResponse response: The HTTP response | [
"Invoked",
"as",
"a",
"callback",
"when",
"GitHub",
"has",
"returned",
"a",
"response",
"to",
"the",
"access",
"token",
"request",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/auth/mixins.py#L131-L147 |
53,719 | gmr/tinman | tinman/auth/mixins.py | GithubMixin._on_github_user | def _on_github_user(self, future, access_token, response):
"""Invoked as a callback when self.github_request returns the response
to the request for user data.
:param method future: The callback method to pass along
:param str access_token: The access token for the user's use
:p... | python | def _on_github_user(self, future, access_token, response):
"""Invoked as a callback when self.github_request returns the response
to the request for user data.
:param method future: The callback method to pass along
:param str access_token: The access token for the user's use
:p... | [
"def",
"_on_github_user",
"(",
"self",
",",
"future",
",",
"access_token",
",",
"response",
")",
":",
"response",
"[",
"'access_token'",
"]",
"=",
"access_token",
"future",
".",
"set_result",
"(",
"response",
")"
] | Invoked as a callback when self.github_request returns the response
to the request for user data.
:param method future: The callback method to pass along
:param str access_token: The access token for the user's use
:param dict response: The HTTP response already decoded | [
"Invoked",
"as",
"a",
"callback",
"when",
"self",
".",
"github_request",
"returns",
"the",
"response",
"to",
"the",
"request",
"for",
"user",
"data",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/auth/mixins.py#L149-L159 |
53,720 | gmr/tinman | tinman/auth/mixins.py | GithubMixin.github_request | def github_request(self, path, callback, access_token=None,
post_args=None, **kwargs):
"""Make a request to the GitHub API, passing in the path, a callback,
the access token, optional post arguments and keyword arguments to be
added as values in the request body or URI
... | python | def github_request(self, path, callback, access_token=None,
post_args=None, **kwargs):
"""Make a request to the GitHub API, passing in the path, a callback,
the access token, optional post arguments and keyword arguments to be
added as values in the request body or URI
... | [
"def",
"github_request",
"(",
"self",
",",
"path",
",",
"callback",
",",
"access_token",
"=",
"None",
",",
"post_args",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"_API_URL",
"+",
"path",
"all_args",
"=",
"{",
"}",
"if",... | Make a request to the GitHub API, passing in the path, a callback,
the access token, optional post arguments and keyword arguments to be
added as values in the request body or URI | [
"Make",
"a",
"request",
"to",
"the",
"GitHub",
"API",
"passing",
"in",
"the",
"path",
"a",
"callback",
"the",
"access",
"token",
"optional",
"post",
"arguments",
"and",
"keyword",
"arguments",
"to",
"be",
"added",
"as",
"values",
"in",
"the",
"request",
"b... | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/auth/mixins.py#L162-L184 |
53,721 | gmr/tinman | tinman/auth/mixins.py | GithubMixin._on_github_request | def _on_github_request(self, future, response):
"""Invoked as a response to the GitHub API request. Will decode the
response and set the result for the future to return the callback or
raise an exception
"""
try:
content = escape.json_decode(response.body)
ex... | python | def _on_github_request(self, future, response):
"""Invoked as a response to the GitHub API request. Will decode the
response and set the result for the future to return the callback or
raise an exception
"""
try:
content = escape.json_decode(response.body)
ex... | [
"def",
"_on_github_request",
"(",
"self",
",",
"future",
",",
"response",
")",
":",
"try",
":",
"content",
"=",
"escape",
".",
"json_decode",
"(",
"response",
".",
"body",
")",
"except",
"ValueError",
"as",
"error",
":",
"future",
".",
"set_exception",
"("... | Invoked as a response to the GitHub API request. Will decode the
response and set the result for the future to return the callback or
raise an exception | [
"Invoked",
"as",
"a",
"response",
"to",
"the",
"GitHub",
"API",
"request",
".",
"Will",
"decode",
"the",
"response",
"and",
"set",
"the",
"result",
"for",
"the",
"future",
"to",
"return",
"the",
"callback",
"or",
"raise",
"an",
"exception"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/auth/mixins.py#L186-L203 |
53,722 | gmr/tinman | tinman/auth/mixins.py | StackExchangeMixin._on_access_token | def _on_access_token(self, future, response):
"""Invoked as a callback when StackExchange has returned a response to
the access token request.
:param method future: The callback method to pass along
:param tornado.httpclient.HTTPResponse response: The HTTP response
"""
... | python | def _on_access_token(self, future, response):
"""Invoked as a callback when StackExchange has returned a response to
the access token request.
:param method future: The callback method to pass along
:param tornado.httpclient.HTTPResponse response: The HTTP response
"""
... | [
"def",
"_on_access_token",
"(",
"self",
",",
"future",
",",
"response",
")",
":",
"LOGGER",
".",
"info",
"(",
"response",
".",
"body",
")",
"content",
"=",
"escape",
".",
"json_decode",
"(",
"response",
".",
"body",
")",
"if",
"'error'",
"in",
"content",... | Invoked as a callback when StackExchange has returned a response to
the access token request.
:param method future: The callback method to pass along
:param tornado.httpclient.HTTPResponse response: The HTTP response | [
"Invoked",
"as",
"a",
"callback",
"when",
"StackExchange",
"has",
"returned",
"a",
"response",
"to",
"the",
"access",
"token",
"request",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/auth/mixins.py#L224-L241 |
53,723 | gmr/tinman | tinman/auth/mixins.py | StackExchangeMixin._on_stackexchange_user | def _on_stackexchange_user(self, future, access_token, response):
"""Invoked as a callback when self.stackexchange_request returns the
response to the request for user data.
:param method future: The callback method to pass along
:param str access_token: The access token for the user's ... | python | def _on_stackexchange_user(self, future, access_token, response):
"""Invoked as a callback when self.stackexchange_request returns the
response to the request for user data.
:param method future: The callback method to pass along
:param str access_token: The access token for the user's ... | [
"def",
"_on_stackexchange_user",
"(",
"self",
",",
"future",
",",
"access_token",
",",
"response",
")",
":",
"response",
"[",
"'access_token'",
"]",
"=",
"access_token",
"future",
".",
"set_result",
"(",
"response",
")"
] | Invoked as a callback when self.stackexchange_request returns the
response to the request for user data.
:param method future: The callback method to pass along
:param str access_token: The access token for the user's use
:param dict response: The HTTP response already decoded | [
"Invoked",
"as",
"a",
"callback",
"when",
"self",
".",
"stackexchange_request",
"returns",
"the",
"response",
"to",
"the",
"request",
"for",
"user",
"data",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/auth/mixins.py#L243-L253 |
53,724 | gmr/tinman | tinman/auth/mixins.py | StackExchangeMixin.stackexchange_request | def stackexchange_request(self, path, callback, access_token=None,
post_args=None, **kwargs):
"""Make a request to the StackExchange API, passing in the path, a
callback, the access token, optional post arguments and keyword
arguments to be added as values in the request b... | python | def stackexchange_request(self, path, callback, access_token=None,
post_args=None, **kwargs):
"""Make a request to the StackExchange API, passing in the path, a
callback, the access token, optional post arguments and keyword
arguments to be added as values in the request b... | [
"def",
"stackexchange_request",
"(",
"self",
",",
"path",
",",
"callback",
",",
"access_token",
"=",
"None",
",",
"post_args",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"_API_URL",
"+",
"path",
"all_args",
"=",
"{",
"}",
... | Make a request to the StackExchange API, passing in the path, a
callback, the access token, optional post arguments and keyword
arguments to be added as values in the request body or URI | [
"Make",
"a",
"request",
"to",
"the",
"StackExchange",
"API",
"passing",
"in",
"the",
"path",
"a",
"callback",
"the",
"access",
"token",
"optional",
"post",
"arguments",
"and",
"keyword",
"arguments",
"to",
"be",
"added",
"as",
"values",
"in",
"the",
"request... | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/auth/mixins.py#L256-L277 |
53,725 | gmr/tinman | tinman/auth/mixins.py | StackExchangeMixin._on_stackexchange_request | def _on_stackexchange_request(self, future, response):
"""Invoked as a response to the StackExchange API request. Will decode
the response and set the result for the future to return the callback or
raise an exception
"""
content = escape.json_decode(response.body)
if 'e... | python | def _on_stackexchange_request(self, future, response):
"""Invoked as a response to the StackExchange API request. Will decode
the response and set the result for the future to return the callback or
raise an exception
"""
content = escape.json_decode(response.body)
if 'e... | [
"def",
"_on_stackexchange_request",
"(",
"self",
",",
"future",
",",
"response",
")",
":",
"content",
"=",
"escape",
".",
"json_decode",
"(",
"response",
".",
"body",
")",
"if",
"'error'",
"in",
"content",
":",
"future",
".",
"set_exception",
"(",
"Exception... | Invoked as a response to the StackExchange API request. Will decode
the response and set the result for the future to return the callback or
raise an exception | [
"Invoked",
"as",
"a",
"response",
"to",
"the",
"StackExchange",
"API",
"request",
".",
"Will",
"decode",
"the",
"response",
"and",
"set",
"the",
"result",
"for",
"the",
"future",
"to",
"return",
"the",
"callback",
"or",
"raise",
"an",
"exception"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/auth/mixins.py#L279-L290 |
53,726 | danpoland/pyramid-restful-framework | pyramid_restful/filters.py | AttributeBaseFilter.filter_query | def filter_query(self, request, query, view):
"""
You may want to override this method if you want to add custom filtering to an ViewSet while still
utilizing the feature of the ``AttributeFilter`` implementation.
:param request: The pyramid ``Request`` instance.
:param query: T... | python | def filter_query(self, request, query, view):
"""
You may want to override this method if you want to add custom filtering to an ViewSet while still
utilizing the feature of the ``AttributeFilter`` implementation.
:param request: The pyramid ``Request`` instance.
:param query: T... | [
"def",
"filter_query",
"(",
"self",
",",
"request",
",",
"query",
",",
"view",
")",
":",
"if",
"not",
"request",
".",
"params",
":",
"return",
"query",
"querystring_params",
"=",
"self",
".",
"parse_query_string",
"(",
"request",
".",
"params",
")",
"query... | You may want to override this method if you want to add custom filtering to an ViewSet while still
utilizing the feature of the ``AttributeFilter`` implementation.
:param request: The pyramid ``Request`` instance.
:param query: The SQLAlchemy ``Query`` instance.
:param view: An instance... | [
"You",
"may",
"want",
"to",
"override",
"this",
"method",
"if",
"you",
"want",
"to",
"add",
"custom",
"filtering",
"to",
"an",
"ViewSet",
"while",
"still",
"utilizing",
"the",
"feature",
"of",
"the",
"AttributeFilter",
"implementation",
"."
] | 4d8c9db44b1869c3d1fdd59ca304c3166473fcbb | https://github.com/danpoland/pyramid-restful-framework/blob/4d8c9db44b1869c3d1fdd59ca304c3166473fcbb/pyramid_restful/filters.py#L58-L75 |
53,727 | ojii/django-multilingual-ng | multilingual/flatpages/views.py | multilingual_flatpage | def multilingual_flatpage(request, url):
"""
Multilingual flat page view.
Models: `multilingual.flatpages.models`
Templates: Uses the template defined by the ``template_name`` field,
or `flatpages/default.html` if template_name is not defined.
Context:
flatpage
`flatpage... | python | def multilingual_flatpage(request, url):
"""
Multilingual flat page view.
Models: `multilingual.flatpages.models`
Templates: Uses the template defined by the ``template_name`` field,
or `flatpages/default.html` if template_name is not defined.
Context:
flatpage
`flatpage... | [
"def",
"multilingual_flatpage",
"(",
"request",
",",
"url",
")",
":",
"if",
"not",
"url",
".",
"endswith",
"(",
"'/'",
")",
"and",
"settings",
".",
"APPEND_SLASH",
":",
"return",
"HttpResponseRedirect",
"(",
"\"%s/\"",
"%",
"request",
".",
"path",
")",
"if... | Multilingual flat page view.
Models: `multilingual.flatpages.models`
Templates: Uses the template defined by the ``template_name`` field,
or `flatpages/default.html` if template_name is not defined.
Context:
flatpage
`flatpages.flatpages` object | [
"Multilingual",
"flat",
"page",
"view",
"."
] | 0d320a0732ec59949380d4b5f21e153174d3ecf7 | https://github.com/ojii/django-multilingual-ng/blob/0d320a0732ec59949380d4b5f21e153174d3ecf7/multilingual/flatpages/views.py#L13-L53 |
53,728 | dirko/pyhacrf | pyhacrf/feature_extraction.py | PairFeatureExtractor.transform | def transform(self, raw_X, y=None):
"""Transform sequence pairs to feature arrays that can be used as input to `Hacrf` models.
Parameters
----------
raw_X : List of (sequence1_n, sequence2_n) pairs, one for each training example n.
y : (ignored)
Returns
-------
... | python | def transform(self, raw_X, y=None):
"""Transform sequence pairs to feature arrays that can be used as input to `Hacrf` models.
Parameters
----------
raw_X : List of (sequence1_n, sequence2_n) pairs, one for each training example n.
y : (ignored)
Returns
-------
... | [
"def",
"transform",
"(",
"self",
",",
"raw_X",
",",
"y",
"=",
"None",
")",
":",
"return",
"[",
"self",
".",
"_extract_features",
"(",
"sequence1",
",",
"sequence2",
")",
"for",
"sequence1",
",",
"sequence2",
"in",
"raw_X",
"]"
] | Transform sequence pairs to feature arrays that can be used as input to `Hacrf` models.
Parameters
----------
raw_X : List of (sequence1_n, sequence2_n) pairs, one for each training example n.
y : (ignored)
Returns
-------
X : List of numpy ndarrays, each with ... | [
"Transform",
"sequence",
"pairs",
"to",
"feature",
"arrays",
"that",
"can",
"be",
"used",
"as",
"input",
"to",
"Hacrf",
"models",
"."
] | 51455681d4edf88e5323313fc0f6b85577ae185c | https://github.com/dirko/pyhacrf/blob/51455681d4edf88e5323313fc0f6b85577ae185c/pyhacrf/feature_extraction.py#L112-L126 |
53,729 | dirko/pyhacrf | pyhacrf/feature_extraction.py | PairFeatureExtractor._extract_features | def _extract_features(self, sequence1, sequence2):
""" Helper to extract features for one data point. """
array1 = np.array(tuple(sequence1), ndmin=2).T
array2 = np.array(tuple(sequence2), ndmin=2)
K = (len(self._binary_features)
+ sum(num_feats for _, num_feats in self._... | python | def _extract_features(self, sequence1, sequence2):
""" Helper to extract features for one data point. """
array1 = np.array(tuple(sequence1), ndmin=2).T
array2 = np.array(tuple(sequence2), ndmin=2)
K = (len(self._binary_features)
+ sum(num_feats for _, num_feats in self._... | [
"def",
"_extract_features",
"(",
"self",
",",
"sequence1",
",",
"sequence2",
")",
":",
"array1",
"=",
"np",
".",
"array",
"(",
"tuple",
"(",
"sequence1",
")",
",",
"ndmin",
"=",
"2",
")",
".",
"T",
"array2",
"=",
"np",
".",
"array",
"(",
"tuple",
"... | Helper to extract features for one data point. | [
"Helper",
"to",
"extract",
"features",
"for",
"one",
"data",
"point",
"."
] | 51455681d4edf88e5323313fc0f6b85577ae185c | https://github.com/dirko/pyhacrf/blob/51455681d4edf88e5323313fc0f6b85577ae185c/pyhacrf/feature_extraction.py#L128-L153 |
53,730 | synw/dataswim | dataswim/messages.py | Message.ok | def ok(self, *msg):
"""
Prints a message with an ok prefix
"""
label = colors.green("OK")
self._msg(label, *msg) | python | def ok(self, *msg):
"""
Prints a message with an ok prefix
"""
label = colors.green("OK")
self._msg(label, *msg) | [
"def",
"ok",
"(",
"self",
",",
"*",
"msg",
")",
":",
"label",
"=",
"colors",
".",
"green",
"(",
"\"OK\"",
")",
"self",
".",
"_msg",
"(",
"label",
",",
"*",
"msg",
")"
] | Prints a message with an ok prefix | [
"Prints",
"a",
"message",
"with",
"an",
"ok",
"prefix"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/messages.py#L12-L17 |
53,731 | synw/dataswim | dataswim/messages.py | Message.info | def info(self, *msg):
"""
Prints a message with an info prefix
"""
label = colors.blue("INFO")
self._msg(label, *msg) | python | def info(self, *msg):
"""
Prints a message with an info prefix
"""
label = colors.blue("INFO")
self._msg(label, *msg) | [
"def",
"info",
"(",
"self",
",",
"*",
"msg",
")",
":",
"label",
"=",
"colors",
".",
"blue",
"(",
"\"INFO\"",
")",
"self",
".",
"_msg",
"(",
"label",
",",
"*",
"msg",
")"
] | Prints a message with an info prefix | [
"Prints",
"a",
"message",
"with",
"an",
"info",
"prefix"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/messages.py#L19-L24 |
53,732 | synw/dataswim | dataswim/messages.py | Message.status | def status(self, *msg):
"""
Prints a status message
"""
label = colors.yellow("STATUS")
self._msg(label, *msg) | python | def status(self, *msg):
"""
Prints a status message
"""
label = colors.yellow("STATUS")
self._msg(label, *msg) | [
"def",
"status",
"(",
"self",
",",
"*",
"msg",
")",
":",
"label",
"=",
"colors",
".",
"yellow",
"(",
"\"STATUS\"",
")",
"self",
".",
"_msg",
"(",
"label",
",",
"*",
"msg",
")"
] | Prints a status message | [
"Prints",
"a",
"status",
"message"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/messages.py#L26-L31 |
53,733 | synw/dataswim | dataswim/messages.py | Message.progress | def progress(self, *msg):
"""
Prints a progress message
"""
label = colors.purple("Progress")
self._msg(label, *msg) | python | def progress(self, *msg):
"""
Prints a progress message
"""
label = colors.purple("Progress")
self._msg(label, *msg) | [
"def",
"progress",
"(",
"self",
",",
"*",
"msg",
")",
":",
"label",
"=",
"colors",
".",
"purple",
"(",
"\"Progress\"",
")",
"self",
".",
"_msg",
"(",
"label",
",",
"*",
"msg",
")"
] | Prints a progress message | [
"Prints",
"a",
"progress",
"message"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/messages.py#L47-L52 |
53,734 | synw/dataswim | dataswim/messages.py | Message.start | def start(self, *msg):
"""
Prints an start message
"""
self.start_time = datetime.datetime.now()
label = colors.purple("START")
self._msg(label, *msg) | python | def start(self, *msg):
"""
Prints an start message
"""
self.start_time = datetime.datetime.now()
label = colors.purple("START")
self._msg(label, *msg) | [
"def",
"start",
"(",
"self",
",",
"*",
"msg",
")",
":",
"self",
".",
"start_time",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"label",
"=",
"colors",
".",
"purple",
"(",
"\"START\"",
")",
"self",
".",
"_msg",
"(",
"label",
",",
"*",
... | Prints an start message | [
"Prints",
"an",
"start",
"message"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/messages.py#L54-L60 |
53,735 | synw/dataswim | dataswim/messages.py | Message.end | def end(self, *msg):
"""
Prints an end message with elapsed time
"""
if self.start_time is None:
self.err("No start time set: please use start() "
"before using this function")
endtime = datetime.datetime.now()
rd = dateutil.relativedelta.... | python | def end(self, *msg):
"""
Prints an end message with elapsed time
"""
if self.start_time is None:
self.err("No start time set: please use start() "
"before using this function")
endtime = datetime.datetime.now()
rd = dateutil.relativedelta.... | [
"def",
"end",
"(",
"self",
",",
"*",
"msg",
")",
":",
"if",
"self",
".",
"start_time",
"is",
"None",
":",
"self",
".",
"err",
"(",
"\"No start time set: please use start() \"",
"\"before using this function\"",
")",
"endtime",
"=",
"datetime",
".",
"datetime",
... | Prints an end message with elapsed time | [
"Prints",
"an",
"end",
"message",
"with",
"elapsed",
"time"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/messages.py#L62-L75 |
53,736 | synw/dataswim | dataswim/messages.py | Message.html | def html(self, label, *msg):
"""
Prints html in notebook
"""
lbl = "[" + label + "] "
txt = lbl + " " + " ".join(list(msg))
if self.notebook is True:
html = HTML(txt)
display(lbl + html)
else:
print(lbl + txt) | python | def html(self, label, *msg):
"""
Prints html in notebook
"""
lbl = "[" + label + "] "
txt = lbl + " " + " ".join(list(msg))
if self.notebook is True:
html = HTML(txt)
display(lbl + html)
else:
print(lbl + txt) | [
"def",
"html",
"(",
"self",
",",
"label",
",",
"*",
"msg",
")",
":",
"lbl",
"=",
"\"[\"",
"+",
"label",
"+",
"\"] \"",
"txt",
"=",
"lbl",
"+",
"\" \"",
"+",
"\" \"",
".",
"join",
"(",
"list",
"(",
"msg",
")",
")",
"if",
"self",
".",
"notebook",... | Prints html in notebook | [
"Prints",
"html",
"in",
"notebook"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/messages.py#L77-L87 |
53,737 | synw/dataswim | dataswim/messages.py | Message.msg_ | def msg_(self, label, *msg):
"""
Returns a message with a label
"""
txt = self._unpack_msg(*msg)
return "[" + label + "] " + txt | python | def msg_(self, label, *msg):
"""
Returns a message with a label
"""
txt = self._unpack_msg(*msg)
return "[" + label + "] " + txt | [
"def",
"msg_",
"(",
"self",
",",
"label",
",",
"*",
"msg",
")",
":",
"txt",
"=",
"self",
".",
"_unpack_msg",
"(",
"*",
"msg",
")",
"return",
"\"[\"",
"+",
"label",
"+",
"\"] \"",
"+",
"txt"
] | Returns a message with a label | [
"Returns",
"a",
"message",
"with",
"a",
"label"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/messages.py#L89-L94 |
53,738 | synw/dataswim | dataswim/messages.py | Message._msg | def _msg(self, label, *msg):
"""
Prints a message with a label
"""
if self.quiet is False:
txt = self._unpack_msg(*msg)
print("[" + label + "] " + txt) | python | def _msg(self, label, *msg):
"""
Prints a message with a label
"""
if self.quiet is False:
txt = self._unpack_msg(*msg)
print("[" + label + "] " + txt) | [
"def",
"_msg",
"(",
"self",
",",
"label",
",",
"*",
"msg",
")",
":",
"if",
"self",
".",
"quiet",
"is",
"False",
":",
"txt",
"=",
"self",
".",
"_unpack_msg",
"(",
"*",
"msg",
")",
"print",
"(",
"\"[\"",
"+",
"label",
"+",
"\"] \"",
"+",
"txt",
"... | Prints a message with a label | [
"Prints",
"a",
"message",
"with",
"a",
"label"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/messages.py#L96-L102 |
53,739 | synw/dataswim | dataswim/messages.py | Message._unpack_msg | def _unpack_msg(self, *msg):
"""
Convert all message elements to string
"""
l = []
for m in msg:
l.append(str(m))
return " ".join(l) | python | def _unpack_msg(self, *msg):
"""
Convert all message elements to string
"""
l = []
for m in msg:
l.append(str(m))
return " ".join(l) | [
"def",
"_unpack_msg",
"(",
"self",
",",
"*",
"msg",
")",
":",
"l",
"=",
"[",
"]",
"for",
"m",
"in",
"msg",
":",
"l",
".",
"append",
"(",
"str",
"(",
"m",
")",
")",
"return",
"\" \"",
".",
"join",
"(",
"l",
")"
] | Convert all message elements to string | [
"Convert",
"all",
"message",
"elements",
"to",
"string"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/messages.py#L104-L111 |
53,740 | synw/dataswim | dataswim/messages.py | Message._endmsg | def _endmsg(self, rd):
"""
Returns an end message with elapsed time
"""
msg = ""
s = ""
if rd.hours > 0:
if rd.hours > 1:
s = "s"
msg += colors.bold(str(rd.hours)) + " hour" + s + " "
s = ""
if rd.minutes > 0:
... | python | def _endmsg(self, rd):
"""
Returns an end message with elapsed time
"""
msg = ""
s = ""
if rd.hours > 0:
if rd.hours > 1:
s = "s"
msg += colors.bold(str(rd.hours)) + " hour" + s + " "
s = ""
if rd.minutes > 0:
... | [
"def",
"_endmsg",
"(",
"self",
",",
"rd",
")",
":",
"msg",
"=",
"\"\"",
"s",
"=",
"\"\"",
"if",
"rd",
".",
"hours",
">",
"0",
":",
"if",
"rd",
".",
"hours",
">",
"1",
":",
"s",
"=",
"\"s\"",
"msg",
"+=",
"colors",
".",
"bold",
"(",
"str",
"... | Returns an end message with elapsed time | [
"Returns",
"an",
"end",
"message",
"with",
"elapsed",
"time"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/messages.py#L113-L136 |
53,741 | cslarsen/crianza | crianza/optimizer.py | optimized | def optimized(code, silent=True, ignore_errors=True):
"""Performs optimizations on already parsed code."""
return constant_fold(code, silent=silent, ignore_errors=ignore_errors) | python | def optimized(code, silent=True, ignore_errors=True):
"""Performs optimizations on already parsed code."""
return constant_fold(code, silent=silent, ignore_errors=ignore_errors) | [
"def",
"optimized",
"(",
"code",
",",
"silent",
"=",
"True",
",",
"ignore_errors",
"=",
"True",
")",
":",
"return",
"constant_fold",
"(",
"code",
",",
"silent",
"=",
"silent",
",",
"ignore_errors",
"=",
"ignore_errors",
")"
] | Performs optimizations on already parsed code. | [
"Performs",
"optimizations",
"on",
"already",
"parsed",
"code",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/optimizer.py#L6-L8 |
53,742 | ojii/django-multilingual-ng | multilingual/compiler.py | MultilingualSQLCompiler.pre_sql_setup | def pre_sql_setup(self):
"""
Adds the JOINS and SELECTS for fetching multilingual data.
"""
super(MultilingualSQLCompiler, self).pre_sql_setup()
if not self.query.include_translation_data:
return
opts = self.query.model._meta
qn = self.quote_name_unl... | python | def pre_sql_setup(self):
"""
Adds the JOINS and SELECTS for fetching multilingual data.
"""
super(MultilingualSQLCompiler, self).pre_sql_setup()
if not self.query.include_translation_data:
return
opts = self.query.model._meta
qn = self.quote_name_unl... | [
"def",
"pre_sql_setup",
"(",
"self",
")",
":",
"super",
"(",
"MultilingualSQLCompiler",
",",
"self",
")",
".",
"pre_sql_setup",
"(",
")",
"if",
"not",
"self",
".",
"query",
".",
"include_translation_data",
":",
"return",
"opts",
"=",
"self",
".",
"query",
... | Adds the JOINS and SELECTS for fetching multilingual data. | [
"Adds",
"the",
"JOINS",
"and",
"SELECTS",
"for",
"fetching",
"multilingual",
"data",
"."
] | 0d320a0732ec59949380d4b5f21e153174d3ecf7 | https://github.com/ojii/django-multilingual-ng/blob/0d320a0732ec59949380d4b5f21e153174d3ecf7/multilingual/compiler.py#L21-L49 |
53,743 | ojii/django-multilingual-ng | multilingual/compiler.py | MultilingualSQLCompiler.get_from_clause | def get_from_clause(self):
"""
Add the JOINS for related multilingual fields filtering.
"""
result = super(MultilingualSQLCompiler, self).get_from_clause()
if not self.query.include_translation_data:
return result
from_ = result[0]
for join in self.q... | python | def get_from_clause(self):
"""
Add the JOINS for related multilingual fields filtering.
"""
result = super(MultilingualSQLCompiler, self).get_from_clause()
if not self.query.include_translation_data:
return result
from_ = result[0]
for join in self.q... | [
"def",
"get_from_clause",
"(",
"self",
")",
":",
"result",
"=",
"super",
"(",
"MultilingualSQLCompiler",
",",
"self",
")",
".",
"get_from_clause",
"(",
")",
"if",
"not",
"self",
".",
"query",
".",
"include_translation_data",
":",
"return",
"result",
"from_",
... | Add the JOINS for related multilingual fields filtering. | [
"Add",
"the",
"JOINS",
"for",
"related",
"multilingual",
"fields",
"filtering",
"."
] | 0d320a0732ec59949380d4b5f21e153174d3ecf7 | https://github.com/ojii/django-multilingual-ng/blob/0d320a0732ec59949380d4b5f21e153174d3ecf7/multilingual/compiler.py#L52-L64 |
53,744 | ojii/django-multilingual-ng | multilingual/admin.py | MultilingualInlineAdmin.queryset | def queryset(self, request):
"""
Filter objects which don't have a value in this language
"""
qs = super(MultilingualInlineAdmin, self).queryset(request)
# Don't now what the hell I was thinking here, but this code breaks stuff:
#
# checkfield = self.get_fill_chec... | python | def queryset(self, request):
"""
Filter objects which don't have a value in this language
"""
qs = super(MultilingualInlineAdmin, self).queryset(request)
# Don't now what the hell I was thinking here, but this code breaks stuff:
#
# checkfield = self.get_fill_chec... | [
"def",
"queryset",
"(",
"self",
",",
"request",
")",
":",
"qs",
"=",
"super",
"(",
"MultilingualInlineAdmin",
",",
"self",
")",
".",
"queryset",
"(",
"request",
")",
"# Don't now what the hell I was thinking here, but this code breaks stuff:",
"#",
"# checkfield = self.... | Filter objects which don't have a value in this language | [
"Filter",
"objects",
"which",
"don",
"t",
"have",
"a",
"value",
"in",
"this",
"language"
] | 0d320a0732ec59949380d4b5f21e153174d3ecf7 | https://github.com/ojii/django-multilingual-ng/blob/0d320a0732ec59949380d4b5f21e153174d3ecf7/multilingual/admin.py#L163-L177 |
53,745 | ojii/django-multilingual-ng | multilingual/admin.py | MultilingualModelAdmin.placeholder_plugin_filter | def placeholder_plugin_filter(self, request, queryset):
"""
This is only used on models which use placeholders from the django-cms
"""
if not request:
return queryset
if GLL.is_active:
return queryset.filter(language=GLL.language_code)
return query... | python | def placeholder_plugin_filter(self, request, queryset):
"""
This is only used on models which use placeholders from the django-cms
"""
if not request:
return queryset
if GLL.is_active:
return queryset.filter(language=GLL.language_code)
return query... | [
"def",
"placeholder_plugin_filter",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"if",
"not",
"request",
":",
"return",
"queryset",
"if",
"GLL",
".",
"is_active",
":",
"return",
"queryset",
".",
"filter",
"(",
"language",
"=",
"GLL",
".",
"langu... | This is only used on models which use placeholders from the django-cms | [
"This",
"is",
"only",
"used",
"on",
"models",
"which",
"use",
"placeholders",
"from",
"the",
"django",
"-",
"cms"
] | 0d320a0732ec59949380d4b5f21e153174d3ecf7 | https://github.com/ojii/django-multilingual-ng/blob/0d320a0732ec59949380d4b5f21e153174d3ecf7/multilingual/admin.py#L314-L322 |
53,746 | synw/dataswim | dataswim/data/transform/dataframe.py | Dataframe.concat | def concat(self, *dss, **kwargs):
"""
Concatenate dataswim instances from and
set it to the main dataframe
:param dss: dataswim instances to concatenate
:type dss: Ds
:param kwargs: keyword arguments for ``pd.concat``
"""
try:
df = p... | python | def concat(self, *dss, **kwargs):
"""
Concatenate dataswim instances from and
set it to the main dataframe
:param dss: dataswim instances to concatenate
:type dss: Ds
:param kwargs: keyword arguments for ``pd.concat``
"""
try:
df = p... | [
"def",
"concat",
"(",
"self",
",",
"*",
"dss",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
")",
"for",
"dsx",
"in",
"dss",
":",
"df",
"=",
"pd",
".",
"concat",
"(",
"[",
"df",
",",
"dsx",
".",
"df"... | Concatenate dataswim instances from and
set it to the main dataframe
:param dss: dataswim instances to concatenate
:type dss: Ds
:param kwargs: keyword arguments for ``pd.concat`` | [
"Concatenate",
"dataswim",
"instances",
"from",
"and",
"set",
"it",
"to",
"the",
"main",
"dataframe"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/dataframe.py#L10-L27 |
53,747 | synw/dataswim | dataswim/data/transform/dataframe.py | Dataframe.split_ | def split_(self, col: str) -> "list(Ds)":
"""
Split the main dataframe according to a column's unique values and
return a dict of dataswim instances
:return: list of dataswim instances
:rtype: list(Ds)
:example: ``dss = ds.slit_("Col 1")``
"""
try:
... | python | def split_(self, col: str) -> "list(Ds)":
"""
Split the main dataframe according to a column's unique values and
return a dict of dataswim instances
:return: list of dataswim instances
:rtype: list(Ds)
:example: ``dss = ds.slit_("Col 1")``
"""
try:
... | [
"def",
"split_",
"(",
"self",
",",
"col",
":",
"str",
")",
"->",
"\"list(Ds)\"",
":",
"try",
":",
"dss",
"=",
"{",
"}",
"unique",
"=",
"self",
".",
"df",
"[",
"col",
"]",
".",
"unique",
"(",
")",
"for",
"key",
"in",
"unique",
":",
"df2",
"=",
... | Split the main dataframe according to a column's unique values and
return a dict of dataswim instances
:return: list of dataswim instances
:rtype: list(Ds)
:example: ``dss = ds.slit_("Col 1")`` | [
"Split",
"the",
"main",
"dataframe",
"according",
"to",
"a",
"column",
"s",
"unique",
"values",
"and",
"return",
"a",
"dict",
"of",
"dataswim",
"instances"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/dataframe.py#L29-L48 |
53,748 | synw/dataswim | dataswim/data/transform/dataframe.py | Dataframe.merge | def merge(self, df: pd.DataFrame, on: str, how: str="outer", **kwargs):
"""
Set the main dataframe from the current dataframe and the passed
dataframe
:param df: the pandas dataframe to merge
:type df: pd.DataFrame
:param on: param for ``pd.merge``
:type on: str
... | python | def merge(self, df: pd.DataFrame, on: str, how: str="outer", **kwargs):
"""
Set the main dataframe from the current dataframe and the passed
dataframe
:param df: the pandas dataframe to merge
:type df: pd.DataFrame
:param on: param for ``pd.merge``
:type on: str
... | [
"def",
"merge",
"(",
"self",
",",
"df",
":",
"pd",
".",
"DataFrame",
",",
"on",
":",
"str",
",",
"how",
":",
"str",
"=",
"\"outer\"",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"df",
"=",
"pd",
".",
"merge",
"(",
"self",
".",
"df",
",",
... | Set the main dataframe from the current dataframe and the passed
dataframe
:param df: the pandas dataframe to merge
:type df: pd.DataFrame
:param on: param for ``pd.merge``
:type on: str
:param how: param for ``pd.merge``, defaults to "outer"
:type how: str, opti... | [
"Set",
"the",
"main",
"dataframe",
"from",
"the",
"current",
"dataframe",
"and",
"the",
"passed",
"dataframe"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/dataframe.py#L50-L67 |
53,749 | iron-io/iron_cache_python | iron_cache.py | IronCache.caches | def caches(self, options={}):
"""Query the server for a list of caches, parse the JSON response, and
return the result.
Keyword arguments:
options -- a dict of arguments to send with the request. See
http://dev.iron.io/cache/reference/api/#list_caches for more
... | python | def caches(self, options={}):
"""Query the server for a list of caches, parse the JSON response, and
return the result.
Keyword arguments:
options -- a dict of arguments to send with the request. See
http://dev.iron.io/cache/reference/api/#list_caches for more
... | [
"def",
"caches",
"(",
"self",
",",
"options",
"=",
"{",
"}",
")",
":",
"query",
"=",
"urllib",
".",
"urlencode",
"(",
"options",
")",
"url",
"=",
"\"caches\"",
"if",
"query",
"!=",
"\"\"",
":",
"url",
"=",
"\"%s?%s\"",
"%",
"(",
"url",
",",
"query"... | Query the server for a list of caches, parse the JSON response, and
return the result.
Keyword arguments:
options -- a dict of arguments to send with the request. See
http://dev.iron.io/cache/reference/api/#list_caches for more
information on defaults and p... | [
"Query",
"the",
"server",
"for",
"a",
"list",
"of",
"caches",
"parse",
"the",
"JSON",
"response",
"and",
"return",
"the",
"result",
"."
] | f68f5a5e216e3189397ffd7d243de0d53bf7c764 | https://github.com/iron-io/iron_cache_python/blob/f68f5a5e216e3189397ffd7d243de0d53bf7c764/iron_cache.py#L72-L86 |
53,750 | iron-io/iron_cache_python | iron_cache.py | IronCache.get | def get(self, key, cache=None):
"""Query the server for an item, parse the JSON, and return the result.
Keyword arguments:
key -- the key of the item that you'd like to retrieve. Required.
cache -- the name of the cache that the item resides in. Defaults to
None, which ... | python | def get(self, key, cache=None):
"""Query the server for an item, parse the JSON, and return the result.
Keyword arguments:
key -- the key of the item that you'd like to retrieve. Required.
cache -- the name of the cache that the item resides in. Defaults to
None, which ... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"cache",
"=",
"None",
")",
":",
"if",
"cache",
"is",
"None",
":",
"cache",
"=",
"self",
".",
"name",
"if",
"cache",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Cache name must be set\"",
")",
"cache",
... | Query the server for an item, parse the JSON, and return the result.
Keyword arguments:
key -- the key of the item that you'd like to retrieve. Required.
cache -- the name of the cache that the item resides in. Defaults to
None, which uses self.name. If no name is set, raises a... | [
"Query",
"the",
"server",
"for",
"an",
"item",
"parse",
"the",
"JSON",
"and",
"return",
"the",
"result",
"."
] | f68f5a5e216e3189397ffd7d243de0d53bf7c764 | https://github.com/iron-io/iron_cache_python/blob/f68f5a5e216e3189397ffd7d243de0d53bf7c764/iron_cache.py#L88-L105 |
53,751 | iron-io/iron_cache_python | iron_cache.py | IronCache.put | def put(self, key, value, cache=None, options={}):
"""Query the server to set the key specified to the value specified in
the specified cache.
Keyword arguments:
key -- the name of the key to be set. Required.
value -- the value to set key to. Must be a string or JSON
... | python | def put(self, key, value, cache=None, options={}):
"""Query the server to set the key specified to the value specified in
the specified cache.
Keyword arguments:
key -- the name of the key to be set. Required.
value -- the value to set key to. Must be a string or JSON
... | [
"def",
"put",
"(",
"self",
",",
"key",
",",
"value",
",",
"cache",
"=",
"None",
",",
"options",
"=",
"{",
"}",
")",
":",
"if",
"cache",
"is",
"None",
":",
"cache",
"=",
"self",
".",
"name",
"if",
"cache",
"is",
"None",
":",
"raise",
"ValueError",... | Query the server to set the key specified to the value specified in
the specified cache.
Keyword arguments:
key -- the name of the key to be set. Required.
value -- the value to set key to. Must be a string or JSON
serialisable. Required.
cache -- the cache to s... | [
"Query",
"the",
"server",
"to",
"set",
"the",
"key",
"specified",
"to",
"the",
"value",
"specified",
"in",
"the",
"specified",
"cache",
"."
] | f68f5a5e216e3189397ffd7d243de0d53bf7c764 | https://github.com/iron-io/iron_cache_python/blob/f68f5a5e216e3189397ffd7d243de0d53bf7c764/iron_cache.py#L107-L138 |
53,752 | iron-io/iron_cache_python | iron_cache.py | IronCache.delete | def delete(self, key, cache=None):
"""Query the server to delete the key specified from the cache
specified.
Keyword arguments:
key -- the key the item is stored under. Required.
cache -- the cache to delete the item from. Defaults to None, which
uses self.name.... | python | def delete(self, key, cache=None):
"""Query the server to delete the key specified from the cache
specified.
Keyword arguments:
key -- the key the item is stored under. Required.
cache -- the cache to delete the item from. Defaults to None, which
uses self.name.... | [
"def",
"delete",
"(",
"self",
",",
"key",
",",
"cache",
"=",
"None",
")",
":",
"if",
"cache",
"is",
"None",
":",
"cache",
"=",
"self",
".",
"name",
"if",
"cache",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Cache name must be set\"",
")",
"cache"... | Query the server to delete the key specified from the cache
specified.
Keyword arguments:
key -- the key the item is stored under. Required.
cache -- the cache to delete the item from. Defaults to None, which
uses self.name. If no name is set, raises a ValueError. | [
"Query",
"the",
"server",
"to",
"delete",
"the",
"key",
"specified",
"from",
"the",
"cache",
"specified",
"."
] | f68f5a5e216e3189397ffd7d243de0d53bf7c764 | https://github.com/iron-io/iron_cache_python/blob/f68f5a5e216e3189397ffd7d243de0d53bf7c764/iron_cache.py#L140-L158 |
53,753 | iron-io/iron_cache_python | iron_cache.py | IronCache.increment | def increment(self, key, cache=None, amount=1):
"""Query the server to increment the value of the key by the specified
amount. Negative amounts can be used to decrement.
Keyword arguments:
key -- the key the item is stored under. Required.
cache -- the cache the item belongs to.... | python | def increment(self, key, cache=None, amount=1):
"""Query the server to increment the value of the key by the specified
amount. Negative amounts can be used to decrement.
Keyword arguments:
key -- the key the item is stored under. Required.
cache -- the cache the item belongs to.... | [
"def",
"increment",
"(",
"self",
",",
"key",
",",
"cache",
"=",
"None",
",",
"amount",
"=",
"1",
")",
":",
"if",
"cache",
"is",
"None",
":",
"cache",
"=",
"self",
".",
"name",
"if",
"cache",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Cache n... | Query the server to increment the value of the key by the specified
amount. Negative amounts can be used to decrement.
Keyword arguments:
key -- the key the item is stored under. Required.
cache -- the cache the item belongs to. Defaults to None, which uses
self.name. I... | [
"Query",
"the",
"server",
"to",
"increment",
"the",
"value",
"of",
"the",
"key",
"by",
"the",
"specified",
"amount",
".",
"Negative",
"amounts",
"can",
"be",
"used",
"to",
"decrement",
"."
] | f68f5a5e216e3189397ffd7d243de0d53bf7c764 | https://github.com/iron-io/iron_cache_python/blob/f68f5a5e216e3189397ffd7d243de0d53bf7c764/iron_cache.py#L160-L183 |
53,754 | iron-io/iron_cache_python | iron_cache.py | IronCache.decrement | def decrement(self, key, cache=None, amount=1):
"""A convenience function for passing negative values to increment.
Keyword arguments:
key -- the key the item is stored under. Required.
cache -- the cache the item belongs to. Defaults to None, which uses
self.name. If n... | python | def decrement(self, key, cache=None, amount=1):
"""A convenience function for passing negative values to increment.
Keyword arguments:
key -- the key the item is stored under. Required.
cache -- the cache the item belongs to. Defaults to None, which uses
self.name. If n... | [
"def",
"decrement",
"(",
"self",
",",
"key",
",",
"cache",
"=",
"None",
",",
"amount",
"=",
"1",
")",
":",
"amount",
"=",
"amount",
"*",
"-",
"1",
"return",
"self",
".",
"increment",
"(",
"key",
"=",
"key",
",",
"cache",
"=",
"cache",
",",
"amoun... | A convenience function for passing negative values to increment.
Keyword arguments:
key -- the key the item is stored under. Required.
cache -- the cache the item belongs to. Defaults to None, which uses
self.name. If no name is set, raises a ValueError.
amount -- the a... | [
"A",
"convenience",
"function",
"for",
"passing",
"negative",
"values",
"to",
"increment",
"."
] | f68f5a5e216e3189397ffd7d243de0d53bf7c764 | https://github.com/iron-io/iron_cache_python/blob/f68f5a5e216e3189397ffd7d243de0d53bf7c764/iron_cache.py#L185-L197 |
53,755 | AntagonistHQ/openprovider.py | openprovider/models.py | Model.dump | def dump(self, *args, **kwargs):
"""Dumps a representation of the Model on standard output."""
lxml.etree.dump(self._obj, *args, **kwargs) | python | def dump(self, *args, **kwargs):
"""Dumps a representation of the Model on standard output."""
lxml.etree.dump(self._obj, *args, **kwargs) | [
"def",
"dump",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"lxml",
".",
"etree",
".",
"dump",
"(",
"self",
".",
"_obj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Dumps a representation of the Model on standard output. | [
"Dumps",
"a",
"representation",
"of",
"the",
"Model",
"on",
"standard",
"output",
"."
] | 5871c3d5b3661e23667f147f49f20389c817a0a4 | https://github.com/AntagonistHQ/openprovider.py/blob/5871c3d5b3661e23667f147f49f20389c817a0a4/openprovider/models.py#L62-L64 |
53,756 | wummel/dosage | dosagelib/helpers.py | queryNamer | def queryNamer(paramName, usePageUrl=False):
"""Get name from URL query part."""
@classmethod
def _namer(cls, imageUrl, pageUrl):
"""Get URL query part."""
url = pageUrl if usePageUrl else imageUrl
return getQueryParams(url)[paramName][0]
return _namer | python | def queryNamer(paramName, usePageUrl=False):
"""Get name from URL query part."""
@classmethod
def _namer(cls, imageUrl, pageUrl):
"""Get URL query part."""
url = pageUrl if usePageUrl else imageUrl
return getQueryParams(url)[paramName][0]
return _namer | [
"def",
"queryNamer",
"(",
"paramName",
",",
"usePageUrl",
"=",
"False",
")",
":",
"@",
"classmethod",
"def",
"_namer",
"(",
"cls",
",",
"imageUrl",
",",
"pageUrl",
")",
":",
"\"\"\"Get URL query part.\"\"\"",
"url",
"=",
"pageUrl",
"if",
"usePageUrl",
"else",
... | Get name from URL query part. | [
"Get",
"name",
"from",
"URL",
"query",
"part",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/helpers.py#L6-L13 |
53,757 | wummel/dosage | dosagelib/helpers.py | regexNamer | def regexNamer(regex, usePageUrl=False):
"""Get name from regular expression."""
@classmethod
def _namer(cls, imageUrl, pageUrl):
"""Get first regular expression group."""
url = pageUrl if usePageUrl else imageUrl
mo = regex.search(url)
if mo:
return mo.group(1)
... | python | def regexNamer(regex, usePageUrl=False):
"""Get name from regular expression."""
@classmethod
def _namer(cls, imageUrl, pageUrl):
"""Get first regular expression group."""
url = pageUrl if usePageUrl else imageUrl
mo = regex.search(url)
if mo:
return mo.group(1)
... | [
"def",
"regexNamer",
"(",
"regex",
",",
"usePageUrl",
"=",
"False",
")",
":",
"@",
"classmethod",
"def",
"_namer",
"(",
"cls",
",",
"imageUrl",
",",
"pageUrl",
")",
":",
"\"\"\"Get first regular expression group.\"\"\"",
"url",
"=",
"pageUrl",
"if",
"usePageUrl"... | Get name from regular expression. | [
"Get",
"name",
"from",
"regular",
"expression",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/helpers.py#L16-L25 |
53,758 | wummel/dosage | dosagelib/helpers.py | bounceStarter | def bounceStarter(url, nextSearch):
"""Get start URL by "bouncing" back and forth one time."""
@classmethod
def _starter(cls):
"""Get bounced start URL."""
data = cls.getPage(url)
url1 = cls.fetchUrl(url, data, cls.prevSearch)
data = cls.getPage(url1)
return cls.fetch... | python | def bounceStarter(url, nextSearch):
"""Get start URL by "bouncing" back and forth one time."""
@classmethod
def _starter(cls):
"""Get bounced start URL."""
data = cls.getPage(url)
url1 = cls.fetchUrl(url, data, cls.prevSearch)
data = cls.getPage(url1)
return cls.fetch... | [
"def",
"bounceStarter",
"(",
"url",
",",
"nextSearch",
")",
":",
"@",
"classmethod",
"def",
"_starter",
"(",
"cls",
")",
":",
"\"\"\"Get bounced start URL.\"\"\"",
"data",
"=",
"cls",
".",
"getPage",
"(",
"url",
")",
"url1",
"=",
"cls",
".",
"fetchUrl",
"(... | Get start URL by "bouncing" back and forth one time. | [
"Get",
"start",
"URL",
"by",
"bouncing",
"back",
"and",
"forth",
"one",
"time",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/helpers.py#L28-L37 |
53,759 | wummel/dosage | dosagelib/helpers.py | indirectStarter | def indirectStarter(url, latestSearch):
"""Get start URL by indirection."""
@classmethod
def _starter(cls):
"""Get indirect start URL."""
data = cls.getPage(url)
return cls.fetchUrl(url, data, latestSearch)
return _starter | python | def indirectStarter(url, latestSearch):
"""Get start URL by indirection."""
@classmethod
def _starter(cls):
"""Get indirect start URL."""
data = cls.getPage(url)
return cls.fetchUrl(url, data, latestSearch)
return _starter | [
"def",
"indirectStarter",
"(",
"url",
",",
"latestSearch",
")",
":",
"@",
"classmethod",
"def",
"_starter",
"(",
"cls",
")",
":",
"\"\"\"Get indirect start URL.\"\"\"",
"data",
"=",
"cls",
".",
"getPage",
"(",
"url",
")",
"return",
"cls",
".",
"fetchUrl",
"(... | Get start URL by indirection. | [
"Get",
"start",
"URL",
"by",
"indirection",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/helpers.py#L40-L47 |
53,760 | AntagonistHQ/openprovider.py | openprovider/modules/domain.py | DomainModule.check_domain_request | def check_domain_request(self, domains):
"""
Return the availability of one or more domain names.
The availability is a model containing a domain and a status. It can also have a premium
attribute in case the domain has non-default costs.
"""
request = E.checkDomainReque... | python | def check_domain_request(self, domains):
"""
Return the availability of one or more domain names.
The availability is a model containing a domain and a status. It can also have a premium
attribute in case the domain has non-default costs.
"""
request = E.checkDomainReque... | [
"def",
"check_domain_request",
"(",
"self",
",",
"domains",
")",
":",
"request",
"=",
"E",
".",
"checkDomainRequest",
"(",
"E",
".",
"domains",
"(",
"E",
".",
"array",
"(",
"*",
"[",
"E",
".",
"item",
"(",
"E",
".",
"name",
"(",
"domain",
".",
"spl... | Return the availability of one or more domain names.
The availability is a model containing a domain and a status. It can also have a premium
attribute in case the domain has non-default costs. | [
"Return",
"the",
"availability",
"of",
"one",
"or",
"more",
"domain",
"names",
"."
] | 5871c3d5b3661e23667f147f49f20389c817a0a4 | https://github.com/AntagonistHQ/openprovider.py/blob/5871c3d5b3661e23667f147f49f20389c817a0a4/openprovider/modules/domain.py#L52-L71 |
53,761 | synw/dataswim | dataswim/db/relations.py | Relation.relation_ | def relation_(self, table, origin_field, search_field, destination_field=None,
id_field="id"):
"""
Returns a DataSwim instance with a column filled from a relation foreign key
"""
df = self._relation(table, origin_field,
search_field, destin... | python | def relation_(self, table, origin_field, search_field, destination_field=None,
id_field="id"):
"""
Returns a DataSwim instance with a column filled from a relation foreign key
"""
df = self._relation(table, origin_field,
search_field, destin... | [
"def",
"relation_",
"(",
"self",
",",
"table",
",",
"origin_field",
",",
"search_field",
",",
"destination_field",
"=",
"None",
",",
"id_field",
"=",
"\"id\"",
")",
":",
"df",
"=",
"self",
".",
"_relation",
"(",
"table",
",",
"origin_field",
",",
"search_f... | Returns a DataSwim instance with a column filled from a relation foreign key | [
"Returns",
"a",
"DataSwim",
"instance",
"with",
"a",
"column",
"filled",
"from",
"a",
"relation",
"foreign",
"key"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/db/relations.py#L19-L26 |
53,762 | wummel/dosage | scripts/order-symlinks.py | loadJson | def loadJson(d):
"""Return JSON data."""
with codecs.open(jsonFn(d), 'r', 'utf-8') as f:
return json.load(f) | python | def loadJson(d):
"""Return JSON data."""
with codecs.open(jsonFn(d), 'r', 'utf-8') as f:
return json.load(f) | [
"def",
"loadJson",
"(",
"d",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"jsonFn",
"(",
"d",
")",
",",
"'r'",
",",
"'utf-8'",
")",
"as",
"f",
":",
"return",
"json",
".",
"load",
"(",
"f",
")"
] | Return JSON data. | [
"Return",
"JSON",
"data",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/scripts/order-symlinks.py#L18-L21 |
53,763 | wummel/dosage | scripts/order-symlinks.py | prepare_output | def prepare_output(d):
"""Clean pre-existing links in output directory."""
outDir = os.path.join(d, 'inorder')
if not os.path.exists(outDir):
os.mkdir(outDir)
for f in os.listdir(outDir):
f = os.path.join(outDir, f)
if os.path.islink(f):
os.remove(f)
return outDir | python | def prepare_output(d):
"""Clean pre-existing links in output directory."""
outDir = os.path.join(d, 'inorder')
if not os.path.exists(outDir):
os.mkdir(outDir)
for f in os.listdir(outDir):
f = os.path.join(outDir, f)
if os.path.islink(f):
os.remove(f)
return outDir | [
"def",
"prepare_output",
"(",
"d",
")",
":",
"outDir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"d",
",",
"'inorder'",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"outDir",
")",
":",
"os",
".",
"mkdir",
"(",
"outDir",
")",
"for",
... | Clean pre-existing links in output directory. | [
"Clean",
"pre",
"-",
"existing",
"links",
"in",
"output",
"directory",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/scripts/order-symlinks.py#L23-L32 |
53,764 | wummel/dosage | scripts/order-symlinks.py | create_symlinks | def create_symlinks(d):
"""Create new symbolic links in output directory."""
data = loadJson(d)
outDir = prepare_output(d)
unseen = data["pages"].keys()
while len(unseen) > 0:
latest = work = unseen[0]
while work in unseen:
unseen.remove(work)
if "prev" in da... | python | def create_symlinks(d):
"""Create new symbolic links in output directory."""
data = loadJson(d)
outDir = prepare_output(d)
unseen = data["pages"].keys()
while len(unseen) > 0:
latest = work = unseen[0]
while work in unseen:
unseen.remove(work)
if "prev" in da... | [
"def",
"create_symlinks",
"(",
"d",
")",
":",
"data",
"=",
"loadJson",
"(",
"d",
")",
"outDir",
"=",
"prepare_output",
"(",
"d",
")",
"unseen",
"=",
"data",
"[",
"\"pages\"",
"]",
".",
"keys",
"(",
")",
"while",
"len",
"(",
"unseen",
")",
">",
"0",... | Create new symbolic links in output directory. | [
"Create",
"new",
"symbolic",
"links",
"in",
"output",
"directory",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/scripts/order-symlinks.py#L34-L59 |
53,765 | cslarsen/crianza | crianza/parser.py | parse | def parse(source):
"""Parses source code returns an array of instructions suitable for
optimization and execution by a Machine.
Args:
source: A string or stream containing source code.
"""
if isinstance(source, str):
return parse_stream(six.StringIO(source))
else:
return... | python | def parse(source):
"""Parses source code returns an array of instructions suitable for
optimization and execution by a Machine.
Args:
source: A string or stream containing source code.
"""
if isinstance(source, str):
return parse_stream(six.StringIO(source))
else:
return... | [
"def",
"parse",
"(",
"source",
")",
":",
"if",
"isinstance",
"(",
"source",
",",
"str",
")",
":",
"return",
"parse_stream",
"(",
"six",
".",
"StringIO",
"(",
"source",
")",
")",
"else",
":",
"return",
"parse_stream",
"(",
"source",
")"
] | Parses source code returns an array of instructions suitable for
optimization and execution by a Machine.
Args:
source: A string or stream containing source code. | [
"Parses",
"source",
"code",
"returns",
"an",
"array",
"of",
"instructions",
"suitable",
"for",
"optimization",
"and",
"execution",
"by",
"a",
"Machine",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/parser.py#L10-L20 |
53,766 | cslarsen/crianza | crianza/parser.py | parse_stream | def parse_stream(stream):
"""Parse a Forth-like language and return code."""
code = []
for (line, col, (token, value)) in Tokenizer(stream).tokenize():
if token == Tokenizer.STRING:
value = '"' + value + '"'
code.append(value)
return code | python | def parse_stream(stream):
"""Parse a Forth-like language and return code."""
code = []
for (line, col, (token, value)) in Tokenizer(stream).tokenize():
if token == Tokenizer.STRING:
value = '"' + value + '"'
code.append(value)
return code | [
"def",
"parse_stream",
"(",
"stream",
")",
":",
"code",
"=",
"[",
"]",
"for",
"(",
"line",
",",
"col",
",",
"(",
"token",
",",
"value",
")",
")",
"in",
"Tokenizer",
"(",
"stream",
")",
".",
"tokenize",
"(",
")",
":",
"if",
"token",
"==",
"Tokeniz... | Parse a Forth-like language and return code. | [
"Parse",
"a",
"Forth",
"-",
"like",
"language",
"and",
"return",
"code",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/parser.py#L22-L31 |
53,767 | ekiro/haps | haps/config.py | Configuration.resolver | def resolver(cls, var_name: str) -> FunctionType:
"""
Variable resolver decorator. Function or method decorated with it is
used to resolve the config variable.
.. note::
Variable is resolved only once.
Next gets are returned from the cache.
:param var_na... | python | def resolver(cls, var_name: str) -> FunctionType:
"""
Variable resolver decorator. Function or method decorated with it is
used to resolve the config variable.
.. note::
Variable is resolved only once.
Next gets are returned from the cache.
:param var_na... | [
"def",
"resolver",
"(",
"cls",
",",
"var_name",
":",
"str",
")",
"->",
"FunctionType",
":",
"def",
"dec",
"(",
"f",
")",
":",
"if",
"var_name",
"in",
"cls",
"(",
")",
".",
"resolvers",
":",
"raise",
"ConfigurationError",
"(",
"f'Resolver for {var_name} alr... | Variable resolver decorator. Function or method decorated with it is
used to resolve the config variable.
.. note::
Variable is resolved only once.
Next gets are returned from the cache.
:param var_name: Variable name
:return: Function decorator | [
"Variable",
"resolver",
"decorator",
".",
"Function",
"or",
"method",
"decorated",
"with",
"it",
"is",
"used",
"to",
"resolve",
"the",
"config",
"variable",
"."
] | 64b6746187e44dadb23b842607d294e03c30a0be | https://github.com/ekiro/haps/blob/64b6746187e44dadb23b842607d294e03c30a0be/haps/config.py#L81-L100 |
53,768 | ekiro/haps | haps/config.py | Configuration.env_resolver | def env_resolver(cls, var_name: str, env_name: str = None,
default: Any = _NONE) -> 'Configuration':
"""
Method for configuring environment resolver.
:param var_name: Variable name
:param env_name: An optional environment variable name. If not set\
haps ... | python | def env_resolver(cls, var_name: str, env_name: str = None,
default: Any = _NONE) -> 'Configuration':
"""
Method for configuring environment resolver.
:param var_name: Variable name
:param env_name: An optional environment variable name. If not set\
haps ... | [
"def",
"env_resolver",
"(",
"cls",
",",
"var_name",
":",
"str",
",",
"env_name",
":",
"str",
"=",
"None",
",",
"default",
":",
"Any",
"=",
"_NONE",
")",
"->",
"'Configuration'",
":",
"cls",
".",
"resolver",
"(",
"var_name",
")",
"(",
"partial",
"(",
... | Method for configuring environment resolver.
:param var_name: Variable name
:param env_name: An optional environment variable name. If not set\
haps looks for `HAPS_var_name`
:param default: Default value for variable. If it's a callable,\
is called before return. If not... | [
"Method",
"for",
"configuring",
"environment",
"resolver",
"."
] | 64b6746187e44dadb23b842607d294e03c30a0be | https://github.com/ekiro/haps/blob/64b6746187e44dadb23b842607d294e03c30a0be/haps/config.py#L103-L122 |
53,769 | ekiro/haps | haps/config.py | Configuration.set | def set(cls, var_name: str, value: Any) -> 'Configuration':
"""
Set the variable
:param var_name: Variable name
:param value: Value of variable
:return: :class:`~haps.config.Configuration` instance for easy\
chaining
"""
with cls._lock:
... | python | def set(cls, var_name: str, value: Any) -> 'Configuration':
"""
Set the variable
:param var_name: Variable name
:param value: Value of variable
:return: :class:`~haps.config.Configuration` instance for easy\
chaining
"""
with cls._lock:
... | [
"def",
"set",
"(",
"cls",
",",
"var_name",
":",
"str",
",",
"value",
":",
"Any",
")",
"->",
"'Configuration'",
":",
"with",
"cls",
".",
"_lock",
":",
"if",
"var_name",
"not",
"in",
"cls",
"(",
")",
".",
"cache",
":",
"cls",
"(",
")",
".",
"cache"... | Set the variable
:param var_name: Variable name
:param value: Value of variable
:return: :class:`~haps.config.Configuration` instance for easy\
chaining | [
"Set",
"the",
"variable"
] | 64b6746187e44dadb23b842607d294e03c30a0be | https://github.com/ekiro/haps/blob/64b6746187e44dadb23b842607d294e03c30a0be/haps/config.py#L125-L140 |
53,770 | danpoland/pyramid-restful-framework | pyramid_restful/mixins.py | CreateModelMixin.perform_create | def perform_create(self, data):
"""
Hook for controlling the creation of an model instance. Override this if you need to do more with your
data before saving your object than just mapping the deserialized data to a new instance of ``self.model``.
"""
instance = self.model(**data... | python | def perform_create(self, data):
"""
Hook for controlling the creation of an model instance. Override this if you need to do more with your
data before saving your object than just mapping the deserialized data to a new instance of ``self.model``.
"""
instance = self.model(**data... | [
"def",
"perform_create",
"(",
"self",
",",
"data",
")",
":",
"instance",
"=",
"self",
".",
"model",
"(",
"*",
"*",
"data",
")",
"self",
".",
"request",
".",
"dbsession",
".",
"add",
"(",
"instance",
")",
"self",
".",
"request",
".",
"dbsession",
".",... | Hook for controlling the creation of an model instance. Override this if you need to do more with your
data before saving your object than just mapping the deserialized data to a new instance of ``self.model``. | [
"Hook",
"for",
"controlling",
"the",
"creation",
"of",
"an",
"model",
"instance",
".",
"Override",
"this",
"if",
"you",
"need",
"to",
"do",
"more",
"with",
"your",
"data",
"before",
"saving",
"your",
"object",
"than",
"just",
"mapping",
"the",
"deserialized"... | 4d8c9db44b1869c3d1fdd59ca304c3166473fcbb | https://github.com/danpoland/pyramid-restful-framework/blob/4d8c9db44b1869c3d1fdd59ca304c3166473fcbb/pyramid_restful/mixins.py#L56-L65 |
53,771 | synw/dataswim | dataswim/charts/chartjs.py | Chartjs._get_chartjs_chart | def _get_chartjs_chart(self, xcol, ycol, chart_type, label=None, opts={},
style={}, options={}, **kwargs):
"""
Get Chartjs html
"""
try:
xdata = list(self.df[xcol])
except Exception as e:
self.err(e, self._get_chartjs_chart,
... | python | def _get_chartjs_chart(self, xcol, ycol, chart_type, label=None, opts={},
style={}, options={}, **kwargs):
"""
Get Chartjs html
"""
try:
xdata = list(self.df[xcol])
except Exception as e:
self.err(e, self._get_chartjs_chart,
... | [
"def",
"_get_chartjs_chart",
"(",
"self",
",",
"xcol",
",",
"ycol",
",",
"chart_type",
",",
"label",
"=",
"None",
",",
"opts",
"=",
"{",
"}",
",",
"style",
"=",
"{",
"}",
",",
"options",
"=",
"{",
"}",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
... | Get Chartjs html | [
"Get",
"Chartjs",
"html"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/chartjs.py#L19-L52 |
53,772 | Seeed-Studio/wio-cli | wio/commands/cmd_state.py | cli | def cli(wio):
'''
Login state.
\b
DOES:
Display login email, token, server url.
\b
USE:
wio state
'''
user_token = wio.config.get("token", None)
mserver_url = wio.config.get("mserver", None)
if not mserver_url or not user_token:
click.echo(click.style('>... | python | def cli(wio):
'''
Login state.
\b
DOES:
Display login email, token, server url.
\b
USE:
wio state
'''
user_token = wio.config.get("token", None)
mserver_url = wio.config.get("mserver", None)
if not mserver_url or not user_token:
click.echo(click.style('>... | [
"def",
"cli",
"(",
"wio",
")",
":",
"user_token",
"=",
"wio",
".",
"config",
".",
"get",
"(",
"\"token\"",
",",
"None",
")",
"mserver_url",
"=",
"wio",
".",
"config",
".",
"get",
"(",
"\"mserver\"",
",",
"None",
")",
"if",
"not",
"mserver_url",
"or",... | Login state.
\b
DOES:
Display login email, token, server url.
\b
USE:
wio state | [
"Login",
"state",
"."
] | ce83f4c2d30be7f72d1a128acd123dfc5effa563 | https://github.com/Seeed-Studio/wio-cli/blob/ce83f4c2d30be7f72d1a128acd123dfc5effa563/wio/commands/cmd_state.py#L6-L34 |
53,773 | haikuginger/beekeeper | beekeeper/exceptions.py | TraversalError.top_level | def top_level(self):
"""
Print just the top level of an object, being sure to show where
it goes deeper
"""
output = {}
if isinstance(self.obj, dict):
for name, item in self.obj.items():
if isinstance(item, dict):
if item:
... | python | def top_level(self):
"""
Print just the top level of an object, being sure to show where
it goes deeper
"""
output = {}
if isinstance(self.obj, dict):
for name, item in self.obj.items():
if isinstance(item, dict):
if item:
... | [
"def",
"top_level",
"(",
"self",
")",
":",
"output",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"self",
".",
"obj",
",",
"dict",
")",
":",
"for",
"name",
",",
"item",
"in",
"self",
".",
"obj",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
... | Print just the top level of an object, being sure to show where
it goes deeper | [
"Print",
"just",
"the",
"top",
"level",
"of",
"an",
"object",
"being",
"sure",
"to",
"show",
"where",
"it",
"goes",
"deeper"
] | b647d3add0b407ec5dc3a2a39c4f6dac31243b18 | https://github.com/haikuginger/beekeeper/blob/b647d3add0b407ec5dc3a2a39c4f6dac31243b18/beekeeper/exceptions.py#L71-L93 |
53,774 | cslarsen/crianza | crianza/compiler.py | make_embedded_push | def make_embedded_push(value):
"""Returns a closure that pushed the given value onto a Machine's stack.
We use this to embed stack pushes in the VM code, so that the interpreter
can assume that all instructions are callable Python functions. This makes
dispatching much faster than checking if an instru... | python | def make_embedded_push(value):
"""Returns a closure that pushed the given value onto a Machine's stack.
We use this to embed stack pushes in the VM code, so that the interpreter
can assume that all instructions are callable Python functions. This makes
dispatching much faster than checking if an instru... | [
"def",
"make_embedded_push",
"(",
"value",
")",
":",
"push",
"=",
"lambda",
"vm",
":",
"vm",
".",
"push",
"(",
"value",
")",
"push",
".",
"tag",
"=",
"EMBEDDED_PUSH_TAG",
"return",
"push"
] | Returns a closure that pushed the given value onto a Machine's stack.
We use this to embed stack pushes in the VM code, so that the interpreter
can assume that all instructions are callable Python functions. This makes
dispatching much faster than checking if an instruction is a constant
(number, strin... | [
"Returns",
"a",
"closure",
"that",
"pushed",
"the",
"given",
"value",
"onto",
"a",
"Machine",
"s",
"stack",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/compiler.py#L8-L18 |
53,775 | cslarsen/crianza | crianza/compiler.py | get_embedded_push_value | def get_embedded_push_value(obj):
"""Extracts the embedded push value."""
assert(is_embedded_push(obj))
assert(len(obj.__closure__) == 1)
return obj.__closure__[0].cell_contents | python | def get_embedded_push_value(obj):
"""Extracts the embedded push value."""
assert(is_embedded_push(obj))
assert(len(obj.__closure__) == 1)
return obj.__closure__[0].cell_contents | [
"def",
"get_embedded_push_value",
"(",
"obj",
")",
":",
"assert",
"(",
"is_embedded_push",
"(",
"obj",
")",
")",
"assert",
"(",
"len",
"(",
"obj",
".",
"__closure__",
")",
"==",
"1",
")",
"return",
"obj",
".",
"__closure__",
"[",
"0",
"]",
".",
"cell_c... | Extracts the embedded push value. | [
"Extracts",
"the",
"embedded",
"push",
"value",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/compiler.py#L24-L28 |
53,776 | cslarsen/crianza | crianza/compiler.py | check | def check(code):
"""Checks code for obvious errors."""
def safe_lookup(op):
try:
return instructions.lookup(op)
except Exception:
return op
for i, a in enumerate(code):
b = code[i+1] if i+1 < len(code) else None
# Does instruction exist?
if n... | python | def check(code):
"""Checks code for obvious errors."""
def safe_lookup(op):
try:
return instructions.lookup(op)
except Exception:
return op
for i, a in enumerate(code):
b = code[i+1] if i+1 < len(code) else None
# Does instruction exist?
if n... | [
"def",
"check",
"(",
"code",
")",
":",
"def",
"safe_lookup",
"(",
"op",
")",
":",
"try",
":",
"return",
"instructions",
".",
"lookup",
"(",
"op",
")",
"except",
"Exception",
":",
"return",
"op",
"for",
"i",
",",
"a",
"in",
"enumerate",
"(",
"code",
... | Checks code for obvious errors. | [
"Checks",
"code",
"for",
"obvious",
"errors",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/compiler.py#L30-L66 |
53,777 | cslarsen/crianza | crianza/compiler.py | compile | def compile(code, silent=True, ignore_errors=False, optimize=True):
"""Compiles subroutine-forms into a complete working code.
A program such as:
: sub1 <sub1 code ...> ;
: sub2 <sub2 code ...> ;
sub1 foo sub2 bar
is compiled into:
<sub1 address> call
foo
... | python | def compile(code, silent=True, ignore_errors=False, optimize=True):
"""Compiles subroutine-forms into a complete working code.
A program such as:
: sub1 <sub1 code ...> ;
: sub2 <sub2 code ...> ;
sub1 foo sub2 bar
is compiled into:
<sub1 address> call
foo
... | [
"def",
"compile",
"(",
"code",
",",
"silent",
"=",
"True",
",",
"ignore_errors",
"=",
"False",
",",
"optimize",
"=",
"True",
")",
":",
"assert",
"(",
"isinstance",
"(",
"code",
",",
"list",
")",
")",
"output",
"=",
"[",
"]",
"subroutine",
"=",
"{",
... | Compiles subroutine-forms into a complete working code.
A program such as:
: sub1 <sub1 code ...> ;
: sub2 <sub2 code ...> ;
sub1 foo sub2 bar
is compiled into:
<sub1 address> call
foo
<sub2 address> call
exit
<sub1 code ...> return
<su... | [
"Compiles",
"subroutine",
"-",
"forms",
"into",
"a",
"complete",
"working",
"code",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/compiler.py#L68-L186 |
53,778 | cslarsen/crianza | crianza/compiler.py | native_types | def native_types(code):
"""Convert code elements from strings to native Python types."""
out = []
for c in code:
if isconstant(c, quoted=True):
if isstring(c, quoted=True):
v = c[1:-1]
elif isbool(c):
v = to_bool(c)
elif isnumber(c)... | python | def native_types(code):
"""Convert code elements from strings to native Python types."""
out = []
for c in code:
if isconstant(c, quoted=True):
if isstring(c, quoted=True):
v = c[1:-1]
elif isbool(c):
v = to_bool(c)
elif isnumber(c)... | [
"def",
"native_types",
"(",
"code",
")",
":",
"out",
"=",
"[",
"]",
"for",
"c",
"in",
"code",
":",
"if",
"isconstant",
"(",
"c",
",",
"quoted",
"=",
"True",
")",
":",
"if",
"isstring",
"(",
"c",
",",
"quoted",
"=",
"True",
")",
":",
"v",
"=",
... | Convert code elements from strings to native Python types. | [
"Convert",
"code",
"elements",
"from",
"strings",
"to",
"native",
"Python",
"types",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/compiler.py#L198-L220 |
53,779 | ska-sa/hypercube | hypercube/dims.py | Dimension.update | def update(self, global_size=None, lower_extent=None, upper_extent=None,
description=None):
"""
Update the dimension properties
Parameters
----------
global_size : int
Global dimension size (Default value = None)
lower_extent : int
Lower d... | python | def update(self, global_size=None, lower_extent=None, upper_extent=None,
description=None):
"""
Update the dimension properties
Parameters
----------
global_size : int
Global dimension size (Default value = None)
lower_extent : int
Lower d... | [
"def",
"update",
"(",
"self",
",",
"global_size",
"=",
"None",
",",
"lower_extent",
"=",
"None",
",",
"upper_extent",
"=",
"None",
",",
"description",
"=",
"None",
")",
":",
"if",
"global_size",
"is",
"not",
"None",
":",
"self",
".",
"_global_size",
"=",... | Update the dimension properties
Parameters
----------
global_size : int
Global dimension size (Default value = None)
lower_extent : int
Lower dimension extent (Default value = None)
upper_extent : int
Upper dimension extent (Default value = No... | [
"Update",
"the",
"dimension",
"properties"
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/dims.py#L154-L177 |
53,780 | ska-sa/hypercube | hypercube/dims.py | Dimension.validate | def validate(self):
""" Validate the contents of a dimension data dictionary """
extents_valid = (0 <= self.lower_extent <= self.upper_extent
<= self.global_size)
if not extents_valid:
raise ValueError("Dimension '{d}' fails 0 <= {el} <= {eu} <= {gs}"
.f... | python | def validate(self):
""" Validate the contents of a dimension data dictionary """
extents_valid = (0 <= self.lower_extent <= self.upper_extent
<= self.global_size)
if not extents_valid:
raise ValueError("Dimension '{d}' fails 0 <= {el} <= {eu} <= {gs}"
.f... | [
"def",
"validate",
"(",
"self",
")",
":",
"extents_valid",
"=",
"(",
"0",
"<=",
"self",
".",
"lower_extent",
"<=",
"self",
".",
"upper_extent",
"<=",
"self",
".",
"global_size",
")",
"if",
"not",
"extents_valid",
":",
"raise",
"ValueError",
"(",
"\"Dimensi... | Validate the contents of a dimension data dictionary | [
"Validate",
"the",
"contents",
"of",
"a",
"dimension",
"data",
"dictionary"
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/dims.py#L179-L188 |
53,781 | synw/dataswim | dataswim/data/transform/values.py | Values.sum_ | def sum_(self, col: str) -> float:
"""
Returns the sum of all values in a column
:param col: column name
:type col: str
:return: sum of all the column values
:rtype: float
:example: ``sum = ds.sum_("Col 1")``
"""
try:
df = self.df[col... | python | def sum_(self, col: str) -> float:
"""
Returns the sum of all values in a column
:param col: column name
:type col: str
:return: sum of all the column values
:rtype: float
:example: ``sum = ds.sum_("Col 1")``
"""
try:
df = self.df[col... | [
"def",
"sum_",
"(",
"self",
",",
"col",
":",
"str",
")",
"->",
"float",
":",
"try",
":",
"df",
"=",
"self",
".",
"df",
"[",
"col",
"]",
"num",
"=",
"float",
"(",
"df",
".",
"sum",
"(",
")",
")",
"return",
"num",
"except",
"Exception",
"as",
"... | Returns the sum of all values in a column
:param col: column name
:type col: str
:return: sum of all the column values
:rtype: float
:example: ``sum = ds.sum_("Col 1")`` | [
"Returns",
"the",
"sum",
"of",
"all",
"values",
"in",
"a",
"column"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/values.py#L10-L26 |
53,782 | synw/dataswim | dataswim/data/transform/values.py | Values.dropr | def dropr(self, *rows):
"""
Drops some rows from the main dataframe
:param rows: rows names
:type rows: list of ints
:example: ``ds.drop_rows([0, 2])``
"""
try:
self.df = rows = list(rows)
self.df.drop(rows)
except Exception as e:... | python | def dropr(self, *rows):
"""
Drops some rows from the main dataframe
:param rows: rows names
:type rows: list of ints
:example: ``ds.drop_rows([0, 2])``
"""
try:
self.df = rows = list(rows)
self.df.drop(rows)
except Exception as e:... | [
"def",
"dropr",
"(",
"self",
",",
"*",
"rows",
")",
":",
"try",
":",
"self",
".",
"df",
"=",
"rows",
"=",
"list",
"(",
"rows",
")",
"self",
".",
"df",
".",
"drop",
"(",
"rows",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"err",
"... | Drops some rows from the main dataframe
:param rows: rows names
:type rows: list of ints
:example: ``ds.drop_rows([0, 2])`` | [
"Drops",
"some",
"rows",
"from",
"the",
"main",
"dataframe"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/values.py#L28-L41 |
53,783 | synw/dataswim | dataswim/data/transform/values.py | Values.append | def append(self, vals: list, index=None):
"""
Append a row to the main dataframe
:param vals: list of the row values to add
:type vals: list
:param index: index key, defaults to None
:param index: any, optional
:example: ``ds.append([0, 2, 2, 3, 4])``
""... | python | def append(self, vals: list, index=None):
"""
Append a row to the main dataframe
:param vals: list of the row values to add
:type vals: list
:param index: index key, defaults to None
:param index: any, optional
:example: ``ds.append([0, 2, 2, 3, 4])``
""... | [
"def",
"append",
"(",
"self",
",",
"vals",
":",
"list",
",",
"index",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"df",
"=",
"self",
".",
"df",
".",
"loc",
"[",
"len",
"(",
"self",
".",
"df",
".",
"index",
")",
"]",
"=",
"vals",
"except",... | Append a row to the main dataframe
:param vals: list of the row values to add
:type vals: list
:param index: index key, defaults to None
:param index: any, optional
:example: ``ds.append([0, 2, 2, 3, 4])`` | [
"Append",
"a",
"row",
"to",
"the",
"main",
"dataframe"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/values.py#L43-L59 |
53,784 | synw/dataswim | dataswim/data/transform/values.py | Values.sort | def sort(self, col: str):
"""
Sorts the main dataframe according to the given column
:param col: column name
:type col: str
:example: ``ds.sort("Col 1")``
"""
try:
self.df = self.df.copy().sort_values(col)
except Exception as e:
s... | python | def sort(self, col: str):
"""
Sorts the main dataframe according to the given column
:param col: column name
:type col: str
:example: ``ds.sort("Col 1")``
"""
try:
self.df = self.df.copy().sort_values(col)
except Exception as e:
s... | [
"def",
"sort",
"(",
"self",
",",
"col",
":",
"str",
")",
":",
"try",
":",
"self",
".",
"df",
"=",
"self",
".",
"df",
".",
"copy",
"(",
")",
".",
"sort_values",
"(",
"col",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"err",
"(",
"... | Sorts the main dataframe according to the given column
:param col: column name
:type col: str
:example: ``ds.sort("Col 1")`` | [
"Sorts",
"the",
"main",
"dataframe",
"according",
"to",
"the",
"given",
"column"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/values.py#L61-L74 |
53,785 | synw/dataswim | dataswim/data/transform/values.py | Values.reverse | def reverse(self):
"""
Reverses the main dataframe order
:example: ``ds.reverse()``
"""
try:
self.df = self.df.iloc[::-1]
except Exception as e:
self.err(e, "Can not reverse the dataframe") | python | def reverse(self):
"""
Reverses the main dataframe order
:example: ``ds.reverse()``
"""
try:
self.df = self.df.iloc[::-1]
except Exception as e:
self.err(e, "Can not reverse the dataframe") | [
"def",
"reverse",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"df",
"=",
"self",
".",
"df",
".",
"iloc",
"[",
":",
":",
"-",
"1",
"]",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"err",
"(",
"e",
",",
"\"Can not reverse the dataframe\""... | Reverses the main dataframe order
:example: ``ds.reverse()`` | [
"Reverses",
"the",
"main",
"dataframe",
"order"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/values.py#L76-L85 |
53,786 | synw/dataswim | dataswim/data/transform/values.py | Values.apply | def apply(self, function: "function", *cols, axis=1, **kwargs):
"""
Apply a function on columns values
:param function: a function to apply to the columns
:type function: function
:param cols: columns names
:type cols: name of columns
:param axis: index (0) or co... | python | def apply(self, function: "function", *cols, axis=1, **kwargs):
"""
Apply a function on columns values
:param function: a function to apply to the columns
:type function: function
:param cols: columns names
:type cols: name of columns
:param axis: index (0) or co... | [
"def",
"apply",
"(",
"self",
",",
"function",
":",
"\"function\"",
",",
"*",
"cols",
",",
"axis",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"if",
"len",
"(",
"cols",
")",
"==",
"0",
":",
"self",
".",
"df",
"=",
"self",
".",
"df... | Apply a function on columns values
:param function: a function to apply to the columns
:type function: function
:param cols: columns names
:type cols: name of columns
:param axis: index (0) or column (1), default is 1
:param kwargs: arguments for ``df.apply``
:ty... | [
"Apply",
"a",
"function",
"on",
"columns",
"values"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/values.py#L87-L117 |
53,787 | synw/dataswim | dataswim/data/transform/values.py | Values.pivot | def pivot(self, index, **kwargs):
"""
Pivots a dataframe
"""
try:
df = self._pivot(index, **kwargs)
return pd.pivot_table(self.df, index=kwargs["index"], **kwargs)
"""if df is None:
self.err("Can not pivot table")
retur... | python | def pivot(self, index, **kwargs):
"""
Pivots a dataframe
"""
try:
df = self._pivot(index, **kwargs)
return pd.pivot_table(self.df, index=kwargs["index"], **kwargs)
"""if df is None:
self.err("Can not pivot table")
retur... | [
"def",
"pivot",
"(",
"self",
",",
"index",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"df",
"=",
"self",
".",
"_pivot",
"(",
"index",
",",
"*",
"*",
"kwargs",
")",
"return",
"pd",
".",
"pivot_table",
"(",
"self",
".",
"df",
",",
"index",
"=... | Pivots a dataframe | [
"Pivots",
"a",
"dataframe"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/values.py#L119-L131 |
53,788 | synw/dataswim | dataswim/data/transform/values.py | Values.trimsquants | def trimsquants(self, col: str, sup: float):
"""
Remove superior quantiles from the dataframe
:param col: column name
:type col: str
:param sup: superior quantile
:type sup: float
:example: ``ds.trimsquants("Col 1", 0.99)``
"""
try:
s... | python | def trimsquants(self, col: str, sup: float):
"""
Remove superior quantiles from the dataframe
:param col: column name
:type col: str
:param sup: superior quantile
:type sup: float
:example: ``ds.trimsquants("Col 1", 0.99)``
"""
try:
s... | [
"def",
"trimsquants",
"(",
"self",
",",
"col",
":",
"str",
",",
"sup",
":",
"float",
")",
":",
"try",
":",
"self",
".",
"df",
"=",
"self",
".",
"_trimquants",
"(",
"col",
",",
"None",
",",
"sup",
")",
"except",
"Exception",
"as",
"e",
":",
"self"... | Remove superior quantiles from the dataframe
:param col: column name
:type col: str
:param sup: superior quantile
:type sup: float
:example: ``ds.trimsquants("Col 1", 0.99)`` | [
"Remove",
"superior",
"quantiles",
"from",
"the",
"dataframe"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/values.py#L151-L165 |
53,789 | cslarsen/crianza | crianza/interpreter.py | isnumber | def isnumber(*args):
"""Checks if value is an integer, long integer or float.
NOTE: Treats booleans as numbers, where True=1 and False=0.
"""
return all(map(lambda c: isinstance(c, int) or isinstance(c, float), args)) | python | def isnumber(*args):
"""Checks if value is an integer, long integer or float.
NOTE: Treats booleans as numbers, where True=1 and False=0.
"""
return all(map(lambda c: isinstance(c, int) or isinstance(c, float), args)) | [
"def",
"isnumber",
"(",
"*",
"args",
")",
":",
"return",
"all",
"(",
"map",
"(",
"lambda",
"c",
":",
"isinstance",
"(",
"c",
",",
"int",
")",
"or",
"isinstance",
"(",
"c",
",",
"float",
")",
",",
"args",
")",
")"
] | Checks if value is an integer, long integer or float.
NOTE: Treats booleans as numbers, where True=1 and False=0. | [
"Checks",
"if",
"value",
"is",
"an",
"integer",
"long",
"integer",
"or",
"float",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/interpreter.py#L37-L42 |
53,790 | cslarsen/crianza | crianza/interpreter.py | isbool | def isbool(*args):
"""Checks if value is boolean."""
true_or_false = [instructions.lookup(instructions.true_),
instructions.lookup(instructions.false_)]
return all(map(lambda c: isinstance(c, bool) or c in true_or_false, args)) | python | def isbool(*args):
"""Checks if value is boolean."""
true_or_false = [instructions.lookup(instructions.true_),
instructions.lookup(instructions.false_)]
return all(map(lambda c: isinstance(c, bool) or c in true_or_false, args)) | [
"def",
"isbool",
"(",
"*",
"args",
")",
":",
"true_or_false",
"=",
"[",
"instructions",
".",
"lookup",
"(",
"instructions",
".",
"true_",
")",
",",
"instructions",
".",
"lookup",
"(",
"instructions",
".",
"false_",
")",
"]",
"return",
"all",
"(",
"map",
... | Checks if value is boolean. | [
"Checks",
"if",
"value",
"is",
"boolean",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/interpreter.py#L44-L48 |
53,791 | cslarsen/crianza | crianza/interpreter.py | isconstant | def isconstant(args, quoted=False):
"""Checks if value is a boolean, number or string."""
check = lambda c: isbool(c) or isnumber(c) or isstring(c, quoted)
if isinstance(args, list):
return all(map(check, args))
else:
return check(args) | python | def isconstant(args, quoted=False):
"""Checks if value is a boolean, number or string."""
check = lambda c: isbool(c) or isnumber(c) or isstring(c, quoted)
if isinstance(args, list):
return all(map(check, args))
else:
return check(args) | [
"def",
"isconstant",
"(",
"args",
",",
"quoted",
"=",
"False",
")",
":",
"check",
"=",
"lambda",
"c",
":",
"isbool",
"(",
"c",
")",
"or",
"isnumber",
"(",
"c",
")",
"or",
"isstring",
"(",
"c",
",",
"quoted",
")",
"if",
"isinstance",
"(",
"args",
... | Checks if value is a boolean, number or string. | [
"Checks",
"if",
"value",
"is",
"a",
"boolean",
"number",
"or",
"string",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/interpreter.py#L54-L60 |
53,792 | cslarsen/crianza | crianza/interpreter.py | execute | def execute(source, optimize=True, output=sys.stdout, input=sys.stdin, steps=-1):
"""Compiles and runs program, returning the machine used to execute the
code.
Args:
optimize: Whether to optimize the code after parsing it.
output: Stream which program can write output to.
input: Str... | python | def execute(source, optimize=True, output=sys.stdout, input=sys.stdin, steps=-1):
"""Compiles and runs program, returning the machine used to execute the
code.
Args:
optimize: Whether to optimize the code after parsing it.
output: Stream which program can write output to.
input: Str... | [
"def",
"execute",
"(",
"source",
",",
"optimize",
"=",
"True",
",",
"output",
"=",
"sys",
".",
"stdout",
",",
"input",
"=",
"sys",
".",
"stdin",
",",
"steps",
"=",
"-",
"1",
")",
":",
"from",
"crianza",
"import",
"compiler",
"code",
"=",
"compiler",
... | Compiles and runs program, returning the machine used to execute the
code.
Args:
optimize: Whether to optimize the code after parsing it.
output: Stream which program can write output to.
input: Stream which program can read input from.
steps: An optional maximum number of instr... | [
"Compiles",
"and",
"runs",
"program",
"returning",
"the",
"machine",
"used",
"to",
"execute",
"the",
"code",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/interpreter.py#L62-L79 |
53,793 | cslarsen/crianza | crianza/interpreter.py | eval | def eval(source, optimize=True, output=sys.stdout, input=sys.stdin, steps=-1):
"""Compiles and runs program, returning the values on the stack.
To return the machine instead, see execute().
Args:
optimize: Whether to optimize the code after parsing it.
output: Stream which program can writ... | python | def eval(source, optimize=True, output=sys.stdout, input=sys.stdin, steps=-1):
"""Compiles and runs program, returning the values on the stack.
To return the machine instead, see execute().
Args:
optimize: Whether to optimize the code after parsing it.
output: Stream which program can writ... | [
"def",
"eval",
"(",
"source",
",",
"optimize",
"=",
"True",
",",
"output",
"=",
"sys",
".",
"stdout",
",",
"input",
"=",
"sys",
".",
"stdin",
",",
"steps",
"=",
"-",
"1",
")",
":",
"machine",
"=",
"execute",
"(",
"source",
",",
"optimize",
"=",
"... | Compiles and runs program, returning the values on the stack.
To return the machine instead, see execute().
Args:
optimize: Whether to optimize the code after parsing it.
output: Stream which program can write output to.
input: Stream which program can read input from.
steps: A... | [
"Compiles",
"and",
"runs",
"program",
"returning",
"the",
"values",
"on",
"the",
"stack",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/interpreter.py#L81-L107 |
53,794 | cslarsen/crianza | crianza/interpreter.py | Machine.reset | def reset(self):
"""Reset stacks and instruction pointer."""
self.data_stack = stack.Stack()
self.return_stack = stack.Stack()
self.instruction_pointer = 0
return self | python | def reset(self):
"""Reset stacks and instruction pointer."""
self.data_stack = stack.Stack()
self.return_stack = stack.Stack()
self.instruction_pointer = 0
return self | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"data_stack",
"=",
"stack",
".",
"Stack",
"(",
")",
"self",
".",
"return_stack",
"=",
"stack",
".",
"Stack",
"(",
")",
"self",
".",
"instruction_pointer",
"=",
"0",
"return",
"self"
] | Reset stacks and instruction pointer. | [
"Reset",
"stacks",
"and",
"instruction",
"pointer",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/interpreter.py#L136-L141 |
53,795 | cslarsen/crianza | crianza/interpreter.py | Machine.pop | def pop(self):
"""Pops the data stack, returning the value."""
try:
return self.data_stack.pop()
except errors.MachineError as e:
raise errors.MachineError("%s: At index %d in code: %s" %
(e, self.instruction_pointer, self.code_string)) | python | def pop(self):
"""Pops the data stack, returning the value."""
try:
return self.data_stack.pop()
except errors.MachineError as e:
raise errors.MachineError("%s: At index %d in code: %s" %
(e, self.instruction_pointer, self.code_string)) | [
"def",
"pop",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"data_stack",
".",
"pop",
"(",
")",
"except",
"errors",
".",
"MachineError",
"as",
"e",
":",
"raise",
"errors",
".",
"MachineError",
"(",
"\"%s: At index %d in code: %s\"",
"%",
"(",
... | Pops the data stack, returning the value. | [
"Pops",
"the",
"data",
"stack",
"returning",
"the",
"value",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/interpreter.py#L155-L161 |
53,796 | cslarsen/crianza | crianza/interpreter.py | Machine.step | def step(self):
"""Executes one instruction and stops."""
op = self.code[self.instruction_pointer]
self.instruction_pointer += 1
op(self) | python | def step(self):
"""Executes one instruction and stops."""
op = self.code[self.instruction_pointer]
self.instruction_pointer += 1
op(self) | [
"def",
"step",
"(",
"self",
")",
":",
"op",
"=",
"self",
".",
"code",
"[",
"self",
".",
"instruction_pointer",
"]",
"self",
".",
"instruction_pointer",
"+=",
"1",
"op",
"(",
"self",
")"
] | Executes one instruction and stops. | [
"Executes",
"one",
"instruction",
"and",
"stops",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/interpreter.py#L172-L176 |
53,797 | cslarsen/crianza | crianza/interpreter.py | Machine.run | def run(self, steps=None):
"""Run threaded code in machine.
Args:
steps: If specified, run that many number of instructions before
stopping.
"""
try:
while self.instruction_pointer < len(self.code):
self.step()
if step... | python | def run(self, steps=None):
"""Run threaded code in machine.
Args:
steps: If specified, run that many number of instructions before
stopping.
"""
try:
while self.instruction_pointer < len(self.code):
self.step()
if step... | [
"def",
"run",
"(",
"self",
",",
"steps",
"=",
"None",
")",
":",
"try",
":",
"while",
"self",
".",
"instruction_pointer",
"<",
"len",
"(",
"self",
".",
"code",
")",
":",
"self",
".",
"step",
"(",
")",
"if",
"steps",
"is",
"not",
"None",
":",
"step... | Run threaded code in machine.
Args:
steps: If specified, run that many number of instructions before
stopping. | [
"Run",
"threaded",
"code",
"in",
"machine",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/interpreter.py#L178-L197 |
53,798 | gmr/tinman | tinman/mapping.py | Mapping.from_dict | def from_dict(self, values):
"""Assign the values from the dict passed in. All items in the dict
are assigned as attributes of the object.
:param dict values: The dictionary of values to assign to this mapping
"""
for k in values.keys():
setattr(self, k, values[k]) | python | def from_dict(self, values):
"""Assign the values from the dict passed in. All items in the dict
are assigned as attributes of the object.
:param dict values: The dictionary of values to assign to this mapping
"""
for k in values.keys():
setattr(self, k, values[k]) | [
"def",
"from_dict",
"(",
"self",
",",
"values",
")",
":",
"for",
"k",
"in",
"values",
".",
"keys",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"k",
",",
"values",
"[",
"k",
"]",
")"
] | Assign the values from the dict passed in. All items in the dict
are assigned as attributes of the object.
:param dict values: The dictionary of values to assign to this mapping | [
"Assign",
"the",
"values",
"from",
"the",
"dict",
"passed",
"in",
".",
"All",
"items",
"in",
"the",
"dict",
"are",
"assigned",
"as",
"attributes",
"of",
"the",
"object",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/mapping.py#L137-L145 |
53,799 | gmr/tinman | tinman/mapping.py | Mapping.keys | def keys(self):
"""Return a list of attribute names for the mapping.
:rtype: list
"""
return sorted([k for k in dir(self) if
k[0:1] != '_' and k != 'keys' and not k.isupper() and
not inspect.ismethod(getattr(self, k)) and
... | python | def keys(self):
"""Return a list of attribute names for the mapping.
:rtype: list
"""
return sorted([k for k in dir(self) if
k[0:1] != '_' and k != 'keys' and not k.isupper() and
not inspect.ismethod(getattr(self, k)) and
... | [
"def",
"keys",
"(",
"self",
")",
":",
"return",
"sorted",
"(",
"[",
"k",
"for",
"k",
"in",
"dir",
"(",
"self",
")",
"if",
"k",
"[",
"0",
":",
"1",
"]",
"!=",
"'_'",
"and",
"k",
"!=",
"'keys'",
"and",
"not",
"k",
".",
"isupper",
"(",
")",
"a... | Return a list of attribute names for the mapping.
:rtype: list | [
"Return",
"a",
"list",
"of",
"attribute",
"names",
"for",
"the",
"mapping",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/mapping.py#L179-L191 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.