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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
240,700 | campbellr/smashrun-client | smashrun/client.py | Smashrun.get_polyline | def get_polyline(self, id_num, style='google'):
"""Return the polyline of the activity with the given id.
:param style: The type of polyline to return. May be one of
'google', 'svg', or 'geojson'.
"""
parts = ['my', 'activities', id_num, 'polyline']
if sty... | python | def get_polyline(self, id_num, style='google'):
"""Return the polyline of the activity with the given id.
:param style: The type of polyline to return. May be one of
'google', 'svg', or 'geojson'.
"""
parts = ['my', 'activities', id_num, 'polyline']
if sty... | [
"def",
"get_polyline",
"(",
"self",
",",
"id_num",
",",
"style",
"=",
"'google'",
")",
":",
"parts",
"=",
"[",
"'my'",
",",
"'activities'",
",",
"id_num",
",",
"'polyline'",
"]",
"if",
"style",
"!=",
"'google'",
":",
"parts",
".",
"append",
"(",
"style... | Return the polyline of the activity with the given id.
:param style: The type of polyline to return. May be one of
'google', 'svg', or 'geojson'. | [
"Return",
"the",
"polyline",
"of",
"the",
"activity",
"with",
"the",
"given",
"id",
"."
] | 2522cb4d0545cf482a49a9533f12aac94c5aecdc | https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L115-L127 |
240,701 | campbellr/smashrun-client | smashrun/client.py | Smashrun.get_splits | def get_splits(self, id_num, unit='mi'):
"""Return the splits of the activity with the given id.
:param unit: The unit to use for splits. May be one of
'mi' or 'km'.
"""
url = self._build_url('my', 'activities', id_num, 'splits', unit)
return self._json(u... | python | def get_splits(self, id_num, unit='mi'):
"""Return the splits of the activity with the given id.
:param unit: The unit to use for splits. May be one of
'mi' or 'km'.
"""
url = self._build_url('my', 'activities', id_num, 'splits', unit)
return self._json(u... | [
"def",
"get_splits",
"(",
"self",
",",
"id_num",
",",
"unit",
"=",
"'mi'",
")",
":",
"url",
"=",
"self",
".",
"_build_url",
"(",
"'my'",
",",
"'activities'",
",",
"id_num",
",",
"'splits'",
",",
"unit",
")",
"return",
"self",
".",
"_json",
"(",
"url"... | Return the splits of the activity with the given id.
:param unit: The unit to use for splits. May be one of
'mi' or 'km'. | [
"Return",
"the",
"splits",
"of",
"the",
"activity",
"with",
"the",
"given",
"id",
"."
] | 2522cb4d0545cf482a49a9533f12aac94c5aecdc | https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L129-L138 |
240,702 | campbellr/smashrun-client | smashrun/client.py | Smashrun.get_stats | def get_stats(self, year=None, month=None):
"""Return stats for the given year and month."""
parts = ['my', 'stats']
if month and not year:
raise ValueError("month cannot be specified without year")
if year:
parts.append(year)
if month:
parts.a... | python | def get_stats(self, year=None, month=None):
"""Return stats for the given year and month."""
parts = ['my', 'stats']
if month and not year:
raise ValueError("month cannot be specified without year")
if year:
parts.append(year)
if month:
parts.a... | [
"def",
"get_stats",
"(",
"self",
",",
"year",
"=",
"None",
",",
"month",
"=",
"None",
")",
":",
"parts",
"=",
"[",
"'my'",
",",
"'stats'",
"]",
"if",
"month",
"and",
"not",
"year",
":",
"raise",
"ValueError",
"(",
"\"month cannot be specified without year\... | Return stats for the given year and month. | [
"Return",
"stats",
"for",
"the",
"given",
"year",
"and",
"month",
"."
] | 2522cb4d0545cf482a49a9533f12aac94c5aecdc | https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L140-L150 |
240,703 | campbellr/smashrun-client | smashrun/client.py | Smashrun.create_weight | def create_weight(self, weight, date=None):
"""Submit a new weight record.
:param weight: The weight, in kilograms.
:param date: The date the weight was recorded. If not
specified, the current date will be used.
"""
url = self._build_url('my', 'body', 'weig... | python | def create_weight(self, weight, date=None):
"""Submit a new weight record.
:param weight: The weight, in kilograms.
:param date: The date the weight was recorded. If not
specified, the current date will be used.
"""
url = self._build_url('my', 'body', 'weig... | [
"def",
"create_weight",
"(",
"self",
",",
"weight",
",",
"date",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_build_url",
"(",
"'my'",
",",
"'body'",
",",
"'weight'",
")",
"data",
"=",
"{",
"'weightInKilograms'",
":",
"weight",
"}",
"if",
"date",
... | Submit a new weight record.
:param weight: The weight, in kilograms.
:param date: The date the weight was recorded. If not
specified, the current date will be used. | [
"Submit",
"a",
"new",
"weight",
"record",
"."
] | 2522cb4d0545cf482a49a9533f12aac94c5aecdc | https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L167-L184 |
240,704 | kyan001/PyConsoleIOTools | consoleiotools.py | pause | def pause(msg="Press Enter to Continue..."):
"""press to continue"""
print('\n' + Fore.YELLOW + msg + Fore.RESET, end='')
input() | python | def pause(msg="Press Enter to Continue..."):
"""press to continue"""
print('\n' + Fore.YELLOW + msg + Fore.RESET, end='')
input() | [
"def",
"pause",
"(",
"msg",
"=",
"\"Press Enter to Continue...\"",
")",
":",
"print",
"(",
"'\\n'",
"+",
"Fore",
".",
"YELLOW",
"+",
"msg",
"+",
"Fore",
".",
"RESET",
",",
"end",
"=",
"''",
")",
"input",
"(",
")"
] | press to continue | [
"press",
"to",
"continue"
] | cc0cc2b9caf62a0fd1a9a72952a6f8c4d17694c4 | https://github.com/kyan001/PyConsoleIOTools/blob/cc0cc2b9caf62a0fd1a9a72952a6f8c4d17694c4/consoleiotools.py#L76-L79 |
240,705 | fangpenlin/pyramid-handy | pyramid_handy/tweens/allow_origin.py | allow_origin_tween_factory | def allow_origin_tween_factory(handler, registry):
"""Allow cross origin XHR requests
"""
def allow_origin_tween(request):
settings = request.registry.settings
request_origin = request.headers.get('origin')
def is_origin_allowed(origin):
allowed_origins = (
... | python | def allow_origin_tween_factory(handler, registry):
"""Allow cross origin XHR requests
"""
def allow_origin_tween(request):
settings = request.registry.settings
request_origin = request.headers.get('origin')
def is_origin_allowed(origin):
allowed_origins = (
... | [
"def",
"allow_origin_tween_factory",
"(",
"handler",
",",
"registry",
")",
":",
"def",
"allow_origin_tween",
"(",
"request",
")",
":",
"settings",
"=",
"request",
".",
"registry",
".",
"settings",
"request_origin",
"=",
"request",
".",
"headers",
".",
"get",
"... | Allow cross origin XHR requests | [
"Allow",
"cross",
"origin",
"XHR",
"requests"
] | e3cbc19224ab1f0a14aab556990bceabd2d1f658 | https://github.com/fangpenlin/pyramid-handy/blob/e3cbc19224ab1f0a14aab556990bceabd2d1f658/pyramid_handy/tweens/allow_origin.py#L6-L70 |
240,706 | fr33jc/bang | bang/providers/hpcloud/reddwarf.py | DBSecurityGroupRules.create | def create(self, dbsecgroup_id, source_cidr, port=3306):
"""
Creates a security group rule.
:param str dbsecgroup_id: The ID of the security group in which this
rule should be created.
:param str source_cidr: The source IP address range from which access
should... | python | def create(self, dbsecgroup_id, source_cidr, port=3306):
"""
Creates a security group rule.
:param str dbsecgroup_id: The ID of the security group in which this
rule should be created.
:param str source_cidr: The source IP address range from which access
should... | [
"def",
"create",
"(",
"self",
",",
"dbsecgroup_id",
",",
"source_cidr",
",",
"port",
"=",
"3306",
")",
":",
"body",
"=",
"{",
"\"security_group_rule\"",
":",
"{",
"\"security_group_id\"",
":",
"dbsecgroup_id",
",",
"\"cidr\"",
":",
"source_cidr",
",",
"\"from_... | Creates a security group rule.
:param str dbsecgroup_id: The ID of the security group in which this
rule should be created.
:param str source_cidr: The source IP address range from which access
should be allowed.
:param int port: The port number used by db clients to ... | [
"Creates",
"a",
"security",
"group",
"rule",
"."
] | 8f000713f88d2a9a8c1193b63ca10a6578560c16 | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/hpcloud/reddwarf.py#L65-L89 |
240,707 | dusty-phillips/opterator | examples/cp.py | main | def main(filename1, filename2, recursive=False, backup=False,
suffix='~', *other_filenames):
'''An example copy script with some example parameters that might
be used in a file or directory copy command.
:param recursive: -r --recursive copy directories
recursively
:param backup: -b --... | python | def main(filename1, filename2, recursive=False, backup=False,
suffix='~', *other_filenames):
'''An example copy script with some example parameters that might
be used in a file or directory copy command.
:param recursive: -r --recursive copy directories
recursively
:param backup: -b --... | [
"def",
"main",
"(",
"filename1",
",",
"filename2",
",",
"recursive",
"=",
"False",
",",
"backup",
"=",
"False",
",",
"suffix",
"=",
"'~'",
",",
"*",
"other_filenames",
")",
":",
"filenames",
"=",
"[",
"filename1",
",",
"filename2",
"]",
"+",
"list",
"(... | An example copy script with some example parameters that might
be used in a file or directory copy command.
:param recursive: -r --recursive copy directories
recursively
:param backup: -b --backup backup any files you copy over
:param suffix: -S --suffix override the usual backup
suffix | [
"An",
"example",
"copy",
"script",
"with",
"some",
"example",
"parameters",
"that",
"might",
"be",
"used",
"in",
"a",
"file",
"or",
"directory",
"copy",
"command",
"."
] | 84fe31f22c73dc0a3666ed82c179461b1799c257 | https://github.com/dusty-phillips/opterator/blob/84fe31f22c73dc0a3666ed82c179461b1799c257/examples/cp.py#L5-L23 |
240,708 | emin63/eyap | eyap/core/github_comments.py | GitHubCommentGroup.parse_date | def parse_date(my_date):
"""Parse a date into canonical format of datetime.dateime.
:param my_date: Either datetime.datetime or string in
'%Y-%m-%dT%H:%M:%SZ' format.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
:return: A datetime.datetime.
... | python | def parse_date(my_date):
"""Parse a date into canonical format of datetime.dateime.
:param my_date: Either datetime.datetime or string in
'%Y-%m-%dT%H:%M:%SZ' format.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
:return: A datetime.datetime.
... | [
"def",
"parse_date",
"(",
"my_date",
")",
":",
"if",
"isinstance",
"(",
"my_date",
",",
"datetime",
".",
"datetime",
")",
":",
"result",
"=",
"my_date",
"elif",
"isinstance",
"(",
"my_date",
",",
"str",
")",
":",
"result",
"=",
"datetime",
".",
"datetime... | Parse a date into canonical format of datetime.dateime.
:param my_date: Either datetime.datetime or string in
'%Y-%m-%dT%H:%M:%SZ' format.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
:return: A datetime.datetime.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-... | [
"Parse",
"a",
"date",
"into",
"canonical",
"format",
"of",
"datetime",
".",
"dateime",
"."
] | a610761973b478ca0e864e970be05ce29d5994a5 | https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L70-L94 |
240,709 | emin63/eyap | eyap/core/github_comments.py | GitHubCommentGroup.get_thread_info | def get_thread_info(self, enforce_re=True, latest_date=None):
"""Return a json list with information about threads in the group.
:param enforce_re=True: Whether to require titles to match
regexp in self.topic_re.
:param latest_date=None: Opti... | python | def get_thread_info(self, enforce_re=True, latest_date=None):
"""Return a json list with information about threads in the group.
:param enforce_re=True: Whether to require titles to match
regexp in self.topic_re.
:param latest_date=None: Opti... | [
"def",
"get_thread_info",
"(",
"self",
",",
"enforce_re",
"=",
"True",
",",
"latest_date",
"=",
"None",
")",
":",
"result",
"=",
"[",
"]",
"my_re",
"=",
"re",
".",
"compile",
"(",
"self",
".",
"topic_re",
")",
"url",
"=",
"'%s/issues?sort=updated'",
"%",... | Return a json list with information about threads in the group.
:param enforce_re=True: Whether to require titles to match
regexp in self.topic_re.
:param latest_date=None: Optional datetime.datetime for latest
... | [
"Return",
"a",
"json",
"list",
"with",
"information",
"about",
"threads",
"in",
"the",
"group",
"."
] | a610761973b478ca0e864e970be05ce29d5994a5 | https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L96-L147 |
240,710 | emin63/eyap | eyap/core/github_comments.py | GitHubCommentGroup.export | def export(self, out_filename):
"""Export desired threads as a zipfile to out_filename.
"""
with zipfile.ZipFile(out_filename, 'w', zipfile.ZIP_DEFLATED) as arc:
id_list = list(self.get_thread_info())
for num, my_info in enumerate(id_list):
logging.info('W... | python | def export(self, out_filename):
"""Export desired threads as a zipfile to out_filename.
"""
with zipfile.ZipFile(out_filename, 'w', zipfile.ZIP_DEFLATED) as arc:
id_list = list(self.get_thread_info())
for num, my_info in enumerate(id_list):
logging.info('W... | [
"def",
"export",
"(",
"self",
",",
"out_filename",
")",
":",
"with",
"zipfile",
".",
"ZipFile",
"(",
"out_filename",
",",
"'w'",
",",
"zipfile",
".",
"ZIP_DEFLATED",
")",
"as",
"arc",
":",
"id_list",
"=",
"list",
"(",
"self",
".",
"get_thread_info",
"(",... | Export desired threads as a zipfile to out_filename. | [
"Export",
"desired",
"threads",
"as",
"a",
"zipfile",
"to",
"out_filename",
"."
] | a610761973b478ca0e864e970be05ce29d5994a5 | https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L149-L164 |
240,711 | emin63/eyap | eyap/core/github_comments.py | GitHubCommentThread.sleep_if_necessary | def sleep_if_necessary(cls, user, token, endpoint='search', msg=''):
"""Sleep a little if hit github recently to honor rate limit.
"""
my_kw = {'auth': (user, token)} if user else {}
info = requests.get('https://api.github.com/rate_limit', **my_kw)
info_dict = info.json()
... | python | def sleep_if_necessary(cls, user, token, endpoint='search', msg=''):
"""Sleep a little if hit github recently to honor rate limit.
"""
my_kw = {'auth': (user, token)} if user else {}
info = requests.get('https://api.github.com/rate_limit', **my_kw)
info_dict = info.json()
... | [
"def",
"sleep_if_necessary",
"(",
"cls",
",",
"user",
",",
"token",
",",
"endpoint",
"=",
"'search'",
",",
"msg",
"=",
"''",
")",
":",
"my_kw",
"=",
"{",
"'auth'",
":",
"(",
"user",
",",
"token",
")",
"}",
"if",
"user",
"else",
"{",
"}",
"info",
... | Sleep a little if hit github recently to honor rate limit. | [
"Sleep",
"a",
"little",
"if",
"hit",
"github",
"recently",
"to",
"honor",
"rate",
"limit",
"."
] | a610761973b478ca0e864e970be05ce29d5994a5 | https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L217-L236 |
240,712 | emin63/eyap | eyap/core/github_comments.py | GitHubCommentThread.update_cache_key | def update_cache_key(cls, cache_key, item=None):
"""Get item in cache for cache_key and add item if item is not None.
"""
contents = cls.__thread_id_cache.get(cache_key, None)
if item is not None:
cls.__thread_id_cache[cache_key] = item
return contents | python | def update_cache_key(cls, cache_key, item=None):
"""Get item in cache for cache_key and add item if item is not None.
"""
contents = cls.__thread_id_cache.get(cache_key, None)
if item is not None:
cls.__thread_id_cache[cache_key] = item
return contents | [
"def",
"update_cache_key",
"(",
"cls",
",",
"cache_key",
",",
"item",
"=",
"None",
")",
":",
"contents",
"=",
"cls",
".",
"__thread_id_cache",
".",
"get",
"(",
"cache_key",
",",
"None",
")",
"if",
"item",
"is",
"not",
"None",
":",
"cls",
".",
"__thread... | Get item in cache for cache_key and add item if item is not None. | [
"Get",
"item",
"in",
"cache",
"for",
"cache_key",
"and",
"add",
"item",
"if",
"item",
"is",
"not",
"None",
"."
] | a610761973b478ca0e864e970be05ce29d5994a5 | https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L239-L246 |
240,713 | emin63/eyap | eyap/core/github_comments.py | GitHubCommentThread.lookup_thread_id | def lookup_thread_id(self):
"""Lookup thread id as required by CommentThread.lookup_thread_id.
This implementation will query GitHub with the required parameters
to try and find the topic for the owner, realm, topic, etc., specified
in init.
"""
query_string = 'in:title... | python | def lookup_thread_id(self):
"""Lookup thread id as required by CommentThread.lookup_thread_id.
This implementation will query GitHub with the required parameters
to try and find the topic for the owner, realm, topic, etc., specified
in init.
"""
query_string = 'in:title... | [
"def",
"lookup_thread_id",
"(",
"self",
")",
":",
"query_string",
"=",
"'in:title \"%s\" repo:%s/%s'",
"%",
"(",
"self",
".",
"topic",
",",
"self",
".",
"owner",
",",
"self",
".",
"realm",
")",
"cache_key",
"=",
"(",
"self",
".",
"owner",
",",
"self",
".... | Lookup thread id as required by CommentThread.lookup_thread_id.
This implementation will query GitHub with the required parameters
to try and find the topic for the owner, realm, topic, etc., specified
in init. | [
"Lookup",
"thread",
"id",
"as",
"required",
"by",
"CommentThread",
".",
"lookup_thread_id",
"."
] | a610761973b478ca0e864e970be05ce29d5994a5 | https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L254-L300 |
240,714 | emin63/eyap | eyap/core/github_comments.py | GitHubCommentThread.raw_search | def raw_search(cls, user, token, query, page=0):
"""Do a raw search for github issues.
:arg user: Username to use in accessing github.
:arg token: Token to use in accessing github.
:arg query: String query to use in searching github.
:arg page=0: Numbe... | python | def raw_search(cls, user, token, query, page=0):
"""Do a raw search for github issues.
:arg user: Username to use in accessing github.
:arg token: Token to use in accessing github.
:arg query: String query to use in searching github.
:arg page=0: Numbe... | [
"def",
"raw_search",
"(",
"cls",
",",
"user",
",",
"token",
",",
"query",
",",
"page",
"=",
"0",
")",
":",
"page",
"=",
"int",
"(",
"page",
")",
"kwargs",
"=",
"{",
"}",
"if",
"not",
"user",
"else",
"{",
"'auth'",
":",
"(",
"user",
",",
"token"... | Do a raw search for github issues.
:arg user: Username to use in accessing github.
:arg token: Token to use in accessing github.
:arg query: String query to use in searching github.
:arg page=0: Number of pages to automatically paginate.
~-~-~-~-~-~-~... | [
"Do",
"a",
"raw",
"search",
"for",
"github",
"issues",
"."
] | a610761973b478ca0e864e970be05ce29d5994a5 | https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L303-L354 |
240,715 | emin63/eyap | eyap/core/github_comments.py | GitHubCommentThread.raw_pull | def raw_pull(self, topic):
"""Do a raw pull of data for given topic down from github.
:arg topic: String topic (i.e., issue title).
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
:returns: Result of request data from github API.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~... | python | def raw_pull(self, topic):
"""Do a raw pull of data for given topic down from github.
:arg topic: String topic (i.e., issue title).
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
:returns: Result of request data from github API.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~... | [
"def",
"raw_pull",
"(",
"self",
",",
"topic",
")",
":",
"assert",
"topic",
"is",
"not",
"None",
",",
"'A topic of None is not allowed'",
"kwargs",
"=",
"{",
"}",
"if",
"not",
"self",
".",
"user",
"else",
"{",
"'auth'",
":",
"(",
"self",
".",
"user",
",... | Do a raw pull of data for given topic down from github.
:arg topic: String topic (i.e., issue title).
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
:returns: Result of request data from github API.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
PURPO... | [
"Do",
"a",
"raw",
"pull",
"of",
"data",
"for",
"given",
"topic",
"down",
"from",
"github",
"."
] | a610761973b478ca0e864e970be05ce29d5994a5 | https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L356-L374 |
240,716 | emin63/eyap | eyap/core/github_comments.py | GitHubCommentThread.lookup_comment_list | def lookup_comment_list(self):
"""Lookup list of comments for an issue.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
:returns: The pair (ISSUE, COMMENTS) where ISSUE is a dict for the
main issue and COMMENTS is a list of comments on the issue.
~-~-~-~-~-~... | python | def lookup_comment_list(self):
"""Lookup list of comments for an issue.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
:returns: The pair (ISSUE, COMMENTS) where ISSUE is a dict for the
main issue and COMMENTS is a list of comments on the issue.
~-~-~-~-~-~... | [
"def",
"lookup_comment_list",
"(",
"self",
")",
":",
"if",
"self",
".",
"thread_id",
"is",
"None",
":",
"return",
"None",
",",
"None",
"# Just pulling a single issue here so pagination shouldn't be problem",
"my_req",
"=",
"self",
".",
"raw_pull",
"(",
"self",
".",
... | Lookup list of comments for an issue.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
:returns: The pair (ISSUE, COMMENTS) where ISSUE is a dict for the
main issue and COMMENTS is a list of comments on the issue.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~... | [
"Lookup",
"list",
"of",
"comments",
"for",
"an",
"issue",
"."
] | a610761973b478ca0e864e970be05ce29d5994a5 | https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L376-L417 |
240,717 | emin63/eyap | eyap/core/github_comments.py | GitHubCommentThread.add_comment | def add_comment(self, body, allow_create=False, allow_hashes=True,
summary=None, hash_create=False):
"""Implement as required by CommentThread.add_comment.
:arg body: String/text of comment to add.
:arg allow_create=False: Whether to automatically create a new thread
... | python | def add_comment(self, body, allow_create=False, allow_hashes=True,
summary=None, hash_create=False):
"""Implement as required by CommentThread.add_comment.
:arg body: String/text of comment to add.
:arg allow_create=False: Whether to automatically create a new thread
... | [
"def",
"add_comment",
"(",
"self",
",",
"body",
",",
"allow_create",
"=",
"False",
",",
"allow_hashes",
"=",
"True",
",",
"summary",
"=",
"None",
",",
"hash_create",
"=",
"False",
")",
":",
"if",
"self",
".",
"thread_id",
"is",
"None",
":",
"self",
"."... | Implement as required by CommentThread.add_comment.
:arg body: String/text of comment to add.
:arg allow_create=False: Whether to automatically create a new thread
if a thread does not exist (usually by calling
self.create_thread).
... | [
"Implement",
"as",
"required",
"by",
"CommentThread",
".",
"add_comment",
"."
] | a610761973b478ca0e864e970be05ce29d5994a5 | https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L445-L504 |
240,718 | emin63/eyap | eyap/core/github_comments.py | GitHubCommentThread.process_hashes | def process_hashes(self, body, allow_create=False):
"""Process any hashes mentioned and push them to related topics.
:arg body: Body of the comment to check for hashes and push out.
:arg allow_create=False: Whether to allow creating new topics
from hash ta... | python | def process_hashes(self, body, allow_create=False):
"""Process any hashes mentioned and push them to related topics.
:arg body: Body of the comment to check for hashes and push out.
:arg allow_create=False: Whether to allow creating new topics
from hash ta... | [
"def",
"process_hashes",
"(",
"self",
",",
"body",
",",
"allow_create",
"=",
"False",
")",
":",
"hash_re",
"=",
"re",
".",
"compile",
"(",
"self",
".",
"hashtag_re",
")",
"hashes",
"=",
"hash_re",
".",
"findall",
"(",
"body",
")",
"done",
"=",
"{",
"... | Process any hashes mentioned and push them to related topics.
:arg body: Body of the comment to check for hashes and push out.
:arg allow_create=False: Whether to allow creating new topics
from hash tag mentions.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-... | [
"Process",
"any",
"hashes",
"mentioned",
"and",
"push",
"them",
"to",
"related",
"topics",
"."
] | a610761973b478ca0e864e970be05ce29d5994a5 | https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L506-L534 |
240,719 | emin63/eyap | eyap/core/github_comments.py | GitHubCommentThread.upload_attachment | def upload_attachment(self, location, data):
"""Upload attachment as required by CommentThread class.
See CommentThread.upload_attachment for details.
"""
self.validate_attachment_location(location)
content = data.read() if hasattr(data, 'read') else data
orig_content = ... | python | def upload_attachment(self, location, data):
"""Upload attachment as required by CommentThread class.
See CommentThread.upload_attachment for details.
"""
self.validate_attachment_location(location)
content = data.read() if hasattr(data, 'read') else data
orig_content = ... | [
"def",
"upload_attachment",
"(",
"self",
",",
"location",
",",
"data",
")",
":",
"self",
".",
"validate_attachment_location",
"(",
"location",
")",
"content",
"=",
"data",
".",
"read",
"(",
")",
"if",
"hasattr",
"(",
"data",
",",
"'read'",
")",
"else",
"... | Upload attachment as required by CommentThread class.
See CommentThread.upload_attachment for details. | [
"Upload",
"attachment",
"as",
"required",
"by",
"CommentThread",
"class",
"."
] | a610761973b478ca0e864e970be05ce29d5994a5 | https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L547-L570 |
240,720 | stevepeak/tornpsql | tornpsql/__init__.py | _Connection._reconnect | def _reconnect(self):
"""Closes the existing database connection and re-opens it."""
self.close()
self._db = psycopg2.connect(**self._db_args)
if self._search_path:
self.execute('set search_path=%s;' % self._search_path)
if self._timezone:
self.execute("... | python | def _reconnect(self):
"""Closes the existing database connection and re-opens it."""
self.close()
self._db = psycopg2.connect(**self._db_args)
if self._search_path:
self.execute('set search_path=%s;' % self._search_path)
if self._timezone:
self.execute("... | [
"def",
"_reconnect",
"(",
"self",
")",
":",
"self",
".",
"close",
"(",
")",
"self",
".",
"_db",
"=",
"psycopg2",
".",
"connect",
"(",
"*",
"*",
"self",
".",
"_db_args",
")",
"if",
"self",
".",
"_search_path",
":",
"self",
".",
"execute",
"(",
"'set... | Closes the existing database connection and re-opens it. | [
"Closes",
"the",
"existing",
"database",
"connection",
"and",
"re",
"-",
"opens",
"it",
"."
] | a109d0f95d6432d0e3b5eba1c9854357ba527f27 | https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L134-L143 |
240,721 | stevepeak/tornpsql | tornpsql/__init__.py | _Connection._reregister_types | def _reregister_types(self):
"""Registers existing types for a new connection"""
for _type in self._register_types:
psycopg2.extensions.register_type(psycopg2.extensions.new_type(*_type)) | python | def _reregister_types(self):
"""Registers existing types for a new connection"""
for _type in self._register_types:
psycopg2.extensions.register_type(psycopg2.extensions.new_type(*_type)) | [
"def",
"_reregister_types",
"(",
"self",
")",
":",
"for",
"_type",
"in",
"self",
".",
"_register_types",
":",
"psycopg2",
".",
"extensions",
".",
"register_type",
"(",
"psycopg2",
".",
"extensions",
".",
"new_type",
"(",
"*",
"_type",
")",
")"
] | Registers existing types for a new connection | [
"Registers",
"existing",
"types",
"for",
"a",
"new",
"connection"
] | a109d0f95d6432d0e3b5eba1c9854357ba527f27 | https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L145-L148 |
240,722 | stevepeak/tornpsql | tornpsql/__init__.py | _Connection.register_type | def register_type(self, oids, name, casting):
"""Callback to register data types when reconnect
"""
assert type(oids) is tuple
assert isinstance(name, basestring)
assert hasattr(casting, '__call__')
self._register_types.append((oids, name, casting))
psycopg2.exten... | python | def register_type(self, oids, name, casting):
"""Callback to register data types when reconnect
"""
assert type(oids) is tuple
assert isinstance(name, basestring)
assert hasattr(casting, '__call__')
self._register_types.append((oids, name, casting))
psycopg2.exten... | [
"def",
"register_type",
"(",
"self",
",",
"oids",
",",
"name",
",",
"casting",
")",
":",
"assert",
"type",
"(",
"oids",
")",
"is",
"tuple",
"assert",
"isinstance",
"(",
"name",
",",
"basestring",
")",
"assert",
"hasattr",
"(",
"casting",
",",
"'__call__'... | Callback to register data types when reconnect | [
"Callback",
"to",
"register",
"data",
"types",
"when",
"reconnect"
] | a109d0f95d6432d0e3b5eba1c9854357ba527f27 | https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L158-L165 |
240,723 | stevepeak/tornpsql | tornpsql/__init__.py | _Connection.query | def query(self, query, *parameters, **kwargs):
"""Returns a row list for the given query and parameters."""
cursor = self._cursor()
try:
self._execute(cursor, query, parameters or None, kwargs)
if cursor.description:
column_names = [column.name for column ... | python | def query(self, query, *parameters, **kwargs):
"""Returns a row list for the given query and parameters."""
cursor = self._cursor()
try:
self._execute(cursor, query, parameters or None, kwargs)
if cursor.description:
column_names = [column.name for column ... | [
"def",
"query",
"(",
"self",
",",
"query",
",",
"*",
"parameters",
",",
"*",
"*",
"kwargs",
")",
":",
"cursor",
"=",
"self",
".",
"_cursor",
"(",
")",
"try",
":",
"self",
".",
"_execute",
"(",
"cursor",
",",
"query",
",",
"parameters",
"or",
"None"... | Returns a row list for the given query and parameters. | [
"Returns",
"a",
"row",
"list",
"for",
"the",
"given",
"query",
"and",
"parameters",
"."
] | a109d0f95d6432d0e3b5eba1c9854357ba527f27 | https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L187-L199 |
240,724 | stevepeak/tornpsql | tornpsql/__init__.py | _Connection.iter | def iter(self, query, *parameters, **kwargs):
"""Returns a generator for records from the query."""
cursor = self._cursor()
try:
self._execute(cursor, query, parameters or None, kwargs)
if cursor.description:
column_names = [column.name for column in curso... | python | def iter(self, query, *parameters, **kwargs):
"""Returns a generator for records from the query."""
cursor = self._cursor()
try:
self._execute(cursor, query, parameters or None, kwargs)
if cursor.description:
column_names = [column.name for column in curso... | [
"def",
"iter",
"(",
"self",
",",
"query",
",",
"*",
"parameters",
",",
"*",
"*",
"kwargs",
")",
":",
"cursor",
"=",
"self",
".",
"_cursor",
"(",
")",
"try",
":",
"self",
".",
"_execute",
"(",
"cursor",
",",
"query",
",",
"parameters",
"or",
"None",... | Returns a generator for records from the query. | [
"Returns",
"a",
"generator",
"for",
"records",
"from",
"the",
"query",
"."
] | a109d0f95d6432d0e3b5eba1c9854357ba527f27 | https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L201-L217 |
240,725 | stevepeak/tornpsql | tornpsql/__init__.py | _Connection.execute | def execute(self, query, *parameters, **kwargs):
"""Same as query, but do not process results. Always returns `None`."""
cursor = self._cursor()
try:
self._execute(cursor, query, parameters, kwargs)
except:
raise
finally:
cursor.close() | python | def execute(self, query, *parameters, **kwargs):
"""Same as query, but do not process results. Always returns `None`."""
cursor = self._cursor()
try:
self._execute(cursor, query, parameters, kwargs)
except:
raise
finally:
cursor.close() | [
"def",
"execute",
"(",
"self",
",",
"query",
",",
"*",
"parameters",
",",
"*",
"*",
"kwargs",
")",
":",
"cursor",
"=",
"self",
".",
"_cursor",
"(",
")",
"try",
":",
"self",
".",
"_execute",
"(",
"cursor",
",",
"query",
",",
"parameters",
",",
"kwar... | Same as query, but do not process results. Always returns `None`. | [
"Same",
"as",
"query",
"but",
"do",
"not",
"process",
"results",
".",
"Always",
"returns",
"None",
"."
] | a109d0f95d6432d0e3b5eba1c9854357ba527f27 | https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L219-L229 |
240,726 | stevepeak/tornpsql | tornpsql/__init__.py | _Connection.get | def get(self, query, *parameters, **kwargs):
"""Returns the first row returned for the given query."""
rows = self.query(query, *parameters, **kwargs)
if not rows:
return None
elif len(rows) > 1:
raise ValueError('Multiple rows returned for get() query')
e... | python | def get(self, query, *parameters, **kwargs):
"""Returns the first row returned for the given query."""
rows = self.query(query, *parameters, **kwargs)
if not rows:
return None
elif len(rows) > 1:
raise ValueError('Multiple rows returned for get() query')
e... | [
"def",
"get",
"(",
"self",
",",
"query",
",",
"*",
"parameters",
",",
"*",
"*",
"kwargs",
")",
":",
"rows",
"=",
"self",
".",
"query",
"(",
"query",
",",
"*",
"parameters",
",",
"*",
"*",
"kwargs",
")",
"if",
"not",
"rows",
":",
"return",
"None",... | Returns the first row returned for the given query. | [
"Returns",
"the",
"first",
"row",
"returned",
"for",
"the",
"given",
"query",
"."
] | a109d0f95d6432d0e3b5eba1c9854357ba527f27 | https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L231-L239 |
240,727 | stevepeak/tornpsql | tornpsql/__init__.py | _Connection.executemany | def executemany(self, query, *parameters):
"""Executes the given query against all the given param sequences.
"""
cursor = self._cursor()
try:
self._executemany(cursor, query, parameters)
if cursor.description:
column_names = [column.name for colum... | python | def executemany(self, query, *parameters):
"""Executes the given query against all the given param sequences.
"""
cursor = self._cursor()
try:
self._executemany(cursor, query, parameters)
if cursor.description:
column_names = [column.name for colum... | [
"def",
"executemany",
"(",
"self",
",",
"query",
",",
"*",
"parameters",
")",
":",
"cursor",
"=",
"self",
".",
"_cursor",
"(",
")",
"try",
":",
"self",
".",
"_executemany",
"(",
"cursor",
",",
"query",
",",
"parameters",
")",
"if",
"cursor",
".",
"de... | Executes the given query against all the given param sequences. | [
"Executes",
"the",
"given",
"query",
"against",
"all",
"the",
"given",
"param",
"sequences",
"."
] | a109d0f95d6432d0e3b5eba1c9854357ba527f27 | https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L241-L255 |
240,728 | MacHu-GWU/pyknackhq-project | pyknackhq/zzz_manual_install.py | install | def install():
"""Install your package to all Python version you have installed on Windows.
"""
import os, shutil
_ROOT = os.getcwd()
_PACKAGE_NAME = os.path.basename(_ROOT)
print("Installing [%s] to all python version..." % _PACKAGE_NAME)
# find all Python release installed on thi... | python | def install():
"""Install your package to all Python version you have installed on Windows.
"""
import os, shutil
_ROOT = os.getcwd()
_PACKAGE_NAME = os.path.basename(_ROOT)
print("Installing [%s] to all python version..." % _PACKAGE_NAME)
# find all Python release installed on thi... | [
"def",
"install",
"(",
")",
":",
"import",
"os",
",",
"shutil",
"_ROOT",
"=",
"os",
".",
"getcwd",
"(",
")",
"_PACKAGE_NAME",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"_ROOT",
")",
"print",
"(",
"\"Installing [%s] to all python version...\"",
"%",
"_P... | Install your package to all Python version you have installed on Windows. | [
"Install",
"your",
"package",
"to",
"all",
"Python",
"version",
"you",
"have",
"installed",
"on",
"Windows",
"."
] | dd937f24d7b0a351ba3818eb746c31b29a8cc341 | https://github.com/MacHu-GWU/pyknackhq-project/blob/dd937f24d7b0a351ba3818eb746c31b29a8cc341/pyknackhq/zzz_manual_install.py#L100-L141 |
240,729 | romaryd/python-jsonrepo | jsonrepo/record.py | namedtuple_asdict | def namedtuple_asdict(obj):
"""
Serializing a nested namedtuple into a Python dict
"""
if obj is None:
return obj
if hasattr(obj, "_asdict"): # detect namedtuple
return OrderedDict(zip(obj._fields, (namedtuple_asdict(item)
for item in obj... | python | def namedtuple_asdict(obj):
"""
Serializing a nested namedtuple into a Python dict
"""
if obj is None:
return obj
if hasattr(obj, "_asdict"): # detect namedtuple
return OrderedDict(zip(obj._fields, (namedtuple_asdict(item)
for item in obj... | [
"def",
"namedtuple_asdict",
"(",
"obj",
")",
":",
"if",
"obj",
"is",
"None",
":",
"return",
"obj",
"if",
"hasattr",
"(",
"obj",
",",
"\"_asdict\"",
")",
":",
"# detect namedtuple",
"return",
"OrderedDict",
"(",
"zip",
"(",
"obj",
".",
"_fields",
",",
"("... | Serializing a nested namedtuple into a Python dict | [
"Serializing",
"a",
"nested",
"namedtuple",
"into",
"a",
"Python",
"dict"
] | 08a9c039a5bd21e93e9a6d1bce77d43e6e10b57d | https://github.com/romaryd/python-jsonrepo/blob/08a9c039a5bd21e93e9a6d1bce77d43e6e10b57d/jsonrepo/record.py#L11-L28 |
240,730 | romaryd/python-jsonrepo | jsonrepo/record.py | DictRecord.from_json | def from_json(cls, json_dump):
"""
How to get a context from a json dump
"""
context = cls()
if json_dump is None:
return None
ctxt = json.loads(json_dump)
for k in ctxt:
context[k] = ctxt[k]
return context | python | def from_json(cls, json_dump):
"""
How to get a context from a json dump
"""
context = cls()
if json_dump is None:
return None
ctxt = json.loads(json_dump)
for k in ctxt:
context[k] = ctxt[k]
return context | [
"def",
"from_json",
"(",
"cls",
",",
"json_dump",
")",
":",
"context",
"=",
"cls",
"(",
")",
"if",
"json_dump",
"is",
"None",
":",
"return",
"None",
"ctxt",
"=",
"json",
".",
"loads",
"(",
"json_dump",
")",
"for",
"k",
"in",
"ctxt",
":",
"context",
... | How to get a context from a json dump | [
"How",
"to",
"get",
"a",
"context",
"from",
"a",
"json",
"dump"
] | 08a9c039a5bd21e93e9a6d1bce77d43e6e10b57d | https://github.com/romaryd/python-jsonrepo/blob/08a9c039a5bd21e93e9a6d1bce77d43e6e10b57d/jsonrepo/record.py#L54-L64 |
240,731 | klmitch/tendril | tendril/manager.py | TendrilManager.find_tendril | def find_tendril(cls, proto, addr):
"""
Finds the tendril corresponding to the protocol and address
tuple. Returns the Tendril object, or raises KeyError if the
tendril is not tracked.
The address tuple is the tuple of the local address and the
remote address for the te... | python | def find_tendril(cls, proto, addr):
"""
Finds the tendril corresponding to the protocol and address
tuple. Returns the Tendril object, or raises KeyError if the
tendril is not tracked.
The address tuple is the tuple of the local address and the
remote address for the te... | [
"def",
"find_tendril",
"(",
"cls",
",",
"proto",
",",
"addr",
")",
":",
"# First, normalize the proto",
"proto",
"=",
"proto",
".",
"lower",
"(",
")",
"# Now, find and return the tendril",
"return",
"cls",
".",
"_tendrils",
"[",
"proto",
"]",
"[",
"addr",
"]"
... | Finds the tendril corresponding to the protocol and address
tuple. Returns the Tendril object, or raises KeyError if the
tendril is not tracked.
The address tuple is the tuple of the local address and the
remote address for the tendril. | [
"Finds",
"the",
"tendril",
"corresponding",
"to",
"the",
"protocol",
"and",
"address",
"tuple",
".",
"Returns",
"the",
"Tendril",
"object",
"or",
"raises",
"KeyError",
"if",
"the",
"tendril",
"is",
"not",
"tracked",
"."
] | 207102c83e88f8f1fa7ba605ef0aab2ae9078b36 | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/manager.py#L99-L113 |
240,732 | klmitch/tendril | tendril/manager.py | TendrilManager._track_tendril | def _track_tendril(self, tendril):
"""
Adds the tendril to the set of tracked tendrils.
"""
self.tendrils[tendril._tendril_key] = tendril
# Also add to _tendrils
self._tendrils.setdefault(tendril.proto, weakref.WeakValueDictionary())
self._tendrils[tendril.proto... | python | def _track_tendril(self, tendril):
"""
Adds the tendril to the set of tracked tendrils.
"""
self.tendrils[tendril._tendril_key] = tendril
# Also add to _tendrils
self._tendrils.setdefault(tendril.proto, weakref.WeakValueDictionary())
self._tendrils[tendril.proto... | [
"def",
"_track_tendril",
"(",
"self",
",",
"tendril",
")",
":",
"self",
".",
"tendrils",
"[",
"tendril",
".",
"_tendril_key",
"]",
"=",
"tendril",
"# Also add to _tendrils",
"self",
".",
"_tendrils",
".",
"setdefault",
"(",
"tendril",
".",
"proto",
",",
"wea... | Adds the tendril to the set of tracked tendrils. | [
"Adds",
"the",
"tendril",
"to",
"the",
"set",
"of",
"tracked",
"tendrils",
"."
] | 207102c83e88f8f1fa7ba605ef0aab2ae9078b36 | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/manager.py#L173-L182 |
240,733 | klmitch/tendril | tendril/manager.py | TendrilManager._untrack_tendril | def _untrack_tendril(self, tendril):
"""
Removes the tendril from the set of tracked tendrils.
"""
try:
del self.tendrils[tendril._tendril_key]
except KeyError:
pass
# Also remove from _tendrils
try:
del self._tendrils[tendril... | python | def _untrack_tendril(self, tendril):
"""
Removes the tendril from the set of tracked tendrils.
"""
try:
del self.tendrils[tendril._tendril_key]
except KeyError:
pass
# Also remove from _tendrils
try:
del self._tendrils[tendril... | [
"def",
"_untrack_tendril",
"(",
"self",
",",
"tendril",
")",
":",
"try",
":",
"del",
"self",
".",
"tendrils",
"[",
"tendril",
".",
"_tendril_key",
"]",
"except",
"KeyError",
":",
"pass",
"# Also remove from _tendrils",
"try",
":",
"del",
"self",
".",
"_tendr... | Removes the tendril from the set of tracked tendrils. | [
"Removes",
"the",
"tendril",
"from",
"the",
"set",
"of",
"tracked",
"tendrils",
"."
] | 207102c83e88f8f1fa7ba605ef0aab2ae9078b36 | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/manager.py#L184-L198 |
240,734 | klmitch/tendril | tendril/manager.py | TendrilManager.get_local_addr | def get_local_addr(self, timeout=None):
"""
Retrieve the current local address.
:param timeout: If not given or given as ``None``, waits until
the local address is available. Otherwise,
waits for as long as specified. If the local
... | python | def get_local_addr(self, timeout=None):
"""
Retrieve the current local address.
:param timeout: If not given or given as ``None``, waits until
the local address is available. Otherwise,
waits for as long as specified. If the local
... | [
"def",
"get_local_addr",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"# If we're not running, just return None",
"if",
"not",
"self",
".",
"running",
":",
"return",
"None",
"# OK, we're running; wait on the _local_addr_event",
"if",
"not",
"self",
".",
"_local... | Retrieve the current local address.
:param timeout: If not given or given as ``None``, waits until
the local address is available. Otherwise,
waits for as long as specified. If the local
address is not set by the time the timeout
... | [
"Retrieve",
"the",
"current",
"local",
"address",
"."
] | 207102c83e88f8f1fa7ba605ef0aab2ae9078b36 | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/manager.py#L291-L312 |
240,735 | klmitch/tendril | tendril/manager.py | TendrilManager.connect | def connect(self, target, acceptor, wrapper=None):
"""
Initiate a connection from the tendril manager's endpoint.
Once the connection is completed, a Tendril object will be
created and passed to the given acceptor.
:param target: The target of the connection attempt.
:pa... | python | def connect(self, target, acceptor, wrapper=None):
"""
Initiate a connection from the tendril manager's endpoint.
Once the connection is completed, a Tendril object will be
created and passed to the given acceptor.
:param target: The target of the connection attempt.
:pa... | [
"def",
"connect",
"(",
"self",
",",
"target",
",",
"acceptor",
",",
"wrapper",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"running",
":",
"raise",
"ValueError",
"(",
"\"TendrilManager not running\"",
")",
"# Check the target address",
"fam",
"=",
"utils"... | Initiate a connection from the tendril manager's endpoint.
Once the connection is completed, a Tendril object will be
created and passed to the given acceptor.
:param target: The target of the connection attempt.
:param acceptor: A callable which will initialize the state of
... | [
"Initiate",
"a",
"connection",
"from",
"the",
"tendril",
"manager",
"s",
"endpoint",
".",
"Once",
"the",
"connection",
"is",
"completed",
"a",
"Tendril",
"object",
"will",
"be",
"created",
"and",
"passed",
"to",
"the",
"given",
"acceptor",
"."
] | 207102c83e88f8f1fa7ba605ef0aab2ae9078b36 | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/manager.py#L341-L369 |
240,736 | bagrat/pyerarchy | pyerarchy/core/node.py | Node.read | def read(self, *args, **kwargs):
"""Reads the node as a file
"""
with self.open('r') as f:
return f.read(*args, **kwargs) | python | def read(self, *args, **kwargs):
"""Reads the node as a file
"""
with self.open('r') as f:
return f.read(*args, **kwargs) | [
"def",
"read",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"self",
".",
"open",
"(",
"'r'",
")",
"as",
"f",
":",
"return",
"f",
".",
"read",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Reads the node as a file | [
"Reads",
"the",
"node",
"as",
"a",
"file"
] | 75d71408af72c583b104d27ac02fbe164354ee91 | https://github.com/bagrat/pyerarchy/blob/75d71408af72c583b104d27ac02fbe164354ee91/pyerarchy/core/node.py#L43-L47 |
240,737 | bagrat/pyerarchy | pyerarchy/core/node.py | Node.ls | def ls(self):
"""List the children entities of the directory.
Raises exception if the object is a file.
:return:
"""
if self.isfile():
raise NotDirectoryError('Cannot ls() on non-directory node: {path}'.format(path=self._pyerarchy_path))
return os.listdir(s... | python | def ls(self):
"""List the children entities of the directory.
Raises exception if the object is a file.
:return:
"""
if self.isfile():
raise NotDirectoryError('Cannot ls() on non-directory node: {path}'.format(path=self._pyerarchy_path))
return os.listdir(s... | [
"def",
"ls",
"(",
"self",
")",
":",
"if",
"self",
".",
"isfile",
"(",
")",
":",
"raise",
"NotDirectoryError",
"(",
"'Cannot ls() on non-directory node: {path}'",
".",
"format",
"(",
"path",
"=",
"self",
".",
"_pyerarchy_path",
")",
")",
"return",
"os",
".",
... | List the children entities of the directory.
Raises exception if the object is a file.
:return: | [
"List",
"the",
"children",
"entities",
"of",
"the",
"directory",
"."
] | 75d71408af72c583b104d27ac02fbe164354ee91 | https://github.com/bagrat/pyerarchy/blob/75d71408af72c583b104d27ac02fbe164354ee91/pyerarchy/core/node.py#L54-L64 |
240,738 | bagrat/pyerarchy | pyerarchy/core/node.py | Node.mkdir | def mkdir(self, children, mode=0o0755, return_node=True):
"""Creates child entities in directory.
Raises exception if the object is a file.
:param children: The list of children to be created.
:return: The child object, if one child is provided. None, otherwise.
"""
res... | python | def mkdir(self, children, mode=0o0755, return_node=True):
"""Creates child entities in directory.
Raises exception if the object is a file.
:param children: The list of children to be created.
:return: The child object, if one child is provided. None, otherwise.
"""
res... | [
"def",
"mkdir",
"(",
"self",
",",
"children",
",",
"mode",
"=",
"0o0755",
",",
"return_node",
"=",
"True",
")",
":",
"result",
"=",
"None",
"if",
"isinstance",
"(",
"children",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"if",
"os",
".",
"path"... | Creates child entities in directory.
Raises exception if the object is a file.
:param children: The list of children to be created.
:return: The child object, if one child is provided. None, otherwise. | [
"Creates",
"child",
"entities",
"in",
"directory",
"."
] | 75d71408af72c583b104d27ac02fbe164354ee91 | https://github.com/bagrat/pyerarchy/blob/75d71408af72c583b104d27ac02fbe164354ee91/pyerarchy/core/node.py#L75-L98 |
240,739 | sxslex/capitalize-name | capitalize_name/__init__.py | capitalize | def capitalize(
full_name,
articles=None,
separator_characters=None,
ignore_worls=None,
):
"""Returns the correct writing of a compound name, respecting the
first letters of the names in upper case."""
if articles is None:
articles = _ARTICLES
if separator_characters is None:
... | python | def capitalize(
full_name,
articles=None,
separator_characters=None,
ignore_worls=None,
):
"""Returns the correct writing of a compound name, respecting the
first letters of the names in upper case."""
if articles is None:
articles = _ARTICLES
if separator_characters is None:
... | [
"def",
"capitalize",
"(",
"full_name",
",",
"articles",
"=",
"None",
",",
"separator_characters",
"=",
"None",
",",
"ignore_worls",
"=",
"None",
",",
")",
":",
"if",
"articles",
"is",
"None",
":",
"articles",
"=",
"_ARTICLES",
"if",
"separator_characters",
"... | Returns the correct writing of a compound name, respecting the
first letters of the names in upper case. | [
"Returns",
"the",
"correct",
"writing",
"of",
"a",
"compound",
"name",
"respecting",
"the",
"first",
"letters",
"of",
"the",
"names",
"in",
"upper",
"case",
"."
] | 98f288a3cffaecdb8aaee5154e783ba46849bccd | https://github.com/sxslex/capitalize-name/blob/98f288a3cffaecdb8aaee5154e783ba46849bccd/capitalize_name/__init__.py#L28-L69 |
240,740 | sxslex/capitalize-name | capitalize_name/__init__.py | deep_unicode | def deep_unicode(s, encodings=None):
"""decode "DEEP" S using the codec registered for encoding."""
if encodings is None:
encodings = ['utf-8', 'latin-1']
if isinstance(s, (list, tuple)):
return [deep_unicode(i) for i in s]
if isinstance(s, dict):
return dict([
(deep_... | python | def deep_unicode(s, encodings=None):
"""decode "DEEP" S using the codec registered for encoding."""
if encodings is None:
encodings = ['utf-8', 'latin-1']
if isinstance(s, (list, tuple)):
return [deep_unicode(i) for i in s]
if isinstance(s, dict):
return dict([
(deep_... | [
"def",
"deep_unicode",
"(",
"s",
",",
"encodings",
"=",
"None",
")",
":",
"if",
"encodings",
"is",
"None",
":",
"encodings",
"=",
"[",
"'utf-8'",
",",
"'latin-1'",
"]",
"if",
"isinstance",
"(",
"s",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"r... | decode "DEEP" S using the codec registered for encoding. | [
"decode",
"DEEP",
"S",
"using",
"the",
"codec",
"registered",
"for",
"encoding",
"."
] | 98f288a3cffaecdb8aaee5154e783ba46849bccd | https://github.com/sxslex/capitalize-name/blob/98f288a3cffaecdb8aaee5154e783ba46849bccd/capitalize_name/__init__.py#L86-L107 |
240,741 | sxslex/capitalize-name | capitalize_name/__init__.py | deep_encode | def deep_encode(s, encoding='utf-8', errors='strict'):
"""Encode "DEEP" S using the codec registered for encoding."""
# encoding defaults to the default encoding. errors may be given to set
# a different error handling scheme. Default is 'strict' meaning
# that encoding errors raise
# a UnicodeEncod... | python | def deep_encode(s, encoding='utf-8', errors='strict'):
"""Encode "DEEP" S using the codec registered for encoding."""
# encoding defaults to the default encoding. errors may be given to set
# a different error handling scheme. Default is 'strict' meaning
# that encoding errors raise
# a UnicodeEncod... | [
"def",
"deep_encode",
"(",
"s",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"# encoding defaults to the default encoding. errors may be given to set",
"# a different error handling scheme. Default is 'strict' meaning",
"# that encoding errors raise",
... | Encode "DEEP" S using the codec registered for encoding. | [
"Encode",
"DEEP",
"S",
"using",
"the",
"codec",
"registered",
"for",
"encoding",
"."
] | 98f288a3cffaecdb8aaee5154e783ba46849bccd | https://github.com/sxslex/capitalize-name/blob/98f288a3cffaecdb8aaee5154e783ba46849bccd/capitalize_name/__init__.py#L110-L136 |
240,742 | bretth/djset | djset/djset.py | DjBase.namespace | def namespace(self, key, glob=False):
"""Return a namespace for keyring"""
if not self.name:
self.name = os.environ['DJANGO_SETTINGS_MODULE']
ns = '.'.join([key, self._glob]) if glob else '.'.join([self.name, self._glob])
return ns | python | def namespace(self, key, glob=False):
"""Return a namespace for keyring"""
if not self.name:
self.name = os.environ['DJANGO_SETTINGS_MODULE']
ns = '.'.join([key, self._glob]) if glob else '.'.join([self.name, self._glob])
return ns | [
"def",
"namespace",
"(",
"self",
",",
"key",
",",
"glob",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"name",
":",
"self",
".",
"name",
"=",
"os",
".",
"environ",
"[",
"'DJANGO_SETTINGS_MODULE'",
"]",
"ns",
"=",
"'.'",
".",
"join",
"(",
"[",
... | Return a namespace for keyring | [
"Return",
"a",
"namespace",
"for",
"keyring"
] | e04cbcadc311f6edec50a718415d0004aa304034 | https://github.com/bretth/djset/blob/e04cbcadc311f6edec50a718415d0004aa304034/djset/djset.py#L31-L36 |
240,743 | bretth/djset | djset/djset.py | DjBase.get | def get(self, key, prompt_default='', prompt_help=''):
"""Return a value from the environ or keyring"""
value = os.getenv(key)
if not value:
ns = self.namespace(key)
value = self.keyring.get_password(ns, key)
else:
ns = 'environ'
if not value... | python | def get(self, key, prompt_default='', prompt_help=''):
"""Return a value from the environ or keyring"""
value = os.getenv(key)
if not value:
ns = self.namespace(key)
value = self.keyring.get_password(ns, key)
else:
ns = 'environ'
if not value... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"prompt_default",
"=",
"''",
",",
"prompt_help",
"=",
"''",
")",
":",
"value",
"=",
"os",
".",
"getenv",
"(",
"key",
")",
"if",
"not",
"value",
":",
"ns",
"=",
"self",
".",
"namespace",
"(",
"key",
")",... | Return a value from the environ or keyring | [
"Return",
"a",
"value",
"from",
"the",
"environ",
"or",
"keyring"
] | e04cbcadc311f6edec50a718415d0004aa304034 | https://github.com/bretth/djset/blob/e04cbcadc311f6edec50a718415d0004aa304034/djset/djset.py#L38-L57 |
240,744 | bretth/djset | djset/djset.py | DjBase.set | def set(self, key, value, glob=False):
"""Set the key value pair in a local or global namespace"""
ns = self.namespace(key, glob)
self.keyring.set_password(ns, key, value) | python | def set(self, key, value, glob=False):
"""Set the key value pair in a local or global namespace"""
ns = self.namespace(key, glob)
self.keyring.set_password(ns, key, value) | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
",",
"glob",
"=",
"False",
")",
":",
"ns",
"=",
"self",
".",
"namespace",
"(",
"key",
",",
"glob",
")",
"self",
".",
"keyring",
".",
"set_password",
"(",
"ns",
",",
"key",
",",
"value",
")"
] | Set the key value pair in a local or global namespace | [
"Set",
"the",
"key",
"value",
"pair",
"in",
"a",
"local",
"or",
"global",
"namespace"
] | e04cbcadc311f6edec50a718415d0004aa304034 | https://github.com/bretth/djset/blob/e04cbcadc311f6edec50a718415d0004aa304034/djset/djset.py#L59-L62 |
240,745 | bretth/djset | djset/djset.py | DjBase.remove | def remove(self, key, glob=False):
"""Remove key value pair in a local or global namespace."""
ns = self.namespace(key, glob)
try:
self.keyring.delete_password(ns, key)
except PasswordDeleteError: # OSX and gnome have no delete method
self.set(key, '', glob) | python | def remove(self, key, glob=False):
"""Remove key value pair in a local or global namespace."""
ns = self.namespace(key, glob)
try:
self.keyring.delete_password(ns, key)
except PasswordDeleteError: # OSX and gnome have no delete method
self.set(key, '', glob) | [
"def",
"remove",
"(",
"self",
",",
"key",
",",
"glob",
"=",
"False",
")",
":",
"ns",
"=",
"self",
".",
"namespace",
"(",
"key",
",",
"glob",
")",
"try",
":",
"self",
".",
"keyring",
".",
"delete_password",
"(",
"ns",
",",
"key",
")",
"except",
"P... | Remove key value pair in a local or global namespace. | [
"Remove",
"key",
"value",
"pair",
"in",
"a",
"local",
"or",
"global",
"namespace",
"."
] | e04cbcadc311f6edec50a718415d0004aa304034 | https://github.com/bretth/djset/blob/e04cbcadc311f6edec50a718415d0004aa304034/djset/djset.py#L64-L70 |
240,746 | bretth/djset | djset/djset.py | DjSecret.get | def get(self, key, prompt_default='', prompt_help=''):
"""
Return the value for key from the environment or keyring.
The keyring value is resolved from a local namespace or a global one.
"""
value = super(DjSecret, self).get(key, prompt_default, prompt_help='')
if not val... | python | def get(self, key, prompt_default='', prompt_help=''):
"""
Return the value for key from the environment or keyring.
The keyring value is resolved from a local namespace or a global one.
"""
value = super(DjSecret, self).get(key, prompt_default, prompt_help='')
if not val... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"prompt_default",
"=",
"''",
",",
"prompt_help",
"=",
"''",
")",
":",
"value",
"=",
"super",
"(",
"DjSecret",
",",
"self",
")",
".",
"get",
"(",
"key",
",",
"prompt_default",
",",
"prompt_help",
"=",
"''",
... | Return the value for key from the environment or keyring.
The keyring value is resolved from a local namespace or a global one. | [
"Return",
"the",
"value",
"for",
"key",
"from",
"the",
"environment",
"or",
"keyring",
".",
"The",
"keyring",
"value",
"is",
"resolved",
"from",
"a",
"local",
"namespace",
"or",
"a",
"global",
"one",
"."
] | e04cbcadc311f6edec50a718415d0004aa304034 | https://github.com/bretth/djset/blob/e04cbcadc311f6edec50a718415d0004aa304034/djset/djset.py#L88-L97 |
240,747 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | PygWidgetsButton.draw | def draw(self):
"""Draws the button in its current state.
Should be called every time through the main loop
"""
if not self.visible:
return
# Blit the button's current appearance to the surface.
if self.isEnabled:
if self.mouseIsDown:... | python | def draw(self):
"""Draws the button in its current state.
Should be called every time through the main loop
"""
if not self.visible:
return
# Blit the button's current appearance to the surface.
if self.isEnabled:
if self.mouseIsDown:... | [
"def",
"draw",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"visible",
":",
"return",
"# Blit the button's current appearance to the surface.\r",
"if",
"self",
".",
"isEnabled",
":",
"if",
"self",
".",
"mouseIsDown",
":",
"if",
"self",
".",
"mouseOverButton"... | Draws the button in its current state.
Should be called every time through the main loop | [
"Draws",
"the",
"button",
"in",
"its",
"current",
"state",
".",
"Should",
"be",
"called",
"every",
"time",
"through",
"the",
"main",
"loop"
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L444-L467 |
240,748 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | PygWidgetsButton._debug | def _debug(self):
"""This is just for debugging, so we can see what buttons would be drawn.
Not intended to be used in production."""
self.window.blit(self.surfaceUp, (self.loc[0], 10))
self.window.blit(self.surfaceOver, (self.loc[0], 60))
self.window.blit(self.surfaceDown... | python | def _debug(self):
"""This is just for debugging, so we can see what buttons would be drawn.
Not intended to be used in production."""
self.window.blit(self.surfaceUp, (self.loc[0], 10))
self.window.blit(self.surfaceOver, (self.loc[0], 60))
self.window.blit(self.surfaceDown... | [
"def",
"_debug",
"(",
"self",
")",
":",
"self",
".",
"window",
".",
"blit",
"(",
"self",
".",
"surfaceUp",
",",
"(",
"self",
".",
"loc",
"[",
"0",
"]",
",",
"10",
")",
")",
"self",
".",
"window",
".",
"blit",
"(",
"self",
".",
"surfaceOver",
",... | This is just for debugging, so we can see what buttons would be drawn.
Not intended to be used in production. | [
"This",
"is",
"just",
"for",
"debugging",
"so",
"we",
"can",
"see",
"what",
"buttons",
"would",
"be",
"drawn",
".",
"Not",
"intended",
"to",
"be",
"used",
"in",
"production",
"."
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L470-L477 |
240,749 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | PygWidgetsCheckBox.draw | def draw(self):
"""Draws the checkbox."""
if not self.visible:
return
# Blit the current checkbox's image.
if self.isEnabled:
if self.mouseIsDown and self.lastMouseDownOverButton and self.mouseOverButton:
if self.value:
... | python | def draw(self):
"""Draws the checkbox."""
if not self.visible:
return
# Blit the current checkbox's image.
if self.isEnabled:
if self.mouseIsDown and self.lastMouseDownOverButton and self.mouseOverButton:
if self.value:
... | [
"def",
"draw",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"visible",
":",
"return",
"# Blit the current checkbox's image.\r",
"if",
"self",
".",
"isEnabled",
":",
"if",
"self",
".",
"mouseIsDown",
"and",
"self",
".",
"lastMouseDownOverButton",
"and",
"se... | Draws the checkbox. | [
"Draws",
"the",
"checkbox",
"."
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L839-L863 |
240,750 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | PygWidgetsRadioButton.getSelectedRadioButton | def getSelectedRadioButton(self):
"""Returns the nickname of the currently selected radio button."""
radioButtonListInGroup = PygWidgetsRadioButton.__PygWidgets__Radio__Buttons__Groups__Dicts__[self.group]
for radioButton in radioButtonListInGroup:
if radioButton.getValue():
... | python | def getSelectedRadioButton(self):
"""Returns the nickname of the currently selected radio button."""
radioButtonListInGroup = PygWidgetsRadioButton.__PygWidgets__Radio__Buttons__Groups__Dicts__[self.group]
for radioButton in radioButtonListInGroup:
if radioButton.getValue():
... | [
"def",
"getSelectedRadioButton",
"(",
"self",
")",
":",
"radioButtonListInGroup",
"=",
"PygWidgetsRadioButton",
".",
"__PygWidgets__Radio__Buttons__Groups__Dicts__",
"[",
"self",
".",
"group",
"]",
"for",
"radioButton",
"in",
"radioButtonListInGroup",
":",
"if",
"radioBut... | Returns the nickname of the currently selected radio button. | [
"Returns",
"the",
"nickname",
"of",
"the",
"currently",
"selected",
"radio",
"button",
"."
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L1248-L1256 |
240,751 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | PygWidgetsRadioButton.enableGroup | def enableGroup(self):
"""Enables all radio buttons in the group."""
radioButtonListInGroup = PygWidgetsRadioButton.__PygWidgets__Radio__Buttons__Groups__Dicts__[self.group]
for radioButton in radioButtonListInGroup:
radioButton.enable() | python | def enableGroup(self):
"""Enables all radio buttons in the group."""
radioButtonListInGroup = PygWidgetsRadioButton.__PygWidgets__Radio__Buttons__Groups__Dicts__[self.group]
for radioButton in radioButtonListInGroup:
radioButton.enable() | [
"def",
"enableGroup",
"(",
"self",
")",
":",
"radioButtonListInGroup",
"=",
"PygWidgetsRadioButton",
".",
"__PygWidgets__Radio__Buttons__Groups__Dicts__",
"[",
"self",
".",
"group",
"]",
"for",
"radioButton",
"in",
"radioButtonListInGroup",
":",
"radioButton",
".",
"ena... | Enables all radio buttons in the group. | [
"Enables",
"all",
"radio",
"buttons",
"in",
"the",
"group",
"."
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L1289-L1293 |
240,752 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | PygWidgetsRadioButton.disableGroup | def disableGroup(self):
"""Disables all radio buttons in the group"""
radioButtonListInGroup = PygWidgetsRadioButton.__PygWidgets__Radio__Buttons__Groups__Dicts__[self.group]
for radioButton in radioButtonListInGroup:
radioButton.disable() | python | def disableGroup(self):
"""Disables all radio buttons in the group"""
radioButtonListInGroup = PygWidgetsRadioButton.__PygWidgets__Radio__Buttons__Groups__Dicts__[self.group]
for radioButton in radioButtonListInGroup:
radioButton.disable() | [
"def",
"disableGroup",
"(",
"self",
")",
":",
"radioButtonListInGroup",
"=",
"PygWidgetsRadioButton",
".",
"__PygWidgets__Radio__Buttons__Groups__Dicts__",
"[",
"self",
".",
"group",
"]",
"for",
"radioButton",
"in",
"radioButtonListInGroup",
":",
"radioButton",
".",
"di... | Disables all radio buttons in the group | [
"Disables",
"all",
"radio",
"buttons",
"in",
"the",
"group"
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L1301-L1305 |
240,753 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | DisplayText.draw | def draw(self):
"""Draws the current text in the window"""
if not self.visible:
return
self.window.blit(self.textImage, self.loc) | python | def draw(self):
"""Draws the current text in the window"""
if not self.visible:
return
self.window.blit(self.textImage, self.loc) | [
"def",
"draw",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"visible",
":",
"return",
"self",
".",
"window",
".",
"blit",
"(",
"self",
".",
"textImage",
",",
"self",
".",
"loc",
")"
] | Draws the current text in the window | [
"Draws",
"the",
"current",
"text",
"in",
"the",
"window"
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L1678-L1683 |
240,754 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | InputText._updateImage | def _updateImage(self):
"""Internal method to render text as an image."""
# Fill the background of the image
if self.backgroundColor is not None:
self.textImage.fill(self.backgroundColor)
# Render the text as a single line, and blit it onto the textImage surface
... | python | def _updateImage(self):
"""Internal method to render text as an image."""
# Fill the background of the image
if self.backgroundColor is not None:
self.textImage.fill(self.backgroundColor)
# Render the text as a single line, and blit it onto the textImage surface
... | [
"def",
"_updateImage",
"(",
"self",
")",
":",
"# Fill the background of the image\r",
"if",
"self",
".",
"backgroundColor",
"is",
"not",
"None",
":",
"self",
".",
"textImage",
".",
"fill",
"(",
"self",
".",
"backgroundColor",
")",
"# Render the text as a single line... | Internal method to render text as an image. | [
"Internal",
"method",
"to",
"render",
"text",
"as",
"an",
"image",
"."
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L1783-L1796 |
240,755 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | InputText.draw | def draw(self):
"""Draws the Text in the window."""
if not self.visible:
return
# If this input text has focus, draw an outline around the text image
if self.focus:
pygame.draw.rect(self.window, self.focusColor, self.focusedImageRect, 1)
# Blit ... | python | def draw(self):
"""Draws the Text in the window."""
if not self.visible:
return
# If this input text has focus, draw an outline around the text image
if self.focus:
pygame.draw.rect(self.window, self.focusColor, self.focusedImageRect, 1)
# Blit ... | [
"def",
"draw",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"visible",
":",
"return",
"# If this input text has focus, draw an outline around the text image\r",
"if",
"self",
".",
"focus",
":",
"pygame",
".",
"draw",
".",
"rect",
"(",
"self",
".",
"window",
... | Draws the Text in the window. | [
"Draws",
"the",
"Text",
"in",
"the",
"window",
"."
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L1924-L1951 |
240,756 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | InputText.setValue | def setValue(self, newText):
"""Sets new text into the field"""
self.text = newText
self.cursorPosition = len(self.text)
self._updateImage() | python | def setValue(self, newText):
"""Sets new text into the field"""
self.text = newText
self.cursorPosition = len(self.text)
self._updateImage() | [
"def",
"setValue",
"(",
"self",
",",
"newText",
")",
":",
"self",
".",
"text",
"=",
"newText",
"self",
".",
"cursorPosition",
"=",
"len",
"(",
"self",
".",
"text",
")",
"self",
".",
"_updateImage",
"(",
")"
] | Sets new text into the field | [
"Sets",
"new",
"text",
"into",
"the",
"field"
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L1963-L1967 |
240,757 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | InputText.clearText | def clearText(self, keepFocus=False):
"""Clear the text in the field"""
self.text = ''
self.focus = keepFocus
self._updateImage() | python | def clearText(self, keepFocus=False):
"""Clear the text in the field"""
self.text = ''
self.focus = keepFocus
self._updateImage() | [
"def",
"clearText",
"(",
"self",
",",
"keepFocus",
"=",
"False",
")",
":",
"self",
".",
"text",
"=",
"''",
"self",
".",
"focus",
"=",
"keepFocus",
"self",
".",
"_updateImage",
"(",
")"
] | Clear the text in the field | [
"Clear",
"the",
"text",
"in",
"the",
"field"
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L1977-L1981 |
240,758 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | Dragger.resetToPreviousLoc | def resetToPreviousLoc(self):
"""Resets the loc of the dragger to place where dragging started.
This could be used in a test situation if the dragger was dragged to an incorrect location.
"""
self.rect.left = self.startDraggingX
self.rect.top = self.startDraggingY | python | def resetToPreviousLoc(self):
"""Resets the loc of the dragger to place where dragging started.
This could be used in a test situation if the dragger was dragged to an incorrect location.
"""
self.rect.left = self.startDraggingX
self.rect.top = self.startDraggingY | [
"def",
"resetToPreviousLoc",
"(",
"self",
")",
":",
"self",
".",
"rect",
".",
"left",
"=",
"self",
".",
"startDraggingX",
"self",
".",
"rect",
".",
"top",
"=",
"self",
".",
"startDraggingY"
] | Resets the loc of the dragger to place where dragging started.
This could be used in a test situation if the dragger was dragged to an incorrect location. | [
"Resets",
"the",
"loc",
"of",
"the",
"dragger",
"to",
"place",
"where",
"dragging",
"started",
".",
"This",
"could",
"be",
"used",
"in",
"a",
"test",
"situation",
"if",
"the",
"dragger",
"was",
"dragged",
"to",
"an",
"incorrect",
"location",
"."
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L2124-L2131 |
240,759 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | Dragger.draw | def draw(self):
"""Draws the dragger at the current mouse location.
Should be called in every frame.
"""
if not self.visible:
return
if self.isEnabled:
# Draw the dragger's current appearance to the window.
if self.dragg... | python | def draw(self):
"""Draws the dragger at the current mouse location.
Should be called in every frame.
"""
if not self.visible:
return
if self.isEnabled:
# Draw the dragger's current appearance to the window.
if self.dragg... | [
"def",
"draw",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"visible",
":",
"return",
"if",
"self",
".",
"isEnabled",
":",
"# Draw the dragger's current appearance to the window.\r",
"if",
"self",
".",
"dragging",
":",
"self",
".",
"window",
".",
"blit",
... | Draws the dragger at the current mouse location.
Should be called in every frame. | [
"Draws",
"the",
"dragger",
"at",
"the",
"current",
"mouse",
"location",
".",
"Should",
"be",
"called",
"in",
"every",
"frame",
"."
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L2133-L2153 |
240,760 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | Image.flipHorizontal | def flipHorizontal(self):
""" flips an image object horizontally
"""
self.flipH = not self.flipH
self._transmogrophy(self.angle, self.percent, self.scaleFromCenter, self.flipH, self.flipV) | python | def flipHorizontal(self):
""" flips an image object horizontally
"""
self.flipH = not self.flipH
self._transmogrophy(self.angle, self.percent, self.scaleFromCenter, self.flipH, self.flipV) | [
"def",
"flipHorizontal",
"(",
"self",
")",
":",
"self",
".",
"flipH",
"=",
"not",
"self",
".",
"flipH",
"self",
".",
"_transmogrophy",
"(",
"self",
".",
"angle",
",",
"self",
".",
"percent",
",",
"self",
".",
"scaleFromCenter",
",",
"self",
".",
"flipH... | flips an image object horizontally | [
"flips",
"an",
"image",
"object",
"horizontally"
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L2205-L2210 |
240,761 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | Image.flipVertical | def flipVertical(self):
""" flips an image object vertically
"""
self.flipV = not self.flipV
self._transmogrophy(self.angle, self.percent, self.scaleFromCenter, self.flipH, self.flipV) | python | def flipVertical(self):
""" flips an image object vertically
"""
self.flipV = not self.flipV
self._transmogrophy(self.angle, self.percent, self.scaleFromCenter, self.flipH, self.flipV) | [
"def",
"flipVertical",
"(",
"self",
")",
":",
"self",
".",
"flipV",
"=",
"not",
"self",
".",
"flipV",
"self",
".",
"_transmogrophy",
"(",
"self",
".",
"angle",
",",
"self",
".",
"percent",
",",
"self",
".",
"scaleFromCenter",
",",
"self",
".",
"flipH",... | flips an image object vertically | [
"flips",
"an",
"image",
"object",
"vertically"
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L2212-L2217 |
240,762 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | Image._transmogrophy | def _transmogrophy(self, angle, percent, scaleFromCenter, flipH, flipV):
'''
Internal method to scale and rotate
'''
self.angle = angle % 360
self.percent = percent
self.scaleFromCenter = scaleFromCenter
previousRect = self.rect
previousCente... | python | def _transmogrophy(self, angle, percent, scaleFromCenter, flipH, flipV):
'''
Internal method to scale and rotate
'''
self.angle = angle % 360
self.percent = percent
self.scaleFromCenter = scaleFromCenter
previousRect = self.rect
previousCente... | [
"def",
"_transmogrophy",
"(",
"self",
",",
"angle",
",",
"percent",
",",
"scaleFromCenter",
",",
"flipH",
",",
"flipV",
")",
":",
"self",
".",
"angle",
"=",
"angle",
"%",
"360",
"self",
".",
"percent",
"=",
"percent",
"self",
".",
"scaleFromCenter",
"=",... | Internal method to scale and rotate | [
"Internal",
"method",
"to",
"scale",
"and",
"rotate"
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L2258-L2301 |
240,763 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | Image.draw | def draw(self):
"""Draws the image at the given location."""
if not self.visible:
return
self.window.blit(self.image, self.loc) | python | def draw(self):
"""Draws the image at the given location."""
if not self.visible:
return
self.window.blit(self.image, self.loc) | [
"def",
"draw",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"visible",
":",
"return",
"self",
".",
"window",
".",
"blit",
"(",
"self",
".",
"image",
",",
"self",
".",
"loc",
")"
] | Draws the image at the given location. | [
"Draws",
"the",
"image",
"at",
"the",
"given",
"location",
"."
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L2304-L2309 |
240,764 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | PygAnimation.play | def play(self):
"""Starts an animation playing."""
if self.state == PygAnimation.PLAYING:
pass # nothing to do
elif self.state == PygAnimation.STOPPED: # restart from beginning of animation
self.index = 0 # first image in list
self.elapsed = 0
... | python | def play(self):
"""Starts an animation playing."""
if self.state == PygAnimation.PLAYING:
pass # nothing to do
elif self.state == PygAnimation.STOPPED: # restart from beginning of animation
self.index = 0 # first image in list
self.elapsed = 0
... | [
"def",
"play",
"(",
"self",
")",
":",
"if",
"self",
".",
"state",
"==",
"PygAnimation",
".",
"PLAYING",
":",
"pass",
"# nothing to do\r",
"elif",
"self",
".",
"state",
"==",
"PygAnimation",
".",
"STOPPED",
":",
"# restart from beginning of animation\r",
"self",
... | Starts an animation playing. | [
"Starts",
"an",
"animation",
"playing",
"."
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L2471-L2490 |
240,765 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | PygAnimation.stop | def stop(self):
"""Stops a a playing animation. A subsequent call to play will start from the beginning."""
if self.state == PygAnimation.PLAYING:
self.index = 0 # set up for first image in list
self.elapsed = 0
self.nIterationsLeft = 0
elif self.sta... | python | def stop(self):
"""Stops a a playing animation. A subsequent call to play will start from the beginning."""
if self.state == PygAnimation.PLAYING:
self.index = 0 # set up for first image in list
self.elapsed = 0
self.nIterationsLeft = 0
elif self.sta... | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"state",
"==",
"PygAnimation",
".",
"PLAYING",
":",
"self",
".",
"index",
"=",
"0",
"# set up for first image in list\r",
"self",
".",
"elapsed",
"=",
"0",
"self",
".",
"nIterationsLeft",
"=",
"0",
... | Stops a a playing animation. A subsequent call to play will start from the beginning. | [
"Stops",
"a",
"a",
"playing",
"animation",
".",
"A",
"subsequent",
"call",
"to",
"play",
"will",
"start",
"from",
"the",
"beginning",
"."
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L2492-L2506 |
240,766 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | PygAnimation.pause | def pause(self):
"""Pauses a playing animation. A subsequent call to play will continue where it left off."""
if self.state == PygAnimation.PLAYING:
self.elapsedAtPause = self.elapsed
# only change state if it was playing
self.state = PygAnimation.PAUSED
... | python | def pause(self):
"""Pauses a playing animation. A subsequent call to play will continue where it left off."""
if self.state == PygAnimation.PLAYING:
self.elapsedAtPause = self.elapsed
# only change state if it was playing
self.state = PygAnimation.PAUSED
... | [
"def",
"pause",
"(",
"self",
")",
":",
"if",
"self",
".",
"state",
"==",
"PygAnimation",
".",
"PLAYING",
":",
"self",
".",
"elapsedAtPause",
"=",
"self",
".",
"elapsed",
"# only change state if it was playing\r",
"self",
".",
"state",
"=",
"PygAnimation",
".",... | Pauses a playing animation. A subsequent call to play will continue where it left off. | [
"Pauses",
"a",
"playing",
"animation",
".",
"A",
"subsequent",
"call",
"to",
"play",
"will",
"continue",
"where",
"it",
"left",
"off",
"."
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L2508-L2519 |
240,767 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | PygAnimation.update | def update(self):
"""Updates the currently running animation.
This method should be called in every frame where you want an animation to run.
Its job is to figure out if it is time to move onto the next image in the animation.
"""
returnValue = False # typical return va... | python | def update(self):
"""Updates the currently running animation.
This method should be called in every frame where you want an animation to run.
Its job is to figure out if it is time to move onto the next image in the animation.
"""
returnValue = False # typical return va... | [
"def",
"update",
"(",
"self",
")",
":",
"returnValue",
"=",
"False",
"# typical return value\r",
"if",
"self",
".",
"state",
"!=",
"PygAnimation",
".",
"PLAYING",
":",
"return",
"returnValue",
"# The job here is to figure out the index of the image to show\r",
"# and the ... | Updates the currently running animation.
This method should be called in every frame where you want an animation to run.
Its job is to figure out if it is time to move onto the next image in the animation. | [
"Updates",
"the",
"currently",
"running",
"animation",
".",
"This",
"method",
"should",
"be",
"called",
"in",
"every",
"frame",
"where",
"you",
"want",
"an",
"animation",
"to",
"run",
".",
"Its",
"job",
"is",
"to",
"figure",
"out",
"if",
"it",
"is",
"tim... | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L2521-L2557 |
240,768 | IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | PygAnimation.draw | def draw(self):
"""Draws the current frame of the animation
Should be called in every frame.
"""
# Assumes that self.index has been set earlier (typically in update method)
# it is used as the index of the current image/endTime/loc
theImage = self.imagesList[sel... | python | def draw(self):
"""Draws the current frame of the animation
Should be called in every frame.
"""
# Assumes that self.index has been set earlier (typically in update method)
# it is used as the index of the current image/endTime/loc
theImage = self.imagesList[sel... | [
"def",
"draw",
"(",
"self",
")",
":",
"# Assumes that self.index has been set earlier (typically in update method)\r",
"# it is used as the index of the current image/endTime/loc\r",
"theImage",
"=",
"self",
".",
"imagesList",
"[",
"self",
".",
"index",
"]",
"# choose the image t... | Draws the current frame of the animation
Should be called in every frame. | [
"Draws",
"the",
"current",
"frame",
"of",
"the",
"animation",
"Should",
"be",
"called",
"in",
"every",
"frame",
"."
] | a830d8885d4d209e471cb53816277d30db56273c | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L2559-L2575 |
240,769 | ironfroggy/django-better-cache | bettercache/decorators.py | CachedMethod.cache | def cache(cls, key_attrs, expires=None):
"""Decorates a method to provide cached-memoization using a
combination of the positional arguments, keyword argments, and
whitelisted instance attributes.
"""
def decorator(func):
@functools.wraps(func)
def wrapp... | python | def cache(cls, key_attrs, expires=None):
"""Decorates a method to provide cached-memoization using a
combination of the positional arguments, keyword argments, and
whitelisted instance attributes.
"""
def decorator(func):
@functools.wraps(func)
def wrapp... | [
"def",
"cache",
"(",
"cls",
",",
"key_attrs",
",",
"expires",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwa... | Decorates a method to provide cached-memoization using a
combination of the positional arguments, keyword argments, and
whitelisted instance attributes. | [
"Decorates",
"a",
"method",
"to",
"provide",
"cached",
"-",
"memoization",
"using",
"a",
"combination",
"of",
"the",
"positional",
"arguments",
"keyword",
"argments",
"and",
"whitelisted",
"instance",
"attributes",
"."
] | 5350e8c646cef1c1ca74eab176f856ddd9eaf5c3 | https://github.com/ironfroggy/django-better-cache/blob/5350e8c646cef1c1ca74eab176f856ddd9eaf5c3/bettercache/decorators.py#L40-L87 |
240,770 | crcresearch/py-utils | crc_nd/utils/error_mixins.py | CallerErrorMixin.assertCallerError | def assertCallerError(self, expected_arg0, callable_obj, *args, **kwargs):
"""
Assert that a callable raises an AssertionError with a particular argument.
:param expected_arg0: The expected value for the AssertionError instance's first argument
(i.e., instance.args... | python | def assertCallerError(self, expected_arg0, callable_obj, *args, **kwargs):
"""
Assert that a callable raises an AssertionError with a particular argument.
:param expected_arg0: The expected value for the AssertionError instance's first argument
(i.e., instance.args... | [
"def",
"assertCallerError",
"(",
"self",
",",
"expected_arg0",
",",
"callable_obj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"callable_obj",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"fail",
"(",
"'Expected As... | Assert that a callable raises an AssertionError with a particular argument.
:param expected_arg0: The expected value for the AssertionError instance's first argument
(i.e., instance.args[0]). | [
"Assert",
"that",
"a",
"callable",
"raises",
"an",
"AssertionError",
"with",
"a",
"particular",
"argument",
"."
] | 04caf0425a047baf900da726cf47c42413b0dd81 | https://github.com/crcresearch/py-utils/blob/04caf0425a047baf900da726cf47c42413b0dd81/crc_nd/utils/error_mixins.py#L23-L36 |
240,771 | cdeboever3/cdpybio | cdpybio/pysamext.py | get_region_nt_counts | def get_region_nt_counts(region, bam, stranded=False):
"""
Get counts of each nucleotide from a bam file for a given region. If R1 and
R2 reads both overlap a position, only one count will be added. If the R1
and R2 reads disagree at a position they both overlap, that read pair is not
used for that ... | python | def get_region_nt_counts(region, bam, stranded=False):
"""
Get counts of each nucleotide from a bam file for a given region. If R1 and
R2 reads both overlap a position, only one count will be added. If the R1
and R2 reads disagree at a position they both overlap, that read pair is not
used for that ... | [
"def",
"get_region_nt_counts",
"(",
"region",
",",
"bam",
",",
"stranded",
"=",
"False",
")",
":",
"# TODO: I should figure out what the different possible values are that",
"# pysam could give me back (so far I only have ATCGN). Can I get deletions",
"# and insertions? ",
"# TODO: Thi... | Get counts of each nucleotide from a bam file for a given region. If R1 and
R2 reads both overlap a position, only one count will be added. If the R1
and R2 reads disagree at a position they both overlap, that read pair is not
used for that position. Can optionally output strand-specific counts.
Param... | [
"Get",
"counts",
"of",
"each",
"nucleotide",
"from",
"a",
"bam",
"file",
"for",
"a",
"given",
"region",
".",
"If",
"R1",
"and",
"R2",
"reads",
"both",
"overlap",
"a",
"position",
"only",
"one",
"count",
"will",
"be",
"added",
".",
"If",
"the",
"R1",
... | 38efdf0e11d01bc00a135921cb91a19c03db5d5c | https://github.com/cdeboever3/cdpybio/blob/38efdf0e11d01bc00a135921cb91a19c03db5d5c/cdpybio/pysamext.py#L11-L103 |
240,772 | cdeboever3/cdpybio | cdpybio/pysamext.py | _pos_nt | def _pos_nt(pr, pos, stranded=False):
"""
Given a pileup read and a position, return the base that is covered by the
read at the given position if the position is covered.
Parameters
----------
pr : pysam.calignmentfile.PileupRead
Region of type chrom:start-end, chrom:start-end:strand, ... | python | def _pos_nt(pr, pos, stranded=False):
"""
Given a pileup read and a position, return the base that is covered by the
read at the given position if the position is covered.
Parameters
----------
pr : pysam.calignmentfile.PileupRead
Region of type chrom:start-end, chrom:start-end:strand, ... | [
"def",
"_pos_nt",
"(",
"pr",
",",
"pos",
",",
"stranded",
"=",
"False",
")",
":",
"nt",
"=",
"None",
"bases",
"=",
"dict",
"(",
"zip",
"(",
"pr",
".",
"alignment",
".",
"get_reference_positions",
"(",
")",
",",
"list",
"(",
"pr",
".",
"alignment",
... | Given a pileup read and a position, return the base that is covered by the
read at the given position if the position is covered.
Parameters
----------
pr : pysam.calignmentfile.PileupRead
Region of type chrom:start-end, chrom:start-end:strand, or [chrom,
pos : int
Zero-based p... | [
"Given",
"a",
"pileup",
"read",
"and",
"a",
"position",
"return",
"the",
"base",
"that",
"is",
"covered",
"by",
"the",
"read",
"at",
"the",
"given",
"position",
"if",
"the",
"position",
"is",
"covered",
"."
] | 38efdf0e11d01bc00a135921cb91a19c03db5d5c | https://github.com/cdeboever3/cdpybio/blob/38efdf0e11d01bc00a135921cb91a19c03db5d5c/cdpybio/pysamext.py#L105-L150 |
240,773 | cdeboever3/cdpybio | cdpybio/pysamext.py | nt_counts | def nt_counts(bam, positions, stranded=False, vcf=False, bed=False):
"""
Find the number of nucleotides covered at all positions in a bed or vcf
file.
Parameters
----------
bam : str or pysam.calignmentfile.AlignmentFile
Bam file opened with pysam or path to bam file (must
be s... | python | def nt_counts(bam, positions, stranded=False, vcf=False, bed=False):
"""
Find the number of nucleotides covered at all positions in a bed or vcf
file.
Parameters
----------
bam : str or pysam.calignmentfile.AlignmentFile
Bam file opened with pysam or path to bam file (must
be s... | [
"def",
"nt_counts",
"(",
"bam",
",",
"positions",
",",
"stranded",
"=",
"False",
",",
"vcf",
"=",
"False",
",",
"bed",
"=",
"False",
")",
":",
"if",
"not",
"bed",
"and",
"not",
"vcf",
":",
"if",
"type",
"(",
"positions",
")",
"==",
"pbt",
".",
"b... | Find the number of nucleotides covered at all positions in a bed or vcf
file.
Parameters
----------
bam : str or pysam.calignmentfile.AlignmentFile
Bam file opened with pysam or path to bam file (must
be sorted and indexed).
positions : str or pybedtools.BedTool
Path t... | [
"Find",
"the",
"number",
"of",
"nucleotides",
"covered",
"at",
"all",
"positions",
"in",
"a",
"bed",
"or",
"vcf",
"file",
"."
] | 38efdf0e11d01bc00a135921cb91a19c03db5d5c | https://github.com/cdeboever3/cdpybio/blob/38efdf0e11d01bc00a135921cb91a19c03db5d5c/cdpybio/pysamext.py#L152-L213 |
240,774 | logston/py3s3 | py3s3/storage.py | Storage.save | def save(self, name, file):
"""
Saves new content to the file specified by name. The content should be
a proper File object or any python file-like object, ready to be read
from the beginning.
"""
# Get the proper name for the file, as it will actually be saved.
i... | python | def save(self, name, file):
"""
Saves new content to the file specified by name. The content should be
a proper File object or any python file-like object, ready to be read
from the beginning.
"""
# Get the proper name for the file, as it will actually be saved.
i... | [
"def",
"save",
"(",
"self",
",",
"name",
",",
"file",
")",
":",
"# Get the proper name for the file, as it will actually be saved.",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"file",
".",
"name",
"if",
"not",
"hasattr",
"(",
"file",
",",
"'chunks'",
")",
... | Saves new content to the file specified by name. The content should be
a proper File object or any python file-like object, ready to be read
from the beginning. | [
"Saves",
"new",
"content",
"to",
"the",
"file",
"specified",
"by",
"name",
".",
"The",
"content",
"should",
"be",
"a",
"proper",
"File",
"object",
"or",
"any",
"python",
"file",
"-",
"like",
"object",
"ready",
"to",
"be",
"read",
"from",
"the",
"beginnin... | 1910ca60c53a53d839d6f7b09c05b555f3bfccf4 | https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/storage.py#L50-L67 |
240,775 | logston/py3s3 | py3s3/storage.py | S3Storage.request_signature | def request_signature(self, stringtosign):
"""
Construct a signature by making an RFC2104 HMAC-SHA1
of the following and converting it to Base64 UTF-8 encoded string.
"""
digest = hmac.new(
self.secret_key.encode(ENCODING),
stringtosign.encode(ENCODING),
... | python | def request_signature(self, stringtosign):
"""
Construct a signature by making an RFC2104 HMAC-SHA1
of the following and converting it to Base64 UTF-8 encoded string.
"""
digest = hmac.new(
self.secret_key.encode(ENCODING),
stringtosign.encode(ENCODING),
... | [
"def",
"request_signature",
"(",
"self",
",",
"stringtosign",
")",
":",
"digest",
"=",
"hmac",
".",
"new",
"(",
"self",
".",
"secret_key",
".",
"encode",
"(",
"ENCODING",
")",
",",
"stringtosign",
".",
"encode",
"(",
"ENCODING",
")",
",",
"hashlib",
".",... | Construct a signature by making an RFC2104 HMAC-SHA1
of the following and converting it to Base64 UTF-8 encoded string. | [
"Construct",
"a",
"signature",
"by",
"making",
"an",
"RFC2104",
"HMAC",
"-",
"SHA1",
"of",
"the",
"following",
"and",
"converting",
"it",
"to",
"Base64",
"UTF",
"-",
"8",
"encoded",
"string",
"."
] | 1910ca60c53a53d839d6f7b09c05b555f3bfccf4 | https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/storage.py#L205-L215 |
240,776 | logston/py3s3 | py3s3/storage.py | S3Storage._get_content_type | def _get_content_type(self, file):
"""
Return content type of file. If file does not
have a content type, make a guess.
"""
if file.mimetype:
return file.mimetype
# get file extension
_, extension = os.path.splitext(file.name)
extension = exte... | python | def _get_content_type(self, file):
"""
Return content type of file. If file does not
have a content type, make a guess.
"""
if file.mimetype:
return file.mimetype
# get file extension
_, extension = os.path.splitext(file.name)
extension = exte... | [
"def",
"_get_content_type",
"(",
"self",
",",
"file",
")",
":",
"if",
"file",
".",
"mimetype",
":",
"return",
"file",
".",
"mimetype",
"# get file extension",
"_",
",",
"extension",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"file",
".",
"name",
")",
... | Return content type of file. If file does not
have a content type, make a guess. | [
"Return",
"content",
"type",
"of",
"file",
".",
"If",
"file",
"does",
"not",
"have",
"a",
"content",
"type",
"make",
"a",
"guess",
"."
] | 1910ca60c53a53d839d6f7b09c05b555f3bfccf4 | https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/storage.py#L261-L274 |
240,777 | logston/py3s3 | py3s3/storage.py | S3Storage._put_file | def _put_file(self, file):
"""Send PUT request to S3 with file contents"""
post_params = {
'file_size': file.size,
'file_hash': file.md5hash(),
'content_type': self._get_content_type(file),
}
headers = self._request_headers('PUT', file.prefixed_name... | python | def _put_file(self, file):
"""Send PUT request to S3 with file contents"""
post_params = {
'file_size': file.size,
'file_hash': file.md5hash(),
'content_type': self._get_content_type(file),
}
headers = self._request_headers('PUT', file.prefixed_name... | [
"def",
"_put_file",
"(",
"self",
",",
"file",
")",
":",
"post_params",
"=",
"{",
"'file_size'",
":",
"file",
".",
"size",
",",
"'file_hash'",
":",
"file",
".",
"md5hash",
"(",
")",
",",
"'content_type'",
":",
"self",
".",
"_get_content_type",
"(",
"file"... | Send PUT request to S3 with file contents | [
"Send",
"PUT",
"request",
"to",
"S3",
"with",
"file",
"contents"
] | 1910ca60c53a53d839d6f7b09c05b555f3bfccf4 | https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/storage.py#L276-L298 |
240,778 | logston/py3s3 | py3s3/storage.py | S3Storage._get_file | def _get_file(self, prefixed_name):
"""
Return a signature for use in GET requests
"""
headers = self._request_headers('GET', prefixed_name)
file = S3ContentFile('')
with closing(HTTPConnection(self.netloc)) as conn:
conn.request('GET', prefixed_name, headers=... | python | def _get_file(self, prefixed_name):
"""
Return a signature for use in GET requests
"""
headers = self._request_headers('GET', prefixed_name)
file = S3ContentFile('')
with closing(HTTPConnection(self.netloc)) as conn:
conn.request('GET', prefixed_name, headers=... | [
"def",
"_get_file",
"(",
"self",
",",
"prefixed_name",
")",
":",
"headers",
"=",
"self",
".",
"_request_headers",
"(",
"'GET'",
",",
"prefixed_name",
")",
"file",
"=",
"S3ContentFile",
"(",
"''",
")",
"with",
"closing",
"(",
"HTTPConnection",
"(",
"self",
... | Return a signature for use in GET requests | [
"Return",
"a",
"signature",
"for",
"use",
"in",
"GET",
"requests"
] | 1910ca60c53a53d839d6f7b09c05b555f3bfccf4 | https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/storage.py#L300-L323 |
240,779 | logston/py3s3 | py3s3/storage.py | S3Storage.url | def url(self, name):
"""Return URL of resource"""
scheme = 'http'
path = self._prepend_name_prefix(name)
query = ''
fragment = ''
url_tuple = (scheme, self.netloc, path, query, fragment)
return urllib.parse.urlunsplit(url_tuple) | python | def url(self, name):
"""Return URL of resource"""
scheme = 'http'
path = self._prepend_name_prefix(name)
query = ''
fragment = ''
url_tuple = (scheme, self.netloc, path, query, fragment)
return urllib.parse.urlunsplit(url_tuple) | [
"def",
"url",
"(",
"self",
",",
"name",
")",
":",
"scheme",
"=",
"'http'",
"path",
"=",
"self",
".",
"_prepend_name_prefix",
"(",
"name",
")",
"query",
"=",
"''",
"fragment",
"=",
"''",
"url_tuple",
"=",
"(",
"scheme",
",",
"self",
".",
"netloc",
","... | Return URL of resource | [
"Return",
"URL",
"of",
"resource"
] | 1910ca60c53a53d839d6f7b09c05b555f3bfccf4 | https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/storage.py#L378-L385 |
240,780 | pablorecio/Cobaya | src/cobaya/app.py | get_all_tasks | def get_all_tasks(conf):
"""Returns a list with every task registred on Hamster.
"""
db = HamsterDB(conf)
fact_list = db.all_facts_id
security_days = int(conf.get_option('tasks.security_days'))
today = datetime.today()
tasks = {}
for fact_id in fact_list:
ht = HamsterTask(fac... | python | def get_all_tasks(conf):
"""Returns a list with every task registred on Hamster.
"""
db = HamsterDB(conf)
fact_list = db.all_facts_id
security_days = int(conf.get_option('tasks.security_days'))
today = datetime.today()
tasks = {}
for fact_id in fact_list:
ht = HamsterTask(fac... | [
"def",
"get_all_tasks",
"(",
"conf",
")",
":",
"db",
"=",
"HamsterDB",
"(",
"conf",
")",
"fact_list",
"=",
"db",
".",
"all_facts_id",
"security_days",
"=",
"int",
"(",
"conf",
".",
"get_option",
"(",
"'tasks.security_days'",
")",
")",
"today",
"=",
"dateti... | Returns a list with every task registred on Hamster. | [
"Returns",
"a",
"list",
"with",
"every",
"task",
"registred",
"on",
"Hamster",
"."
] | 70b107dea5f31f51e7b6738da3c2a1df5b9f3f20 | https://github.com/pablorecio/Cobaya/blob/70b107dea5f31f51e7b6738da3c2a1df5b9f3f20/src/cobaya/app.py#L94-L117 |
240,781 | edwards-lab/libGWAS | libgwas/impute_parser.py | SetEncoding | def SetEncoding(sval):
"""Sets the encoding variable according to the text passed
:param sval: text specification for the desired model
"""
global encoding
s=sval.lower()
if s == "additive":
encoding = Encoding.Additive
elif s == "dominant":
encoding = Encoding.Dominant
... | python | def SetEncoding(sval):
"""Sets the encoding variable according to the text passed
:param sval: text specification for the desired model
"""
global encoding
s=sval.lower()
if s == "additive":
encoding = Encoding.Additive
elif s == "dominant":
encoding = Encoding.Dominant
... | [
"def",
"SetEncoding",
"(",
"sval",
")",
":",
"global",
"encoding",
"s",
"=",
"sval",
".",
"lower",
"(",
")",
"if",
"s",
"==",
"\"additive\"",
":",
"encoding",
"=",
"Encoding",
".",
"Additive",
"elif",
"s",
"==",
"\"dominant\"",
":",
"encoding",
"=",
"E... | Sets the encoding variable according to the text passed
:param sval: text specification for the desired model | [
"Sets",
"the",
"encoding",
"variable",
"according",
"to",
"the",
"text",
"passed"
] | d68c9a083d443dfa5d7c5112de29010909cfe23f | https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/impute_parser.py#L39-L57 |
240,782 | edwards-lab/libGWAS | libgwas/impute_parser.py | Parser.load_family_details | def load_family_details(self, pheno_covar):
"""Load family data updating the pheno_covar with family ids found.
:param pheno_covar: Phenotype/covariate object
:return: None
"""
file = open(self.fam_details)
header = file.readline()
format = file.readline()
... | python | def load_family_details(self, pheno_covar):
"""Load family data updating the pheno_covar with family ids found.
:param pheno_covar: Phenotype/covariate object
:return: None
"""
file = open(self.fam_details)
header = file.readline()
format = file.readline()
... | [
"def",
"load_family_details",
"(",
"self",
",",
"pheno_covar",
")",
":",
"file",
"=",
"open",
"(",
"self",
".",
"fam_details",
")",
"header",
"=",
"file",
".",
"readline",
"(",
")",
"format",
"=",
"file",
".",
"readline",
"(",
")",
"self",
".",
"file_i... | Load family data updating the pheno_covar with family ids found.
:param pheno_covar: Phenotype/covariate object
:return: None | [
"Load",
"family",
"data",
"updating",
"the",
"pheno_covar",
"with",
"family",
"ids",
"found",
"."
] | d68c9a083d443dfa5d7c5112de29010909cfe23f | https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/impute_parser.py#L149-L176 |
240,783 | edwards-lab/libGWAS | libgwas/impute_parser.py | Parser.load_genotypes | def load_genotypes(self):
"""Prepares the files for genotype parsing.
:return: None
"""
if self.file_index < len(self.archives):
self.current_file = self.archives[self.file_index]
info_filename = self.current_file.replace(Parser.gen_ext, Parser.info_ext)
... | python | def load_genotypes(self):
"""Prepares the files for genotype parsing.
:return: None
"""
if self.file_index < len(self.archives):
self.current_file = self.archives[self.file_index]
info_filename = self.current_file.replace(Parser.gen_ext, Parser.info_ext)
... | [
"def",
"load_genotypes",
"(",
"self",
")",
":",
"if",
"self",
".",
"file_index",
"<",
"len",
"(",
"self",
".",
"archives",
")",
":",
"self",
".",
"current_file",
"=",
"self",
".",
"archives",
"[",
"self",
".",
"file_index",
"]",
"info_filename",
"=",
"... | Prepares the files for genotype parsing.
:return: None | [
"Prepares",
"the",
"files",
"for",
"genotype",
"parsing",
"."
] | d68c9a083d443dfa5d7c5112de29010909cfe23f | https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/impute_parser.py#L178-L200 |
240,784 | edwards-lab/libGWAS | libgwas/impute_parser.py | Parser.get_next_line | def get_next_line(self):
"""If we reach the end of the file, we simply open the next, until we \
run out of archives to process"""
line = self.freq_file.readline().strip().split()
if len(line) < 1:
self.load_genotypes()
line = self.freq_file.readline().strip().sp... | python | def get_next_line(self):
"""If we reach the end of the file, we simply open the next, until we \
run out of archives to process"""
line = self.freq_file.readline().strip().split()
if len(line) < 1:
self.load_genotypes()
line = self.freq_file.readline().strip().sp... | [
"def",
"get_next_line",
"(",
"self",
")",
":",
"line",
"=",
"self",
".",
"freq_file",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
".",
"split",
"(",
")",
"if",
"len",
"(",
"line",
")",
"<",
"1",
":",
"self",
".",
"load_genotypes",
"(",
")"... | If we reach the end of the file, we simply open the next, until we \
run out of archives to process | [
"If",
"we",
"reach",
"the",
"end",
"of",
"the",
"file",
"we",
"simply",
"open",
"the",
"next",
"until",
"we",
"\\",
"run",
"out",
"of",
"archives",
"to",
"process"
] | d68c9a083d443dfa5d7c5112de29010909cfe23f | https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/impute_parser.py#L202-L213 |
240,785 | mayfield/shellish | shellish/command/command.py | parse_docstring | def parse_docstring(entity):
""" Return sanitized docstring from an entity. The first line of the
docstring is the title, and remaining lines are the details, aka git
style. """
doc = inspect.getdoc(entity)
if not doc:
return None, None
doc = doc.splitlines(keepends=True)
if not doc... | python | def parse_docstring(entity):
""" Return sanitized docstring from an entity. The first line of the
docstring is the title, and remaining lines are the details, aka git
style. """
doc = inspect.getdoc(entity)
if not doc:
return None, None
doc = doc.splitlines(keepends=True)
if not doc... | [
"def",
"parse_docstring",
"(",
"entity",
")",
":",
"doc",
"=",
"inspect",
".",
"getdoc",
"(",
"entity",
")",
"if",
"not",
"doc",
":",
"return",
"None",
",",
"None",
"doc",
"=",
"doc",
".",
"splitlines",
"(",
"keepends",
"=",
"True",
")",
"if",
"not",... | Return sanitized docstring from an entity. The first line of the
docstring is the title, and remaining lines are the details, aka git
style. | [
"Return",
"sanitized",
"docstring",
"from",
"an",
"entity",
".",
"The",
"first",
"line",
"of",
"the",
"docstring",
"is",
"the",
"title",
"and",
"remaining",
"lines",
"are",
"the",
"details",
"aka",
"git",
"style",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L16-L30 |
240,786 | mayfield/shellish | shellish/command/command.py | Command.parse_args | def parse_args(self, argv=None):
""" Return an argparse.Namespace of the argv string or sys.argv if
argv is None. """
arg_input = shlex.split(argv) if argv is not None else None
self.get_or_create_session()
return self.argparser.parse_args(arg_input) | python | def parse_args(self, argv=None):
""" Return an argparse.Namespace of the argv string or sys.argv if
argv is None. """
arg_input = shlex.split(argv) if argv is not None else None
self.get_or_create_session()
return self.argparser.parse_args(arg_input) | [
"def",
"parse_args",
"(",
"self",
",",
"argv",
"=",
"None",
")",
":",
"arg_input",
"=",
"shlex",
".",
"split",
"(",
"argv",
")",
"if",
"argv",
"is",
"not",
"None",
"else",
"None",
"self",
".",
"get_or_create_session",
"(",
")",
"return",
"self",
".",
... | Return an argparse.Namespace of the argv string or sys.argv if
argv is None. | [
"Return",
"an",
"argparse",
".",
"Namespace",
"of",
"the",
"argv",
"string",
"or",
"sys",
".",
"argv",
"if",
"argv",
"is",
"None",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L105-L110 |
240,787 | mayfield/shellish | shellish/command/command.py | Command.get_pager_spec | def get_pager_spec(self):
""" Find the best pager settings for this command. If the user has
specified overrides in the INI config file we prefer those. """
self_config = self.get_config()
pagercmd = self_config.get('pager')
istty = self_config.getboolean('pager_istty')
... | python | def get_pager_spec(self):
""" Find the best pager settings for this command. If the user has
specified overrides in the INI config file we prefer those. """
self_config = self.get_config()
pagercmd = self_config.get('pager')
istty = self_config.getboolean('pager_istty')
... | [
"def",
"get_pager_spec",
"(",
"self",
")",
":",
"self_config",
"=",
"self",
".",
"get_config",
"(",
")",
"pagercmd",
"=",
"self_config",
".",
"get",
"(",
"'pager'",
")",
"istty",
"=",
"self_config",
".",
"getboolean",
"(",
"'pager_istty'",
")",
"core_config"... | Find the best pager settings for this command. If the user has
specified overrides in the INI config file we prefer those. | [
"Find",
"the",
"best",
"pager",
"settings",
"for",
"this",
"command",
".",
"If",
"the",
"user",
"has",
"specified",
"overrides",
"in",
"the",
"INI",
"config",
"file",
"we",
"prefer",
"those",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L135-L149 |
240,788 | mayfield/shellish | shellish/command/command.py | Command.run_wrap | def run_wrap(self, args):
""" Wrap some standard protocol around a command's run method. This
wrapper should generally never capture exceptions. It can look at
them and do things but prerun and postrun should always be symmetric.
Any exception suppression should happen in the `session.... | python | def run_wrap(self, args):
""" Wrap some standard protocol around a command's run method. This
wrapper should generally never capture exceptions. It can look at
them and do things but prerun and postrun should always be symmetric.
Any exception suppression should happen in the `session.... | [
"def",
"run_wrap",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"fire_event",
"(",
"'prerun'",
",",
"args",
")",
"self",
".",
"prerun",
"(",
"args",
")",
"try",
":",
"if",
"self",
".",
"session",
".",
"allow_pager",
"and",
"self",
".",
"use_pager... | Wrap some standard protocol around a command's run method. This
wrapper should generally never capture exceptions. It can look at
them and do things but prerun and postrun should always be symmetric.
Any exception suppression should happen in the `session.execute`. | [
"Wrap",
"some",
"standard",
"protocol",
"around",
"a",
"command",
"s",
"run",
"method",
".",
"This",
"wrapper",
"should",
"generally",
"never",
"capture",
"exceptions",
".",
"It",
"can",
"look",
"at",
"them",
"and",
"do",
"things",
"but",
"prerun",
"and",
... | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L151-L172 |
240,789 | mayfield/shellish | shellish/command/command.py | Command.get_config | def get_config(self, section=None):
""" Return the merged end-user configuration for this command or a
specific section if set in `section`. """
config = self.session.config
section = self.config_section() if section is None else section
try:
return config[section]
... | python | def get_config(self, section=None):
""" Return the merged end-user configuration for this command or a
specific section if set in `section`. """
config = self.session.config
section = self.config_section() if section is None else section
try:
return config[section]
... | [
"def",
"get_config",
"(",
"self",
",",
"section",
"=",
"None",
")",
":",
"config",
"=",
"self",
".",
"session",
".",
"config",
"section",
"=",
"self",
".",
"config_section",
"(",
")",
"if",
"section",
"is",
"None",
"else",
"section",
"try",
":",
"retur... | Return the merged end-user configuration for this command or a
specific section if set in `section`. | [
"Return",
"the",
"merged",
"end",
"-",
"user",
"configuration",
"for",
"this",
"command",
"or",
"a",
"specific",
"section",
"if",
"set",
"in",
"section",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L194-L203 |
240,790 | mayfield/shellish | shellish/command/command.py | Command.parent | def parent(self, parent):
""" Copy context from the parent into this instance as well as
adjusting or depth value to indicate where we exist in a command
tree. """
self._parent = parent
if parent:
pctx = dict((x, getattr(parent, x)) for x in parent.context_keys)
... | python | def parent(self, parent):
""" Copy context from the parent into this instance as well as
adjusting or depth value to indicate where we exist in a command
tree. """
self._parent = parent
if parent:
pctx = dict((x, getattr(parent, x)) for x in parent.context_keys)
... | [
"def",
"parent",
"(",
"self",
",",
"parent",
")",
":",
"self",
".",
"_parent",
"=",
"parent",
"if",
"parent",
":",
"pctx",
"=",
"dict",
"(",
"(",
"x",
",",
"getattr",
"(",
"parent",
",",
"x",
")",
")",
"for",
"x",
"in",
"parent",
".",
"context_ke... | Copy context from the parent into this instance as well as
adjusting or depth value to indicate where we exist in a command
tree. | [
"Copy",
"context",
"from",
"the",
"parent",
"into",
"this",
"instance",
"as",
"well",
"as",
"adjusting",
"or",
"depth",
"value",
"to",
"indicate",
"where",
"we",
"exist",
"in",
"a",
"command",
"tree",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L210-L222 |
240,791 | mayfield/shellish | shellish/command/command.py | Command.find_root | def find_root(self):
""" Traverse parent refs to top. """
cmd = self
while cmd.parent:
cmd = cmd.parent
return cmd | python | def find_root(self):
""" Traverse parent refs to top. """
cmd = self
while cmd.parent:
cmd = cmd.parent
return cmd | [
"def",
"find_root",
"(",
"self",
")",
":",
"cmd",
"=",
"self",
"while",
"cmd",
".",
"parent",
":",
"cmd",
"=",
"cmd",
".",
"parent",
"return",
"cmd"
] | Traverse parent refs to top. | [
"Traverse",
"parent",
"refs",
"to",
"top",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L224-L229 |
240,792 | mayfield/shellish | shellish/command/command.py | Command.inject_context | def inject_context(self, __context_dict__=None, **context):
""" Map context dict to this instance as attributes and keep note of
the keys being set so we can pass this along to any subcommands. """
context = context or __context_dict__
self.context_keys |= set(context.keys())
for... | python | def inject_context(self, __context_dict__=None, **context):
""" Map context dict to this instance as attributes and keep note of
the keys being set so we can pass this along to any subcommands. """
context = context or __context_dict__
self.context_keys |= set(context.keys())
for... | [
"def",
"inject_context",
"(",
"self",
",",
"__context_dict__",
"=",
"None",
",",
"*",
"*",
"context",
")",
":",
"context",
"=",
"context",
"or",
"__context_dict__",
"self",
".",
"context_keys",
"|=",
"set",
"(",
"context",
".",
"keys",
"(",
")",
")",
"fo... | Map context dict to this instance as attributes and keep note of
the keys being set so we can pass this along to any subcommands. | [
"Map",
"context",
"dict",
"to",
"this",
"instance",
"as",
"attributes",
"and",
"keep",
"note",
"of",
"the",
"keys",
"being",
"set",
"so",
"we",
"can",
"pass",
"this",
"along",
"to",
"any",
"subcommands",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L231-L239 |
240,793 | mayfield/shellish | shellish/command/command.py | Command.add_argument | def add_argument(self, *args, parser=None, autoenv=False, env=None,
complete=None, **kwargs):
""" Allow cleaner action supplementation. Autoenv will generate an
environment variable to be usable as a defaults setter based on the
command name and the dest property of the act... | python | def add_argument(self, *args, parser=None, autoenv=False, env=None,
complete=None, **kwargs):
""" Allow cleaner action supplementation. Autoenv will generate an
environment variable to be usable as a defaults setter based on the
command name and the dest property of the act... | [
"def",
"add_argument",
"(",
"self",
",",
"*",
"args",
",",
"parser",
"=",
"None",
",",
"autoenv",
"=",
"False",
",",
"env",
"=",
"None",
",",
"complete",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"parser",
"is",
"None",
":",
"parser",
... | Allow cleaner action supplementation. Autoenv will generate an
environment variable to be usable as a defaults setter based on the
command name and the dest property of the action. | [
"Allow",
"cleaner",
"action",
"supplementation",
".",
"Autoenv",
"will",
"generate",
"an",
"environment",
"variable",
"to",
"be",
"usable",
"as",
"a",
"defaults",
"setter",
"based",
"on",
"the",
"command",
"name",
"and",
"the",
"dest",
"property",
"of",
"the",... | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L270-L289 |
240,794 | mayfield/shellish | shellish/command/command.py | Command._make_autoenv | def _make_autoenv(self, action):
""" Generate a suitable env variable for this action. This is
dependant on our subcommand hierarchy. Review the prog setter for
details. """
env = ('%s_%s' % (self.prog, action.dest)).upper()
env = re.sub(self.env_scrub_re, '', env.strip())
... | python | def _make_autoenv(self, action):
""" Generate a suitable env variable for this action. This is
dependant on our subcommand hierarchy. Review the prog setter for
details. """
env = ('%s_%s' % (self.prog, action.dest)).upper()
env = re.sub(self.env_scrub_re, '', env.strip())
... | [
"def",
"_make_autoenv",
"(",
"self",
",",
"action",
")",
":",
"env",
"=",
"(",
"'%s_%s'",
"%",
"(",
"self",
".",
"prog",
",",
"action",
".",
"dest",
")",
")",
".",
"upper",
"(",
")",
"env",
"=",
"re",
".",
"sub",
"(",
"self",
".",
"env_scrub_re",... | Generate a suitable env variable for this action. This is
dependant on our subcommand hierarchy. Review the prog setter for
details. | [
"Generate",
"a",
"suitable",
"env",
"variable",
"for",
"this",
"action",
".",
"This",
"is",
"dependant",
"on",
"our",
"subcommand",
"hierarchy",
".",
"Review",
"the",
"prog",
"setter",
"for",
"details",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L291-L301 |
240,795 | mayfield/shellish | shellish/command/command.py | Command.add_file_argument | def add_file_argument(self, *args, mode='r', buffering=1,
filetype_options=None, **kwargs):
""" Add a tab-completion safe FileType argument. This argument
differs from a normal argparse.FileType based argument in that the
value is a factory function that returns a file... | python | def add_file_argument(self, *args, mode='r', buffering=1,
filetype_options=None, **kwargs):
""" Add a tab-completion safe FileType argument. This argument
differs from a normal argparse.FileType based argument in that the
value is a factory function that returns a file... | [
"def",
"add_file_argument",
"(",
"self",
",",
"*",
"args",
",",
"mode",
"=",
"'r'",
",",
"buffering",
"=",
"1",
",",
"filetype_options",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"type_",
"=",
"supplement",
".",
"SafeFileType",
"(",
"mode",
"=",
... | Add a tab-completion safe FileType argument. This argument
differs from a normal argparse.FileType based argument in that the
value is a factory function that returns a file handle instead of
providing an already open file handle. There are various reasons
why this is a better approach... | [
"Add",
"a",
"tab",
"-",
"completion",
"safe",
"FileType",
"argument",
".",
"This",
"argument",
"differs",
"from",
"a",
"normal",
"argparse",
".",
"FileType",
"based",
"argument",
"in",
"that",
"the",
"value",
"is",
"a",
"factory",
"function",
"that",
"return... | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L303-L313 |
240,796 | mayfield/shellish | shellish/command/command.py | Command.create_argparser | def create_argparser(self):
""" Factory for arg parser. Can be overridden as long as it returns
an ArgParser compatible instance. """
if self.desc:
if self.title:
fulldesc = '%s\n\n%s' % (self.title, self.desc)
else:
fulldesc = self.desc
... | python | def create_argparser(self):
""" Factory for arg parser. Can be overridden as long as it returns
an ArgParser compatible instance. """
if self.desc:
if self.title:
fulldesc = '%s\n\n%s' % (self.title, self.desc)
else:
fulldesc = self.desc
... | [
"def",
"create_argparser",
"(",
"self",
")",
":",
"if",
"self",
".",
"desc",
":",
"if",
"self",
".",
"title",
":",
"fulldesc",
"=",
"'%s\\n\\n%s'",
"%",
"(",
"self",
".",
"title",
",",
"self",
".",
"desc",
")",
"else",
":",
"fulldesc",
"=",
"self",
... | Factory for arg parser. Can be overridden as long as it returns
an ArgParser compatible instance. | [
"Factory",
"for",
"arg",
"parser",
".",
"Can",
"be",
"overridden",
"as",
"long",
"as",
"it",
"returns",
"an",
"ArgParser",
"compatible",
"instance",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L320-L331 |
240,797 | mayfield/shellish | shellish/command/command.py | Command.attach_session | def attach_session(self):
""" Create a session and inject it as context for this command and any
subcommands. """
assert self.session is None
root = self.find_root()
session = self.Session(root)
root.inject_context(session=session)
return session | python | def attach_session(self):
""" Create a session and inject it as context for this command and any
subcommands. """
assert self.session is None
root = self.find_root()
session = self.Session(root)
root.inject_context(session=session)
return session | [
"def",
"attach_session",
"(",
"self",
")",
":",
"assert",
"self",
".",
"session",
"is",
"None",
"root",
"=",
"self",
".",
"find_root",
"(",
")",
"session",
"=",
"self",
".",
"Session",
"(",
"root",
")",
"root",
".",
"inject_context",
"(",
"session",
"=... | Create a session and inject it as context for this command and any
subcommands. | [
"Create",
"a",
"session",
"and",
"inject",
"it",
"as",
"context",
"for",
"this",
"command",
"and",
"any",
"subcommands",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L333-L340 |
240,798 | mayfield/shellish | shellish/command/command.py | Command._complete | def _complete(self, text, line, begin, end):
""" Do naive argument parsing so the completer has better ability to
understand expansion rules. """
line = line[:end] # Ignore characters following the cursor.
fullargs = self.split_line(line)[1:]
args = fullargs[:]
options =... | python | def _complete(self, text, line, begin, end):
""" Do naive argument parsing so the completer has better ability to
understand expansion rules. """
line = line[:end] # Ignore characters following the cursor.
fullargs = self.split_line(line)[1:]
args = fullargs[:]
options =... | [
"def",
"_complete",
"(",
"self",
",",
"text",
",",
"line",
",",
"begin",
",",
"end",
")",
":",
"line",
"=",
"line",
"[",
":",
"end",
"]",
"# Ignore characters following the cursor.",
"fullargs",
"=",
"self",
".",
"split_line",
"(",
"line",
")",
"[",
"1",... | Do naive argument parsing so the completer has better ability to
understand expansion rules. | [
"Do",
"naive",
"argument",
"parsing",
"so",
"the",
"completer",
"has",
"better",
"ability",
"to",
"understand",
"expansion",
"rules",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L360-L428 |
240,799 | mayfield/shellish | shellish/command/command.py | Command.split_line | def split_line(self, line):
""" Try to do pure shlex.split unless it can't parse the line. In that
case we trim the input line until shlex can split the args and tack the
unparsable portion on as the last argument. """
remainder = []
while True:
try:
a... | python | def split_line(self, line):
""" Try to do pure shlex.split unless it can't parse the line. In that
case we trim the input line until shlex can split the args and tack the
unparsable portion on as the last argument. """
remainder = []
while True:
try:
a... | [
"def",
"split_line",
"(",
"self",
",",
"line",
")",
":",
"remainder",
"=",
"[",
"]",
"while",
"True",
":",
"try",
":",
"args",
"=",
"shlex",
".",
"split",
"(",
"line",
")",
"except",
"ValueError",
":",
"remainder",
".",
"append",
"(",
"line",
"[",
... | Try to do pure shlex.split unless it can't parse the line. In that
case we trim the input line until shlex can split the args and tack the
unparsable portion on as the last argument. | [
"Try",
"to",
"do",
"pure",
"shlex",
".",
"split",
"unless",
"it",
"can",
"t",
"parse",
"the",
"line",
".",
"In",
"that",
"case",
"we",
"trim",
"the",
"input",
"line",
"until",
"shlex",
"can",
"split",
"the",
"args",
"and",
"tack",
"the",
"unparsable",
... | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L430-L444 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.