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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
39,500 | mozilla/rna | rna/models.py | Release.equivalent_release_for_product | def equivalent_release_for_product(self, product):
"""
Returns the release for a specified product with the same
channel and major version with the highest minor version,
or None if no such releases exist
"""
releases = self._default_manager.filter(
version__s... | python | def equivalent_release_for_product(self, product):
"""
Returns the release for a specified product with the same
channel and major version with the highest minor version,
or None if no such releases exist
"""
releases = self._default_manager.filter(
version__s... | [
"def",
"equivalent_release_for_product",
"(",
"self",
",",
"product",
")",
":",
"releases",
"=",
"self",
".",
"_default_manager",
".",
"filter",
"(",
"version__startswith",
"=",
"self",
".",
"major_version",
"(",
")",
"+",
"'.'",
",",
"channel",
"=",
"self",
... | Returns the release for a specified product with the same
channel and major version with the highest minor version,
or None if no such releases exist | [
"Returns",
"the",
"release",
"for",
"a",
"specified",
"product",
"with",
"the",
"same",
"channel",
"and",
"major",
"version",
"with",
"the",
"highest",
"minor",
"version",
"or",
"None",
"if",
"no",
"such",
"releases",
"exist"
] | c1d3931f577dc9c54997f876d36bc0b44dc225ea | https://github.com/mozilla/rna/blob/c1d3931f577dc9c54997f876d36bc0b44dc225ea/rna/models.py#L94-L109 |
39,501 | mozilla/rna | rna/models.py | Release.notes | def notes(self, public_only=False):
"""
Retrieve a list of Note instances that should be shown for this
release, grouped as either new features or known issues, and sorted
first by sort_num highest to lowest and then by created date,
which is applied to both groups,
and t... | python | def notes(self, public_only=False):
"""
Retrieve a list of Note instances that should be shown for this
release, grouped as either new features or known issues, and sorted
first by sort_num highest to lowest and then by created date,
which is applied to both groups,
and t... | [
"def",
"notes",
"(",
"self",
",",
"public_only",
"=",
"False",
")",
":",
"tag_index",
"=",
"dict",
"(",
"(",
"tag",
",",
"i",
")",
"for",
"i",
",",
"tag",
"in",
"enumerate",
"(",
"Note",
".",
"TAGS",
")",
")",
"notes",
"=",
"self",
".",
"note_set... | Retrieve a list of Note instances that should be shown for this
release, grouped as either new features or known issues, and sorted
first by sort_num highest to lowest and then by created date,
which is applied to both groups,
and then for new features we also sort by tag in the order sp... | [
"Retrieve",
"a",
"list",
"of",
"Note",
"instances",
"that",
"should",
"be",
"shown",
"for",
"this",
"release",
"grouped",
"as",
"either",
"new",
"features",
"or",
"known",
"issues",
"and",
"sorted",
"first",
"by",
"sort_num",
"highest",
"to",
"lowest",
"and"... | c1d3931f577dc9c54997f876d36bc0b44dc225ea | https://github.com/mozilla/rna/blob/c1d3931f577dc9c54997f876d36bc0b44dc225ea/rna/models.py#L119-L142 |
39,502 | mozilla/rna | rna/models.py | Release.to_dict | def to_dict(self):
"""Return a dict all all data about the release"""
data = model_to_dict(self, exclude=['id'])
data['title'] = unicode(self)
data['slug'] = self.slug
data['release_date'] = self.release_date.date().isoformat()
data['created'] = self.created.isoformat()
... | python | def to_dict(self):
"""Return a dict all all data about the release"""
data = model_to_dict(self, exclude=['id'])
data['title'] = unicode(self)
data['slug'] = self.slug
data['release_date'] = self.release_date.date().isoformat()
data['created'] = self.created.isoformat()
... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"data",
"=",
"model_to_dict",
"(",
"self",
",",
"exclude",
"=",
"[",
"'id'",
"]",
")",
"data",
"[",
"'title'",
"]",
"=",
"unicode",
"(",
"self",
")",
"data",
"[",
"'slug'",
"]",
"=",
"self",
".",
"slug",
"... | Return a dict all all data about the release | [
"Return",
"a",
"dict",
"all",
"all",
"data",
"about",
"the",
"release"
] | c1d3931f577dc9c54997f876d36bc0b44dc225ea | https://github.com/mozilla/rna/blob/c1d3931f577dc9c54997f876d36bc0b44dc225ea/rna/models.py#L144-L156 |
39,503 | mozilla/rna | rna/models.py | Release.to_simple_dict | def to_simple_dict(self):
"""Return a dict of only the basic data about the release"""
return {
'version': self.version,
'product': self.product,
'channel': self.channel,
'is_public': self.is_public,
'slug': self.slug,
'title': unic... | python | def to_simple_dict(self):
"""Return a dict of only the basic data about the release"""
return {
'version': self.version,
'product': self.product,
'channel': self.channel,
'is_public': self.is_public,
'slug': self.slug,
'title': unic... | [
"def",
"to_simple_dict",
"(",
"self",
")",
":",
"return",
"{",
"'version'",
":",
"self",
".",
"version",
",",
"'product'",
":",
"self",
".",
"product",
",",
"'channel'",
":",
"self",
".",
"channel",
",",
"'is_public'",
":",
"self",
".",
"is_public",
",",... | Return a dict of only the basic data about the release | [
"Return",
"a",
"dict",
"of",
"only",
"the",
"basic",
"data",
"about",
"the",
"release"
] | c1d3931f577dc9c54997f876d36bc0b44dc225ea | https://github.com/mozilla/rna/blob/c1d3931f577dc9c54997f876d36bc0b44dc225ea/rna/models.py#L158-L167 |
39,504 | mobinrg/rpi_spark_drives | JMRPiSpark/Drives/Audio/RPiTone.py | RPiTonePlayer.playToneList | def playToneList(self, playList = None):
"""!
\~english
Play tone from a tone list
@param playList a array of tones
\~chinese
播放音调列表
@param playList: 音调数组
\~english @note <b>playList</b> format:\n
\~chinese @note <b>playList</b> 格... | python | def playToneList(self, playList = None):
"""!
\~english
Play tone from a tone list
@param playList a array of tones
\~chinese
播放音调列表
@param playList: 音调数组
\~english @note <b>playList</b> format:\n
\~chinese @note <b>playList</b> 格... | [
"def",
"playToneList",
"(",
"self",
",",
"playList",
"=",
"None",
")",
":",
"if",
"playList",
"==",
"None",
":",
"return",
"False",
"for",
"t",
"in",
"playList",
":",
"self",
".",
"playTone",
"(",
"t",
"[",
"\"freq\"",
"]",
",",
"t",
"[",
"\"reps\"",... | !
\~english
Play tone from a tone list
@param playList a array of tones
\~chinese
播放音调列表
@param playList: 音调数组
\~english @note <b>playList</b> format:\n
\~chinese @note <b>playList</b> 格式:\n
\~
<pre>
[
... | [
"!",
"\\",
"~english",
"Play",
"tone",
"from",
"a",
"tone",
"list"
] | e1602d8268a5ef48e9e0a8b37de89e0233f946ea | https://github.com/mobinrg/rpi_spark_drives/blob/e1602d8268a5ef48e9e0a8b37de89e0233f946ea/JMRPiSpark/Drives/Audio/RPiTone.py#L197-L229 |
39,505 | objectrocket/python-client | objectrocket/acls.py | Acls.all | def all(self, instance):
"""Get all ACLs associated with the instance specified by name.
:param str instance: The name of the instance from which to fetch ACLs.
:returns: A list of :py:class:`Acl` objects associated with the specified instance.
:rtype: list
"""
url = sel... | python | def all(self, instance):
"""Get all ACLs associated with the instance specified by name.
:param str instance: The name of the instance from which to fetch ACLs.
:returns: A list of :py:class:`Acl` objects associated with the specified instance.
:rtype: list
"""
url = sel... | [
"def",
"all",
"(",
"self",
",",
"instance",
")",
":",
"url",
"=",
"self",
".",
"_url",
".",
"format",
"(",
"instance",
"=",
"instance",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"*",
"*",
"self",
".",
"_default_request_kwargs",
"... | Get all ACLs associated with the instance specified by name.
:param str instance: The name of the instance from which to fetch ACLs.
:returns: A list of :py:class:`Acl` objects associated with the specified instance.
:rtype: list | [
"Get",
"all",
"ACLs",
"associated",
"with",
"the",
"instance",
"specified",
"by",
"name",
"."
] | a65868c7511ff49a5fbe304e53bf592b7fc6d5ef | https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/acls.py#L28-L38 |
39,506 | objectrocket/python-client | objectrocket/acls.py | Acls.create | def create(self, instance, cidr_mask, description, **kwargs):
"""Create an ACL entry for the specified instance.
:param str instance: The name of the instance to associate the new ACL entry with.
:param str cidr_mask: The IPv4 CIDR mask for the new ACL entry.
:param str description: A s... | python | def create(self, instance, cidr_mask, description, **kwargs):
"""Create an ACL entry for the specified instance.
:param str instance: The name of the instance to associate the new ACL entry with.
:param str cidr_mask: The IPv4 CIDR mask for the new ACL entry.
:param str description: A s... | [
"def",
"create",
"(",
"self",
",",
"instance",
",",
"cidr_mask",
",",
"description",
",",
"*",
"*",
"kwargs",
")",
":",
"# Build up request data.",
"url",
"=",
"self",
".",
"_url",
".",
"format",
"(",
"instance",
"=",
"instance",
")",
"request_data",
"=",
... | Create an ACL entry for the specified instance.
:param str instance: The name of the instance to associate the new ACL entry with.
:param str cidr_mask: The IPv4 CIDR mask for the new ACL entry.
:param str description: A short description for the new ACL entry.
:param collector kwargs: ... | [
"Create",
"an",
"ACL",
"entry",
"for",
"the",
"specified",
"instance",
"."
] | a65868c7511ff49a5fbe304e53bf592b7fc6d5ef | https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/acls.py#L41-L75 |
39,507 | objectrocket/python-client | objectrocket/acls.py | Acls.get | def get(self, instance, acl):
"""Get an ACL by ID belonging to the instance specified by name.
:param str instance: The name of the instance from which to fetch the ACL.
:param str acl: The ID of the ACL to fetch.
:returns: An :py:class:`Acl` object, or None if ACL does not exist.
... | python | def get(self, instance, acl):
"""Get an ACL by ID belonging to the instance specified by name.
:param str instance: The name of the instance from which to fetch the ACL.
:param str acl: The ID of the ACL to fetch.
:returns: An :py:class:`Acl` object, or None if ACL does not exist.
... | [
"def",
"get",
"(",
"self",
",",
"instance",
",",
"acl",
")",
":",
"base_url",
"=",
"self",
".",
"_url",
".",
"format",
"(",
"instance",
"=",
"instance",
")",
"url",
"=",
"'{base}{aclid}/'",
".",
"format",
"(",
"base",
"=",
"base_url",
",",
"aclid",
"... | Get an ACL by ID belonging to the instance specified by name.
:param str instance: The name of the instance from which to fetch the ACL.
:param str acl: The ID of the ACL to fetch.
:returns: An :py:class:`Acl` object, or None if ACL does not exist.
:rtype: :py:class:`Acl` | [
"Get",
"an",
"ACL",
"by",
"ID",
"belonging",
"to",
"the",
"instance",
"specified",
"by",
"name",
"."
] | a65868c7511ff49a5fbe304e53bf592b7fc6d5ef | https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/acls.py#L78-L90 |
39,508 | objectrocket/python-client | objectrocket/acls.py | Acls.delete | def delete(self, instance, acl):
"""Delete an ACL by ID belonging to the instance specified by name.
:param str instance: The name of the instance on which the ACL exists.
:param str acll: The ID of the ACL to delete.
"""
base_url = self._url.format(instance=instance)
ur... | python | def delete(self, instance, acl):
"""Delete an ACL by ID belonging to the instance specified by name.
:param str instance: The name of the instance on which the ACL exists.
:param str acll: The ID of the ACL to delete.
"""
base_url = self._url.format(instance=instance)
ur... | [
"def",
"delete",
"(",
"self",
",",
"instance",
",",
"acl",
")",
":",
"base_url",
"=",
"self",
".",
"_url",
".",
"format",
"(",
"instance",
"=",
"instance",
")",
"url",
"=",
"'{base}{aclid}/'",
".",
"format",
"(",
"base",
"=",
"base_url",
",",
"aclid",
... | Delete an ACL by ID belonging to the instance specified by name.
:param str instance: The name of the instance on which the ACL exists.
:param str acll: The ID of the ACL to delete. | [
"Delete",
"an",
"ACL",
"by",
"ID",
"belonging",
"to",
"the",
"instance",
"specified",
"by",
"name",
"."
] | a65868c7511ff49a5fbe304e53bf592b7fc6d5ef | https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/acls.py#L93-L108 |
39,509 | objectrocket/python-client | objectrocket/acls.py | Acls._concrete_acl | def _concrete_acl(self, acl_doc):
"""Concretize an ACL document.
:param dict acl_doc: A document describing an ACL entry. Should come from the API.
:returns: An :py:class:`Acl`, or None.
:rtype: :py:class:`bases.BaseInstance`
"""
if not isinstance(acl_doc, dict):
... | python | def _concrete_acl(self, acl_doc):
"""Concretize an ACL document.
:param dict acl_doc: A document describing an ACL entry. Should come from the API.
:returns: An :py:class:`Acl`, or None.
:rtype: :py:class:`bases.BaseInstance`
"""
if not isinstance(acl_doc, dict):
... | [
"def",
"_concrete_acl",
"(",
"self",
",",
"acl_doc",
")",
":",
"if",
"not",
"isinstance",
"(",
"acl_doc",
",",
"dict",
")",
":",
"return",
"None",
"# Attempt to instantiate an Acl object with the given dict.",
"try",
":",
"return",
"Acl",
"(",
"document",
"=",
"... | Concretize an ACL document.
:param dict acl_doc: A document describing an ACL entry. Should come from the API.
:returns: An :py:class:`Acl`, or None.
:rtype: :py:class:`bases.BaseInstance` | [
"Concretize",
"an",
"ACL",
"document",
"."
] | a65868c7511ff49a5fbe304e53bf592b7fc6d5ef | https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/acls.py#L113-L133 |
39,510 | objectrocket/python-client | objectrocket/acls.py | Acls._concrete_acl_list | def _concrete_acl_list(self, acl_docs):
"""Concretize a list of ACL documents.
:param list acl_docs: A list of ACL documents. Should come from the API.
:returns: A list of :py:class:`ACL` objects.
:rtype: list
"""
if not acl_docs:
return []
return li... | python | def _concrete_acl_list(self, acl_docs):
"""Concretize a list of ACL documents.
:param list acl_docs: A list of ACL documents. Should come from the API.
:returns: A list of :py:class:`ACL` objects.
:rtype: list
"""
if not acl_docs:
return []
return li... | [
"def",
"_concrete_acl_list",
"(",
"self",
",",
"acl_docs",
")",
":",
"if",
"not",
"acl_docs",
":",
"return",
"[",
"]",
"return",
"list",
"(",
"filter",
"(",
"None",
",",
"[",
"self",
".",
"_concrete_acl",
"(",
"acl_doc",
"=",
"doc",
")",
"for",
"doc",
... | Concretize a list of ACL documents.
:param list acl_docs: A list of ACL documents. Should come from the API.
:returns: A list of :py:class:`ACL` objects.
:rtype: list | [
"Concretize",
"a",
"list",
"of",
"ACL",
"documents",
"."
] | a65868c7511ff49a5fbe304e53bf592b7fc6d5ef | https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/acls.py#L135-L145 |
39,511 | objectrocket/python-client | objectrocket/acls.py | Acls._default_request_kwargs | def _default_request_kwargs(self):
"""The default request keyword arguments to be passed to the requests library."""
defaults = copy.deepcopy(super(Acls, self)._default_request_kwargs)
defaults.setdefault('headers', {}).update({
'X-Auth-Token': self._client.auth._token
})
... | python | def _default_request_kwargs(self):
"""The default request keyword arguments to be passed to the requests library."""
defaults = copy.deepcopy(super(Acls, self)._default_request_kwargs)
defaults.setdefault('headers', {}).update({
'X-Auth-Token': self._client.auth._token
})
... | [
"def",
"_default_request_kwargs",
"(",
"self",
")",
":",
"defaults",
"=",
"copy",
".",
"deepcopy",
"(",
"super",
"(",
"Acls",
",",
"self",
")",
".",
"_default_request_kwargs",
")",
"defaults",
".",
"setdefault",
"(",
"'headers'",
",",
"{",
"}",
")",
".",
... | The default request keyword arguments to be passed to the requests library. | [
"The",
"default",
"request",
"keyword",
"arguments",
"to",
"be",
"passed",
"to",
"the",
"requests",
"library",
"."
] | a65868c7511ff49a5fbe304e53bf592b7fc6d5ef | https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/acls.py#L148-L154 |
39,512 | objectrocket/python-client | objectrocket/acls.py | Acl._url | def _url(self):
"""The URL of this ACL object."""
base_url = self._client._url.rstrip('/')
return '{}/instances/{}/acls/{}/'.format(base_url, self.instance_name, self.id) | python | def _url(self):
"""The URL of this ACL object."""
base_url = self._client._url.rstrip('/')
return '{}/instances/{}/acls/{}/'.format(base_url, self.instance_name, self.id) | [
"def",
"_url",
"(",
"self",
")",
":",
"base_url",
"=",
"self",
".",
"_client",
".",
"_url",
".",
"rstrip",
"(",
"'/'",
")",
"return",
"'{}/instances/{}/acls/{}/'",
".",
"format",
"(",
"base_url",
",",
"self",
".",
"instance_name",
",",
"self",
".",
"id",... | The URL of this ACL object. | [
"The",
"URL",
"of",
"this",
"ACL",
"object",
"."
] | a65868c7511ff49a5fbe304e53bf592b7fc6d5ef | https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/acls.py#L273-L276 |
39,513 | thespacedoctor/fundamentals | fundamentals/mysql/insert_list_of_dictionaries_into_database_tables.py | insert_list_of_dictionaries_into_database_tables | def insert_list_of_dictionaries_into_database_tables(
dbConn,
log,
dictList,
dbTableName,
uniqueKeyList=[],
dateModified=False,
dateCreated=True,
batchSize=2500,
replace=False,
dbSettings=False):
"""insert list of dictionaries into data... | python | def insert_list_of_dictionaries_into_database_tables(
dbConn,
log,
dictList,
dbTableName,
uniqueKeyList=[],
dateModified=False,
dateCreated=True,
batchSize=2500,
replace=False,
dbSettings=False):
"""insert list of dictionaries into data... | [
"def",
"insert_list_of_dictionaries_into_database_tables",
"(",
"dbConn",
",",
"log",
",",
"dictList",
",",
"dbTableName",
",",
"uniqueKeyList",
"=",
"[",
"]",
",",
"dateModified",
"=",
"False",
",",
"dateCreated",
"=",
"True",
",",
"batchSize",
"=",
"2500",
","... | insert list of dictionaries into database tables
**Key Arguments:**
- ``dbConn`` -- mysql database connection
- ``log`` -- logger
- ``dictList`` -- list of python dictionaries to add to the database table
- ``dbTableName`` -- name of the database table
- ``uniqueKeyList`` --... | [
"insert",
"list",
"of",
"dictionaries",
"into",
"database",
"tables"
] | 1d2c007ac74442ec2eabde771cfcacdb9c1ab382 | https://github.com/thespacedoctor/fundamentals/blob/1d2c007ac74442ec2eabde771cfcacdb9c1ab382/fundamentals/mysql/insert_list_of_dictionaries_into_database_tables.py#L33-L158 |
39,514 | klen/starter | starter/core.py | FS.make_directory | def make_directory(path):
""" Create directory if that not exists. """
try:
makedirs(path)
logging.debug('Directory created: {0}'.format(path))
except OSError as e:
if e.errno != errno.EEXIST:
raise | python | def make_directory(path):
""" Create directory if that not exists. """
try:
makedirs(path)
logging.debug('Directory created: {0}'.format(path))
except OSError as e:
if e.errno != errno.EEXIST:
raise | [
"def",
"make_directory",
"(",
"path",
")",
":",
"try",
":",
"makedirs",
"(",
"path",
")",
"logging",
".",
"debug",
"(",
"'Directory created: {0}'",
".",
"format",
"(",
"path",
")",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"!="... | Create directory if that not exists. | [
"Create",
"directory",
"if",
"that",
"not",
"exists",
"."
] | 24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f | https://github.com/klen/starter/blob/24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f/starter/core.py#L42-L50 |
39,515 | klen/starter | starter/core.py | FS.copy_file | def copy_file(self, from_path, to_path):
""" Copy file. """
if not op.exists(op.dirname(to_path)):
self.make_directory(op.dirname(to_path))
shutil.copy(from_path, to_path)
logging.debug('File copied: {0}'.format(to_path)) | python | def copy_file(self, from_path, to_path):
""" Copy file. """
if not op.exists(op.dirname(to_path)):
self.make_directory(op.dirname(to_path))
shutil.copy(from_path, to_path)
logging.debug('File copied: {0}'.format(to_path)) | [
"def",
"copy_file",
"(",
"self",
",",
"from_path",
",",
"to_path",
")",
":",
"if",
"not",
"op",
".",
"exists",
"(",
"op",
".",
"dirname",
"(",
"to_path",
")",
")",
":",
"self",
".",
"make_directory",
"(",
"op",
".",
"dirname",
"(",
"to_path",
")",
... | Copy file. | [
"Copy",
"file",
"."
] | 24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f | https://github.com/klen/starter/blob/24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f/starter/core.py#L52-L58 |
39,516 | klen/starter | starter/core.py | Template.params | def params(self):
""" Read self params from configuration. """
parser = JinjaInterpolationNamespace()
parser.read(self.configuration)
return dict(parser['params'] or {}) | python | def params(self):
""" Read self params from configuration. """
parser = JinjaInterpolationNamespace()
parser.read(self.configuration)
return dict(parser['params'] or {}) | [
"def",
"params",
"(",
"self",
")",
":",
"parser",
"=",
"JinjaInterpolationNamespace",
"(",
")",
"parser",
".",
"read",
"(",
"self",
".",
"configuration",
")",
"return",
"dict",
"(",
"parser",
"[",
"'params'",
"]",
"or",
"{",
"}",
")"
] | Read self params from configuration. | [
"Read",
"self",
"params",
"from",
"configuration",
"."
] | 24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f | https://github.com/klen/starter/blob/24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f/starter/core.py#L105-L109 |
39,517 | klen/starter | starter/core.py | Template.scan | def scan(cls, path):
""" Scan directory for templates. """
result = []
try:
for _p in listdir(path):
try:
result.append(Template(_p, op.join(path, _p)))
except ValueError:
continue
except OSError:
... | python | def scan(cls, path):
""" Scan directory for templates. """
result = []
try:
for _p in listdir(path):
try:
result.append(Template(_p, op.join(path, _p)))
except ValueError:
continue
except OSError:
... | [
"def",
"scan",
"(",
"cls",
",",
"path",
")",
":",
"result",
"=",
"[",
"]",
"try",
":",
"for",
"_p",
"in",
"listdir",
"(",
"path",
")",
":",
"try",
":",
"result",
".",
"append",
"(",
"Template",
"(",
"_p",
",",
"op",
".",
"join",
"(",
"path",
... | Scan directory for templates. | [
"Scan",
"directory",
"for",
"templates",
"."
] | 24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f | https://github.com/klen/starter/blob/24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f/starter/core.py#L134-L146 |
39,518 | klen/starter | starter/core.py | Starter.copy | def copy(self):
""" Prepare and paste self templates. """
templates = self.prepare_templates()
if self.params.interactive:
keys = list(self.parser.default)
for key in keys:
if key.startswith('_'):
continue
prompt = "{0} ... | python | def copy(self):
""" Prepare and paste self templates. """
templates = self.prepare_templates()
if self.params.interactive:
keys = list(self.parser.default)
for key in keys:
if key.startswith('_'):
continue
prompt = "{0} ... | [
"def",
"copy",
"(",
"self",
")",
":",
"templates",
"=",
"self",
".",
"prepare_templates",
"(",
")",
"if",
"self",
".",
"params",
".",
"interactive",
":",
"keys",
"=",
"list",
"(",
"self",
".",
"parser",
".",
"default",
")",
"for",
"key",
"in",
"keys"... | Prepare and paste self templates. | [
"Prepare",
"and",
"paste",
"self",
"templates",
"."
] | 24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f | https://github.com/klen/starter/blob/24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f/starter/core.py#L180-L211 |
39,519 | klen/starter | starter/core.py | Starter.iterate_templates | def iterate_templates(self):
""" Iterate self starter templates.
:returns: A templates generator
"""
return [t for dd in self.dirs for t in Template.scan(dd)] | python | def iterate_templates(self):
""" Iterate self starter templates.
:returns: A templates generator
"""
return [t for dd in self.dirs for t in Template.scan(dd)] | [
"def",
"iterate_templates",
"(",
"self",
")",
":",
"return",
"[",
"t",
"for",
"dd",
"in",
"self",
".",
"dirs",
"for",
"t",
"in",
"Template",
".",
"scan",
"(",
"dd",
")",
"]"
] | Iterate self starter templates.
:returns: A templates generator | [
"Iterate",
"self",
"starter",
"templates",
"."
] | 24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f | https://github.com/klen/starter/blob/24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f/starter/core.py#L239-L245 |
39,520 | sci-bots/dmf-device-ui | dmf_device_ui/view.py | DmfDeviceViewBase.on_canvas_slave__electrode_pair_selected | def on_canvas_slave__electrode_pair_selected(self, slave, data):
'''
Process pair of selected electrodes.
For now, this consists of finding the shortest path between the two
electrodes and appending it to the list of droplet routes for the
current step.
Note that the dr... | python | def on_canvas_slave__electrode_pair_selected(self, slave, data):
'''
Process pair of selected electrodes.
For now, this consists of finding the shortest path between the two
electrodes and appending it to the list of droplet routes for the
current step.
Note that the dr... | [
"def",
"on_canvas_slave__electrode_pair_selected",
"(",
"self",
",",
"slave",
",",
"data",
")",
":",
"import",
"networkx",
"as",
"nx",
"source_id",
"=",
"data",
"[",
"'source_id'",
"]",
"target_id",
"=",
"data",
"[",
"'target_id'",
"]",
"if",
"self",
".",
"c... | Process pair of selected electrodes.
For now, this consists of finding the shortest path between the two
electrodes and appending it to the list of droplet routes for the
current step.
Note that the droplet routes for a step are stored in a frame/table in
the `DmfDeviceControll... | [
"Process",
"pair",
"of",
"selected",
"electrodes",
"."
] | 05b480683c9fa43f91ce5a58de2fa90cdf363fc8 | https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/view.py#L241-L281 |
39,521 | sci-bots/dmf-device-ui | dmf_device_ui/view.py | DmfDeviceViewBase.ping_hub | def ping_hub(self):
'''
Attempt to ping the ZeroMQ plugin hub to verify connection is alive.
If ping is successful, record timestamp.
If ping is unsuccessful, call `on_heartbeat_error` method.
'''
if self.plugin is not None:
try:
self.plugin.e... | python | def ping_hub(self):
'''
Attempt to ping the ZeroMQ plugin hub to verify connection is alive.
If ping is successful, record timestamp.
If ping is unsuccessful, call `on_heartbeat_error` method.
'''
if self.plugin is not None:
try:
self.plugin.e... | [
"def",
"ping_hub",
"(",
"self",
")",
":",
"if",
"self",
".",
"plugin",
"is",
"not",
"None",
":",
"try",
":",
"self",
".",
"plugin",
".",
"execute",
"(",
"self",
".",
"plugin",
".",
"hub_name",
",",
"'ping'",
",",
"timeout_s",
"=",
"1",
",",
"silent... | Attempt to ping the ZeroMQ plugin hub to verify connection is alive.
If ping is successful, record timestamp.
If ping is unsuccessful, call `on_heartbeat_error` method. | [
"Attempt",
"to",
"ping",
"the",
"ZeroMQ",
"plugin",
"hub",
"to",
"verify",
"connection",
"is",
"alive",
"."
] | 05b480683c9fa43f91ce5a58de2fa90cdf363fc8 | https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/view.py#L330-L347 |
39,522 | lambdalisue/app_version | src/app_version/core.py | get_string_version | def get_string_version(name,
default=DEFAULT_STRING_NOT_FOUND,
allow_ambiguous=True):
"""
Get string version from installed package information.
It will return :attr:`default` value when the named package is not
installed.
Parameters
-----------
... | python | def get_string_version(name,
default=DEFAULT_STRING_NOT_FOUND,
allow_ambiguous=True):
"""
Get string version from installed package information.
It will return :attr:`default` value when the named package is not
installed.
Parameters
-----------
... | [
"def",
"get_string_version",
"(",
"name",
",",
"default",
"=",
"DEFAULT_STRING_NOT_FOUND",
",",
"allow_ambiguous",
"=",
"True",
")",
":",
"# get filename of callar",
"callar",
"=",
"inspect",
".",
"getouterframes",
"(",
"inspect",
".",
"currentframe",
"(",
")",
")... | Get string version from installed package information.
It will return :attr:`default` value when the named package is not
installed.
Parameters
-----------
name : string
An application name used to install via setuptools.
default : string
A default returning value used when the... | [
"Get",
"string",
"version",
"from",
"installed",
"package",
"information",
"."
] | 4b9f0acf44b5ed4230cb510edc15625151246611 | https://github.com/lambdalisue/app_version/blob/4b9f0acf44b5ed4230cb510edc15625151246611/src/app_version/core.py#L27-L77 |
39,523 | lambdalisue/app_version | src/app_version/core.py | get_tuple_version | def get_tuple_version(name,
default=DEFAULT_TUPLE_NOT_FOUND,
allow_ambiguous=True):
"""
Get tuple version from installed package information for easy handling.
It will return :attr:`default` value when the named package is not
installed.
Parameters
-... | python | def get_tuple_version(name,
default=DEFAULT_TUPLE_NOT_FOUND,
allow_ambiguous=True):
"""
Get tuple version from installed package information for easy handling.
It will return :attr:`default` value when the named package is not
installed.
Parameters
-... | [
"def",
"get_tuple_version",
"(",
"name",
",",
"default",
"=",
"DEFAULT_TUPLE_NOT_FOUND",
",",
"allow_ambiguous",
"=",
"True",
")",
":",
"def",
"_prefer_int",
"(",
"x",
")",
":",
"try",
":",
"return",
"int",
"(",
"x",
")",
"except",
"ValueError",
":",
"retu... | Get tuple version from installed package information for easy handling.
It will return :attr:`default` value when the named package is not
installed.
Parameters
-----------
name : string
An application name used to install via setuptools.
default : tuple
A default returning val... | [
"Get",
"tuple",
"version",
"from",
"installed",
"package",
"information",
"for",
"easy",
"handling",
"."
] | 4b9f0acf44b5ed4230cb510edc15625151246611 | https://github.com/lambdalisue/app_version/blob/4b9f0acf44b5ed4230cb510edc15625151246611/src/app_version/core.py#L80-L130 |
39,524 | lambdalisue/app_version | src/app_version/core.py | get_versions | def get_versions(name,
default_string=DEFAULT_STRING_NOT_FOUND,
default_tuple=DEFAULT_TUPLE_NOT_FOUND,
allow_ambiguous=True):
"""
Get string and tuple versions from installed package information
It will return :attr:`default_string` and :attr:`default_tupl... | python | def get_versions(name,
default_string=DEFAULT_STRING_NOT_FOUND,
default_tuple=DEFAULT_TUPLE_NOT_FOUND,
allow_ambiguous=True):
"""
Get string and tuple versions from installed package information
It will return :attr:`default_string` and :attr:`default_tupl... | [
"def",
"get_versions",
"(",
"name",
",",
"default_string",
"=",
"DEFAULT_STRING_NOT_FOUND",
",",
"default_tuple",
"=",
"DEFAULT_TUPLE_NOT_FOUND",
",",
"allow_ambiguous",
"=",
"True",
")",
":",
"version_string",
"=",
"get_string_version",
"(",
"name",
",",
"default_str... | Get string and tuple versions from installed package information
It will return :attr:`default_string` and :attr:`default_tuple` values when
the named package is not installed.
Parameters
-----------
name : string
An application name used to install via setuptools.
default : string
... | [
"Get",
"string",
"and",
"tuple",
"versions",
"from",
"installed",
"package",
"information"
] | 4b9f0acf44b5ed4230cb510edc15625151246611 | https://github.com/lambdalisue/app_version/blob/4b9f0acf44b5ed4230cb510edc15625151246611/src/app_version/core.py#L133-L174 |
39,525 | stxnext/mappet | mappet/helpers.py | no_empty_value | def no_empty_value(func):
"""Raises an exception if function argument is empty."""
@wraps(func)
def wrapper(value):
if not value:
raise Exception("Empty value not allowed")
return func(value)
return wrapper | python | def no_empty_value(func):
"""Raises an exception if function argument is empty."""
@wraps(func)
def wrapper(value):
if not value:
raise Exception("Empty value not allowed")
return func(value)
return wrapper | [
"def",
"no_empty_value",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"value",
")",
":",
"if",
"not",
"value",
":",
"raise",
"Exception",
"(",
"\"Empty value not allowed\"",
")",
"return",
"func",
"(",
"value",
")",
"retu... | Raises an exception if function argument is empty. | [
"Raises",
"an",
"exception",
"if",
"function",
"argument",
"is",
"empty",
"."
] | ac7468ac28ed82e45065b1e348cf865c8f73f0db | https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/helpers.py#L38-L45 |
39,526 | stxnext/mappet | mappet/helpers.py | to_bool | def to_bool(value):
"""Converts human boolean-like values to Python boolean.
Falls back to :class:`bool` when ``value`` is not recognized.
:param value: the value to convert
:returns: ``True`` if value is truthy, ``False`` otherwise
:rtype: bool
"""
cases = {
'0': False,
'f... | python | def to_bool(value):
"""Converts human boolean-like values to Python boolean.
Falls back to :class:`bool` when ``value`` is not recognized.
:param value: the value to convert
:returns: ``True`` if value is truthy, ``False`` otherwise
:rtype: bool
"""
cases = {
'0': False,
'f... | [
"def",
"to_bool",
"(",
"value",
")",
":",
"cases",
"=",
"{",
"'0'",
":",
"False",
",",
"'false'",
":",
"False",
",",
"'no'",
":",
"False",
",",
"'1'",
":",
"True",
",",
"'true'",
":",
"True",
",",
"'yes'",
":",
"True",
",",
"}",
"value",
"=",
"... | Converts human boolean-like values to Python boolean.
Falls back to :class:`bool` when ``value`` is not recognized.
:param value: the value to convert
:returns: ``True`` if value is truthy, ``False`` otherwise
:rtype: bool | [
"Converts",
"human",
"boolean",
"-",
"like",
"values",
"to",
"Python",
"boolean",
"."
] | ac7468ac28ed82e45065b1e348cf865c8f73f0db | https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/helpers.py#L48-L67 |
39,527 | stxnext/mappet | mappet/helpers.py | etree_to_dict | def etree_to_dict(t, trim=True, **kw):
u"""Converts an lxml.etree object to Python dict.
>>> etree_to_dict(etree.Element('root'))
{'root': None}
:param etree.Element t: lxml tree to convert
:returns d: a dict representing the lxml tree ``t``
:rtype: dict
"""
d = {t.tag: {} if t.attrib ... | python | def etree_to_dict(t, trim=True, **kw):
u"""Converts an lxml.etree object to Python dict.
>>> etree_to_dict(etree.Element('root'))
{'root': None}
:param etree.Element t: lxml tree to convert
:returns d: a dict representing the lxml tree ``t``
:rtype: dict
"""
d = {t.tag: {} if t.attrib ... | [
"def",
"etree_to_dict",
"(",
"t",
",",
"trim",
"=",
"True",
",",
"*",
"*",
"kw",
")",
":",
"d",
"=",
"{",
"t",
".",
"tag",
":",
"{",
"}",
"if",
"t",
".",
"attrib",
"else",
"None",
"}",
"children",
"=",
"list",
"(",
"t",
")",
"etree_to_dict_w_ar... | u"""Converts an lxml.etree object to Python dict.
>>> etree_to_dict(etree.Element('root'))
{'root': None}
:param etree.Element t: lxml tree to convert
:returns d: a dict representing the lxml tree ``t``
:rtype: dict | [
"u",
"Converts",
"an",
"lxml",
".",
"etree",
"object",
"to",
"Python",
"dict",
"."
] | ac7468ac28ed82e45065b1e348cf865c8f73f0db | https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/helpers.py#L174-L212 |
39,528 | stxnext/mappet | mappet/helpers.py | dict_to_etree | def dict_to_etree(d, root):
u"""Converts a dict to lxml.etree object.
>>> dict_to_etree({'root': {'#text': 'node_text', '@attr': 'val'}}, etree.Element('root')) # doctest: +ELLIPSIS
<Element root at 0x...>
:param dict d: dict representing the XML tree
:param etree.Element root: XML node which will... | python | def dict_to_etree(d, root):
u"""Converts a dict to lxml.etree object.
>>> dict_to_etree({'root': {'#text': 'node_text', '@attr': 'val'}}, etree.Element('root')) # doctest: +ELLIPSIS
<Element root at 0x...>
:param dict d: dict representing the XML tree
:param etree.Element root: XML node which will... | [
"def",
"dict_to_etree",
"(",
"d",
",",
"root",
")",
":",
"def",
"_to_etree",
"(",
"d",
",",
"node",
")",
":",
"if",
"d",
"is",
"None",
"or",
"len",
"(",
"d",
")",
"==",
"0",
":",
"return",
"elif",
"isinstance",
"(",
"d",
",",
"basestring",
")",
... | u"""Converts a dict to lxml.etree object.
>>> dict_to_etree({'root': {'#text': 'node_text', '@attr': 'val'}}, etree.Element('root')) # doctest: +ELLIPSIS
<Element root at 0x...>
:param dict d: dict representing the XML tree
:param etree.Element root: XML node which will be assigned the resulting tree
... | [
"u",
"Converts",
"a",
"dict",
"to",
"lxml",
".",
"etree",
"object",
"."
] | ac7468ac28ed82e45065b1e348cf865c8f73f0db | https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/helpers.py#L215-L275 |
39,529 | nuSTORM/gnomon | gnomon/JsonToROOT.py | JsonToROOTConverter.objwalk | def objwalk(self, obj, path=(), memo=None):
"""Traverse a dictionary recursively and save path
Taken from:
http://code.activestate.com/recipes/577982-recursively-walk-python-objects/
"""
# dual python 2/3 compatability, inspired by the "six" library
string_types = (str, unicode) if s... | python | def objwalk(self, obj, path=(), memo=None):
"""Traverse a dictionary recursively and save path
Taken from:
http://code.activestate.com/recipes/577982-recursively-walk-python-objects/
"""
# dual python 2/3 compatability, inspired by the "six" library
string_types = (str, unicode) if s... | [
"def",
"objwalk",
"(",
"self",
",",
"obj",
",",
"path",
"=",
"(",
")",
",",
"memo",
"=",
"None",
")",
":",
"# dual python 2/3 compatability, inspired by the \"six\" library",
"string_types",
"=",
"(",
"str",
",",
"unicode",
")",
"if",
"str",
"is",
"bytes",
"... | Traverse a dictionary recursively and save path
Taken from:
http://code.activestate.com/recipes/577982-recursively-walk-python-objects/ | [
"Traverse",
"a",
"dictionary",
"recursively",
"and",
"save",
"path"
] | 7616486ecd6e26b76f677c380e62db1c0ade558a | https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/JsonToROOT.py#L149-L175 |
39,530 | hackedd/gw2api | gw2api/__init__.py | set_cache_dir | def set_cache_dir(directory):
"""Set the directory to cache JSON responses from most API endpoints.
"""
global cache_dir
if directory is None:
cache_dir = None
return
if not os.path.exists(directory):
os.makedirs(directory)
if not os.path.isdir(directory):
raise... | python | def set_cache_dir(directory):
"""Set the directory to cache JSON responses from most API endpoints.
"""
global cache_dir
if directory is None:
cache_dir = None
return
if not os.path.exists(directory):
os.makedirs(directory)
if not os.path.isdir(directory):
raise... | [
"def",
"set_cache_dir",
"(",
"directory",
")",
":",
"global",
"cache_dir",
"if",
"directory",
"is",
"None",
":",
"cache_dir",
"=",
"None",
"return",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"directory",
")",
":",
"os",
".",
"makedirs",
"(",
... | Set the directory to cache JSON responses from most API endpoints. | [
"Set",
"the",
"directory",
"to",
"cache",
"JSON",
"responses",
"from",
"most",
"API",
"endpoints",
"."
] | 5543a78e6e3ed0573b7e84c142c44004b4779eac | https://github.com/hackedd/gw2api/blob/5543a78e6e3ed0573b7e84c142c44004b4779eac/gw2api/__init__.py#L38-L51 |
39,531 | consbio/parserutils | parserutils/elements.py | element_is_empty | def element_is_empty(elem_to_parse, element_path=None):
"""
Returns true if the element is None, or has no text, tail, children or attributes.
Whitespace in the element is stripped from text and tail before making the determination.
"""
element = get_element(elem_to_parse, element_path)
if ele... | python | def element_is_empty(elem_to_parse, element_path=None):
"""
Returns true if the element is None, or has no text, tail, children or attributes.
Whitespace in the element is stripped from text and tail before making the determination.
"""
element = get_element(elem_to_parse, element_path)
if ele... | [
"def",
"element_is_empty",
"(",
"elem_to_parse",
",",
"element_path",
"=",
"None",
")",
":",
"element",
"=",
"get_element",
"(",
"elem_to_parse",
",",
"element_path",
")",
"if",
"element",
"is",
"None",
":",
"return",
"True",
"is_empty",
"=",
"(",
"(",
"elem... | Returns true if the element is None, or has no text, tail, children or attributes.
Whitespace in the element is stripped from text and tail before making the determination. | [
"Returns",
"true",
"if",
"the",
"element",
"is",
"None",
"or",
"has",
"no",
"text",
"tail",
"children",
"or",
"attributes",
".",
"Whitespace",
"in",
"the",
"element",
"is",
"stripped",
"from",
"text",
"and",
"tail",
"before",
"making",
"the",
"determination"... | f13f80db99ed43479336b116e38512e3566e4623 | https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/elements.py#L250-L268 |
39,532 | consbio/parserutils | parserutils/elements.py | insert_element | def insert_element(elem_to_parse, elem_idx, elem_path, elem_txt=u'', **attrib_kwargs):
"""
Creates an element named after elem_path, containing elem_txt, with kwargs
as attributes, inserts it into elem_to_parse at elem_idx and returns it.
If elem_path is an XPATH pointing to a non-existent element, ele... | python | def insert_element(elem_to_parse, elem_idx, elem_path, elem_txt=u'', **attrib_kwargs):
"""
Creates an element named after elem_path, containing elem_txt, with kwargs
as attributes, inserts it into elem_to_parse at elem_idx and returns it.
If elem_path is an XPATH pointing to a non-existent element, ele... | [
"def",
"insert_element",
"(",
"elem_to_parse",
",",
"elem_idx",
",",
"elem_path",
",",
"elem_txt",
"=",
"u''",
",",
"*",
"*",
"attrib_kwargs",
")",
":",
"element",
"=",
"get_element",
"(",
"elem_to_parse",
")",
"if",
"element",
"is",
"None",
"or",
"not",
"... | Creates an element named after elem_path, containing elem_txt, with kwargs
as attributes, inserts it into elem_to_parse at elem_idx and returns it.
If elem_path is an XPATH pointing to a non-existent element, elements not
in the path are inserted and the text and index are applied to the last one.
If ... | [
"Creates",
"an",
"element",
"named",
"after",
"elem_path",
"containing",
"elem_txt",
"with",
"kwargs",
"as",
"attributes",
"inserts",
"it",
"into",
"elem_to_parse",
"at",
"elem_idx",
"and",
"returns",
"it",
"."
] | f13f80db99ed43479336b116e38512e3566e4623 | https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/elements.py#L271-L328 |
39,533 | consbio/parserutils | parserutils/elements.py | remove_empty_element | def remove_empty_element(parent_to_parse, element_path, target_element=None):
"""
Searches for all empty sub-elements named after element_name in the parsed element,
and if it exists, removes them all and returns them as a list.
"""
element = get_element(parent_to_parse)
removed = []
if el... | python | def remove_empty_element(parent_to_parse, element_path, target_element=None):
"""
Searches for all empty sub-elements named after element_name in the parsed element,
and if it exists, removes them all and returns them as a list.
"""
element = get_element(parent_to_parse)
removed = []
if el... | [
"def",
"remove_empty_element",
"(",
"parent_to_parse",
",",
"element_path",
",",
"target_element",
"=",
"None",
")",
":",
"element",
"=",
"get_element",
"(",
"parent_to_parse",
")",
"removed",
"=",
"[",
"]",
"if",
"element",
"is",
"None",
"or",
"not",
"element... | Searches for all empty sub-elements named after element_name in the parsed element,
and if it exists, removes them all and returns them as a list. | [
"Searches",
"for",
"all",
"empty",
"sub",
"-",
"elements",
"named",
"after",
"element_name",
"in",
"the",
"parsed",
"element",
"and",
"if",
"it",
"exists",
"removes",
"them",
"all",
"and",
"returns",
"them",
"as",
"a",
"list",
"."
] | f13f80db99ed43479336b116e38512e3566e4623 | https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/elements.py#L390-L439 |
39,534 | consbio/parserutils | parserutils/elements.py | remove_element_attributes | def remove_element_attributes(elem_to_parse, *args):
"""
Removes the specified keys from the element's attributes, and
returns a dict containing the attributes that have been removed.
"""
element = get_element(elem_to_parse)
if element is None:
return element
if len(args):
... | python | def remove_element_attributes(elem_to_parse, *args):
"""
Removes the specified keys from the element's attributes, and
returns a dict containing the attributes that have been removed.
"""
element = get_element(elem_to_parse)
if element is None:
return element
if len(args):
... | [
"def",
"remove_element_attributes",
"(",
"elem_to_parse",
",",
"*",
"args",
")",
":",
"element",
"=",
"get_element",
"(",
"elem_to_parse",
")",
"if",
"element",
"is",
"None",
":",
"return",
"element",
"if",
"len",
"(",
"args",
")",
":",
"attribs",
"=",
"el... | Removes the specified keys from the element's attributes, and
returns a dict containing the attributes that have been removed. | [
"Removes",
"the",
"specified",
"keys",
"from",
"the",
"element",
"s",
"attributes",
"and",
"returns",
"a",
"dict",
"containing",
"the",
"attributes",
"that",
"have",
"been",
"removed",
"."
] | f13f80db99ed43479336b116e38512e3566e4623 | https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/elements.py#L500-L515 |
39,535 | consbio/parserutils | parserutils/elements.py | _get_elements_property | def _get_elements_property(parent_to_parse, element_path, prop_name):
""" A helper to construct a list of values from """
parent_element = get_element(parent_to_parse)
if parent_element is None:
return []
if element_path and not element_exists(parent_element, element_path):
return []
... | python | def _get_elements_property(parent_to_parse, element_path, prop_name):
""" A helper to construct a list of values from """
parent_element = get_element(parent_to_parse)
if parent_element is None:
return []
if element_path and not element_exists(parent_element, element_path):
return []
... | [
"def",
"_get_elements_property",
"(",
"parent_to_parse",
",",
"element_path",
",",
"prop_name",
")",
":",
"parent_element",
"=",
"get_element",
"(",
"parent_to_parse",
")",
"if",
"parent_element",
"is",
"None",
":",
"return",
"[",
"]",
"if",
"element_path",
"and",... | A helper to construct a list of values from | [
"A",
"helper",
"to",
"construct",
"a",
"list",
"of",
"values",
"from"
] | f13f80db99ed43479336b116e38512e3566e4623 | https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/elements.py#L595-L616 |
39,536 | consbio/parserutils | parserutils/elements.py | _set_element_property | def _set_element_property(parent_to_parse, element_path, prop_name, value):
""" Assigns the value to the parsed parent element and then returns it """
element = get_element(parent_to_parse)
if element is None:
return None
if element_path and not element_exists(element, element_path):
... | python | def _set_element_property(parent_to_parse, element_path, prop_name, value):
""" Assigns the value to the parsed parent element and then returns it """
element = get_element(parent_to_parse)
if element is None:
return None
if element_path and not element_exists(element, element_path):
... | [
"def",
"_set_element_property",
"(",
"parent_to_parse",
",",
"element_path",
",",
"prop_name",
",",
"value",
")",
":",
"element",
"=",
"get_element",
"(",
"parent_to_parse",
")",
"if",
"element",
"is",
"None",
":",
"return",
"None",
"if",
"element_path",
"and",
... | Assigns the value to the parsed parent element and then returns it | [
"Assigns",
"the",
"value",
"to",
"the",
"parsed",
"parent",
"element",
"and",
"then",
"returns",
"it"
] | f13f80db99ed43479336b116e38512e3566e4623 | https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/elements.py#L639-L655 |
39,537 | consbio/parserutils | parserutils/elements.py | set_elements_tail | def set_elements_tail(parent_to_parse, element_path=None, tail_values=None):
"""
Assigns an array of tail values to each of the elements parsed from the parent. The
tail values are assigned in the same order they are provided.
If there are less values then elements, the remaining elements are skipped; b... | python | def set_elements_tail(parent_to_parse, element_path=None, tail_values=None):
"""
Assigns an array of tail values to each of the elements parsed from the parent. The
tail values are assigned in the same order they are provided.
If there are less values then elements, the remaining elements are skipped; b... | [
"def",
"set_elements_tail",
"(",
"parent_to_parse",
",",
"element_path",
"=",
"None",
",",
"tail_values",
"=",
"None",
")",
":",
"if",
"tail_values",
"is",
"None",
":",
"tail_values",
"=",
"[",
"]",
"return",
"_set_elements_property",
"(",
"parent_to_parse",
","... | Assigns an array of tail values to each of the elements parsed from the parent. The
tail values are assigned in the same order they are provided.
If there are less values then elements, the remaining elements are skipped; but if
there are more, new elements will be inserted for each with the remaining tail ... | [
"Assigns",
"an",
"array",
"of",
"tail",
"values",
"to",
"each",
"of",
"the",
"elements",
"parsed",
"from",
"the",
"parent",
".",
"The",
"tail",
"values",
"are",
"assigned",
"in",
"the",
"same",
"order",
"they",
"are",
"provided",
".",
"If",
"there",
"are... | f13f80db99ed43479336b116e38512e3566e4623 | https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/elements.py#L658-L669 |
39,538 | consbio/parserutils | parserutils/elements.py | set_elements_text | def set_elements_text(parent_to_parse, element_path=None, text_values=None):
"""
Assigns an array of text values to each of the elements parsed from the parent. The
text values are assigned in the same order they are provided.
If there are less values then elements, the remaining elements are skipped; b... | python | def set_elements_text(parent_to_parse, element_path=None, text_values=None):
"""
Assigns an array of text values to each of the elements parsed from the parent. The
text values are assigned in the same order they are provided.
If there are less values then elements, the remaining elements are skipped; b... | [
"def",
"set_elements_text",
"(",
"parent_to_parse",
",",
"element_path",
"=",
"None",
",",
"text_values",
"=",
"None",
")",
":",
"if",
"text_values",
"is",
"None",
":",
"text_values",
"=",
"[",
"]",
"return",
"_set_elements_property",
"(",
"parent_to_parse",
","... | Assigns an array of text values to each of the elements parsed from the parent. The
text values are assigned in the same order they are provided.
If there are less values then elements, the remaining elements are skipped; but if
there are more, new elements will be inserted for each with the remaining text ... | [
"Assigns",
"an",
"array",
"of",
"text",
"values",
"to",
"each",
"of",
"the",
"elements",
"parsed",
"from",
"the",
"parent",
".",
"The",
"text",
"values",
"are",
"assigned",
"in",
"the",
"same",
"order",
"they",
"are",
"provided",
".",
"If",
"there",
"are... | f13f80db99ed43479336b116e38512e3566e4623 | https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/elements.py#L672-L683 |
39,539 | consbio/parserutils | parserutils/elements.py | strip_namespaces | def strip_namespaces(file_or_xml):
"""
Removes all namespaces from the XML file or string passed in.
If file_or_xml is not a file or string, it is returned as is.
"""
xml_content = _xml_content_to_string(file_or_xml)
if not isinstance(xml_content, string_types):
return xml_content
... | python | def strip_namespaces(file_or_xml):
"""
Removes all namespaces from the XML file or string passed in.
If file_or_xml is not a file or string, it is returned as is.
"""
xml_content = _xml_content_to_string(file_or_xml)
if not isinstance(xml_content, string_types):
return xml_content
... | [
"def",
"strip_namespaces",
"(",
"file_or_xml",
")",
":",
"xml_content",
"=",
"_xml_content_to_string",
"(",
"file_or_xml",
")",
"if",
"not",
"isinstance",
"(",
"xml_content",
",",
"string_types",
")",
":",
"return",
"xml_content",
"# This pattern can have overlapping ma... | Removes all namespaces from the XML file or string passed in.
If file_or_xml is not a file or string, it is returned as is. | [
"Removes",
"all",
"namespaces",
"from",
"the",
"XML",
"file",
"or",
"string",
"passed",
"in",
".",
"If",
"file_or_xml",
"is",
"not",
"a",
"file",
"or",
"string",
"it",
"is",
"returned",
"as",
"is",
"."
] | f13f80db99ed43479336b116e38512e3566e4623 | https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/elements.py#L958-L978 |
39,540 | consbio/parserutils | parserutils/elements.py | strip_xml_declaration | def strip_xml_declaration(file_or_xml):
"""
Removes XML declaration line from file or string passed in.
If file_or_xml is not a file or string, it is returned as is.
"""
xml_content = _xml_content_to_string(file_or_xml)
if not isinstance(xml_content, string_types):
return xml_content
... | python | def strip_xml_declaration(file_or_xml):
"""
Removes XML declaration line from file or string passed in.
If file_or_xml is not a file or string, it is returned as is.
"""
xml_content = _xml_content_to_string(file_or_xml)
if not isinstance(xml_content, string_types):
return xml_content
... | [
"def",
"strip_xml_declaration",
"(",
"file_or_xml",
")",
":",
"xml_content",
"=",
"_xml_content_to_string",
"(",
"file_or_xml",
")",
"if",
"not",
"isinstance",
"(",
"xml_content",
",",
"string_types",
")",
":",
"return",
"xml_content",
"# For Python 2 compliance: replac... | Removes XML declaration line from file or string passed in.
If file_or_xml is not a file or string, it is returned as is. | [
"Removes",
"XML",
"declaration",
"line",
"from",
"file",
"or",
"string",
"passed",
"in",
".",
"If",
"file_or_xml",
"is",
"not",
"a",
"file",
"or",
"string",
"it",
"is",
"returned",
"as",
"is",
"."
] | f13f80db99ed43479336b116e38512e3566e4623 | https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/elements.py#L981-L992 |
39,541 | hayalasalah/adhan.py | adhan/adhan.py | floating_point_to_datetime | def floating_point_to_datetime(day, fp_time):
"""Convert a floating point time to a datetime."""
result = datetime(year=day.year, month=day.month, day=day.day)
result += timedelta(minutes=math.ceil(60 * fp_time))
return result | python | def floating_point_to_datetime(day, fp_time):
"""Convert a floating point time to a datetime."""
result = datetime(year=day.year, month=day.month, day=day.day)
result += timedelta(minutes=math.ceil(60 * fp_time))
return result | [
"def",
"floating_point_to_datetime",
"(",
"day",
",",
"fp_time",
")",
":",
"result",
"=",
"datetime",
"(",
"year",
"=",
"day",
".",
"year",
",",
"month",
"=",
"day",
".",
"month",
",",
"day",
"=",
"day",
".",
"day",
")",
"result",
"+=",
"timedelta",
... | Convert a floating point time to a datetime. | [
"Convert",
"a",
"floating",
"point",
"time",
"to",
"a",
"datetime",
"."
] | a7c080ba48f70be9801f048451d2c91a7d579602 | https://github.com/hayalasalah/adhan.py/blob/a7c080ba48f70be9801f048451d2c91a7d579602/adhan/adhan.py#L39-L43 |
39,542 | hayalasalah/adhan.py | adhan/adhan.py | adhan | def adhan(day, location, parameters, timezone_offset=0):
"""Calculate adhan times given the parameters.
This function will compute the adhan times for a certain location on
certain day. The method for calculating the prayers as well as the time for
Asr can also be specified. The timezone offset naively... | python | def adhan(day, location, parameters, timezone_offset=0):
"""Calculate adhan times given the parameters.
This function will compute the adhan times for a certain location on
certain day. The method for calculating the prayers as well as the time for
Asr can also be specified. The timezone offset naively... | [
"def",
"adhan",
"(",
"day",
",",
"location",
",",
"parameters",
",",
"timezone_offset",
"=",
"0",
")",
":",
"latitude",
",",
"longitude",
"=",
"location",
"#",
"# To reduce a little repetitiveness, using a partial function that has the",
"# day and latitude already set",
... | Calculate adhan times given the parameters.
This function will compute the adhan times for a certain location on
certain day. The method for calculating the prayers as well as the time for
Asr can also be specified. The timezone offset naively adds the specified
number of hours to each time that is ret... | [
"Calculate",
"adhan",
"times",
"given",
"the",
"parameters",
"."
] | a7c080ba48f70be9801f048451d2c91a7d579602 | https://github.com/hayalasalah/adhan.py/blob/a7c080ba48f70be9801f048451d2c91a7d579602/adhan/adhan.py#L46-L112 |
39,543 | trevisanj/a99 | a99/gui/a_WEditor.py | WEditor._make_fn_text | def _make_fn_text(self):
"""Makes filename text"""
if not self._f:
text = "(not loaded)"
elif self._f.filename:
text = os.path.relpath(self._f.filename, ".")
else:
text = "(filename not set)"
return text | python | def _make_fn_text(self):
"""Makes filename text"""
if not self._f:
text = "(not loaded)"
elif self._f.filename:
text = os.path.relpath(self._f.filename, ".")
else:
text = "(filename not set)"
return text | [
"def",
"_make_fn_text",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_f",
":",
"text",
"=",
"\"(not loaded)\"",
"elif",
"self",
".",
"_f",
".",
"filename",
":",
"text",
"=",
"os",
".",
"path",
".",
"relpath",
"(",
"self",
".",
"_f",
".",
"file... | Makes filename text | [
"Makes",
"filename",
"text"
] | 193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539 | https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/a_WEditor.py#L91-L99 |
39,544 | trevisanj/a99 | a99/matplotlibaux.py | format_BLB | def format_BLB():
"""Sets some formatting options in Matplotlib."""
rc("figure", facecolor="white")
rc('font', family = 'serif', size=10) #, serif = 'cmr10')
rc('xtick', labelsize=10)
rc('ytick', labelsize=10)
rc('axes', linewidth=1)
rc('xtick.major', size=4, width=1)
rc('xtick.m... | python | def format_BLB():
"""Sets some formatting options in Matplotlib."""
rc("figure", facecolor="white")
rc('font', family = 'serif', size=10) #, serif = 'cmr10')
rc('xtick', labelsize=10)
rc('ytick', labelsize=10)
rc('axes', linewidth=1)
rc('xtick.major', size=4, width=1)
rc('xtick.m... | [
"def",
"format_BLB",
"(",
")",
":",
"rc",
"(",
"\"figure\"",
",",
"facecolor",
"=",
"\"white\"",
")",
"rc",
"(",
"'font'",
",",
"family",
"=",
"'serif'",
",",
"size",
"=",
"10",
")",
"#, serif = 'cmr10')\r",
"rc",
"(",
"'xtick'",
",",
"labelsize",
"=",
... | Sets some formatting options in Matplotlib. | [
"Sets",
"some",
"formatting",
"options",
"in",
"Matplotlib",
"."
] | 193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539 | https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/matplotlibaux.py#L16-L26 |
39,545 | wuher/devil | devil/fields/representation.py | get_declared_fields | def get_declared_fields(bases, attrs):
""" Find all fields and return them as a dictionary.
note:: this function is copied and modified
from django.forms.get_declared_fields
"""
def is_field(prop):
return isinstance(prop, forms.Field) or \
isinstance(prop, BaseRepresentatio... | python | def get_declared_fields(bases, attrs):
""" Find all fields and return them as a dictionary.
note:: this function is copied and modified
from django.forms.get_declared_fields
"""
def is_field(prop):
return isinstance(prop, forms.Field) or \
isinstance(prop, BaseRepresentatio... | [
"def",
"get_declared_fields",
"(",
"bases",
",",
"attrs",
")",
":",
"def",
"is_field",
"(",
"prop",
")",
":",
"return",
"isinstance",
"(",
"prop",
",",
"forms",
".",
"Field",
")",
"or",
"isinstance",
"(",
"prop",
",",
"BaseRepresentation",
")",
"fields",
... | Find all fields and return them as a dictionary.
note:: this function is copied and modified
from django.forms.get_declared_fields | [
"Find",
"all",
"fields",
"and",
"return",
"them",
"as",
"a",
"dictionary",
"."
] | a8834d4f88d915a21754c6b96f99d0ad9123ad4d | https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/fields/representation.py#L76-L92 |
39,546 | wuher/devil | devil/fields/representation.py | BaseRepresentation.validate | def validate(self, data=None):
""" Validate the data
Check also that no extra properties are present.
:raises: ValidationError if the data is not valid.
"""
errors = {}
data = self._getData(data)
# validate each field, one by one
for name, field in se... | python | def validate(self, data=None):
""" Validate the data
Check also that no extra properties are present.
:raises: ValidationError if the data is not valid.
"""
errors = {}
data = self._getData(data)
# validate each field, one by one
for name, field in se... | [
"def",
"validate",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"data",
"=",
"self",
".",
"_getData",
"(",
"data",
")",
"# validate each field, one by one",
"for",
"name",
",",
"field",
"in",
"self",
".",
"fields",
".",
"it... | Validate the data
Check also that no extra properties are present.
:raises: ValidationError if the data is not valid. | [
"Validate",
"the",
"data"
] | a8834d4f88d915a21754c6b96f99d0ad9123ad4d | https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/fields/representation.py#L29-L57 |
39,547 | wuher/devil | devil/fields/representation.py | BaseRepresentation._getData | def _getData(self, data):
""" Check that data is acceptable and return it.
Default behavior is that the data has to be of type `dict`. In derived
classes this method could for example allow `None` or empty strings and
just return empty dictionary.
:raises: ``ValidationError`` i... | python | def _getData(self, data):
""" Check that data is acceptable and return it.
Default behavior is that the data has to be of type `dict`. In derived
classes this method could for example allow `None` or empty strings and
just return empty dictionary.
:raises: ``ValidationError`` i... | [
"def",
"_getData",
"(",
"self",
",",
"data",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"raise",
"ValidationError",
"(",
"'data is not a valid dictionary: %s'",
"%",
"(",
"str",
"(",
"type",
"(",
"data",
")",
")",
",",
")",
... | Check that data is acceptable and return it.
Default behavior is that the data has to be of type `dict`. In derived
classes this method could for example allow `None` or empty strings and
just return empty dictionary.
:raises: ``ValidationError`` if data is missing or wrong type
... | [
"Check",
"that",
"data",
"is",
"acceptable",
"and",
"return",
"it",
"."
] | a8834d4f88d915a21754c6b96f99d0ad9123ad4d | https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/fields/representation.py#L59-L73 |
39,548 | wdbm/megaparsex | megaparsex_example_1.py | main | def main():
"""
Loop over a list of input text strings. Parse each string using a list of
parsers, one included in megaparsex and one defined in this script. If a
confirmation is requested, seek confirmation, otherwise display any response
text and engage any triggered functions.
"""
for tex... | python | def main():
"""
Loop over a list of input text strings. Parse each string using a list of
parsers, one included in megaparsex and one defined in this script. If a
confirmation is requested, seek confirmation, otherwise display any response
text and engage any triggered functions.
"""
for tex... | [
"def",
"main",
"(",
")",
":",
"for",
"text",
"in",
"[",
"\"how are you\"",
",",
"\"ip address\"",
",",
"\"restart\"",
",",
"\"run command\"",
",",
"\"rain EGPF\"",
",",
"\"reverse SSH\"",
"]",
":",
"print",
"(",
"\"\\nparse text: \"",
"+",
"text",
"+",
"\"\\nW... | Loop over a list of input text strings. Parse each string using a list of
parsers, one included in megaparsex and one defined in this script. If a
confirmation is requested, seek confirmation, otherwise display any response
text and engage any triggered functions. | [
"Loop",
"over",
"a",
"list",
"of",
"input",
"text",
"strings",
".",
"Parse",
"each",
"string",
"using",
"a",
"list",
"of",
"parsers",
"one",
"included",
"in",
"megaparsex",
"and",
"one",
"defined",
"in",
"this",
"script",
".",
"If",
"a",
"confirmation",
... | 59da05410aa1cf8682dcee2bf0bd0572fa42bd29 | https://github.com/wdbm/megaparsex/blob/59da05410aa1cf8682dcee2bf0bd0572fa42bd29/megaparsex_example_1.py#L44-L92 |
39,549 | mixer/beam-interactive-python | beam_interactive/proto/identifier.py | _Identifier.get_packet_id | def get_packet_id(self, packet):
"""
Returns the ID of a protocol buffer packet. Returns None
if no ID was found.
"""
for p in self._packets:
if isinstance(packet, p['cls']):
return p['id']
return None | python | def get_packet_id(self, packet):
"""
Returns the ID of a protocol buffer packet. Returns None
if no ID was found.
"""
for p in self._packets:
if isinstance(packet, p['cls']):
return p['id']
return None | [
"def",
"get_packet_id",
"(",
"self",
",",
"packet",
")",
":",
"for",
"p",
"in",
"self",
".",
"_packets",
":",
"if",
"isinstance",
"(",
"packet",
",",
"p",
"[",
"'cls'",
"]",
")",
":",
"return",
"p",
"[",
"'id'",
"]",
"return",
"None"
] | Returns the ID of a protocol buffer packet. Returns None
if no ID was found. | [
"Returns",
"the",
"ID",
"of",
"a",
"protocol",
"buffer",
"packet",
".",
"Returns",
"None",
"if",
"no",
"ID",
"was",
"found",
"."
] | e035bc45515dea9315b77648a24b5ae8685aa5cf | https://github.com/mixer/beam-interactive-python/blob/e035bc45515dea9315b77648a24b5ae8685aa5cf/beam_interactive/proto/identifier.py#L23-L33 |
39,550 | klen/starter | starter/main.py | main | def main(*args):
""" Enter point. """
args = args or sys.argv[1:]
params = PARSER.parse_args(args)
from .log import setup_logging
setup_logging(params.level.upper())
from .core import Starter
starter = Starter(params)
if not starter.params.TEMPLATES or starter.params.list:
set... | python | def main(*args):
""" Enter point. """
args = args or sys.argv[1:]
params = PARSER.parse_args(args)
from .log import setup_logging
setup_logging(params.level.upper())
from .core import Starter
starter = Starter(params)
if not starter.params.TEMPLATES or starter.params.list:
set... | [
"def",
"main",
"(",
"*",
"args",
")",
":",
"args",
"=",
"args",
"or",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"params",
"=",
"PARSER",
".",
"parse_args",
"(",
"args",
")",
"from",
".",
"log",
"import",
"setup_logging",
"setup_logging",
"(",
"params",... | Enter point. | [
"Enter",
"point",
"."
] | 24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f | https://github.com/klen/starter/blob/24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f/starter/main.py#L50-L73 |
39,551 | a2liu/mr-clean | mr_clean/core/tools/summarize.py | summarize | def summarize(df,preview_rows = 8,
display_max_cols = None,display_width = None,
output_path = None, output_safe = True,to_folder = False):
""" Prints information about the DataFrame to a file or to the prompt.
Parameters
----------
df - DataFrame
The DataFrame to summa... | python | def summarize(df,preview_rows = 8,
display_max_cols = None,display_width = None,
output_path = None, output_safe = True,to_folder = False):
""" Prints information about the DataFrame to a file or to the prompt.
Parameters
----------
df - DataFrame
The DataFrame to summa... | [
"def",
"summarize",
"(",
"df",
",",
"preview_rows",
"=",
"8",
",",
"display_max_cols",
"=",
"None",
",",
"display_width",
"=",
"None",
",",
"output_path",
"=",
"None",
",",
"output_safe",
"=",
"True",
",",
"to_folder",
"=",
"False",
")",
":",
"assert",
"... | Prints information about the DataFrame to a file or to the prompt.
Parameters
----------
df - DataFrame
The DataFrame to summarize
preview_rows - int, default 5
Amount of rows to preview from the head and tail of the DataFrame
display_max_cols - int, default None
Maximum amo... | [
"Prints",
"information",
"about",
"the",
"DataFrame",
"to",
"a",
"file",
"or",
"to",
"the",
"prompt",
"."
] | 0ee4ee5639f834dec4b59b94442fa84373f3c176 | https://github.com/a2liu/mr-clean/blob/0ee4ee5639f834dec4b59b94442fa84373f3c176/mr_clean/core/tools/summarize.py#L13-L103 |
39,552 | CodyKochmann/generators | generators/timed_pipe.py | timed_pipe | def timed_pipe(generator, seconds=3):
''' This is a time limited pipeline. If you have a infinite pipeline and
want it to stop yielding after a certain amount of time, use this! '''
# grab the highest precision timer
# when it started
start = ts()
# when it will stop
end = start + second... | python | def timed_pipe(generator, seconds=3):
''' This is a time limited pipeline. If you have a infinite pipeline and
want it to stop yielding after a certain amount of time, use this! '''
# grab the highest precision timer
# when it started
start = ts()
# when it will stop
end = start + second... | [
"def",
"timed_pipe",
"(",
"generator",
",",
"seconds",
"=",
"3",
")",
":",
"# grab the highest precision timer",
"# when it started",
"start",
"=",
"ts",
"(",
")",
"# when it will stop",
"end",
"=",
"start",
"+",
"seconds",
"# iterate over the pipeline",
"for",
"i",... | This is a time limited pipeline. If you have a infinite pipeline and
want it to stop yielding after a certain amount of time, use this! | [
"This",
"is",
"a",
"time",
"limited",
"pipeline",
".",
"If",
"you",
"have",
"a",
"infinite",
"pipeline",
"and",
"want",
"it",
"to",
"stop",
"yielding",
"after",
"a",
"certain",
"amount",
"of",
"time",
"use",
"this!"
] | e4ca4dd25d5023a94b0349c69d6224070cc2526f | https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/timed_pipe.py#L11-L28 |
39,553 | Titan-C/slaveparticles | slaveparticles/quantum/fermion.py | destruct | def destruct(particles, index):
"""Fermion annihilation operator in matrix representation for a indexed
particle in a bounded N-particles fermion fock space"""
mat = np.zeros((2**particles, 2**particles))
flipper = 2**index
for i in range(2**particles):
ispin = btest(i, index)
i... | python | def destruct(particles, index):
"""Fermion annihilation operator in matrix representation for a indexed
particle in a bounded N-particles fermion fock space"""
mat = np.zeros((2**particles, 2**particles))
flipper = 2**index
for i in range(2**particles):
ispin = btest(i, index)
i... | [
"def",
"destruct",
"(",
"particles",
",",
"index",
")",
":",
"mat",
"=",
"np",
".",
"zeros",
"(",
"(",
"2",
"**",
"particles",
",",
"2",
"**",
"particles",
")",
")",
"flipper",
"=",
"2",
"**",
"index",
"for",
"i",
"in",
"range",
"(",
"2",
"**",
... | Fermion annihilation operator in matrix representation for a indexed
particle in a bounded N-particles fermion fock space | [
"Fermion",
"annihilation",
"operator",
"in",
"matrix",
"representation",
"for",
"a",
"indexed",
"particle",
"in",
"a",
"bounded",
"N",
"-",
"particles",
"fermion",
"fock",
"space"
] | e4c2f5afb1a7b195517ef2f1b5cc758965036aab | https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/fermion.py#L23-L34 |
39,554 | inveniosoftware-attic/invenio-utils | invenio_utils/json.py | json_unicode_to_utf8 | def json_unicode_to_utf8(data):
"""Change all strings in a JSON structure to UTF-8."""
if isinstance(data, unicode):
return data.encode('utf-8')
elif isinstance(data, dict):
newdict = {}
for key in data:
newdict[json_unicode_to_utf8(
key)] = json_unicode_t... | python | def json_unicode_to_utf8(data):
"""Change all strings in a JSON structure to UTF-8."""
if isinstance(data, unicode):
return data.encode('utf-8')
elif isinstance(data, dict):
newdict = {}
for key in data:
newdict[json_unicode_to_utf8(
key)] = json_unicode_t... | [
"def",
"json_unicode_to_utf8",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"unicode",
")",
":",
"return",
"data",
".",
"encode",
"(",
"'utf-8'",
")",
"elif",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"newdict",
"=",
"{",
"}",
... | Change all strings in a JSON structure to UTF-8. | [
"Change",
"all",
"strings",
"in",
"a",
"JSON",
"structure",
"to",
"UTF",
"-",
"8",
"."
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/json.py#L32-L45 |
39,555 | inveniosoftware-attic/invenio-utils | invenio_utils/json.py | json_decode_file | def json_decode_file(filename):
"""
Parses a textfile using json to build a python object representation
"""
seq = open(filename).read()
# The JSON standard has no comments syntax. We have to remove them
# before feeding python's JSON parser
seq = json_remove_comments(seq)
# Parse all th... | python | def json_decode_file(filename):
"""
Parses a textfile using json to build a python object representation
"""
seq = open(filename).read()
# The JSON standard has no comments syntax. We have to remove them
# before feeding python's JSON parser
seq = json_remove_comments(seq)
# Parse all th... | [
"def",
"json_decode_file",
"(",
"filename",
")",
":",
"seq",
"=",
"open",
"(",
"filename",
")",
".",
"read",
"(",
")",
"# The JSON standard has no comments syntax. We have to remove them",
"# before feeding python's JSON parser",
"seq",
"=",
"json_remove_comments",
"(",
"... | Parses a textfile using json to build a python object representation | [
"Parses",
"a",
"textfile",
"using",
"json",
"to",
"build",
"a",
"python",
"object",
"representation"
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/json.py#L48-L57 |
39,556 | cdumay/kser | src/kser/entry.py | Entrypoint._post_init | def _post_init(self):
"""A post init trigger"""
try:
return self.postinit()
except Exception as exc:
return self._onerror(Result.from_exception(exc, uuid=self.uuid)) | python | def _post_init(self):
"""A post init trigger"""
try:
return self.postinit()
except Exception as exc:
return self._onerror(Result.from_exception(exc, uuid=self.uuid)) | [
"def",
"_post_init",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"postinit",
"(",
")",
"except",
"Exception",
"as",
"exc",
":",
"return",
"self",
".",
"_onerror",
"(",
"Result",
".",
"from_exception",
"(",
"exc",
",",
"uuid",
"=",
"self",... | A post init trigger | [
"A",
"post",
"init",
"trigger"
] | fbd6fe9ab34b8b89d9937e5ff727614304af48c1 | https://github.com/cdumay/kser/blob/fbd6fe9ab34b8b89d9937e5ff727614304af48c1/src/kser/entry.py#L43-L48 |
39,557 | cdumay/kser | src/kser/entry.py | Entrypoint._postrun | def _postrun(self, result):
""" To execute after exection
:param kser.result.Result result: Execution result
:return: Execution result
:rtype: kser.result.Result
"""
logger.debug(
"{}.PostRun: {}[{}]".format(
self.__class__.__name__, self.__cl... | python | def _postrun(self, result):
""" To execute after exection
:param kser.result.Result result: Execution result
:return: Execution result
:rtype: kser.result.Result
"""
logger.debug(
"{}.PostRun: {}[{}]".format(
self.__class__.__name__, self.__cl... | [
"def",
"_postrun",
"(",
"self",
",",
"result",
")",
":",
"logger",
".",
"debug",
"(",
"\"{}.PostRun: {}[{}]\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"self",
".",
"__class__",
".",
"path",
",",
"self",
".",
"uuid",
")",
",... | To execute after exection
:param kser.result.Result result: Execution result
:return: Execution result
:rtype: kser.result.Result | [
"To",
"execute",
"after",
"exection"
] | fbd6fe9ab34b8b89d9937e5ff727614304af48c1 | https://github.com/cdumay/kser/blob/fbd6fe9ab34b8b89d9937e5ff727614304af48c1/src/kser/entry.py#L165-L183 |
39,558 | cdumay/kser | src/kser/entry.py | Entrypoint.execute | def execute(self, result=None):
""" Execution 'wrapper' to make sure that it return a result
:return: Execution result
:rtype: kser.result.Result
"""
try:
return self.unsafe_execute(result=result)
except Exception as exc:
return self._onerror(Resu... | python | def execute(self, result=None):
""" Execution 'wrapper' to make sure that it return a result
:return: Execution result
:rtype: kser.result.Result
"""
try:
return self.unsafe_execute(result=result)
except Exception as exc:
return self._onerror(Resu... | [
"def",
"execute",
"(",
"self",
",",
"result",
"=",
"None",
")",
":",
"try",
":",
"return",
"self",
".",
"unsafe_execute",
"(",
"result",
"=",
"result",
")",
"except",
"Exception",
"as",
"exc",
":",
"return",
"self",
".",
"_onerror",
"(",
"Result",
".",... | Execution 'wrapper' to make sure that it return a result
:return: Execution result
:rtype: kser.result.Result | [
"Execution",
"wrapper",
"to",
"make",
"sure",
"that",
"it",
"return",
"a",
"result"
] | fbd6fe9ab34b8b89d9937e5ff727614304af48c1 | https://github.com/cdumay/kser/blob/fbd6fe9ab34b8b89d9937e5ff727614304af48c1/src/kser/entry.py#L238-L247 |
39,559 | cdumay/kser | src/kser/entry.py | Entrypoint.to_Message | def to_Message(self, result=None):
""" Entrypoint -> Message
:param kser.result.Result result: Execution result
:return: Kafka message
:rtype kser.schemas.Message
"""
return Message(
uuid=self.uuid, entrypoint=self.__class__.path, params=self.params,
... | python | def to_Message(self, result=None):
""" Entrypoint -> Message
:param kser.result.Result result: Execution result
:return: Kafka message
:rtype kser.schemas.Message
"""
return Message(
uuid=self.uuid, entrypoint=self.__class__.path, params=self.params,
... | [
"def",
"to_Message",
"(",
"self",
",",
"result",
"=",
"None",
")",
":",
"return",
"Message",
"(",
"uuid",
"=",
"self",
".",
"uuid",
",",
"entrypoint",
"=",
"self",
".",
"__class__",
".",
"path",
",",
"params",
"=",
"self",
".",
"params",
",",
"result... | Entrypoint -> Message
:param kser.result.Result result: Execution result
:return: Kafka message
:rtype kser.schemas.Message | [
"Entrypoint",
"-",
">",
"Message"
] | fbd6fe9ab34b8b89d9937e5ff727614304af48c1 | https://github.com/cdumay/kser/blob/fbd6fe9ab34b8b89d9937e5ff727614304af48c1/src/kser/entry.py#L250-L260 |
39,560 | cdumay/kser | src/kser/entry.py | Entrypoint.from_Message | def from_Message(cls, kmsg):
""" Message -> Entrypoint
:param kser.schemas.Message kmsg: Kafka message
:return: a entrypoint
:rtype kser.entry.Entrypoint
"""
return cls(
uuid=kmsg.uuid, params=kmsg.params, result=kmsg.result,
metadata=kmsg.metadat... | python | def from_Message(cls, kmsg):
""" Message -> Entrypoint
:param kser.schemas.Message kmsg: Kafka message
:return: a entrypoint
:rtype kser.entry.Entrypoint
"""
return cls(
uuid=kmsg.uuid, params=kmsg.params, result=kmsg.result,
metadata=kmsg.metadat... | [
"def",
"from_Message",
"(",
"cls",
",",
"kmsg",
")",
":",
"return",
"cls",
"(",
"uuid",
"=",
"kmsg",
".",
"uuid",
",",
"params",
"=",
"kmsg",
".",
"params",
",",
"result",
"=",
"kmsg",
".",
"result",
",",
"metadata",
"=",
"kmsg",
".",
"metadata",
"... | Message -> Entrypoint
:param kser.schemas.Message kmsg: Kafka message
:return: a entrypoint
:rtype kser.entry.Entrypoint | [
"Message",
"-",
">",
"Entrypoint"
] | fbd6fe9ab34b8b89d9937e5ff727614304af48c1 | https://github.com/cdumay/kser/blob/fbd6fe9ab34b8b89d9937e5ff727614304af48c1/src/kser/entry.py#L264-L274 |
39,561 | trevisanj/f311 | f311/filetypes/datafile.py | DataFile.save_as | def save_as(self, filename=None):
"""
Dumps object contents into file on disk.
Args:
filename (optional): defaults to self.filename. If passed, self.filename
will be updated to filename.
"""
if filename is None:
filename = self.filename
... | python | def save_as(self, filename=None):
"""
Dumps object contents into file on disk.
Args:
filename (optional): defaults to self.filename. If passed, self.filename
will be updated to filename.
"""
if filename is None:
filename = self.filename
... | [
"def",
"save_as",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"self",
".",
"filename",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"self",
".",
"default_filename",
"if",
"filename",... | Dumps object contents into file on disk.
Args:
filename (optional): defaults to self.filename. If passed, self.filename
will be updated to filename. | [
"Dumps",
"object",
"contents",
"into",
"file",
"on",
"disk",
"."
] | 9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7 | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/datafile.py#L63-L78 |
39,562 | trevisanj/f311 | f311/filetypes/datafile.py | DataFile.load | def load(self, filename=None):
"""Loads file and registers filename as attribute."""
assert not self.__flag_loaded, "File can be loaded only once"
if filename is None:
filename = self.default_filename
assert filename is not None, \
"{0!s} class has no default file... | python | def load(self, filename=None):
"""Loads file and registers filename as attribute."""
assert not self.__flag_loaded, "File can be loaded only once"
if filename is None:
filename = self.default_filename
assert filename is not None, \
"{0!s} class has no default file... | [
"def",
"load",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"assert",
"not",
"self",
".",
"__flag_loaded",
",",
"\"File can be loaded only once\"",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"self",
".",
"default_filename",
"assert",
"filena... | Loads file and registers filename as attribute. | [
"Loads",
"file",
"and",
"registers",
"filename",
"as",
"attribute",
"."
] | 9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7 | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/datafile.py#L80-L98 |
39,563 | trevisanj/f311 | f311/filetypes/datafile.py | DataFile.init_default | def init_default(self):
"""
Initializes object with its default values
Tries to load self.default_filename from default
data directory. For safety, filename is reset to None so that it doesn't point to the
original file.
"""
import f311
if self.default_fi... | python | def init_default(self):
"""
Initializes object with its default values
Tries to load self.default_filename from default
data directory. For safety, filename is reset to None so that it doesn't point to the
original file.
"""
import f311
if self.default_fi... | [
"def",
"init_default",
"(",
"self",
")",
":",
"import",
"f311",
"if",
"self",
".",
"default_filename",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Class '{}' has no default filename\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
... | Initializes object with its default values
Tries to load self.default_filename from default
data directory. For safety, filename is reset to None so that it doesn't point to the
original file. | [
"Initializes",
"object",
"with",
"its",
"default",
"values"
] | 9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7 | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/datafile.py#L100-L113 |
39,564 | tradenity/python-sdk | tradenity/resources/product.py | Product.availability | def availability(self, availability):
"""Sets the availability of this Product.
:param availability: The availability of this Product.
:type: str
"""
allowed_values = ["available", "comingSoon", "retired"]
if availability is not None and availability not in allowed_valu... | python | def availability(self, availability):
"""Sets the availability of this Product.
:param availability: The availability of this Product.
:type: str
"""
allowed_values = ["available", "comingSoon", "retired"]
if availability is not None and availability not in allowed_valu... | [
"def",
"availability",
"(",
"self",
",",
"availability",
")",
":",
"allowed_values",
"=",
"[",
"\"available\"",
",",
"\"comingSoon\"",
",",
"\"retired\"",
"]",
"if",
"availability",
"is",
"not",
"None",
"and",
"availability",
"not",
"in",
"allowed_values",
":",
... | Sets the availability of this Product.
:param availability: The availability of this Product.
:type: str | [
"Sets",
"the",
"availability",
"of",
"this",
"Product",
"."
] | d13fbe23f4d6ff22554c6d8d2deaf209371adaf1 | https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/product.py#L716-L730 |
39,565 | tradenity/python-sdk | tradenity/resources/product.py | Product.stock_status | def stock_status(self, stock_status):
"""Sets the stock_status of this Product.
:param stock_status: The stock_status of this Product.
:type: str
"""
allowed_values = ["available", "alert", "unavailable"]
if stock_status is not None and stock_status not in allowed_value... | python | def stock_status(self, stock_status):
"""Sets the stock_status of this Product.
:param stock_status: The stock_status of this Product.
:type: str
"""
allowed_values = ["available", "alert", "unavailable"]
if stock_status is not None and stock_status not in allowed_value... | [
"def",
"stock_status",
"(",
"self",
",",
"stock_status",
")",
":",
"allowed_values",
"=",
"[",
"\"available\"",
",",
"\"alert\"",
",",
"\"unavailable\"",
"]",
"if",
"stock_status",
"is",
"not",
"None",
"and",
"stock_status",
"not",
"in",
"allowed_values",
":",
... | Sets the stock_status of this Product.
:param stock_status: The stock_status of this Product.
:type: str | [
"Sets",
"the",
"stock_status",
"of",
"this",
"Product",
"."
] | d13fbe23f4d6ff22554c6d8d2deaf209371adaf1 | https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/product.py#L911-L925 |
39,566 | CodyKochmann/generators | generators/inline_tools.py | asserts | def asserts(input_value, rule, message=''):
""" this function allows you to write asserts in generators since there are
moments where you actually want the program to halt when certain values
are seen.
"""
assert callable(rule) or type(rule)==bool, 'asserts needs rule to be a callable functi... | python | def asserts(input_value, rule, message=''):
""" this function allows you to write asserts in generators since there are
moments where you actually want the program to halt when certain values
are seen.
"""
assert callable(rule) or type(rule)==bool, 'asserts needs rule to be a callable functi... | [
"def",
"asserts",
"(",
"input_value",
",",
"rule",
",",
"message",
"=",
"''",
")",
":",
"assert",
"callable",
"(",
"rule",
")",
"or",
"type",
"(",
"rule",
")",
"==",
"bool",
",",
"'asserts needs rule to be a callable function or a test boolean'",
"assert",
"isin... | this function allows you to write asserts in generators since there are
moments where you actually want the program to halt when certain values
are seen. | [
"this",
"function",
"allows",
"you",
"to",
"write",
"asserts",
"in",
"generators",
"since",
"there",
"are",
"moments",
"where",
"you",
"actually",
"want",
"the",
"program",
"to",
"halt",
"when",
"certain",
"values",
"are",
"seen",
"."
] | e4ca4dd25d5023a94b0349c69d6224070cc2526f | https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/inline_tools.py#L14-L33 |
39,567 | CodyKochmann/generators | generators/inline_tools.py | print | def print(*a):
""" print just one that returns what you give it instead of None """
try:
_print(*a)
return a[0] if len(a) == 1 else a
except:
_print(*a) | python | def print(*a):
""" print just one that returns what you give it instead of None """
try:
_print(*a)
return a[0] if len(a) == 1 else a
except:
_print(*a) | [
"def",
"print",
"(",
"*",
"a",
")",
":",
"try",
":",
"_print",
"(",
"*",
"a",
")",
"return",
"a",
"[",
"0",
"]",
"if",
"len",
"(",
"a",
")",
"==",
"1",
"else",
"a",
"except",
":",
"_print",
"(",
"*",
"a",
")"
] | print just one that returns what you give it instead of None | [
"print",
"just",
"one",
"that",
"returns",
"what",
"you",
"give",
"it",
"instead",
"of",
"None"
] | e4ca4dd25d5023a94b0349c69d6224070cc2526f | https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/inline_tools.py#L38-L44 |
39,568 | remram44/rpaths | rpaths.py | pattern2re | def pattern2re(pattern):
"""Makes a unicode regular expression from a pattern.
Returns ``(start, full_re, int_re)`` where:
* `start` is either empty or the subdirectory in which to start searching,
* `full_re` is a regular expression object that matches the requested
files, i.e. a translation... | python | def pattern2re(pattern):
"""Makes a unicode regular expression from a pattern.
Returns ``(start, full_re, int_re)`` where:
* `start` is either empty or the subdirectory in which to start searching,
* `full_re` is a regular expression object that matches the requested
files, i.e. a translation... | [
"def",
"pattern2re",
"(",
"pattern",
")",
":",
"pattern_segs",
"=",
"filter",
"(",
"None",
",",
"pattern",
".",
"split",
"(",
"'/'",
")",
")",
"# This anchors the first component either at the start of the string or at",
"# the start of a path component",
"if",
"not",
"... | Makes a unicode regular expression from a pattern.
Returns ``(start, full_re, int_re)`` where:
* `start` is either empty or the subdirectory in which to start searching,
* `full_re` is a regular expression object that matches the requested
files, i.e. a translation of the pattern
* `int_re` ... | [
"Makes",
"a",
"unicode",
"regular",
"expression",
"from",
"a",
"pattern",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L1133-L1210 |
39,569 | remram44/rpaths | rpaths.py | AbstractPath._to_backend | def _to_backend(self, p):
"""Converts something to the correct path representation.
If given a Path, this will simply unpack it, if it's the correct type.
If given the correct backend, it will return that.
If given bytes for unicode of unicode for bytes, it will encode/decode
wi... | python | def _to_backend(self, p):
"""Converts something to the correct path representation.
If given a Path, this will simply unpack it, if it's the correct type.
If given the correct backend, it will return that.
If given bytes for unicode of unicode for bytes, it will encode/decode
wi... | [
"def",
"_to_backend",
"(",
"self",
",",
"p",
")",
":",
"if",
"isinstance",
"(",
"p",
",",
"self",
".",
"_cmp_base",
")",
":",
"return",
"p",
".",
"path",
"elif",
"isinstance",
"(",
"p",
",",
"self",
".",
"_backend",
")",
":",
"return",
"p",
"elif",... | Converts something to the correct path representation.
If given a Path, this will simply unpack it, if it's the correct type.
If given the correct backend, it will return that.
If given bytes for unicode of unicode for bytes, it will encode/decode
with a reasonable encoding. Note that t... | [
"Converts",
"something",
"to",
"the",
"correct",
"path",
"representation",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L70-L90 |
39,570 | remram44/rpaths | rpaths.py | AbstractPath.parent | def parent(self):
"""The parent directory of this path.
"""
p = self._lib.dirname(self.path)
p = self.__class__(p)
return p | python | def parent(self):
"""The parent directory of this path.
"""
p = self._lib.dirname(self.path)
p = self.__class__(p)
return p | [
"def",
"parent",
"(",
"self",
")",
":",
"p",
"=",
"self",
".",
"_lib",
".",
"dirname",
"(",
"self",
".",
"path",
")",
"p",
"=",
"self",
".",
"__class__",
"(",
"p",
")",
"return",
"p"
] | The parent directory of this path. | [
"The",
"parent",
"directory",
"of",
"this",
"path",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L275-L280 |
39,571 | remram44/rpaths | rpaths.py | AbstractPath.unicodename | def unicodename(self):
"""The name of this path as unicode.
"""
n = self._lib.basename(self.path)
if self._backend is unicode:
return n
else:
return n.decode(self._encoding, 'replace') | python | def unicodename(self):
"""The name of this path as unicode.
"""
n = self._lib.basename(self.path)
if self._backend is unicode:
return n
else:
return n.decode(self._encoding, 'replace') | [
"def",
"unicodename",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"_lib",
".",
"basename",
"(",
"self",
".",
"path",
")",
"if",
"self",
".",
"_backend",
"is",
"unicode",
":",
"return",
"n",
"else",
":",
"return",
"n",
".",
"decode",
"(",
"self",
... | The name of this path as unicode. | [
"The",
"name",
"of",
"this",
"path",
"as",
"unicode",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L289-L296 |
39,572 | remram44/rpaths | rpaths.py | AbstractPath.rel_path_to | def rel_path_to(self, dest):
"""Builds a relative path leading from this one to the given `dest`.
Note that these paths might be both relative, in which case they'll be
assumed to start from the same directory.
"""
dest = self.__class__(dest)
orig_list = self.norm_case(... | python | def rel_path_to(self, dest):
"""Builds a relative path leading from this one to the given `dest`.
Note that these paths might be both relative, in which case they'll be
assumed to start from the same directory.
"""
dest = self.__class__(dest)
orig_list = self.norm_case(... | [
"def",
"rel_path_to",
"(",
"self",
",",
"dest",
")",
":",
"dest",
"=",
"self",
".",
"__class__",
"(",
"dest",
")",
"orig_list",
"=",
"self",
".",
"norm_case",
"(",
")",
".",
"_components",
"(",
")",
"dest_list",
"=",
"dest",
".",
"_components",
"(",
... | Builds a relative path leading from this one to the given `dest`.
Note that these paths might be both relative, in which case they'll be
assumed to start from the same directory. | [
"Builds",
"a",
"relative",
"path",
"leading",
"from",
"this",
"one",
"to",
"the",
"given",
"dest",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L380-L404 |
39,573 | remram44/rpaths | rpaths.py | AbstractPath.lies_under | def lies_under(self, prefix):
"""Indicates if the `prefix` is a parent of this path.
"""
orig_list = self.norm_case()._components()
pref_list = self.__class__(prefix).norm_case()._components()
return (len(orig_list) >= len(pref_list) and
orig_list[:len(pref_list)... | python | def lies_under(self, prefix):
"""Indicates if the `prefix` is a parent of this path.
"""
orig_list = self.norm_case()._components()
pref_list = self.__class__(prefix).norm_case()._components()
return (len(orig_list) >= len(pref_list) and
orig_list[:len(pref_list)... | [
"def",
"lies_under",
"(",
"self",
",",
"prefix",
")",
":",
"orig_list",
"=",
"self",
".",
"norm_case",
"(",
")",
".",
"_components",
"(",
")",
"pref_list",
"=",
"self",
".",
"__class__",
"(",
"prefix",
")",
".",
"norm_case",
"(",
")",
".",
"_components... | Indicates if the `prefix` is a parent of this path. | [
"Indicates",
"if",
"the",
"prefix",
"is",
"a",
"parent",
"of",
"this",
"path",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L406-L413 |
39,574 | remram44/rpaths | rpaths.py | Path.tempfile | def tempfile(cls, suffix='', prefix=None, dir=None, text=False):
"""Returns a new temporary file.
The return value is a pair (fd, path) where fd is the file descriptor
returned by :func:`os.open`, and path is a :class:`~rpaths.Path` to it.
:param suffix: If specified, the file name wil... | python | def tempfile(cls, suffix='', prefix=None, dir=None, text=False):
"""Returns a new temporary file.
The return value is a pair (fd, path) where fd is the file descriptor
returned by :func:`os.open`, and path is a :class:`~rpaths.Path` to it.
:param suffix: If specified, the file name wil... | [
"def",
"tempfile",
"(",
"cls",
",",
"suffix",
"=",
"''",
",",
"prefix",
"=",
"None",
",",
"dir",
"=",
"None",
",",
"text",
"=",
"False",
")",
":",
"if",
"prefix",
"is",
"None",
":",
"prefix",
"=",
"tempfile",
".",
"template",
"if",
"dir",
"is",
"... | Returns a new temporary file.
The return value is a pair (fd, path) where fd is the file descriptor
returned by :func:`os.open`, and path is a :class:`~rpaths.Path` to it.
:param suffix: If specified, the file name will end with that suffix,
otherwise there will be no suffix.
... | [
"Returns",
"a",
"new",
"temporary",
"file",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L498-L531 |
39,575 | remram44/rpaths | rpaths.py | Path.tempdir | def tempdir(cls, suffix='', prefix=None, dir=None):
"""Returns a new temporary directory.
Arguments are as for :meth:`~rpaths.Path.tempfile`, except that the
`text` argument is not accepted.
The directory is readable, writable, and searchable only by the
creating user.
... | python | def tempdir(cls, suffix='', prefix=None, dir=None):
"""Returns a new temporary directory.
Arguments are as for :meth:`~rpaths.Path.tempfile`, except that the
`text` argument is not accepted.
The directory is readable, writable, and searchable only by the
creating user.
... | [
"def",
"tempdir",
"(",
"cls",
",",
"suffix",
"=",
"''",
",",
"prefix",
"=",
"None",
",",
"dir",
"=",
"None",
")",
":",
"if",
"prefix",
"is",
"None",
":",
"prefix",
"=",
"tempfile",
".",
"template",
"if",
"dir",
"is",
"not",
"None",
":",
"# Note tha... | Returns a new temporary directory.
Arguments are as for :meth:`~rpaths.Path.tempfile`, except that the
`text` argument is not accepted.
The directory is readable, writable, and searchable only by the
creating user.
The caller is responsible for deleting the directory when done... | [
"Returns",
"a",
"new",
"temporary",
"directory",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L534-L552 |
39,576 | remram44/rpaths | rpaths.py | Path.rel_path_to | def rel_path_to(self, dest):
"""Builds a relative path leading from this one to another.
Note that these paths might be both relative, in which case they'll be
assumed to be considered starting from the same directory.
Contrary to :class:`~rpaths.AbstractPath`'s version, this will also... | python | def rel_path_to(self, dest):
"""Builds a relative path leading from this one to another.
Note that these paths might be both relative, in which case they'll be
assumed to be considered starting from the same directory.
Contrary to :class:`~rpaths.AbstractPath`'s version, this will also... | [
"def",
"rel_path_to",
"(",
"self",
",",
"dest",
")",
":",
"return",
"super",
"(",
"Path",
",",
"self",
".",
"absolute",
"(",
")",
")",
".",
"rel_path_to",
"(",
"Path",
"(",
"dest",
")",
".",
"absolute",
"(",
")",
")"
] | Builds a relative path leading from this one to another.
Note that these paths might be both relative, in which case they'll be
assumed to be considered starting from the same directory.
Contrary to :class:`~rpaths.AbstractPath`'s version, this will also
work if one path is relative an... | [
"Builds",
"a",
"relative",
"path",
"leading",
"from",
"this",
"one",
"to",
"another",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L559-L568 |
39,577 | remram44/rpaths | rpaths.py | Path.listdir | def listdir(self, pattern=None):
"""Returns a list of all the files in this directory.
The special entries ``'.'`` and ``'..'`` will not be returned.
:param pattern: A pattern to match directory entries against.
:type pattern: NoneType | Callable | Pattern | unicode | bytes
"""... | python | def listdir(self, pattern=None):
"""Returns a list of all the files in this directory.
The special entries ``'.'`` and ``'..'`` will not be returned.
:param pattern: A pattern to match directory entries against.
:type pattern: NoneType | Callable | Pattern | unicode | bytes
"""... | [
"def",
"listdir",
"(",
"self",
",",
"pattern",
"=",
"None",
")",
":",
"files",
"=",
"[",
"self",
"/",
"self",
".",
"__class__",
"(",
"p",
")",
"for",
"p",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"path",
")",
"]",
"if",
"pattern",
"is",
"N... | Returns a list of all the files in this directory.
The special entries ``'.'`` and ``'..'`` will not be returned.
:param pattern: A pattern to match directory entries against.
:type pattern: NoneType | Callable | Pattern | unicode | bytes | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"files",
"in",
"this",
"directory",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L582-L611 |
39,578 | remram44/rpaths | rpaths.py | Path.recursedir | def recursedir(self, pattern=None, top_down=True, follow_links=False,
handle_errors=None):
"""Recursively lists all files under this directory.
:param pattern: An extended patterns, where:
* a slash '/' always represents the path separator
* a backslash '\' e... | python | def recursedir(self, pattern=None, top_down=True, follow_links=False,
handle_errors=None):
"""Recursively lists all files under this directory.
:param pattern: An extended patterns, where:
* a slash '/' always represents the path separator
* a backslash '\' e... | [
"def",
"recursedir",
"(",
"self",
",",
"pattern",
"=",
"None",
",",
"top_down",
"=",
"True",
",",
"follow_links",
"=",
"False",
",",
"handle_errors",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"is_dir",
"(",
")",
":",
"raise",
"ValueError",
"(",
... | Recursively lists all files under this directory.
:param pattern: An extended patterns, where:
* a slash '/' always represents the path separator
* a backslash '\' escapes other special characters
* an initial slash '/' anchors the match at the beginning of the
... | [
"Recursively",
"lists",
"all",
"files",
"under",
"this",
"directory",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L613-L684 |
39,579 | remram44/rpaths | rpaths.py | Path.mkdir | def mkdir(self, name=None, parents=False, mode=0o777):
"""Creates that directory, or a directory under this one.
``path.mkdir(name)`` is a shortcut for ``(path/name).mkdir()``.
:param name: Path component to append to this path before creating the
directory.
:param parents... | python | def mkdir(self, name=None, parents=False, mode=0o777):
"""Creates that directory, or a directory under this one.
``path.mkdir(name)`` is a shortcut for ``(path/name).mkdir()``.
:param name: Path component to append to this path before creating the
directory.
:param parents... | [
"def",
"mkdir",
"(",
"self",
",",
"name",
"=",
"None",
",",
"parents",
"=",
"False",
",",
"mode",
"=",
"0o777",
")",
":",
"if",
"name",
"is",
"not",
"None",
":",
"return",
"(",
"self",
"/",
"name",
")",
".",
"mkdir",
"(",
"parents",
"=",
"parents... | Creates that directory, or a directory under this one.
``path.mkdir(name)`` is a shortcut for ``(path/name).mkdir()``.
:param name: Path component to append to this path before creating the
directory.
:param parents: If True, missing directories leading to the path will
... | [
"Creates",
"that",
"directory",
"or",
"a",
"directory",
"under",
"this",
"one",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L811-L834 |
39,580 | remram44/rpaths | rpaths.py | Path.rmdir | def rmdir(self, parents=False):
"""Removes this directory, provided it is empty.
Use :func:`~rpaths.Path.rmtree` if it might still contain files.
:param parents: If set to True, it will also destroy every empty
directory above it until an error is encountered.
"""
i... | python | def rmdir(self, parents=False):
"""Removes this directory, provided it is empty.
Use :func:`~rpaths.Path.rmtree` if it might still contain files.
:param parents: If set to True, it will also destroy every empty
directory above it until an error is encountered.
"""
i... | [
"def",
"rmdir",
"(",
"self",
",",
"parents",
"=",
"False",
")",
":",
"if",
"parents",
":",
"os",
".",
"removedirs",
"(",
"self",
".",
"path",
")",
"else",
":",
"os",
".",
"rmdir",
"(",
"self",
".",
"path",
")"
] | Removes this directory, provided it is empty.
Use :func:`~rpaths.Path.rmtree` if it might still contain files.
:param parents: If set to True, it will also destroy every empty
directory above it until an error is encountered. | [
"Removes",
"this",
"directory",
"provided",
"it",
"is",
"empty",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L836-L847 |
39,581 | remram44/rpaths | rpaths.py | Path.rename | def rename(self, new, parents=False):
"""Renames this path to the given new location.
:param new: New path where to move this one.
:param parents: If set to True, it will create the parent directories
of the target if they don't exist.
"""
if parents:
os... | python | def rename(self, new, parents=False):
"""Renames this path to the given new location.
:param new: New path where to move this one.
:param parents: If set to True, it will create the parent directories
of the target if they don't exist.
"""
if parents:
os... | [
"def",
"rename",
"(",
"self",
",",
"new",
",",
"parents",
"=",
"False",
")",
":",
"if",
"parents",
":",
"os",
".",
"renames",
"(",
"self",
".",
"path",
",",
"self",
".",
"_to_backend",
"(",
"new",
")",
")",
"else",
":",
"os",
".",
"rename",
"(",
... | Renames this path to the given new location.
:param new: New path where to move this one.
:param parents: If set to True, it will create the parent directories
of the target if they don't exist. | [
"Renames",
"this",
"path",
"to",
"the",
"given",
"new",
"location",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L854-L865 |
39,582 | remram44/rpaths | rpaths.py | Path.copyfile | def copyfile(self, target):
"""Copies this file to the given `target` location.
"""
shutil.copyfile(self.path, self._to_backend(target)) | python | def copyfile(self, target):
"""Copies this file to the given `target` location.
"""
shutil.copyfile(self.path, self._to_backend(target)) | [
"def",
"copyfile",
"(",
"self",
",",
"target",
")",
":",
"shutil",
".",
"copyfile",
"(",
"self",
".",
"path",
",",
"self",
".",
"_to_backend",
"(",
"target",
")",
")"
] | Copies this file to the given `target` location. | [
"Copies",
"this",
"file",
"to",
"the",
"given",
"target",
"location",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L891-L894 |
39,583 | remram44/rpaths | rpaths.py | Path.copymode | def copymode(self, target):
"""Copies the mode of this file on the `target` file.
The owner is not copied.
"""
shutil.copymode(self.path, self._to_backend(target)) | python | def copymode(self, target):
"""Copies the mode of this file on the `target` file.
The owner is not copied.
"""
shutil.copymode(self.path, self._to_backend(target)) | [
"def",
"copymode",
"(",
"self",
",",
"target",
")",
":",
"shutil",
".",
"copymode",
"(",
"self",
".",
"path",
",",
"self",
".",
"_to_backend",
"(",
"target",
")",
")"
] | Copies the mode of this file on the `target` file.
The owner is not copied. | [
"Copies",
"the",
"mode",
"of",
"this",
"file",
"on",
"the",
"target",
"file",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L896-L901 |
39,584 | remram44/rpaths | rpaths.py | Path.copystat | def copystat(self, target):
"""Copies the permissions, times and flags from this to the `target`.
The owner is not copied.
"""
shutil.copystat(self.path, self._to_backend(target)) | python | def copystat(self, target):
"""Copies the permissions, times and flags from this to the `target`.
The owner is not copied.
"""
shutil.copystat(self.path, self._to_backend(target)) | [
"def",
"copystat",
"(",
"self",
",",
"target",
")",
":",
"shutil",
".",
"copystat",
"(",
"self",
".",
"path",
",",
"self",
".",
"_to_backend",
"(",
"target",
")",
")"
] | Copies the permissions, times and flags from this to the `target`.
The owner is not copied. | [
"Copies",
"the",
"permissions",
"times",
"and",
"flags",
"from",
"this",
"to",
"the",
"target",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L903-L908 |
39,585 | remram44/rpaths | rpaths.py | Path.copy | def copy(self, target):
"""Copies this file the `target`, which might be a directory.
The permissions are copied.
"""
shutil.copy(self.path, self._to_backend(target)) | python | def copy(self, target):
"""Copies this file the `target`, which might be a directory.
The permissions are copied.
"""
shutil.copy(self.path, self._to_backend(target)) | [
"def",
"copy",
"(",
"self",
",",
"target",
")",
":",
"shutil",
".",
"copy",
"(",
"self",
".",
"path",
",",
"self",
".",
"_to_backend",
"(",
"target",
")",
")"
] | Copies this file the `target`, which might be a directory.
The permissions are copied. | [
"Copies",
"this",
"file",
"the",
"target",
"which",
"might",
"be",
"a",
"directory",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L910-L915 |
39,586 | remram44/rpaths | rpaths.py | Path.copytree | def copytree(self, target, symlinks=False):
"""Recursively copies this directory to the `target` location.
The permissions and times are copied (like
:meth:`~rpaths.Path.copystat`).
If the optional `symlinks` flag is true, symbolic links in the source
tree result in symbolic li... | python | def copytree(self, target, symlinks=False):
"""Recursively copies this directory to the `target` location.
The permissions and times are copied (like
:meth:`~rpaths.Path.copystat`).
If the optional `symlinks` flag is true, symbolic links in the source
tree result in symbolic li... | [
"def",
"copytree",
"(",
"self",
",",
"target",
",",
"symlinks",
"=",
"False",
")",
":",
"shutil",
".",
"copytree",
"(",
"self",
".",
"path",
",",
"self",
".",
"_to_backend",
"(",
"target",
")",
",",
"symlinks",
")"
] | Recursively copies this directory to the `target` location.
The permissions and times are copied (like
:meth:`~rpaths.Path.copystat`).
If the optional `symlinks` flag is true, symbolic links in the source
tree result in symbolic links in the destination tree; if it is false,
th... | [
"Recursively",
"copies",
"this",
"directory",
"to",
"the",
"target",
"location",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L917-L927 |
39,587 | remram44/rpaths | rpaths.py | Path.move | def move(self, target):
"""Recursively moves a file or directory to the given target location.
"""
shutil.move(self.path, self._to_backend(target)) | python | def move(self, target):
"""Recursively moves a file or directory to the given target location.
"""
shutil.move(self.path, self._to_backend(target)) | [
"def",
"move",
"(",
"self",
",",
"target",
")",
":",
"shutil",
".",
"move",
"(",
"self",
".",
"path",
",",
"self",
".",
"_to_backend",
"(",
"target",
")",
")"
] | Recursively moves a file or directory to the given target location. | [
"Recursively",
"moves",
"a",
"file",
"or",
"directory",
"to",
"the",
"given",
"target",
"location",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L937-L940 |
39,588 | remram44/rpaths | rpaths.py | Path.open | def open(self, mode='r', name=None, **kwargs):
"""Opens this file, or a file under this directory.
``path.open(mode, name)`` is a shortcut for ``(path/name).open(mode)``.
Note that this uses :func:`io.open()` which behaves differently from
:func:`open()` on Python 2; see the appropriat... | python | def open(self, mode='r', name=None, **kwargs):
"""Opens this file, or a file under this directory.
``path.open(mode, name)`` is a shortcut for ``(path/name).open(mode)``.
Note that this uses :func:`io.open()` which behaves differently from
:func:`open()` on Python 2; see the appropriat... | [
"def",
"open",
"(",
"self",
",",
"mode",
"=",
"'r'",
",",
"name",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"is",
"not",
"None",
":",
"return",
"io",
".",
"open",
"(",
"(",
"self",
"/",
"name",
")",
".",
"path",
",",
"mode... | Opens this file, or a file under this directory.
``path.open(mode, name)`` is a shortcut for ``(path/name).open(mode)``.
Note that this uses :func:`io.open()` which behaves differently from
:func:`open()` on Python 2; see the appropriate documentation.
:param name: Path component to a... | [
"Opens",
"this",
"file",
"or",
"a",
"file",
"under",
"this",
"directory",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L942-L956 |
39,589 | remram44/rpaths | rpaths.py | Path.rewrite | def rewrite(self, mode='r', name=None, temp=None, tempext='~', **kwargs):
r"""Replaces this file with new content.
This context manager gives you two file objects, (r, w), where r is
readable and has the current content of the file, and w is writable
and will replace the file at the end... | python | def rewrite(self, mode='r', name=None, temp=None, tempext='~', **kwargs):
r"""Replaces this file with new content.
This context manager gives you two file objects, (r, w), where r is
readable and has the current content of the file, and w is writable
and will replace the file at the end... | [
"def",
"rewrite",
"(",
"self",
",",
"mode",
"=",
"'r'",
",",
"name",
"=",
"None",
",",
"temp",
"=",
"None",
",",
"tempext",
"=",
"'~'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"is",
"not",
"None",
":",
"pathr",
"=",
"self",
"/",
"name"... | r"""Replaces this file with new content.
This context manager gives you two file objects, (r, w), where r is
readable and has the current content of the file, and w is writable
and will replace the file at the end of the context (unless an
exception is raised, in which case it is rolled... | [
"r",
"Replaces",
"this",
"file",
"with",
"new",
"content",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L959-L1026 |
39,590 | remram44/rpaths | rpaths.py | Pattern.matches | def matches(self, path):
"""Tests if the given path matches the pattern.
Note that the unicode translation of the patch is matched, so
replacement characters might have been added.
"""
path = self._prepare_path(path)
return self.full_regex.search(path) is not None | python | def matches(self, path):
"""Tests if the given path matches the pattern.
Note that the unicode translation of the patch is matched, so
replacement characters might have been added.
"""
path = self._prepare_path(path)
return self.full_regex.search(path) is not None | [
"def",
"matches",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"self",
".",
"_prepare_path",
"(",
"path",
")",
"return",
"self",
".",
"full_regex",
".",
"search",
"(",
"path",
")",
"is",
"not",
"None"
] | Tests if the given path matches the pattern.
Note that the unicode translation of the patch is matched, so
replacement characters might have been added. | [
"Tests",
"if",
"the",
"given",
"path",
"matches",
"the",
"pattern",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L1078-L1085 |
39,591 | remram44/rpaths | rpaths.py | Pattern.may_contain_matches | def may_contain_matches(self, path):
"""Tests whether it's possible for paths under the given one to match.
If this method returns None, no path under the given one will match the
pattern.
"""
path = self._prepare_path(path)
return self.int_regex.search(path) is not None | python | def may_contain_matches(self, path):
"""Tests whether it's possible for paths under the given one to match.
If this method returns None, no path under the given one will match the
pattern.
"""
path = self._prepare_path(path)
return self.int_regex.search(path) is not None | [
"def",
"may_contain_matches",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"self",
".",
"_prepare_path",
"(",
"path",
")",
"return",
"self",
".",
"int_regex",
".",
"search",
"(",
"path",
")",
"is",
"not",
"None"
] | Tests whether it's possible for paths under the given one to match.
If this method returns None, no path under the given one will match the
pattern. | [
"Tests",
"whether",
"it",
"s",
"possible",
"for",
"paths",
"under",
"the",
"given",
"one",
"to",
"match",
"."
] | e4ff55d985c4d643d9fd214539d45af39ae5a7cd | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L1087-L1094 |
39,592 | micha030201/aionationstates | aionationstates/nation_.py | Nation.tgcanrecruit | def tgcanrecruit(self, region=None):
"""Whether the nation will receive a recruitment telegram.
Useful in conjunction with the Telegrams API.
Parameters
----------
region : str
Name of the region you are recruiting for.
Returns
-------
an :c... | python | def tgcanrecruit(self, region=None):
"""Whether the nation will receive a recruitment telegram.
Useful in conjunction with the Telegrams API.
Parameters
----------
region : str
Name of the region you are recruiting for.
Returns
-------
an :c... | [
"def",
"tgcanrecruit",
"(",
"self",
",",
"region",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'from'",
":",
"normalize",
"(",
"region",
")",
"}",
"if",
"region",
"is",
"not",
"None",
"else",
"{",
"}",
"@",
"api_query",
"(",
"'tgcanrecruit'",
",",
"*... | Whether the nation will receive a recruitment telegram.
Useful in conjunction with the Telegrams API.
Parameters
----------
region : str
Name of the region you are recruiting for.
Returns
-------
an :class:`ApiQuery` of bool | [
"Whether",
"the",
"nation",
"will",
"receive",
"a",
"recruitment",
"telegram",
"."
] | dc86b86d994cbab830b69ab8023601c73e778b3a | https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/nation_.py#L460-L478 |
39,593 | micha030201/aionationstates | aionationstates/nation_.py | Nation.govt | async def govt(self, root):
"""Nation's government expenditure, as percentages.
Returns
-------
an :class:`ApiQuery` of :class:`collections.OrderedDict` with \
keys of str and values of float
Keys being, in order: ``Administration``, ``Defense``,
``Educat... | python | async def govt(self, root):
"""Nation's government expenditure, as percentages.
Returns
-------
an :class:`ApiQuery` of :class:`collections.OrderedDict` with \
keys of str and values of float
Keys being, in order: ``Administration``, ``Defense``,
``Educat... | [
"async",
"def",
"govt",
"(",
"self",
",",
"root",
")",
":",
"elem",
"=",
"root",
".",
"find",
"(",
"'GOVT'",
")",
"result",
"=",
"OrderedDict",
"(",
")",
"result",
"[",
"'Administration'",
"]",
"=",
"float",
"(",
"elem",
".",
"find",
"(",
"'ADMINISTR... | Nation's government expenditure, as percentages.
Returns
-------
an :class:`ApiQuery` of :class:`collections.OrderedDict` with \
keys of str and values of float
Keys being, in order: ``Administration``, ``Defense``,
``Education``, ``Environment``, ``Healthcare``,... | [
"Nation",
"s",
"government",
"expenditure",
"as",
"percentages",
"."
] | dc86b86d994cbab830b69ab8023601c73e778b3a | https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/nation_.py#L522-L549 |
39,594 | micha030201/aionationstates | aionationstates/nation_.py | Nation.sectors | async def sectors(self, root):
"""Components of the nation's economy, as percentages.
Returns
-------
an :class:`ApiQuery` of :class:`collections.OrderedDict` with \
keys of str and values of float
Keys being, in order: ``Black Market (estimated)``, ``Government``,
... | python | async def sectors(self, root):
"""Components of the nation's economy, as percentages.
Returns
-------
an :class:`ApiQuery` of :class:`collections.OrderedDict` with \
keys of str and values of float
Keys being, in order: ``Black Market (estimated)``, ``Government``,
... | [
"async",
"def",
"sectors",
"(",
"self",
",",
"root",
")",
":",
"elem",
"=",
"root",
".",
"find",
"(",
"'SECTORS'",
")",
"result",
"=",
"OrderedDict",
"(",
")",
"result",
"[",
"'Black Market (estimated)'",
"]",
"=",
"float",
"(",
"elem",
".",
"find",
"(... | Components of the nation's economy, as percentages.
Returns
-------
an :class:`ApiQuery` of :class:`collections.OrderedDict` with \
keys of str and values of float
Keys being, in order: ``Black Market (estimated)``, ``Government``,
``Private Industry``, and ``Sta... | [
"Components",
"of",
"the",
"nation",
"s",
"economy",
"as",
"percentages",
"."
] | dc86b86d994cbab830b69ab8023601c73e778b3a | https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/nation_.py#L552-L569 |
39,595 | micha030201/aionationstates | aionationstates/nation_.py | Nation.deaths | async def deaths(self, root):
"""Causes of death in the nation, as percentages.
Returns
-------
an :class:`ApiQuery` of dict with keys of str and values of float
"""
return {
elem.get('type'): float(elem.text)
for elem in root.find('DEATHS')
... | python | async def deaths(self, root):
"""Causes of death in the nation, as percentages.
Returns
-------
an :class:`ApiQuery` of dict with keys of str and values of float
"""
return {
elem.get('type'): float(elem.text)
for elem in root.find('DEATHS')
... | [
"async",
"def",
"deaths",
"(",
"self",
",",
"root",
")",
":",
"return",
"{",
"elem",
".",
"get",
"(",
"'type'",
")",
":",
"float",
"(",
"elem",
".",
"text",
")",
"for",
"elem",
"in",
"root",
".",
"find",
"(",
"'DEATHS'",
")",
"}"
] | Causes of death in the nation, as percentages.
Returns
-------
an :class:`ApiQuery` of dict with keys of str and values of float | [
"Causes",
"of",
"death",
"in",
"the",
"nation",
"as",
"percentages",
"."
] | dc86b86d994cbab830b69ab8023601c73e778b3a | https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/nation_.py#L572-L582 |
39,596 | micha030201/aionationstates | aionationstates/nation_.py | Nation.endorsements | async def endorsements(self, root):
"""Regional neighbours endorsing the nation.
Returns
-------
an :class:`ApiQuery` of a list of :class:`Nation`
"""
text = root.find('ENDORSEMENTS').text
return [Nation(name) for name in text.split(',')] if text else [] | python | async def endorsements(self, root):
"""Regional neighbours endorsing the nation.
Returns
-------
an :class:`ApiQuery` of a list of :class:`Nation`
"""
text = root.find('ENDORSEMENTS').text
return [Nation(name) for name in text.split(',')] if text else [] | [
"async",
"def",
"endorsements",
"(",
"self",
",",
"root",
")",
":",
"text",
"=",
"root",
".",
"find",
"(",
"'ENDORSEMENTS'",
")",
".",
"text",
"return",
"[",
"Nation",
"(",
"name",
")",
"for",
"name",
"in",
"text",
".",
"split",
"(",
"','",
")",
"]... | Regional neighbours endorsing the nation.
Returns
-------
an :class:`ApiQuery` of a list of :class:`Nation` | [
"Regional",
"neighbours",
"endorsing",
"the",
"nation",
"."
] | dc86b86d994cbab830b69ab8023601c73e778b3a | https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/nation_.py#L585-L593 |
39,597 | micha030201/aionationstates | aionationstates/nation_.py | Nation.description | async def description(self):
"""Nation's full description, as seen on its in-game page.
Returns
-------
an awaitable of str
"""
resp = await self._call_web(f'nation={self.id}')
return html.unescape(
re.search(
'<div class="nationsummar... | python | async def description(self):
"""Nation's full description, as seen on its in-game page.
Returns
-------
an awaitable of str
"""
resp = await self._call_web(f'nation={self.id}')
return html.unescape(
re.search(
'<div class="nationsummar... | [
"async",
"def",
"description",
"(",
"self",
")",
":",
"resp",
"=",
"await",
"self",
".",
"_call_web",
"(",
"f'nation={self.id}'",
")",
"return",
"html",
".",
"unescape",
"(",
"re",
".",
"search",
"(",
"'<div class=\"nationsummary\">(.+?)<p class=\"nationranktext\">'... | Nation's full description, as seen on its in-game page.
Returns
-------
an awaitable of str | [
"Nation",
"s",
"full",
"description",
"as",
"seen",
"on",
"its",
"in",
"-",
"game",
"page",
"."
] | dc86b86d994cbab830b69ab8023601c73e778b3a | https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/nation_.py#L716-L735 |
39,598 | micha030201/aionationstates | aionationstates/nation_.py | IssueOption.accept | def accept(self):
"""Accept the option.
Returns
-------
an awaitable of :class:`IssueResult`
"""
return self._issue._nation._accept_issue(self._issue.id, self._id) | python | def accept(self):
"""Accept the option.
Returns
-------
an awaitable of :class:`IssueResult`
"""
return self._issue._nation._accept_issue(self._issue.id, self._id) | [
"def",
"accept",
"(",
"self",
")",
":",
"return",
"self",
".",
"_issue",
".",
"_nation",
".",
"_accept_issue",
"(",
"self",
".",
"_issue",
".",
"id",
",",
"self",
".",
"_id",
")"
] | Accept the option.
Returns
-------
an awaitable of :class:`IssueResult` | [
"Accept",
"the",
"option",
"."
] | dc86b86d994cbab830b69ab8023601c73e778b3a | https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/nation_.py#L867-L874 |
39,599 | stephanh42/ipython_pip_magics | ipython_pip_magics/__init__.py | pip_upgrade_all | def pip_upgrade_all(line):
"""Attempt to upgrade all packages"""
from pip import get_installed_distributions
user = set(d.project_name for d in get_installed_distributions(user_only=True))
all = set(d.project_name for d in get_installed_distributions())
for dist in all - user:
do_pip(["insta... | python | def pip_upgrade_all(line):
"""Attempt to upgrade all packages"""
from pip import get_installed_distributions
user = set(d.project_name for d in get_installed_distributions(user_only=True))
all = set(d.project_name for d in get_installed_distributions())
for dist in all - user:
do_pip(["insta... | [
"def",
"pip_upgrade_all",
"(",
"line",
")",
":",
"from",
"pip",
"import",
"get_installed_distributions",
"user",
"=",
"set",
"(",
"d",
".",
"project_name",
"for",
"d",
"in",
"get_installed_distributions",
"(",
"user_only",
"=",
"True",
")",
")",
"all",
"=",
... | Attempt to upgrade all packages | [
"Attempt",
"to",
"upgrade",
"all",
"packages"
] | 4a56db4414dff4456158c53d9050a84e926f8b57 | https://github.com/stephanh42/ipython_pip_magics/blob/4a56db4414dff4456158c53d9050a84e926f8b57/ipython_pip_magics/__init__.py#L32-L40 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.