repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
jtpaasch/simplygithub | simplygithub/internals/trees.py | create_tree | def create_tree(profile, tree):
"""Create a new tree.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
tree
A l... | python | def create_tree(profile, tree):
"""Create a new tree.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
tree
A l... | [
"def",
"create_tree",
"(",
"profile",
",",
"tree",
")",
":",
"resource",
"=",
"\"/trees\"",
"payload",
"=",
"{",
"\"tree\"",
":",
"tree",
"}",
"data",
"=",
"api",
".",
"post_request",
"(",
"profile",
",",
"resource",
",",
"payload",
")",
"return",
"prepa... | Create a new tree.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
tree
A list of blob objects (each with a path, ... | [
"Create",
"a",
"new",
"tree",
"."
] | train | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/trees.py#L44-L65 |
mushkevych/synergy_odm | odm/document.py | BaseDocument.validate | def validate(self):
"""Ensure that all fields' values are valid and that non-nullable fields are present. """
for field_name, field_obj in self._fields.items():
value = field_obj.__get__(self, self.__class__)
if value is None and field_obj.null is False:
raise Va... | python | def validate(self):
"""Ensure that all fields' values are valid and that non-nullable fields are present. """
for field_name, field_obj in self._fields.items():
value = field_obj.__get__(self, self.__class__)
if value is None and field_obj.null is False:
raise Va... | [
"def",
"validate",
"(",
"self",
")",
":",
"for",
"field_name",
",",
"field_obj",
"in",
"self",
".",
"_fields",
".",
"items",
"(",
")",
":",
"value",
"=",
"field_obj",
".",
"__get__",
"(",
"self",
",",
"self",
".",
"__class__",
")",
"if",
"value",
"is... | Ensure that all fields' values are valid and that non-nullable fields are present. | [
"Ensure",
"that",
"all",
"fields",
"values",
"are",
"valid",
"and",
"that",
"non",
"-",
"nullable",
"fields",
"are",
"present",
"."
] | train | https://github.com/mushkevych/synergy_odm/blob/3a5ac37333fc6391478564ef653a4be38e332f68/odm/document.py#L141-L155 |
mushkevych/synergy_odm | odm/document.py | BaseDocument.to_json | def to_json(self):
"""Converts given document to JSON dict. """
json_data = dict()
for field_name, field_obj in self._fields.items():
if isinstance(field_obj, NestedDocumentField):
nested_document = field_obj.__get__(self, self.__class__)
value = None... | python | def to_json(self):
"""Converts given document to JSON dict. """
json_data = dict()
for field_name, field_obj in self._fields.items():
if isinstance(field_obj, NestedDocumentField):
nested_document = field_obj.__get__(self, self.__class__)
value = None... | [
"def",
"to_json",
"(",
"self",
")",
":",
"json_data",
"=",
"dict",
"(",
")",
"for",
"field_name",
",",
"field_obj",
"in",
"self",
".",
"_fields",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"field_obj",
",",
"NestedDocumentField",
")",
":",
"... | Converts given document to JSON dict. | [
"Converts",
"given",
"document",
"to",
"JSON",
"dict",
"."
] | train | https://github.com/mushkevych/synergy_odm/blob/3a5ac37333fc6391478564ef653a4be38e332f68/odm/document.py#L157-L178 |
mushkevych/synergy_odm | odm/document.py | BaseDocument.from_json | def from_json(cls, json_data):
""" Converts json data to a new document instance"""
new_instance = cls()
for field_name, field_obj in cls._get_fields().items():
if isinstance(field_obj, NestedDocumentField):
if field_name in json_data:
nested_field... | python | def from_json(cls, json_data):
""" Converts json data to a new document instance"""
new_instance = cls()
for field_name, field_obj in cls._get_fields().items():
if isinstance(field_obj, NestedDocumentField):
if field_name in json_data:
nested_field... | [
"def",
"from_json",
"(",
"cls",
",",
"json_data",
")",
":",
"new_instance",
"=",
"cls",
"(",
")",
"for",
"field_name",
",",
"field_obj",
"in",
"cls",
".",
"_get_fields",
"(",
")",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"field_obj",
",",
... | Converts json data to a new document instance | [
"Converts",
"json",
"data",
"to",
"a",
"new",
"document",
"instance"
] | train | https://github.com/mushkevych/synergy_odm/blob/3a5ac37333fc6391478564ef653a4be38e332f68/odm/document.py#L208-L229 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/runner/action_plugins/template.py | ActionModule.run | def run(self, conn, tmp, module_name, module_args, inject):
''' handler for template operations '''
if not self.runner.is_playbook:
raise errors.AnsibleError("in current versions of ansible, templates are only usable in playbooks")
# load up options
options = utils.parse_k... | python | def run(self, conn, tmp, module_name, module_args, inject):
''' handler for template operations '''
if not self.runner.is_playbook:
raise errors.AnsibleError("in current versions of ansible, templates are only usable in playbooks")
# load up options
options = utils.parse_k... | [
"def",
"run",
"(",
"self",
",",
"conn",
",",
"tmp",
",",
"module_name",
",",
"module_args",
",",
"inject",
")",
":",
"if",
"not",
"self",
".",
"runner",
".",
"is_playbook",
":",
"raise",
"errors",
".",
"AnsibleError",
"(",
"\"in current versions of ansible, ... | handler for template operations | [
"handler",
"for",
"template",
"operations"
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/action_plugins/template.py#L29-L80 |
shaypal5/utilitime | utilitime/dateint/dateint.py | decompose_dateint | def decompose_dateint(dateint):
"""Decomposes the given dateint into its year, month and day components.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
Returns
-------
year : int
The year component of the given datein... | python | def decompose_dateint(dateint):
"""Decomposes the given dateint into its year, month and day components.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
Returns
-------
year : int
The year component of the given datein... | [
"def",
"decompose_dateint",
"(",
"dateint",
")",
":",
"year",
"=",
"int",
"(",
"dateint",
"/",
"10000",
")",
"leftover",
"=",
"dateint",
"-",
"year",
"*",
"10000",
"month",
"=",
"int",
"(",
"leftover",
"/",
"100",
")",
"day",
"=",
"leftover",
"-",
"m... | Decomposes the given dateint into its year, month and day components.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
Returns
-------
year : int
The year component of the given dateint.
month : int
The month co... | [
"Decomposes",
"the",
"given",
"dateint",
"into",
"its",
"year",
"month",
"and",
"day",
"components",
"."
] | train | https://github.com/shaypal5/utilitime/blob/554ca05fa83c2dbf5d6cf9c9cfa6b03ee6cdb609/utilitime/dateint/dateint.py#L16-L37 |
shaypal5/utilitime | utilitime/dateint/dateint.py | dateint_to_datetime | def dateint_to_datetime(dateint):
"""Converts the given dateint to a datetime object, in local timezone.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
Returns
-------
datetime.datetime
A timezone-unaware datetime obj... | python | def dateint_to_datetime(dateint):
"""Converts the given dateint to a datetime object, in local timezone.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
Returns
-------
datetime.datetime
A timezone-unaware datetime obj... | [
"def",
"dateint_to_datetime",
"(",
"dateint",
")",
":",
"if",
"len",
"(",
"str",
"(",
"dateint",
")",
")",
"!=",
"8",
":",
"raise",
"ValueError",
"(",
"'Dateints must have exactly 8 digits; the first four representing '",
"'the year, the next two the months, and the last tw... | Converts the given dateint to a datetime object, in local timezone.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
Returns
-------
datetime.datetime
A timezone-unaware datetime object representing the start of the given
... | [
"Converts",
"the",
"given",
"dateint",
"to",
"a",
"datetime",
"object",
"in",
"local",
"timezone",
"."
] | train | https://github.com/shaypal5/utilitime/blob/554ca05fa83c2dbf5d6cf9c9cfa6b03ee6cdb609/utilitime/dateint/dateint.py#L114-L133 |
shaypal5/utilitime | utilitime/dateint/dateint.py | dateint_to_weekday | def dateint_to_weekday(dateint, first_day='Monday'):
"""Returns the weekday of the given dateint.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
first_day : str, default 'Monday'
The first day of the week.
Returns
---... | python | def dateint_to_weekday(dateint, first_day='Monday'):
"""Returns the weekday of the given dateint.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
first_day : str, default 'Monday'
The first day of the week.
Returns
---... | [
"def",
"dateint_to_weekday",
"(",
"dateint",
",",
"first_day",
"=",
"'Monday'",
")",
":",
"weekday_ix",
"=",
"dateint_to_datetime",
"(",
"dateint",
")",
".",
"weekday",
"(",
")",
"return",
"(",
"weekday_ix",
"-",
"WEEKDAYS",
".",
"index",
"(",
"first_day",
"... | Returns the weekday of the given dateint.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
first_day : str, default 'Monday'
The first day of the week.
Returns
-------
int
The weekday of the given dateint, when ... | [
"Returns",
"the",
"weekday",
"of",
"the",
"given",
"dateint",
"."
] | train | https://github.com/shaypal5/utilitime/blob/554ca05fa83c2dbf5d6cf9c9cfa6b03ee6cdb609/utilitime/dateint/dateint.py#L136-L166 |
shaypal5/utilitime | utilitime/dateint/dateint.py | shift_dateint | def shift_dateint(dateint, day_shift):
"""Shifts the given dateint by the given amount of days.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
days : int
The number of days to shift the given dateint by. A negative number
... | python | def shift_dateint(dateint, day_shift):
"""Shifts the given dateint by the given amount of days.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
days : int
The number of days to shift the given dateint by. A negative number
... | [
"def",
"shift_dateint",
"(",
"dateint",
",",
"day_shift",
")",
":",
"dtime",
"=",
"dateint_to_datetime",
"(",
"dateint",
")",
"delta",
"=",
"timedelta",
"(",
"days",
"=",
"abs",
"(",
"day_shift",
")",
")",
"if",
"day_shift",
">",
"0",
":",
"dtime",
"=",
... | Shifts the given dateint by the given amount of days.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
days : int
The number of days to shift the given dateint by. A negative number
shifts the dateint backwards.
Returns... | [
"Shifts",
"the",
"given",
"dateint",
"by",
"the",
"given",
"amount",
"of",
"days",
"."
] | train | https://github.com/shaypal5/utilitime/blob/554ca05fa83c2dbf5d6cf9c9cfa6b03ee6cdb609/utilitime/dateint/dateint.py#L194-L226 |
shaypal5/utilitime | utilitime/dateint/dateint.py | dateint_range | def dateint_range(first_dateint, last_dateint):
"""Returns all dateints in the given dateint range.
Arguments
---------
first_dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
last_dateint : int
An integer object decipting a specific calendaric day;... | python | def dateint_range(first_dateint, last_dateint):
"""Returns all dateints in the given dateint range.
Arguments
---------
first_dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
last_dateint : int
An integer object decipting a specific calendaric day;... | [
"def",
"dateint_range",
"(",
"first_dateint",
",",
"last_dateint",
")",
":",
"first_datetime",
"=",
"dateint_to_datetime",
"(",
"first_dateint",
")",
"last_datetime",
"=",
"dateint_to_datetime",
"(",
"last_dateint",
")",
"delta",
"=",
"last_datetime",
"-",
"first_date... | Returns all dateints in the given dateint range.
Arguments
---------
first_dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
last_dateint : int
An integer object decipting a specific calendaric day; e.g. 20170108.
Returns
-------
iterable
... | [
"Returns",
"all",
"dateints",
"in",
"the",
"given",
"dateint",
"range",
"."
] | train | https://github.com/shaypal5/utilitime/blob/554ca05fa83c2dbf5d6cf9c9cfa6b03ee6cdb609/utilitime/dateint/dateint.py#L229-L262 |
shaypal5/utilitime | utilitime/dateint/dateint.py | dateint_week_by_dateint | def dateint_week_by_dateint(dateint, first_day='Monday'):
"""Return a dateint range of the week the given dateint belongs to.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
first_day : str, default 'Monday'
The first day of th... | python | def dateint_week_by_dateint(dateint, first_day='Monday'):
"""Return a dateint range of the week the given dateint belongs to.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
first_day : str, default 'Monday'
The first day of th... | [
"def",
"dateint_week_by_dateint",
"(",
"dateint",
",",
"first_day",
"=",
"'Monday'",
")",
":",
"weekday_ix",
"=",
"dateint_to_weekday",
"(",
"dateint",
",",
"first_day",
")",
"first_day_dateint",
"=",
"shift_dateint",
"(",
"dateint",
",",
"-",
"weekday_ix",
")",
... | Return a dateint range of the week the given dateint belongs to.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
first_day : str, default 'Monday'
The first day of the week.
Returns
-------
iterable
An iterable... | [
"Return",
"a",
"dateint",
"range",
"of",
"the",
"week",
"the",
"given",
"dateint",
"belongs",
"to",
"."
] | train | https://github.com/shaypal5/utilitime/blob/554ca05fa83c2dbf5d6cf9c9cfa6b03ee6cdb609/utilitime/dateint/dateint.py#L270-L289 |
shaypal5/utilitime | utilitime/dateint/dateint.py | dateint_difference | def dateint_difference(dateint1, dateint2):
"""Return the difference between two dateints in days.
Arguments
---------
dateint1 : int
An integer object decipting a specific calendaric day; e.g. 20161225.
dateint2 : int
An integer object decipting a specific calendaric day; e.g. 2016... | python | def dateint_difference(dateint1, dateint2):
"""Return the difference between two dateints in days.
Arguments
---------
dateint1 : int
An integer object decipting a specific calendaric day; e.g. 20161225.
dateint2 : int
An integer object decipting a specific calendaric day; e.g. 2016... | [
"def",
"dateint_difference",
"(",
"dateint1",
",",
"dateint2",
")",
":",
"dt1",
"=",
"dateint_to_datetime",
"(",
"dateint1",
")",
"dt2",
"=",
"dateint_to_datetime",
"(",
"dateint2",
")",
"delta",
"=",
"dt1",
"-",
"dt2",
"return",
"abs",
"(",
"delta",
".",
... | Return the difference between two dateints in days.
Arguments
---------
dateint1 : int
An integer object decipting a specific calendaric day; e.g. 20161225.
dateint2 : int
An integer object decipting a specific calendaric day; e.g. 20161225.
Returns
-------
int
The ... | [
"Return",
"the",
"difference",
"between",
"two",
"dateints",
"in",
"days",
"."
] | train | https://github.com/shaypal5/utilitime/blob/554ca05fa83c2dbf5d6cf9c9cfa6b03ee6cdb609/utilitime/dateint/dateint.py#L292-L310 |
riordan/py-copyfile | copyfile/copyfile.py | touch | def touch(fname, times=None):
"""Creates an empty file at fname, creating path if necessary
Answer taken from Stack Overflow http://stackoverflow.com/a/1160227
User: ephemient http://stackoverflow.com/users/20713
License: CC-BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0/
"""
fpath, f ... | python | def touch(fname, times=None):
"""Creates an empty file at fname, creating path if necessary
Answer taken from Stack Overflow http://stackoverflow.com/a/1160227
User: ephemient http://stackoverflow.com/users/20713
License: CC-BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0/
"""
fpath, f ... | [
"def",
"touch",
"(",
"fname",
",",
"times",
"=",
"None",
")",
":",
"fpath",
",",
"f",
"=",
"os",
".",
"path",
".",
"split",
"(",
"fname",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"fpath",
")",
":",
"os",
".",
"makedirs",
"(",
... | Creates an empty file at fname, creating path if necessary
Answer taken from Stack Overflow http://stackoverflow.com/a/1160227
User: ephemient http://stackoverflow.com/users/20713
License: CC-BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0/ | [
"Creates",
"an",
"empty",
"file",
"at",
"fname",
"creating",
"path",
"if",
"necessary",
"Answer",
"taken",
"from",
"Stack",
"Overflow",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"1160227",
"User",
":",
"ephemient",
"http",
":",
"//",
... | train | https://github.com/riordan/py-copyfile/blob/ea7c45de8ac8e6f3a8a9dc0deee87f8f882a8e79/copyfile/copyfile.py#L6-L17 |
riordan/py-copyfile | copyfile/copyfile.py | copyFile | def copyFile(src, dest):
"""Copies a source file to a destination whose path may not yet exist.
Keyword arguments:
src -- Source path to a file (string)
dest -- Path for destination file (also a string)
"""
#Src Exists?
try:
if os.path.isfile(src):
dpath, dfile = os.path... | python | def copyFile(src, dest):
"""Copies a source file to a destination whose path may not yet exist.
Keyword arguments:
src -- Source path to a file (string)
dest -- Path for destination file (also a string)
"""
#Src Exists?
try:
if os.path.isfile(src):
dpath, dfile = os.path... | [
"def",
"copyFile",
"(",
"src",
",",
"dest",
")",
":",
"#Src Exists?",
"try",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"src",
")",
":",
"dpath",
",",
"dfile",
"=",
"os",
".",
"path",
".",
"split",
"(",
"dest",
")",
"if",
"not",
"os",
".... | Copies a source file to a destination whose path may not yet exist.
Keyword arguments:
src -- Source path to a file (string)
dest -- Path for destination file (also a string) | [
"Copies",
"a",
"source",
"file",
"to",
"a",
"destination",
"whose",
"path",
"may",
"not",
"yet",
"exist",
"."
] | train | https://github.com/riordan/py-copyfile/blob/ea7c45de8ac8e6f3a8a9dc0deee87f8f882a8e79/copyfile/copyfile.py#L19-L45 |
xtrementl/focus | focus/plugin/modules/notify.py | _terminal_notifier | def _terminal_notifier(title, message):
""" Shows user notification message via `terminal-notifier` command.
`title`
Notification title.
`message`
Notification message.
"""
try:
paths = common.extract_app_paths(['terminal-notifier'])
except ValueErro... | python | def _terminal_notifier(title, message):
""" Shows user notification message via `terminal-notifier` command.
`title`
Notification title.
`message`
Notification message.
"""
try:
paths = common.extract_app_paths(['terminal-notifier'])
except ValueErro... | [
"def",
"_terminal_notifier",
"(",
"title",
",",
"message",
")",
":",
"try",
":",
"paths",
"=",
"common",
".",
"extract_app_paths",
"(",
"[",
"'terminal-notifier'",
"]",
")",
"except",
"ValueError",
":",
"pass",
"common",
".",
"shell_process",
"(",
"[",
"path... | Shows user notification message via `terminal-notifier` command.
`title`
Notification title.
`message`
Notification message. | [
"Shows",
"user",
"notification",
"message",
"via",
"terminal",
"-",
"notifier",
"command",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/notify.py#L12-L26 |
xtrementl/focus | focus/plugin/modules/notify.py | _growlnotify | def _growlnotify(title, message):
""" Shows growl notification message via `growlnotify` command.
`title`
Notification title.
`message`
Notification message.
"""
try:
paths = common.extract_app_paths(['growlnotify'])
except ValueError:
return... | python | def _growlnotify(title, message):
""" Shows growl notification message via `growlnotify` command.
`title`
Notification title.
`message`
Notification message.
"""
try:
paths = common.extract_app_paths(['growlnotify'])
except ValueError:
return... | [
"def",
"_growlnotify",
"(",
"title",
",",
"message",
")",
":",
"try",
":",
"paths",
"=",
"common",
".",
"extract_app_paths",
"(",
"[",
"'growlnotify'",
"]",
")",
"except",
"ValueError",
":",
"return",
"common",
".",
"shell_process",
"(",
"[",
"paths",
"[",... | Shows growl notification message via `growlnotify` command.
`title`
Notification title.
`message`
Notification message. | [
"Shows",
"growl",
"notification",
"message",
"via",
"growlnotify",
"command",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/notify.py#L29-L43 |
xtrementl/focus | focus/plugin/modules/notify.py | _osx_popup | def _osx_popup(title, message):
""" Shows a popup dialog message via System Events daemon.
`title`
Notification title.
`message`
Notification message.
"""
message = message.replace('"', '\\"') # escape message
# build applescript
script = """
tell... | python | def _osx_popup(title, message):
""" Shows a popup dialog message via System Events daemon.
`title`
Notification title.
`message`
Notification message.
"""
message = message.replace('"', '\\"') # escape message
# build applescript
script = """
tell... | [
"def",
"_osx_popup",
"(",
"title",
",",
"message",
")",
":",
"message",
"=",
"message",
".",
"replace",
"(",
"'\"'",
",",
"'\\\\\"'",
")",
"# escape message",
"# build applescript",
"script",
"=",
"\"\"\"\n tell application \"System Events\"\n display dialog \"{... | Shows a popup dialog message via System Events daemon.
`title`
Notification title.
`message`
Notification message. | [
"Shows",
"a",
"popup",
"dialog",
"message",
"via",
"System",
"Events",
"daemon",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/notify.py#L46-L64 |
xtrementl/focus | focus/plugin/modules/notify.py | _dbus_notify | def _dbus_notify(title, message):
""" Shows system notification message via dbus.
`title`
Notification title.
`message`
Notification message.
"""
try:
# fetch main account manager interface
bus = dbus.SessionBus()
obj = bus.get_object('or... | python | def _dbus_notify(title, message):
""" Shows system notification message via dbus.
`title`
Notification title.
`message`
Notification message.
"""
try:
# fetch main account manager interface
bus = dbus.SessionBus()
obj = bus.get_object('or... | [
"def",
"_dbus_notify",
"(",
"title",
",",
"message",
")",
":",
"try",
":",
"# fetch main account manager interface",
"bus",
"=",
"dbus",
".",
"SessionBus",
"(",
")",
"obj",
"=",
"bus",
".",
"get_object",
"(",
"'org.freedesktop.Notifications'",
",",
"'/org/freedesk... | Shows system notification message via dbus.
`title`
Notification title.
`message`
Notification message. | [
"Shows",
"system",
"notification",
"message",
"via",
"dbus",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/notify.py#L67-L89 |
xtrementl/focus | focus/plugin/modules/notify.py | Notify._notify | def _notify(self, task, message):
""" Shows system notification message according to system requirements.
`message`
Status message.
"""
if self.notify_func:
message = common.to_utf8(message.strip())
title = common.to_utf8(u'Focus ({0})'.f... | python | def _notify(self, task, message):
""" Shows system notification message according to system requirements.
`message`
Status message.
"""
if self.notify_func:
message = common.to_utf8(message.strip())
title = common.to_utf8(u'Focus ({0})'.f... | [
"def",
"_notify",
"(",
"self",
",",
"task",
",",
"message",
")",
":",
"if",
"self",
".",
"notify_func",
":",
"message",
"=",
"common",
".",
"to_utf8",
"(",
"message",
".",
"strip",
"(",
")",
")",
"title",
"=",
"common",
".",
"to_utf8",
"(",
"u'Focus ... | Shows system notification message according to system requirements.
`message`
Status message. | [
"Shows",
"system",
"notification",
"message",
"according",
"to",
"system",
"requirements",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/notify.py#L154-L164 |
xtrementl/focus | focus/plugin/modules/notify.py | Notify.parse_option | def parse_option(self, option, block_name, message):
""" Parse show, end_show, and timer_show options.
"""
if option == 'show':
option = 'start_' + option
key = option.split('_', 1)[0]
self.messages[key] = message | python | def parse_option(self, option, block_name, message):
""" Parse show, end_show, and timer_show options.
"""
if option == 'show':
option = 'start_' + option
key = option.split('_', 1)[0]
self.messages[key] = message | [
"def",
"parse_option",
"(",
"self",
",",
"option",
",",
"block_name",
",",
"message",
")",
":",
"if",
"option",
"==",
"'show'",
":",
"option",
"=",
"'start_'",
"+",
"option",
"key",
"=",
"option",
".",
"split",
"(",
"'_'",
",",
"1",
")",
"[",
"0",
... | Parse show, end_show, and timer_show options. | [
"Parse",
"show",
"end_show",
"and",
"timer_show",
"options",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/notify.py#L166-L174 |
minhhoit/yacms | yacms/forms/page_processors.py | format_value | def format_value(value):
"""
Convert a list into a comma separated string, for displaying
select multiple values in emails.
"""
if isinstance(value, list):
value = ", ".join([v.strip() for v in value])
return value | python | def format_value(value):
"""
Convert a list into a comma separated string, for displaying
select multiple values in emails.
"""
if isinstance(value, list):
value = ", ".join([v.strip() for v in value])
return value | [
"def",
"format_value",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"value",
"=",
"\", \"",
".",
"join",
"(",
"[",
"v",
".",
"strip",
"(",
")",
"for",
"v",
"in",
"value",
"]",
")",
"return",
"value"
] | Convert a list into a comma separated string, for displaying
select multiple values in emails. | [
"Convert",
"a",
"list",
"into",
"a",
"comma",
"separated",
"string",
"for",
"displaying",
"select",
"multiple",
"values",
"in",
"emails",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/forms/page_processors.py#L15-L22 |
minhhoit/yacms | yacms/forms/page_processors.py | form_processor | def form_processor(request, page):
"""
Display a built form and handle submission.
"""
form = FormForForm(page.form, RequestContext(request),
request.POST or None, request.FILES or None)
if form.is_valid():
url = page.get_absolute_url() + "?sent=1"
if is_spam(r... | python | def form_processor(request, page):
"""
Display a built form and handle submission.
"""
form = FormForForm(page.form, RequestContext(request),
request.POST or None, request.FILES or None)
if form.is_valid():
url = page.get_absolute_url() + "?sent=1"
if is_spam(r... | [
"def",
"form_processor",
"(",
"request",
",",
"page",
")",
":",
"form",
"=",
"FormForForm",
"(",
"page",
".",
"form",
",",
"RequestContext",
"(",
"request",
")",
",",
"request",
".",
"POST",
"or",
"None",
",",
"request",
".",
"FILES",
"or",
"None",
")"... | Display a built form and handle submission. | [
"Display",
"a",
"built",
"form",
"and",
"handle",
"submission",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/forms/page_processors.py#L26-L68 |
ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/browser/viewlets.py | JoinViewlet.visible | def visible(self):
"""
Join viewlet is shown if:
* In a 'self-join' workspace
* User is not already a member
"""
if not self.in_workspace():
return False
if not self.context.join_policy == "self":
return False
user = api.user.get_... | python | def visible(self):
"""
Join viewlet is shown if:
* In a 'self-join' workspace
* User is not already a member
"""
if not self.in_workspace():
return False
if not self.context.join_policy == "self":
return False
user = api.user.get_... | [
"def",
"visible",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"in_workspace",
"(",
")",
":",
"return",
"False",
"if",
"not",
"self",
".",
"context",
".",
"join_policy",
"==",
"\"self\"",
":",
"return",
"False",
"user",
"=",
"api",
".",
"user",
"... | Join viewlet is shown if:
* In a 'self-join' workspace
* User is not already a member | [
"Join",
"viewlet",
"is",
"shown",
"if",
":",
"*",
"In",
"a",
"self",
"-",
"join",
"workspace",
"*",
"User",
"is",
"not",
"already",
"a",
"member"
] | train | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/browser/viewlets.py#L16-L33 |
ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/browser/viewlets.py | SharingViewlet.visible | def visible(self):
"""
Only shown on the sharing view
"""
context_state = api.content.get_view(context=self.context,
request=self.request,
name="plone_context_state")
url = context_state.cur... | python | def visible(self):
"""
Only shown on the sharing view
"""
context_state = api.content.get_view(context=self.context,
request=self.request,
name="plone_context_state")
url = context_state.cur... | [
"def",
"visible",
"(",
"self",
")",
":",
"context_state",
"=",
"api",
".",
"content",
".",
"get_view",
"(",
"context",
"=",
"self",
".",
"context",
",",
"request",
"=",
"self",
".",
"request",
",",
"name",
"=",
"\"plone_context_state\"",
")",
"url",
"=",... | Only shown on the sharing view | [
"Only",
"shown",
"on",
"the",
"sharing",
"view"
] | train | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/browser/viewlets.py#L49-L57 |
ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/browser/viewlets.py | SharingViewlet.active_participant_policy | def active_participant_policy(self):
""" Get the title of the current participation policy """
key = self.context.participant_policy
policy = PARTICIPANT_POLICY.get(key)
return policy['title'] | python | def active_participant_policy(self):
""" Get the title of the current participation policy """
key = self.context.participant_policy
policy = PARTICIPANT_POLICY.get(key)
return policy['title'] | [
"def",
"active_participant_policy",
"(",
"self",
")",
":",
"key",
"=",
"self",
".",
"context",
".",
"participant_policy",
"policy",
"=",
"PARTICIPANT_POLICY",
".",
"get",
"(",
"key",
")",
"return",
"policy",
"[",
"'title'",
"]"
] | Get the title of the current participation policy | [
"Get",
"the",
"title",
"of",
"the",
"current",
"participation",
"policy"
] | train | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/browser/viewlets.py#L59-L63 |
fstab50/metal | metal/script_utils.py | bool_assignment | def bool_assignment(arg, patterns=None):
"""
Summary:
Enforces correct bool argment assignment
Arg:
:arg (*): arg which must be interpreted as either bool True or False
Returns:
bool assignment | TYPE: bool
"""
arg = str(arg) # only eval type str
try:
if p... | python | def bool_assignment(arg, patterns=None):
"""
Summary:
Enforces correct bool argment assignment
Arg:
:arg (*): arg which must be interpreted as either bool True or False
Returns:
bool assignment | TYPE: bool
"""
arg = str(arg) # only eval type str
try:
if p... | [
"def",
"bool_assignment",
"(",
"arg",
",",
"patterns",
"=",
"None",
")",
":",
"arg",
"=",
"str",
"(",
"arg",
")",
"# only eval type str",
"try",
":",
"if",
"patterns",
"is",
"None",
":",
"patterns",
"=",
"(",
"(",
"re",
".",
"compile",
"(",
"r'^(true|f... | Summary:
Enforces correct bool argment assignment
Arg:
:arg (*): arg which must be interpreted as either bool True or False
Returns:
bool assignment | TYPE: bool | [
"Summary",
":",
"Enforces",
"correct",
"bool",
"argment",
"assignment",
"Arg",
":",
":",
"arg",
"(",
"*",
")",
":",
"arg",
"which",
"must",
"be",
"interpreted",
"as",
"either",
"bool",
"True",
"or",
"False",
"Returns",
":",
"bool",
"assignment",
"|",
"TY... | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/script_utils.py#L36-L60 |
fstab50/metal | metal/script_utils.py | convert_strtime_datetime | def convert_strtime_datetime(dt_str):
""" Converts datetime isoformat string to datetime (dt) object
Args:
:dt_str (str): input string in '2017-12-30T18:48:00.353Z' form
or similar
Returns:
TYPE: datetime object
"""
dt, _, us = dt_str.partition(".")
dt = datetime.datet... | python | def convert_strtime_datetime(dt_str):
""" Converts datetime isoformat string to datetime (dt) object
Args:
:dt_str (str): input string in '2017-12-30T18:48:00.353Z' form
or similar
Returns:
TYPE: datetime object
"""
dt, _, us = dt_str.partition(".")
dt = datetime.datet... | [
"def",
"convert_strtime_datetime",
"(",
"dt_str",
")",
":",
"dt",
",",
"_",
",",
"us",
"=",
"dt_str",
".",
"partition",
"(",
"\".\"",
")",
"dt",
"=",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"dt",
",",
"\"%Y-%m-%dT%H:%M:%S\"",
")",
"us",
"=",
... | Converts datetime isoformat string to datetime (dt) object
Args:
:dt_str (str): input string in '2017-12-30T18:48:00.353Z' form
or similar
Returns:
TYPE: datetime object | [
"Converts",
"datetime",
"isoformat",
"string",
"to",
"datetime",
"(",
"dt",
")",
"object"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/script_utils.py#L63-L75 |
fstab50/metal | metal/script_utils.py | convert_timedelta | def convert_timedelta(duration):
"""
Summary:
Convert duration into component time units
Args:
:duration (datetime.timedelta): time duration to convert
Returns:
days, hours, minutes, seconds | TYPE: tuple (integers)
"""
days, seconds = duration.days, duration.seconds
... | python | def convert_timedelta(duration):
"""
Summary:
Convert duration into component time units
Args:
:duration (datetime.timedelta): time duration to convert
Returns:
days, hours, minutes, seconds | TYPE: tuple (integers)
"""
days, seconds = duration.days, duration.seconds
... | [
"def",
"convert_timedelta",
"(",
"duration",
")",
":",
"days",
",",
"seconds",
"=",
"duration",
".",
"days",
",",
"duration",
".",
"seconds",
"hours",
"=",
"seconds",
"//",
"3600",
"minutes",
"=",
"(",
"seconds",
"%",
"3600",
")",
"//",
"60",
"seconds",
... | Summary:
Convert duration into component time units
Args:
:duration (datetime.timedelta): time duration to convert
Returns:
days, hours, minutes, seconds | TYPE: tuple (integers) | [
"Summary",
":",
"Convert",
"duration",
"into",
"component",
"time",
"units",
"Args",
":",
":",
"duration",
"(",
"datetime",
".",
"timedelta",
")",
":",
"time",
"duration",
"to",
"convert",
"Returns",
":",
"days",
"hours",
"minutes",
"seconds",
"|",
"TYPE",
... | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/script_utils.py#L78-L91 |
fstab50/metal | metal/script_utils.py | convert_dt_time | def convert_dt_time(duration, return_iter=False):
"""
Summary:
convert timedelta objects to human readable output
Args:
:duration (datetime.timedelta): time duration to convert
:return_iter (tuple): tuple containing time sequence
Returns:
days, hours, minutes, seconds | ... | python | def convert_dt_time(duration, return_iter=False):
"""
Summary:
convert timedelta objects to human readable output
Args:
:duration (datetime.timedelta): time duration to convert
:return_iter (tuple): tuple containing time sequence
Returns:
days, hours, minutes, seconds | ... | [
"def",
"convert_dt_time",
"(",
"duration",
",",
"return_iter",
"=",
"False",
")",
":",
"try",
":",
"days",
",",
"hours",
",",
"minutes",
",",
"seconds",
"=",
"convert_timedelta",
"(",
"duration",
")",
"if",
"return_iter",
":",
"return",
"days",
",",
"hours... | Summary:
convert timedelta objects to human readable output
Args:
:duration (datetime.timedelta): time duration to convert
:return_iter (tuple): tuple containing time sequence
Returns:
days, hours, minutes, seconds | TYPE: tuple (integers), OR
human readable, notated uni... | [
"Summary",
":",
"convert",
"timedelta",
"objects",
"to",
"human",
"readable",
"output",
"Args",
":",
":",
"duration",
"(",
"datetime",
".",
"timedelta",
")",
":",
"time",
"duration",
"to",
"convert",
":",
"return_iter",
"(",
"tuple",
")",
":",
"tuple",
"co... | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/script_utils.py#L94-L130 |
fstab50/metal | metal/script_utils.py | debug_mode | def debug_mode(header, data_object, debug=False, halt=False):
""" debug output """
if debug:
print('\n ' + str(header) + '\n')
try:
export_json_object(data_object)
except Exception:
print(data_object)
if halt:
sys.exit(0)
return True | python | def debug_mode(header, data_object, debug=False, halt=False):
""" debug output """
if debug:
print('\n ' + str(header) + '\n')
try:
export_json_object(data_object)
except Exception:
print(data_object)
if halt:
sys.exit(0)
return True | [
"def",
"debug_mode",
"(",
"header",
",",
"data_object",
",",
"debug",
"=",
"False",
",",
"halt",
"=",
"False",
")",
":",
"if",
"debug",
":",
"print",
"(",
"'\\n '",
"+",
"str",
"(",
"header",
")",
"+",
"'\\n'",
")",
"try",
":",
"export_json_object",
... | debug output | [
"debug",
"output"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/script_utils.py#L133-L143 |
fstab50/metal | metal/script_utils.py | get_os | def get_os(detailed=False):
"""
Summary:
Retrieve local operating system environment characteristics
Args:
:user (str): USERNAME, only required when run on windows os
Returns:
TYPE: dict object containing key, value pairs describing
os information
"""
try:
... | python | def get_os(detailed=False):
"""
Summary:
Retrieve local operating system environment characteristics
Args:
:user (str): USERNAME, only required when run on windows os
Returns:
TYPE: dict object containing key, value pairs describing
os information
"""
try:
... | [
"def",
"get_os",
"(",
"detailed",
"=",
"False",
")",
":",
"try",
":",
"os_type",
"=",
"platform",
".",
"system",
"(",
")",
"if",
"os_type",
"==",
"'Linux'",
":",
"os_detail",
"=",
"platform",
".",
"uname",
"(",
")",
"distribution",
"=",
"platform",
"."... | Summary:
Retrieve local operating system environment characteristics
Args:
:user (str): USERNAME, only required when run on windows os
Returns:
TYPE: dict object containing key, value pairs describing
os information | [
"Summary",
":",
"Retrieve",
"local",
"operating",
"system",
"environment",
"characteristics",
"Args",
":",
":",
"user",
"(",
"str",
")",
":",
"USERNAME",
"only",
"required",
"when",
"run",
"on",
"windows",
"os",
"Returns",
":",
"TYPE",
":",
"dict",
"object",... | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/script_utils.py#L146-L191 |
fstab50/metal | metal/script_utils.py | awscli_defaults | def awscli_defaults(os_type=None):
"""
Summary:
Parse, update local awscli config credentials
Args:
:user (str): USERNAME, only required when run on windows os
Returns:
TYPE: dict object containing key, value pairs describing
os information
"""
try:
if o... | python | def awscli_defaults(os_type=None):
"""
Summary:
Parse, update local awscli config credentials
Args:
:user (str): USERNAME, only required when run on windows os
Returns:
TYPE: dict object containing key, value pairs describing
os information
"""
try:
if o... | [
"def",
"awscli_defaults",
"(",
"os_type",
"=",
"None",
")",
":",
"try",
":",
"if",
"os_type",
"is",
"None",
":",
"os_type",
"=",
"platform",
".",
"system",
"(",
")",
"if",
"os_type",
"==",
"'Linux'",
":",
"HOME",
"=",
"os",
".",
"environ",
"[",
"'HOM... | Summary:
Parse, update local awscli config credentials
Args:
:user (str): USERNAME, only required when run on windows os
Returns:
TYPE: dict object containing key, value pairs describing
os information | [
"Summary",
":",
"Parse",
"update",
"local",
"awscli",
"config",
"credentials",
"Args",
":",
":",
"user",
"(",
"str",
")",
":",
"USERNAME",
"only",
"required",
"when",
"run",
"on",
"windows",
"os",
"Returns",
":",
"TYPE",
":",
"dict",
"object",
"containing"... | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/script_utils.py#L194-L235 |
fstab50/metal | metal/script_utils.py | config_init | def config_init(config_file, json_config_obj, config_dirname=None):
"""
Summary:
Creates local config from JSON seed template
Args:
:config_file (str): filesystem object containing json dict of config values
:json_config_obj (json): data to be written to config_file
:config_... | python | def config_init(config_file, json_config_obj, config_dirname=None):
"""
Summary:
Creates local config from JSON seed template
Args:
:config_file (str): filesystem object containing json dict of config values
:json_config_obj (json): data to be written to config_file
:config_... | [
"def",
"config_init",
"(",
"config_file",
",",
"json_config_obj",
",",
"config_dirname",
"=",
"None",
")",
":",
"HOME",
"=",
"os",
".",
"environ",
"[",
"'HOME'",
"]",
"# client config dir",
"if",
"config_dirname",
":",
"dir_path",
"=",
"HOME",
"+",
"'/'",
"+... | Summary:
Creates local config from JSON seed template
Args:
:config_file (str): filesystem object containing json dict of config values
:json_config_obj (json): data to be written to config_file
:config_dirname (str): dir name containing config_file
Returns:
TYPE: bool,... | [
"Summary",
":",
"Creates",
"local",
"config",
"from",
"JSON",
"seed",
"template",
"Args",
":",
":",
"config_file",
"(",
"str",
")",
":",
"filesystem",
"object",
"containing",
"json",
"dict",
"of",
"config",
"values",
":",
"json_config_obj",
"(",
"json",
")",... | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/script_utils.py#L238-L263 |
fstab50/metal | metal/script_utils.py | export_json_object | def export_json_object(dict_obj, filename=None):
"""
Summary:
exports object to block filesystem object
Args:
:dict_obj (dict): dictionary object
:filename (str): name of file to be exported (optional)
Returns:
True | False Boolean export status
"""
try:
... | python | def export_json_object(dict_obj, filename=None):
"""
Summary:
exports object to block filesystem object
Args:
:dict_obj (dict): dictionary object
:filename (str): name of file to be exported (optional)
Returns:
True | False Boolean export status
"""
try:
... | [
"def",
"export_json_object",
"(",
"dict_obj",
",",
"filename",
"=",
"None",
")",
":",
"try",
":",
"if",
"filename",
":",
"try",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"handle",
":",
"handle",
".",
"write",
"(",
"json",
".",
"dum... | Summary:
exports object to block filesystem object
Args:
:dict_obj (dict): dictionary object
:filename (str): name of file to be exported (optional)
Returns:
True | False Boolean export status | [
"Summary",
":",
"exports",
"object",
"to",
"block",
"filesystem",
"object"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/script_utils.py#L266-L304 |
fstab50/metal | metal/script_utils.py | import_file_object | def import_file_object(filename):
"""
Summary:
Imports block filesystem object
Args:
:filename (str): block filesystem object
Returns:
dictionary obj (valid json file), file data object
"""
try:
handle = open(filename, 'r')
file_obj = handle.read()
... | python | def import_file_object(filename):
"""
Summary:
Imports block filesystem object
Args:
:filename (str): block filesystem object
Returns:
dictionary obj (valid json file), file data object
"""
try:
handle = open(filename, 'r')
file_obj = handle.read()
... | [
"def",
"import_file_object",
"(",
"filename",
")",
":",
"try",
":",
"handle",
"=",
"open",
"(",
"filename",
",",
"'r'",
")",
"file_obj",
"=",
"handle",
".",
"read",
"(",
")",
"dict_obj",
"=",
"json",
".",
"loads",
"(",
"file_obj",
")",
"except",
"IOErr... | Summary:
Imports block filesystem object
Args:
:filename (str): block filesystem object
Returns:
dictionary obj (valid json file), file data object | [
"Summary",
":",
"Imports",
"block",
"filesystem",
"object",
"Args",
":",
":",
"filename",
"(",
"str",
")",
":",
"block",
"filesystem",
"object",
"Returns",
":",
"dictionary",
"obj",
"(",
"valid",
"json",
"file",
")",
"file",
"data",
"object"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/script_utils.py#L307-L332 |
fstab50/metal | metal/script_utils.py | json_integrity | def json_integrity(baseline, suspect):
"""
Summary:
Validates baseline dict against suspect dict to ensure contain USERNAME
k,v parameters.
Args:
baseline (dict): baseline json structure
suspect (dict): json object validated against baseline structure
Returns:
Suc... | python | def json_integrity(baseline, suspect):
"""
Summary:
Validates baseline dict against suspect dict to ensure contain USERNAME
k,v parameters.
Args:
baseline (dict): baseline json structure
suspect (dict): json object validated against baseline structure
Returns:
Suc... | [
"def",
"json_integrity",
"(",
"baseline",
",",
"suspect",
")",
":",
"try",
":",
"for",
"k",
",",
"v",
"in",
"baseline",
".",
"items",
"(",
")",
":",
"for",
"ks",
",",
"vs",
"in",
"suspect",
".",
"items",
"(",
")",
":",
"keys_baseline",
"=",
"set",
... | Summary:
Validates baseline dict against suspect dict to ensure contain USERNAME
k,v parameters.
Args:
baseline (dict): baseline json structure
suspect (dict): json object validated against baseline structure
Returns:
Success (matches baseline) | Failure (no match), TYPE:... | [
"Summary",
":",
"Validates",
"baseline",
"dict",
"against",
"suspect",
"dict",
"to",
"ensure",
"contain",
"USERNAME",
"k",
"v",
"parameters",
".",
"Args",
":",
"baseline",
"(",
"dict",
")",
":",
"baseline",
"json",
"structure",
"suspect",
"(",
"dict",
")",
... | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/script_utils.py#L335-L361 |
fstab50/metal | metal/script_utils.py | json_integrity_multilevel | def json_integrity_multilevel(d1, d2):
""" still under development """
keys = [x for x in d2]
for key in keys:
d1_keys = set(d1.keys())
d2_keys = set(d2.keys())
intersect_keys = d1_keys.intersection(d2_keys)
added = d1_keys - d2_keys
removed = d2_keys - d1_keys
... | python | def json_integrity_multilevel(d1, d2):
""" still under development """
keys = [x for x in d2]
for key in keys:
d1_keys = set(d1.keys())
d2_keys = set(d2.keys())
intersect_keys = d1_keys.intersection(d2_keys)
added = d1_keys - d2_keys
removed = d2_keys - d1_keys
... | [
"def",
"json_integrity_multilevel",
"(",
"d1",
",",
"d2",
")",
":",
"keys",
"=",
"[",
"x",
"for",
"x",
"in",
"d2",
"]",
"for",
"key",
"in",
"keys",
":",
"d1_keys",
"=",
"set",
"(",
"d1",
".",
"keys",
"(",
")",
")",
"d2_keys",
"=",
"set",
"(",
"... | still under development | [
"still",
"under",
"development"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/script_utils.py#L364-L388 |
fstab50/metal | metal/script_utils.py | read_local_config | def read_local_config(cfg):
""" Parses local config file for override values
Args:
:local_file (str): filename of local config file
Returns:
dict object of values contained in local config file
"""
try:
if os.path.exists(cfg):
config = import_file_object(cfg)
... | python | def read_local_config(cfg):
""" Parses local config file for override values
Args:
:local_file (str): filename of local config file
Returns:
dict object of values contained in local config file
"""
try:
if os.path.exists(cfg):
config = import_file_object(cfg)
... | [
"def",
"read_local_config",
"(",
"cfg",
")",
":",
"try",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"cfg",
")",
":",
"config",
"=",
"import_file_object",
"(",
"cfg",
")",
"return",
"config",
"else",
":",
"logger",
".",
"warning",
"(",
"'%s: loca... | Parses local config file for override values
Args:
:local_file (str): filename of local config file
Returns:
dict object of values contained in local config file | [
"Parses",
"local",
"config",
"file",
"for",
"override",
"values"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/script_utils.py#L391-L412 |
fstab50/metal | metal/script_utils.py | os_parityPath | def os_parityPath(path):
"""
Converts unix paths to correct windows equivalents.
Unix native paths remain unchanged (no effect)
"""
path = os.path.normpath(os.path.expanduser(path))
if path.startswith('\\'):
return 'C:' + path
return path | python | def os_parityPath(path):
"""
Converts unix paths to correct windows equivalents.
Unix native paths remain unchanged (no effect)
"""
path = os.path.normpath(os.path.expanduser(path))
if path.startswith('\\'):
return 'C:' + path
return path | [
"def",
"os_parityPath",
"(",
"path",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"path",
")",
")",
"if",
"path",
".",
"startswith",
"(",
"'\\\\'",
")",
":",
"return",
"'C:'",
"+",
"path... | Converts unix paths to correct windows equivalents.
Unix native paths remain unchanged (no effect) | [
"Converts",
"unix",
"paths",
"to",
"correct",
"windows",
"equivalents",
".",
"Unix",
"native",
"paths",
"remain",
"unchanged",
"(",
"no",
"effect",
")"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/script_utils.py#L465-L473 |
minhhoit/yacms | yacms/twitter/admin.py | TweetableAdminMixin.formfield_for_dbfield | def formfield_for_dbfield(self, db_field, **kwargs):
"""
Adds the "Send to Twitter" checkbox after the "status" field,
provided by any ``Displayable`` models. The approach here is
quite a hack, however the sane approach of using a custom
form with a boolean field defined, and the... | python | def formfield_for_dbfield(self, db_field, **kwargs):
"""
Adds the "Send to Twitter" checkbox after the "status" field,
provided by any ``Displayable`` models. The approach here is
quite a hack, however the sane approach of using a custom
form with a boolean field defined, and the... | [
"def",
"formfield_for_dbfield",
"(",
"self",
",",
"db_field",
",",
"*",
"*",
"kwargs",
")",
":",
"formfield",
"=",
"super",
"(",
"TweetableAdminMixin",
",",
"self",
")",
".",
"formfield_for_dbfield",
"(",
"db_field",
",",
"*",
"*",
"kwargs",
")",
"if",
"Ap... | Adds the "Send to Twitter" checkbox after the "status" field,
provided by any ``Displayable`` models. The approach here is
quite a hack, however the sane approach of using a custom
form with a boolean field defined, and then adding it to the
formssets attribute of the admin class fell ap... | [
"Adds",
"the",
"Send",
"to",
"Twitter",
"checkbox",
"after",
"the",
"status",
"field",
"provided",
"by",
"any",
"Displayable",
"models",
".",
"The",
"approach",
"here",
"is",
"quite",
"a",
"hack",
"however",
"the",
"sane",
"approach",
"of",
"using",
"a",
"... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/twitter/admin.py#L31-L50 |
minhhoit/yacms | yacms/twitter/admin.py | TweetableAdminMixin.save_model | def save_model(self, request, obj, form, change):
"""
Sends a tweet with the title/short_url if applicable.
"""
super(TweetableAdminMixin, self).save_model(request, obj, form, change)
if Api and request.POST.get("send_tweet", False):
auth_settings = get_auth_settings(... | python | def save_model(self, request, obj, form, change):
"""
Sends a tweet with the title/short_url if applicable.
"""
super(TweetableAdminMixin, self).save_model(request, obj, form, change)
if Api and request.POST.get("send_tweet", False):
auth_settings = get_auth_settings(... | [
"def",
"save_model",
"(",
"self",
",",
"request",
",",
"obj",
",",
"form",
",",
"change",
")",
":",
"super",
"(",
"TweetableAdminMixin",
",",
"self",
")",
".",
"save_model",
"(",
"request",
",",
"obj",
",",
"form",
",",
"change",
")",
"if",
"Api",
"a... | Sends a tweet with the title/short_url if applicable. | [
"Sends",
"a",
"tweet",
"with",
"the",
"title",
"/",
"short_url",
"if",
"applicable",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/twitter/admin.py#L52-L62 |
lizardsystem/tags2sdists | tags2sdists/utils.py | command | def command(cmd):
"""Execute command and raise an exception upon an error.
>>> 'README' in command('ls')
True
>>> command('nonexistingcommand') #doctest: +ELLIPSIS
Traceback (most recent call last):
...
SdistCreationError
"""
status, out = commands.getstatusoutput(cmd)... | python | def command(cmd):
"""Execute command and raise an exception upon an error.
>>> 'README' in command('ls')
True
>>> command('nonexistingcommand') #doctest: +ELLIPSIS
Traceback (most recent call last):
...
SdistCreationError
"""
status, out = commands.getstatusoutput(cmd)... | [
"def",
"command",
"(",
"cmd",
")",
":",
"status",
",",
"out",
"=",
"commands",
".",
"getstatusoutput",
"(",
"cmd",
")",
"if",
"status",
"is",
"not",
"0",
":",
"logger",
".",
"error",
"(",
"\"Something went wrong:\"",
")",
"logger",
".",
"error",
"(",
"... | Execute command and raise an exception upon an error.
>>> 'README' in command('ls')
True
>>> command('nonexistingcommand') #doctest: +ELLIPSIS
Traceback (most recent call last):
...
SdistCreationError | [
"Execute",
"command",
"and",
"raise",
"an",
"exception",
"upon",
"an",
"error",
"."
] | train | https://github.com/lizardsystem/tags2sdists/blob/72f3c664940133e3238fca4d87edcc36b9775e48/tags2sdists/utils.py#L12-L28 |
thespacedoctor/transientNamer | transientNamer/search.py | search.sources | def sources(
self):
"""*The results of the search returned as a python list of dictionaries*
**Usage:**
.. code-block:: python
sources = tns.sources
"""
sourceResultsList = []
sourceResultsList[:] = [dict(l) for l in self.sourceResultsLi... | python | def sources(
self):
"""*The results of the search returned as a python list of dictionaries*
**Usage:**
.. code-block:: python
sources = tns.sources
"""
sourceResultsList = []
sourceResultsList[:] = [dict(l) for l in self.sourceResultsLi... | [
"def",
"sources",
"(",
"self",
")",
":",
"sourceResultsList",
"=",
"[",
"]",
"sourceResultsList",
"[",
":",
"]",
"=",
"[",
"dict",
"(",
"l",
")",
"for",
"l",
"in",
"self",
".",
"sourceResultsList",
"]",
"return",
"sourceResultsList"
] | *The results of the search returned as a python list of dictionaries*
**Usage:**
.. code-block:: python
sources = tns.sources | [
"*",
"The",
"results",
"of",
"the",
"search",
"returned",
"as",
"a",
"python",
"list",
"of",
"dictionaries",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L152-L164 |
thespacedoctor/transientNamer | transientNamer/search.py | search.spectra | def spectra(
self):
"""*The associated source spectral data*
**Usage:**
.. code-block:: python
sourceSpectra = tns.spectra
"""
specResultsList = []
specResultsList[:] = [dict(l) for l in self.specResultsList]
return specResultsL... | python | def spectra(
self):
"""*The associated source spectral data*
**Usage:**
.. code-block:: python
sourceSpectra = tns.spectra
"""
specResultsList = []
specResultsList[:] = [dict(l) for l in self.specResultsList]
return specResultsL... | [
"def",
"spectra",
"(",
"self",
")",
":",
"specResultsList",
"=",
"[",
"]",
"specResultsList",
"[",
":",
"]",
"=",
"[",
"dict",
"(",
"l",
")",
"for",
"l",
"in",
"self",
".",
"specResultsList",
"]",
"return",
"specResultsList"
] | *The associated source spectral data*
**Usage:**
.. code-block:: python
sourceSpectra = tns.spectra | [
"*",
"The",
"associated",
"source",
"spectral",
"data",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L167-L179 |
thespacedoctor/transientNamer | transientNamer/search.py | search.files | def files(
self):
"""*The associated source files*
**Usage:**
.. code-block:: python
sourceFiles = tns.files
"""
relatedFilesResultsList = []
relatedFilesResultsList[:] = [dict(l)
for l in self.rela... | python | def files(
self):
"""*The associated source files*
**Usage:**
.. code-block:: python
sourceFiles = tns.files
"""
relatedFilesResultsList = []
relatedFilesResultsList[:] = [dict(l)
for l in self.rela... | [
"def",
"files",
"(",
"self",
")",
":",
"relatedFilesResultsList",
"=",
"[",
"]",
"relatedFilesResultsList",
"[",
":",
"]",
"=",
"[",
"dict",
"(",
"l",
")",
"for",
"l",
"in",
"self",
".",
"relatedFilesResultsList",
"]",
"return",
"relatedFilesResultsList"
] | *The associated source files*
**Usage:**
.. code-block:: python
sourceFiles = tns.files | [
"*",
"The",
"associated",
"source",
"files",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L182-L195 |
thespacedoctor/transientNamer | transientNamer/search.py | search.photometry | def photometry(
self):
"""*The associated source photometry*
**Usage:**
.. code-block:: python
sourcePhotometry = tns.photometry
"""
photResultsList = []
photResultsList[:] = [dict(l) for l in self.photResultsList]
return photRe... | python | def photometry(
self):
"""*The associated source photometry*
**Usage:**
.. code-block:: python
sourcePhotometry = tns.photometry
"""
photResultsList = []
photResultsList[:] = [dict(l) for l in self.photResultsList]
return photRe... | [
"def",
"photometry",
"(",
"self",
")",
":",
"photResultsList",
"=",
"[",
"]",
"photResultsList",
"[",
":",
"]",
"=",
"[",
"dict",
"(",
"l",
")",
"for",
"l",
"in",
"self",
".",
"photResultsList",
"]",
"return",
"photResultsList"
] | *The associated source photometry*
**Usage:**
.. code-block:: python
sourcePhotometry = tns.photometry | [
"*",
"The",
"associated",
"source",
"photometry",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L198-L210 |
thespacedoctor/transientNamer | transientNamer/search.py | search.csv | def csv(
self,
dirPath=None):
"""*Render the results in csv format*
**Key Arguments:**
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Return:**
- `csvSources` -- the top-level transient data
... | python | def csv(
self,
dirPath=None):
"""*Render the results in csv format*
**Key Arguments:**
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Return:**
- `csvSources` -- the top-level transient data
... | [
"def",
"csv",
"(",
"self",
",",
"dirPath",
"=",
"None",
")",
":",
"if",
"dirPath",
":",
"p",
"=",
"self",
".",
"_file_prefix",
"(",
")",
"csvSources",
"=",
"self",
".",
"sourceResults",
".",
"csv",
"(",
"filepath",
"=",
"dirPath",
"+",
"\"/\"",
"+",
... | *Render the results in csv format*
**Key Arguments:**
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Return:**
- `csvSources` -- the top-level transient data
- `csvPhot` -- all photometry associated with the transients
... | [
"*",
"Render",
"the",
"results",
"in",
"csv",
"format",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L226-L280 |
thespacedoctor/transientNamer | transientNamer/search.py | search.json | def json(
self,
dirPath=None):
"""*Render the results in json format*
**Key Arguments:**
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Return:**
- `jsonSources` -- the top-level transient data
... | python | def json(
self,
dirPath=None):
"""*Render the results in json format*
**Key Arguments:**
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Return:**
- `jsonSources` -- the top-level transient data
... | [
"def",
"json",
"(",
"self",
",",
"dirPath",
"=",
"None",
")",
":",
"if",
"dirPath",
":",
"p",
"=",
"self",
".",
"_file_prefix",
"(",
")",
"jsonSources",
"=",
"self",
".",
"sourceResults",
".",
"json",
"(",
"filepath",
"=",
"dirPath",
"+",
"\"/\"",
"+... | *Render the results in json format*
**Key Arguments:**
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Return:**
- `jsonSources` -- the top-level transient data
- `jsonPhot` -- all photometry associated with the transient... | [
"*",
"Render",
"the",
"results",
"in",
"json",
"format",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L282-L357 |
thespacedoctor/transientNamer | transientNamer/search.py | search.yaml | def yaml(
self,
dirPath=None):
"""*Render the results in yaml format*
**Key Arguments:**
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Return:**
- `yamlSources` -- the top-level transient data
... | python | def yaml(
self,
dirPath=None):
"""*Render the results in yaml format*
**Key Arguments:**
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Return:**
- `yamlSources` -- the top-level transient data
... | [
"def",
"yaml",
"(",
"self",
",",
"dirPath",
"=",
"None",
")",
":",
"if",
"dirPath",
":",
"p",
"=",
"self",
".",
"_file_prefix",
"(",
")",
"yamlSources",
"=",
"self",
".",
"sourceResults",
".",
"yaml",
"(",
"filepath",
"=",
"dirPath",
"+",
"\"/\"",
"+... | *Render the results in yaml format*
**Key Arguments:**
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Return:**
- `yamlSources` -- the top-level transient data
- `yamlPhot` -- all photometry associated with the transient... | [
"*",
"Render",
"the",
"results",
"in",
"yaml",
"format",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L359-L430 |
thespacedoctor/transientNamer | transientNamer/search.py | search.markdown | def markdown(
self,
dirPath=None):
"""*Render the results in markdown format*
**Key Arguments:**
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Return:**
- `markdownSources` -- the top-level transient... | python | def markdown(
self,
dirPath=None):
"""*Render the results in markdown format*
**Key Arguments:**
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Return:**
- `markdownSources` -- the top-level transient... | [
"def",
"markdown",
"(",
"self",
",",
"dirPath",
"=",
"None",
")",
":",
"if",
"dirPath",
":",
"p",
"=",
"self",
".",
"_file_prefix",
"(",
")",
"markdownSources",
"=",
"self",
".",
"sourceResults",
".",
"markdown",
"(",
"filepath",
"=",
"dirPath",
"+",
"... | *Render the results in markdown format*
**Key Arguments:**
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Return:**
- `markdownSources` -- the top-level transient data
- `markdownPhot` -- all photometry associated with t... | [
"*",
"Render",
"the",
"results",
"in",
"markdown",
"format",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L432-L487 |
thespacedoctor/transientNamer | transientNamer/search.py | search.table | def table(
self,
dirPath=None):
"""*Render the results as an ascii table*
**Key Arguments:**
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Return:**
- `tableSources` -- the top-level transient data
... | python | def table(
self,
dirPath=None):
"""*Render the results as an ascii table*
**Key Arguments:**
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Return:**
- `tableSources` -- the top-level transient data
... | [
"def",
"table",
"(",
"self",
",",
"dirPath",
"=",
"None",
")",
":",
"if",
"dirPath",
":",
"p",
"=",
"self",
".",
"_file_prefix",
"(",
")",
"tableSources",
"=",
"self",
".",
"sourceResults",
".",
"table",
"(",
"filepath",
"=",
"dirPath",
"+",
"\"/\"",
... | *Render the results as an ascii table*
**Key Arguments:**
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Return:**
- `tableSources` -- the top-level transient data
- `tablePhot` -- all photometry associated with the tran... | [
"*",
"Render",
"the",
"results",
"as",
"an",
"ascii",
"table",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L489-L546 |
thespacedoctor/transientNamer | transientNamer/search.py | search.mysql | def mysql(
self,
tableNamePrefix="TNS",
dirPath=None):
"""*Render the results as MySQL Insert statements*
**Key Arguments:**
- ``tableNamePrefix`` -- the prefix for the database table names to assign the insert statements to. Default *TNS*.
- ... | python | def mysql(
self,
tableNamePrefix="TNS",
dirPath=None):
"""*Render the results as MySQL Insert statements*
**Key Arguments:**
- ``tableNamePrefix`` -- the prefix for the database table names to assign the insert statements to. Default *TNS*.
- ... | [
"def",
"mysql",
"(",
"self",
",",
"tableNamePrefix",
"=",
"\"TNS\"",
",",
"dirPath",
"=",
"None",
")",
":",
"if",
"dirPath",
":",
"p",
"=",
"self",
".",
"_file_prefix",
"(",
")",
"createStatement",
"=",
"\"\"\"\nCREATE TABLE `%(tableNamePrefix)s_sources` (\n `pri... | *Render the results as MySQL Insert statements*
**Key Arguments:**
- ``tableNamePrefix`` -- the prefix for the database table names to assign the insert statements to. Default *TNS*.
- ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*
**Re... | [
"*",
"Render",
"the",
"results",
"as",
"MySQL",
"Insert",
"statements",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L548-L704 |
thespacedoctor/transientNamer | transientNamer/search.py | search._query_tns | def _query_tns(self):
"""
*determine how to query the TNS, send query and parse the results*
**Return:**
- ``results`` -- a list of dictionaries (one dictionary for each result set returned from the TNS)
"""
self.log.info('starting the ``get`` method')
sourc... | python | def _query_tns(self):
"""
*determine how to query the TNS, send query and parse the results*
**Return:**
- ``results`` -- a list of dictionaries (one dictionary for each result set returned from the TNS)
"""
self.log.info('starting the ``get`` method')
sourc... | [
"def",
"_query_tns",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``get`` method'",
")",
"sourceTable",
"=",
"[",
"]",
"photoTable",
"=",
"[",
"]",
"specTable",
"=",
"[",
"]",
"relatedFilesTable",
"=",
"[",
"]",
"# THIS stop ... | *determine how to query the TNS, send query and parse the results*
**Return:**
- ``results`` -- a list of dictionaries (one dictionary for each result set returned from the TNS) | [
"*",
"determine",
"how",
"to",
"query",
"the",
"TNS",
"send",
"query",
"and",
"parse",
"the",
"results",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L706-L777 |
thespacedoctor/transientNamer | transientNamer/search.py | search._get_tns_search_results | def _get_tns_search_results(
self):
"""
*query the tns and result the response*
"""
self.log.info('starting the ``_get_tns_search_results`` method')
try:
response = requests.get(
url="http://wis-tns.weizmann.ac.il/search",
... | python | def _get_tns_search_results(
self):
"""
*query the tns and result the response*
"""
self.log.info('starting the ``_get_tns_search_results`` method')
try:
response = requests.get(
url="http://wis-tns.weizmann.ac.il/search",
... | [
"def",
"_get_tns_search_results",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_get_tns_search_results`` method'",
")",
"try",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
"=",
"\"http://wis-tns.weizmann.ac.il/search\"",
... | *query the tns and result the response* | [
"*",
"query",
"the",
"tns",
"and",
"result",
"the",
"response",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L779-L818 |
thespacedoctor/transientNamer | transientNamer/search.py | search._file_prefix | def _file_prefix(
self):
"""*Generate a file prefix based on the type of search for saving files to disk*
**Return:**
- ``prefix`` -- the file prefix
"""
self.log.info('starting the ``_file_prefix`` method')
if self.ra:
now = datetime.now()
... | python | def _file_prefix(
self):
"""*Generate a file prefix based on the type of search for saving files to disk*
**Return:**
- ``prefix`` -- the file prefix
"""
self.log.info('starting the ``_file_prefix`` method')
if self.ra:
now = datetime.now()
... | [
"def",
"_file_prefix",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_file_prefix`` method'",
")",
"if",
"self",
".",
"ra",
":",
"now",
"=",
"datetime",
".",
"now",
"(",
")",
"prefix",
"=",
"now",
".",
"strftime",
"(",
"... | *Generate a file prefix based on the type of search for saving files to disk*
**Return:**
- ``prefix`` -- the file prefix | [
"*",
"Generate",
"a",
"file",
"prefix",
"based",
"on",
"the",
"type",
"of",
"search",
"for",
"saving",
"files",
"to",
"disk",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L820-L843 |
thespacedoctor/transientNamer | transientNamer/search.py | search._parse_transient_rows | def _parse_transient_rows(
self,
content,
count=False):
"""* parse transient rows from the TNS result page content*
**Key Arguments:**
- ``content`` -- the content from the TNS results page.
- ``count`` -- return only the number of rows
... | python | def _parse_transient_rows(
self,
content,
count=False):
"""* parse transient rows from the TNS result page content*
**Key Arguments:**
- ``content`` -- the content from the TNS results page.
- ``count`` -- return only the number of rows
... | [
"def",
"_parse_transient_rows",
"(",
"self",
",",
"content",
",",
"count",
"=",
"False",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_parse_transient_rows`` method'",
")",
"regexForRow",
"=",
"r\"\"\"\\n([^\\n]*?<a href=\"/object/.*?)(?=\\n[^\\n]*?<a ... | * parse transient rows from the TNS result page content*
**Key Arguments:**
- ``content`` -- the content from the TNS results page.
- ``count`` -- return only the number of rows
**Return:**
- ``transientRows`` | [
"*",
"parse",
"transient",
"rows",
"from",
"the",
"TNS",
"result",
"page",
"content",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L845-L879 |
thespacedoctor/transientNamer | transientNamer/search.py | search._parse_discovery_information | def _parse_discovery_information(
self,
content):
"""* parse discovery information from one row on the TNS results page*
**Key Arguments:**
- ``content`` -- a table row from the TNS results page.
**Return:**
- ``discoveryData`` -- dictionary of r... | python | def _parse_discovery_information(
self,
content):
"""* parse discovery information from one row on the TNS results page*
**Key Arguments:**
- ``content`` -- a table row from the TNS results page.
**Return:**
- ``discoveryData`` -- dictionary of r... | [
"def",
"_parse_discovery_information",
"(",
"self",
",",
"content",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_parse_discovery_information`` method'",
")",
"# ASTROCALC UNIT CONVERTER OBJECT",
"converter",
"=",
"unit_conversion",
"(",
"log",
"=",
... | * parse discovery information from one row on the TNS results page*
**Key Arguments:**
- ``content`` -- a table row from the TNS results page.
**Return:**
- ``discoveryData`` -- dictionary of results
- ``TNSId`` -- the unique TNS id for the transient | [
"*",
"parse",
"discovery",
"information",
"from",
"one",
"row",
"on",
"the",
"TNS",
"results",
"page",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L881-L971 |
thespacedoctor/transientNamer | transientNamer/search.py | search._parse_photometry_data | def _parse_photometry_data(
self,
content,
TNSId):
"""*parse photometry data from a row in the tns results content*
**Key Arguments:**
- ``content`` -- a table row from the TNS results page
- ``TNSId`` -- the tns id of the transient
... | python | def _parse_photometry_data(
self,
content,
TNSId):
"""*parse photometry data from a row in the tns results content*
**Key Arguments:**
- ``content`` -- a table row from the TNS results page
- ``TNSId`` -- the tns id of the transient
... | [
"def",
"_parse_photometry_data",
"(",
"self",
",",
"content",
",",
"TNSId",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_parse_photometry_data`` method'",
")",
"photData",
"=",
"[",
"]",
"relatedFilesTable",
"=",
"[",
"]",
"# AT REPORT BLOCK",... | *parse photometry data from a row in the tns results content*
**Key Arguments:**
- ``content`` -- a table row from the TNS results page
- ``TNSId`` -- the tns id of the transient
**Return:**
- ``photData`` -- a list of dictionaries of the photometry data
... | [
"*",
"parse",
"photometry",
"data",
"from",
"a",
"row",
"in",
"the",
"tns",
"results",
"content",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L973-L1106 |
thespacedoctor/transientNamer | transientNamer/search.py | search._parse_related_files | def _parse_related_files(
self,
content):
"""*parse the contents for related files URLs and comments*
**Key Arguments:**
- ``content`` -- the content to parse.
**Return:**
- ``relatedFiles`` -- a list of dictionaries of transient related files
... | python | def _parse_related_files(
self,
content):
"""*parse the contents for related files URLs and comments*
**Key Arguments:**
- ``content`` -- the content to parse.
**Return:**
- ``relatedFiles`` -- a list of dictionaries of transient related files
... | [
"def",
"_parse_related_files",
"(",
"self",
",",
"content",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_parse_related_files`` method'",
")",
"relatedFilesList",
"=",
"re",
".",
"finditer",
"(",
"r\"\"\"<td class=\"cell-filename\">.*?href=\"(?P<filepa... | *parse the contents for related files URLs and comments*
**Key Arguments:**
- ``content`` -- the content to parse.
**Return:**
- ``relatedFiles`` -- a list of dictionaries of transient related files | [
"*",
"parse",
"the",
"contents",
"for",
"related",
"files",
"URLs",
"and",
"comments",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L1108-L1133 |
thespacedoctor/transientNamer | transientNamer/search.py | search._parse_spectral_data | def _parse_spectral_data(
self,
content,
TNSId):
"""*parse spectra data from a row in the tns results content*
**Key Arguments:**
- ``content`` -- a table row from the TNS results page
- ``TNSId`` -- the tns id of the transient
**Re... | python | def _parse_spectral_data(
self,
content,
TNSId):
"""*parse spectra data from a row in the tns results content*
**Key Arguments:**
- ``content`` -- a table row from the TNS results page
- ``TNSId`` -- the tns id of the transient
**Re... | [
"def",
"_parse_spectral_data",
"(",
"self",
",",
"content",
",",
"TNSId",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_parse_spectral_data`` method'",
")",
"specData",
"=",
"[",
"]",
"relatedFilesTable",
"=",
"[",
"]",
"# CLASSIFICATION BLOCK"... | *parse spectra data from a row in the tns results content*
**Key Arguments:**
- ``content`` -- a table row from the TNS results page
- ``TNSId`` -- the tns id of the transient
**Return:**
- ``specData`` -- a list of dictionaries of the spectral data
- ... | [
"*",
"parse",
"spectra",
"data",
"from",
"a",
"row",
"in",
"the",
"tns",
"results",
"content",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/search.py#L1135-L1273 |
Sean1708/HipPy | hippy/lexer.py | tokenize_number | def tokenize_number(val, line):
"""Parse val correctly into int or float."""
try:
num = int(val)
typ = TokenType.int
except ValueError:
num = float(val)
typ = TokenType.float
return {'type': typ, 'value': num, 'line': line} | python | def tokenize_number(val, line):
"""Parse val correctly into int or float."""
try:
num = int(val)
typ = TokenType.int
except ValueError:
num = float(val)
typ = TokenType.float
return {'type': typ, 'value': num, 'line': line} | [
"def",
"tokenize_number",
"(",
"val",
",",
"line",
")",
":",
"try",
":",
"num",
"=",
"int",
"(",
"val",
")",
"typ",
"=",
"TokenType",
".",
"int",
"except",
"ValueError",
":",
"num",
"=",
"float",
"(",
"val",
")",
"typ",
"=",
"TokenType",
".",
"floa... | Parse val correctly into int or float. | [
"Parse",
"val",
"correctly",
"into",
"int",
"or",
"float",
"."
] | train | https://github.com/Sean1708/HipPy/blob/d0ea8fb1e417f1fedaa8e215e3d420b90c4de691/hippy/lexer.py#L43-L52 |
jmgilman/Neolib | neolib/shop/UserShop.py | UserShop.till | def till(self):
""" Queries the current shop till and returns the amount
Returns
str -- Amount of NPs in shop till
Raises
parseException
"""
pg = self.usr.getPage("http://www.neopets.com/market.phtml?type=till")
try:
... | python | def till(self):
""" Queries the current shop till and returns the amount
Returns
str -- Amount of NPs in shop till
Raises
parseException
"""
pg = self.usr.getPage("http://www.neopets.com/market.phtml?type=till")
try:
... | [
"def",
"till",
"(",
"self",
")",
":",
"pg",
"=",
"self",
".",
"usr",
".",
"getPage",
"(",
"\"http://www.neopets.com/market.phtml?type=till\"",
")",
"try",
":",
"return",
"pg",
".",
"find_all",
"(",
"text",
"=",
"\"Shop Till\"",
")",
"[",
"1",
"]",
".",
"... | Queries the current shop till and returns the amount
Returns
str -- Amount of NPs in shop till
Raises
parseException | [
"Queries",
"the",
"current",
"shop",
"till",
"and",
"returns",
"the",
"amount",
"Returns",
"str",
"--",
"Amount",
"of",
"NPs",
"in",
"shop",
"till",
"Raises",
"parseException"
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/shop/UserShop.py#L63-L78 |
jmgilman/Neolib | neolib/shop/UserShop.py | UserShop.grabTill | def grabTill(self, nps):
""" Withdraws given number of NPs from the shop till, returns result
Parameters:
nps (int) -- Number of NPs to withdraw
Returns
bool - True if successful, False otherwise
"""
if not int(nps):
retur... | python | def grabTill(self, nps):
""" Withdraws given number of NPs from the shop till, returns result
Parameters:
nps (int) -- Number of NPs to withdraw
Returns
bool - True if successful, False otherwise
"""
if not int(nps):
retur... | [
"def",
"grabTill",
"(",
"self",
",",
"nps",
")",
":",
"if",
"not",
"int",
"(",
"nps",
")",
":",
"return",
"False",
"pg",
"=",
"self",
".",
"usr",
".",
"getPage",
"(",
"\"http://www.neopets.com/market.phtml?type=till\"",
")",
"form",
"=",
"pg",
".",
"form... | Withdraws given number of NPs from the shop till, returns result
Parameters:
nps (int) -- Number of NPs to withdraw
Returns
bool - True if successful, False otherwise | [
"Withdraws",
"given",
"number",
"of",
"NPs",
"from",
"the",
"shop",
"till",
"returns",
"result",
"Parameters",
":",
"nps",
"(",
"int",
")",
"--",
"Number",
"of",
"NPs",
"to",
"withdraw",
"Returns",
"bool",
"-",
"True",
"if",
"successful",
"False",
"otherwi... | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/shop/UserShop.py#L80-L104 |
jmgilman/Neolib | neolib/shop/UserShop.py | UserShop.load | def load(self):
""" Loads the shop details and current inventory
Raises
parseException
"""
pg = self.usr.getPage("http://www.neopets.com/market.phtml?type=your")
try:
self.name = pg.find_all(text = "Shop Till")[1].parent.parent.parent.p... | python | def load(self):
""" Loads the shop details and current inventory
Raises
parseException
"""
pg = self.usr.getPage("http://www.neopets.com/market.phtml?type=your")
try:
self.name = pg.find_all(text = "Shop Till")[1].parent.parent.parent.p... | [
"def",
"load",
"(",
"self",
")",
":",
"pg",
"=",
"self",
".",
"usr",
".",
"getPage",
"(",
"\"http://www.neopets.com/market.phtml?type=your\"",
")",
"try",
":",
"self",
".",
"name",
"=",
"pg",
".",
"find_all",
"(",
"text",
"=",
"\"Shop Till\"",
")",
"[",
... | Loads the shop details and current inventory
Raises
parseException | [
"Loads",
"the",
"shop",
"details",
"and",
"current",
"inventory",
"Raises",
"parseException"
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/shop/UserShop.py#L106-L130 |
jmgilman/Neolib | neolib/shop/UserShop.py | UserShop.loadHistory | def loadHistory(self):
""" Loads the shop sale history
Raises
parseException
"""
pg = self.usr.getPage("http://www.neopets.com/market.phtml?type=sales")\
try:
rows = pg.find("b", text = "Date").parent.parent.parent.find_all("tr")
... | python | def loadHistory(self):
""" Loads the shop sale history
Raises
parseException
"""
pg = self.usr.getPage("http://www.neopets.com/market.phtml?type=sales")\
try:
rows = pg.find("b", text = "Date").parent.parent.parent.find_all("tr")
... | [
"def",
"loadHistory",
"(",
"self",
")",
":",
"pg",
"=",
"self",
".",
"usr",
".",
"getPage",
"(",
"\"http://www.neopets.com/market.phtml?type=sales\"",
")",
"try",
":",
"rows",
"=",
"pg",
".",
"find",
"(",
"\"b\"",
",",
"text",
"=",
"\"Date\"",
")",
".",
... | Loads the shop sale history
Raises
parseException | [
"Loads",
"the",
"shop",
"sale",
"history",
"Raises",
"parseException"
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/shop/UserShop.py#L132-L163 |
rGunti/CarPi-DaemonCommons | daemoncommons/daemon.py | Daemon._get_config | def _get_config(self, section: str, key: str, fallback: str=object()) -> str:
"""
Gets a string config value
:param section: Section
:param key: Key
:param fallback: Optional fallback value
"""
return self._config.get(section, key, fallback=fallback) | python | def _get_config(self, section: str, key: str, fallback: str=object()) -> str:
"""
Gets a string config value
:param section: Section
:param key: Key
:param fallback: Optional fallback value
"""
return self._config.get(section, key, fallback=fallback) | [
"def",
"_get_config",
"(",
"self",
",",
"section",
":",
"str",
",",
"key",
":",
"str",
",",
"fallback",
":",
"str",
"=",
"object",
"(",
")",
")",
"->",
"str",
":",
"return",
"self",
".",
"_config",
".",
"get",
"(",
"section",
",",
"key",
",",
"fa... | Gets a string config value
:param section: Section
:param key: Key
:param fallback: Optional fallback value | [
"Gets",
"a",
"string",
"config",
"value",
":",
"param",
"section",
":",
"Section",
":",
"param",
"key",
":",
"Key",
":",
"param",
"fallback",
":",
"Optional",
"fallback",
"value"
] | train | https://github.com/rGunti/CarPi-DaemonCommons/blob/f0abf89fb39813721acee88273c3eb4dad7c5acc/daemoncommons/daemon.py#L28-L35 |
rGunti/CarPi-DaemonCommons | daemoncommons/daemon.py | Daemon._get_config_float | def _get_config_float(self, section: str, key: str, fallback: float=object()) -> float:
"""
Gets a float config value
:param section: Section
:param key: Key
:param fallback: Optional fallback value
"""
return self._config.getfloat(section, key, fallback=fallback) | python | def _get_config_float(self, section: str, key: str, fallback: float=object()) -> float:
"""
Gets a float config value
:param section: Section
:param key: Key
:param fallback: Optional fallback value
"""
return self._config.getfloat(section, key, fallback=fallback) | [
"def",
"_get_config_float",
"(",
"self",
",",
"section",
":",
"str",
",",
"key",
":",
"str",
",",
"fallback",
":",
"float",
"=",
"object",
"(",
")",
")",
"->",
"float",
":",
"return",
"self",
".",
"_config",
".",
"getfloat",
"(",
"section",
",",
"key... | Gets a float config value
:param section: Section
:param key: Key
:param fallback: Optional fallback value | [
"Gets",
"a",
"float",
"config",
"value",
":",
"param",
"section",
":",
"Section",
":",
"param",
"key",
":",
"Key",
":",
"param",
"fallback",
":",
"Optional",
"fallback",
"value"
] | train | https://github.com/rGunti/CarPi-DaemonCommons/blob/f0abf89fb39813721acee88273c3eb4dad7c5acc/daemoncommons/daemon.py#L37-L44 |
rGunti/CarPi-DaemonCommons | daemoncommons/daemon.py | Daemon._get_config_int | def _get_config_int(self, section: str, key: str, fallback: int=object()) -> int:
"""
Gets an int config value
:param section: Section
:param key: Key
:param fallback: Optional fallback value
"""
return self._config.getint(section, key, fallback=fallback) | python | def _get_config_int(self, section: str, key: str, fallback: int=object()) -> int:
"""
Gets an int config value
:param section: Section
:param key: Key
:param fallback: Optional fallback value
"""
return self._config.getint(section, key, fallback=fallback) | [
"def",
"_get_config_int",
"(",
"self",
",",
"section",
":",
"str",
",",
"key",
":",
"str",
",",
"fallback",
":",
"int",
"=",
"object",
"(",
")",
")",
"->",
"int",
":",
"return",
"self",
".",
"_config",
".",
"getint",
"(",
"section",
",",
"key",
","... | Gets an int config value
:param section: Section
:param key: Key
:param fallback: Optional fallback value | [
"Gets",
"an",
"int",
"config",
"value",
":",
"param",
"section",
":",
"Section",
":",
"param",
"key",
":",
"Key",
":",
"param",
"fallback",
":",
"Optional",
"fallback",
"value"
] | train | https://github.com/rGunti/CarPi-DaemonCommons/blob/f0abf89fb39813721acee88273c3eb4dad7c5acc/daemoncommons/daemon.py#L46-L53 |
rGunti/CarPi-DaemonCommons | daemoncommons/daemon.py | Daemon._get_config_bool | def _get_config_bool(self, section: str, key: str, fallback: bool=object()) -> bool:
"""
Gets a boolean config value
:param section: Section
:param key: Key
:param fallback: Optional fallback value
"""
return self._config.getboolean(section, key, fallback=fallback... | python | def _get_config_bool(self, section: str, key: str, fallback: bool=object()) -> bool:
"""
Gets a boolean config value
:param section: Section
:param key: Key
:param fallback: Optional fallback value
"""
return self._config.getboolean(section, key, fallback=fallback... | [
"def",
"_get_config_bool",
"(",
"self",
",",
"section",
":",
"str",
",",
"key",
":",
"str",
",",
"fallback",
":",
"bool",
"=",
"object",
"(",
")",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_config",
".",
"getboolean",
"(",
"section",
",",
"key"... | Gets a boolean config value
:param section: Section
:param key: Key
:param fallback: Optional fallback value | [
"Gets",
"a",
"boolean",
"config",
"value",
":",
"param",
"section",
":",
"Section",
":",
"param",
"key",
":",
"Key",
":",
"param",
"fallback",
":",
"Optional",
"fallback",
"value"
] | train | https://github.com/rGunti/CarPi-DaemonCommons/blob/f0abf89fb39813721acee88273c3eb4dad7c5acc/daemoncommons/daemon.py#L55-L62 |
port-zero/mite | mite/mite.py | Mite.request | def request(self, scheme, url, data=None, params=None):
"""
Low-level request interface to mite. Takes a HTTP request scheme (lower
case!), a URL to request (relative), and optionally data to add to the
request. Either returns the JSON body of the request or raises a
HttpExcepti... | python | def request(self, scheme, url, data=None, params=None):
"""
Low-level request interface to mite. Takes a HTTP request scheme (lower
case!), a URL to request (relative), and optionally data to add to the
request. Either returns the JSON body of the request or raises a
HttpExcepti... | [
"def",
"request",
"(",
"self",
",",
"scheme",
",",
"url",
",",
"data",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"url",
".",
"format",
"(",
"self",
".",
"team",
",",
"url",
")",
"headers",
"=",
"{",
"\"X-MiteApik... | Low-level request interface to mite. Takes a HTTP request scheme (lower
case!), a URL to request (relative), and optionally data to add to the
request. Either returns the JSON body of the request or raises a
HttpException. | [
"Low",
"-",
"level",
"request",
"interface",
"to",
"mite",
".",
"Takes",
"a",
"HTTP",
"request",
"scheme",
"(",
"lower",
"case!",
")",
"a",
"URL",
"to",
"request",
"(",
"relative",
")",
"and",
"optionally",
"data",
"to",
"add",
"to",
"the",
"request",
... | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L22-L52 |
port-zero/mite | mite/mite.py | Mite.get | def get(self, url, data=None, params=None):
"""
Low-level GET request interface to mite. Takes a URL to request
(relative), and optionally data to add to the request. Either returns
the JSON body of the request or raises a HttpException.
"""
return self.request("get", ur... | python | def get(self, url, data=None, params=None):
"""
Low-level GET request interface to mite. Takes a URL to request
(relative), and optionally data to add to the request. Either returns
the JSON body of the request or raises a HttpException.
"""
return self.request("get", ur... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"get\"",
",",
"url",
",",
"data",
",",
"params",
")"
] | Low-level GET request interface to mite. Takes a URL to request
(relative), and optionally data to add to the request. Either returns
the JSON body of the request or raises a HttpException. | [
"Low",
"-",
"level",
"GET",
"request",
"interface",
"to",
"mite",
".",
"Takes",
"a",
"URL",
"to",
"request",
"(",
"relative",
")",
"and",
"optionally",
"data",
"to",
"add",
"to",
"the",
"request",
".",
"Either",
"returns",
"the",
"JSON",
"body",
"of",
... | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L57-L64 |
port-zero/mite | mite/mite.py | Mite.put | def put(self, url, data=None, params=None):
"""
Low-level PUT request interface to mite. Takes a URL to request
(relative), and optionally data to add to the request. Either returns
the JSON body of the request or raises a HttpException.
"""
return self.request("put", ur... | python | def put(self, url, data=None, params=None):
"""
Low-level PUT request interface to mite. Takes a URL to request
(relative), and optionally data to add to the request. Either returns
the JSON body of the request or raises a HttpException.
"""
return self.request("put", ur... | [
"def",
"put",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"put\"",
",",
"url",
",",
"data",
",",
"params",
")"
] | Low-level PUT request interface to mite. Takes a URL to request
(relative), and optionally data to add to the request. Either returns
the JSON body of the request or raises a HttpException. | [
"Low",
"-",
"level",
"PUT",
"request",
"interface",
"to",
"mite",
".",
"Takes",
"a",
"URL",
"to",
"request",
"(",
"relative",
")",
"and",
"optionally",
"data",
"to",
"add",
"to",
"the",
"request",
".",
"Either",
"returns",
"the",
"JSON",
"body",
"of",
... | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L66-L73 |
port-zero/mite | mite/mite.py | Mite.post | def post(self, url, data=None, params=None):
"""
Low-level POST request interface to mite. Takes a URL to request
(relative), and optionally data to add to the request. Either returns
the JSON body of the request or raises a HttpException.
"""
return self.request("post",... | python | def post(self, url, data=None, params=None):
"""
Low-level POST request interface to mite. Takes a URL to request
(relative), and optionally data to add to the request. Either returns
the JSON body of the request or raises a HttpException.
"""
return self.request("post",... | [
"def",
"post",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"post\"",
",",
"url",
",",
"data",
",",
"params",
")"
] | Low-level POST request interface to mite. Takes a URL to request
(relative), and optionally data to add to the request. Either returns
the JSON body of the request or raises a HttpException. | [
"Low",
"-",
"level",
"POST",
"request",
"interface",
"to",
"mite",
".",
"Takes",
"a",
"URL",
"to",
"request",
"(",
"relative",
")",
"and",
"optionally",
"data",
"to",
"add",
"to",
"the",
"request",
".",
"Either",
"returns",
"the",
"JSON",
"body",
"of",
... | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L75-L82 |
port-zero/mite | mite/mite.py | Mite.patch | def patch(self, url, data=None, params=None):
"""
Low-level PATCH request interface to mite. Takes a URL to request
(relative), and optionally data to add to the request. Either returns
the JSON body of the request or raises a HttpException.
"""
return self.request("patc... | python | def patch(self, url, data=None, params=None):
"""
Low-level PATCH request interface to mite. Takes a URL to request
(relative), and optionally data to add to the request. Either returns
the JSON body of the request or raises a HttpException.
"""
return self.request("patc... | [
"def",
"patch",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"patch\"",
",",
"url",
",",
"data",
",",
"params",
")"
] | Low-level PATCH request interface to mite. Takes a URL to request
(relative), and optionally data to add to the request. Either returns
the JSON body of the request or raises a HttpException. | [
"Low",
"-",
"level",
"PATCH",
"request",
"interface",
"to",
"mite",
".",
"Takes",
"a",
"URL",
"to",
"request",
"(",
"relative",
")",
"and",
"optionally",
"data",
"to",
"add",
"to",
"the",
"request",
".",
"Either",
"returns",
"the",
"JSON",
"body",
"of",
... | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L84-L91 |
port-zero/mite | mite/mite.py | Mite.delete | def delete(self, url, data=None, params=None):
"""
Low-level DELETE request interface to mite. Takes a URL to request
(relative), and optionally data to add to the request. Either returns
the JSON body of the request or raises a HttpException.
"""
return self.request("de... | python | def delete(self, url, data=None, params=None):
"""
Low-level DELETE request interface to mite. Takes a URL to request
(relative), and optionally data to add to the request. Either returns
the JSON body of the request or raises a HttpException.
"""
return self.request("de... | [
"def",
"delete",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"delete\"",
",",
"url",
",",
"data",
",",
"params",
")"
] | Low-level DELETE request interface to mite. Takes a URL to request
(relative), and optionally data to add to the request. Either returns
the JSON body of the request or raises a HttpException. | [
"Low",
"-",
"level",
"DELETE",
"request",
"interface",
"to",
"mite",
".",
"Takes",
"a",
"URL",
"to",
"request",
"(",
"relative",
")",
"and",
"optionally",
"data",
"to",
"add",
"to",
"the",
"request",
".",
"Either",
"returns",
"the",
"JSON",
"body",
"of",... | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L93-L100 |
port-zero/mite | mite/mite.py | Mite.get_daily | def get_daily(self, date=None):
"""
Get time entries for a date (defaults to today).
"""
if date == None:
return self.get("/daily.json")
url = "/daily/{}/{}/{}.json".format(date.year, date.month, date.day)
return self.get(url) | python | def get_daily(self, date=None):
"""
Get time entries for a date (defaults to today).
"""
if date == None:
return self.get("/daily.json")
url = "/daily/{}/{}/{}.json".format(date.year, date.month, date.day)
return self.get(url) | [
"def",
"get_daily",
"(",
"self",
",",
"date",
"=",
"None",
")",
":",
"if",
"date",
"==",
"None",
":",
"return",
"self",
".",
"get",
"(",
"\"/daily.json\"",
")",
"url",
"=",
"\"/daily/{}/{}/{}.json\"",
".",
"format",
"(",
"date",
".",
"year",
",",
"date... | Get time entries for a date (defaults to today). | [
"Get",
"time",
"entries",
"for",
"a",
"date",
"(",
"defaults",
"to",
"today",
")",
"."
] | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L125-L132 |
port-zero/mite | mite/mite.py | Mite.create_entry | def create_entry(self, **kwargs):
"""
Creates a new time entry on Mite. Takes a data dictionary with the keys
`date_at` (a date string in `YYYY-MM-DD` format), `minutes` (an int),
`note` (the entry text), `user_id`, `project_id`, `service_id`, and
`locked`. All of them are option... | python | def create_entry(self, **kwargs):
"""
Creates a new time entry on Mite. Takes a data dictionary with the keys
`date_at` (a date string in `YYYY-MM-DD` format), `minutes` (an int),
`note` (the entry text), `user_id`, `project_id`, `service_id`, and
`locked`. All of them are option... | [
"def",
"create_entry",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"_wrap_dict",
"(",
"\"time_entry\"",
",",
"kwargs",
")",
"return",
"self",
".",
"post",
"(",
"\"/time_entries.json\"",
",",
"data",
")"
] | Creates a new time entry on Mite. Takes a data dictionary with the keys
`date_at` (a date string in `YYYY-MM-DD` format), `minutes` (an int),
`note` (the entry text), `user_id`, `project_id`, `service_id`, and
`locked`. All of them are optional. | [
"Creates",
"a",
"new",
"time",
"entry",
"on",
"Mite",
".",
"Takes",
"a",
"data",
"dictionary",
"with",
"the",
"keys",
"date_at",
"(",
"a",
"date",
"string",
"in",
"YYYY",
"-",
"MM",
"-",
"DD",
"format",
")",
"minutes",
"(",
"an",
"int",
")",
"note",
... | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L143-L152 |
port-zero/mite | mite/mite.py | Mite.edit_entry | def edit_entry(self, id_, **kwargs):
"""
Edits a time entry by ID. Takes the same data as `create_entry`, but
requires an ID to work. It also takes a `force` parameter that, when set
to True, allows administrators to edit locked entries.
"""
data = self._wrap_dict("time_e... | python | def edit_entry(self, id_, **kwargs):
"""
Edits a time entry by ID. Takes the same data as `create_entry`, but
requires an ID to work. It also takes a `force` parameter that, when set
to True, allows administrators to edit locked entries.
"""
data = self._wrap_dict("time_e... | [
"def",
"edit_entry",
"(",
"self",
",",
"id_",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"_wrap_dict",
"(",
"\"time_entry\"",
",",
"kwargs",
")",
"return",
"self",
".",
"patch",
"(",
"\"/time_entries/{}.json\"",
".",
"format",
"(",
"id_... | Edits a time entry by ID. Takes the same data as `create_entry`, but
requires an ID to work. It also takes a `force` parameter that, when set
to True, allows administrators to edit locked entries. | [
"Edits",
"a",
"time",
"entry",
"by",
"ID",
".",
"Takes",
"the",
"same",
"data",
"as",
"create_entry",
"but",
"requires",
"an",
"ID",
"to",
"work",
".",
"It",
"also",
"takes",
"a",
"force",
"parameter",
"that",
"when",
"set",
"to",
"True",
"allows",
"ad... | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L154-L162 |
port-zero/mite | mite/mite.py | Mite.start_tracker | def start_tracker(self, id_, **kwargs):
"""
Starts a tracker for the time entry identified by `id_`.
"""
data = None
if kwargs:
data = self._wrap_dict("tracker",
self._wrap_dict("tracking_time_entry", kwargs))
return self.patch("/tracker/{}.jso... | python | def start_tracker(self, id_, **kwargs):
"""
Starts a tracker for the time entry identified by `id_`.
"""
data = None
if kwargs:
data = self._wrap_dict("tracker",
self._wrap_dict("tracking_time_entry", kwargs))
return self.patch("/tracker/{}.jso... | [
"def",
"start_tracker",
"(",
"self",
",",
"id_",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"None",
"if",
"kwargs",
":",
"data",
"=",
"self",
".",
"_wrap_dict",
"(",
"\"tracker\"",
",",
"self",
".",
"_wrap_dict",
"(",
"\"tracking_time_entry\"",
",",... | Starts a tracker for the time entry identified by `id_`. | [
"Starts",
"a",
"tracker",
"for",
"the",
"time",
"entry",
"identified",
"by",
"id_",
"."
] | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L176-L184 |
port-zero/mite | mite/mite.py | Mite.create_customer | def create_customer(self, name, **kwargs):
"""
Creates a customer with a name. All other parameters are optional. They
are: `note`, `active_hourly_rate`, `hourly_rate`,
`hourly_rates_per_service`, and `archived`.
"""
data = self._wrap_dict("customer", kwargs)
data... | python | def create_customer(self, name, **kwargs):
"""
Creates a customer with a name. All other parameters are optional. They
are: `note`, `active_hourly_rate`, `hourly_rate`,
`hourly_rates_per_service`, and `archived`.
"""
data = self._wrap_dict("customer", kwargs)
data... | [
"def",
"create_customer",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"_wrap_dict",
"(",
"\"customer\"",
",",
"kwargs",
")",
"data",
"[",
"\"customer\"",
"]",
"[",
"\"name\"",
"]",
"=",
"name",
"return",
"self... | Creates a customer with a name. All other parameters are optional. They
are: `note`, `active_hourly_rate`, `hourly_rate`,
`hourly_rates_per_service`, and `archived`. | [
"Creates",
"a",
"customer",
"with",
"a",
"name",
".",
"All",
"other",
"parameters",
"are",
"optional",
".",
"They",
"are",
":",
"note",
"active_hourly_rate",
"hourly_rate",
"hourly_rates_per_service",
"and",
"archived",
"."
] | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L229-L237 |
port-zero/mite | mite/mite.py | Mite.edit_customer | def edit_customer(self, id_, **kwargs):
"""
Edits a customer by ID. All fields available at creation can be updated
as well. If you want to update hourly rates retroactively, set the
argument `update_hourly_rate_on_time_entries` to True.
"""
data = self._wrap_dict("custom... | python | def edit_customer(self, id_, **kwargs):
"""
Edits a customer by ID. All fields available at creation can be updated
as well. If you want to update hourly rates retroactively, set the
argument `update_hourly_rate_on_time_entries` to True.
"""
data = self._wrap_dict("custom... | [
"def",
"edit_customer",
"(",
"self",
",",
"id_",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"_wrap_dict",
"(",
"\"customer\"",
",",
"kwargs",
")",
"return",
"self",
".",
"patch",
"(",
"\"/customers/{}.json\"",
".",
"format",
"(",
"id_",... | Edits a customer by ID. All fields available at creation can be updated
as well. If you want to update hourly rates retroactively, set the
argument `update_hourly_rate_on_time_entries` to True. | [
"Edits",
"a",
"customer",
"by",
"ID",
".",
"All",
"fields",
"available",
"at",
"creation",
"can",
"be",
"updated",
"as",
"well",
".",
"If",
"you",
"want",
"to",
"update",
"hourly",
"rates",
"retroactively",
"set",
"the",
"argument",
"update_hourly_rate_on_time... | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L239-L246 |
port-zero/mite | mite/mite.py | Mite.create_project | def create_project(self, name, **kwargs):
"""
Creates a project with a name. All other parameters are optional. They
are: `note`, `customer_id`, `budget`, `budget_type`,
`active_hourly_rate`, `hourly_rate`, `hourly_rates_per_service`, and
`archived`.
"""
data = s... | python | def create_project(self, name, **kwargs):
"""
Creates a project with a name. All other parameters are optional. They
are: `note`, `customer_id`, `budget`, `budget_type`,
`active_hourly_rate`, `hourly_rate`, `hourly_rates_per_service`, and
`archived`.
"""
data = s... | [
"def",
"create_project",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"_wrap_dict",
"(",
"\"project\"",
",",
"kwargs",
")",
"data",
"[",
"\"customer\"",
"]",
"[",
"\"name\"",
"]",
"=",
"name",
"return",
"self",... | Creates a project with a name. All other parameters are optional. They
are: `note`, `customer_id`, `budget`, `budget_type`,
`active_hourly_rate`, `hourly_rate`, `hourly_rates_per_service`, and
`archived`. | [
"Creates",
"a",
"project",
"with",
"a",
"name",
".",
"All",
"other",
"parameters",
"are",
"optional",
".",
"They",
"are",
":",
"note",
"customer_id",
"budget",
"budget_type",
"active_hourly_rate",
"hourly_rate",
"hourly_rates_per_service",
"and",
"archived",
"."
] | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L275-L284 |
port-zero/mite | mite/mite.py | Mite.edit_project | def edit_project(self, id_, **kwargs):
"""
Edits a project by ID. All fields available at creation can be updated
as well. If you want to update hourly rates retroactively, set the
argument `update_hourly_rate_on_time_entries` to True.
"""
data = self._wrap_dict("project"... | python | def edit_project(self, id_, **kwargs):
"""
Edits a project by ID. All fields available at creation can be updated
as well. If you want to update hourly rates retroactively, set the
argument `update_hourly_rate_on_time_entries` to True.
"""
data = self._wrap_dict("project"... | [
"def",
"edit_project",
"(",
"self",
",",
"id_",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"_wrap_dict",
"(",
"\"project\"",
",",
"kwargs",
")",
"return",
"self",
".",
"patch",
"(",
"\"/projects/{}.json\"",
".",
"format",
"(",
"id_",
... | Edits a project by ID. All fields available at creation can be updated
as well. If you want to update hourly rates retroactively, set the
argument `update_hourly_rate_on_time_entries` to True. | [
"Edits",
"a",
"project",
"by",
"ID",
".",
"All",
"fields",
"available",
"at",
"creation",
"can",
"be",
"updated",
"as",
"well",
".",
"If",
"you",
"want",
"to",
"update",
"hourly",
"rates",
"retroactively",
"set",
"the",
"argument",
"update_hourly_rate_on_time_... | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L286-L293 |
port-zero/mite | mite/mite.py | Mite.create_service | def create_service(self, name, **kwargs):
"""
Creates a service with a name. All other parameters are optional. They
are: `note`, `hourly_rate`, `billable`, and `archived`.
"""
data = self._wrap_dict("service", kwargs)
data["customer"]["name"] = name
return self.p... | python | def create_service(self, name, **kwargs):
"""
Creates a service with a name. All other parameters are optional. They
are: `note`, `hourly_rate`, `billable`, and `archived`.
"""
data = self._wrap_dict("service", kwargs)
data["customer"]["name"] = name
return self.p... | [
"def",
"create_service",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"_wrap_dict",
"(",
"\"service\"",
",",
"kwargs",
")",
"data",
"[",
"\"customer\"",
"]",
"[",
"\"name\"",
"]",
"=",
"name",
"return",
"self",... | Creates a service with a name. All other parameters are optional. They
are: `note`, `hourly_rate`, `billable`, and `archived`. | [
"Creates",
"a",
"service",
"with",
"a",
"name",
".",
"All",
"other",
"parameters",
"are",
"optional",
".",
"They",
"are",
":",
"note",
"hourly_rate",
"billable",
"and",
"archived",
"."
] | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L322-L329 |
port-zero/mite | mite/mite.py | Mite.edit_service | def edit_service(self, id_, **kwargs):
"""
Edits a service by ID. All fields available at creation can be updated
as well. If you want to update hourly rates retroactively, set the
argument `update_hourly_rate_on_time_entries` to True.
"""
data = self._wrap_dict("service"... | python | def edit_service(self, id_, **kwargs):
"""
Edits a service by ID. All fields available at creation can be updated
as well. If you want to update hourly rates retroactively, set the
argument `update_hourly_rate_on_time_entries` to True.
"""
data = self._wrap_dict("service"... | [
"def",
"edit_service",
"(",
"self",
",",
"id_",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"_wrap_dict",
"(",
"\"service\"",
",",
"kwargs",
")",
"return",
"self",
".",
"patch",
"(",
"\"/services/{}.json\"",
".",
"format",
"(",
"id_",
... | Edits a service by ID. All fields available at creation can be updated
as well. If you want to update hourly rates retroactively, set the
argument `update_hourly_rate_on_time_entries` to True. | [
"Edits",
"a",
"service",
"by",
"ID",
".",
"All",
"fields",
"available",
"at",
"creation",
"can",
"be",
"updated",
"as",
"well",
".",
"If",
"you",
"want",
"to",
"update",
"hourly",
"rates",
"retroactively",
"set",
"the",
"argument",
"update_hourly_rate_on_time_... | train | https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L331-L338 |
naphatkrit/easyci | easyci/history.py | get_committed_signatures | def get_committed_signatures(vcs):
"""Get the list of committed signatures
Args:
vcs (easyci.vcs.base.Vcs)
Returns:
list(basestring) - list of signatures
"""
committed_path = _get_committed_history_path(vcs)
known_signatures = []
if os.path.exists(committed_path):
w... | python | def get_committed_signatures(vcs):
"""Get the list of committed signatures
Args:
vcs (easyci.vcs.base.Vcs)
Returns:
list(basestring) - list of signatures
"""
committed_path = _get_committed_history_path(vcs)
known_signatures = []
if os.path.exists(committed_path):
w... | [
"def",
"get_committed_signatures",
"(",
"vcs",
")",
":",
"committed_path",
"=",
"_get_committed_history_path",
"(",
"vcs",
")",
"known_signatures",
"=",
"[",
"]",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"committed_path",
")",
":",
"with",
"open",
"(",
"... | Get the list of committed signatures
Args:
vcs (easyci.vcs.base.Vcs)
Returns:
list(basestring) - list of signatures | [
"Get",
"the",
"list",
"of",
"committed",
"signatures"
] | train | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/history.py#L40-L54 |
naphatkrit/easyci | easyci/history.py | get_staged_signatures | def get_staged_signatures(vcs):
"""Get the list of staged signatures
Args:
vcs (easyci.vcs.base.Vcs)
Returns:
list(basestring) - list of signatures
"""
staged_path = _get_staged_history_path(vcs)
known_signatures = []
if os.path.exists(staged_path):
with open(staged... | python | def get_staged_signatures(vcs):
"""Get the list of staged signatures
Args:
vcs (easyci.vcs.base.Vcs)
Returns:
list(basestring) - list of signatures
"""
staged_path = _get_staged_history_path(vcs)
known_signatures = []
if os.path.exists(staged_path):
with open(staged... | [
"def",
"get_staged_signatures",
"(",
"vcs",
")",
":",
"staged_path",
"=",
"_get_staged_history_path",
"(",
"vcs",
")",
"known_signatures",
"=",
"[",
"]",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"staged_path",
")",
":",
"with",
"open",
"(",
"staged_path"... | Get the list of staged signatures
Args:
vcs (easyci.vcs.base.Vcs)
Returns:
list(basestring) - list of signatures | [
"Get",
"the",
"list",
"of",
"staged",
"signatures"
] | train | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/history.py#L57-L71 |
naphatkrit/easyci | easyci/history.py | commit_signature | def commit_signature(vcs, user_config, signature):
"""Add `signature` to the list of committed signatures
The signature must already be staged
Args:
vcs (easyci.vcs.base.Vcs)
user_config (dict)
signature (basestring)
Raises:
NotStagedError
AlreadyCommittedError... | python | def commit_signature(vcs, user_config, signature):
"""Add `signature` to the list of committed signatures
The signature must already be staged
Args:
vcs (easyci.vcs.base.Vcs)
user_config (dict)
signature (basestring)
Raises:
NotStagedError
AlreadyCommittedError... | [
"def",
"commit_signature",
"(",
"vcs",
",",
"user_config",
",",
"signature",
")",
":",
"if",
"signature",
"not",
"in",
"get_staged_signatures",
"(",
"vcs",
")",
":",
"raise",
"NotStagedError",
"evidence_path",
"=",
"_get_committed_history_path",
"(",
"vcs",
")",
... | Add `signature` to the list of committed signatures
The signature must already be staged
Args:
vcs (easyci.vcs.base.Vcs)
user_config (dict)
signature (basestring)
Raises:
NotStagedError
AlreadyCommittedError | [
"Add",
"signature",
"to",
"the",
"list",
"of",
"committed",
"signatures"
] | train | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/history.py#L74-L98 |
naphatkrit/easyci | easyci/history.py | stage_signature | def stage_signature(vcs, signature):
"""Add `signature` to the list of staged signatures
Args:
vcs (easyci.vcs.base.Vcs)
signature (basestring)
Raises:
AlreadyStagedError
"""
evidence_path = _get_staged_history_path(vcs)
staged = get_staged_signatures(vcs)
if signat... | python | def stage_signature(vcs, signature):
"""Add `signature` to the list of staged signatures
Args:
vcs (easyci.vcs.base.Vcs)
signature (basestring)
Raises:
AlreadyStagedError
"""
evidence_path = _get_staged_history_path(vcs)
staged = get_staged_signatures(vcs)
if signat... | [
"def",
"stage_signature",
"(",
"vcs",
",",
"signature",
")",
":",
"evidence_path",
"=",
"_get_staged_history_path",
"(",
"vcs",
")",
"staged",
"=",
"get_staged_signatures",
"(",
"vcs",
")",
"if",
"signature",
"in",
"staged",
":",
"raise",
"AlreadyStagedError",
"... | Add `signature` to the list of staged signatures
Args:
vcs (easyci.vcs.base.Vcs)
signature (basestring)
Raises:
AlreadyStagedError | [
"Add",
"signature",
"to",
"the",
"list",
"of",
"staged",
"signatures"
] | train | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/history.py#L101-L118 |
naphatkrit/easyci | easyci/history.py | unstage_signature | def unstage_signature(vcs, signature):
"""Remove `signature` from the list of staged signatures
Args:
vcs (easyci.vcs.base.Vcs)
signature (basestring)
Raises:
NotStagedError
"""
evidence_path = _get_staged_history_path(vcs)
staged = get_staged_signatures(vcs)
if sig... | python | def unstage_signature(vcs, signature):
"""Remove `signature` from the list of staged signatures
Args:
vcs (easyci.vcs.base.Vcs)
signature (basestring)
Raises:
NotStagedError
"""
evidence_path = _get_staged_history_path(vcs)
staged = get_staged_signatures(vcs)
if sig... | [
"def",
"unstage_signature",
"(",
"vcs",
",",
"signature",
")",
":",
"evidence_path",
"=",
"_get_staged_history_path",
"(",
"vcs",
")",
"staged",
"=",
"get_staged_signatures",
"(",
"vcs",
")",
"if",
"signature",
"not",
"in",
"staged",
":",
"raise",
"NotStagedErro... | Remove `signature` from the list of staged signatures
Args:
vcs (easyci.vcs.base.Vcs)
signature (basestring)
Raises:
NotStagedError | [
"Remove",
"signature",
"from",
"the",
"list",
"of",
"staged",
"signatures"
] | train | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/history.py#L121-L138 |
naphatkrit/easyci | easyci/history.py | clear_history | def clear_history(vcs):
"""Clear (committed) test run history from this project.
Args:
vcs (easyci.vcs.base.Vcs)
"""
evidence_path = _get_committed_history_path(vcs)
if os.path.exists(evidence_path):
os.remove(evidence_path) | python | def clear_history(vcs):
"""Clear (committed) test run history from this project.
Args:
vcs (easyci.vcs.base.Vcs)
"""
evidence_path = _get_committed_history_path(vcs)
if os.path.exists(evidence_path):
os.remove(evidence_path) | [
"def",
"clear_history",
"(",
"vcs",
")",
":",
"evidence_path",
"=",
"_get_committed_history_path",
"(",
"vcs",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"evidence_path",
")",
":",
"os",
".",
"remove",
"(",
"evidence_path",
")"
] | Clear (committed) test run history from this project.
Args:
vcs (easyci.vcs.base.Vcs) | [
"Clear",
"(",
"committed",
")",
"test",
"run",
"history",
"from",
"this",
"project",
"."
] | train | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/history.py#L141-L149 |
MacHu-GWU/windtalker-project | windtalker/files.py | get_encrpyted_path | def get_encrpyted_path(original_path, surfix=default_surfix):
"""
Find the output encrypted file /dir path (by adding a surfix).
Example:
- file: ``${home}/test.txt`` -> ``${home}/test-encrypted.txt``
- dir: ``${home}/Documents`` -> ``${home}/Documents-encrypted``
"""
p = Path(original_pat... | python | def get_encrpyted_path(original_path, surfix=default_surfix):
"""
Find the output encrypted file /dir path (by adding a surfix).
Example:
- file: ``${home}/test.txt`` -> ``${home}/test-encrypted.txt``
- dir: ``${home}/Documents`` -> ``${home}/Documents-encrypted``
"""
p = Path(original_pat... | [
"def",
"get_encrpyted_path",
"(",
"original_path",
",",
"surfix",
"=",
"default_surfix",
")",
":",
"p",
"=",
"Path",
"(",
"original_path",
")",
".",
"absolute",
"(",
")",
"encrypted_p",
"=",
"p",
".",
"change",
"(",
"new_fname",
"=",
"p",
".",
"fname",
"... | Find the output encrypted file /dir path (by adding a surfix).
Example:
- file: ``${home}/test.txt`` -> ``${home}/test-encrypted.txt``
- dir: ``${home}/Documents`` -> ``${home}/Documents-encrypted`` | [
"Find",
"the",
"output",
"encrypted",
"file",
"/",
"dir",
"path",
"(",
"by",
"adding",
"a",
"surfix",
")",
"."
] | train | https://github.com/MacHu-GWU/windtalker-project/blob/1dcff7c3692d5883cf1b55d1ea745723cfc6c3ce/windtalker/files.py#L12-L23 |
MacHu-GWU/windtalker-project | windtalker/files.py | get_decrpyted_path | def get_decrpyted_path(encrypted_path, surfix=default_surfix):
"""
Find the original path of encrypted file or dir.
Example:
- file: ``${home}/test-encrypted.txt`` -> ``${home}/test.txt``
- dir: ``${home}/Documents-encrypted`` -> ``${home}/Documents``
"""
surfix_reversed = surfix[::-1]
... | python | def get_decrpyted_path(encrypted_path, surfix=default_surfix):
"""
Find the original path of encrypted file or dir.
Example:
- file: ``${home}/test-encrypted.txt`` -> ``${home}/test.txt``
- dir: ``${home}/Documents-encrypted`` -> ``${home}/Documents``
"""
surfix_reversed = surfix[::-1]
... | [
"def",
"get_decrpyted_path",
"(",
"encrypted_path",
",",
"surfix",
"=",
"default_surfix",
")",
":",
"surfix_reversed",
"=",
"surfix",
"[",
":",
":",
"-",
"1",
"]",
"p",
"=",
"Path",
"(",
"encrypted_path",
")",
".",
"absolute",
"(",
")",
"fname",
"=",
"p"... | Find the original path of encrypted file or dir.
Example:
- file: ``${home}/test-encrypted.txt`` -> ``${home}/test.txt``
- dir: ``${home}/Documents-encrypted`` -> ``${home}/Documents`` | [
"Find",
"the",
"original",
"path",
"of",
"encrypted",
"file",
"or",
"dir",
"."
] | train | https://github.com/MacHu-GWU/windtalker-project/blob/1dcff7c3692d5883cf1b55d1ea745723cfc6c3ce/windtalker/files.py#L26-L42 |
MacHu-GWU/windtalker-project | windtalker/files.py | transform | def transform(src, dst, converter,
overwrite=False, stream=True, chunksize=1024**2, **kwargs):
"""
A file stream transform IO utility function.
:param src: original file path
:param dst: destination file path
:param converter: binary content converter function
:param overwrite: de... | python | def transform(src, dst, converter,
overwrite=False, stream=True, chunksize=1024**2, **kwargs):
"""
A file stream transform IO utility function.
:param src: original file path
:param dst: destination file path
:param converter: binary content converter function
:param overwrite: de... | [
"def",
"transform",
"(",
"src",
",",
"dst",
",",
"converter",
",",
"overwrite",
"=",
"False",
",",
"stream",
"=",
"True",
",",
"chunksize",
"=",
"1024",
"**",
"2",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"overwrite",
":",
"# pragma: no cover",
... | A file stream transform IO utility function.
:param src: original file path
:param dst: destination file path
:param converter: binary content converter function
:param overwrite: default False,
:param stream: default True, if True, use stream IO mode, chunksize has to
be specified.
:para... | [
"A",
"file",
"stream",
"transform",
"IO",
"utility",
"function",
"."
] | train | https://github.com/MacHu-GWU/windtalker-project/blob/1dcff7c3692d5883cf1b55d1ea745723cfc6c3ce/windtalker/files.py#L45-L79 |
billyoverton/tweetqueue | tweetqueue/TweetList.py | TweetList.append | def append(self, tweet):
"""Add a tweet to the end of the list."""
c = self.connection.cursor()
last_tweet = c.execute("SELECT tweet from tweetlist where label='last_tweet'").next()[0]
c.execute("INSERT INTO tweets(message, previous_tweet, next_tweet) VALUES (?,?,NULL)", (tweet, last_... | python | def append(self, tweet):
"""Add a tweet to the end of the list."""
c = self.connection.cursor()
last_tweet = c.execute("SELECT tweet from tweetlist where label='last_tweet'").next()[0]
c.execute("INSERT INTO tweets(message, previous_tweet, next_tweet) VALUES (?,?,NULL)", (tweet, last_... | [
"def",
"append",
"(",
"self",
",",
"tweet",
")",
":",
"c",
"=",
"self",
".",
"connection",
".",
"cursor",
"(",
")",
"last_tweet",
"=",
"c",
".",
"execute",
"(",
"\"SELECT tweet from tweetlist where label='last_tweet'\"",
")",
".",
"next",
"(",
")",
"[",
"0... | Add a tweet to the end of the list. | [
"Add",
"a",
"tweet",
"to",
"the",
"end",
"of",
"the",
"list",
"."
] | train | https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/TweetList.py#L57-L78 |
billyoverton/tweetqueue | tweetqueue/TweetList.py | TweetList.pop | def pop(self):
"""Return first tweet in the list."""
c = self.connection.cursor()
first_tweet_id = c.execute("SELECT tweet from tweetlist where label='first_tweet'").next()[0]
if first_tweet_id is None:
# No tweets are in the list, so return None
return None
... | python | def pop(self):
"""Return first tweet in the list."""
c = self.connection.cursor()
first_tweet_id = c.execute("SELECT tweet from tweetlist where label='first_tweet'").next()[0]
if first_tweet_id is None:
# No tweets are in the list, so return None
return None
... | [
"def",
"pop",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"connection",
".",
"cursor",
"(",
")",
"first_tweet_id",
"=",
"c",
".",
"execute",
"(",
"\"SELECT tweet from tweetlist where label='first_tweet'\"",
")",
".",
"next",
"(",
")",
"[",
"0",
"]",
"if"... | Return first tweet in the list. | [
"Return",
"first",
"tweet",
"in",
"the",
"list",
"."
] | train | https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/TweetList.py#L81-L108 |
billyoverton/tweetqueue | tweetqueue/TweetList.py | TweetList.peek | def peek(self):
"""Peeks at the first of the list without removing it."""
c = self.connection.cursor()
first_tweet_id = c.execute("SELECT tweet from tweetlist where label='first_tweet'").next()[0]
if first_tweet_id is None:
# No tweets are in the list, so return None
... | python | def peek(self):
"""Peeks at the first of the list without removing it."""
c = self.connection.cursor()
first_tweet_id = c.execute("SELECT tweet from tweetlist where label='first_tweet'").next()[0]
if first_tweet_id is None:
# No tweets are in the list, so return None
... | [
"def",
"peek",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"connection",
".",
"cursor",
"(",
")",
"first_tweet_id",
"=",
"c",
".",
"execute",
"(",
"\"SELECT tweet from tweetlist where label='first_tweet'\"",
")",
".",
"next",
"(",
")",
"[",
"0",
"]",
"if... | Peeks at the first of the list without removing it. | [
"Peeks",
"at",
"the",
"first",
"of",
"the",
"list",
"without",
"removing",
"it",
"."
] | train | https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/TweetList.py#L110-L121 |
billyoverton/tweetqueue | tweetqueue/TweetList.py | TweetList.delete | def delete(self, tweet_id):
"""Deletes a tweet from the list with the given id"""
c = self.connection.cursor()
try:
tweet = c.execute("SELECT id, message, previous_tweet, next_tweet from tweets WHERE id=?", (tweet_id,)).next()
except StopIteration:
raise ValueErr... | python | def delete(self, tweet_id):
"""Deletes a tweet from the list with the given id"""
c = self.connection.cursor()
try:
tweet = c.execute("SELECT id, message, previous_tweet, next_tweet from tweets WHERE id=?", (tweet_id,)).next()
except StopIteration:
raise ValueErr... | [
"def",
"delete",
"(",
"self",
",",
"tweet_id",
")",
":",
"c",
"=",
"self",
".",
"connection",
".",
"cursor",
"(",
")",
"try",
":",
"tweet",
"=",
"c",
".",
"execute",
"(",
"\"SELECT id, message, previous_tweet, next_tweet from tweets WHERE id=?\"",
",",
"(",
"t... | Deletes a tweet from the list with the given id | [
"Deletes",
"a",
"tweet",
"from",
"the",
"list",
"with",
"the",
"given",
"id"
] | train | https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/TweetList.py#L130-L152 |
scdoshi/django-bits | bits/models.py | usetz_now | def usetz_now():
"""Determine current time depending on USE_TZ setting.
Affects Django 1.4 and above only. if `USE_TZ = True`, then returns
current time according to timezone, else returns current UTC time.
"""
USE_TZ = getattr(settings, 'USE_TZ', False)
if USE_TZ and DJANGO_VERSION >= '1.4':
... | python | def usetz_now():
"""Determine current time depending on USE_TZ setting.
Affects Django 1.4 and above only. if `USE_TZ = True`, then returns
current time according to timezone, else returns current UTC time.
"""
USE_TZ = getattr(settings, 'USE_TZ', False)
if USE_TZ and DJANGO_VERSION >= '1.4':
... | [
"def",
"usetz_now",
"(",
")",
":",
"USE_TZ",
"=",
"getattr",
"(",
"settings",
",",
"'USE_TZ'",
",",
"False",
")",
"if",
"USE_TZ",
"and",
"DJANGO_VERSION",
">=",
"'1.4'",
":",
"return",
"now",
"(",
")",
"else",
":",
"return",
"datetime",
".",
"utcnow",
... | Determine current time depending on USE_TZ setting.
Affects Django 1.4 and above only. if `USE_TZ = True`, then returns
current time according to timezone, else returns current UTC time. | [
"Determine",
"current",
"time",
"depending",
"on",
"USE_TZ",
"setting",
"."
] | train | https://github.com/scdoshi/django-bits/blob/0a2f4fd9374d2a8acb8df9a7b83eebcf2782256f/bits/models.py#L25-L36 |
tBaxter/tango-comments | build/lib/tango_comments/moderation.py | CommentModerator._get_delta | def _get_delta(self, now, then):
"""
Internal helper which will return a ``datetime.timedelta``
representing the time between ``now`` and ``then``. Assumes
``now`` is a ``datetime.date`` or ``datetime.datetime`` later
than ``then``.
If ``now`` and ``then`` are not of the... | python | def _get_delta(self, now, then):
"""
Internal helper which will return a ``datetime.timedelta``
representing the time between ``now`` and ``then``. Assumes
``now`` is a ``datetime.date`` or ``datetime.datetime`` later
than ``then``.
If ``now`` and ``then`` are not of the... | [
"def",
"_get_delta",
"(",
"self",
",",
"now",
",",
"then",
")",
":",
"if",
"now",
".",
"__class__",
"is",
"not",
"then",
".",
"__class__",
":",
"now",
"=",
"datetime",
".",
"date",
"(",
"now",
".",
"year",
",",
"now",
".",
"month",
",",
"now",
".... | Internal helper which will return a ``datetime.timedelta``
representing the time between ``now`` and ``then``. Assumes
``now`` is a ``datetime.date`` or ``datetime.datetime`` later
than ``then``.
If ``now`` and ``then`` are not of the same type due to one of
them being a ``datet... | [
"Internal",
"helper",
"which",
"will",
"return",
"a",
"datetime",
".",
"timedelta",
"representing",
"the",
"time",
"between",
"now",
"and",
"then",
".",
"Assumes",
"now",
"is",
"a",
"datetime",
".",
"date",
"or",
"datetime",
".",
"datetime",
"later",
"than",... | train | https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/moderation.py#L179-L197 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.