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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
mezz64/pyHik | pyhik/hikvision.py | HikCamera.publish_changes | def publish_changes(self, etype, echid):
"""Post updates for specified event type."""
_LOGGING.debug('%s Update: %s, %s',
self.name, etype, self.fetch_attributes(etype, echid))
signal = 'ValueChanged.{}'.format(self.cam_id)
sender = '{}.{}'.format(etype, echid)
... | python | def publish_changes(self, etype, echid):
"""Post updates for specified event type."""
_LOGGING.debug('%s Update: %s, %s',
self.name, etype, self.fetch_attributes(etype, echid))
signal = 'ValueChanged.{}'.format(self.cam_id)
sender = '{}.{}'.format(etype, echid)
... | [
"def",
"publish_changes",
"(",
"self",
",",
"etype",
",",
"echid",
")",
":",
"_LOGGING",
".",
"debug",
"(",
"'%s Update: %s, %s'",
",",
"self",
".",
"name",
",",
"etype",
",",
"self",
".",
"fetch_attributes",
"(",
"etype",
",",
"echid",
")",
")",
"signal... | Post updates for specified event type. | [
"Post",
"updates",
"for",
"specified",
"event",
"type",
"."
] | 1e7afca926e2b045257a43cbf8b1236a435493c2 | https://github.com/mezz64/pyHik/blob/1e7afca926e2b045257a43cbf8b1236a435493c2/pyhik/hikvision.py#L592-L601 | train |
mezz64/pyHik | pyhik/watchdog.py | Watchdog.start | def start(self):
""" Starts the watchdog timer. """
self._timer = Timer(self.time, self.handler)
self._timer.daemon = True
self._timer.start()
return | python | def start(self):
""" Starts the watchdog timer. """
self._timer = Timer(self.time, self.handler)
self._timer.daemon = True
self._timer.start()
return | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"_timer",
"=",
"Timer",
"(",
"self",
".",
"time",
",",
"self",
".",
"handler",
")",
"self",
".",
"_timer",
".",
"daemon",
"=",
"True",
"self",
".",
"_timer",
".",
"start",
"(",
")",
"return"
] | Starts the watchdog timer. | [
"Starts",
"the",
"watchdog",
"timer",
"."
] | 1e7afca926e2b045257a43cbf8b1236a435493c2 | https://github.com/mezz64/pyHik/blob/1e7afca926e2b045257a43cbf8b1236a435493c2/pyhik/watchdog.py#L21-L26 | train |
mezz64/pyHik | examples/basic_usage.py | HikCamObject.flip_motion | def flip_motion(self, value):
"""Toggle motion detection"""
if value:
self.cam.enable_motion_detection()
else:
self.cam.disable_motion_detection() | python | def flip_motion(self, value):
"""Toggle motion detection"""
if value:
self.cam.enable_motion_detection()
else:
self.cam.disable_motion_detection() | [
"def",
"flip_motion",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
":",
"self",
".",
"cam",
".",
"enable_motion_detection",
"(",
")",
"else",
":",
"self",
".",
"cam",
".",
"disable_motion_detection",
"(",
")"
] | Toggle motion detection | [
"Toggle",
"motion",
"detection"
] | 1e7afca926e2b045257a43cbf8b1236a435493c2 | https://github.com/mezz64/pyHik/blob/1e7afca926e2b045257a43cbf8b1236a435493c2/examples/basic_usage.py#L47-L52 | train |
mezz64/pyHik | examples/basic_usage.py | HikSensor.update_callback | def update_callback(self, msg):
""" get updates. """
print('Callback: {}'.format(msg))
print('{}:{} @ {}'.format(self.name, self._sensor_state(), self._sensor_last_update())) | python | def update_callback(self, msg):
""" get updates. """
print('Callback: {}'.format(msg))
print('{}:{} @ {}'.format(self.name, self._sensor_state(), self._sensor_last_update())) | [
"def",
"update_callback",
"(",
"self",
",",
"msg",
")",
":",
"print",
"(",
"'Callback: {}'",
".",
"format",
"(",
"msg",
")",
")",
"print",
"(",
"'{}:{} @ {}'",
".",
"format",
"(",
"self",
".",
"name",
",",
"self",
".",
"_sensor_state",
"(",
")",
",",
... | get updates. | [
"get",
"updates",
"."
] | 1e7afca926e2b045257a43cbf8b1236a435493c2 | https://github.com/mezz64/pyHik/blob/1e7afca926e2b045257a43cbf8b1236a435493c2/examples/basic_usage.py#L91-L94 | train |
mbr/flask-nav | flask_nav/elements.py | NavigationItem.render | def render(self, renderer=None, **kwargs):
"""Render the navigational item using a renderer.
:param renderer: An object implementing the :class:`~.Renderer`
interface.
:return: A markupsafe string with the rendered result.
"""
return Markup(get_renderer(... | python | def render(self, renderer=None, **kwargs):
"""Render the navigational item using a renderer.
:param renderer: An object implementing the :class:`~.Renderer`
interface.
:return: A markupsafe string with the rendered result.
"""
return Markup(get_renderer(... | [
"def",
"render",
"(",
"self",
",",
"renderer",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"return",
"Markup",
"(",
"get_renderer",
"(",
"current_app",
",",
"renderer",
")",
"(",
"**",
"kwargs",
")",
".",
"visit",
"(",
"self",
")",
")"
] | Render the navigational item using a renderer.
:param renderer: An object implementing the :class:`~.Renderer`
interface.
:return: A markupsafe string with the rendered result. | [
"Render",
"the",
"navigational",
"item",
"using",
"a",
"renderer",
"."
] | 06f3b5b2addad29c2fc531a7e8e74958e9e4b793 | https://github.com/mbr/flask-nav/blob/06f3b5b2addad29c2fc531a7e8e74958e9e4b793/flask_nav/elements.py#L16-L24 | train |
mbr/flask-nav | flask_nav/renderers.py | Renderer.visit_object | def visit_object(self, node):
"""Fallback rendering for objects.
If the current application is in debug-mode
(``flask.current_app.debug`` is ``True``), an ``<!-- HTML comment
-->`` will be rendered, indicating which class is missing a visitation
function.
Outside of deb... | python | def visit_object(self, node):
"""Fallback rendering for objects.
If the current application is in debug-mode
(``flask.current_app.debug`` is ``True``), an ``<!-- HTML comment
-->`` will be rendered, indicating which class is missing a visitation
function.
Outside of deb... | [
"def",
"visit_object",
"(",
"self",
",",
"node",
")",
":",
"if",
"current_app",
".",
"debug",
":",
"return",
"tags",
".",
"comment",
"(",
"'no implementation in {} to render {}'",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"node",
".... | Fallback rendering for objects.
If the current application is in debug-mode
(``flask.current_app.debug`` is ``True``), an ``<!-- HTML comment
-->`` will be rendered, indicating which class is missing a visitation
function.
Outside of debug-mode, returns an empty string. | [
"Fallback",
"rendering",
"for",
"objects",
"."
] | 06f3b5b2addad29c2fc531a7e8e74958e9e4b793 | https://github.com/mbr/flask-nav/blob/06f3b5b2addad29c2fc531a7e8e74958e9e4b793/flask_nav/renderers.py#L13-L27 | train |
mbr/flask-nav | flask_nav/__init__.py | register_renderer | def register_renderer(app, id, renderer, force=True):
"""Registers a renderer on the application.
:param app: The :class:`~flask.Flask` application to register the renderer
on
:param id: Internal id-string for the renderer
:param renderer: Renderer to register
:param force: Whether ... | python | def register_renderer(app, id, renderer, force=True):
"""Registers a renderer on the application.
:param app: The :class:`~flask.Flask` application to register the renderer
on
:param id: Internal id-string for the renderer
:param renderer: Renderer to register
:param force: Whether ... | [
"def",
"register_renderer",
"(",
"app",
",",
"id",
",",
"renderer",
",",
"force",
"=",
"True",
")",
":",
"renderers",
"=",
"app",
".",
"extensions",
".",
"setdefault",
"(",
"'nav_renderers'",
",",
"{",
"}",
")",
"if",
"force",
":",
"renderers",
"[",
"i... | Registers a renderer on the application.
:param app: The :class:`~flask.Flask` application to register the renderer
on
:param id: Internal id-string for the renderer
:param renderer: Renderer to register
:param force: Whether or not to overwrite the renderer if a different one
... | [
"Registers",
"a",
"renderer",
"on",
"the",
"application",
"."
] | 06f3b5b2addad29c2fc531a7e8e74958e9e4b793 | https://github.com/mbr/flask-nav/blob/06f3b5b2addad29c2fc531a7e8e74958e9e4b793/flask_nav/__init__.py#L6-L21 | train |
mbr/flask-nav | flask_nav/__init__.py | get_renderer | def get_renderer(app, id):
"""Retrieve a renderer.
:param app: :class:`~flask.Flask` application to look ``id`` up on
:param id: Internal renderer id-string to look up
"""
renderer = app.extensions.get('nav_renderers', {})[id]
if isinstance(renderer, tuple):
mod_name, cls_name = render... | python | def get_renderer(app, id):
"""Retrieve a renderer.
:param app: :class:`~flask.Flask` application to look ``id`` up on
:param id: Internal renderer id-string to look up
"""
renderer = app.extensions.get('nav_renderers', {})[id]
if isinstance(renderer, tuple):
mod_name, cls_name = render... | [
"def",
"get_renderer",
"(",
"app",
",",
"id",
")",
":",
"renderer",
"=",
"app",
".",
"extensions",
".",
"get",
"(",
"'nav_renderers'",
",",
"{",
"}",
")",
"[",
"id",
"]",
"if",
"isinstance",
"(",
"renderer",
",",
"tuple",
")",
":",
"mod_name",
",",
... | Retrieve a renderer.
:param app: :class:`~flask.Flask` application to look ``id`` up on
:param id: Internal renderer id-string to look up | [
"Retrieve",
"a",
"renderer",
"."
] | 06f3b5b2addad29c2fc531a7e8e74958e9e4b793 | https://github.com/mbr/flask-nav/blob/06f3b5b2addad29c2fc531a7e8e74958e9e4b793/flask_nav/__init__.py#L24-L42 | train |
mbr/flask-nav | flask_nav/__init__.py | Nav.init_app | def init_app(self, app):
"""Initialize an application.
:param app: A :class:`~flask.Flask` app.
"""
if not hasattr(app, 'extensions'):
app.extensions = {}
app.extensions['nav'] = self
app.add_template_global(self.elems, 'nav')
# register some render... | python | def init_app(self, app):
"""Initialize an application.
:param app: A :class:`~flask.Flask` app.
"""
if not hasattr(app, 'extensions'):
app.extensions = {}
app.extensions['nav'] = self
app.add_template_global(self.elems, 'nav')
# register some render... | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"if",
"not",
"hasattr",
"(",
"app",
",",
"'extensions'",
")",
":",
"app",
".",
"extensions",
"=",
"{",
"}",
"app",
".",
"extensions",
"[",
"'nav'",
"]",
"=",
"self",
"app",
".",
"add_template_glob... | Initialize an application.
:param app: A :class:`~flask.Flask` app. | [
"Initialize",
"an",
"application",
"."
] | 06f3b5b2addad29c2fc531a7e8e74958e9e4b793 | https://github.com/mbr/flask-nav/blob/06f3b5b2addad29c2fc531a7e8e74958e9e4b793/flask_nav/__init__.py#L99-L112 | train |
mbr/flask-nav | flask_nav/__init__.py | Nav.navigation | def navigation(self, id=None):
"""Function decorator for navbar registration.
Convenience function, calls :meth:`.register_element` with ``id`` and
the decorated function as ``elem``.
:param id: ID to pass on. If ``None``, uses the decorated functions
name.
"... | python | def navigation(self, id=None):
"""Function decorator for navbar registration.
Convenience function, calls :meth:`.register_element` with ``id`` and
the decorated function as ``elem``.
:param id: ID to pass on. If ``None``, uses the decorated functions
name.
"... | [
"def",
"navigation",
"(",
"self",
",",
"id",
"=",
"None",
")",
":",
"def",
"wrapper",
"(",
"f",
")",
":",
"self",
".",
"register_element",
"(",
"id",
"or",
"f",
".",
"__name__",
",",
"f",
")",
"return",
"f",
"return",
"wrapper"
] | Function decorator for navbar registration.
Convenience function, calls :meth:`.register_element` with ``id`` and
the decorated function as ``elem``.
:param id: ID to pass on. If ``None``, uses the decorated functions
name. | [
"Function",
"decorator",
"for",
"navbar",
"registration",
"."
] | 06f3b5b2addad29c2fc531a7e8e74958e9e4b793 | https://github.com/mbr/flask-nav/blob/06f3b5b2addad29c2fc531a7e8e74958e9e4b793/flask_nav/__init__.py#L114-L128 | train |
mbr/flask-nav | flask_nav/__init__.py | Nav.renderer | def renderer(self, id=None, force=True):
"""Class decorator for Renderers.
The decorated class will be added to the list of renderers kept by this
instance that will be registered on the app upon app initialization.
:param id: Id for the renderer, defaults to the class name in snake
... | python | def renderer(self, id=None, force=True):
"""Class decorator for Renderers.
The decorated class will be added to the list of renderers kept by this
instance that will be registered on the app upon app initialization.
:param id: Id for the renderer, defaults to the class name in snake
... | [
"def",
"renderer",
"(",
"self",
",",
"id",
"=",
"None",
",",
"force",
"=",
"True",
")",
":",
"def",
"_",
"(",
"cls",
")",
":",
"name",
"=",
"cls",
".",
"__name__",
"sn",
"=",
"name",
"[",
"0",
"]",
"+",
"re",
".",
"sub",
"(",
"r'([A-Z])'",
",... | Class decorator for Renderers.
The decorated class will be added to the list of renderers kept by this
instance that will be registered on the app upon app initialization.
:param id: Id for the renderer, defaults to the class name in snake
case.
:param force: Whether... | [
"Class",
"decorator",
"for",
"Renderers",
"."
] | 06f3b5b2addad29c2fc531a7e8e74958e9e4b793 | https://github.com/mbr/flask-nav/blob/06f3b5b2addad29c2fc531a7e8e74958e9e4b793/flask_nav/__init__.py#L148-L166 | train |
tonyseek/openvpn-status | openvpn_status/utils.py | parse_time | def parse_time(time):
"""Parses date and time from input string in OpenVPN logging format."""
if isinstance(time, datetime.datetime):
return time
return datetime.datetime.strptime(time, DATETIME_FORMAT_OPENVPN) | python | def parse_time(time):
"""Parses date and time from input string in OpenVPN logging format."""
if isinstance(time, datetime.datetime):
return time
return datetime.datetime.strptime(time, DATETIME_FORMAT_OPENVPN) | [
"def",
"parse_time",
"(",
"time",
")",
":",
"if",
"isinstance",
"(",
"time",
",",
"datetime",
".",
"datetime",
")",
":",
"return",
"time",
"return",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"time",
",",
"DATETIME_FORMAT_OPENVPN",
")"
] | Parses date and time from input string in OpenVPN logging format. | [
"Parses",
"date",
"and",
"time",
"from",
"input",
"string",
"in",
"OpenVPN",
"logging",
"format",
"."
] | b8f5ec5f79933605af2301c42e4e7ec230334237 | https://github.com/tonyseek/openvpn-status/blob/b8f5ec5f79933605af2301c42e4e7ec230334237/openvpn_status/utils.py#L19-L23 | train |
jieter/python-lora | lora/payload.py | LoRaPayload.decrypt | def decrypt(self, key, dev_addr):
"""
Decrypt the actual payload in this LoraPayload.
key: 16-byte hex-encoded AES key. (i.e. AABBCCDDEEFFAABBCCDDEEFFAABBCCDD)
dev_addr: 4-byte hex-encoded DevAddr (i.e. AABBCCDD)
"""
sequence_counter = int(self.FCntUp)
return lo... | python | def decrypt(self, key, dev_addr):
"""
Decrypt the actual payload in this LoraPayload.
key: 16-byte hex-encoded AES key. (i.e. AABBCCDDEEFFAABBCCDDEEFFAABBCCDD)
dev_addr: 4-byte hex-encoded DevAddr (i.e. AABBCCDD)
"""
sequence_counter = int(self.FCntUp)
return lo... | [
"def",
"decrypt",
"(",
"self",
",",
"key",
",",
"dev_addr",
")",
":",
"sequence_counter",
"=",
"int",
"(",
"self",
".",
"FCntUp",
")",
"return",
"loramac_decrypt",
"(",
"self",
".",
"payload_hex",
",",
"sequence_counter",
",",
"key",
",",
"dev_addr",
")"
] | Decrypt the actual payload in this LoraPayload.
key: 16-byte hex-encoded AES key. (i.e. AABBCCDDEEFFAABBCCDDEEFFAABBCCDD)
dev_addr: 4-byte hex-encoded DevAddr (i.e. AABBCCDD) | [
"Decrypt",
"the",
"actual",
"payload",
"in",
"this",
"LoraPayload",
"."
] | 0edb8dbad771da1e2b455571c7a9b064ba67fbcd | https://github.com/jieter/python-lora/blob/0edb8dbad771da1e2b455571c7a9b064ba67fbcd/lora/payload.py#L38-L47 | train |
tonyseek/openvpn-status | openvpn_status/parser.py | LogParser.parse | def parse(self):
"""Parses the status log.
:raises ParsingError: if syntax error found in the log.
:return: The :class:`.models.Status` with filled data.
"""
status = Status()
self.expect_line(Status.client_list.label)
status.updated_at = self.expect_tuple(Statu... | python | def parse(self):
"""Parses the status log.
:raises ParsingError: if syntax error found in the log.
:return: The :class:`.models.Status` with filled data.
"""
status = Status()
self.expect_line(Status.client_list.label)
status.updated_at = self.expect_tuple(Statu... | [
"def",
"parse",
"(",
"self",
")",
":",
"status",
"=",
"Status",
"(",
")",
"self",
".",
"expect_line",
"(",
"Status",
".",
"client_list",
".",
"label",
")",
"status",
".",
"updated_at",
"=",
"self",
".",
"expect_tuple",
"(",
"Status",
".",
"updated_at",
... | Parses the status log.
:raises ParsingError: if syntax error found in the log.
:return: The :class:`.models.Status` with filled data. | [
"Parses",
"the",
"status",
"log",
"."
] | b8f5ec5f79933605af2301c42e4e7ec230334237 | https://github.com/tonyseek/openvpn-status/blob/b8f5ec5f79933605af2301c42e4e7ec230334237/openvpn_status/parser.py#L77-L98 | train |
tonyseek/openvpn-status | openvpn_status/shortcuts.py | parse_status | def parse_status(status_log, encoding='utf-8'):
"""Parses the status log of OpenVPN.
:param status_log: The content of status log.
:type status_log: :class:`str`
:param encoding: Optional. The encoding of status log.
:type encoding: :class:`str`
:return: The instance of :class:`.models.Status`
... | python | def parse_status(status_log, encoding='utf-8'):
"""Parses the status log of OpenVPN.
:param status_log: The content of status log.
:type status_log: :class:`str`
:param encoding: Optional. The encoding of status log.
:type encoding: :class:`str`
:return: The instance of :class:`.models.Status`
... | [
"def",
"parse_status",
"(",
"status_log",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"if",
"isinstance",
"(",
"status_log",
",",
"bytes",
")",
":",
"status_log",
"=",
"status_log",
".",
"decode",
"(",
"encoding",
")",
"parser",
"=",
"LogParser",
".",
"from... | Parses the status log of OpenVPN.
:param status_log: The content of status log.
:type status_log: :class:`str`
:param encoding: Optional. The encoding of status log.
:type encoding: :class:`str`
:return: The instance of :class:`.models.Status` | [
"Parses",
"the",
"status",
"log",
"of",
"OpenVPN",
"."
] | b8f5ec5f79933605af2301c42e4e7ec230334237 | https://github.com/tonyseek/openvpn-status/blob/b8f5ec5f79933605af2301c42e4e7ec230334237/openvpn_status/shortcuts.py#L6-L18 | train |
vfilimonov/pydatastream | pydatastream/pydatastream.py | Datastream.version | def version(self):
"""Return version of the TR DWE."""
res = self.client.service.Version()
return '.'.join([ustr(x) for x in res[0]]) | python | def version(self):
"""Return version of the TR DWE."""
res = self.client.service.Version()
return '.'.join([ustr(x) for x in res[0]]) | [
"def",
"version",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"client",
".",
"service",
".",
"Version",
"(",
")",
"return",
"'.'",
".",
"join",
"(",
"[",
"ustr",
"(",
"x",
")",
"for",
"x",
"in",
"res",
"[",
"0",
"]",
"]",
")"
] | Return version of the TR DWE. | [
"Return",
"version",
"of",
"the",
"TR",
"DWE",
"."
] | 15d2adac1c83501715db1542373fa8428542816e | https://github.com/vfilimonov/pydatastream/blob/15d2adac1c83501715db1542373fa8428542816e/pydatastream/pydatastream.py#L119-L122 | train |
vfilimonov/pydatastream | pydatastream/pydatastream.py | Datastream.system_info | def system_info(self):
"""Return system information."""
res = self.client.service.SystemInfo()
res = {ustr(x[0]): x[1] for x in res[0]}
to_str = lambda arr: '.'.join([ustr(x) for x in arr[0]])
res['OSVersion'] = to_str(res['OSVersion'])
res['RuntimeVersion'] = to_str(res... | python | def system_info(self):
"""Return system information."""
res = self.client.service.SystemInfo()
res = {ustr(x[0]): x[1] for x in res[0]}
to_str = lambda arr: '.'.join([ustr(x) for x in arr[0]])
res['OSVersion'] = to_str(res['OSVersion'])
res['RuntimeVersion'] = to_str(res... | [
"def",
"system_info",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"client",
".",
"service",
".",
"SystemInfo",
"(",
")",
"res",
"=",
"{",
"ustr",
"(",
"x",
"[",
"0",
"]",
")",
":",
"x",
"[",
"1",
"]",
"for",
"x",
"in",
"res",
"[",
"0",
... | Return system information. | [
"Return",
"system",
"information",
"."
] | 15d2adac1c83501715db1542373fa8428542816e | https://github.com/vfilimonov/pydatastream/blob/15d2adac1c83501715db1542373fa8428542816e/pydatastream/pydatastream.py#L124-L139 | train |
vfilimonov/pydatastream | pydatastream/pydatastream.py | Datastream.sources | def sources(self):
"""Return available sources of data."""
res = self.client.service.Sources(self.userdata, 0)
return [ustr(x[0]) for x in res[0]] | python | def sources(self):
"""Return available sources of data."""
res = self.client.service.Sources(self.userdata, 0)
return [ustr(x[0]) for x in res[0]] | [
"def",
"sources",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"client",
".",
"service",
".",
"Sources",
"(",
"self",
".",
"userdata",
",",
"0",
")",
"return",
"[",
"ustr",
"(",
"x",
"[",
"0",
"]",
")",
"for",
"x",
"in",
"res",
"[",
"0",
"... | Return available sources of data. | [
"Return",
"available",
"sources",
"of",
"data",
"."
] | 15d2adac1c83501715db1542373fa8428542816e | https://github.com/vfilimonov/pydatastream/blob/15d2adac1c83501715db1542373fa8428542816e/pydatastream/pydatastream.py#L141-L144 | train |
vfilimonov/pydatastream | pydatastream/pydatastream.py | Datastream.status | def status(self, record=None):
"""Extract status from the retrieved data and save it as a property of an object.
If record with data is not specified then the status of previous operation is
returned.
status - dictionary with data source, string with request and status type,
... | python | def status(self, record=None):
"""Extract status from the retrieved data and save it as a property of an object.
If record with data is not specified then the status of previous operation is
returned.
status - dictionary with data source, string with request and status type,
... | [
"def",
"status",
"(",
"self",
",",
"record",
"=",
"None",
")",
":",
"if",
"record",
"is",
"not",
"None",
":",
"self",
".",
"last_status",
"=",
"{",
"'Source'",
":",
"ustr",
"(",
"record",
"[",
"'Source'",
"]",
")",
",",
"'StatusType'",
":",
"ustr",
... | Extract status from the retrieved data and save it as a property of an object.
If record with data is not specified then the status of previous operation is
returned.
status - dictionary with data source, string with request and status type,
code and message.
... | [
"Extract",
"status",
"from",
"the",
"retrieved",
"data",
"and",
"save",
"it",
"as",
"a",
"property",
"of",
"an",
"object",
".",
"If",
"record",
"with",
"data",
"is",
"not",
"specified",
"then",
"the",
"status",
"of",
"previous",
"operation",
"is",
"returne... | 15d2adac1c83501715db1542373fa8428542816e | https://github.com/vfilimonov/pydatastream/blob/15d2adac1c83501715db1542373fa8428542816e/pydatastream/pydatastream.py#L230-L259 | train |
vfilimonov/pydatastream | pydatastream/pydatastream.py | Datastream.construct_request | def construct_request(ticker, fields=None, date=None,
date_from=None, date_to=None, freq=None):
"""Construct a request string for querying TR DWE.
tickers - ticker or symbol
fields - list of fields.
date - date for a single-date query
da... | python | def construct_request(ticker, fields=None, date=None,
date_from=None, date_to=None, freq=None):
"""Construct a request string for querying TR DWE.
tickers - ticker or symbol
fields - list of fields.
date - date for a single-date query
da... | [
"def",
"construct_request",
"(",
"ticker",
",",
"fields",
"=",
"None",
",",
"date",
"=",
"None",
",",
"date_from",
"=",
"None",
",",
"date_to",
"=",
"None",
",",
"freq",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"ticker",
",",
"basestring",
")",
... | Construct a request string for querying TR DWE.
tickers - ticker or symbol
fields - list of fields.
date - date for a single-date query
date_from, date_to - date range (used only if "date" is not specified)
freq - frequency of data: daily('D'), weekly('W') ... | [
"Construct",
"a",
"request",
"string",
"for",
"querying",
"TR",
"DWE",
"."
] | 15d2adac1c83501715db1542373fa8428542816e | https://github.com/vfilimonov/pydatastream/blob/15d2adac1c83501715db1542373fa8428542816e/pydatastream/pydatastream.py#L413-L462 | train |
vfilimonov/pydatastream | pydatastream/pydatastream.py | Datastream.fetch | def fetch(self, tickers, fields=None, date=None, date_from=None, date_to=None,
freq='D', only_data=True, static=False):
"""Fetch data from TR DWE.
tickers - ticker or list of tickers
fields - list of fields.
date - date for a single-date query
date_... | python | def fetch(self, tickers, fields=None, date=None, date_from=None, date_to=None,
freq='D', only_data=True, static=False):
"""Fetch data from TR DWE.
tickers - ticker or list of tickers
fields - list of fields.
date - date for a single-date query
date_... | [
"def",
"fetch",
"(",
"self",
",",
"tickers",
",",
"fields",
"=",
"None",
",",
"date",
"=",
"None",
",",
"date_from",
"=",
"None",
",",
"date_to",
"=",
"None",
",",
"freq",
"=",
"'D'",
",",
"only_data",
"=",
"True",
",",
"static",
"=",
"False",
")",... | Fetch data from TR DWE.
tickers - ticker or list of tickers
fields - list of fields.
date - date for a single-date query
date_from, date_to - date range (used only if "date" is not specified)
freq - frequency of data: daily('D'), weekly('W') or monthly('M')... | [
"Fetch",
"data",
"from",
"TR",
"DWE",
"."
] | 15d2adac1c83501715db1542373fa8428542816e | https://github.com/vfilimonov/pydatastream/blob/15d2adac1c83501715db1542373fa8428542816e/pydatastream/pydatastream.py#L465-L525 | train |
vfilimonov/pydatastream | pydatastream/pydatastream.py | Datastream.get_OHLCV | def get_OHLCV(self, ticker, date=None, date_from=None, date_to=None):
"""Get Open, High, Low, Close prices and daily Volume for a given ticker.
ticker - ticker or symbol
date - date for a single-date query
date_from, date_to - date range (used only if "date" is not specifie... | python | def get_OHLCV(self, ticker, date=None, date_from=None, date_to=None):
"""Get Open, High, Low, Close prices and daily Volume for a given ticker.
ticker - ticker or symbol
date - date for a single-date query
date_from, date_to - date range (used only if "date" is not specifie... | [
"def",
"get_OHLCV",
"(",
"self",
",",
"ticker",
",",
"date",
"=",
"None",
",",
"date_from",
"=",
"None",
",",
"date_to",
"=",
"None",
")",
":",
"data",
",",
"meta",
"=",
"self",
".",
"fetch",
"(",
"ticker",
"+",
"\"~OHLCV\"",
",",
"None",
",",
"dat... | Get Open, High, Low, Close prices and daily Volume for a given ticker.
ticker - ticker or symbol
date - date for a single-date query
date_from, date_to - date range (used only if "date" is not specified)
Returns pandas.Dataframe with data. If error occurs, then it is pr... | [
"Get",
"Open",
"High",
"Low",
"Close",
"prices",
"and",
"daily",
"Volume",
"for",
"a",
"given",
"ticker",
"."
] | 15d2adac1c83501715db1542373fa8428542816e | https://github.com/vfilimonov/pydatastream/blob/15d2adac1c83501715db1542373fa8428542816e/pydatastream/pydatastream.py#L528-L540 | train |
vfilimonov/pydatastream | pydatastream/pydatastream.py | Datastream.get_constituents | def get_constituents(self, index_ticker, date=None, only_list=False):
""" Get a list of all constituents of a given index.
index_ticker - Datastream ticker for index
date - date for which list should be retrieved (if None then
list of present constitue... | python | def get_constituents(self, index_ticker, date=None, only_list=False):
""" Get a list of all constituents of a given index.
index_ticker - Datastream ticker for index
date - date for which list should be retrieved (if None then
list of present constitue... | [
"def",
"get_constituents",
"(",
"self",
",",
"index_ticker",
",",
"date",
"=",
"None",
",",
"only_list",
"=",
"False",
")",
":",
"if",
"date",
"is",
"not",
"None",
":",
"str_date",
"=",
"pd",
".",
"to_datetime",
"(",
"date",
")",
".",
"strftime",
"(",
... | Get a list of all constituents of a given index.
index_ticker - Datastream ticker for index
date - date for which list should be retrieved (if None then
list of present constituents is retrieved)
only_list - request only list of symbols. By defa... | [
"Get",
"a",
"list",
"of",
"all",
"constituents",
"of",
"a",
"given",
"index",
"."
] | 15d2adac1c83501715db1542373fa8428542816e | https://github.com/vfilimonov/pydatastream/blob/15d2adac1c83501715db1542373fa8428542816e/pydatastream/pydatastream.py#L571-L595 | train |
crs4/hl7apy | hl7apy/__init__.py | check_encoding_chars | def check_encoding_chars(encoding_chars):
"""
Validate the given encoding chars
:type encoding_chars: ``dict``
:param encoding_chars: the encoding chars (see :func:`hl7apy.set_default_encoding_chars`)
:raises: :exc:`hl7apy.exceptions.InvalidEncodingChars` if the given encoding chars are not valid
... | python | def check_encoding_chars(encoding_chars):
"""
Validate the given encoding chars
:type encoding_chars: ``dict``
:param encoding_chars: the encoding chars (see :func:`hl7apy.set_default_encoding_chars`)
:raises: :exc:`hl7apy.exceptions.InvalidEncodingChars` if the given encoding chars are not valid
... | [
"def",
"check_encoding_chars",
"(",
"encoding_chars",
")",
":",
"if",
"not",
"isinstance",
"(",
"encoding_chars",
",",
"collections",
".",
"MutableMapping",
")",
":",
"raise",
"InvalidEncodingChars",
"required",
"=",
"{",
"'FIELD'",
",",
"'COMPONENT'",
",",
"'SUBC... | Validate the given encoding chars
:type encoding_chars: ``dict``
:param encoding_chars: the encoding chars (see :func:`hl7apy.set_default_encoding_chars`)
:raises: :exc:`hl7apy.exceptions.InvalidEncodingChars` if the given encoding chars are not valid | [
"Validate",
"the",
"given",
"encoding",
"chars"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/__init__.py#L46-L63 | train |
crs4/hl7apy | hl7apy/__init__.py | check_validation_level | def check_validation_level(validation_level):
"""
Validate the given validation level
:type validation_level: ``int``
:param validation_level: validation level (see :class:`hl7apy.consts.VALIDATION_LEVEL`)
:raises: :exc:`hl7apy.exceptions.UnknownValidationLevel` if the given validation level is uns... | python | def check_validation_level(validation_level):
"""
Validate the given validation level
:type validation_level: ``int``
:param validation_level: validation level (see :class:`hl7apy.consts.VALIDATION_LEVEL`)
:raises: :exc:`hl7apy.exceptions.UnknownValidationLevel` if the given validation level is uns... | [
"def",
"check_validation_level",
"(",
"validation_level",
")",
":",
"if",
"validation_level",
"not",
"in",
"(",
"VALIDATION_LEVEL",
".",
"QUIET",
",",
"VALIDATION_LEVEL",
".",
"STRICT",
",",
"VALIDATION_LEVEL",
".",
"TOLERANT",
")",
":",
"raise",
"UnknownValidationL... | Validate the given validation level
:type validation_level: ``int``
:param validation_level: validation level (see :class:`hl7apy.consts.VALIDATION_LEVEL`)
:raises: :exc:`hl7apy.exceptions.UnknownValidationLevel` if the given validation level is unsupported | [
"Validate",
"the",
"given",
"validation",
"level"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/__init__.py#L66-L75 | train |
crs4/hl7apy | hl7apy/__init__.py | load_library | def load_library(version):
"""
Load the correct module according to the version
:type version: ``str``
:param version: the version of the library to be loaded (e.g. '2.6')
:rtype: module object
"""
check_version(version)
module_name = SUPPORTED_LIBRARIES[version]
lib = sys.modules.g... | python | def load_library(version):
"""
Load the correct module according to the version
:type version: ``str``
:param version: the version of the library to be loaded (e.g. '2.6')
:rtype: module object
"""
check_version(version)
module_name = SUPPORTED_LIBRARIES[version]
lib = sys.modules.g... | [
"def",
"load_library",
"(",
"version",
")",
":",
"check_version",
"(",
"version",
")",
"module_name",
"=",
"SUPPORTED_LIBRARIES",
"[",
"version",
"]",
"lib",
"=",
"sys",
".",
"modules",
".",
"get",
"(",
"module_name",
")",
"if",
"lib",
"is",
"None",
":",
... | Load the correct module according to the version
:type version: ``str``
:param version: the version of the library to be loaded (e.g. '2.6')
:rtype: module object | [
"Load",
"the",
"correct",
"module",
"according",
"to",
"the",
"version"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/__init__.py#L223-L236 | train |
crs4/hl7apy | hl7apy/__init__.py | load_reference | def load_reference(name, element_type, version):
"""
Look for an element of the given type, name and version and return its reference structure
:type element_type: ``str``
:param element_type: the element type to look for (e.g. 'Segment')
:type name: ``str``
:param name: the element name to loo... | python | def load_reference(name, element_type, version):
"""
Look for an element of the given type, name and version and return its reference structure
:type element_type: ``str``
:param element_type: the element type to look for (e.g. 'Segment')
:type name: ``str``
:param name: the element name to loo... | [
"def",
"load_reference",
"(",
"name",
",",
"element_type",
",",
"version",
")",
":",
"lib",
"=",
"load_library",
"(",
"version",
")",
"ref",
"=",
"lib",
".",
"get",
"(",
"name",
",",
"element_type",
")",
"return",
"ref"
] | Look for an element of the given type, name and version and return its reference structure
:type element_type: ``str``
:param element_type: the element type to look for (e.g. 'Segment')
:type name: ``str``
:param name: the element name to look for (e.g. 'MSH')
:type version: ``str``
:param vers... | [
"Look",
"for",
"an",
"element",
"of",
"the",
"given",
"type",
"name",
"and",
"version",
"and",
"return",
"its",
"reference",
"structure"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/__init__.py#L239-L281 | train |
crs4/hl7apy | hl7apy/__init__.py | find_reference | def find_reference(name, element_types, version):
"""
Look for an element of the given name and version into the given types and return its reference structure
:type name: ``str``
:param name: the element name to look for (e.g. 'MSH')
:type types: ``list`` or ``tuple``
:param types: the element... | python | def find_reference(name, element_types, version):
"""
Look for an element of the given name and version into the given types and return its reference structure
:type name: ``str``
:param name: the element name to look for (e.g. 'MSH')
:type types: ``list`` or ``tuple``
:param types: the element... | [
"def",
"find_reference",
"(",
"name",
",",
"element_types",
",",
"version",
")",
":",
"lib",
"=",
"load_library",
"(",
"version",
")",
"ref",
"=",
"lib",
".",
"find",
"(",
"name",
",",
"element_types",
")",
"return",
"ref"
] | Look for an element of the given name and version into the given types and return its reference structure
:type name: ``str``
:param name: the element name to look for (e.g. 'MSH')
:type types: ``list`` or ``tuple``
:param types: the element classes where to look for the element (e.g. (Group, Segment))... | [
"Look",
"for",
"an",
"element",
"of",
"the",
"given",
"name",
"and",
"version",
"into",
"the",
"given",
"types",
"and",
"return",
"its",
"reference",
"structure"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/__init__.py#L284-L313 | train |
crs4/hl7apy | hl7apy/utils.py | get_date_info | def get_date_info(value):
"""
Returns the datetime object and the format of the date in input
:type value: `str`
"""
fmt = _get_date_format(value)
dt_value = _datetime_obj_factory(value, fmt)
return dt_value, fmt | python | def get_date_info(value):
"""
Returns the datetime object and the format of the date in input
:type value: `str`
"""
fmt = _get_date_format(value)
dt_value = _datetime_obj_factory(value, fmt)
return dt_value, fmt | [
"def",
"get_date_info",
"(",
"value",
")",
":",
"fmt",
"=",
"_get_date_format",
"(",
"value",
")",
"dt_value",
"=",
"_datetime_obj_factory",
"(",
"value",
",",
"fmt",
")",
"return",
"dt_value",
",",
"fmt"
] | Returns the datetime object and the format of the date in input
:type value: `str` | [
"Returns",
"the",
"datetime",
"object",
"and",
"the",
"format",
"of",
"the",
"date",
"in",
"input"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/utils.py#L70-L78 | train |
crs4/hl7apy | hl7apy/utils.py | get_timestamp_info | def get_timestamp_info(value):
"""
Returns the datetime object, the format, the offset and the microsecond of the timestamp in input
:type value: `str`
"""
value, offset = _split_offset(value)
fmt, microsec = _get_timestamp_format(value)
dt_value = _datetime_obj_factory(value, fmt)
retu... | python | def get_timestamp_info(value):
"""
Returns the datetime object, the format, the offset and the microsecond of the timestamp in input
:type value: `str`
"""
value, offset = _split_offset(value)
fmt, microsec = _get_timestamp_format(value)
dt_value = _datetime_obj_factory(value, fmt)
retu... | [
"def",
"get_timestamp_info",
"(",
"value",
")",
":",
"value",
",",
"offset",
"=",
"_split_offset",
"(",
"value",
")",
"fmt",
",",
"microsec",
"=",
"_get_timestamp_format",
"(",
"value",
")",
"dt_value",
"=",
"_datetime_obj_factory",
"(",
"value",
",",
"fmt",
... | Returns the datetime object, the format, the offset and the microsecond of the timestamp in input
:type value: `str` | [
"Returns",
"the",
"datetime",
"object",
"the",
"format",
"the",
"offset",
"and",
"the",
"microsecond",
"of",
"the",
"timestamp",
"in",
"input"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/utils.py#L81-L90 | train |
crs4/hl7apy | hl7apy/utils.py | get_datetime_info | def get_datetime_info(value):
"""
Returns the datetime object, the format, the offset and the microsecond of the datetime in input
:type value: `str`
"""
date_value, offset = _split_offset(value)
date_format = _get_date_format(date_value[:8])
try:
timestamp_form, microsec = _get_ti... | python | def get_datetime_info(value):
"""
Returns the datetime object, the format, the offset and the microsecond of the datetime in input
:type value: `str`
"""
date_value, offset = _split_offset(value)
date_format = _get_date_format(date_value[:8])
try:
timestamp_form, microsec = _get_ti... | [
"def",
"get_datetime_info",
"(",
"value",
")",
":",
"date_value",
",",
"offset",
"=",
"_split_offset",
"(",
"value",
")",
"date_format",
"=",
"_get_date_format",
"(",
"date_value",
"[",
":",
"8",
"]",
")",
"try",
":",
"timestamp_form",
",",
"microsec",
"=",
... | Returns the datetime object, the format, the offset and the microsecond of the datetime in input
:type value: `str` | [
"Returns",
"the",
"datetime",
"object",
"the",
"format",
"the",
"offset",
"and",
"the",
"microsecond",
"of",
"the",
"datetime",
"in",
"input"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/utils.py#L93-L112 | train |
crs4/hl7apy | hl7apy/core.py | is_base_datatype | def is_base_datatype(datatype, version=None):
"""
Check if the given datatype is a base datatype of the specified version
:type datatype: ``str``
:param datatype: the datatype (e.g. ST)
:type version: ``str``
:param version: the HL7 version (e.g. 2.5)
:return: ``True`` if it is a base dat... | python | def is_base_datatype(datatype, version=None):
"""
Check if the given datatype is a base datatype of the specified version
:type datatype: ``str``
:param datatype: the datatype (e.g. ST)
:type version: ``str``
:param version: the HL7 version (e.g. 2.5)
:return: ``True`` if it is a base dat... | [
"def",
"is_base_datatype",
"(",
"datatype",
",",
"version",
"=",
"None",
")",
":",
"if",
"version",
"is",
"None",
":",
"version",
"=",
"get_default_version",
"(",
")",
"lib",
"=",
"load_library",
"(",
"version",
")",
"return",
"lib",
".",
"is_base_datatype",... | Check if the given datatype is a base datatype of the specified version
:type datatype: ``str``
:param datatype: the datatype (e.g. ST)
:type version: ``str``
:param version: the HL7 version (e.g. 2.5)
:return: ``True`` if it is a base datatype, ``False`` otherwise
>>> is_base_datatype('ST')... | [
"Check",
"if",
"the",
"given",
"datatype",
"is",
"a",
"base",
"datatype",
"of",
"the",
"specified",
"version"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L59-L79 | train |
crs4/hl7apy | hl7apy/core.py | ElementList.get_ordered_children | def get_ordered_children(self):
"""
Return the list of children ordered according to the element structure
:return: a list of :class:`Element <hl7apy.core.Element>`
"""
ordered_keys = self.element.ordered_children if self.element.ordered_children is not None else []
chil... | python | def get_ordered_children(self):
"""
Return the list of children ordered according to the element structure
:return: a list of :class:`Element <hl7apy.core.Element>`
"""
ordered_keys = self.element.ordered_children if self.element.ordered_children is not None else []
chil... | [
"def",
"get_ordered_children",
"(",
"self",
")",
":",
"ordered_keys",
"=",
"self",
".",
"element",
".",
"ordered_children",
"if",
"self",
".",
"element",
".",
"ordered_children",
"is",
"not",
"None",
"else",
"[",
"]",
"children",
"=",
"[",
"self",
".",
"in... | Return the list of children ordered according to the element structure
:return: a list of :class:`Element <hl7apy.core.Element>` | [
"Return",
"the",
"list",
"of",
"children",
"ordered",
"according",
"to",
"the",
"element",
"structure"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L210-L218 | train |
crs4/hl7apy | hl7apy/core.py | ElementList.insert | def insert(self, index, child, by_name_index=-1):
"""
Add the child at the given index
:type index: ``int``
:param index: child position
:type child: :class:`Element <hl7apy.core.Element>`
:param child: an instance of an :class:`Element <hl7apy.core.Element>` subclass
... | python | def insert(self, index, child, by_name_index=-1):
"""
Add the child at the given index
:type index: ``int``
:param index: child position
:type child: :class:`Element <hl7apy.core.Element>`
:param child: an instance of an :class:`Element <hl7apy.core.Element>` subclass
... | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"child",
",",
"by_name_index",
"=",
"-",
"1",
")",
":",
"if",
"self",
".",
"_can_add_child",
"(",
"child",
")",
":",
"try",
":",
"if",
"by_name_index",
"==",
"-",
"1",
":",
"self",
".",
"indexes",
"[... | Add the child at the given index
:type index: ``int``
:param index: child position
:type child: :class:`Element <hl7apy.core.Element>`
:param child: an instance of an :class:`Element <hl7apy.core.Element>` subclass | [
"Add",
"the",
"child",
"at",
"the",
"given",
"index"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L228-L246 | train |
crs4/hl7apy | hl7apy/core.py | ElementList.append | def append(self, child):
"""
Append the given child
:class:`Element <hl7apy.core.Element>`
:param child: an instance of an :class:`Element <hl7apy.core.Element>` subclass
"""
if self._can_add_child(child):
if self.element == child.parent:
self... | python | def append(self, child):
"""
Append the given child
:class:`Element <hl7apy.core.Element>`
:param child: an instance of an :class:`Element <hl7apy.core.Element>` subclass
"""
if self._can_add_child(child):
if self.element == child.parent:
self... | [
"def",
"append",
"(",
"self",
",",
"child",
")",
":",
"if",
"self",
".",
"_can_add_child",
"(",
"child",
")",
":",
"if",
"self",
".",
"element",
"==",
"child",
".",
"parent",
":",
"self",
".",
"_remove_from_traversal_index",
"(",
"child",
")",
"self",
... | Append the given child
:class:`Element <hl7apy.core.Element>`
:param child: an instance of an :class:`Element <hl7apy.core.Element>` subclass | [
"Append",
"the",
"given",
"child"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L248-L267 | train |
crs4/hl7apy | hl7apy/core.py | ElementList.set | def set(self, name, value, index=-1):
"""
Assign the ``value`` to the child having the given ``name`` at the ``index`` position
:type name: ``str``
:param name: the child name (e.g. PID)
:type value: an instance of :class:`Element <hl7apy.core.Element>`, a `str` or an instance ... | python | def set(self, name, value, index=-1):
"""
Assign the ``value`` to the child having the given ``name`` at the ``index`` position
:type name: ``str``
:param name: the child name (e.g. PID)
:type value: an instance of :class:`Element <hl7apy.core.Element>`, a `str` or an instance ... | [
"def",
"set",
"(",
"self",
",",
"name",
",",
"value",
",",
"index",
"=",
"-",
"1",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"ElementProxy",
")",
":",
"value",
"=",
"value",
"[",
"0",
"]",
".",
"to_er7",
"(",
")",
"name",
"=",
"name",
".... | Assign the ``value`` to the child having the given ``name`` at the ``index`` position
:type name: ``str``
:param name: the child name (e.g. PID)
:type value: an instance of :class:`Element <hl7apy.core.Element>`, a `str` or an instance of
:class:`ElementProxy <hl7apy.core.ElementPr... | [
"Assign",
"the",
"value",
"to",
"the",
"child",
"having",
"the",
"given",
"name",
"at",
"the",
"index",
"position"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L285-L329 | train |
crs4/hl7apy | hl7apy/core.py | ElementList.remove | def remove(self, child):
"""
Remove the given child from both child list and child indexes
:type child: :class:`Element <hl7apy.core.Element>`
:param child: an instance of :class:`Element <hl7apy.core.Element>` subclass
"""
try:
if self.element == child.trave... | python | def remove(self, child):
"""
Remove the given child from both child list and child indexes
:type child: :class:`Element <hl7apy.core.Element>`
:param child: an instance of :class:`Element <hl7apy.core.Element>` subclass
"""
try:
if self.element == child.trave... | [
"def",
"remove",
"(",
"self",
",",
"child",
")",
":",
"try",
":",
"if",
"self",
".",
"element",
"==",
"child",
".",
"traversal_parent",
":",
"self",
".",
"_remove_from_traversal_index",
"(",
"child",
")",
"else",
":",
"self",
".",
"_remove_from_index",
"("... | Remove the given child from both child list and child indexes
:type child: :class:`Element <hl7apy.core.Element>`
:param child: an instance of :class:`Element <hl7apy.core.Element>` subclass | [
"Remove",
"the",
"given",
"child",
"from",
"both",
"child",
"list",
"and",
"child",
"indexes"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L331-L345 | train |
crs4/hl7apy | hl7apy/core.py | ElementList.remove_by_name | def remove_by_name(self, name, index=0):
"""
Remove the child having the given name at the given position
:type name: ``str``
:param name: child name (e.g. PID)
:type index: ``int``
:param index: child index
:return: an instance of :class:`Element <hl7apy.core.... | python | def remove_by_name(self, name, index=0):
"""
Remove the child having the given name at the given position
:type name: ``str``
:param name: child name (e.g. PID)
:type index: ``int``
:param index: child index
:return: an instance of :class:`Element <hl7apy.core.... | [
"def",
"remove_by_name",
"(",
"self",
",",
"name",
",",
"index",
"=",
"0",
")",
":",
"child",
"=",
"self",
".",
"child_at_index",
"(",
"name",
",",
"index",
")",
"self",
".",
"remove",
"(",
"child",
")",
"return",
"child"
] | Remove the child having the given name at the given position
:type name: ``str``
:param name: child name (e.g. PID)
:type index: ``int``
:param index: child index
:return: an instance of :class:`Element <hl7apy.core.Element>` subclass | [
"Remove",
"the",
"child",
"having",
"the",
"given",
"name",
"at",
"the",
"given",
"position"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L347-L361 | train |
crs4/hl7apy | hl7apy/core.py | ElementList.child_at_index | def child_at_index(self, name, index):
"""
Return the child named `name` at the given index
:type name: ``str``
:param name: child name (e.g. PID)
:type index: ``int``
:param index: child index
:return: an instance of :class:`Element <hl7apy.core.Element>` subc... | python | def child_at_index(self, name, index):
"""
Return the child named `name` at the given index
:type name: ``str``
:param name: child name (e.g. PID)
:type index: ``int``
:param index: child index
:return: an instance of :class:`Element <hl7apy.core.Element>` subc... | [
"def",
"child_at_index",
"(",
"self",
",",
"name",
",",
"index",
")",
":",
"def",
"_finder",
"(",
"n",
",",
"i",
")",
":",
"try",
":",
"return",
"self",
".",
"indexes",
"[",
"n",
"]",
"[",
"i",
"]",
"except",
"(",
"KeyError",
",",
"IndexError",
"... | Return the child named `name` at the given index
:type name: ``str``
:param name: child name (e.g. PID)
:type index: ``int``
:param index: child index
:return: an instance of :class:`Element <hl7apy.core.Element>` subclass | [
"Return",
"the",
"child",
"named",
"name",
"at",
"the",
"given",
"index"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L363-L389 | train |
crs4/hl7apy | hl7apy/core.py | ElementList.create_element | def create_element(self, name, traversal_parent=False, reference=None):
"""
Create an element having the given name
:type name: ``str``
:param name: the name of the element to be created (e.g. PID)
:type traversal_parent: ``bool``
:param traversal_parent: if ``True``, t... | python | def create_element(self, name, traversal_parent=False, reference=None):
"""
Create an element having the given name
:type name: ``str``
:param name: the name of the element to be created (e.g. PID)
:type traversal_parent: ``bool``
:param traversal_parent: if ``True``, t... | [
"def",
"create_element",
"(",
"self",
",",
"name",
",",
"traversal_parent",
"=",
"False",
",",
"reference",
"=",
"None",
")",
":",
"if",
"reference",
"is",
"None",
":",
"reference",
"=",
"self",
".",
"element",
".",
"find_child_reference",
"(",
"name",
")"... | Create an element having the given name
:type name: ``str``
:param name: the name of the element to be created (e.g. PID)
:type traversal_parent: ``bool``
:param traversal_parent: if ``True``, the parent will be set as temporary for traversal purposes
:param reference: the new... | [
"Create",
"an",
"element",
"having",
"the",
"given",
"name"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L403-L433 | train |
crs4/hl7apy | hl7apy/core.py | ElementList._find_name | def _find_name(self, name):
"""
Find the reference of a child having the given name
:type name: ``str``
:param name: the child name (e.g. PID)
:return: the element structure (see :func:`load_reference <hl7apy.load_reference>`) or ``None`` if the
element has not been... | python | def _find_name(self, name):
"""
Find the reference of a child having the given name
:type name: ``str``
:param name: the child name (e.g. PID)
:return: the element structure (see :func:`load_reference <hl7apy.load_reference>`) or ``None`` if the
element has not been... | [
"def",
"_find_name",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"name",
".",
"upper",
"(",
")",
"element",
"=",
"self",
".",
"element",
".",
"find_child_reference",
"(",
"name",
")",
"return",
"element",
"[",
"'name'",
"]",
"if",
"element",
"is",... | Find the reference of a child having the given name
:type name: ``str``
:param name: the child name (e.g. PID)
:return: the element structure (see :func:`load_reference <hl7apy.load_reference>`) or ``None`` if the
element has not been found | [
"Find",
"the",
"reference",
"of",
"a",
"child",
"having",
"the",
"given",
"name"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L435-L447 | train |
crs4/hl7apy | hl7apy/core.py | ElementFinder.get_structure | def get_structure(element, reference=None):
"""
Get the element structure
:type element: :class:`Element <hl7apy.core.Element>`
:param element: element having the given reference structure
:param reference: the element structure from :func:`load_reference <hl7apy.load_reference... | python | def get_structure(element, reference=None):
"""
Get the element structure
:type element: :class:`Element <hl7apy.core.Element>`
:param element: element having the given reference structure
:param reference: the element structure from :func:`load_reference <hl7apy.load_reference... | [
"def",
"get_structure",
"(",
"element",
",",
"reference",
"=",
"None",
")",
":",
"if",
"reference",
"is",
"None",
":",
"try",
":",
"reference",
"=",
"load_reference",
"(",
"element",
".",
"name",
",",
"element",
".",
"classname",
",",
"element",
".",
"ve... | Get the element structure
:type element: :class:`Element <hl7apy.core.Element>`
:param element: element having the given reference structure
:param reference: the element structure from :func:`load_reference <hl7apy.load_reference>` or from a
message profile
:return: a dic... | [
"Get",
"the",
"element",
"structure"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L532-L551 | train |
crs4/hl7apy | hl7apy/core.py | ElementFinder._parse_structure | def _parse_structure(element, reference):
"""
Parse the given reference
:type element: :class:`Element <hl7apy.core.Element>`
:param element: element having the given reference structure
:param reference: the element structure from :func:`load_reference <hl7apy.load_reference>`... | python | def _parse_structure(element, reference):
"""
Parse the given reference
:type element: :class:`Element <hl7apy.core.Element>`
:param element: element having the given reference structure
:param reference: the element structure from :func:`load_reference <hl7apy.load_reference>`... | [
"def",
"_parse_structure",
"(",
"element",
",",
"reference",
")",
":",
"data",
"=",
"{",
"'reference'",
":",
"reference",
"}",
"content_type",
"=",
"reference",
"[",
"0",
"]",
"if",
"content_type",
"in",
"(",
"'sequence'",
",",
"'choice'",
")",
":",
"child... | Parse the given reference
:type element: :class:`Element <hl7apy.core.Element>`
:param element: element having the given reference structure
:param reference: the element structure from :func:`load_reference <hl7apy.load_reference>` or from a
message profile
:return: a dic... | [
"Parse",
"the",
"given",
"reference"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L554-L600 | train |
crs4/hl7apy | hl7apy/core.py | Message.to_mllp | def to_mllp(self, encoding_chars=None, trailing_children=False):
"""
Returns the er7 representation of the message wrapped with mllp encoding characters
:type encoding_chars: ``dict``
:param encoding_chars: a dictionary containing the encoding chars or None to use the default
... | python | def to_mllp(self, encoding_chars=None, trailing_children=False):
"""
Returns the er7 representation of the message wrapped with mllp encoding characters
:type encoding_chars: ``dict``
:param encoding_chars: a dictionary containing the encoding chars or None to use the default
... | [
"def",
"to_mllp",
"(",
"self",
",",
"encoding_chars",
"=",
"None",
",",
"trailing_children",
"=",
"False",
")",
":",
"if",
"encoding_chars",
"is",
"None",
":",
"encoding_chars",
"=",
"self",
".",
"encoding_chars",
"return",
"\"{0}{1}{2}{3}{2}\"",
".",
"format",
... | Returns the er7 representation of the message wrapped with mllp encoding characters
:type encoding_chars: ``dict``
:param encoding_chars: a dictionary containing the encoding chars or None to use the default
(see :func:`get_default_encoding_chars <hl7apy.get_default_encoding_chars>`)
... | [
"Returns",
"the",
"er7",
"representation",
"of",
"the",
"message",
"wrapped",
"with",
"mllp",
"encoding",
"characters"
] | 91be488e9274f6ec975519a1d9c17045bc91bf74 | https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L1969-L1988 | train |
playpauseandstop/Flask-And-Redis | flask_redis.py | Redis.get_app | def get_app(self):
"""Get current app from Flast stack to use.
This will allow to ensure which Redis connection to be used when
accessing Redis connection public methods via plugin.
"""
# First see to connection stack
ctx = connection_stack.top
if ctx is not None... | python | def get_app(self):
"""Get current app from Flast stack to use.
This will allow to ensure which Redis connection to be used when
accessing Redis connection public methods via plugin.
"""
# First see to connection stack
ctx = connection_stack.top
if ctx is not None... | [
"def",
"get_app",
"(",
"self",
")",
":",
"ctx",
"=",
"connection_stack",
".",
"top",
"if",
"ctx",
"is",
"not",
"None",
":",
"return",
"ctx",
".",
"app",
"if",
"self",
".",
"app",
"is",
"not",
"None",
":",
"return",
"self",
".",
"app",
"raise",
"Run... | Get current app from Flast stack to use.
This will allow to ensure which Redis connection to be used when
accessing Redis connection public methods via plugin. | [
"Get",
"current",
"app",
"from",
"Flast",
"stack",
"to",
"use",
"."
] | 878bb193ae4a8c3497f6f1ff1511a3b8c96d08b5 | https://github.com/playpauseandstop/Flask-And-Redis/blob/878bb193ae4a8c3497f6f1ff1511a3b8c96d08b5/flask_redis.py#L79-L98 | train |
playpauseandstop/Flask-And-Redis | flask_redis.py | Redis.init_app | def init_app(self, app, config_prefix=None):
"""
Actual method to read redis settings from app configuration, initialize
Redis connection and copy all public connection methods to current
instance.
:param app: :class:`flask.Flask` application instance.
:param config_pref... | python | def init_app(self, app, config_prefix=None):
"""
Actual method to read redis settings from app configuration, initialize
Redis connection and copy all public connection methods to current
instance.
:param app: :class:`flask.Flask` application instance.
:param config_pref... | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"config_prefix",
"=",
"None",
")",
":",
"if",
"'redis'",
"not",
"in",
"app",
".",
"extensions",
":",
"app",
".",
"extensions",
"[",
"'redis'",
"]",
"=",
"{",
"}",
"self",
".",
"config_prefix",
"=",
"co... | Actual method to read redis settings from app configuration, initialize
Redis connection and copy all public connection methods to current
instance.
:param app: :class:`flask.Flask` application instance.
:param config_prefix: Config prefix to use. By default: ``REDIS`` | [
"Actual",
"method",
"to",
"read",
"redis",
"settings",
"from",
"app",
"configuration",
"initialize",
"Redis",
"connection",
"and",
"copy",
"all",
"public",
"connection",
"methods",
"to",
"current",
"instance",
"."
] | 878bb193ae4a8c3497f6f1ff1511a3b8c96d08b5 | https://github.com/playpauseandstop/Flask-And-Redis/blob/878bb193ae4a8c3497f6f1ff1511a3b8c96d08b5/flask_redis.py#L100-L170 | train |
playpauseandstop/Flask-And-Redis | flask_redis.py | Redis._build_connection_args | def _build_connection_args(self, klass):
"""Read connection args spec, exclude self from list of possible
:param klass: Redis connection class.
"""
bases = [base for base in klass.__bases__ if base is not object]
all_args = []
for cls in [klass] + bases:
try:... | python | def _build_connection_args(self, klass):
"""Read connection args spec, exclude self from list of possible
:param klass: Redis connection class.
"""
bases = [base for base in klass.__bases__ if base is not object]
all_args = []
for cls in [klass] + bases:
try:... | [
"def",
"_build_connection_args",
"(",
"self",
",",
"klass",
")",
":",
"bases",
"=",
"[",
"base",
"for",
"base",
"in",
"klass",
".",
"__bases__",
"if",
"base",
"is",
"not",
"object",
"]",
"all_args",
"=",
"[",
"]",
"for",
"cls",
"in",
"[",
"klass",
"]... | Read connection args spec, exclude self from list of possible
:param klass: Redis connection class. | [
"Read",
"connection",
"args",
"spec",
"exclude",
"self",
"from",
"list",
"of",
"possible"
] | 878bb193ae4a8c3497f6f1ff1511a3b8c96d08b5 | https://github.com/playpauseandstop/Flask-And-Redis/blob/878bb193ae4a8c3497f6f1ff1511a3b8c96d08b5/flask_redis.py#L172-L189 | train |
playpauseandstop/Flask-And-Redis | flask_redis.py | Redis._include_public_methods | def _include_public_methods(self, connection):
"""Include public methods from Redis connection to current instance.
:param connection: Redis connection instance.
"""
for attr in dir(connection):
value = getattr(connection, attr)
if attr.startswith('_') or not cal... | python | def _include_public_methods(self, connection):
"""Include public methods from Redis connection to current instance.
:param connection: Redis connection instance.
"""
for attr in dir(connection):
value = getattr(connection, attr)
if attr.startswith('_') or not cal... | [
"def",
"_include_public_methods",
"(",
"self",
",",
"connection",
")",
":",
"for",
"attr",
"in",
"dir",
"(",
"connection",
")",
":",
"value",
"=",
"getattr",
"(",
"connection",
",",
"attr",
")",
"if",
"attr",
".",
"startswith",
"(",
"'_'",
")",
"or",
"... | Include public methods from Redis connection to current instance.
:param connection: Redis connection instance. | [
"Include",
"public",
"methods",
"from",
"Redis",
"connection",
"to",
"current",
"instance",
"."
] | 878bb193ae4a8c3497f6f1ff1511a3b8c96d08b5 | https://github.com/playpauseandstop/Flask-And-Redis/blob/878bb193ae4a8c3497f6f1ff1511a3b8c96d08b5/flask_redis.py#L191-L200 | train |
JonathonReinhart/scuba | scuba/__main__.py | ScubaDive.prepare | def prepare(self):
'''Prepare to run the docker command'''
self.__make_scubadir()
if self.is_remote_docker:
'''
Docker is running remotely (e.g. boot2docker on OSX).
We don't need to do any user setup whatsoever.
TODO: For now, remote instances w... | python | def prepare(self):
'''Prepare to run the docker command'''
self.__make_scubadir()
if self.is_remote_docker:
'''
Docker is running remotely (e.g. boot2docker on OSX).
We don't need to do any user setup whatsoever.
TODO: For now, remote instances w... | [
"def",
"prepare",
"(",
"self",
")",
":",
"self",
".",
"__make_scubadir",
"(",
")",
"if",
"self",
".",
"is_remote_docker",
":",
"raise",
"ScubaError",
"(",
"'Remote docker not supported (DOCKER_HOST is set)'",
")",
"self",
".",
"__setup_native_run",
"(",
")",
"self... | Prepare to run the docker command | [
"Prepare",
"to",
"run",
"the",
"docker",
"command"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L119-L139 | train |
JonathonReinhart/scuba | scuba/__main__.py | ScubaDive.add_env | def add_env(self, name, val):
'''Add an environment variable to the docker run invocation
'''
if name in self.env_vars:
raise KeyError(name)
self.env_vars[name] = val | python | def add_env(self, name, val):
'''Add an environment variable to the docker run invocation
'''
if name in self.env_vars:
raise KeyError(name)
self.env_vars[name] = val | [
"def",
"add_env",
"(",
"self",
",",
"name",
",",
"val",
")",
":",
"if",
"name",
"in",
"self",
".",
"env_vars",
":",
"raise",
"KeyError",
"(",
"name",
")",
"self",
".",
"env_vars",
"[",
"name",
"]",
"=",
"val"
] | Add an environment variable to the docker run invocation | [
"Add",
"an",
"environment",
"variable",
"to",
"the",
"docker",
"run",
"invocation"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L176-L181 | train |
JonathonReinhart/scuba | scuba/__main__.py | ScubaDive.__locate_scubainit | def __locate_scubainit(self):
'''Determine path to scubainit binary
'''
pkg_path = os.path.dirname(__file__)
self.scubainit_path = os.path.join(pkg_path, 'scubainit')
if not os.path.isfile(self.scubainit_path):
raise ScubaError('scubainit not found at "{}"'.format(se... | python | def __locate_scubainit(self):
'''Determine path to scubainit binary
'''
pkg_path = os.path.dirname(__file__)
self.scubainit_path = os.path.join(pkg_path, 'scubainit')
if not os.path.isfile(self.scubainit_path):
raise ScubaError('scubainit not found at "{}"'.format(se... | [
"def",
"__locate_scubainit",
"(",
"self",
")",
":",
"pkg_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"self",
".",
"scubainit_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"pkg_path",
",",
"'scubainit'",
")",
"if",
"not",
"os... | Determine path to scubainit binary | [
"Determine",
"path",
"to",
"scubainit",
"binary"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L198-L205 | train |
JonathonReinhart/scuba | scuba/__main__.py | ScubaDive.__load_config | def __load_config(self):
'''Find and load .scuba.yml
'''
# top_path is where .scuba.yml is found, and becomes the top of our bind mount.
# top_rel is the relative path from top_path to the current working directory,
# and is where we'll set the working directory in the container... | python | def __load_config(self):
'''Find and load .scuba.yml
'''
# top_path is where .scuba.yml is found, and becomes the top of our bind mount.
# top_rel is the relative path from top_path to the current working directory,
# and is where we'll set the working directory in the container... | [
"def",
"__load_config",
"(",
"self",
")",
":",
"try",
":",
"top_path",
",",
"top_rel",
"=",
"find_config",
"(",
")",
"self",
".",
"config",
"=",
"load_config",
"(",
"os",
".",
"path",
".",
"join",
"(",
"top_path",
",",
"SCUBA_YML",
")",
")",
"except",
... | Find and load .scuba.yml | [
"Find",
"and",
"load",
".",
"scuba",
".",
"yml"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L208-L235 | train |
JonathonReinhart/scuba | scuba/__main__.py | ScubaDive.__make_scubadir | def __make_scubadir(self):
'''Make temp directory where all ancillary files are bind-mounted
'''
self.__scubadir_hostpath = tempfile.mkdtemp(prefix='scubadir')
self.__scubadir_contpath = '/.scuba'
self.add_volume(self.__scubadir_hostpath, self.__scubadir_contpath) | python | def __make_scubadir(self):
'''Make temp directory where all ancillary files are bind-mounted
'''
self.__scubadir_hostpath = tempfile.mkdtemp(prefix='scubadir')
self.__scubadir_contpath = '/.scuba'
self.add_volume(self.__scubadir_hostpath, self.__scubadir_contpath) | [
"def",
"__make_scubadir",
"(",
"self",
")",
":",
"self",
".",
"__scubadir_hostpath",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"prefix",
"=",
"'scubadir'",
")",
"self",
".",
"__scubadir_contpath",
"=",
"'/.scuba'",
"self",
".",
"add_volume",
"(",
"self",
".",
"_... | Make temp directory where all ancillary files are bind-mounted | [
"Make",
"temp",
"directory",
"where",
"all",
"ancillary",
"files",
"are",
"bind",
"-",
"mounted"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L237-L242 | train |
JonathonReinhart/scuba | scuba/__main__.py | ScubaDive.__setup_native_run | def __setup_native_run(self):
# These options are appended to mounted volume arguments
# NOTE: This tells Docker to re-label the directory for compatibility
# with SELinux. See `man docker-run` for more information.
self.vol_opts = ['z']
# Pass variables to scubainit
se... | python | def __setup_native_run(self):
# These options are appended to mounted volume arguments
# NOTE: This tells Docker to re-label the directory for compatibility
# with SELinux. See `man docker-run` for more information.
self.vol_opts = ['z']
# Pass variables to scubainit
se... | [
"def",
"__setup_native_run",
"(",
"self",
")",
":",
"self",
".",
"vol_opts",
"=",
"[",
"'z'",
"]",
"self",
".",
"add_env",
"(",
"'SCUBAINIT_UMASK'",
",",
"'{:04o}'",
".",
"format",
"(",
"get_umask",
"(",
")",
")",
")",
"if",
"not",
"self",
".",
"as_roo... | Normally, if the user provides no command to "docker run", the image's
default CMD is run. Because we set the entrypiont, scuba must emulate the
default behavior itself. | [
"Normally",
"if",
"the",
"user",
"provides",
"no",
"command",
"to",
"docker",
"run",
"the",
"image",
"s",
"default",
"CMD",
"is",
"run",
".",
"Because",
"we",
"set",
"the",
"entrypiont",
"scuba",
"must",
"emulate",
"the",
"default",
"behavior",
"itself",
"... | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L244-L326 | train |
JonathonReinhart/scuba | scuba/__main__.py | ScubaDive.open_scubadir_file | def open_scubadir_file(self, name, mode):
'''Opens a file in the 'scubadir'
This file will automatically be bind-mounted into the container,
at a path given by the 'container_path' property on the returned file object.
'''
path = os.path.join(self.__scubadir_hostpath, name)
... | python | def open_scubadir_file(self, name, mode):
'''Opens a file in the 'scubadir'
This file will automatically be bind-mounted into the container,
at a path given by the 'container_path' property on the returned file object.
'''
path = os.path.join(self.__scubadir_hostpath, name)
... | [
"def",
"open_scubadir_file",
"(",
"self",
",",
"name",
",",
"mode",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"__scubadir_hostpath",
",",
"name",
")",
"assert",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",... | Opens a file in the 'scubadir'
This file will automatically be bind-mounted into the container,
at a path given by the 'container_path' property on the returned file object. | [
"Opens",
"a",
"file",
"in",
"the",
"scubadir"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L330-L344 | train |
JonathonReinhart/scuba | scuba/__main__.py | ScubaDive.copy_scubadir_file | def copy_scubadir_file(self, name, source):
'''Copies source into the scubadir
Returns the container-path of the copied file
'''
dest = os.path.join(self.__scubadir_hostpath, name)
assert not os.path.exists(dest)
shutil.copy2(source, dest)
return os.path.join(se... | python | def copy_scubadir_file(self, name, source):
'''Copies source into the scubadir
Returns the container-path of the copied file
'''
dest = os.path.join(self.__scubadir_hostpath, name)
assert not os.path.exists(dest)
shutil.copy2(source, dest)
return os.path.join(se... | [
"def",
"copy_scubadir_file",
"(",
"self",
",",
"name",
",",
"source",
")",
":",
"dest",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"__scubadir_hostpath",
",",
"name",
")",
"assert",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"dest",
")... | Copies source into the scubadir
Returns the container-path of the copied file | [
"Copies",
"source",
"into",
"the",
"scubadir"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L347-L356 | train |
JonathonReinhart/scuba | scuba/utils.py | format_cmdline | def format_cmdline(args, maxwidth=80):
'''Format args into a shell-quoted command line.
The result will be wrapped to maxwidth characters where possible,
not breaking a single long argument.
'''
# Leave room for the space and backslash at the end of each line
maxwidth -= 2
def lines():
... | python | def format_cmdline(args, maxwidth=80):
'''Format args into a shell-quoted command line.
The result will be wrapped to maxwidth characters where possible,
not breaking a single long argument.
'''
# Leave room for the space and backslash at the end of each line
maxwidth -= 2
def lines():
... | [
"def",
"format_cmdline",
"(",
"args",
",",
"maxwidth",
"=",
"80",
")",
":",
"maxwidth",
"-=",
"2",
"def",
"lines",
"(",
")",
":",
"line",
"=",
"''",
"for",
"a",
"in",
"(",
"shell_quote",
"(",
"a",
")",
"for",
"a",
"in",
"args",
")",
":",
"if",
... | Format args into a shell-quoted command line.
The result will be wrapped to maxwidth characters where possible,
not breaking a single long argument. | [
"Format",
"args",
"into",
"a",
"shell",
"-",
"quoted",
"command",
"line",
"."
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/utils.py#L13-L41 | train |
JonathonReinhart/scuba | scuba/utils.py | parse_env_var | def parse_env_var(s):
"""Parse an environment variable string
Returns a key-value tuple
Apply the same logic as `docker run -e`:
"If the operator names an environment variable without specifying a value,
then the current value of the named variable is propagated into the
container's environmen... | python | def parse_env_var(s):
"""Parse an environment variable string
Returns a key-value tuple
Apply the same logic as `docker run -e`:
"If the operator names an environment variable without specifying a value,
then the current value of the named variable is propagated into the
container's environmen... | [
"def",
"parse_env_var",
"(",
"s",
")",
":",
"parts",
"=",
"s",
".",
"split",
"(",
"'='",
",",
"1",
")",
"if",
"len",
"(",
"parts",
")",
"==",
"2",
":",
"k",
",",
"v",
"=",
"parts",
"return",
"(",
"k",
",",
"v",
")",
"k",
"=",
"parts",
"[",
... | Parse an environment variable string
Returns a key-value tuple
Apply the same logic as `docker run -e`:
"If the operator names an environment variable without specifying a value,
then the current value of the named variable is propagated into the
container's environment | [
"Parse",
"an",
"environment",
"variable",
"string"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/utils.py#L53-L69 | train |
JonathonReinhart/scuba | scuba/dockerutil.py | __wrap_docker_exec | def __wrap_docker_exec(func):
'''Wrap a function to raise DockerExecuteError on ENOENT'''
def call(*args, **kwargs):
try:
return func(*args, **kwargs)
except OSError as e:
if e.errno == errno.ENOENT:
raise DockerExecuteError('Failed to execute docker. Is i... | python | def __wrap_docker_exec(func):
'''Wrap a function to raise DockerExecuteError on ENOENT'''
def call(*args, **kwargs):
try:
return func(*args, **kwargs)
except OSError as e:
if e.errno == errno.ENOENT:
raise DockerExecuteError('Failed to execute docker. Is i... | [
"def",
"__wrap_docker_exec",
"(",
"func",
")",
":",
"def",
"call",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"try",
":",
"return",
"func",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"e",
".",
"er... | Wrap a function to raise DockerExecuteError on ENOENT | [
"Wrap",
"a",
"function",
"to",
"raise",
"DockerExecuteError",
"on",
"ENOENT"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/dockerutil.py#L19-L28 | train |
JonathonReinhart/scuba | scuba/dockerutil.py | docker_inspect | def docker_inspect(image):
'''Inspects a docker image
Returns: Parsed JSON data
'''
args = ['docker', 'inspect', '--type', 'image', image]
p = Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
stdout, stderr = p.communicate()
stdout = stdout.decode('utf-8')
stderr = stder... | python | def docker_inspect(image):
'''Inspects a docker image
Returns: Parsed JSON data
'''
args = ['docker', 'inspect', '--type', 'image', image]
p = Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
stdout, stderr = p.communicate()
stdout = stdout.decode('utf-8')
stderr = stder... | [
"def",
"docker_inspect",
"(",
"image",
")",
":",
"args",
"=",
"[",
"'docker'",
",",
"'inspect'",
",",
"'--type'",
",",
"'image'",
",",
"image",
"]",
"p",
"=",
"Popen",
"(",
"args",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"s... | Inspects a docker image
Returns: Parsed JSON data | [
"Inspects",
"a",
"docker",
"image"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/dockerutil.py#L34-L51 | train |
JonathonReinhart/scuba | scuba/dockerutil.py | docker_pull | def docker_pull(image):
'''Pulls an image'''
args = ['docker', 'pull', image]
# If this fails, the default docker stdout/stderr looks good to the user.
ret = call(args)
if ret != 0:
raise DockerError('Failed to pull image "{}"'.format(image)) | python | def docker_pull(image):
'''Pulls an image'''
args = ['docker', 'pull', image]
# If this fails, the default docker stdout/stderr looks good to the user.
ret = call(args)
if ret != 0:
raise DockerError('Failed to pull image "{}"'.format(image)) | [
"def",
"docker_pull",
"(",
"image",
")",
":",
"args",
"=",
"[",
"'docker'",
",",
"'pull'",
",",
"image",
"]",
"ret",
"=",
"call",
"(",
"args",
")",
"if",
"ret",
"!=",
"0",
":",
"raise",
"DockerError",
"(",
"'Failed to pull image \"{}\"'",
".",
"format",
... | Pulls an image | [
"Pulls",
"an",
"image"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/dockerutil.py#L53-L60 | train |
JonathonReinhart/scuba | scuba/dockerutil.py | get_image_command | def get_image_command(image):
'''Gets the default command for an image'''
info = docker_inspect_or_pull(image)
try:
return info['Config']['Cmd']
except KeyError as ke:
raise DockerError('Failed to inspect image: JSON result missing key {}'.format(ke)) | python | def get_image_command(image):
'''Gets the default command for an image'''
info = docker_inspect_or_pull(image)
try:
return info['Config']['Cmd']
except KeyError as ke:
raise DockerError('Failed to inspect image: JSON result missing key {}'.format(ke)) | [
"def",
"get_image_command",
"(",
"image",
")",
":",
"info",
"=",
"docker_inspect_or_pull",
"(",
"image",
")",
"try",
":",
"return",
"info",
"[",
"'Config'",
"]",
"[",
"'Cmd'",
"]",
"except",
"KeyError",
"as",
"ke",
":",
"raise",
"DockerError",
"(",
"'Faile... | Gets the default command for an image | [
"Gets",
"the",
"default",
"command",
"for",
"an",
"image"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/dockerutil.py#L71-L77 | train |
JonathonReinhart/scuba | scuba/dockerutil.py | get_image_entrypoint | def get_image_entrypoint(image):
'''Gets the image entrypoint'''
info = docker_inspect_or_pull(image)
try:
return info['Config']['Entrypoint']
except KeyError as ke:
raise DockerError('Failed to inspect image: JSON result missing key {}'.format(ke)) | python | def get_image_entrypoint(image):
'''Gets the image entrypoint'''
info = docker_inspect_or_pull(image)
try:
return info['Config']['Entrypoint']
except KeyError as ke:
raise DockerError('Failed to inspect image: JSON result missing key {}'.format(ke)) | [
"def",
"get_image_entrypoint",
"(",
"image",
")",
":",
"info",
"=",
"docker_inspect_or_pull",
"(",
"image",
")",
"try",
":",
"return",
"info",
"[",
"'Config'",
"]",
"[",
"'Entrypoint'",
"]",
"except",
"KeyError",
"as",
"ke",
":",
"raise",
"DockerError",
"(",... | Gets the image entrypoint | [
"Gets",
"the",
"image",
"entrypoint"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/dockerutil.py#L79-L85 | train |
JonathonReinhart/scuba | scuba/dockerutil.py | make_vol_opt | def make_vol_opt(hostdir, contdir, options=None):
'''Generate a docker volume option'''
vol = '--volume={}:{}'.format(hostdir, contdir)
if options != None:
if isinstance(options, str):
options = (options,)
vol += ':' + ','.join(options)
return vol | python | def make_vol_opt(hostdir, contdir, options=None):
'''Generate a docker volume option'''
vol = '--volume={}:{}'.format(hostdir, contdir)
if options != None:
if isinstance(options, str):
options = (options,)
vol += ':' + ','.join(options)
return vol | [
"def",
"make_vol_opt",
"(",
"hostdir",
",",
"contdir",
",",
"options",
"=",
"None",
")",
":",
"vol",
"=",
"'--volume={}:{}'",
".",
"format",
"(",
"hostdir",
",",
"contdir",
")",
"if",
"options",
"!=",
"None",
":",
"if",
"isinstance",
"(",
"options",
",",... | Generate a docker volume option | [
"Generate",
"a",
"docker",
"volume",
"option"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/dockerutil.py#L88-L95 | train |
JonathonReinhart/scuba | scuba/config.py | find_config | def find_config():
'''Search up the diretcory hierarchy for .scuba.yml
Returns: path, rel on success, or None if not found
path The absolute path of the directory where .scuba.yml was found
rel The relative path from the directory where .scuba.yml was found
to the current... | python | def find_config():
'''Search up the diretcory hierarchy for .scuba.yml
Returns: path, rel on success, or None if not found
path The absolute path of the directory where .scuba.yml was found
rel The relative path from the directory where .scuba.yml was found
to the current... | [
"def",
"find_config",
"(",
")",
":",
"cross_fs",
"=",
"'SCUBA_DISCOVERY_ACROSS_FILESYSTEM'",
"in",
"os",
".",
"environ",
"path",
"=",
"os",
".",
"getcwd",
"(",
")",
"rel",
"=",
"''",
"while",
"True",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"o... | Search up the diretcory hierarchy for .scuba.yml
Returns: path, rel on success, or None if not found
path The absolute path of the directory where .scuba.yml was found
rel The relative path from the directory where .scuba.yml was found
to the current directory | [
"Search",
"up",
"the",
"diretcory",
"hierarchy",
"for",
".",
"scuba",
".",
"yml"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/config.py#L74-L101 | train |
JonathonReinhart/scuba | scuba/config.py | _process_script_node | def _process_script_node(node, name):
'''Process a script-type node
This handles nodes that follow the *Common script schema*,
as outlined in doc/yaml-reference.md.
'''
if isinstance(node, basestring):
# The script is just the text itself
return [node]
if isinstance(node, dict... | python | def _process_script_node(node, name):
'''Process a script-type node
This handles nodes that follow the *Common script schema*,
as outlined in doc/yaml-reference.md.
'''
if isinstance(node, basestring):
# The script is just the text itself
return [node]
if isinstance(node, dict... | [
"def",
"_process_script_node",
"(",
"node",
",",
"name",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"basestring",
")",
":",
"return",
"[",
"node",
"]",
"if",
"isinstance",
"(",
"node",
",",
"dict",
")",
":",
"script",
"=",
"node",
".",
"get",
"(... | Process a script-type node
This handles nodes that follow the *Common script schema*,
as outlined in doc/yaml-reference.md. | [
"Process",
"a",
"script",
"-",
"type",
"node"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/config.py#L104-L129 | train |
JonathonReinhart/scuba | scuba/config.py | ScubaConfig.process_command | def process_command(self, command):
'''Processes a user command using aliases
Arguments:
command A user command list (e.g. argv)
Returns: A ScubaContext object with the following attributes:
script: a list of command line strings
image: the docker image ... | python | def process_command(self, command):
'''Processes a user command using aliases
Arguments:
command A user command list (e.g. argv)
Returns: A ScubaContext object with the following attributes:
script: a list of command line strings
image: the docker image ... | [
"def",
"process_command",
"(",
"self",
",",
"command",
")",
":",
"result",
"=",
"ScubaContext",
"(",
")",
"result",
".",
"script",
"=",
"None",
"result",
".",
"image",
"=",
"self",
".",
"image",
"result",
".",
"entrypoint",
"=",
"self",
".",
"entrypoint"... | Processes a user command using aliases
Arguments:
command A user command list (e.g. argv)
Returns: A ScubaContext object with the following attributes:
script: a list of command line strings
image: the docker image name to use | [
"Processes",
"a",
"user",
"command",
"using",
"aliases"
] | 0244c81ec482d3c60202028bc075621447bc3ad1 | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/config.py#L276-L324 | train |
chrislim2888/IP2Location-Python | IP2Location.py | IP2Location.open | def open(self, filename):
''' Opens a database file '''
# Ensure old file is closed before opening a new one
self.close()
self._f = open(filename, 'rb')
self._dbtype = struct.unpack('B', self._f.read(1))[0]
self._dbcolumn = struct.unpack('B', self._f.read(1))[0]
... | python | def open(self, filename):
''' Opens a database file '''
# Ensure old file is closed before opening a new one
self.close()
self._f = open(filename, 'rb')
self._dbtype = struct.unpack('B', self._f.read(1))[0]
self._dbcolumn = struct.unpack('B', self._f.read(1))[0]
... | [
"def",
"open",
"(",
"self",
",",
"filename",
")",
":",
"self",
".",
"close",
"(",
")",
"self",
".",
"_f",
"=",
"open",
"(",
"filename",
",",
"'rb'",
")",
"self",
".",
"_dbtype",
"=",
"struct",
".",
"unpack",
"(",
"'B'",
",",
"self",
".",
"_f",
... | Opens a database file | [
"Opens",
"a",
"database",
"file"
] | 6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621 | https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L105-L121 | train |
chrislim2888/IP2Location-Python | IP2Location.py | IP2Location._parse_addr | def _parse_addr(self, addr):
''' Parses address and returns IP version. Raises exception on invalid argument '''
ipv = 0
try:
socket.inet_pton(socket.AF_INET6, addr)
# Convert ::FFFF:x.y.z.y to IPv4
if addr.lower().startswith('::ffff:'):
try:
... | python | def _parse_addr(self, addr):
''' Parses address and returns IP version. Raises exception on invalid argument '''
ipv = 0
try:
socket.inet_pton(socket.AF_INET6, addr)
# Convert ::FFFF:x.y.z.y to IPv4
if addr.lower().startswith('::ffff:'):
try:
... | [
"def",
"_parse_addr",
"(",
"self",
",",
"addr",
")",
":",
"ipv",
"=",
"0",
"try",
":",
"socket",
".",
"inet_pton",
"(",
"socket",
".",
"AF_INET6",
",",
"addr",
")",
"if",
"addr",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"'::ffff:'",
")",
":"... | Parses address and returns IP version. Raises exception on invalid argument | [
"Parses",
"address",
"and",
"returns",
"IP",
"version",
".",
"Raises",
"exception",
"on",
"invalid",
"argument"
] | 6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621 | https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L342-L359 | train |
taxjar/taxjar-python | taxjar/client.py | Client.rates_for_location | def rates_for_location(self, postal_code, location_deets=None):
"""Shows the sales tax rates for a given location."""
request = self._get("rates/" + postal_code, location_deets)
return self.responder(request) | python | def rates_for_location(self, postal_code, location_deets=None):
"""Shows the sales tax rates for a given location."""
request = self._get("rates/" + postal_code, location_deets)
return self.responder(request) | [
"def",
"rates_for_location",
"(",
"self",
",",
"postal_code",
",",
"location_deets",
"=",
"None",
")",
":",
"request",
"=",
"self",
".",
"_get",
"(",
"\"rates/\"",
"+",
"postal_code",
",",
"location_deets",
")",
"return",
"self",
".",
"responder",
"(",
"requ... | Shows the sales tax rates for a given location. | [
"Shows",
"the",
"sales",
"tax",
"rates",
"for",
"a",
"given",
"location",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L31-L34 | train |
taxjar/taxjar-python | taxjar/client.py | Client.tax_for_order | def tax_for_order(self, order_deets):
"""Shows the sales tax that should be collected for a given order."""
request = self._post('taxes', order_deets)
return self.responder(request) | python | def tax_for_order(self, order_deets):
"""Shows the sales tax that should be collected for a given order."""
request = self._post('taxes', order_deets)
return self.responder(request) | [
"def",
"tax_for_order",
"(",
"self",
",",
"order_deets",
")",
":",
"request",
"=",
"self",
".",
"_post",
"(",
"'taxes'",
",",
"order_deets",
")",
"return",
"self",
".",
"responder",
"(",
"request",
")"
] | Shows the sales tax that should be collected for a given order. | [
"Shows",
"the",
"sales",
"tax",
"that",
"should",
"be",
"collected",
"for",
"a",
"given",
"order",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L36-L39 | train |
taxjar/taxjar-python | taxjar/client.py | Client.list_orders | def list_orders(self, params=None):
"""Lists existing order transactions."""
request = self._get('transactions/orders', params)
return self.responder(request) | python | def list_orders(self, params=None):
"""Lists existing order transactions."""
request = self._get('transactions/orders', params)
return self.responder(request) | [
"def",
"list_orders",
"(",
"self",
",",
"params",
"=",
"None",
")",
":",
"request",
"=",
"self",
".",
"_get",
"(",
"'transactions/orders'",
",",
"params",
")",
"return",
"self",
".",
"responder",
"(",
"request",
")"
] | Lists existing order transactions. | [
"Lists",
"existing",
"order",
"transactions",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L41-L44 | train |
taxjar/taxjar-python | taxjar/client.py | Client.show_order | def show_order(self, order_id):
"""Shows an existing order transaction."""
request = self._get('transactions/orders/' + str(order_id))
return self.responder(request) | python | def show_order(self, order_id):
"""Shows an existing order transaction."""
request = self._get('transactions/orders/' + str(order_id))
return self.responder(request) | [
"def",
"show_order",
"(",
"self",
",",
"order_id",
")",
":",
"request",
"=",
"self",
".",
"_get",
"(",
"'transactions/orders/'",
"+",
"str",
"(",
"order_id",
")",
")",
"return",
"self",
".",
"responder",
"(",
"request",
")"
] | Shows an existing order transaction. | [
"Shows",
"an",
"existing",
"order",
"transaction",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L46-L49 | train |
taxjar/taxjar-python | taxjar/client.py | Client.create_order | def create_order(self, order_deets):
"""Creates a new order transaction."""
request = self._post('transactions/orders', order_deets)
return self.responder(request) | python | def create_order(self, order_deets):
"""Creates a new order transaction."""
request = self._post('transactions/orders', order_deets)
return self.responder(request) | [
"def",
"create_order",
"(",
"self",
",",
"order_deets",
")",
":",
"request",
"=",
"self",
".",
"_post",
"(",
"'transactions/orders'",
",",
"order_deets",
")",
"return",
"self",
".",
"responder",
"(",
"request",
")"
] | Creates a new order transaction. | [
"Creates",
"a",
"new",
"order",
"transaction",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L51-L54 | train |
taxjar/taxjar-python | taxjar/client.py | Client.update_order | def update_order(self, order_id, order_deets):
"""Updates an existing order transaction."""
request = self._put("transactions/orders/" + str(order_id), order_deets)
return self.responder(request) | python | def update_order(self, order_id, order_deets):
"""Updates an existing order transaction."""
request = self._put("transactions/orders/" + str(order_id), order_deets)
return self.responder(request) | [
"def",
"update_order",
"(",
"self",
",",
"order_id",
",",
"order_deets",
")",
":",
"request",
"=",
"self",
".",
"_put",
"(",
"\"transactions/orders/\"",
"+",
"str",
"(",
"order_id",
")",
",",
"order_deets",
")",
"return",
"self",
".",
"responder",
"(",
"re... | Updates an existing order transaction. | [
"Updates",
"an",
"existing",
"order",
"transaction",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L56-L59 | train |
taxjar/taxjar-python | taxjar/client.py | Client.delete_order | def delete_order(self, order_id):
"""Deletes an existing order transaction."""
request = self._delete("transactions/orders/" + str(order_id))
return self.responder(request) | python | def delete_order(self, order_id):
"""Deletes an existing order transaction."""
request = self._delete("transactions/orders/" + str(order_id))
return self.responder(request) | [
"def",
"delete_order",
"(",
"self",
",",
"order_id",
")",
":",
"request",
"=",
"self",
".",
"_delete",
"(",
"\"transactions/orders/\"",
"+",
"str",
"(",
"order_id",
")",
")",
"return",
"self",
".",
"responder",
"(",
"request",
")"
] | Deletes an existing order transaction. | [
"Deletes",
"an",
"existing",
"order",
"transaction",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L61-L64 | train |
taxjar/taxjar-python | taxjar/client.py | Client.list_refunds | def list_refunds(self, params=None):
"""Lists existing refund transactions."""
request = self._get('transactions/refunds', params)
return self.responder(request) | python | def list_refunds(self, params=None):
"""Lists existing refund transactions."""
request = self._get('transactions/refunds', params)
return self.responder(request) | [
"def",
"list_refunds",
"(",
"self",
",",
"params",
"=",
"None",
")",
":",
"request",
"=",
"self",
".",
"_get",
"(",
"'transactions/refunds'",
",",
"params",
")",
"return",
"self",
".",
"responder",
"(",
"request",
")"
] | Lists existing refund transactions. | [
"Lists",
"existing",
"refund",
"transactions",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L66-L69 | train |
taxjar/taxjar-python | taxjar/client.py | Client.show_refund | def show_refund(self, refund_id):
"""Shows an existing refund transaction."""
request = self._get('transactions/refunds/' + str(refund_id))
return self.responder(request) | python | def show_refund(self, refund_id):
"""Shows an existing refund transaction."""
request = self._get('transactions/refunds/' + str(refund_id))
return self.responder(request) | [
"def",
"show_refund",
"(",
"self",
",",
"refund_id",
")",
":",
"request",
"=",
"self",
".",
"_get",
"(",
"'transactions/refunds/'",
"+",
"str",
"(",
"refund_id",
")",
")",
"return",
"self",
".",
"responder",
"(",
"request",
")"
] | Shows an existing refund transaction. | [
"Shows",
"an",
"existing",
"refund",
"transaction",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L71-L74 | train |
taxjar/taxjar-python | taxjar/client.py | Client.create_refund | def create_refund(self, refund_deets):
"""Creates a new refund transaction."""
request = self._post('transactions/refunds', refund_deets)
return self.responder(request) | python | def create_refund(self, refund_deets):
"""Creates a new refund transaction."""
request = self._post('transactions/refunds', refund_deets)
return self.responder(request) | [
"def",
"create_refund",
"(",
"self",
",",
"refund_deets",
")",
":",
"request",
"=",
"self",
".",
"_post",
"(",
"'transactions/refunds'",
",",
"refund_deets",
")",
"return",
"self",
".",
"responder",
"(",
"request",
")"
] | Creates a new refund transaction. | [
"Creates",
"a",
"new",
"refund",
"transaction",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L76-L79 | train |
taxjar/taxjar-python | taxjar/client.py | Client.update_refund | def update_refund(self, refund_id, refund_deets):
"""Updates an existing refund transaction."""
request = self._put('transactions/refunds/' + str(refund_id), refund_deets)
return self.responder(request) | python | def update_refund(self, refund_id, refund_deets):
"""Updates an existing refund transaction."""
request = self._put('transactions/refunds/' + str(refund_id), refund_deets)
return self.responder(request) | [
"def",
"update_refund",
"(",
"self",
",",
"refund_id",
",",
"refund_deets",
")",
":",
"request",
"=",
"self",
".",
"_put",
"(",
"'transactions/refunds/'",
"+",
"str",
"(",
"refund_id",
")",
",",
"refund_deets",
")",
"return",
"self",
".",
"responder",
"(",
... | Updates an existing refund transaction. | [
"Updates",
"an",
"existing",
"refund",
"transaction",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L81-L84 | train |
taxjar/taxjar-python | taxjar/client.py | Client.delete_refund | def delete_refund(self, refund_id):
"""Deletes an existing refund transaction."""
request = self._delete('transactions/refunds/' + str(refund_id))
return self.responder(request) | python | def delete_refund(self, refund_id):
"""Deletes an existing refund transaction."""
request = self._delete('transactions/refunds/' + str(refund_id))
return self.responder(request) | [
"def",
"delete_refund",
"(",
"self",
",",
"refund_id",
")",
":",
"request",
"=",
"self",
".",
"_delete",
"(",
"'transactions/refunds/'",
"+",
"str",
"(",
"refund_id",
")",
")",
"return",
"self",
".",
"responder",
"(",
"request",
")"
] | Deletes an existing refund transaction. | [
"Deletes",
"an",
"existing",
"refund",
"transaction",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L86-L89 | train |
taxjar/taxjar-python | taxjar/client.py | Client.list_customers | def list_customers(self, params=None):
"""Lists existing customers."""
request = self._get('customers', params)
return self.responder(request) | python | def list_customers(self, params=None):
"""Lists existing customers."""
request = self._get('customers', params)
return self.responder(request) | [
"def",
"list_customers",
"(",
"self",
",",
"params",
"=",
"None",
")",
":",
"request",
"=",
"self",
".",
"_get",
"(",
"'customers'",
",",
"params",
")",
"return",
"self",
".",
"responder",
"(",
"request",
")"
] | Lists existing customers. | [
"Lists",
"existing",
"customers",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L91-L94 | train |
taxjar/taxjar-python | taxjar/client.py | Client.show_customer | def show_customer(self, customer_id):
"""Shows an existing customer."""
request = self._get('customers/' + str(customer_id))
return self.responder(request) | python | def show_customer(self, customer_id):
"""Shows an existing customer."""
request = self._get('customers/' + str(customer_id))
return self.responder(request) | [
"def",
"show_customer",
"(",
"self",
",",
"customer_id",
")",
":",
"request",
"=",
"self",
".",
"_get",
"(",
"'customers/'",
"+",
"str",
"(",
"customer_id",
")",
")",
"return",
"self",
".",
"responder",
"(",
"request",
")"
] | Shows an existing customer. | [
"Shows",
"an",
"existing",
"customer",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L96-L99 | train |
taxjar/taxjar-python | taxjar/client.py | Client.create_customer | def create_customer(self, customer_deets):
"""Creates a new customer."""
request = self._post('customers', customer_deets)
return self.responder(request) | python | def create_customer(self, customer_deets):
"""Creates a new customer."""
request = self._post('customers', customer_deets)
return self.responder(request) | [
"def",
"create_customer",
"(",
"self",
",",
"customer_deets",
")",
":",
"request",
"=",
"self",
".",
"_post",
"(",
"'customers'",
",",
"customer_deets",
")",
"return",
"self",
".",
"responder",
"(",
"request",
")"
] | Creates a new customer. | [
"Creates",
"a",
"new",
"customer",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L101-L104 | train |
taxjar/taxjar-python | taxjar/client.py | Client.update_customer | def update_customer(self, customer_id, customer_deets):
"""Updates an existing customer."""
request = self._put("customers/" + str(customer_id), customer_deets)
return self.responder(request) | python | def update_customer(self, customer_id, customer_deets):
"""Updates an existing customer."""
request = self._put("customers/" + str(customer_id), customer_deets)
return self.responder(request) | [
"def",
"update_customer",
"(",
"self",
",",
"customer_id",
",",
"customer_deets",
")",
":",
"request",
"=",
"self",
".",
"_put",
"(",
"\"customers/\"",
"+",
"str",
"(",
"customer_id",
")",
",",
"customer_deets",
")",
"return",
"self",
".",
"responder",
"(",
... | Updates an existing customer. | [
"Updates",
"an",
"existing",
"customer",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L106-L109 | train |
taxjar/taxjar-python | taxjar/client.py | Client.delete_customer | def delete_customer(self, customer_id):
"""Deletes an existing customer."""
request = self._delete("customers/" + str(customer_id))
return self.responder(request) | python | def delete_customer(self, customer_id):
"""Deletes an existing customer."""
request = self._delete("customers/" + str(customer_id))
return self.responder(request) | [
"def",
"delete_customer",
"(",
"self",
",",
"customer_id",
")",
":",
"request",
"=",
"self",
".",
"_delete",
"(",
"\"customers/\"",
"+",
"str",
"(",
"customer_id",
")",
")",
"return",
"self",
".",
"responder",
"(",
"request",
")"
] | Deletes an existing customer. | [
"Deletes",
"an",
"existing",
"customer",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L111-L114 | train |
taxjar/taxjar-python | taxjar/client.py | Client.validate_address | def validate_address(self, address_deets):
"""Validates a customer address and returns back a collection of address matches."""
request = self._post('addresses/validate', address_deets)
return self.responder(request) | python | def validate_address(self, address_deets):
"""Validates a customer address and returns back a collection of address matches."""
request = self._post('addresses/validate', address_deets)
return self.responder(request) | [
"def",
"validate_address",
"(",
"self",
",",
"address_deets",
")",
":",
"request",
"=",
"self",
".",
"_post",
"(",
"'addresses/validate'",
",",
"address_deets",
")",
"return",
"self",
".",
"responder",
"(",
"request",
")"
] | Validates a customer address and returns back a collection of address matches. | [
"Validates",
"a",
"customer",
"address",
"and",
"returns",
"back",
"a",
"collection",
"of",
"address",
"matches",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L121-L124 | train |
taxjar/taxjar-python | taxjar/client.py | Client.validate | def validate(self, vat_deets):
"""Validates an existing VAT identification number against VIES."""
request = self._get('validation', vat_deets)
return self.responder(request) | python | def validate(self, vat_deets):
"""Validates an existing VAT identification number against VIES."""
request = self._get('validation', vat_deets)
return self.responder(request) | [
"def",
"validate",
"(",
"self",
",",
"vat_deets",
")",
":",
"request",
"=",
"self",
".",
"_get",
"(",
"'validation'",
",",
"vat_deets",
")",
"return",
"self",
".",
"responder",
"(",
"request",
")"
] | Validates an existing VAT identification number against VIES. | [
"Validates",
"an",
"existing",
"VAT",
"identification",
"number",
"against",
"VIES",
"."
] | be9b30d7dc968d24e066c7c133849fee180f8d95 | https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L126-L129 | train |
last-partizan/pytils | pytils/templatetags/pytils_numeral.py | choose_plural | def choose_plural(amount, variants):
"""
Choose proper form for plural.
Value is a amount, parameters are forms of noun.
Forms are variants for 1, 2, 5 nouns. It may be tuple
of elements, or string where variants separates each other
by comma.
Examples::
{{ some_int|choose_plural:"... | python | def choose_plural(amount, variants):
"""
Choose proper form for plural.
Value is a amount, parameters are forms of noun.
Forms are variants for 1, 2, 5 nouns. It may be tuple
of elements, or string where variants separates each other
by comma.
Examples::
{{ some_int|choose_plural:"... | [
"def",
"choose_plural",
"(",
"amount",
",",
"variants",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"variants",
",",
"six",
".",
"string_types",
")",
":",
"uvariants",
"=",
"smart_text",
"(",
"variants",
",",
"encoding",
")",
"else",
":",
"uvariants",
... | Choose proper form for plural.
Value is a amount, parameters are forms of noun.
Forms are variants for 1, 2, 5 nouns. It may be tuple
of elements, or string where variants separates each other
by comma.
Examples::
{{ some_int|choose_plural:"пример,примера,примеров" }} | [
"Choose",
"proper",
"form",
"for",
"plural",
"."
] | 1c570a32b15e564bc68587b8207e32d464e61d08 | https://github.com/last-partizan/pytils/blob/1c570a32b15e564bc68587b8207e32d464e61d08/pytils/templatetags/pytils_numeral.py#L29-L54 | train |
last-partizan/pytils | pytils/templatetags/pytils_numeral.py | in_words | def in_words(amount, gender=None):
"""
In-words representation of amount.
Parameter is a gender: MALE, FEMALE or NEUTER
Examples::
{{ some_int|in_words }}
{{ some_other_int|in_words:FEMALE }}
"""
try:
res = numeral.in_words(amount, getattr(numeral, str(gender), None))
... | python | def in_words(amount, gender=None):
"""
In-words representation of amount.
Parameter is a gender: MALE, FEMALE or NEUTER
Examples::
{{ some_int|in_words }}
{{ some_other_int|in_words:FEMALE }}
"""
try:
res = numeral.in_words(amount, getattr(numeral, str(gender), None))
... | [
"def",
"in_words",
"(",
"amount",
",",
"gender",
"=",
"None",
")",
":",
"try",
":",
"res",
"=",
"numeral",
".",
"in_words",
"(",
"amount",
",",
"getattr",
"(",
"numeral",
",",
"str",
"(",
"gender",
")",
",",
"None",
")",
")",
"except",
"Exception",
... | In-words representation of amount.
Parameter is a gender: MALE, FEMALE or NEUTER
Examples::
{{ some_int|in_words }}
{{ some_other_int|in_words:FEMALE }} | [
"In",
"-",
"words",
"representation",
"of",
"amount",
"."
] | 1c570a32b15e564bc68587b8207e32d464e61d08 | https://github.com/last-partizan/pytils/blob/1c570a32b15e564bc68587b8207e32d464e61d08/pytils/templatetags/pytils_numeral.py#L92-L107 | train |
last-partizan/pytils | pytils/templatetags/pytils_numeral.py | sum_string | def sum_string(amount, gender, items):
"""
in_words and choose_plural in a one flask
Makes in-words representation of value with
choosing correct form of noun.
First parameter is an amount of objects. Second is a
gender (MALE, FEMALE, NEUTER). Third is a variants
of forms for object name.
... | python | def sum_string(amount, gender, items):
"""
in_words and choose_plural in a one flask
Makes in-words representation of value with
choosing correct form of noun.
First parameter is an amount of objects. Second is a
gender (MALE, FEMALE, NEUTER). Third is a variants
of forms for object name.
... | [
"def",
"sum_string",
"(",
"amount",
",",
"gender",
",",
"items",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"items",
",",
"six",
".",
"string_types",
")",
":",
"uitems",
"=",
"smart_text",
"(",
"items",
",",
"encoding",
",",
"default_uvalue",
")",
... | in_words and choose_plural in a one flask
Makes in-words representation of value with
choosing correct form of noun.
First parameter is an amount of objects. Second is a
gender (MALE, FEMALE, NEUTER). Third is a variants
of forms for object name.
Examples::
{% sum_string some_int MALE ... | [
"in_words",
"and",
"choose_plural",
"in",
"a",
"one",
"flask",
"Makes",
"in",
"-",
"words",
"representation",
"of",
"value",
"with",
"choosing",
"correct",
"form",
"of",
"noun",
"."
] | 1c570a32b15e564bc68587b8207e32d464e61d08 | https://github.com/last-partizan/pytils/blob/1c570a32b15e564bc68587b8207e32d464e61d08/pytils/templatetags/pytils_numeral.py#L118-L141 | train |
last-partizan/pytils | pytils/typo.py | rl_cleanspaces | def rl_cleanspaces(x):
"""
Clean double spaces, trailing spaces, heading spaces,
spaces before punctuations
"""
patterns = (
# arguments for re.sub: pattern and repl
# удаляем пробел перед знаками препинания
(r' +([\.,?!\)]+)', r'\1'),
# добавляем пробел после знака п... | python | def rl_cleanspaces(x):
"""
Clean double spaces, trailing spaces, heading spaces,
spaces before punctuations
"""
patterns = (
# arguments for re.sub: pattern and repl
# удаляем пробел перед знаками препинания
(r' +([\.,?!\)]+)', r'\1'),
# добавляем пробел после знака п... | [
"def",
"rl_cleanspaces",
"(",
"x",
")",
":",
"patterns",
"=",
"(",
"(",
"r' +([\\.,?!\\)]+)'",
",",
"r'\\1'",
")",
",",
"(",
"r'([\\.,?!\\)]+)([^\\.!,?\\)]+)'",
",",
"r'\\1 \\2'",
")",
",",
"(",
"r'(\\S+)\\s*(\\()\\s*(\\S+)'",
",",
"r'\\1 (\\3'",
")",
",",
")",
... | Clean double spaces, trailing spaces, heading spaces,
spaces before punctuations | [
"Clean",
"double",
"spaces",
"trailing",
"spaces",
"heading",
"spaces",
"spaces",
"before",
"punctuations"
] | 1c570a32b15e564bc68587b8207e32d464e61d08 | https://github.com/last-partizan/pytils/blob/1c570a32b15e564bc68587b8207e32d464e61d08/pytils/typo.py#L26-L44 | train |
last-partizan/pytils | pytils/typo.py | rl_quotes | def rl_quotes(x):
"""
Replace quotes by typographic quotes
"""
patterns = (
# открывающие кавычки ставятся обычно вплотную к слову слева
# а закрывающие -- вплотную справа
# открывающие русские кавычки-ёлочки
(re.compile(r'((?:^|\s))(")((?u))', re.UNICODE), u'\\1\xab... | python | def rl_quotes(x):
"""
Replace quotes by typographic quotes
"""
patterns = (
# открывающие кавычки ставятся обычно вплотную к слову слева
# а закрывающие -- вплотную справа
# открывающие русские кавычки-ёлочки
(re.compile(r'((?:^|\s))(")((?u))', re.UNICODE), u'\\1\xab... | [
"def",
"rl_quotes",
"(",
"x",
")",
":",
"patterns",
"=",
"(",
"(",
"re",
".",
"compile",
"(",
"r'((?:^|\\s))(\")((?u))'",
",",
"re",
".",
"UNICODE",
")",
",",
"u'\\\\1\\xab\\\\3'",
")",
",",
"(",
"re",
".",
"compile",
"(",
"r'(\\S)(\")((?u))'",
",",
"re"... | Replace quotes by typographic quotes | [
"Replace",
"quotes",
"by",
"typographic",
"quotes"
] | 1c570a32b15e564bc68587b8207e32d464e61d08 | https://github.com/last-partizan/pytils/blob/1c570a32b15e564bc68587b8207e32d464e61d08/pytils/typo.py#L134-L151 | train |
last-partizan/pytils | pytils/templatetags/pytils_dt.py | distance_of_time | def distance_of_time(from_time, accuracy=1):
"""
Display distance of time from current time.
Parameter is an accuracy level (deafult is 1).
Value must be numeral (i.e. time.time() result) or
datetime.datetime (i.e. datetime.datetime.now()
result).
Examples::
{{ some_time|distance_o... | python | def distance_of_time(from_time, accuracy=1):
"""
Display distance of time from current time.
Parameter is an accuracy level (deafult is 1).
Value must be numeral (i.e. time.time() result) or
datetime.datetime (i.e. datetime.datetime.now()
result).
Examples::
{{ some_time|distance_o... | [
"def",
"distance_of_time",
"(",
"from_time",
",",
"accuracy",
"=",
"1",
")",
":",
"try",
":",
"to_time",
"=",
"None",
"if",
"conf",
".",
"settings",
".",
"USE_TZ",
":",
"to_time",
"=",
"utils",
".",
"timezone",
".",
"now",
"(",
")",
"res",
"=",
"dt",... | Display distance of time from current time.
Parameter is an accuracy level (deafult is 1).
Value must be numeral (i.e. time.time() result) or
datetime.datetime (i.e. datetime.datetime.now()
result).
Examples::
{{ some_time|distance_of_time }}
{{ some_dtime|distance_of_time:2 }} | [
"Display",
"distance",
"of",
"time",
"from",
"current",
"time",
"."
] | 1c570a32b15e564bc68587b8207e32d464e61d08 | https://github.com/last-partizan/pytils/blob/1c570a32b15e564bc68587b8207e32d464e61d08/pytils/templatetags/pytils_dt.py#L20-L45 | train |
last-partizan/pytils | pytils/templatetags/pytils_dt.py | ru_strftime | def ru_strftime(date, format="%d.%m.%Y", inflected_day=False, preposition=False):
"""
Russian strftime, formats date with given format.
Value is a date (supports datetime.date and datetime.datetime),
parameter is a format (string). For explainings about format,
see documentation for original strfti... | python | def ru_strftime(date, format="%d.%m.%Y", inflected_day=False, preposition=False):
"""
Russian strftime, formats date with given format.
Value is a date (supports datetime.date and datetime.datetime),
parameter is a format (string). For explainings about format,
see documentation for original strfti... | [
"def",
"ru_strftime",
"(",
"date",
",",
"format",
"=",
"\"%d.%m.%Y\"",
",",
"inflected_day",
"=",
"False",
",",
"preposition",
"=",
"False",
")",
":",
"try",
":",
"res",
"=",
"dt",
".",
"ru_strftime",
"(",
"format",
",",
"date",
",",
"inflected",
"=",
... | Russian strftime, formats date with given format.
Value is a date (supports datetime.date and datetime.datetime),
parameter is a format (string). For explainings about format,
see documentation for original strftime:
http://docs.python.org/lib/module-time.html
Examples::
{{ some_date|ru_st... | [
"Russian",
"strftime",
"formats",
"date",
"with",
"given",
"format",
"."
] | 1c570a32b15e564bc68587b8207e32d464e61d08 | https://github.com/last-partizan/pytils/blob/1c570a32b15e564bc68587b8207e32d464e61d08/pytils/templatetags/pytils_dt.py#L47-L72 | train |
last-partizan/pytils | pytils/dt.py | ru_strftime | def ru_strftime(format=u"%d.%m.%Y", date=None, inflected=False,
inflected_day=False, preposition=False):
"""
Russian strftime without locale
@param format: strftime format, default=u'%d.%m.%Y'
@type format: C{unicode}
@param date: date value, default=None translates to today
@t... | python | def ru_strftime(format=u"%d.%m.%Y", date=None, inflected=False,
inflected_day=False, preposition=False):
"""
Russian strftime without locale
@param format: strftime format, default=u'%d.%m.%Y'
@type format: C{unicode}
@param date: date value, default=None translates to today
@t... | [
"def",
"ru_strftime",
"(",
"format",
"=",
"u\"%d.%m.%Y\"",
",",
"date",
"=",
"None",
",",
"inflected",
"=",
"False",
",",
"inflected_day",
"=",
"False",
",",
"preposition",
"=",
"False",
")",
":",
"if",
"date",
"is",
"None",
":",
"date",
"=",
"datetime",... | Russian strftime without locale
@param format: strftime format, default=u'%d.%m.%Y'
@type format: C{unicode}
@param date: date value, default=None translates to today
@type date: C{datetime.date} or C{datetime.datetime}
@param inflected: is month inflected, default False
@type inflected: C{bo... | [
"Russian",
"strftime",
"without",
"locale"
] | 1c570a32b15e564bc68587b8207e32d464e61d08 | https://github.com/last-partizan/pytils/blob/1c570a32b15e564bc68587b8207e32d464e61d08/pytils/dt.py#L179-L233 | train |
last-partizan/pytils | pytils/numeral.py | _get_float_remainder | def _get_float_remainder(fvalue, signs=9):
"""
Get remainder of float, i.e. 2.05 -> '05'
@param fvalue: input value
@type fvalue: C{integer types}, C{float} or C{Decimal}
@param signs: maximum number of signs
@type signs: C{integer types}
@return: remainder
@rtype: C{str}
@raise ... | python | def _get_float_remainder(fvalue, signs=9):
"""
Get remainder of float, i.e. 2.05 -> '05'
@param fvalue: input value
@type fvalue: C{integer types}, C{float} or C{Decimal}
@param signs: maximum number of signs
@type signs: C{integer types}
@return: remainder
@rtype: C{str}
@raise ... | [
"def",
"_get_float_remainder",
"(",
"fvalue",
",",
"signs",
"=",
"9",
")",
":",
"check_positive",
"(",
"fvalue",
")",
"if",
"isinstance",
"(",
"fvalue",
",",
"six",
".",
"integer_types",
")",
":",
"return",
"\"0\"",
"if",
"isinstance",
"(",
"fvalue",
",",
... | Get remainder of float, i.e. 2.05 -> '05'
@param fvalue: input value
@type fvalue: C{integer types}, C{float} or C{Decimal}
@param signs: maximum number of signs
@type signs: C{integer types}
@return: remainder
@rtype: C{str}
@raise ValueError: fvalue is negative
@raise ValueError: s... | [
"Get",
"remainder",
"of",
"float",
"i",
".",
"e",
".",
"2",
".",
"05",
"-",
">",
"05"
] | 1c570a32b15e564bc68587b8207e32d464e61d08 | https://github.com/last-partizan/pytils/blob/1c570a32b15e564bc68587b8207e32d464e61d08/pytils/numeral.py#L77-L123 | train |
last-partizan/pytils | pytils/numeral.py | choose_plural | def choose_plural(amount, variants):
"""
Choose proper case depending on amount
@param amount: amount of objects
@type amount: C{integer types}
@param variants: variants (forms) of object in such form:
(1 object, 2 objects, 5 objects).
@type variants: 3-element C{sequence} of C{unicode... | python | def choose_plural(amount, variants):
"""
Choose proper case depending on amount
@param amount: amount of objects
@type amount: C{integer types}
@param variants: variants (forms) of object in such form:
(1 object, 2 objects, 5 objects).
@type variants: 3-element C{sequence} of C{unicode... | [
"def",
"choose_plural",
"(",
"amount",
",",
"variants",
")",
":",
"if",
"isinstance",
"(",
"variants",
",",
"six",
".",
"text_type",
")",
":",
"variants",
"=",
"split_values",
"(",
"variants",
")",
"check_length",
"(",
"variants",
",",
"3",
")",
"amount",
... | Choose proper case depending on amount
@param amount: amount of objects
@type amount: C{integer types}
@param variants: variants (forms) of object in such form:
(1 object, 2 objects, 5 objects).
@type variants: 3-element C{sequence} of C{unicode}
or C{unicode} (three variants with deli... | [
"Choose",
"proper",
"case",
"depending",
"on",
"amount"
] | 1c570a32b15e564bc68587b8207e32d464e61d08 | https://github.com/last-partizan/pytils/blob/1c570a32b15e564bc68587b8207e32d464e61d08/pytils/numeral.py#L126-L157 | train |
last-partizan/pytils | pytils/numeral.py | get_plural | def get_plural(amount, variants, absence=None):
"""
Get proper case with value
@param amount: amount of objects
@type amount: C{integer types}
@param variants: variants (forms) of object in such form:
(1 object, 2 objects, 5 objects).
@type variants: 3-element C{sequence} of C{unicode}... | python | def get_plural(amount, variants, absence=None):
"""
Get proper case with value
@param amount: amount of objects
@type amount: C{integer types}
@param variants: variants (forms) of object in such form:
(1 object, 2 objects, 5 objects).
@type variants: 3-element C{sequence} of C{unicode}... | [
"def",
"get_plural",
"(",
"amount",
",",
"variants",
",",
"absence",
"=",
"None",
")",
":",
"if",
"amount",
"or",
"absence",
"is",
"None",
":",
"return",
"u\"%d %s\"",
"%",
"(",
"amount",
",",
"choose_plural",
"(",
"amount",
",",
"variants",
")",
")",
... | Get proper case with value
@param amount: amount of objects
@type amount: C{integer types}
@param variants: variants (forms) of object in such form:
(1 object, 2 objects, 5 objects).
@type variants: 3-element C{sequence} of C{unicode}
or C{unicode} (three variants with delimeter ',')
... | [
"Get",
"proper",
"case",
"with",
"value"
] | 1c570a32b15e564bc68587b8207e32d464e61d08 | https://github.com/last-partizan/pytils/blob/1c570a32b15e564bc68587b8207e32d464e61d08/pytils/numeral.py#L160-L181 | train |
last-partizan/pytils | pytils/numeral.py | in_words | def in_words(amount, gender=None):
"""
Numeral in words
@param amount: numeral
@type amount: C{integer types}, C{float} or C{Decimal}
@param gender: gender (MALE, FEMALE or NEUTER)
@type gender: C{int}
@return: in-words reprsentation of numeral
@rtype: C{unicode}
raise ValueError... | python | def in_words(amount, gender=None):
"""
Numeral in words
@param amount: numeral
@type amount: C{integer types}, C{float} or C{Decimal}
@param gender: gender (MALE, FEMALE or NEUTER)
@type gender: C{int}
@return: in-words reprsentation of numeral
@rtype: C{unicode}
raise ValueError... | [
"def",
"in_words",
"(",
"amount",
",",
"gender",
"=",
"None",
")",
":",
"check_positive",
"(",
"amount",
")",
"if",
"isinstance",
"(",
"amount",
",",
"Decimal",
")",
"and",
"amount",
".",
"as_tuple",
"(",
")",
"[",
"2",
"]",
"==",
"0",
":",
"amount",... | Numeral in words
@param amount: numeral
@type amount: C{integer types}, C{float} or C{Decimal}
@param gender: gender (MALE, FEMALE or NEUTER)
@type gender: C{int}
@return: in-words reprsentation of numeral
@rtype: C{unicode}
raise ValueError: when amount is negative | [
"Numeral",
"in",
"words"
] | 1c570a32b15e564bc68587b8207e32d464e61d08 | https://github.com/last-partizan/pytils/blob/1c570a32b15e564bc68587b8207e32d464e61d08/pytils/numeral.py#L289-L325 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.