repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_android_utils.py | _AndroidUtilsKeywords.push_file | def push_file(self, path, data, encode=False):
"""Puts the data in the file specified as `path`.
Android only.
- _path_ - the path on the device
- _data_ - data to be written to the file
- _encode_ - True/False encode the data as base64 before writing it to the file (default... | python | def push_file(self, path, data, encode=False):
"""Puts the data in the file specified as `path`.
Android only.
- _path_ - the path on the device
- _data_ - data to be written to the file
- _encode_ - True/False encode the data as base64 before writing it to the file (default... | [
"def",
"push_file",
"(",
"self",
",",
"path",
",",
"data",
",",
"encode",
"=",
"False",
")",
":",
"driver",
"=",
"self",
".",
"_current_application",
"(",
")",
"data",
"=",
"to_bytes",
"(",
"data",
")",
"if",
"encode",
":",
"data",
"=",
"base64",
"."... | Puts the data in the file specified as `path`.
Android only.
- _path_ - the path on the device
- _data_ - data to be written to the file
- _encode_ - True/False encode the data as base64 before writing it to the file (default=False) | [
"Puts",
"the",
"data",
"in",
"the",
"file",
"specified",
"as",
"path",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_android_utils.py#L65-L78 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_android_utils.py | _AndroidUtilsKeywords.start_activity | def start_activity(self, appPackage, appActivity, **opts):
"""Opens an arbitrary activity during a test. If the activity belongs to
another application, that application is started and the activity is opened.
Android only.
- _appPackage_ - The package containing the activity to start.
... | python | def start_activity(self, appPackage, appActivity, **opts):
"""Opens an arbitrary activity during a test. If the activity belongs to
another application, that application is started and the activity is opened.
Android only.
- _appPackage_ - The package containing the activity to start.
... | [
"def",
"start_activity",
"(",
"self",
",",
"appPackage",
",",
"appActivity",
",",
"**",
"opts",
")",
":",
"arguments",
"=",
"{",
"'app_wait_package'",
":",
"'appWaitPackage'",
",",
"'app_wait_activity'",
":",
"'appWaitActivity'",
",",
"'intent_action'",
":",
"'int... | Opens an arbitrary activity during a test. If the activity belongs to
another application, that application is started and the activity is opened.
Android only.
- _appPackage_ - The package containing the activity to start.
- _appActivity_ - The activity to start.
- _appWaitPac... | [
"Opens",
"an",
"arbitrary",
"activity",
"during",
"a",
"test",
".",
"If",
"the",
"activity",
"belongs",
"to",
"another",
"application",
"that",
"application",
"is",
"started",
"and",
"the",
"activity",
"is",
"opened",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_android_utils.py#L89-L128 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_android_utils.py | _AndroidUtilsKeywords.install_app | def install_app(self, app_path, app_package):
""" Install App via Appium
Android only.
- app_path - path to app
- app_package - package of install app to verify
"""
driver = self._current_application()
driver.install_app(app_path)
return driver.i... | python | def install_app(self, app_path, app_package):
""" Install App via Appium
Android only.
- app_path - path to app
- app_package - package of install app to verify
"""
driver = self._current_application()
driver.install_app(app_path)
return driver.i... | [
"def",
"install_app",
"(",
"self",
",",
"app_path",
",",
"app_package",
")",
":",
"driver",
"=",
"self",
".",
"_current_application",
"(",
")",
"driver",
".",
"install_app",
"(",
"app_path",
")",
"return",
"driver",
".",
"is_app_installed",
"(",
"app_package",... | Install App via Appium
Android only.
- app_path - path to app
- app_package - package of install app to verify | [
"Install",
"App",
"via",
"Appium",
"Android",
"only",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_android_utils.py#L148-L158 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | _ElementKeywords.click_element | def click_element(self, locator):
"""Click element identified by `locator`.
Key attributes for arbitrary elements are `index` and `name`. See
`introduction` for details about locating elements.
"""
self._info("Clicking element '%s'." % locator)
self._element_find(... | python | def click_element(self, locator):
"""Click element identified by `locator`.
Key attributes for arbitrary elements are `index` and `name`. See
`introduction` for details about locating elements.
"""
self._info("Clicking element '%s'." % locator)
self._element_find(... | [
"def",
"click_element",
"(",
"self",
",",
"locator",
")",
":",
"self",
".",
"_info",
"(",
"\"Clicking element '%s'.\"",
"%",
"locator",
")",
"self",
".",
"_element_find",
"(",
"locator",
",",
"True",
",",
"True",
")",
".",
"click",
"(",
")"
] | Click element identified by `locator`.
Key attributes for arbitrary elements are `index` and `name`. See
`introduction` for details about locating elements. | [
"Click",
"element",
"identified",
"by",
"locator",
".",
"Key",
"attributes",
"for",
"arbitrary",
"elements",
"are",
"index",
"and",
"name",
".",
"See",
"introduction",
"for",
"details",
"about",
"locating",
"elements",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L35-L42 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | _ElementKeywords.click_text | def click_text(self, text, exact_match=False):
"""Click text identified by ``text``.
By default tries to click first text involves given ``text``, if you would
like to click exactly matching text, then set ``exact_match`` to `True`.
If there are multiple use of ``text`` and you ... | python | def click_text(self, text, exact_match=False):
"""Click text identified by ``text``.
By default tries to click first text involves given ``text``, if you would
like to click exactly matching text, then set ``exact_match`` to `True`.
If there are multiple use of ``text`` and you ... | [
"def",
"click_text",
"(",
"self",
",",
"text",
",",
"exact_match",
"=",
"False",
")",
":",
"self",
".",
"_element_find_by_text",
"(",
"text",
",",
"exact_match",
")",
".",
"click",
"(",
")"
] | Click text identified by ``text``.
By default tries to click first text involves given ``text``, if you would
like to click exactly matching text, then set ``exact_match`` to `True`.
If there are multiple use of ``text`` and you do not want first one,
use `locator` with `Get Web... | [
"Click",
"text",
"identified",
"by",
"text",
".",
"By",
"default",
"tries",
"to",
"click",
"first",
"text",
"involves",
"given",
"text",
"if",
"you",
"would",
"like",
"to",
"click",
"exactly",
"matching",
"text",
"then",
"set",
"exact_match",
"to",
"True",
... | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L52-L62 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | _ElementKeywords.input_text | def input_text(self, locator, text):
"""Types the given `text` into text field identified by `locator`.
See `introduction` for details about locating elements.
"""
self._info("Typing text '%s' into text field '%s'" % (text, locator))
self._element_input_text_by_locator(loc... | python | def input_text(self, locator, text):
"""Types the given `text` into text field identified by `locator`.
See `introduction` for details about locating elements.
"""
self._info("Typing text '%s' into text field '%s'" % (text, locator))
self._element_input_text_by_locator(loc... | [
"def",
"input_text",
"(",
"self",
",",
"locator",
",",
"text",
")",
":",
"self",
".",
"_info",
"(",
"\"Typing text '%s' into text field '%s'\"",
"%",
"(",
"text",
",",
"locator",
")",
")",
"self",
".",
"_element_input_text_by_locator",
"(",
"locator",
",",
"te... | Types the given `text` into text field identified by `locator`.
See `introduction` for details about locating elements. | [
"Types",
"the",
"given",
"text",
"into",
"text",
"field",
"identified",
"by",
"locator",
".",
"See",
"introduction",
"for",
"details",
"about",
"locating",
"elements",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L64-L70 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | _ElementKeywords.input_password | def input_password(self, locator, text):
"""Types the given password into text field identified by `locator`.
Difference between this keyword and `Input Text` is that this keyword
does not log the given password. See `introduction` for details about
locating elements.
"""
... | python | def input_password(self, locator, text):
"""Types the given password into text field identified by `locator`.
Difference between this keyword and `Input Text` is that this keyword
does not log the given password. See `introduction` for details about
locating elements.
"""
... | [
"def",
"input_password",
"(",
"self",
",",
"locator",
",",
"text",
")",
":",
"self",
".",
"_info",
"(",
"\"Typing password into text field '%s'\"",
"%",
"locator",
")",
"self",
".",
"_element_input_text_by_locator",
"(",
"locator",
",",
"text",
")"
] | Types the given password into text field identified by `locator`.
Difference between this keyword and `Input Text` is that this keyword
does not log the given password. See `introduction` for details about
locating elements. | [
"Types",
"the",
"given",
"password",
"into",
"text",
"field",
"identified",
"by",
"locator",
".",
"Difference",
"between",
"this",
"keyword",
"and",
"Input",
"Text",
"is",
"that",
"this",
"keyword",
"does",
"not",
"log",
"the",
"given",
"password",
".",
"See... | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L72-L80 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | _ElementKeywords.input_value | def input_value(self, locator, text):
"""Sets the given value into text field identified by `locator`. This is an IOS only keyword, input value makes use of set_value
See `introduction` for details about locating elements.
"""
self._info("Setting text '%s' into text field '%s'" % (... | python | def input_value(self, locator, text):
"""Sets the given value into text field identified by `locator`. This is an IOS only keyword, input value makes use of set_value
See `introduction` for details about locating elements.
"""
self._info("Setting text '%s' into text field '%s'" % (... | [
"def",
"input_value",
"(",
"self",
",",
"locator",
",",
"text",
")",
":",
"self",
".",
"_info",
"(",
"\"Setting text '%s' into text field '%s'\"",
"%",
"(",
"text",
",",
"locator",
")",
")",
"self",
".",
"_element_input_value_by_locator",
"(",
"locator",
",",
... | Sets the given value into text field identified by `locator`. This is an IOS only keyword, input value makes use of set_value
See `introduction` for details about locating elements. | [
"Sets",
"the",
"given",
"value",
"into",
"text",
"field",
"identified",
"by",
"locator",
".",
"This",
"is",
"an",
"IOS",
"only",
"keyword",
"input",
"value",
"makes",
"use",
"of",
"set_value",
"See",
"introduction",
"for",
"details",
"about",
"locating",
"el... | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L82-L88 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | _ElementKeywords.page_should_contain_text | def page_should_contain_text(self, text, loglevel='INFO'):
"""Verifies that current page contains `text`.
If this keyword fails, it automatically logs the page source
using the log level specified with the optional `loglevel` argument.
Giving `NONE` as level disables logging.
... | python | def page_should_contain_text(self, text, loglevel='INFO'):
"""Verifies that current page contains `text`.
If this keyword fails, it automatically logs the page source
using the log level specified with the optional `loglevel` argument.
Giving `NONE` as level disables logging.
... | [
"def",
"page_should_contain_text",
"(",
"self",
",",
"text",
",",
"loglevel",
"=",
"'INFO'",
")",
":",
"if",
"not",
"self",
".",
"_is_text_present",
"(",
"text",
")",
":",
"self",
".",
"log_source",
"(",
"loglevel",
")",
"raise",
"AssertionError",
"(",
"\"... | Verifies that current page contains `text`.
If this keyword fails, it automatically logs the page source
using the log level specified with the optional `loglevel` argument.
Giving `NONE` as level disables logging. | [
"Verifies",
"that",
"current",
"page",
"contains",
"text",
".",
"If",
"this",
"keyword",
"fails",
"it",
"automatically",
"logs",
"the",
"page",
"source",
"using",
"the",
"log",
"level",
"specified",
"with",
"the",
"optional",
"loglevel",
"argument",
".",
"Givi... | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L97-L108 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | _ElementKeywords.page_should_not_contain_text | def page_should_not_contain_text(self, text, loglevel='INFO'):
"""Verifies that current page not contains `text`.
If this keyword fails, it automatically logs the page source
using the log level specified with the optional `loglevel` argument.
Giving `NONE` as level disables loggin... | python | def page_should_not_contain_text(self, text, loglevel='INFO'):
"""Verifies that current page not contains `text`.
If this keyword fails, it automatically logs the page source
using the log level specified with the optional `loglevel` argument.
Giving `NONE` as level disables loggin... | [
"def",
"page_should_not_contain_text",
"(",
"self",
",",
"text",
",",
"loglevel",
"=",
"'INFO'",
")",
":",
"if",
"self",
".",
"_is_text_present",
"(",
"text",
")",
":",
"self",
".",
"log_source",
"(",
"loglevel",
")",
"raise",
"AssertionError",
"(",
"\"Page ... | Verifies that current page not contains `text`.
If this keyword fails, it automatically logs the page source
using the log level specified with the optional `loglevel` argument.
Giving `NONE` as level disables logging. | [
"Verifies",
"that",
"current",
"page",
"not",
"contains",
"text",
".",
"If",
"this",
"keyword",
"fails",
"it",
"automatically",
"logs",
"the",
"page",
"source",
"using",
"the",
"log",
"level",
"specified",
"with",
"the",
"optional",
"loglevel",
"argument",
"."... | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L110-L120 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | _ElementKeywords.page_should_contain_element | def page_should_contain_element(self, locator, loglevel='INFO'):
"""Verifies that current page contains `locator` element.
If this keyword fails, it automatically logs the page source
using the log level specified with the optional `loglevel` argument.
Giving `NONE` as level disabl... | python | def page_should_contain_element(self, locator, loglevel='INFO'):
"""Verifies that current page contains `locator` element.
If this keyword fails, it automatically logs the page source
using the log level specified with the optional `loglevel` argument.
Giving `NONE` as level disabl... | [
"def",
"page_should_contain_element",
"(",
"self",
",",
"locator",
",",
"loglevel",
"=",
"'INFO'",
")",
":",
"if",
"not",
"self",
".",
"_is_element_present",
"(",
"locator",
")",
":",
"self",
".",
"log_source",
"(",
"loglevel",
")",
"raise",
"AssertionError",
... | Verifies that current page contains `locator` element.
If this keyword fails, it automatically logs the page source
using the log level specified with the optional `loglevel` argument.
Giving `NONE` as level disables logging. | [
"Verifies",
"that",
"current",
"page",
"contains",
"locator",
"element",
".",
"If",
"this",
"keyword",
"fails",
"it",
"automatically",
"logs",
"the",
"page",
"source",
"using",
"the",
"log",
"level",
"specified",
"with",
"the",
"optional",
"loglevel",
"argument"... | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L122-L133 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | _ElementKeywords.page_should_not_contain_element | def page_should_not_contain_element(self, locator, loglevel='INFO'):
"""Verifies that current page not contains `locator` element.
If this keyword fails, it automatically logs the page source
using the log level specified with the optional `loglevel` argument.
Giving `NONE` as leve... | python | def page_should_not_contain_element(self, locator, loglevel='INFO'):
"""Verifies that current page not contains `locator` element.
If this keyword fails, it automatically logs the page source
using the log level specified with the optional `loglevel` argument.
Giving `NONE` as leve... | [
"def",
"page_should_not_contain_element",
"(",
"self",
",",
"locator",
",",
"loglevel",
"=",
"'INFO'",
")",
":",
"if",
"self",
".",
"_is_element_present",
"(",
"locator",
")",
":",
"self",
".",
"log_source",
"(",
"loglevel",
")",
"raise",
"AssertionError",
"("... | Verifies that current page not contains `locator` element.
If this keyword fails, it automatically logs the page source
using the log level specified with the optional `loglevel` argument.
Giving `NONE` as level disables logging. | [
"Verifies",
"that",
"current",
"page",
"not",
"contains",
"locator",
"element",
".",
"If",
"this",
"keyword",
"fails",
"it",
"automatically",
"logs",
"the",
"page",
"source",
"using",
"the",
"log",
"level",
"specified",
"with",
"the",
"optional",
"loglevel",
"... | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L135-L145 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | _ElementKeywords.element_should_be_disabled | def element_should_be_disabled(self, locator, loglevel='INFO'):
"""Verifies that element identified with locator is disabled.
Key attributes for arbitrary elements are `id` and `name`. See
`introduction` for details about locating elements.
"""
if self._element_find(locato... | python | def element_should_be_disabled(self, locator, loglevel='INFO'):
"""Verifies that element identified with locator is disabled.
Key attributes for arbitrary elements are `id` and `name`. See
`introduction` for details about locating elements.
"""
if self._element_find(locato... | [
"def",
"element_should_be_disabled",
"(",
"self",
",",
"locator",
",",
"loglevel",
"=",
"'INFO'",
")",
":",
"if",
"self",
".",
"_element_find",
"(",
"locator",
",",
"True",
",",
"True",
")",
".",
"is_enabled",
"(",
")",
":",
"self",
".",
"log_source",
"(... | Verifies that element identified with locator is disabled.
Key attributes for arbitrary elements are `id` and `name`. See
`introduction` for details about locating elements. | [
"Verifies",
"that",
"element",
"identified",
"with",
"locator",
"is",
"disabled",
".",
"Key",
"attributes",
"for",
"arbitrary",
"elements",
"are",
"id",
"and",
"name",
".",
"See",
"introduction",
"for",
"details",
"about",
"locating",
"elements",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L147-L157 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | _ElementKeywords.element_should_be_visible | def element_should_be_visible(self, locator, loglevel='INFO'):
"""Verifies that element identified with locator is visible.
Key attributes for arbitrary elements are `id` and `name`. See
`introduction` for details about locating elements.
New in AppiumLibrary 1.4.... | python | def element_should_be_visible(self, locator, loglevel='INFO'):
"""Verifies that element identified with locator is visible.
Key attributes for arbitrary elements are `id` and `name`. See
`introduction` for details about locating elements.
New in AppiumLibrary 1.4.... | [
"def",
"element_should_be_visible",
"(",
"self",
",",
"locator",
",",
"loglevel",
"=",
"'INFO'",
")",
":",
"if",
"not",
"self",
".",
"_element_find",
"(",
"locator",
",",
"True",
",",
"True",
")",
".",
"is_displayed",
"(",
")",
":",
"self",
".",
"log_sou... | Verifies that element identified with locator is visible.
Key attributes for arbitrary elements are `id` and `name`. See
`introduction` for details about locating elements.
New in AppiumLibrary 1.4.5 | [
"Verifies",
"that",
"element",
"identified",
"with",
"locator",
"is",
"visible",
".",
"Key",
"attributes",
"for",
"arbitrary",
"elements",
"are",
"id",
"and",
"name",
".",
"See",
"introduction",
"for",
"details",
"about",
"locating",
"elements",
".",
"New",
"i... | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L171-L182 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | _ElementKeywords.element_text_should_be | def element_text_should_be(self, locator, expected, message=''):
"""Verifies element identified by ``locator`` exactly contains text ``expected``.
In contrast to `Element Should Contain Text`, this keyword does not try
a substring match but an exact match on the element identified by ``loca... | python | def element_text_should_be(self, locator, expected, message=''):
"""Verifies element identified by ``locator`` exactly contains text ``expected``.
In contrast to `Element Should Contain Text`, this keyword does not try
a substring match but an exact match on the element identified by ``loca... | [
"def",
"element_text_should_be",
"(",
"self",
",",
"locator",
",",
"expected",
",",
"message",
"=",
"''",
")",
":",
"self",
".",
"_info",
"(",
"\"Verifying element '%s' contains exactly text '%s'.\"",
"%",
"(",
"locator",
",",
"expected",
")",
")",
"element",
"=... | Verifies element identified by ``locator`` exactly contains text ``expected``.
In contrast to `Element Should Contain Text`, this keyword does not try
a substring match but an exact match on the element identified by ``locator``.
``message`` can be used to override the default error messa... | [
"Verifies",
"element",
"identified",
"by",
"locator",
"exactly",
"contains",
"text",
"expected",
".",
"In",
"contrast",
"to",
"Element",
"Should",
"Contain",
"Text",
"this",
"keyword",
"does",
"not",
"try",
"a",
"substring",
"match",
"but",
"an",
"exact",
"mat... | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L312-L330 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | _ElementKeywords.get_element_location | def get_element_location(self, locator):
"""Get element location
Key attributes for arbitrary elements are `id` and `name`. See
`introduction` for details about locating elements.
"""
element = self._element_find(locator, True, True)
element_location = element.loc... | python | def get_element_location(self, locator):
"""Get element location
Key attributes for arbitrary elements are `id` and `name`. See
`introduction` for details about locating elements.
"""
element = self._element_find(locator, True, True)
element_location = element.loc... | [
"def",
"get_element_location",
"(",
"self",
",",
"locator",
")",
":",
"element",
"=",
"self",
".",
"_element_find",
"(",
"locator",
",",
"True",
",",
"True",
")",
"element_location",
"=",
"element",
".",
"location",
"self",
".",
"_info",
"(",
"\"Element '%s'... | Get element location
Key attributes for arbitrary elements are `id` and `name`. See
`introduction` for details about locating elements. | [
"Get",
"element",
"location",
"Key",
"attributes",
"for",
"arbitrary",
"elements",
"are",
"id",
"and",
"name",
".",
"See",
"introduction",
"for",
"details",
"about",
"locating",
"elements",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L380-L389 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | _ElementKeywords.get_element_size | def get_element_size(self, locator):
"""Get element size
Key attributes for arbitrary elements are `id` and `name`. See
`introduction` for details about locating elements.
"""
element = self._element_find(locator, True, True)
element_size = element.size
s... | python | def get_element_size(self, locator):
"""Get element size
Key attributes for arbitrary elements are `id` and `name`. See
`introduction` for details about locating elements.
"""
element = self._element_find(locator, True, True)
element_size = element.size
s... | [
"def",
"get_element_size",
"(",
"self",
",",
"locator",
")",
":",
"element",
"=",
"self",
".",
"_element_find",
"(",
"locator",
",",
"True",
",",
"True",
")",
"element_size",
"=",
"element",
".",
"size",
"self",
".",
"_info",
"(",
"\"Element '%s' size: %s \"... | Get element size
Key attributes for arbitrary elements are `id` and `name`. See
`introduction` for details about locating elements. | [
"Get",
"element",
"size",
"Key",
"attributes",
"for",
"arbitrary",
"elements",
"are",
"id",
"and",
"name",
".",
"See",
"introduction",
"for",
"details",
"about",
"locating",
"elements",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L391-L400 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | _ElementKeywords.text_should_be_visible | def text_should_be_visible(self, text, exact_match=False, loglevel='INFO'):
"""Verifies that element identified with text is visible.
New in AppiumLibrary 1.4.5
"""
if not self._element_find_by_text(text, exact_match).is_displayed():
self.log_source(loglevel)
... | python | def text_should_be_visible(self, text, exact_match=False, loglevel='INFO'):
"""Verifies that element identified with text is visible.
New in AppiumLibrary 1.4.5
"""
if not self._element_find_by_text(text, exact_match).is_displayed():
self.log_source(loglevel)
... | [
"def",
"text_should_be_visible",
"(",
"self",
",",
"text",
",",
"exact_match",
"=",
"False",
",",
"loglevel",
"=",
"'INFO'",
")",
":",
"if",
"not",
"self",
".",
"_element_find_by_text",
"(",
"text",
",",
"exact_match",
")",
".",
"is_displayed",
"(",
")",
"... | Verifies that element identified with text is visible.
New in AppiumLibrary 1.4.5 | [
"Verifies",
"that",
"element",
"identified",
"with",
"text",
"is",
"visible",
".",
"New",
"in",
"AppiumLibrary",
"1",
".",
"4",
".",
"5"
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L433-L441 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_applicationmanagement.py | _ApplicationManagementKeywords.close_application | def close_application(self):
"""Closes the current application and also close webdriver session."""
self._debug('Closing application with session id %s' % self._current_application().session_id)
self._cache.close() | python | def close_application(self):
"""Closes the current application and also close webdriver session."""
self._debug('Closing application with session id %s' % self._current_application().session_id)
self._cache.close() | [
"def",
"close_application",
"(",
"self",
")",
":",
"self",
".",
"_debug",
"(",
"'Closing application with session id %s'",
"%",
"self",
".",
"_current_application",
"(",
")",
".",
"session_id",
")",
"self",
".",
"_cache",
".",
"close",
"(",
")"
] | Closes the current application and also close webdriver session. | [
"Closes",
"the",
"current",
"application",
"and",
"also",
"close",
"webdriver",
"session",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_applicationmanagement.py#L20-L23 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_applicationmanagement.py | _ApplicationManagementKeywords.get_appium_sessionId | def get_appium_sessionId(self):
"""Returns the current session ID as a reference"""
self._info("Appium Session ID: " + self._current_application().session_id)
return self._current_application().session_id | python | def get_appium_sessionId(self):
"""Returns the current session ID as a reference"""
self._info("Appium Session ID: " + self._current_application().session_id)
return self._current_application().session_id | [
"def",
"get_appium_sessionId",
"(",
"self",
")",
":",
"self",
".",
"_info",
"(",
"\"Appium Session ID: \"",
"+",
"self",
".",
"_current_application",
"(",
")",
".",
"session_id",
")",
"return",
"self",
".",
"_current_application",
"(",
")",
".",
"session_id"
] | Returns the current session ID as a reference | [
"Returns",
"the",
"current",
"session",
"ID",
"as",
"a",
"reference"
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_applicationmanagement.py#L163-L166 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_applicationmanagement.py | _ApplicationManagementKeywords.lock | def lock(self, seconds=5):
"""
Lock the device for a certain period of time. iOS only.
"""
self._current_application().lock(robot.utils.timestr_to_secs(seconds)) | python | def lock(self, seconds=5):
"""
Lock the device for a certain period of time. iOS only.
"""
self._current_application().lock(robot.utils.timestr_to_secs(seconds)) | [
"def",
"lock",
"(",
"self",
",",
"seconds",
"=",
"5",
")",
":",
"self",
".",
"_current_application",
"(",
")",
".",
"lock",
"(",
"robot",
".",
"utils",
".",
"timestr_to_secs",
"(",
"seconds",
")",
")"
] | Lock the device for a certain period of time. iOS only. | [
"Lock",
"the",
"device",
"for",
"a",
"certain",
"period",
"of",
"time",
".",
"iOS",
"only",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_applicationmanagement.py#L221-L225 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_applicationmanagement.py | _ApplicationManagementKeywords.get_capability | def get_capability(self, capability_name):
"""
Return the desired capability value by desired capability name
"""
try:
capability = self._current_application().capabilities[capability_name]
except Exception as e:
raise e
return capability | python | def get_capability(self, capability_name):
"""
Return the desired capability value by desired capability name
"""
try:
capability = self._current_application().capabilities[capability_name]
except Exception as e:
raise e
return capability | [
"def",
"get_capability",
"(",
"self",
",",
"capability_name",
")",
":",
"try",
":",
"capability",
"=",
"self",
".",
"_current_application",
"(",
")",
".",
"capabilities",
"[",
"capability_name",
"]",
"except",
"Exception",
"as",
"e",
":",
"raise",
"e",
"retu... | Return the desired capability value by desired capability name | [
"Return",
"the",
"desired",
"capability",
"value",
"by",
"desired",
"capability",
"name"
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_applicationmanagement.py#L317-L325 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/locators/elementfinder.py | ElementFinder._find_by_android | def _find_by_android(self, browser, criteria, tag, constraints):
"""Find element matches by UI Automator."""
return self._filter_elements(
browser.find_elements_by_android_uiautomator(criteria),
tag, constraints) | python | def _find_by_android(self, browser, criteria, tag, constraints):
"""Find element matches by UI Automator."""
return self._filter_elements(
browser.find_elements_by_android_uiautomator(criteria),
tag, constraints) | [
"def",
"_find_by_android",
"(",
"self",
",",
"browser",
",",
"criteria",
",",
"tag",
",",
"constraints",
")",
":",
"return",
"self",
".",
"_filter_elements",
"(",
"browser",
".",
"find_elements_by_android_uiautomator",
"(",
"criteria",
")",
",",
"tag",
",",
"c... | Find element matches by UI Automator. | [
"Find",
"element",
"matches",
"by",
"UI",
"Automator",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/locators/elementfinder.py#L98-L102 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/locators/elementfinder.py | ElementFinder._find_by_ios | def _find_by_ios(self, browser, criteria, tag, constraints):
"""Find element matches by UI Automation."""
return self._filter_elements(
browser.find_elements_by_ios_uiautomation(criteria),
tag, constraints) | python | def _find_by_ios(self, browser, criteria, tag, constraints):
"""Find element matches by UI Automation."""
return self._filter_elements(
browser.find_elements_by_ios_uiautomation(criteria),
tag, constraints) | [
"def",
"_find_by_ios",
"(",
"self",
",",
"browser",
",",
"criteria",
",",
"tag",
",",
"constraints",
")",
":",
"return",
"self",
".",
"_filter_elements",
"(",
"browser",
".",
"find_elements_by_ios_uiautomation",
"(",
"criteria",
")",
",",
"tag",
",",
"constrai... | Find element matches by UI Automation. | [
"Find",
"element",
"matches",
"by",
"UI",
"Automation",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/locators/elementfinder.py#L104-L108 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/locators/elementfinder.py | ElementFinder._find_by_nsp | def _find_by_nsp(self, browser, criteria, tag, constraints):
"""Find element matches by iOSNsPredicateString."""
return self._filter_elements(
browser.find_elements_by_ios_predicate(criteria),
tag, constraints) | python | def _find_by_nsp(self, browser, criteria, tag, constraints):
"""Find element matches by iOSNsPredicateString."""
return self._filter_elements(
browser.find_elements_by_ios_predicate(criteria),
tag, constraints) | [
"def",
"_find_by_nsp",
"(",
"self",
",",
"browser",
",",
"criteria",
",",
"tag",
",",
"constraints",
")",
":",
"return",
"self",
".",
"_filter_elements",
"(",
"browser",
".",
"find_elements_by_ios_predicate",
"(",
"criteria",
")",
",",
"tag",
",",
"constraints... | Find element matches by iOSNsPredicateString. | [
"Find",
"element",
"matches",
"by",
"iOSNsPredicateString",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/locators/elementfinder.py#L110-L114 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/locators/elementfinder.py | ElementFinder._find_by_chain | def _find_by_chain(self, browser, criteria, tag, constraints):
"""Find element matches by iOSChainString."""
return self._filter_elements(
browser.find_elements_by_ios_class_chain(criteria),
tag, constraints) | python | def _find_by_chain(self, browser, criteria, tag, constraints):
"""Find element matches by iOSChainString."""
return self._filter_elements(
browser.find_elements_by_ios_class_chain(criteria),
tag, constraints) | [
"def",
"_find_by_chain",
"(",
"self",
",",
"browser",
",",
"criteria",
",",
"tag",
",",
"constraints",
")",
":",
"return",
"self",
".",
"_filter_elements",
"(",
"browser",
".",
"find_elements_by_ios_class_chain",
"(",
"criteria",
")",
",",
"tag",
",",
"constra... | Find element matches by iOSChainString. | [
"Find",
"element",
"matches",
"by",
"iOSChainString",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/locators/elementfinder.py#L116-L120 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_keyevent.py | _KeyeventKeywords.press_keycode | def press_keycode(self, keycode, metastate=None):
"""Sends a press of keycode to the device.
Android only.
Possible keycodes & meta states can be found in
http://developer.android.com/reference/android/view/KeyEvent.html
Meta state describe the pressed state of key modifiers s... | python | def press_keycode(self, keycode, metastate=None):
"""Sends a press of keycode to the device.
Android only.
Possible keycodes & meta states can be found in
http://developer.android.com/reference/android/view/KeyEvent.html
Meta state describe the pressed state of key modifiers s... | [
"def",
"press_keycode",
"(",
"self",
",",
"keycode",
",",
"metastate",
"=",
"None",
")",
":",
"driver",
"=",
"self",
".",
"_current_application",
"(",
")",
"driver",
".",
"press_keycode",
"(",
"keycode",
",",
"metastate",
")"
] | Sends a press of keycode to the device.
Android only.
Possible keycodes & meta states can be found in
http://developer.android.com/reference/android/view/KeyEvent.html
Meta state describe the pressed state of key modifiers such as
Shift, Ctrl & Alt keys. The Meta State is an i... | [
"Sends",
"a",
"press",
"of",
"keycode",
"to",
"the",
"device",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_keyevent.py#L9-L33 | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_keyevent.py | _KeyeventKeywords.long_press_keycode | def long_press_keycode(self, keycode, metastate=None):
"""Sends a long press of keycode to the device.
Android only.
See `press keycode` for more details.
"""
driver = self._current_application()
driver.long_press_keycode(int(keycode), metastate) | python | def long_press_keycode(self, keycode, metastate=None):
"""Sends a long press of keycode to the device.
Android only.
See `press keycode` for more details.
"""
driver = self._current_application()
driver.long_press_keycode(int(keycode), metastate) | [
"def",
"long_press_keycode",
"(",
"self",
",",
"keycode",
",",
"metastate",
"=",
"None",
")",
":",
"driver",
"=",
"self",
".",
"_current_application",
"(",
")",
"driver",
".",
"long_press_keycode",
"(",
"int",
"(",
"keycode",
")",
",",
"metastate",
")"
] | Sends a long press of keycode to the device.
Android only.
See `press keycode` for more details. | [
"Sends",
"a",
"long",
"press",
"of",
"keycode",
"to",
"the",
"device",
"."
] | 91c808cf0602af6be8135ac529fa488fded04a85 | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_keyevent.py#L35-L43 | train |
amanusk/s-tui | s_tui/sources/rapl_read.py | rapl_read | def rapl_read():
""" Read power stats and return dictionary"""
basenames = glob.glob('/sys/class/powercap/intel-rapl:*/')
basenames = sorted(set({x for x in basenames}))
pjoin = os.path.join
ret = list()
for path in basenames:
name = None
try:
name = cat(pjoin(path, ... | python | def rapl_read():
""" Read power stats and return dictionary"""
basenames = glob.glob('/sys/class/powercap/intel-rapl:*/')
basenames = sorted(set({x for x in basenames}))
pjoin = os.path.join
ret = list()
for path in basenames:
name = None
try:
name = cat(pjoin(path, ... | [
"def",
"rapl_read",
"(",
")",
":",
"basenames",
"=",
"glob",
".",
"glob",
"(",
"'/sys/class/powercap/intel-rapl:*/'",
")",
"basenames",
"=",
"sorted",
"(",
"set",
"(",
"{",
"x",
"for",
"x",
"in",
"basenames",
"}",
")",
")",
"pjoin",
"=",
"os",
".",
"pa... | Read power stats and return dictionary | [
"Read",
"power",
"stats",
"and",
"return",
"dictionary"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sources/rapl_read.py#L35-L58 | train |
amanusk/s-tui | s_tui/sturwid/complex_bar_graph.py | ScalableBarGraph.calculate_bar_widths | def calculate_bar_widths(self, size, bardata):
"""
Return a list of bar widths, one for each bar in data.
If self.bar_width is None this implementation will stretch
the bars across the available space specified by maxcol.
"""
(maxcol, _) = size
if self.bar_width... | python | def calculate_bar_widths(self, size, bardata):
"""
Return a list of bar widths, one for each bar in data.
If self.bar_width is None this implementation will stretch
the bars across the available space specified by maxcol.
"""
(maxcol, _) = size
if self.bar_width... | [
"def",
"calculate_bar_widths",
"(",
"self",
",",
"size",
",",
"bardata",
")",
":",
"(",
"maxcol",
",",
"_",
")",
"=",
"size",
"if",
"self",
".",
"bar_width",
"is",
"not",
"None",
":",
"return",
"[",
"self",
".",
"bar_width",
"]",
"*",
"min",
"(",
"... | Return a list of bar widths, one for each bar in data.
If self.bar_width is None this implementation will stretch
the bars across the available space specified by maxcol. | [
"Return",
"a",
"list",
"of",
"bar",
"widths",
"one",
"for",
"each",
"bar",
"in",
"data",
"."
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sturwid/complex_bar_graph.py#L43-L67 | train |
amanusk/s-tui | s_tui/sturwid/complex_bar_graph.py | LabeledBarGraphVector.set_visible_graphs | def set_visible_graphs(self, visible_graph_list=None):
"""Show a column of the graph selected for display"""
if visible_graph_list is None:
visible_graph_list = self.visible_graph_list
vline = urwid.AttrWrap(urwid.SolidFill(u'|'), 'line')
graph_vector_column_list = []
... | python | def set_visible_graphs(self, visible_graph_list=None):
"""Show a column of the graph selected for display"""
if visible_graph_list is None:
visible_graph_list = self.visible_graph_list
vline = urwid.AttrWrap(urwid.SolidFill(u'|'), 'line')
graph_vector_column_list = []
... | [
"def",
"set_visible_graphs",
"(",
"self",
",",
"visible_graph_list",
"=",
"None",
")",
":",
"if",
"visible_graph_list",
"is",
"None",
":",
"visible_graph_list",
"=",
"self",
".",
"visible_graph_list",
"vline",
"=",
"urwid",
".",
"AttrWrap",
"(",
"urwid",
".",
... | Show a column of the graph selected for display | [
"Show",
"a",
"column",
"of",
"the",
"graph",
"selected",
"for",
"display"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sturwid/complex_bar_graph.py#L135-L174 | train |
amanusk/s-tui | s_tui/helper_functions.py | get_processor_name | def get_processor_name():
""" Returns the processor name in the system """
if platform.system() == "Linux":
with open("/proc/cpuinfo", "rb") as cpuinfo:
all_info = cpuinfo.readlines()
for line in all_info:
if b'model name' in line:
return re.su... | python | def get_processor_name():
""" Returns the processor name in the system """
if platform.system() == "Linux":
with open("/proc/cpuinfo", "rb") as cpuinfo:
all_info = cpuinfo.readlines()
for line in all_info:
if b'model name' in line:
return re.su... | [
"def",
"get_processor_name",
"(",
")",
":",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"\"Linux\"",
":",
"with",
"open",
"(",
"\"/proc/cpuinfo\"",
",",
"\"rb\"",
")",
"as",
"cpuinfo",
":",
"all_info",
"=",
"cpuinfo",
".",
"readlines",
"(",
")",
"fo... | Returns the processor name in the system | [
"Returns",
"the",
"processor",
"name",
"in",
"the",
"system"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/helper_functions.py#L47-L56 | train |
amanusk/s-tui | s_tui/helper_functions.py | kill_child_processes | def kill_child_processes(parent_proc):
""" Kills a process and all its children """
logging.debug("Killing stress process")
try:
for proc in parent_proc.children(recursive=True):
logging.debug('Killing %s', proc)
proc.kill()
parent_proc.kill()
except AttributeErro... | python | def kill_child_processes(parent_proc):
""" Kills a process and all its children """
logging.debug("Killing stress process")
try:
for proc in parent_proc.children(recursive=True):
logging.debug('Killing %s', proc)
proc.kill()
parent_proc.kill()
except AttributeErro... | [
"def",
"kill_child_processes",
"(",
"parent_proc",
")",
":",
"logging",
".",
"debug",
"(",
"\"Killing stress process\"",
")",
"try",
":",
"for",
"proc",
"in",
"parent_proc",
".",
"children",
"(",
"recursive",
"=",
"True",
")",
":",
"logging",
".",
"debug",
"... | Kills a process and all its children | [
"Kills",
"a",
"process",
"and",
"all",
"its",
"children"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/helper_functions.py#L59-L69 | train |
amanusk/s-tui | s_tui/helper_functions.py | output_to_csv | def output_to_csv(sources, csv_writeable_file):
"""Print statistics to csv file"""
file_exists = os.path.isfile(csv_writeable_file)
with open(csv_writeable_file, 'a') as csvfile:
csv_dict = OrderedDict()
csv_dict.update({'Time': time.strftime("%Y-%m-%d_%H:%M:%S")})
summaries = [val ... | python | def output_to_csv(sources, csv_writeable_file):
"""Print statistics to csv file"""
file_exists = os.path.isfile(csv_writeable_file)
with open(csv_writeable_file, 'a') as csvfile:
csv_dict = OrderedDict()
csv_dict.update({'Time': time.strftime("%Y-%m-%d_%H:%M:%S")})
summaries = [val ... | [
"def",
"output_to_csv",
"(",
"sources",
",",
"csv_writeable_file",
")",
":",
"file_exists",
"=",
"os",
".",
"path",
".",
"isfile",
"(",
"csv_writeable_file",
")",
"with",
"open",
"(",
"csv_writeable_file",
",",
"'a'",
")",
"as",
"csvfile",
":",
"csv_dict",
"... | Print statistics to csv file | [
"Print",
"statistics",
"to",
"csv",
"file"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/helper_functions.py#L72-L88 | train |
amanusk/s-tui | s_tui/helper_functions.py | output_to_terminal | def output_to_terminal(sources):
"""Print statistics to the terminal"""
results = OrderedDict()
for source in sources:
if source.get_is_available():
source.update()
results.update(source.get_summary())
for key, value in results.items():
sys.stdout.write(str(key) +... | python | def output_to_terminal(sources):
"""Print statistics to the terminal"""
results = OrderedDict()
for source in sources:
if source.get_is_available():
source.update()
results.update(source.get_summary())
for key, value in results.items():
sys.stdout.write(str(key) +... | [
"def",
"output_to_terminal",
"(",
"sources",
")",
":",
"results",
"=",
"OrderedDict",
"(",
")",
"for",
"source",
"in",
"sources",
":",
"if",
"source",
".",
"get_is_available",
"(",
")",
":",
"source",
".",
"update",
"(",
")",
"results",
".",
"update",
"(... | Print statistics to the terminal | [
"Print",
"statistics",
"to",
"the",
"terminal"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/helper_functions.py#L91-L101 | train |
amanusk/s-tui | s_tui/helper_functions.py | output_to_json | def output_to_json(sources):
"""Print statistics to the terminal in Json format"""
results = OrderedDict()
for source in sources:
if source.get_is_available():
source.update()
source_name = source.get_source_name()
results[source_name] = source.get_sensors_summary... | python | def output_to_json(sources):
"""Print statistics to the terminal in Json format"""
results = OrderedDict()
for source in sources:
if source.get_is_available():
source.update()
source_name = source.get_source_name()
results[source_name] = source.get_sensors_summary... | [
"def",
"output_to_json",
"(",
"sources",
")",
":",
"results",
"=",
"OrderedDict",
"(",
")",
"for",
"source",
"in",
"sources",
":",
"if",
"source",
".",
"get_is_available",
"(",
")",
":",
"source",
".",
"update",
"(",
")",
"source_name",
"=",
"source",
".... | Print statistics to the terminal in Json format | [
"Print",
"statistics",
"to",
"the",
"terminal",
"in",
"Json",
"format"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/helper_functions.py#L104-L113 | train |
amanusk/s-tui | s_tui/helper_functions.py | make_user_config_dir | def make_user_config_dir():
"""
Create the user s-tui config directory if it doesn't exist
"""
config_path = get_user_config_dir()
if not user_config_dir_exists():
try:
os.mkdir(config_path)
os.mkdir(os.path.join(config_path, 'hooks.d'))
except OSError:
... | python | def make_user_config_dir():
"""
Create the user s-tui config directory if it doesn't exist
"""
config_path = get_user_config_dir()
if not user_config_dir_exists():
try:
os.mkdir(config_path)
os.mkdir(os.path.join(config_path, 'hooks.d'))
except OSError:
... | [
"def",
"make_user_config_dir",
"(",
")",
":",
"config_path",
"=",
"get_user_config_dir",
"(",
")",
"if",
"not",
"user_config_dir_exists",
"(",
")",
":",
"try",
":",
"os",
".",
"mkdir",
"(",
"config_path",
")",
"os",
".",
"mkdir",
"(",
"os",
".",
"path",
... | Create the user s-tui config directory if it doesn't exist | [
"Create",
"the",
"user",
"s",
"-",
"tui",
"config",
"directory",
"if",
"it",
"doesn",
"t",
"exist"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/helper_functions.py#L157-L170 | train |
amanusk/s-tui | s_tui/sources/script_hook_loader.py | ScriptHookLoader.load_script | def load_script(self, source_name, timeoutMilliseconds=0):
"""
Return ScriptHook for source_name Source and with a ready timeout
of timeoutMilliseconds
"""
script_path = os.path.join(self.scripts_dir_path,
self._source_to_script_name(source_nam... | python | def load_script(self, source_name, timeoutMilliseconds=0):
"""
Return ScriptHook for source_name Source and with a ready timeout
of timeoutMilliseconds
"""
script_path = os.path.join(self.scripts_dir_path,
self._source_to_script_name(source_nam... | [
"def",
"load_script",
"(",
"self",
",",
"source_name",
",",
"timeoutMilliseconds",
"=",
"0",
")",
":",
"script_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"scripts_dir_path",
",",
"self",
".",
"_source_to_script_name",
"(",
"source_name",
"... | Return ScriptHook for source_name Source and with a ready timeout
of timeoutMilliseconds | [
"Return",
"ScriptHook",
"for",
"source_name",
"Source",
"and",
"with",
"a",
"ready",
"timeout",
"of",
"timeoutMilliseconds"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sources/script_hook_loader.py#L31-L42 | train |
amanusk/s-tui | s_tui/sources/source.py | Source.get_sensors_summary | def get_sensors_summary(self):
""" This returns a dict of sensor of the source and their values """
sub_title_list = self.get_sensor_list()
graph_vector_summary = OrderedDict()
for graph_idx, graph_data in enumerate(self.last_measurement):
val_str = str(round(graph_data, 1))... | python | def get_sensors_summary(self):
""" This returns a dict of sensor of the source and their values """
sub_title_list = self.get_sensor_list()
graph_vector_summary = OrderedDict()
for graph_idx, graph_data in enumerate(self.last_measurement):
val_str = str(round(graph_data, 1))... | [
"def",
"get_sensors_summary",
"(",
"self",
")",
":",
"sub_title_list",
"=",
"self",
".",
"get_sensor_list",
"(",
")",
"graph_vector_summary",
"=",
"OrderedDict",
"(",
")",
"for",
"graph_idx",
",",
"graph_data",
"in",
"enumerate",
"(",
"self",
".",
"last_measurem... | This returns a dict of sensor of the source and their values | [
"This",
"returns",
"a",
"dict",
"of",
"sensor",
"of",
"the",
"source",
"and",
"their",
"values"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sources/source.py#L53-L62 | train |
amanusk/s-tui | s_tui/sources/source.py | Source.get_summary | def get_summary(self):
""" Returns a dict of source name and sensors with their values """
graph_vector_summary = OrderedDict()
graph_vector_summary[self.get_source_name()] = (
'[' + self.measurement_unit + ']')
graph_vector_summary.update(self.get_sensors_summary())
... | python | def get_summary(self):
""" Returns a dict of source name and sensors with their values """
graph_vector_summary = OrderedDict()
graph_vector_summary[self.get_source_name()] = (
'[' + self.measurement_unit + ']')
graph_vector_summary.update(self.get_sensors_summary())
... | [
"def",
"get_summary",
"(",
"self",
")",
":",
"graph_vector_summary",
"=",
"OrderedDict",
"(",
")",
"graph_vector_summary",
"[",
"self",
".",
"get_source_name",
"(",
")",
"]",
"=",
"(",
"'['",
"+",
"self",
".",
"measurement_unit",
"+",
"']'",
")",
"graph_vect... | Returns a dict of source name and sensors with their values | [
"Returns",
"a",
"dict",
"of",
"source",
"name",
"and",
"sensors",
"with",
"their",
"values"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sources/source.py#L64-L70 | train |
amanusk/s-tui | s_tui/sources/source.py | Source.eval_hooks | def eval_hooks(self):
"""
Evaluate the current state of this Source and
invoke any attached hooks if they've been triggered
"""
logging.debug("Evaluating hooks")
if self.get_edge_triggered():
logging.debug("Hook triggered")
for hook in [h for h in ... | python | def eval_hooks(self):
"""
Evaluate the current state of this Source and
invoke any attached hooks if they've been triggered
"""
logging.debug("Evaluating hooks")
if self.get_edge_triggered():
logging.debug("Hook triggered")
for hook in [h for h in ... | [
"def",
"eval_hooks",
"(",
"self",
")",
":",
"logging",
".",
"debug",
"(",
"\"Evaluating hooks\"",
")",
"if",
"self",
".",
"get_edge_triggered",
"(",
")",
":",
"logging",
".",
"debug",
"(",
"\"Hook triggered\"",
")",
"for",
"hook",
"in",
"[",
"h",
"for",
... | Evaluate the current state of this Source and
invoke any attached hooks if they've been triggered | [
"Evaluate",
"the",
"current",
"state",
"of",
"this",
"Source",
"and",
"invoke",
"any",
"attached",
"hooks",
"if",
"they",
"ve",
"been",
"triggered"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sources/source.py#L109-L119 | train |
amanusk/s-tui | s_tui/sources/hook.py | Hook.invoke | def invoke(self):
"""
Run callback, optionally passing a variable number
of arguments `callback_args`
"""
# Don't sleep a hook if it has never run
if self.timeout_milliseconds > 0:
self.ready_time = (
datetime.now() +
timedelta... | python | def invoke(self):
"""
Run callback, optionally passing a variable number
of arguments `callback_args`
"""
# Don't sleep a hook if it has never run
if self.timeout_milliseconds > 0:
self.ready_time = (
datetime.now() +
timedelta... | [
"def",
"invoke",
"(",
"self",
")",
":",
"if",
"self",
".",
"timeout_milliseconds",
">",
"0",
":",
"self",
".",
"ready_time",
"=",
"(",
"datetime",
".",
"now",
"(",
")",
"+",
"timedelta",
"(",
"milliseconds",
"=",
"self",
".",
"timeout_milliseconds",
")",... | Run callback, optionally passing a variable number
of arguments `callback_args` | [
"Run",
"callback",
"optionally",
"passing",
"a",
"variable",
"number",
"of",
"arguments",
"callback_args"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sources/hook.py#L42-L54 | train |
amanusk/s-tui | s_tui/sturwid/ui_elements.py | radio_button | def radio_button(g, l, fn):
""" Inheriting radio button of urwid """
w = urwid.RadioButton(g, l, False, on_state_change=fn)
w = urwid.AttrWrap(w, 'button normal', 'button select')
return w | python | def radio_button(g, l, fn):
""" Inheriting radio button of urwid """
w = urwid.RadioButton(g, l, False, on_state_change=fn)
w = urwid.AttrWrap(w, 'button normal', 'button select')
return w | [
"def",
"radio_button",
"(",
"g",
",",
"l",
",",
"fn",
")",
":",
"w",
"=",
"urwid",
".",
"RadioButton",
"(",
"g",
",",
"l",
",",
"False",
",",
"on_state_change",
"=",
"fn",
")",
"w",
"=",
"urwid",
".",
"AttrWrap",
"(",
"w",
",",
"'button normal'",
... | Inheriting radio button of urwid | [
"Inheriting",
"radio",
"button",
"of",
"urwid"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sturwid/ui_elements.py#L95-L99 | train |
amanusk/s-tui | s_tui/s_tui.py | StressController.start_stress | def start_stress(self, stress_cmd):
""" Starts a new stress process with a given cmd """
with open(os.devnull, 'w') as dev_null:
try:
stress_proc = subprocess.Popen(stress_cmd, stdout=dev_null,
stderr=dev_null)
se... | python | def start_stress(self, stress_cmd):
""" Starts a new stress process with a given cmd """
with open(os.devnull, 'w') as dev_null:
try:
stress_proc = subprocess.Popen(stress_cmd, stdout=dev_null,
stderr=dev_null)
se... | [
"def",
"start_stress",
"(",
"self",
",",
"stress_cmd",
")",
":",
"with",
"open",
"(",
"os",
".",
"devnull",
",",
"'w'",
")",
"as",
"dev_null",
":",
"try",
":",
"stress_proc",
"=",
"subprocess",
".",
"Popen",
"(",
"stress_cmd",
",",
"stdout",
"=",
"dev_... | Starts a new stress process with a given cmd | [
"Starts",
"a",
"new",
"stress",
"process",
"with",
"a",
"given",
"cmd"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L164-L172 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphView.update_displayed_information | def update_displayed_information(self):
""" Update all the graphs that are being displayed """
for source in self.controller.sources:
source_name = source.get_source_name()
if (any(self.graphs_menu.active_sensors[source_name]) or
any(self.summary_menu.active_... | python | def update_displayed_information(self):
""" Update all the graphs that are being displayed """
for source in self.controller.sources:
source_name = source.get_source_name()
if (any(self.graphs_menu.active_sensors[source_name]) or
any(self.summary_menu.active_... | [
"def",
"update_displayed_information",
"(",
"self",
")",
":",
"for",
"source",
"in",
"self",
".",
"controller",
".",
"sources",
":",
"source_name",
"=",
"source",
".",
"get_source_name",
"(",
")",
"if",
"(",
"any",
"(",
"self",
".",
"graphs_menu",
".",
"ac... | Update all the graphs that are being displayed | [
"Update",
"all",
"the",
"graphs",
"that",
"are",
"being",
"displayed"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L235-L254 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphView.on_reset_button | def on_reset_button(self, _):
"""Reset graph data and display empty graph"""
for graph in self.visible_graphs.values():
graph.reset()
for graph in self.graphs.values():
try:
graph.source.reset()
except NotImplementedError:
pass
... | python | def on_reset_button(self, _):
"""Reset graph data and display empty graph"""
for graph in self.visible_graphs.values():
graph.reset()
for graph in self.graphs.values():
try:
graph.source.reset()
except NotImplementedError:
pass
... | [
"def",
"on_reset_button",
"(",
"self",
",",
"_",
")",
":",
"for",
"graph",
"in",
"self",
".",
"visible_graphs",
".",
"values",
"(",
")",
":",
"graph",
".",
"reset",
"(",
")",
"for",
"graph",
"in",
"self",
".",
"graphs",
".",
"values",
"(",
")",
":"... | Reset graph data and display empty graph | [
"Reset",
"graph",
"data",
"and",
"display",
"empty",
"graph"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L256-L268 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphView.on_stress_menu_open | def on_stress_menu_open(self, widget):
"""Open stress options"""
self.original_widget = urwid.Overlay(self.stress_menu.main_window,
self.original_widget,
('relative', self.left_margin),
... | python | def on_stress_menu_open(self, widget):
"""Open stress options"""
self.original_widget = urwid.Overlay(self.stress_menu.main_window,
self.original_widget,
('relative', self.left_margin),
... | [
"def",
"on_stress_menu_open",
"(",
"self",
",",
"widget",
")",
":",
"self",
".",
"original_widget",
"=",
"urwid",
".",
"Overlay",
"(",
"self",
".",
"stress_menu",
".",
"main_window",
",",
"self",
".",
"original_widget",
",",
"(",
"'relative'",
",",
"self",
... | Open stress options | [
"Open",
"stress",
"options"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L309-L316 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphView.on_help_menu_open | def on_help_menu_open(self, widget):
"""Open Help menu"""
self.original_widget = urwid.Overlay(self.help_menu.main_window,
self.original_widget,
('relative', self.left_margin),
... | python | def on_help_menu_open(self, widget):
"""Open Help menu"""
self.original_widget = urwid.Overlay(self.help_menu.main_window,
self.original_widget,
('relative', self.left_margin),
... | [
"def",
"on_help_menu_open",
"(",
"self",
",",
"widget",
")",
":",
"self",
".",
"original_widget",
"=",
"urwid",
".",
"Overlay",
"(",
"self",
".",
"help_menu",
".",
"main_window",
",",
"self",
".",
"original_widget",
",",
"(",
"'relative'",
",",
"self",
"."... | Open Help menu | [
"Open",
"Help",
"menu"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L318-L325 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphView.on_about_menu_open | def on_about_menu_open(self, widget):
"""Open About menu"""
self.original_widget = urwid.Overlay(self.about_menu.main_window,
self.original_widget,
('relative', self.left_margin),
... | python | def on_about_menu_open(self, widget):
"""Open About menu"""
self.original_widget = urwid.Overlay(self.about_menu.main_window,
self.original_widget,
('relative', self.left_margin),
... | [
"def",
"on_about_menu_open",
"(",
"self",
",",
"widget",
")",
":",
"self",
".",
"original_widget",
"=",
"urwid",
".",
"Overlay",
"(",
"self",
".",
"about_menu",
".",
"main_window",
",",
"self",
".",
"original_widget",
",",
"(",
"'relative'",
",",
"self",
"... | Open About menu | [
"Open",
"About",
"menu"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L327-L334 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphView.on_mode_button | def on_mode_button(self, my_button, state):
"""Notify the controller of a new mode setting."""
if state:
# The new mode is the label of the button
self.controller.set_mode(my_button.get_label()) | python | def on_mode_button(self, my_button, state):
"""Notify the controller of a new mode setting."""
if state:
# The new mode is the label of the button
self.controller.set_mode(my_button.get_label()) | [
"def",
"on_mode_button",
"(",
"self",
",",
"my_button",
",",
"state",
")",
":",
"if",
"state",
":",
"self",
".",
"controller",
".",
"set_mode",
"(",
"my_button",
".",
"get_label",
"(",
")",
")"
] | Notify the controller of a new mode setting. | [
"Notify",
"the",
"controller",
"of",
"a",
"new",
"mode",
"setting",
"."
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L356-L360 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphView.on_unicode_checkbox | def on_unicode_checkbox(self, w=None, state=False):
"""Enable smooth edges if utf-8 is supported"""
logging.debug("unicode State is %s", state)
# Update the controller to the state of the checkbox
self.controller.smooth_graph_mode = state
if state:
self.hline = urwid... | python | def on_unicode_checkbox(self, w=None, state=False):
"""Enable smooth edges if utf-8 is supported"""
logging.debug("unicode State is %s", state)
# Update the controller to the state of the checkbox
self.controller.smooth_graph_mode = state
if state:
self.hline = urwid... | [
"def",
"on_unicode_checkbox",
"(",
"self",
",",
"w",
"=",
"None",
",",
"state",
"=",
"False",
")",
":",
"logging",
".",
"debug",
"(",
"\"unicode State is %s\"",
",",
"state",
")",
"self",
".",
"controller",
".",
"smooth_graph_mode",
"=",
"state",
"if",
"st... | Enable smooth edges if utf-8 is supported | [
"Enable",
"smooth",
"edges",
"if",
"utf",
"-",
"8",
"is",
"supported"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L362-L377 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphView._generate_graph_controls | def _generate_graph_controls(self):
""" Display sidebar controls. i.e. buttons, and controls"""
# setup mode radio buttons
stress_modes = self.controller.stress_conroller.get_modes()
group = []
for mode in stress_modes:
self.mode_buttons.append(radio_button(group, mod... | python | def _generate_graph_controls(self):
""" Display sidebar controls. i.e. buttons, and controls"""
# setup mode radio buttons
stress_modes = self.controller.stress_conroller.get_modes()
group = []
for mode in stress_modes:
self.mode_buttons.append(radio_button(group, mod... | [
"def",
"_generate_graph_controls",
"(",
"self",
")",
":",
"stress_modes",
"=",
"self",
".",
"controller",
".",
"stress_conroller",
".",
"get_modes",
"(",
")",
"group",
"=",
"[",
"]",
"for",
"mode",
"in",
"stress_modes",
":",
"self",
".",
"mode_buttons",
".",... | Display sidebar controls. i.e. buttons, and controls | [
"Display",
"sidebar",
"controls",
".",
"i",
".",
"e",
".",
"buttons",
"and",
"controls"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L387-L452 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphView._generate_cpu_stats | def _generate_cpu_stats():
"""Read and display processor name """
cpu_name = urwid.Text("CPU Name N/A", align="center")
try:
cpu_name = urwid.Text(get_processor_name().strip(), align="center")
except OSError:
logging.info("CPU name not available")
return [... | python | def _generate_cpu_stats():
"""Read and display processor name """
cpu_name = urwid.Text("CPU Name N/A", align="center")
try:
cpu_name = urwid.Text(get_processor_name().strip(), align="center")
except OSError:
logging.info("CPU name not available")
return [... | [
"def",
"_generate_cpu_stats",
"(",
")",
":",
"cpu_name",
"=",
"urwid",
".",
"Text",
"(",
"\"CPU Name N/A\"",
",",
"align",
"=",
"\"center\"",
")",
"try",
":",
"cpu_name",
"=",
"urwid",
".",
"Text",
"(",
"get_processor_name",
"(",
")",
".",
"strip",
"(",
... | Read and display processor name | [
"Read",
"and",
"display",
"processor",
"name"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L455-L463 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphView.show_graphs | def show_graphs(self):
"""Show a pile of the graph selected for dislpay"""
elements = itertools.chain.from_iterable(
([graph]
for graph in self.visible_graphs.values()))
self.graph_place_holder.original_widget = urwid.Pile(elements) | python | def show_graphs(self):
"""Show a pile of the graph selected for dislpay"""
elements = itertools.chain.from_iterable(
([graph]
for graph in self.visible_graphs.values()))
self.graph_place_holder.original_widget = urwid.Pile(elements) | [
"def",
"show_graphs",
"(",
"self",
")",
":",
"elements",
"=",
"itertools",
".",
"chain",
".",
"from_iterable",
"(",
"(",
"[",
"graph",
"]",
"for",
"graph",
"in",
"self",
".",
"visible_graphs",
".",
"values",
"(",
")",
")",
")",
"self",
".",
"graph_plac... | Show a pile of the graph selected for dislpay | [
"Show",
"a",
"pile",
"of",
"the",
"graph",
"selected",
"for",
"dislpay"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L475-L480 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphController._load_config | def _load_config(self, t_thresh):
"""
Uses configurations defined by user to configure sources for display.
This should be the only place where sources are initiated
This returns a list of sources after configurations are applied
"""
# Load and configure user config dir ... | python | def _load_config(self, t_thresh):
"""
Uses configurations defined by user to configure sources for display.
This should be the only place where sources are initiated
This returns a list of sources after configurations are applied
"""
# Load and configure user config dir ... | [
"def",
"_load_config",
"(",
"self",
",",
"t_thresh",
")",
":",
"if",
"not",
"user_config_dir_exists",
"(",
")",
":",
"user_config_dir",
"=",
"make_user_config_dir",
"(",
")",
"else",
":",
"user_config_dir",
"=",
"get_user_config_dir",
"(",
")",
"if",
"user_confi... | Uses configurations defined by user to configure sources for display.
This should be the only place where sources are initiated
This returns a list of sources after configurations are applied | [
"Uses",
"configurations",
"defined",
"by",
"user",
"to",
"configure",
"sources",
"for",
"display",
".",
"This",
"should",
"be",
"the",
"only",
"place",
"where",
"sources",
"are",
"initiated"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L564-L648 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphController._config_stress | def _config_stress(self):
""" Configures the possible stress processes and modes """
# Configure stress_process
self.stress_exe = None
stress_installed = False
self.stress_exe = which('stress')
if self.stress_exe:
stress_installed = True
else:
... | python | def _config_stress(self):
""" Configures the possible stress processes and modes """
# Configure stress_process
self.stress_exe = None
stress_installed = False
self.stress_exe = which('stress')
if self.stress_exe:
stress_installed = True
else:
... | [
"def",
"_config_stress",
"(",
"self",
")",
":",
"self",
".",
"stress_exe",
"=",
"None",
"stress_installed",
"=",
"False",
"self",
".",
"stress_exe",
"=",
"which",
"(",
"'stress'",
")",
"if",
"self",
".",
"stress_exe",
":",
"stress_installed",
"=",
"True",
... | Configures the possible stress processes and modes | [
"Configures",
"the",
"possible",
"stress",
"processes",
"and",
"modes"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L650-L675 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphController.main | def main(self):
""" Starts the main loop and graph animation """
loop = MainLoop(self.view, DEFAULT_PALETTE,
handle_mouse=self.handle_mouse)
self.view.show_graphs()
self.animate_graph(loop)
try:
loop.run()
except (ZeroDivisionError) as ... | python | def main(self):
""" Starts the main loop and graph animation """
loop = MainLoop(self.view, DEFAULT_PALETTE,
handle_mouse=self.handle_mouse)
self.view.show_graphs()
self.animate_graph(loop)
try:
loop.run()
except (ZeroDivisionError) as ... | [
"def",
"main",
"(",
"self",
")",
":",
"loop",
"=",
"MainLoop",
"(",
"self",
".",
"view",
",",
"DEFAULT_PALETTE",
",",
"handle_mouse",
"=",
"self",
".",
"handle_mouse",
")",
"self",
".",
"view",
".",
"show_graphs",
"(",
")",
"self",
".",
"animate_graph",
... | Starts the main loop and graph animation | [
"Starts",
"the",
"main",
"loop",
"and",
"graph",
"animation"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L724-L749 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphController.update_stress_mode | def update_stress_mode(self):
""" Updates stress mode according to radio buttons state """
self.stress_conroller.kill_stress_process()
# Start a new clock upon starting a new stress test
self.view.clock_view.set_text(ZERO_TIME)
self.stress_start_time = timeit.default_timer()
... | python | def update_stress_mode(self):
""" Updates stress mode according to radio buttons state """
self.stress_conroller.kill_stress_process()
# Start a new clock upon starting a new stress test
self.view.clock_view.set_text(ZERO_TIME)
self.stress_start_time = timeit.default_timer()
... | [
"def",
"update_stress_mode",
"(",
"self",
")",
":",
"self",
".",
"stress_conroller",
".",
"kill_stress_process",
"(",
")",
"self",
".",
"view",
".",
"clock_view",
".",
"set_text",
"(",
"ZERO_TIME",
")",
"self",
".",
"stress_start_time",
"=",
"timeit",
".",
"... | Updates stress mode according to radio buttons state | [
"Updates",
"stress",
"mode",
"according",
"to",
"radio",
"buttons",
"state"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L751-L766 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphController.save_settings | def save_settings(self):
""" Save the current configuration to a user config file """
def _save_displayed_setting(conf, submenu):
for source, visible_sensors in \
self.view.graphs_menu.active_sensors.items():
section = source + "," + submenu
... | python | def save_settings(self):
""" Save the current configuration to a user config file """
def _save_displayed_setting(conf, submenu):
for source, visible_sensors in \
self.view.graphs_menu.active_sensors.items():
section = source + "," + submenu
... | [
"def",
"save_settings",
"(",
"self",
")",
":",
"def",
"_save_displayed_setting",
"(",
"conf",
",",
"submenu",
")",
":",
"for",
"source",
",",
"visible_sensors",
"in",
"self",
".",
"view",
".",
"graphs_menu",
".",
"active_sensors",
".",
"items",
"(",
")",
"... | Save the current configuration to a user config file | [
"Save",
"the",
"current",
"configuration",
"to",
"a",
"user",
"config",
"file"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L768-L810 | train |
amanusk/s-tui | s_tui/s_tui.py | GraphController.animate_graph | def animate_graph(self, loop, user_data=None):
"""
Update the graph and schedule the next update
This is where the magic happens
"""
self.view.update_displayed_information()
# Save to CSV if configured
if self.save_csv or self.csv_file is not None:
ou... | python | def animate_graph(self, loop, user_data=None):
"""
Update the graph and schedule the next update
This is where the magic happens
"""
self.view.update_displayed_information()
# Save to CSV if configured
if self.save_csv or self.csv_file is not None:
ou... | [
"def",
"animate_graph",
"(",
"self",
",",
"loop",
",",
"user_data",
"=",
"None",
")",
":",
"self",
".",
"view",
".",
"update_displayed_information",
"(",
")",
"if",
"self",
".",
"save_csv",
"or",
"self",
".",
"csv_file",
"is",
"not",
"None",
":",
"output... | Update the graph and schedule the next update
This is where the magic happens | [
"Update",
"the",
"graph",
"and",
"schedule",
"the",
"next",
"update",
"This",
"is",
"where",
"the",
"magic",
"happens"
] | 5e89d15081e716024db28ec03b1e3a7710330951 | https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L817-L836 | train |
liftoff/pyminifier | pyminifier/obfuscate.py | obfuscation_machine | def obfuscation_machine(use_unicode=False, identifier_length=1):
"""
A generator that returns short sequential combinations of lower and
upper-case letters that will never repeat.
If *use_unicode* is ``True``, use nonlatin cryllic, arabic, and syriac
letters instead of the usual ABCs.
The *ide... | python | def obfuscation_machine(use_unicode=False, identifier_length=1):
"""
A generator that returns short sequential combinations of lower and
upper-case letters that will never repeat.
If *use_unicode* is ``True``, use nonlatin cryllic, arabic, and syriac
letters instead of the usual ABCs.
The *ide... | [
"def",
"obfuscation_machine",
"(",
"use_unicode",
"=",
"False",
",",
"identifier_length",
"=",
"1",
")",
":",
"lowercase",
"=",
"list",
"(",
"map",
"(",
"chr",
",",
"range",
"(",
"97",
",",
"123",
")",
")",
")",
"uppercase",
"=",
"list",
"(",
"map",
... | A generator that returns short sequential combinations of lower and
upper-case letters that will never repeat.
If *use_unicode* is ``True``, use nonlatin cryllic, arabic, and syriac
letters instead of the usual ABCs.
The *identifier_length* represents the length of the string to return using
the a... | [
"A",
"generator",
"that",
"returns",
"short",
"sequential",
"combinations",
"of",
"lower",
"and",
"upper",
"-",
"case",
"letters",
"that",
"will",
"never",
"repeat",
"."
] | 087ea7b0c8c964f1f907c3f350f5ce281798db86 | https://github.com/liftoff/pyminifier/blob/087ea7b0c8c964f1f907c3f350f5ce281798db86/pyminifier/obfuscate.py#L33-L77 | train |
liftoff/pyminifier | pyminifier/obfuscate.py | apply_obfuscation | def apply_obfuscation(source):
"""
Returns 'source' all obfuscated.
"""
global keyword_args
global imported_modules
tokens = token_utils.listified_tokenizer(source)
keyword_args = analyze.enumerate_keyword_args(tokens)
imported_modules = analyze.enumerate_imports(tokens)
variables = ... | python | def apply_obfuscation(source):
"""
Returns 'source' all obfuscated.
"""
global keyword_args
global imported_modules
tokens = token_utils.listified_tokenizer(source)
keyword_args = analyze.enumerate_keyword_args(tokens)
imported_modules = analyze.enumerate_imports(tokens)
variables = ... | [
"def",
"apply_obfuscation",
"(",
"source",
")",
":",
"global",
"keyword_args",
"global",
"imported_modules",
"tokens",
"=",
"token_utils",
".",
"listified_tokenizer",
"(",
"source",
")",
"keyword_args",
"=",
"analyze",
".",
"enumerate_keyword_args",
"(",
"tokens",
"... | Returns 'source' all obfuscated. | [
"Returns",
"source",
"all",
"obfuscated",
"."
] | 087ea7b0c8c964f1f907c3f350f5ce281798db86 | https://github.com/liftoff/pyminifier/blob/087ea7b0c8c964f1f907c3f350f5ce281798db86/pyminifier/obfuscate.py#L79-L99 | train |
liftoff/pyminifier | pyminifier/compression.py | bz2_pack | def bz2_pack(source):
"""
Returns 'source' as a bzip2-compressed, self-extracting python script.
.. note::
This method uses up more space than the zip_pack method but it has the
advantage in that the resulting .py file can still be imported into a
python program.
"""
import... | python | def bz2_pack(source):
"""
Returns 'source' as a bzip2-compressed, self-extracting python script.
.. note::
This method uses up more space than the zip_pack method but it has the
advantage in that the resulting .py file can still be imported into a
python program.
"""
import... | [
"def",
"bz2_pack",
"(",
"source",
")",
":",
"import",
"bz2",
",",
"base64",
"out",
"=",
"\"\"",
"first_line",
"=",
"source",
".",
"split",
"(",
"'\\n'",
")",
"[",
"0",
"]",
"if",
"analyze",
".",
"shebang",
".",
"match",
"(",
"first_line",
")",
":",
... | Returns 'source' as a bzip2-compressed, self-extracting python script.
.. note::
This method uses up more space than the zip_pack method but it has the
advantage in that the resulting .py file can still be imported into a
python program. | [
"Returns",
"source",
"as",
"a",
"bzip2",
"-",
"compressed",
"self",
"-",
"extracting",
"python",
"script",
"."
] | 087ea7b0c8c964f1f907c3f350f5ce281798db86 | https://github.com/liftoff/pyminifier/blob/087ea7b0c8c964f1f907c3f350f5ce281798db86/pyminifier/compression.py#L51-L76 | train |
peopledoc/workalendar | workalendar/registry.py | iso_register | def iso_register(iso_code):
"""
Registers Calendar class as country or region in IsoRegistry.
Registered country must set class variables ``iso`` using this decorator.
>>> from workalendar.core import Calendar
>>> @iso_register('MC-MR')
>>> class MyRegion(Calendar):
>>> 'My Region'
... | python | def iso_register(iso_code):
"""
Registers Calendar class as country or region in IsoRegistry.
Registered country must set class variables ``iso`` using this decorator.
>>> from workalendar.core import Calendar
>>> @iso_register('MC-MR')
>>> class MyRegion(Calendar):
>>> 'My Region'
... | [
"def",
"iso_register",
"(",
"iso_code",
")",
":",
"def",
"wrapper",
"(",
"cls",
")",
":",
"registry",
".",
"register",
"(",
"iso_code",
",",
"cls",
")",
"return",
"cls",
"return",
"wrapper"
] | Registers Calendar class as country or region in IsoRegistry.
Registered country must set class variables ``iso`` using this decorator.
>>> from workalendar.core import Calendar
>>> @iso_register('MC-MR')
>>> class MyRegion(Calendar):
>>> 'My Region'
Region calendar is then retrievable fr... | [
"Registers",
"Calendar",
"class",
"as",
"country",
"or",
"region",
"in",
"IsoRegistry",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/registry.py#L94-L112 | train |
peopledoc/workalendar | workalendar/registry.py | IsoRegistry.get_calendar_class | def get_calendar_class(self, iso_code):
"""
Retrieves calendar class associated with given ``iso_code``.
If calendar of subdivision is not registered
(for subdivision like ISO codes, e.g. GB-ENG)
returns calendar of containing region
(e.g. United Kingdom for ISO code GB)... | python | def get_calendar_class(self, iso_code):
"""
Retrieves calendar class associated with given ``iso_code``.
If calendar of subdivision is not registered
(for subdivision like ISO codes, e.g. GB-ENG)
returns calendar of containing region
(e.g. United Kingdom for ISO code GB)... | [
"def",
"get_calendar_class",
"(",
"self",
",",
"iso_code",
")",
":",
"code_elements",
",",
"is_subregion",
"=",
"self",
".",
"_code_elements",
"(",
"iso_code",
")",
"if",
"is_subregion",
"and",
"iso_code",
"not",
"in",
"self",
".",
"region_registry",
":",
"cod... | Retrieves calendar class associated with given ``iso_code``.
If calendar of subdivision is not registered
(for subdivision like ISO codes, e.g. GB-ENG)
returns calendar of containing region
(e.g. United Kingdom for ISO code GB) if it's available.
:rtype: Calendar | [
"Retrieves",
"calendar",
"class",
"associated",
"with",
"given",
"iso_code",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/registry.py#L29-L47 | train |
peopledoc/workalendar | workalendar/registry.py | IsoRegistry.get_subregions | def get_subregions(self, iso_code):
"""
Returns subregion calendar classes for given region iso_code.
>>> registry = IsoRegistry()
>>> # assuming calendars registered are: DE, DE-HH, DE-BE
>>> registry.get_subregions('DE')
{'DE-HH': <class 'workalendar.europe.germany.Ham... | python | def get_subregions(self, iso_code):
"""
Returns subregion calendar classes for given region iso_code.
>>> registry = IsoRegistry()
>>> # assuming calendars registered are: DE, DE-HH, DE-BE
>>> registry.get_subregions('DE')
{'DE-HH': <class 'workalendar.europe.germany.Ham... | [
"def",
"get_subregions",
"(",
"self",
",",
"iso_code",
")",
":",
"items",
"=",
"OrderedDict",
"(",
")",
"for",
"key",
",",
"value",
"in",
"self",
".",
"region_registry",
".",
"items",
"(",
")",
":",
"code_elements",
",",
"is_subregion",
"=",
"self",
".",... | Returns subregion calendar classes for given region iso_code.
>>> registry = IsoRegistry()
>>> # assuming calendars registered are: DE, DE-HH, DE-BE
>>> registry.get_subregions('DE')
{'DE-HH': <class 'workalendar.europe.germany.Hamburg'>,
'DE-BE': <class 'workalendar.europe.germ... | [
"Returns",
"subregion",
"calendar",
"classes",
"for",
"given",
"region",
"iso_code",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/registry.py#L49-L67 | train |
peopledoc/workalendar | workalendar/registry.py | IsoRegistry.items | def items(self, region_codes, include_subregions=False):
"""
Returns calendar classes for regions
:param region_codes list of ISO codes for selected regions
:param include_subregions boolean if subregions
of selected regions should be included in result
:rtype dict
... | python | def items(self, region_codes, include_subregions=False):
"""
Returns calendar classes for regions
:param region_codes list of ISO codes for selected regions
:param include_subregions boolean if subregions
of selected regions should be included in result
:rtype dict
... | [
"def",
"items",
"(",
"self",
",",
"region_codes",
",",
"include_subregions",
"=",
"False",
")",
":",
"items",
"=",
"OrderedDict",
"(",
")",
"for",
"code",
"in",
"region_codes",
":",
"try",
":",
"items",
"[",
"code",
"]",
"=",
"self",
".",
"region_registr... | Returns calendar classes for regions
:param region_codes list of ISO codes for selected regions
:param include_subregions boolean if subregions
of selected regions should be included in result
:rtype dict
:return dict where keys are ISO codes strings
and values are calen... | [
"Returns",
"calendar",
"classes",
"for",
"regions"
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/registry.py#L69-L88 | train |
peopledoc/workalendar | workalendar/core.py | cleaned_date | def cleaned_date(day, keep_datetime=False):
"""
Return a "clean" date type.
* keep a `date` unchanged
* convert a datetime into a date,
* convert any "duck date" type into a date using its `date()` method.
"""
if not isinstance(day, (date, datetime)):
raise UnsupportedDateType(
... | python | def cleaned_date(day, keep_datetime=False):
"""
Return a "clean" date type.
* keep a `date` unchanged
* convert a datetime into a date,
* convert any "duck date" type into a date using its `date()` method.
"""
if not isinstance(day, (date, datetime)):
raise UnsupportedDateType(
... | [
"def",
"cleaned_date",
"(",
"day",
",",
"keep_datetime",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"day",
",",
"(",
"date",
",",
"datetime",
")",
")",
":",
"raise",
"UnsupportedDateType",
"(",
"\"`{}` is of unsupported type ({})\"",
".",
"format"... | Return a "clean" date type.
* keep a `date` unchanged
* convert a datetime into a date,
* convert any "duck date" type into a date using its `date()` method. | [
"Return",
"a",
"clean",
"date",
"type",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L32-L46 | train |
peopledoc/workalendar | workalendar/core.py | Calendar.get_fixed_holidays | def get_fixed_holidays(self, year):
"""Return the fixed days according to the FIXED_HOLIDAYS class property
"""
days = []
for month, day, label in self.FIXED_HOLIDAYS:
days.append((date(year, month, day), label))
return days | python | def get_fixed_holidays(self, year):
"""Return the fixed days according to the FIXED_HOLIDAYS class property
"""
days = []
for month, day, label in self.FIXED_HOLIDAYS:
days.append((date(year, month, day), label))
return days | [
"def",
"get_fixed_holidays",
"(",
"self",
",",
"year",
")",
":",
"days",
"=",
"[",
"]",
"for",
"month",
",",
"day",
",",
"label",
"in",
"self",
".",
"FIXED_HOLIDAYS",
":",
"days",
".",
"append",
"(",
"(",
"date",
"(",
"year",
",",
"month",
",",
"da... | Return the fixed days according to the FIXED_HOLIDAYS class property | [
"Return",
"the",
"fixed",
"days",
"according",
"to",
"the",
"FIXED_HOLIDAYS",
"class",
"property"
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L66-L72 | train |
peopledoc/workalendar | workalendar/core.py | Calendar.get_holiday_label | def get_holiday_label(self, day):
"""Return the label of the holiday, if the date is a holiday"""
day = cleaned_date(day)
return {day: label for day, label in self.holidays(day.year)
}.get(day) | python | def get_holiday_label(self, day):
"""Return the label of the holiday, if the date is a holiday"""
day = cleaned_date(day)
return {day: label for day, label in self.holidays(day.year)
}.get(day) | [
"def",
"get_holiday_label",
"(",
"self",
",",
"day",
")",
":",
"day",
"=",
"cleaned_date",
"(",
"day",
")",
"return",
"{",
"day",
":",
"label",
"for",
"day",
",",
"label",
"in",
"self",
".",
"holidays",
"(",
"day",
".",
"year",
")",
"}",
".",
"get"... | Return the label of the holiday, if the date is a holiday | [
"Return",
"the",
"label",
"of",
"the",
"holiday",
"if",
"the",
"date",
"is",
"a",
"holiday"
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L99-L103 | train |
peopledoc/workalendar | workalendar/core.py | Calendar.is_working_day | def is_working_day(self, day,
extra_working_days=None, extra_holidays=None):
"""Return True if it's a working day.
In addition to the regular holidays, you can add exceptions.
By providing ``extra_working_days``, you'll state that these dates
**are** working days.... | python | def is_working_day(self, day,
extra_working_days=None, extra_holidays=None):
"""Return True if it's a working day.
In addition to the regular holidays, you can add exceptions.
By providing ``extra_working_days``, you'll state that these dates
**are** working days.... | [
"def",
"is_working_day",
"(",
"self",
",",
"day",
",",
"extra_working_days",
"=",
"None",
",",
"extra_holidays",
"=",
"None",
")",
":",
"day",
"=",
"cleaned_date",
"(",
"day",
")",
"if",
"extra_working_days",
":",
"extra_working_days",
"=",
"tuple",
"(",
"ma... | Return True if it's a working day.
In addition to the regular holidays, you can add exceptions.
By providing ``extra_working_days``, you'll state that these dates
**are** working days.
By providing ``extra_holidays``, you'll state that these dates **are**
holidays, even if not ... | [
"Return",
"True",
"if",
"it",
"s",
"a",
"working",
"day",
".",
"In",
"addition",
"to",
"the",
"regular",
"holidays",
"you",
"can",
"add",
"exceptions",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L122-L151 | train |
peopledoc/workalendar | workalendar/core.py | Calendar.is_holiday | def is_holiday(self, day, extra_holidays=None):
"""Return True if it's an holiday.
In addition to the regular holidays, you can add exceptions.
By providing ``extra_holidays``, you'll state that these dates **are**
holidays, even if not in the regular calendar holidays (or weekends).
... | python | def is_holiday(self, day, extra_holidays=None):
"""Return True if it's an holiday.
In addition to the regular holidays, you can add exceptions.
By providing ``extra_holidays``, you'll state that these dates **are**
holidays, even if not in the regular calendar holidays (or weekends).
... | [
"def",
"is_holiday",
"(",
"self",
",",
"day",
",",
"extra_holidays",
"=",
"None",
")",
":",
"day",
"=",
"cleaned_date",
"(",
"day",
")",
"if",
"extra_holidays",
":",
"extra_holidays",
"=",
"tuple",
"(",
"map",
"(",
"cleaned_date",
",",
"extra_holidays",
")... | Return True if it's an holiday.
In addition to the regular holidays, you can add exceptions.
By providing ``extra_holidays``, you'll state that these dates **are**
holidays, even if not in the regular calendar holidays (or weekends). | [
"Return",
"True",
"if",
"it",
"s",
"an",
"holiday",
".",
"In",
"addition",
"to",
"the",
"regular",
"holidays",
"you",
"can",
"add",
"exceptions",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L153-L169 | train |
peopledoc/workalendar | workalendar/core.py | Calendar.add_working_days | def add_working_days(self, day, delta,
extra_working_days=None, extra_holidays=None,
keep_datetime=False):
"""Add `delta` working days to the date.
You can provide either a date or a datetime to this function that will
output a ``date`` result. ... | python | def add_working_days(self, day, delta,
extra_working_days=None, extra_holidays=None,
keep_datetime=False):
"""Add `delta` working days to the date.
You can provide either a date or a datetime to this function that will
output a ``date`` result. ... | [
"def",
"add_working_days",
"(",
"self",
",",
"day",
",",
"delta",
",",
"extra_working_days",
"=",
"None",
",",
"extra_holidays",
"=",
"None",
",",
"keep_datetime",
"=",
"False",
")",
":",
"day",
"=",
"cleaned_date",
"(",
"day",
",",
"keep_datetime",
")",
"... | Add `delta` working days to the date.
You can provide either a date or a datetime to this function that will
output a ``date`` result. You can alter this behaviour using the
``keep_datetime`` option set to ``True``.
the ``delta`` parameter might be positive or negative. If it's
... | [
"Add",
"delta",
"working",
"days",
"to",
"the",
"date",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L171-L213 | train |
peopledoc/workalendar | workalendar/core.py | Calendar.sub_working_days | def sub_working_days(self, day, delta,
extra_working_days=None, extra_holidays=None,
keep_datetime=False):
"""
Substract `delta` working days to the date.
This method is a shortcut / helper. Users may want to use either::
cal.add_wo... | python | def sub_working_days(self, day, delta,
extra_working_days=None, extra_holidays=None,
keep_datetime=False):
"""
Substract `delta` working days to the date.
This method is a shortcut / helper. Users may want to use either::
cal.add_wo... | [
"def",
"sub_working_days",
"(",
"self",
",",
"day",
",",
"delta",
",",
"extra_working_days",
"=",
"None",
",",
"extra_holidays",
"=",
"None",
",",
"keep_datetime",
"=",
"False",
")",
":",
"delta",
"=",
"abs",
"(",
"delta",
")",
"return",
"self",
".",
"ad... | Substract `delta` working days to the date.
This method is a shortcut / helper. Users may want to use either::
cal.add_working_days(my_date, -7)
cal.sub_working_days(my_date, 7)
The other parameters are to be used exactly as in the
``add_working_days`` method.
... | [
"Substract",
"delta",
"working",
"days",
"to",
"the",
"date",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L215-L244 | train |
peopledoc/workalendar | workalendar/core.py | Calendar.find_following_working_day | def find_following_working_day(self, day):
"""Looks for the following working day, if not already a working day.
**WARNING**: this function doesn't take into account the calendar
holidays, only the days of the week and the weekend days parameters.
"""
day = cleaned_date(day)
... | python | def find_following_working_day(self, day):
"""Looks for the following working day, if not already a working day.
**WARNING**: this function doesn't take into account the calendar
holidays, only the days of the week and the weekend days parameters.
"""
day = cleaned_date(day)
... | [
"def",
"find_following_working_day",
"(",
"self",
",",
"day",
")",
":",
"day",
"=",
"cleaned_date",
"(",
"day",
")",
"while",
"day",
".",
"weekday",
"(",
")",
"in",
"self",
".",
"get_weekend_days",
"(",
")",
":",
"day",
"=",
"day",
"+",
"timedelta",
"(... | Looks for the following working day, if not already a working day.
**WARNING**: this function doesn't take into account the calendar
holidays, only the days of the week and the weekend days parameters. | [
"Looks",
"for",
"the",
"following",
"working",
"day",
"if",
"not",
"already",
"a",
"working",
"day",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L246-L256 | train |
peopledoc/workalendar | workalendar/core.py | Calendar.get_first_weekday_after | def get_first_weekday_after(day, weekday):
"""Get the first weekday after a given day. If the day is the same
weekday, the same day will be returned.
>>> # the first monday after Apr 1 2015
>>> Calendar.get_first_weekday_after(date(2015, 4, 1), MON)
datetime.date(2015, 4, 6)
... | python | def get_first_weekday_after(day, weekday):
"""Get the first weekday after a given day. If the day is the same
weekday, the same day will be returned.
>>> # the first monday after Apr 1 2015
>>> Calendar.get_first_weekday_after(date(2015, 4, 1), MON)
datetime.date(2015, 4, 6)
... | [
"def",
"get_first_weekday_after",
"(",
"day",
",",
"weekday",
")",
":",
"day_delta",
"=",
"(",
"weekday",
"-",
"day",
".",
"weekday",
"(",
")",
")",
"%",
"7",
"day",
"=",
"day",
"+",
"timedelta",
"(",
"days",
"=",
"day_delta",
")",
"return",
"day"
] | Get the first weekday after a given day. If the day is the same
weekday, the same day will be returned.
>>> # the first monday after Apr 1 2015
>>> Calendar.get_first_weekday_after(date(2015, 4, 1), MON)
datetime.date(2015, 4, 6)
>>> # the first tuesday after Apr 14 2015
... | [
"Get",
"the",
"first",
"weekday",
"after",
"a",
"given",
"day",
".",
"If",
"the",
"day",
"is",
"the",
"same",
"weekday",
"the",
"same",
"day",
"will",
"be",
"returned",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L304-L318 | train |
peopledoc/workalendar | workalendar/core.py | Calendar.get_working_days_delta | def get_working_days_delta(self, start, end):
"""
Return the number of working day between two given dates.
The order of the dates provided doesn't matter.
In the following example, there are 5 days, because of the week-end:
>>> cal = WesternCalendar() # does not include easte... | python | def get_working_days_delta(self, start, end):
"""
Return the number of working day between two given dates.
The order of the dates provided doesn't matter.
In the following example, there are 5 days, because of the week-end:
>>> cal = WesternCalendar() # does not include easte... | [
"def",
"get_working_days_delta",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"start",
"=",
"cleaned_date",
"(",
"start",
")",
"end",
"=",
"cleaned_date",
"(",
"end",
")",
"if",
"start",
"==",
"end",
":",
"return",
"0",
"if",
"start",
">",
"end",
... | Return the number of working day between two given dates.
The order of the dates provided doesn't matter.
In the following example, there are 5 days, because of the week-end:
>>> cal = WesternCalendar() # does not include easter monday
>>> day1 = date(2018, 3, 29)
>>> day2 = d... | [
"Return",
"the",
"number",
"of",
"working",
"day",
"between",
"two",
"given",
"dates",
".",
"The",
"order",
"of",
"the",
"dates",
"provided",
"doesn",
"t",
"matter",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L320-L356 | train |
peopledoc/workalendar | workalendar/core.py | ChristianMixin.get_holy_thursday | def get_holy_thursday(self, year):
"Return the date of the last thursday before easter"
sunday = self.get_easter_sunday(year)
return sunday - timedelta(days=3) | python | def get_holy_thursday(self, year):
"Return the date of the last thursday before easter"
sunday = self.get_easter_sunday(year)
return sunday - timedelta(days=3) | [
"def",
"get_holy_thursday",
"(",
"self",
",",
"year",
")",
":",
"\"Return the date of the last thursday before easter\"",
"sunday",
"=",
"self",
".",
"get_easter_sunday",
"(",
"year",
")",
"return",
"sunday",
"-",
"timedelta",
"(",
"days",
"=",
"3",
")"
] | Return the date of the last thursday before easter | [
"Return",
"the",
"date",
"of",
"the",
"last",
"thursday",
"before",
"easter"
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L397-L400 | train |
peopledoc/workalendar | workalendar/core.py | ChristianMixin.get_good_friday | def get_good_friday(self, year):
"Return the date of the last friday before easter"
sunday = self.get_easter_sunday(year)
return sunday - timedelta(days=2) | python | def get_good_friday(self, year):
"Return the date of the last friday before easter"
sunday = self.get_easter_sunday(year)
return sunday - timedelta(days=2) | [
"def",
"get_good_friday",
"(",
"self",
",",
"year",
")",
":",
"\"Return the date of the last friday before easter\"",
"sunday",
"=",
"self",
".",
"get_easter_sunday",
"(",
"year",
")",
"return",
"sunday",
"-",
"timedelta",
"(",
"days",
"=",
"2",
")"
] | Return the date of the last friday before easter | [
"Return",
"the",
"date",
"of",
"the",
"last",
"friday",
"before",
"easter"
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L402-L405 | train |
peopledoc/workalendar | workalendar/core.py | ChristianMixin.get_clean_monday | def get_clean_monday(self, year):
"Return the clean monday date"
sunday = self.get_easter_sunday(year)
return sunday - timedelta(days=48) | python | def get_clean_monday(self, year):
"Return the clean monday date"
sunday = self.get_easter_sunday(year)
return sunday - timedelta(days=48) | [
"def",
"get_clean_monday",
"(",
"self",
",",
"year",
")",
":",
"\"Return the clean monday date\"",
"sunday",
"=",
"self",
".",
"get_easter_sunday",
"(",
"year",
")",
"return",
"sunday",
"-",
"timedelta",
"(",
"days",
"=",
"48",
")"
] | Return the clean monday date | [
"Return",
"the",
"clean",
"monday",
"date"
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L407-L410 | train |
peopledoc/workalendar | workalendar/core.py | ChristianMixin.get_easter_saturday | def get_easter_saturday(self, year):
"Return the Easter Saturday date"
sunday = self.get_easter_sunday(year)
return sunday - timedelta(days=1) | python | def get_easter_saturday(self, year):
"Return the Easter Saturday date"
sunday = self.get_easter_sunday(year)
return sunday - timedelta(days=1) | [
"def",
"get_easter_saturday",
"(",
"self",
",",
"year",
")",
":",
"\"Return the Easter Saturday date\"",
"sunday",
"=",
"self",
".",
"get_easter_sunday",
"(",
"year",
")",
"return",
"sunday",
"-",
"timedelta",
"(",
"days",
"=",
"1",
")"
] | Return the Easter Saturday date | [
"Return",
"the",
"Easter",
"Saturday",
"date"
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L412-L415 | train |
peopledoc/workalendar | workalendar/core.py | ChristianMixin.get_easter_monday | def get_easter_monday(self, year):
"Return the date of the monday after easter"
sunday = self.get_easter_sunday(year)
return sunday + timedelta(days=1) | python | def get_easter_monday(self, year):
"Return the date of the monday after easter"
sunday = self.get_easter_sunday(year)
return sunday + timedelta(days=1) | [
"def",
"get_easter_monday",
"(",
"self",
",",
"year",
")",
":",
"\"Return the date of the monday after easter\"",
"sunday",
"=",
"self",
".",
"get_easter_sunday",
"(",
"year",
")",
"return",
"sunday",
"+",
"timedelta",
"(",
"days",
"=",
"1",
")"
] | Return the date of the monday after easter | [
"Return",
"the",
"date",
"of",
"the",
"monday",
"after",
"easter"
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L421-L424 | train |
peopledoc/workalendar | workalendar/core.py | ChristianMixin.get_variable_days | def get_variable_days(self, year): # noqa
"Return the christian holidays list according to the mixin"
days = super(ChristianMixin, self).get_variable_days(year)
if self.include_epiphany:
days.append((date(year, 1, 6), "Epiphany"))
if self.include_clean_monday:
da... | python | def get_variable_days(self, year): # noqa
"Return the christian holidays list according to the mixin"
days = super(ChristianMixin, self).get_variable_days(year)
if self.include_epiphany:
days.append((date(year, 1, 6), "Epiphany"))
if self.include_clean_monday:
da... | [
"def",
"get_variable_days",
"(",
"self",
",",
"year",
")",
":",
"\"Return the christian holidays list according to the mixin\"",
"days",
"=",
"super",
"(",
"ChristianMixin",
",",
"self",
")",
".",
"get_variable_days",
"(",
"year",
")",
"if",
"self",
".",
"include_ep... | Return the christian holidays list according to the mixin | [
"Return",
"the",
"christian",
"holidays",
"list",
"according",
"to",
"the",
"mixin"
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L458-L506 | train |
peopledoc/workalendar | workalendar/core.py | ChineseNewYearCalendar.get_chinese_new_year | def get_chinese_new_year(self, year):
"""
Compute Chinese New Year days. To return a list of holidays.
By default, it'll at least return the Chinese New Year holidays chosen
using the following options:
* ``include_chinese_new_year_eve``
* ``include_chinese_new_year`` (... | python | def get_chinese_new_year(self, year):
"""
Compute Chinese New Year days. To return a list of holidays.
By default, it'll at least return the Chinese New Year holidays chosen
using the following options:
* ``include_chinese_new_year_eve``
* ``include_chinese_new_year`` (... | [
"def",
"get_chinese_new_year",
"(",
"self",
",",
"year",
")",
":",
"days",
"=",
"[",
"]",
"lunar_first_day",
"=",
"ChineseNewYearCalendar",
".",
"lunar",
"(",
"year",
",",
"1",
",",
"1",
")",
"if",
"self",
".",
"include_chinese_new_year_eve",
":",
"days",
... | Compute Chinese New Year days. To return a list of holidays.
By default, it'll at least return the Chinese New Year holidays chosen
using the following options:
* ``include_chinese_new_year_eve``
* ``include_chinese_new_year`` (on by default)
* ``include_chinese_second_day``
... | [
"Compute",
"Chinese",
"New",
"Year",
"days",
".",
"To",
"return",
"a",
"list",
"of",
"holidays",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L566-L633 | train |
peopledoc/workalendar | workalendar/core.py | ChineseNewYearCalendar.get_shifted_holidays | def get_shifted_holidays(self, dates):
"""
Taking a list of existing holidays, yield a list of 'shifted' days if
the holiday falls on SUN.
"""
for holiday, label in dates:
if holiday.weekday() == SUN:
yield (
holiday + timedelta(day... | python | def get_shifted_holidays(self, dates):
"""
Taking a list of existing holidays, yield a list of 'shifted' days if
the holiday falls on SUN.
"""
for holiday, label in dates:
if holiday.weekday() == SUN:
yield (
holiday + timedelta(day... | [
"def",
"get_shifted_holidays",
"(",
"self",
",",
"dates",
")",
":",
"for",
"holiday",
",",
"label",
"in",
"dates",
":",
"if",
"holiday",
".",
"weekday",
"(",
")",
"==",
"SUN",
":",
"yield",
"(",
"holiday",
"+",
"timedelta",
"(",
"days",
"=",
"1",
")"... | Taking a list of existing holidays, yield a list of 'shifted' days if
the holiday falls on SUN. | [
"Taking",
"a",
"list",
"of",
"existing",
"holidays",
"yield",
"a",
"list",
"of",
"shifted",
"days",
"if",
"the",
"holiday",
"falls",
"on",
"SUN",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L640-L650 | train |
peopledoc/workalendar | workalendar/core.py | ChineseNewYearCalendar.get_calendar_holidays | def get_calendar_holidays(self, year):
"""
Take into account the eventual shift to the next MON if any holiday
falls on SUN.
"""
# Unshifted days are here:
days = super(ChineseNewYearCalendar, self).get_calendar_holidays(year)
if self.shift_sunday_holidays:
... | python | def get_calendar_holidays(self, year):
"""
Take into account the eventual shift to the next MON if any holiday
falls on SUN.
"""
# Unshifted days are here:
days = super(ChineseNewYearCalendar, self).get_calendar_holidays(year)
if self.shift_sunday_holidays:
... | [
"def",
"get_calendar_holidays",
"(",
"self",
",",
"year",
")",
":",
"days",
"=",
"super",
"(",
"ChineseNewYearCalendar",
",",
"self",
")",
".",
"get_calendar_holidays",
"(",
"year",
")",
"if",
"self",
".",
"shift_sunday_holidays",
":",
"days_to_inspect",
"=",
... | Take into account the eventual shift to the next MON if any holiday
falls on SUN. | [
"Take",
"into",
"account",
"the",
"eventual",
"shift",
"to",
"the",
"next",
"MON",
"if",
"any",
"holiday",
"falls",
"on",
"SUN",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L652-L663 | train |
peopledoc/workalendar | workalendar/core.py | EphemMixin.calculate_equinoxes | def calculate_equinoxes(self, year, timezone='UTC'):
""" calculate equinox with time zone """
tz = pytz.timezone(timezone)
d1 = ephem.next_equinox(str(year))
d = ephem.Date(str(d1))
equinox1 = d.datetime() + tz.utcoffset(d.datetime())
d2 = ephem.next_equinox(d1)
... | python | def calculate_equinoxes(self, year, timezone='UTC'):
""" calculate equinox with time zone """
tz = pytz.timezone(timezone)
d1 = ephem.next_equinox(str(year))
d = ephem.Date(str(d1))
equinox1 = d.datetime() + tz.utcoffset(d.datetime())
d2 = ephem.next_equinox(d1)
... | [
"def",
"calculate_equinoxes",
"(",
"self",
",",
"year",
",",
"timezone",
"=",
"'UTC'",
")",
":",
"tz",
"=",
"pytz",
".",
"timezone",
"(",
"timezone",
")",
"d1",
"=",
"ephem",
".",
"next_equinox",
"(",
"str",
"(",
"year",
")",
")",
"d",
"=",
"ephem",
... | calculate equinox with time zone | [
"calculate",
"equinox",
"with",
"time",
"zone"
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L667-L680 | train |
peopledoc/workalendar | workalendar/core.py | EphemMixin.solar_term | def solar_term(self, year, degrees, timezone='UTC'):
"""
Returns the date of the solar term for the given longitude
and the given year.
Solar terms are used for Chinese and Taiwanese holidays
(e.g. Qingming Festival in Taiwan).
More information:
- https://en.wik... | python | def solar_term(self, year, degrees, timezone='UTC'):
"""
Returns the date of the solar term for the given longitude
and the given year.
Solar terms are used for Chinese and Taiwanese holidays
(e.g. Qingming Festival in Taiwan).
More information:
- https://en.wik... | [
"def",
"solar_term",
"(",
"self",
",",
"year",
",",
"degrees",
",",
"timezone",
"=",
"'UTC'",
")",
":",
"twopi",
"=",
"2",
"*",
"pi",
"tz",
"=",
"pytz",
".",
"timezone",
"(",
"timezone",
")",
"sun",
"=",
"ephem",
".",
"Sun",
"(",
"ephem",
".",
"D... | Returns the date of the solar term for the given longitude
and the given year.
Solar terms are used for Chinese and Taiwanese holidays
(e.g. Qingming Festival in Taiwan).
More information:
- https://en.wikipedia.org/wiki/Solar_term
- https://en.wikipedia.org/wiki/Qingmi... | [
"Returns",
"the",
"date",
"of",
"the",
"solar",
"term",
"for",
"the",
"given",
"longitude",
"and",
"the",
"given",
"year",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L682-L721 | train |
peopledoc/workalendar | workalendar/europe/scotland/__init__.py | Edinburgh.get_spring_holiday | def get_spring_holiday(self, year):
"""
Return Spring Holiday for Edinburgh.
Set to the 3rd Monday of April, unless it falls on Easter Monday, then
it's shifted to previous week.
"""
easter = self.get_easter_monday(year)
spring_holiday = self.get_nth_weekday_in_m... | python | def get_spring_holiday(self, year):
"""
Return Spring Holiday for Edinburgh.
Set to the 3rd Monday of April, unless it falls on Easter Monday, then
it's shifted to previous week.
"""
easter = self.get_easter_monday(year)
spring_holiday = self.get_nth_weekday_in_m... | [
"def",
"get_spring_holiday",
"(",
"self",
",",
"year",
")",
":",
"easter",
"=",
"self",
".",
"get_easter_monday",
"(",
"year",
")",
"spring_holiday",
"=",
"self",
".",
"get_nth_weekday_in_month",
"(",
"year",
",",
"4",
",",
"MON",
",",
"3",
")",
"if",
"e... | Return Spring Holiday for Edinburgh.
Set to the 3rd Monday of April, unless it falls on Easter Monday, then
it's shifted to previous week. | [
"Return",
"Spring",
"Holiday",
"for",
"Edinburgh",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/europe/scotland/__init__.py#L230-L243 | train |
peopledoc/workalendar | workalendar/europe/scotland/__init__.py | Edinburgh.get_victoria_day | def get_victoria_day(self, year):
"""
Return Victoria Day for Edinburgh.
Set to the Monday strictly before May 24th. It means that if May 24th
is a Monday, it's shifted to the week before.
"""
may_24th = date(year, 5, 24)
# Since "MON(day) == 0", it's either the ... | python | def get_victoria_day(self, year):
"""
Return Victoria Day for Edinburgh.
Set to the Monday strictly before May 24th. It means that if May 24th
is a Monday, it's shifted to the week before.
"""
may_24th = date(year, 5, 24)
# Since "MON(day) == 0", it's either the ... | [
"def",
"get_victoria_day",
"(",
"self",
",",
"year",
")",
":",
"may_24th",
"=",
"date",
"(",
"year",
",",
"5",
",",
"24",
")",
"shift",
"=",
"may_24th",
".",
"weekday",
"(",
")",
"or",
"7",
"victoria_day",
"=",
"may_24th",
"-",
"timedelta",
"(",
"day... | Return Victoria Day for Edinburgh.
Set to the Monday strictly before May 24th. It means that if May 24th
is a Monday, it's shifted to the week before. | [
"Return",
"Victoria",
"Day",
"for",
"Edinburgh",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/europe/scotland/__init__.py#L245-L257 | train |
peopledoc/workalendar | setup.py | read_relative_file | def read_relative_file(filename):
"""
Return the contents of the given file.
Its path is supposed relative to this module.
"""
path = join(dirname(abspath(__file__)), filename)
with io.open(path, encoding='utf-8') as f:
return f.read() | python | def read_relative_file(filename):
"""
Return the contents of the given file.
Its path is supposed relative to this module.
"""
path = join(dirname(abspath(__file__)), filename)
with io.open(path, encoding='utf-8') as f:
return f.read() | [
"def",
"read_relative_file",
"(",
"filename",
")",
":",
"path",
"=",
"join",
"(",
"dirname",
"(",
"abspath",
"(",
"__file__",
")",
")",
",",
"filename",
")",
"with",
"io",
".",
"open",
"(",
"path",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":"... | Return the contents of the given file.
Its path is supposed relative to this module. | [
"Return",
"the",
"contents",
"of",
"the",
"given",
"file",
"."
] | d044d5dfc1709ec388db34dab583dd554cc66c4e | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/setup.py#L8-L16 | train |
bmuller/kademlia | kademlia/routing.py | RoutingTable.lonely_buckets | def lonely_buckets(self):
"""
Get all of the buckets that haven't been updated in over
an hour.
"""
hrago = time.monotonic() - 3600
return [b for b in self.buckets if b.last_updated < hrago] | python | def lonely_buckets(self):
"""
Get all of the buckets that haven't been updated in over
an hour.
"""
hrago = time.monotonic() - 3600
return [b for b in self.buckets if b.last_updated < hrago] | [
"def",
"lonely_buckets",
"(",
"self",
")",
":",
"hrago",
"=",
"time",
".",
"monotonic",
"(",
")",
"-",
"3600",
"return",
"[",
"b",
"for",
"b",
"in",
"self",
".",
"buckets",
"if",
"b",
".",
"last_updated",
"<",
"hrago",
"]"
] | Get all of the buckets that haven't been updated in over
an hour. | [
"Get",
"all",
"of",
"the",
"buckets",
"that",
"haven",
"t",
"been",
"updated",
"in",
"over",
"an",
"hour",
"."
] | 4a8d445c9ee8f3ca10f56107e4445daed4933c8a | https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/routing.py#L140-L146 | train |
bmuller/kademlia | kademlia/routing.py | RoutingTable.get_bucket_for | def get_bucket_for(self, node):
"""
Get the index of the bucket that the given node would fall into.
"""
for index, bucket in enumerate(self.buckets):
if node.long_id < bucket.range[1]:
return index
# we should never be here, but make linter happy
... | python | def get_bucket_for(self, node):
"""
Get the index of the bucket that the given node would fall into.
"""
for index, bucket in enumerate(self.buckets):
if node.long_id < bucket.range[1]:
return index
# we should never be here, but make linter happy
... | [
"def",
"get_bucket_for",
"(",
"self",
",",
"node",
")",
":",
"for",
"index",
",",
"bucket",
"in",
"enumerate",
"(",
"self",
".",
"buckets",
")",
":",
"if",
"node",
".",
"long_id",
"<",
"bucket",
".",
"range",
"[",
"1",
"]",
":",
"return",
"index",
... | Get the index of the bucket that the given node would fall into. | [
"Get",
"the",
"index",
"of",
"the",
"bucket",
"that",
"the",
"given",
"node",
"would",
"fall",
"into",
"."
] | 4a8d445c9ee8f3ca10f56107e4445daed4933c8a | https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/routing.py#L172-L180 | train |
bmuller/kademlia | kademlia/crawling.py | SpiderCrawl._find | async def _find(self, rpcmethod):
"""
Get either a value or list of nodes.
Args:
rpcmethod: The protocol's callfindValue or call_find_node.
The process:
1. calls find_* to current ALPHA nearest not already queried nodes,
adding results to current near... | python | async def _find(self, rpcmethod):
"""
Get either a value or list of nodes.
Args:
rpcmethod: The protocol's callfindValue or call_find_node.
The process:
1. calls find_* to current ALPHA nearest not already queried nodes,
adding results to current near... | [
"async",
"def",
"_find",
"(",
"self",
",",
"rpcmethod",
")",
":",
"log",
".",
"info",
"(",
"\"crawling network with nearest: %s\"",
",",
"str",
"(",
"tuple",
"(",
"self",
".",
"nearest",
")",
")",
")",
"count",
"=",
"self",
".",
"alpha",
"if",
"self",
... | Get either a value or list of nodes.
Args:
rpcmethod: The protocol's callfindValue or call_find_node.
The process:
1. calls find_* to current ALPHA nearest not already queried nodes,
adding results to current nearest list of k nodes.
2. current nearest list... | [
"Get",
"either",
"a",
"value",
"or",
"list",
"of",
"nodes",
"."
] | 4a8d445c9ee8f3ca10f56107e4445daed4933c8a | https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/crawling.py#L38-L65 | train |
bmuller/kademlia | kademlia/network.py | check_dht_value_type | def check_dht_value_type(value):
"""
Checks to see if the type of the value is a valid type for
placing in the dht.
"""
typeset = [
int,
float,
bool,
str,
bytes
]
return type(value) in typeset | python | def check_dht_value_type(value):
"""
Checks to see if the type of the value is a valid type for
placing in the dht.
"""
typeset = [
int,
float,
bool,
str,
bytes
]
return type(value) in typeset | [
"def",
"check_dht_value_type",
"(",
"value",
")",
":",
"typeset",
"=",
"[",
"int",
",",
"float",
",",
"bool",
",",
"str",
",",
"bytes",
"]",
"return",
"type",
"(",
"value",
")",
"in",
"typeset"
] | Checks to see if the type of the value is a valid type for
placing in the dht. | [
"Checks",
"to",
"see",
"if",
"the",
"type",
"of",
"the",
"value",
"is",
"a",
"valid",
"type",
"for",
"placing",
"in",
"the",
"dht",
"."
] | 4a8d445c9ee8f3ca10f56107e4445daed4933c8a | https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/network.py#L245-L257 | train |
bmuller/kademlia | kademlia/network.py | Server.listen | async def listen(self, port, interface='0.0.0.0'):
"""
Start listening on the given port.
Provide interface="::" to accept ipv6 address
"""
loop = asyncio.get_event_loop()
listen = loop.create_datagram_endpoint(self._create_protocol,
... | python | async def listen(self, port, interface='0.0.0.0'):
"""
Start listening on the given port.
Provide interface="::" to accept ipv6 address
"""
loop = asyncio.get_event_loop()
listen = loop.create_datagram_endpoint(self._create_protocol,
... | [
"async",
"def",
"listen",
"(",
"self",
",",
"port",
",",
"interface",
"=",
"'0.0.0.0'",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"listen",
"=",
"loop",
".",
"create_datagram_endpoint",
"(",
"self",
".",
"_create_protocol",
",",
"l... | Start listening on the given port.
Provide interface="::" to accept ipv6 address | [
"Start",
"listening",
"on",
"the",
"given",
"port",
"."
] | 4a8d445c9ee8f3ca10f56107e4445daed4933c8a | https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/network.py#L61-L74 | train |
bmuller/kademlia | kademlia/network.py | Server.bootstrap | async def bootstrap(self, addrs):
"""
Bootstrap the server by connecting to other known nodes in the network.
Args:
addrs: A `list` of (ip, port) `tuple` pairs. Note that only IP
addresses are acceptable - hostnames will cause an error.
"""
log.de... | python | async def bootstrap(self, addrs):
"""
Bootstrap the server by connecting to other known nodes in the network.
Args:
addrs: A `list` of (ip, port) `tuple` pairs. Note that only IP
addresses are acceptable - hostnames will cause an error.
"""
log.de... | [
"async",
"def",
"bootstrap",
"(",
"self",
",",
"addrs",
")",
":",
"log",
".",
"debug",
"(",
"\"Attempting to bootstrap node with %i initial contacts\"",
",",
"len",
"(",
"addrs",
")",
")",
"cos",
"=",
"list",
"(",
"map",
"(",
"self",
".",
"bootstrap_node",
"... | Bootstrap the server by connecting to other known nodes in the network.
Args:
addrs: A `list` of (ip, port) `tuple` pairs. Note that only IP
addresses are acceptable - hostnames will cause an error. | [
"Bootstrap",
"the",
"server",
"by",
"connecting",
"to",
"other",
"known",
"nodes",
"in",
"the",
"network",
"."
] | 4a8d445c9ee8f3ca10f56107e4445daed4933c8a | https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/network.py#L115-L130 | train |
bmuller/kademlia | kademlia/network.py | Server.get | async def get(self, key):
"""
Get a key if the network has it.
Returns:
:class:`None` if not found, the value otherwise.
"""
log.info("Looking up key %s", key)
dkey = digest(key)
# if this node has it, return it
if self.storage.get(dkey) is no... | python | async def get(self, key):
"""
Get a key if the network has it.
Returns:
:class:`None` if not found, the value otherwise.
"""
log.info("Looking up key %s", key)
dkey = digest(key)
# if this node has it, return it
if self.storage.get(dkey) is no... | [
"async",
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"log",
".",
"info",
"(",
"\"Looking up key %s\"",
",",
"key",
")",
"dkey",
"=",
"digest",
"(",
"key",
")",
"if",
"self",
".",
"storage",
".",
"get",
"(",
"dkey",
")",
"is",
"not",
"None",
... | Get a key if the network has it.
Returns:
:class:`None` if not found, the value otherwise. | [
"Get",
"a",
"key",
"if",
"the",
"network",
"has",
"it",
"."
] | 4a8d445c9ee8f3ca10f56107e4445daed4933c8a | https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/network.py#L136-L155 | train |
bmuller/kademlia | kademlia/network.py | Server.set | async def set(self, key, value):
"""
Set the given string key to the given value in the network.
"""
if not check_dht_value_type(value):
raise TypeError(
"Value must be of type int, float, bool, str, or bytes"
)
log.info("setting '%s' = '%s... | python | async def set(self, key, value):
"""
Set the given string key to the given value in the network.
"""
if not check_dht_value_type(value):
raise TypeError(
"Value must be of type int, float, bool, str, or bytes"
)
log.info("setting '%s' = '%s... | [
"async",
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"not",
"check_dht_value_type",
"(",
"value",
")",
":",
"raise",
"TypeError",
"(",
"\"Value must be of type int, float, bool, str, or bytes\"",
")",
"log",
".",
"info",
"(",
"\"setting ... | Set the given string key to the given value in the network. | [
"Set",
"the",
"given",
"string",
"key",
"to",
"the",
"given",
"value",
"in",
"the",
"network",
"."
] | 4a8d445c9ee8f3ca10f56107e4445daed4933c8a | https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/network.py#L157-L167 | train |
bmuller/kademlia | kademlia/network.py | Server.save_state_regularly | def save_state_regularly(self, fname, frequency=600):
"""
Save the state of node with a given regularity to the given
filename.
Args:
fname: File name to save retularly to
frequency: Frequency in seconds that the state should be saved.
By ... | python | def save_state_regularly(self, fname, frequency=600):
"""
Save the state of node with a given regularity to the given
filename.
Args:
fname: File name to save retularly to
frequency: Frequency in seconds that the state should be saved.
By ... | [
"def",
"save_state_regularly",
"(",
"self",
",",
"fname",
",",
"frequency",
"=",
"600",
")",
":",
"self",
".",
"save_state",
"(",
"fname",
")",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"self",
".",
"save_state_loop",
"=",
"loop",
".",
"ca... | Save the state of node with a given regularity to the given
filename.
Args:
fname: File name to save retularly to
frequency: Frequency in seconds that the state should be saved.
By default, 10 minutes. | [
"Save",
"the",
"state",
"of",
"node",
"with",
"a",
"given",
"regularity",
"to",
"the",
"given",
"filename",
"."
] | 4a8d445c9ee8f3ca10f56107e4445daed4933c8a | https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/network.py#L227-L242 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.