repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
rshk/python-libxdo
xdo/__init__.py
Xdo.send_keysequence_window_up
def send_keysequence_window_up(self, window, keysequence, delay=12000): """Send key release (up) events for the given key sequence""" _libxdo.xdo_send_keysequence_window_up( self._xdo, window, keysequence, ctypes.c_ulong(delay))
python
def send_keysequence_window_up(self, window, keysequence, delay=12000): """Send key release (up) events for the given key sequence""" _libxdo.xdo_send_keysequence_window_up( self._xdo, window, keysequence, ctypes.c_ulong(delay))
[ "def", "send_keysequence_window_up", "(", "self", ",", "window", ",", "keysequence", ",", "delay", "=", "12000", ")", ":", "_libxdo", ".", "xdo_send_keysequence_window_up", "(", "self", ".", "_xdo", ",", "window", ",", "keysequence", ",", "ctypes", ".", "c_ulo...
Send key release (up) events for the given key sequence
[ "Send", "key", "release", "(", "up", ")", "events", "for", "the", "given", "key", "sequence" ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L289-L292
train
rshk/python-libxdo
xdo/__init__.py
Xdo.send_keysequence_window_down
def send_keysequence_window_down(self, window, keysequence, delay=12000): """Send key press (down) events for the given key sequence""" _libxdo.xdo_send_keysequence_window_down( self._xdo, window, keysequence, ctypes.c_ulong(delay))
python
def send_keysequence_window_down(self, window, keysequence, delay=12000): """Send key press (down) events for the given key sequence""" _libxdo.xdo_send_keysequence_window_down( self._xdo, window, keysequence, ctypes.c_ulong(delay))
[ "def", "send_keysequence_window_down", "(", "self", ",", "window", ",", "keysequence", ",", "delay", "=", "12000", ")", ":", "_libxdo", ".", "xdo_send_keysequence_window_down", "(", "self", ".", "_xdo", ",", "window", ",", "keysequence", ",", "ctypes", ".", "c...
Send key press (down) events for the given key sequence
[ "Send", "key", "press", "(", "down", ")", "events", "for", "the", "given", "key", "sequence" ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L294-L297
train
rshk/python-libxdo
xdo/__init__.py
Xdo.send_keysequence_window_list_do
def send_keysequence_window_list_do( self, window, keys, pressed=1, modifier=None, delay=120000): """ Send a series of keystrokes. :param window: The window to send events to or CURRENTWINDOW :param keys: The array of charcodemap_t entities to send. :param pressed: 1...
python
def send_keysequence_window_list_do( self, window, keys, pressed=1, modifier=None, delay=120000): """ Send a series of keystrokes. :param window: The window to send events to or CURRENTWINDOW :param keys: The array of charcodemap_t entities to send. :param pressed: 1...
[ "def", "send_keysequence_window_list_do", "(", "self", ",", "window", ",", "keys", ",", "pressed", "=", "1", ",", "modifier", "=", "None", ",", "delay", "=", "120000", ")", ":", "# todo: how to properly use charcodes_t in a nice way?", "_libxdo", ".", "xdo_send_keys...
Send a series of keystrokes. :param window: The window to send events to or CURRENTWINDOW :param keys: The array of charcodemap_t entities to send. :param pressed: 1 for key press, 0 for key release. :param modifier: Pointer to integer to record the modifiers act...
[ "Send", "a", "series", "of", "keystrokes", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L299-L316
train
rshk/python-libxdo
xdo/__init__.py
Xdo.get_active_keys_to_keycode_list
def get_active_keys_to_keycode_list(self): """Get a list of active keys. Uses XQueryKeymap""" try: _libxdo.xdo_get_active_keys_to_keycode_list except AttributeError: # Apparently, this was implemented in a later version.. raise NotImplementedError() ...
python
def get_active_keys_to_keycode_list(self): """Get a list of active keys. Uses XQueryKeymap""" try: _libxdo.xdo_get_active_keys_to_keycode_list except AttributeError: # Apparently, this was implemented in a later version.. raise NotImplementedError() ...
[ "def", "get_active_keys_to_keycode_list", "(", "self", ")", ":", "try", ":", "_libxdo", ".", "xdo_get_active_keys_to_keycode_list", "except", "AttributeError", ":", "# Apparently, this was implemented in a later version..", "raise", "NotImplementedError", "(", ")", "keys", "=...
Get a list of active keys. Uses XQueryKeymap
[ "Get", "a", "list", "of", "active", "keys", ".", "Uses", "XQueryKeymap" ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L318-L333
train
rshk/python-libxdo
xdo/__init__.py
Xdo.wait_for_window_map_state
def wait_for_window_map_state(self, window, state): """ Wait for a window to have a specific map state. State possibilities: IsUnmapped - window is not displayed. IsViewable - window is mapped and shown (though may be clipped by windows on top of it) ...
python
def wait_for_window_map_state(self, window, state): """ Wait for a window to have a specific map state. State possibilities: IsUnmapped - window is not displayed. IsViewable - window is mapped and shown (though may be clipped by windows on top of it) ...
[ "def", "wait_for_window_map_state", "(", "self", ",", "window", ",", "state", ")", ":", "_libxdo", ".", "xdo_wait_for_window_map_state", "(", "self", ".", "_xdo", ",", "window", ",", "state", ")" ]
Wait for a window to have a specific map state. State possibilities: IsUnmapped - window is not displayed. IsViewable - window is mapped and shown (though may be clipped by windows on top of it) IsUnviewable - window is mapped but a parent window is unmapped. ...
[ "Wait", "for", "a", "window", "to", "have", "a", "specific", "map", "state", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L335-L348
train
rshk/python-libxdo
xdo/__init__.py
Xdo.move_window
def move_window(self, window, x, y): """ Move a window to a specific location. The top left corner of the window will be moved to the x,y coordinate. :param wid: the window to move :param x: the X coordinate to move to. :param y: the Y coordinate to move to. """...
python
def move_window(self, window, x, y): """ Move a window to a specific location. The top left corner of the window will be moved to the x,y coordinate. :param wid: the window to move :param x: the X coordinate to move to. :param y: the Y coordinate to move to. """...
[ "def", "move_window", "(", "self", ",", "window", ",", "x", ",", "y", ")", ":", "_libxdo", ".", "xdo_move_window", "(", "self", ".", "_xdo", ",", "window", ",", "x", ",", "y", ")" ]
Move a window to a specific location. The top left corner of the window will be moved to the x,y coordinate. :param wid: the window to move :param x: the X coordinate to move to. :param y: the Y coordinate to move to.
[ "Move", "a", "window", "to", "a", "specific", "location", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L359-L369
train
rshk/python-libxdo
xdo/__init__.py
Xdo.translate_window_with_sizehint
def translate_window_with_sizehint(self, window, width, height): """ Apply a window's sizing hints (if any) to a given width and height. This function wraps XGetWMNormalHints() and applies any resize increment and base size to your given width and height values. :param window: ...
python
def translate_window_with_sizehint(self, window, width, height): """ Apply a window's sizing hints (if any) to a given width and height. This function wraps XGetWMNormalHints() and applies any resize increment and base size to your given width and height values. :param window: ...
[ "def", "translate_window_with_sizehint", "(", "self", ",", "window", ",", "width", ",", "height", ")", ":", "width_ret", "=", "ctypes", ".", "c_uint", "(", "0", ")", "height_ret", "=", "ctypes", ".", "c_uint", "(", "0", ")", "_libxdo", ".", "xdo_translate_...
Apply a window's sizing hints (if any) to a given width and height. This function wraps XGetWMNormalHints() and applies any resize increment and base size to your given width and height values. :param window: the window to use :param width: the unit width you want to translate ...
[ "Apply", "a", "window", "s", "sizing", "hints", "(", "if", "any", ")", "to", "a", "given", "width", "and", "height", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L371-L389
train
rshk/python-libxdo
xdo/__init__.py
Xdo.set_window_size
def set_window_size(self, window, w, h, flags=0): """ Change the window size. :param wid: the window to resize :param w: the new desired width :param h: the new desired height :param flags: if 0, use pixels for units. If SIZE_USEHINTS, then the units will be ...
python
def set_window_size(self, window, w, h, flags=0): """ Change the window size. :param wid: the window to resize :param w: the new desired width :param h: the new desired height :param flags: if 0, use pixels for units. If SIZE_USEHINTS, then the units will be ...
[ "def", "set_window_size", "(", "self", ",", "window", ",", "w", ",", "h", ",", "flags", "=", "0", ")", ":", "_libxdo", ".", "xdo_set_window_size", "(", "self", ".", "_xdo", ",", "window", ",", "w", ",", "h", ",", "flags", ")" ]
Change the window size. :param wid: the window to resize :param w: the new desired width :param h: the new desired height :param flags: if 0, use pixels for units. If SIZE_USEHINTS, then the units will be relative to the window size hints.
[ "Change", "the", "window", "size", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L391-L401
train
rshk/python-libxdo
xdo/__init__.py
Xdo.set_window_property
def set_window_property(self, window, name, value): """ Change a window property. Example properties you can change are WM_NAME, WM_ICON_NAME, etc. :param wid: The window to change a property of. :param name: the string name of the property. :param value: the string val...
python
def set_window_property(self, window, name, value): """ Change a window property. Example properties you can change are WM_NAME, WM_ICON_NAME, etc. :param wid: The window to change a property of. :param name: the string name of the property. :param value: the string val...
[ "def", "set_window_property", "(", "self", ",", "window", ",", "name", ",", "value", ")", ":", "_libxdo", ".", "xdo_set_window_property", "(", "self", ".", "_xdo", ",", "window", ",", "name", ",", "value", ")" ]
Change a window property. Example properties you can change are WM_NAME, WM_ICON_NAME, etc. :param wid: The window to change a property of. :param name: the string name of the property. :param value: the string value of the property.
[ "Change", "a", "window", "property", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L403-L413
train
rshk/python-libxdo
xdo/__init__.py
Xdo.set_window_class
def set_window_class(self, window, name, class_): """ Change the window's classname and or class. :param name: The new class name. If ``None``, no change. :param class_: The new class. If ``None``, no change. """ _libxdo.xdo_set_window_class(self._xdo, window, name, clas...
python
def set_window_class(self, window, name, class_): """ Change the window's classname and or class. :param name: The new class name. If ``None``, no change. :param class_: The new class. If ``None``, no change. """ _libxdo.xdo_set_window_class(self._xdo, window, name, clas...
[ "def", "set_window_class", "(", "self", ",", "window", ",", "name", ",", "class_", ")", ":", "_libxdo", ".", "xdo_set_window_class", "(", "self", ".", "_xdo", ",", "window", ",", "name", ",", "class_", ")" ]
Change the window's classname and or class. :param name: The new class name. If ``None``, no change. :param class_: The new class. If ``None``, no change.
[ "Change", "the", "window", "s", "classname", "and", "or", "class", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L415-L422
train
rshk/python-libxdo
xdo/__init__.py
Xdo.set_window_urgency
def set_window_urgency(self, window, urgency): """Sets the urgency hint for a window""" _libxdo.xdo_set_window_urgency(self._xdo, window, urgency)
python
def set_window_urgency(self, window, urgency): """Sets the urgency hint for a window""" _libxdo.xdo_set_window_urgency(self._xdo, window, urgency)
[ "def", "set_window_urgency", "(", "self", ",", "window", ",", "urgency", ")", ":", "_libxdo", ".", "xdo_set_window_urgency", "(", "self", ".", "_xdo", ",", "window", ",", "urgency", ")" ]
Sets the urgency hint for a window
[ "Sets", "the", "urgency", "hint", "for", "a", "window" ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L424-L426
train
rshk/python-libxdo
xdo/__init__.py
Xdo.set_window_override_redirect
def set_window_override_redirect(self, window, override_redirect): """ Set the override_redirect value for a window. This generally means whether or not a window manager will manage this window. If you set it to 1, the window manager will usually not draw borders on the window, ...
python
def set_window_override_redirect(self, window, override_redirect): """ Set the override_redirect value for a window. This generally means whether or not a window manager will manage this window. If you set it to 1, the window manager will usually not draw borders on the window, ...
[ "def", "set_window_override_redirect", "(", "self", ",", "window", ",", "override_redirect", ")", ":", "_libxdo", ".", "xdo_set_window_override_redirect", "(", "self", ".", "_xdo", ",", "window", ",", "override_redirect", ")" ]
Set the override_redirect value for a window. This generally means whether or not a window manager will manage this window. If you set it to 1, the window manager will usually not draw borders on the window, etc. If you set it to 0, the window manager will see it like a normal applicat...
[ "Set", "the", "override_redirect", "value", "for", "a", "window", ".", "This", "generally", "means", "whether", "or", "not", "a", "window", "manager", "will", "manage", "this", "window", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L428-L438
train
rshk/python-libxdo
xdo/__init__.py
Xdo.get_focused_window
def get_focused_window(self): """ Get the window currently having focus. :param window_ret: Pointer to a window where the currently-focused window will be stored. """ window_ret = window_t(0) _libxdo.xdo_get_focused_window(self._xdo, ctypes.byref(window_r...
python
def get_focused_window(self): """ Get the window currently having focus. :param window_ret: Pointer to a window where the currently-focused window will be stored. """ window_ret = window_t(0) _libxdo.xdo_get_focused_window(self._xdo, ctypes.byref(window_r...
[ "def", "get_focused_window", "(", "self", ")", ":", "window_ret", "=", "window_t", "(", "0", ")", "_libxdo", ".", "xdo_get_focused_window", "(", "self", ".", "_xdo", ",", "ctypes", ".", "byref", "(", "window_ret", ")", ")", "return", "window_ret", ".", "va...
Get the window currently having focus. :param window_ret: Pointer to a window where the currently-focused window will be stored.
[ "Get", "the", "window", "currently", "having", "focus", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L458-L468
train
rshk/python-libxdo
xdo/__init__.py
Xdo.wait_for_window_focus
def wait_for_window_focus(self, window, want_focus): """ Wait for a window to have or lose focus. :param window: The window to wait on :param want_focus: If 1, wait for focus. If 0, wait for loss of focus. """ _libxdo.xdo_wait_for_window_focus(self._xdo, window, want_foc...
python
def wait_for_window_focus(self, window, want_focus): """ Wait for a window to have or lose focus. :param window: The window to wait on :param want_focus: If 1, wait for focus. If 0, wait for loss of focus. """ _libxdo.xdo_wait_for_window_focus(self._xdo, window, want_foc...
[ "def", "wait_for_window_focus", "(", "self", ",", "window", ",", "want_focus", ")", ":", "_libxdo", ".", "xdo_wait_for_window_focus", "(", "self", ".", "_xdo", ",", "window", ",", "want_focus", ")" ]
Wait for a window to have or lose focus. :param window: The window to wait on :param want_focus: If 1, wait for focus. If 0, wait for loss of focus.
[ "Wait", "for", "a", "window", "to", "have", "or", "lose", "focus", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L470-L477
train
rshk/python-libxdo
xdo/__init__.py
Xdo.get_focused_window_sane
def get_focused_window_sane(self): """ Like xdo_get_focused_window, but return the first ancestor-or-self window * having a property of WM_CLASS. This allows you to get the "real" or top-level-ish window having focus rather than something you may not expect to be the window havin...
python
def get_focused_window_sane(self): """ Like xdo_get_focused_window, but return the first ancestor-or-self window * having a property of WM_CLASS. This allows you to get the "real" or top-level-ish window having focus rather than something you may not expect to be the window havin...
[ "def", "get_focused_window_sane", "(", "self", ")", ":", "window_ret", "=", "window_t", "(", "0", ")", "_libxdo", ".", "xdo_get_focused_window_sane", "(", "self", ".", "_xdo", ",", "ctypes", ".", "byref", "(", "window_ret", ")", ")", "return", "window_ret", ...
Like xdo_get_focused_window, but return the first ancestor-or-self window * having a property of WM_CLASS. This allows you to get the "real" or top-level-ish window having focus rather than something you may not expect to be the window having focused. :param window_ret: Poin...
[ "Like", "xdo_get_focused_window", "but", "return", "the", "first", "ancestor", "-", "or", "-", "self", "window", "*", "having", "a", "property", "of", "WM_CLASS", ".", "This", "allows", "you", "to", "get", "the", "real", "or", "top", "-", "level", "-", "...
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L490-L504
train
rshk/python-libxdo
xdo/__init__.py
Xdo.wait_for_window_active
def wait_for_window_active(self, window, active=1): """ Wait for a window to be active or not active. Requires your window manager to support this. Uses _NET_ACTIVE_WINDOW from the EWMH spec. :param window: the window to wait on :param active: If 1, wait for active. If ...
python
def wait_for_window_active(self, window, active=1): """ Wait for a window to be active or not active. Requires your window manager to support this. Uses _NET_ACTIVE_WINDOW from the EWMH spec. :param window: the window to wait on :param active: If 1, wait for active. If ...
[ "def", "wait_for_window_active", "(", "self", ",", "window", ",", "active", "=", "1", ")", ":", "_libxdo", ".", "xdo_wait_for_window_active", "(", "self", ".", "_xdo", ",", "window", ",", "active", ")" ]
Wait for a window to be active or not active. Requires your window manager to support this. Uses _NET_ACTIVE_WINDOW from the EWMH spec. :param window: the window to wait on :param active: If 1, wait for active. If 0, wait for inactive.
[ "Wait", "for", "a", "window", "to", "be", "active", "or", "not", "active", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L522-L532
train
rshk/python-libxdo
xdo/__init__.py
Xdo.reparent_window
def reparent_window(self, window_source, window_target): """ Reparents a window :param wid_source: the window to reparent :param wid_target: the new parent window """ _libxdo.xdo_reparent_window(self._xdo, window_source, window_target)
python
def reparent_window(self, window_source, window_target): """ Reparents a window :param wid_source: the window to reparent :param wid_target: the new parent window """ _libxdo.xdo_reparent_window(self._xdo, window_source, window_target)
[ "def", "reparent_window", "(", "self", ",", "window_source", ",", "window_target", ")", ":", "_libxdo", ".", "xdo_reparent_window", "(", "self", ".", "_xdo", ",", "window_source", ",", "window_target", ")" ]
Reparents a window :param wid_source: the window to reparent :param wid_target: the new parent window
[ "Reparents", "a", "window" ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L555-L562
train
rshk/python-libxdo
xdo/__init__.py
Xdo.get_window_location
def get_window_location(self, window): """ Get a window's location. """ screen_ret = Screen() x_ret = ctypes.c_int(0) y_ret = ctypes.c_int(0) _libxdo.xdo_get_window_location( self._xdo, window, ctypes.byref(x_ret), ctypes.byref(y_ret), ctyp...
python
def get_window_location(self, window): """ Get a window's location. """ screen_ret = Screen() x_ret = ctypes.c_int(0) y_ret = ctypes.c_int(0) _libxdo.xdo_get_window_location( self._xdo, window, ctypes.byref(x_ret), ctypes.byref(y_ret), ctyp...
[ "def", "get_window_location", "(", "self", ",", "window", ")", ":", "screen_ret", "=", "Screen", "(", ")", "x_ret", "=", "ctypes", ".", "c_int", "(", "0", ")", "y_ret", "=", "ctypes", ".", "c_int", "(", "0", ")", "_libxdo", ".", "xdo_get_window_location"...
Get a window's location.
[ "Get", "a", "window", "s", "location", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L564-L574
train
rshk/python-libxdo
xdo/__init__.py
Xdo.get_window_size
def get_window_size(self, window): """ Get a window's size. """ w_ret = ctypes.c_uint(0) h_ret = ctypes.c_uint(0) _libxdo.xdo_get_window_size(self._xdo, window, ctypes.byref(w_ret), ctypes.byref(h_ret)) return window_size(w_ret....
python
def get_window_size(self, window): """ Get a window's size. """ w_ret = ctypes.c_uint(0) h_ret = ctypes.c_uint(0) _libxdo.xdo_get_window_size(self._xdo, window, ctypes.byref(w_ret), ctypes.byref(h_ret)) return window_size(w_ret....
[ "def", "get_window_size", "(", "self", ",", "window", ")", ":", "w_ret", "=", "ctypes", ".", "c_uint", "(", "0", ")", "h_ret", "=", "ctypes", ".", "c_uint", "(", "0", ")", "_libxdo", ".", "xdo_get_window_size", "(", "self", ".", "_xdo", ",", "window", ...
Get a window's size.
[ "Get", "a", "window", "s", "size", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L576-L584
train
rshk/python-libxdo
xdo/__init__.py
Xdo.get_active_window
def get_active_window(self): """ Get the currently-active window. Requires your window manager to support this. Uses ``_NET_ACTIVE_WINDOW`` from the EWMH spec. """ window_ret = window_t(0) _libxdo.xdo_get_active_window(self._xdo, ctypes.byref(window_ret)) ...
python
def get_active_window(self): """ Get the currently-active window. Requires your window manager to support this. Uses ``_NET_ACTIVE_WINDOW`` from the EWMH spec. """ window_ret = window_t(0) _libxdo.xdo_get_active_window(self._xdo, ctypes.byref(window_ret)) ...
[ "def", "get_active_window", "(", "self", ")", ":", "window_ret", "=", "window_t", "(", "0", ")", "_libxdo", ".", "xdo_get_active_window", "(", "self", ".", "_xdo", ",", "ctypes", ".", "byref", "(", "window_ret", ")", ")", "return", "window_ret", ".", "valu...
Get the currently-active window. Requires your window manager to support this. Uses ``_NET_ACTIVE_WINDOW`` from the EWMH spec.
[ "Get", "the", "currently", "-", "active", "window", ".", "Requires", "your", "window", "manager", "to", "support", "this", ".", "Uses", "_NET_ACTIVE_WINDOW", "from", "the", "EWMH", "spec", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L586-L594
train
rshk/python-libxdo
xdo/__init__.py
Xdo.select_window_with_click
def select_window_with_click(self): """ Get a window ID by clicking on it. This function blocks until a selection is made. """ window_ret = window_t(0) _libxdo.xdo_select_window_with_click( self._xdo, ctypes.byref(window_ret)) return window_ret.value
python
def select_window_with_click(self): """ Get a window ID by clicking on it. This function blocks until a selection is made. """ window_ret = window_t(0) _libxdo.xdo_select_window_with_click( self._xdo, ctypes.byref(window_ret)) return window_ret.value
[ "def", "select_window_with_click", "(", "self", ")", ":", "window_ret", "=", "window_t", "(", "0", ")", "_libxdo", ".", "xdo_select_window_with_click", "(", "self", ".", "_xdo", ",", "ctypes", ".", "byref", "(", "window_ret", ")", ")", "return", "window_ret", ...
Get a window ID by clicking on it. This function blocks until a selection is made.
[ "Get", "a", "window", "ID", "by", "clicking", "on", "it", ".", "This", "function", "blocks", "until", "a", "selection", "is", "made", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L596-L604
train
rshk/python-libxdo
xdo/__init__.py
Xdo.get_number_of_desktops
def get_number_of_desktops(self): """ Get the current number of desktops. Uses ``_NET_NUMBER_OF_DESKTOPS`` of the EWMH spec. :param ndesktops: pointer to long where the current number of desktops is stored """ ndesktops = ctypes.c_long(0) _libxdo.xdo_...
python
def get_number_of_desktops(self): """ Get the current number of desktops. Uses ``_NET_NUMBER_OF_DESKTOPS`` of the EWMH spec. :param ndesktops: pointer to long where the current number of desktops is stored """ ndesktops = ctypes.c_long(0) _libxdo.xdo_...
[ "def", "get_number_of_desktops", "(", "self", ")", ":", "ndesktops", "=", "ctypes", ".", "c_long", "(", "0", ")", "_libxdo", ".", "xdo_get_number_of_desktops", "(", "self", ".", "_xdo", ",", "ctypes", ".", "byref", "(", "ndesktops", ")", ")", "return", "nd...
Get the current number of desktops. Uses ``_NET_NUMBER_OF_DESKTOPS`` of the EWMH spec. :param ndesktops: pointer to long where the current number of desktops is stored
[ "Get", "the", "current", "number", "of", "desktops", ".", "Uses", "_NET_NUMBER_OF_DESKTOPS", "of", "the", "EWMH", "spec", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L615-L625
train
rshk/python-libxdo
xdo/__init__.py
Xdo.get_current_desktop
def get_current_desktop(self): """ Get the current desktop. Uses ``_NET_CURRENT_DESKTOP`` of the EWMH spec. """ desktop = ctypes.c_long(0) _libxdo.xdo_get_current_desktop(self._xdo, ctypes.byref(desktop)) return desktop.value
python
def get_current_desktop(self): """ Get the current desktop. Uses ``_NET_CURRENT_DESKTOP`` of the EWMH spec. """ desktop = ctypes.c_long(0) _libxdo.xdo_get_current_desktop(self._xdo, ctypes.byref(desktop)) return desktop.value
[ "def", "get_current_desktop", "(", "self", ")", ":", "desktop", "=", "ctypes", ".", "c_long", "(", "0", ")", "_libxdo", ".", "xdo_get_current_desktop", "(", "self", ".", "_xdo", ",", "ctypes", ".", "byref", "(", "desktop", ")", ")", "return", "desktop", ...
Get the current desktop. Uses ``_NET_CURRENT_DESKTOP`` of the EWMH spec.
[ "Get", "the", "current", "desktop", ".", "Uses", "_NET_CURRENT_DESKTOP", "of", "the", "EWMH", "spec", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L636-L643
train
rshk/python-libxdo
xdo/__init__.py
Xdo.set_desktop_for_window
def set_desktop_for_window(self, window, desktop): """ Move a window to another desktop Uses _NET_WM_DESKTOP of the EWMH spec. :param wid: the window to move :param desktop: the desktop destination for the window """ _libxdo.xdo_set_desktop_for_window(self._xdo, ...
python
def set_desktop_for_window(self, window, desktop): """ Move a window to another desktop Uses _NET_WM_DESKTOP of the EWMH spec. :param wid: the window to move :param desktop: the desktop destination for the window """ _libxdo.xdo_set_desktop_for_window(self._xdo, ...
[ "def", "set_desktop_for_window", "(", "self", ",", "window", ",", "desktop", ")", ":", "_libxdo", ".", "xdo_set_desktop_for_window", "(", "self", ".", "_xdo", ",", "window", ",", "desktop", ")" ]
Move a window to another desktop Uses _NET_WM_DESKTOP of the EWMH spec. :param wid: the window to move :param desktop: the desktop destination for the window
[ "Move", "a", "window", "to", "another", "desktop", "Uses", "_NET_WM_DESKTOP", "of", "the", "EWMH", "spec", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L645-L653
train
rshk/python-libxdo
xdo/__init__.py
Xdo.get_desktop_for_window
def get_desktop_for_window(self, window): """ Get the desktop a window is on. Uses _NET_WM_DESKTOP of the EWMH spec. If your desktop does not support ``_NET_WM_DESKTOP``, then '*desktop' remains unmodified. :param wid: the window to query """ desktop = c...
python
def get_desktop_for_window(self, window): """ Get the desktop a window is on. Uses _NET_WM_DESKTOP of the EWMH spec. If your desktop does not support ``_NET_WM_DESKTOP``, then '*desktop' remains unmodified. :param wid: the window to query """ desktop = c...
[ "def", "get_desktop_for_window", "(", "self", ",", "window", ")", ":", "desktop", "=", "ctypes", ".", "c_long", "(", "0", ")", "_libxdo", ".", "xdo_get_desktop_for_window", "(", "self", ".", "_xdo", ",", "window", ",", "ctypes", ".", "byref", "(", "desktop...
Get the desktop a window is on. Uses _NET_WM_DESKTOP of the EWMH spec. If your desktop does not support ``_NET_WM_DESKTOP``, then '*desktop' remains unmodified. :param wid: the window to query
[ "Get", "the", "desktop", "a", "window", "is", "on", ".", "Uses", "_NET_WM_DESKTOP", "of", "the", "EWMH", "spec", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L655-L668
train
rshk/python-libxdo
xdo/__init__.py
Xdo.search_windows
def search_windows( self, winname=None, winclass=None, winclassname=None, pid=None, only_visible=False, screen=None, require=False, searchmask=0, desktop=None, limit=0, max_depth=-1): """ Search for windows. :param winname: Regexp to be matched ag...
python
def search_windows( self, winname=None, winclass=None, winclassname=None, pid=None, only_visible=False, screen=None, require=False, searchmask=0, desktop=None, limit=0, max_depth=-1): """ Search for windows. :param winname: Regexp to be matched ag...
[ "def", "search_windows", "(", "self", ",", "winname", "=", "None", ",", "winclass", "=", "None", ",", "winclassname", "=", "None", ",", "pid", "=", "None", ",", "only_visible", "=", "False", ",", "screen", "=", "None", ",", "require", "=", "False", ","...
Search for windows. :param winname: Regexp to be matched against window name :param winclass: Regexp to be matched against window class :param winclassname: Regexp to be matched against window class name :param pid: Only return windows fro...
[ "Search", "for", "windows", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L670-L743
train
rshk/python-libxdo
xdo/__init__.py
Xdo.get_symbol_map
def get_symbol_map(self): """ If you need the symbol map, use this method. The symbol map is an array of string pairs mapping common tokens to X Keysym strings, such as "alt" to "Alt_L" :return: array of strings. """ # todo: make sure we return a list of strings...
python
def get_symbol_map(self): """ If you need the symbol map, use this method. The symbol map is an array of string pairs mapping common tokens to X Keysym strings, such as "alt" to "Alt_L" :return: array of strings. """ # todo: make sure we return a list of strings...
[ "def", "get_symbol_map", "(", "self", ")", ":", "# todo: make sure we return a list of strings!", "sm", "=", "_libxdo", ".", "xdo_get_symbol_map", "(", ")", "# Return value is like:", "# ['alt', 'Alt_L', ..., None, None, None, ...]", "# We want to return only values up to the first N...
If you need the symbol map, use this method. The symbol map is an array of string pairs mapping common tokens to X Keysym strings, such as "alt" to "Alt_L" :return: array of strings.
[ "If", "you", "need", "the", "symbol", "map", "use", "this", "method", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L782-L805
train
rshk/python-libxdo
xdo/__init__.py
Xdo.get_active_modifiers
def get_active_modifiers(self): """ Get a list of active keys. Uses XQueryKeymap. :return: list of charcodemap_t instances """ keys = ctypes.pointer(charcodemap_t()) nkeys = ctypes.c_int(0) _libxdo.xdo_get_active_modifiers( self._xdo, ctypes.byref(ke...
python
def get_active_modifiers(self): """ Get a list of active keys. Uses XQueryKeymap. :return: list of charcodemap_t instances """ keys = ctypes.pointer(charcodemap_t()) nkeys = ctypes.c_int(0) _libxdo.xdo_get_active_modifiers( self._xdo, ctypes.byref(ke...
[ "def", "get_active_modifiers", "(", "self", ")", ":", "keys", "=", "ctypes", ".", "pointer", "(", "charcodemap_t", "(", ")", ")", "nkeys", "=", "ctypes", ".", "c_int", "(", "0", ")", "_libxdo", ".", "xdo_get_active_modifiers", "(", "self", ".", "_xdo", "...
Get a list of active keys. Uses XQueryKeymap. :return: list of charcodemap_t instances
[ "Get", "a", "list", "of", "active", "keys", ".", "Uses", "XQueryKeymap", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L807-L818
train
rshk/python-libxdo
xdo/__init__.py
Xdo.get_window_name
def get_window_name(self, win_id): """ Get a window's name, if any. """ window = window_t(win_id) name_ptr = ctypes.c_char_p() name_len = ctypes.c_int(0) name_type = ctypes.c_int(0) _libxdo.xdo_get_window_name( self._xdo, window, ctypes.byref(n...
python
def get_window_name(self, win_id): """ Get a window's name, if any. """ window = window_t(win_id) name_ptr = ctypes.c_char_p() name_len = ctypes.c_int(0) name_type = ctypes.c_int(0) _libxdo.xdo_get_window_name( self._xdo, window, ctypes.byref(n...
[ "def", "get_window_name", "(", "self", ",", "win_id", ")", ":", "window", "=", "window_t", "(", "win_id", ")", "name_ptr", "=", "ctypes", ".", "c_char_p", "(", ")", "name_len", "=", "ctypes", ".", "c_int", "(", "0", ")", "name_type", "=", "ctypes", "."...
Get a window's name, if any.
[ "Get", "a", "window", "s", "name", "if", "any", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L870-L883
train
canonical-ols/acceptable
acceptable/__main__.py
import_metadata
def import_metadata(module_paths): """Import all the given modules""" cwd = os.getcwd() if cwd not in sys.path: sys.path.insert(0, cwd) modules = [] try: for path in module_paths: modules.append(import_module(path)) except ImportError as e: err = RuntimeError(...
python
def import_metadata(module_paths): """Import all the given modules""" cwd = os.getcwd() if cwd not in sys.path: sys.path.insert(0, cwd) modules = [] try: for path in module_paths: modules.append(import_module(path)) except ImportError as e: err = RuntimeError(...
[ "def", "import_metadata", "(", "module_paths", ")", ":", "cwd", "=", "os", ".", "getcwd", "(", ")", "if", "cwd", "not", "in", "sys", ".", "path", ":", "sys", ".", "path", ".", "insert", "(", "0", ",", "cwd", ")", "modules", "=", "[", "]", "try", ...
Import all the given modules
[ "Import", "all", "the", "given", "modules" ]
6ccbe969078166a5315d857da38b59b43b29fadc
https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/__main__.py#L184-L196
train
canonical-ols/acceptable
acceptable/__main__.py
load_metadata
def load_metadata(stream): """Load JSON metadata from opened stream.""" try: metadata = json.load( stream, encoding='utf8', object_pairs_hook=OrderedDict) except json.JSONDecodeError as e: err = RuntimeError('Error parsing {}: {}'.format(stream.name, e)) raise_from(err, e...
python
def load_metadata(stream): """Load JSON metadata from opened stream.""" try: metadata = json.load( stream, encoding='utf8', object_pairs_hook=OrderedDict) except json.JSONDecodeError as e: err = RuntimeError('Error parsing {}: {}'.format(stream.name, e)) raise_from(err, e...
[ "def", "load_metadata", "(", "stream", ")", ":", "try", ":", "metadata", "=", "json", ".", "load", "(", "stream", ",", "encoding", "=", "'utf8'", ",", "object_pairs_hook", "=", "OrderedDict", ")", "except", "json", ".", "JSONDecodeError", "as", "e", ":", ...
Load JSON metadata from opened stream.
[ "Load", "JSON", "metadata", "from", "opened", "stream", "." ]
6ccbe969078166a5315d857da38b59b43b29fadc
https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/__main__.py#L199-L221
train
elifesciences/elife-tools
elifetools/utils.py
strip_punctuation_space
def strip_punctuation_space(value): "Strip excess whitespace prior to punctuation." def strip_punctuation(string): replacement_list = ( (' .', '.'), (' :', ':'), ('( ', '('), (' )', ')'), ) for match, replacement in replacement_list: ...
python
def strip_punctuation_space(value): "Strip excess whitespace prior to punctuation." def strip_punctuation(string): replacement_list = ( (' .', '.'), (' :', ':'), ('( ', '('), (' )', ')'), ) for match, replacement in replacement_list: ...
[ "def", "strip_punctuation_space", "(", "value", ")", ":", "def", "strip_punctuation", "(", "string", ")", ":", "replacement_list", "=", "(", "(", "' .'", ",", "'.'", ")", ",", "(", "' :'", ",", "':'", ")", ",", "(", "'( '", ",", "'('", ")", ",", "(",...
Strip excess whitespace prior to punctuation.
[ "Strip", "excess", "whitespace", "prior", "to", "punctuation", "." ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L47-L63
train
elifesciences/elife-tools
elifetools/utils.py
join_sentences
def join_sentences(string1, string2, glue='.'): "concatenate two sentences together with punctuation glue" if not string1 or string1 == '': return string2 if not string2 or string2 == '': return string1 # both are strings, continue joining them together with the glue and whitespace n...
python
def join_sentences(string1, string2, glue='.'): "concatenate two sentences together with punctuation glue" if not string1 or string1 == '': return string2 if not string2 or string2 == '': return string1 # both are strings, continue joining them together with the glue and whitespace n...
[ "def", "join_sentences", "(", "string1", ",", "string2", ",", "glue", "=", "'.'", ")", ":", "if", "not", "string1", "or", "string1", "==", "''", ":", "return", "string2", "if", "not", "string2", "or", "string2", "==", "''", ":", "return", "string1", "#...
concatenate two sentences together with punctuation glue
[ "concatenate", "two", "sentences", "together", "with", "punctuation", "glue" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L65-L76
train
elifesciences/elife-tools
elifetools/utils.py
coerce_to_int
def coerce_to_int(val, default=0xDEADBEEF): """Attempts to cast given value to an integer, return the original value if failed or the default if one provided.""" try: return int(val) except (TypeError, ValueError): if default != 0xDEADBEEF: return default return val
python
def coerce_to_int(val, default=0xDEADBEEF): """Attempts to cast given value to an integer, return the original value if failed or the default if one provided.""" try: return int(val) except (TypeError, ValueError): if default != 0xDEADBEEF: return default return val
[ "def", "coerce_to_int", "(", "val", ",", "default", "=", "0xDEADBEEF", ")", ":", "try", ":", "return", "int", "(", "val", ")", "except", "(", "TypeError", ",", "ValueError", ")", ":", "if", "default", "!=", "0xDEADBEEF", ":", "return", "default", "return...
Attempts to cast given value to an integer, return the original value if failed or the default if one provided.
[ "Attempts", "to", "cast", "given", "value", "to", "an", "integer", "return", "the", "original", "value", "if", "failed", "or", "the", "default", "if", "one", "provided", "." ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L78-L85
train
elifesciences/elife-tools
elifetools/utils.py
nullify
def nullify(function): "Decorator. If empty list, returns None, else list." def wrapper(*args, **kwargs): value = function(*args, **kwargs) if(type(value) == list and len(value) == 0): return None return value return wrapper
python
def nullify(function): "Decorator. If empty list, returns None, else list." def wrapper(*args, **kwargs): value = function(*args, **kwargs) if(type(value) == list and len(value) == 0): return None return value return wrapper
[ "def", "nullify", "(", "function", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "value", "=", "function", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "(", "type", "(", "value", ")", "==", "list", "a...
Decorator. If empty list, returns None, else list.
[ "Decorator", ".", "If", "empty", "list", "returns", "None", "else", "list", "." ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L88-L95
train
elifesciences/elife-tools
elifetools/utils.py
strippen
def strippen(function): "Decorator. Strip excess whitespace from return value." def wrapper(*args, **kwargs): return strip_strings(function(*args, **kwargs)) return wrapper
python
def strippen(function): "Decorator. Strip excess whitespace from return value." def wrapper(*args, **kwargs): return strip_strings(function(*args, **kwargs)) return wrapper
[ "def", "strippen", "(", "function", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "strip_strings", "(", "function", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")", "return", "wrapper" ]
Decorator. Strip excess whitespace from return value.
[ "Decorator", ".", "Strip", "excess", "whitespace", "from", "return", "value", "." ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L97-L101
train
elifesciences/elife-tools
elifetools/utils.py
inten
def inten(function): "Decorator. Attempts to convert return value to int" def wrapper(*args, **kwargs): return coerce_to_int(function(*args, **kwargs)) return wrapper
python
def inten(function): "Decorator. Attempts to convert return value to int" def wrapper(*args, **kwargs): return coerce_to_int(function(*args, **kwargs)) return wrapper
[ "def", "inten", "(", "function", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "coerce_to_int", "(", "function", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")", "return", "wrapper" ]
Decorator. Attempts to convert return value to int
[ "Decorator", ".", "Attempts", "to", "convert", "return", "value", "to", "int" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L103-L107
train
elifesciences/elife-tools
elifetools/utils.py
date_struct
def date_struct(year, month, day, tz = "UTC"): """ Given year, month and day numeric values and a timezone convert to structured date object """ ymdtz = (year, month, day, tz) if None in ymdtz: #logger.debug("a year, month, day or tz value was empty: %s" % str(ymdtz)) return None...
python
def date_struct(year, month, day, tz = "UTC"): """ Given year, month and day numeric values and a timezone convert to structured date object """ ymdtz = (year, month, day, tz) if None in ymdtz: #logger.debug("a year, month, day or tz value was empty: %s" % str(ymdtz)) return None...
[ "def", "date_struct", "(", "year", ",", "month", ",", "day", ",", "tz", "=", "\"UTC\"", ")", ":", "ymdtz", "=", "(", "year", ",", "month", ",", "day", ",", "tz", ")", "if", "None", "in", "ymdtz", ":", "#logger.debug(\"a year, month, day or tz value was emp...
Given year, month and day numeric values and a timezone convert to structured date object
[ "Given", "year", "month", "and", "day", "numeric", "values", "and", "a", "timezone", "convert", "to", "structured", "date", "object" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L119-L132
train
elifesciences/elife-tools
elifetools/utils.py
date_struct_nn
def date_struct_nn(year, month, day, tz="UTC"): """ Assemble a date object but if day or month is none set them to 1 to make it easier to deal with partial dates """ if not day: day = 1 if not month: month = 1 return date_struct(year, month, day, tz)
python
def date_struct_nn(year, month, day, tz="UTC"): """ Assemble a date object but if day or month is none set them to 1 to make it easier to deal with partial dates """ if not day: day = 1 if not month: month = 1 return date_struct(year, month, day, tz)
[ "def", "date_struct_nn", "(", "year", ",", "month", ",", "day", ",", "tz", "=", "\"UTC\"", ")", ":", "if", "not", "day", ":", "day", "=", "1", "if", "not", "month", ":", "month", "=", "1", "return", "date_struct", "(", "year", ",", "month", ",", ...
Assemble a date object but if day or month is none set them to 1 to make it easier to deal with partial dates
[ "Assemble", "a", "date", "object", "but", "if", "day", "or", "month", "is", "none", "set", "them", "to", "1", "to", "make", "it", "easier", "to", "deal", "with", "partial", "dates" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L134-L143
train
elifesciences/elife-tools
elifetools/utils.py
doi_uri_to_doi
def doi_uri_to_doi(value): "Strip the uri schema from the start of DOI URL strings" if value is None: return value replace_values = ['http://dx.doi.org/', 'https://dx.doi.org/', 'http://doi.org/', 'https://doi.org/'] for replace_value in replace_values: value = valu...
python
def doi_uri_to_doi(value): "Strip the uri schema from the start of DOI URL strings" if value is None: return value replace_values = ['http://dx.doi.org/', 'https://dx.doi.org/', 'http://doi.org/', 'https://doi.org/'] for replace_value in replace_values: value = valu...
[ "def", "doi_uri_to_doi", "(", "value", ")", ":", "if", "value", "is", "None", ":", "return", "value", "replace_values", "=", "[", "'http://dx.doi.org/'", ",", "'https://dx.doi.org/'", ",", "'http://doi.org/'", ",", "'https://doi.org/'", "]", "for", "replace_value", ...
Strip the uri schema from the start of DOI URL strings
[ "Strip", "the", "uri", "schema", "from", "the", "start", "of", "DOI", "URL", "strings" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L195-L203
train
elifesciences/elife-tools
elifetools/utils.py
remove_doi_paragraph
def remove_doi_paragraph(tags): "Given a list of tags, only return those whose text doesn't start with 'DOI:'" p_tags = list(filter(lambda tag: not starts_with_doi(tag), tags)) p_tags = list(filter(lambda tag: not paragraph_is_only_doi(tag), p_tags)) return p_tags
python
def remove_doi_paragraph(tags): "Given a list of tags, only return those whose text doesn't start with 'DOI:'" p_tags = list(filter(lambda tag: not starts_with_doi(tag), tags)) p_tags = list(filter(lambda tag: not paragraph_is_only_doi(tag), p_tags)) return p_tags
[ "def", "remove_doi_paragraph", "(", "tags", ")", ":", "p_tags", "=", "list", "(", "filter", "(", "lambda", "tag", ":", "not", "starts_with_doi", "(", "tag", ")", ",", "tags", ")", ")", "p_tags", "=", "list", "(", "filter", "(", "lambda", "tag", ":", ...
Given a list of tags, only return those whose text doesn't start with 'DOI:
[ "Given", "a", "list", "of", "tags", "only", "return", "those", "whose", "text", "doesn", "t", "start", "with", "DOI", ":" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L212-L216
train
elifesciences/elife-tools
elifetools/utils.py
orcid_uri_to_orcid
def orcid_uri_to_orcid(value): "Strip the uri schema from the start of ORCID URL strings" if value is None: return value replace_values = ['http://orcid.org/', 'https://orcid.org/'] for replace_value in replace_values: value = value.replace(replace_value, '') return value
python
def orcid_uri_to_orcid(value): "Strip the uri schema from the start of ORCID URL strings" if value is None: return value replace_values = ['http://orcid.org/', 'https://orcid.org/'] for replace_value in replace_values: value = value.replace(replace_value, '') return value
[ "def", "orcid_uri_to_orcid", "(", "value", ")", ":", "if", "value", "is", "None", ":", "return", "value", "replace_values", "=", "[", "'http://orcid.org/'", ",", "'https://orcid.org/'", "]", "for", "replace_value", "in", "replace_values", ":", "value", "=", "val...
Strip the uri schema from the start of ORCID URL strings
[ "Strip", "the", "uri", "schema", "from", "the", "start", "of", "ORCID", "URL", "strings" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L218-L225
train
elifesciences/elife-tools
elifetools/utils.py
component_acting_parent_tag
def component_acting_parent_tag(parent_tag, tag): """ Only intended for use in getting components, look for tag name of fig-group and if so, find the first fig tag inside it as the acting parent tag """ if parent_tag.name == "fig-group": if (len(tag.find_previous_siblings("fig")) > 0): ...
python
def component_acting_parent_tag(parent_tag, tag): """ Only intended for use in getting components, look for tag name of fig-group and if so, find the first fig tag inside it as the acting parent tag """ if parent_tag.name == "fig-group": if (len(tag.find_previous_siblings("fig")) > 0): ...
[ "def", "component_acting_parent_tag", "(", "parent_tag", ",", "tag", ")", ":", "if", "parent_tag", ".", "name", "==", "\"fig-group\"", ":", "if", "(", "len", "(", "tag", ".", "find_previous_siblings", "(", "\"fig\"", ")", ")", ">", "0", ")", ":", "acting_p...
Only intended for use in getting components, look for tag name of fig-group and if so, find the first fig tag inside it as the acting parent tag
[ "Only", "intended", "for", "use", "in", "getting", "components", "look", "for", "tag", "name", "of", "fig", "-", "group", "and", "if", "so", "find", "the", "first", "fig", "tag", "inside", "it", "as", "the", "acting", "parent", "tag" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L235-L248
train
elifesciences/elife-tools
elifetools/utils.py
extract_nodes
def extract_nodes(soup, nodename, attr = None, value = None): """ Returns a list of tags (nodes) from the given soup matching the given nodename. If an optional attribute and value are given, these are used to filter the results further.""" tags = soup.find_all(nodename) if attr != None and valu...
python
def extract_nodes(soup, nodename, attr = None, value = None): """ Returns a list of tags (nodes) from the given soup matching the given nodename. If an optional attribute and value are given, these are used to filter the results further.""" tags = soup.find_all(nodename) if attr != None and valu...
[ "def", "extract_nodes", "(", "soup", ",", "nodename", ",", "attr", "=", "None", ",", "value", "=", "None", ")", ":", "tags", "=", "soup", ".", "find_all", "(", "nodename", ")", "if", "attr", "!=", "None", "and", "value", "!=", "None", ":", "return", ...
Returns a list of tags (nodes) from the given soup matching the given nodename. If an optional attribute and value are given, these are used to filter the results further.
[ "Returns", "a", "list", "of", "tags", "(", "nodes", ")", "from", "the", "given", "soup", "matching", "the", "given", "nodename", ".", "If", "an", "optional", "attribute", "and", "value", "are", "given", "these", "are", "used", "to", "filter", "the", "res...
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L254-L262
train
elifesciences/elife-tools
elifetools/utils.py
node_contents_str
def node_contents_str(tag): """ Return the contents of a tag, including it's children, as a string. Does not include the root/parent of the tag. """ if not tag: return None tag_string = '' for child_tag in tag.children: if isinstance(child_tag, Comment): # Beautif...
python
def node_contents_str(tag): """ Return the contents of a tag, including it's children, as a string. Does not include the root/parent of the tag. """ if not tag: return None tag_string = '' for child_tag in tag.children: if isinstance(child_tag, Comment): # Beautif...
[ "def", "node_contents_str", "(", "tag", ")", ":", "if", "not", "tag", ":", "return", "None", "tag_string", "=", "''", "for", "child_tag", "in", "tag", ".", "children", ":", "if", "isinstance", "(", "child_tag", ",", "Comment", ")", ":", "# BeautifulSoup do...
Return the contents of a tag, including it's children, as a string. Does not include the root/parent of the tag.
[ "Return", "the", "contents", "of", "a", "tag", "including", "it", "s", "children", "as", "a", "string", ".", "Does", "not", "include", "the", "root", "/", "parent", "of", "the", "tag", "." ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L268-L282
train
elifesciences/elife-tools
elifetools/utils.py
first_parent
def first_parent(tag, nodename): """ Given a beautiful soup tag, look at its parents and return the first tag name that matches nodename or the list nodename """ if nodename is not None and type(nodename) == str: nodename = [nodename] return first(list(filter(lambda tag: tag.name in node...
python
def first_parent(tag, nodename): """ Given a beautiful soup tag, look at its parents and return the first tag name that matches nodename or the list nodename """ if nodename is not None and type(nodename) == str: nodename = [nodename] return first(list(filter(lambda tag: tag.name in node...
[ "def", "first_parent", "(", "tag", ",", "nodename", ")", ":", "if", "nodename", "is", "not", "None", "and", "type", "(", "nodename", ")", "==", "str", ":", "nodename", "=", "[", "nodename", "]", "return", "first", "(", "list", "(", "filter", "(", "la...
Given a beautiful soup tag, look at its parents and return the first tag name that matches nodename or the list nodename
[ "Given", "a", "beautiful", "soup", "tag", "look", "at", "its", "parents", "and", "return", "the", "first", "tag", "name", "that", "matches", "nodename", "or", "the", "list", "nodename" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L284-L291
train
elifesciences/elife-tools
elifetools/utils.py
tag_fig_ordinal
def tag_fig_ordinal(tag): """ Meant for finding the position of fig tags with respect to whether they are for a main figure or a child figure """ tag_count = 0 if 'specific-use' not in tag.attrs: # Look for tags with no "specific-use" attribute return len(list(filter(lambda tag: ...
python
def tag_fig_ordinal(tag): """ Meant for finding the position of fig tags with respect to whether they are for a main figure or a child figure """ tag_count = 0 if 'specific-use' not in tag.attrs: # Look for tags with no "specific-use" attribute return len(list(filter(lambda tag: ...
[ "def", "tag_fig_ordinal", "(", "tag", ")", ":", "tag_count", "=", "0", "if", "'specific-use'", "not", "in", "tag", ".", "attrs", ":", "# Look for tags with no \"specific-use\" attribute", "return", "len", "(", "list", "(", "filter", "(", "lambda", "tag", ":", ...
Meant for finding the position of fig tags with respect to whether they are for a main figure or a child figure
[ "Meant", "for", "finding", "the", "position", "of", "fig", "tags", "with", "respect", "to", "whether", "they", "are", "for", "a", "main", "figure", "or", "a", "child", "figure" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L302-L311
train
elifesciences/elife-tools
elifetools/utils.py
tag_limit_sibling_ordinal
def tag_limit_sibling_ordinal(tag, stop_tag_name): """ Count previous tags of the same name until it reaches a tag name of type stop_tag, then stop counting """ tag_count = 1 for prev_tag in tag.previous_elements: if prev_tag.name == tag.name: tag_count += 1 if prev_t...
python
def tag_limit_sibling_ordinal(tag, stop_tag_name): """ Count previous tags of the same name until it reaches a tag name of type stop_tag, then stop counting """ tag_count = 1 for prev_tag in tag.previous_elements: if prev_tag.name == tag.name: tag_count += 1 if prev_t...
[ "def", "tag_limit_sibling_ordinal", "(", "tag", ",", "stop_tag_name", ")", ":", "tag_count", "=", "1", "for", "prev_tag", "in", "tag", ".", "previous_elements", ":", "if", "prev_tag", ".", "name", "==", "tag", ".", "name", ":", "tag_count", "+=", "1", "if"...
Count previous tags of the same name until it reaches a tag name of type stop_tag, then stop counting
[ "Count", "previous", "tags", "of", "the", "same", "name", "until", "it", "reaches", "a", "tag", "name", "of", "type", "stop_tag", "then", "stop", "counting" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L323-L335
train
elifesciences/elife-tools
elifetools/utils.py
tag_media_sibling_ordinal
def tag_media_sibling_ordinal(tag): """ Count sibling ordinal differently depending on if the mimetype is video or not """ if hasattr(tag, 'name') and tag.name != 'media': return None nodenames = ['fig','supplementary-material','sub-article'] first_parent_tag = first_parent(tag, nod...
python
def tag_media_sibling_ordinal(tag): """ Count sibling ordinal differently depending on if the mimetype is video or not """ if hasattr(tag, 'name') and tag.name != 'media': return None nodenames = ['fig','supplementary-material','sub-article'] first_parent_tag = first_parent(tag, nod...
[ "def", "tag_media_sibling_ordinal", "(", "tag", ")", ":", "if", "hasattr", "(", "tag", ",", "'name'", ")", "and", "tag", ".", "name", "!=", "'media'", ":", "return", "None", "nodenames", "=", "[", "'fig'", ",", "'supplementary-material'", ",", "'sub-article'...
Count sibling ordinal differently depending on if the mimetype is video or not
[ "Count", "sibling", "ordinal", "differently", "depending", "on", "if", "the", "mimetype", "is", "video", "or", "not" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L343-L387
train
elifesciences/elife-tools
elifetools/utils.py
tag_supplementary_material_sibling_ordinal
def tag_supplementary_material_sibling_ordinal(tag): """ Strategy is to count the previous supplementary-material tags having the same asset value to get its sibling ordinal. The result is its position inside any parent tag that are the same asset type """ if hasattr(tag, 'name') and tag.nam...
python
def tag_supplementary_material_sibling_ordinal(tag): """ Strategy is to count the previous supplementary-material tags having the same asset value to get its sibling ordinal. The result is its position inside any parent tag that are the same asset type """ if hasattr(tag, 'name') and tag.nam...
[ "def", "tag_supplementary_material_sibling_ordinal", "(", "tag", ")", ":", "if", "hasattr", "(", "tag", ",", "'name'", ")", "and", "tag", ".", "name", "!=", "'supplementary-material'", ":", "return", "None", "nodenames", "=", "[", "'fig'", ",", "'media'", ",",...
Strategy is to count the previous supplementary-material tags having the same asset value to get its sibling ordinal. The result is its position inside any parent tag that are the same asset type
[ "Strategy", "is", "to", "count", "the", "previous", "supplementary", "-", "material", "tags", "having", "the", "same", "asset", "value", "to", "get", "its", "sibling", "ordinal", ".", "The", "result", "is", "its", "position", "inside", "any", "parent", "tag"...
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L389-L422
train
elifesciences/elife-tools
elifetools/utils.py
supp_asset
def supp_asset(tag): """ Given a supplementary-material tag, the asset value depends on its label text. This also informs in what order (its ordinal) it has depending on how many of each type is present """ # Default asset = 'supp' if first(extract_nodes(tag, "label")): label_tex...
python
def supp_asset(tag): """ Given a supplementary-material tag, the asset value depends on its label text. This also informs in what order (its ordinal) it has depending on how many of each type is present """ # Default asset = 'supp' if first(extract_nodes(tag, "label")): label_tex...
[ "def", "supp_asset", "(", "tag", ")", ":", "# Default", "asset", "=", "'supp'", "if", "first", "(", "extract_nodes", "(", "tag", ",", "\"label\"", ")", ")", ":", "label_text", "=", "node_text", "(", "first", "(", "extract_nodes", "(", "tag", ",", "\"labe...
Given a supplementary-material tag, the asset value depends on its label text. This also informs in what order (its ordinal) it has depending on how many of each type is present
[ "Given", "a", "supplementary", "-", "material", "tag", "the", "asset", "value", "depends", "on", "its", "label", "text", ".", "This", "also", "informs", "in", "what", "order", "(", "its", "ordinal", ")", "it", "has", "depending", "on", "how", "many", "of...
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L425-L440
train
elifesciences/elife-tools
elifetools/utils.py
text_to_title
def text_to_title(value): """when a title is required, generate one from the value""" title = None if not value: return title words = value.split(" ") keep_words = [] for word in words: if word.endswith(".") or word.endswith(":"): keep_words.append(word) i...
python
def text_to_title(value): """when a title is required, generate one from the value""" title = None if not value: return title words = value.split(" ") keep_words = [] for word in words: if word.endswith(".") or word.endswith(":"): keep_words.append(word) i...
[ "def", "text_to_title", "(", "value", ")", ":", "title", "=", "None", "if", "not", "value", ":", "return", "title", "words", "=", "value", ".", "split", "(", "\" \"", ")", "keep_words", "=", "[", "]", "for", "word", "in", "words", ":", "if", "word", ...
when a title is required, generate one from the value
[ "when", "a", "title", "is", "required", "generate", "one", "from", "the", "value" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L460-L478
train
elifesciences/elife-tools
elifetools/utils.py
escape_unmatched_angle_brackets
def escape_unmatched_angle_brackets(string, allowed_tag_fragments=()): """ In order to make an XML string less malformed, escape unmatched less than tags that are not part of an allowed tag Note: Very, very basic, and do not try regex \1 style replacements on unicode ever again! Instead this uses ...
python
def escape_unmatched_angle_brackets(string, allowed_tag_fragments=()): """ In order to make an XML string less malformed, escape unmatched less than tags that are not part of an allowed tag Note: Very, very basic, and do not try regex \1 style replacements on unicode ever again! Instead this uses ...
[ "def", "escape_unmatched_angle_brackets", "(", "string", ",", "allowed_tag_fragments", "=", "(", ")", ")", ":", "if", "not", "string", ":", "return", "string", "# Split string on tags", "tags", "=", "re", ".", "split", "(", "'(<.*?>)'", ",", "string", ")", "#p...
In order to make an XML string less malformed, escape unmatched less than tags that are not part of an allowed tag Note: Very, very basic, and do not try regex \1 style replacements on unicode ever again! Instead this uses string replace allowed_tag_fragments is a tuple of tag name matches for use wit...
[ "In", "order", "to", "make", "an", "XML", "string", "less", "malformed", "escape", "unmatched", "less", "than", "tags", "that", "are", "not", "part", "of", "an", "allowed", "tag", "Note", ":", "Very", "very", "basic", "and", "do", "not", "try", "regex", ...
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L486-L521
train
elifesciences/elife-tools
elifetools/utils.py
escape_ampersand
def escape_ampersand(string): """ Quick convert unicode ampersand characters not associated with a numbered entity or not starting with allowed characters to a plain &amp; """ if not string: return string start_with_match = r"(\#x(....);|lt;|gt;|amp;)" # The pattern below is match & ...
python
def escape_ampersand(string): """ Quick convert unicode ampersand characters not associated with a numbered entity or not starting with allowed characters to a plain &amp; """ if not string: return string start_with_match = r"(\#x(....);|lt;|gt;|amp;)" # The pattern below is match & ...
[ "def", "escape_ampersand", "(", "string", ")", ":", "if", "not", "string", ":", "return", "string", "start_with_match", "=", "r\"(\\#x(....);|lt;|gt;|amp;)\"", "# The pattern below is match & that is not immediately followed by #", "string", "=", "re", ".", "sub", "(", "r...
Quick convert unicode ampersand characters not associated with a numbered entity or not starting with allowed characters to a plain &amp;
[ "Quick", "convert", "unicode", "ampersand", "characters", "not", "associated", "with", "a", "numbered", "entity", "or", "not", "starting", "with", "allowed", "characters", "to", "a", "plain", "&amp", ";" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L523-L533
train
elifesciences/elife-tools
elifetools/xmlio.py
parse
def parse(filename, return_doctype_dict=False): """ to extract the doctype details from the file when parsed and return the data for later use, set return_doctype_dict to True """ doctype_dict = {} # check for python version, doctype in ElementTree is deprecated 3.2 and above if sys.version_...
python
def parse(filename, return_doctype_dict=False): """ to extract the doctype details from the file when parsed and return the data for later use, set return_doctype_dict to True """ doctype_dict = {} # check for python version, doctype in ElementTree is deprecated 3.2 and above if sys.version_...
[ "def", "parse", "(", "filename", ",", "return_doctype_dict", "=", "False", ")", ":", "doctype_dict", "=", "{", "}", "# check for python version, doctype in ElementTree is deprecated 3.2 and above", "if", "sys", ".", "version_info", "<", "(", "3", ",", "2", ")", ":",...
to extract the doctype details from the file when parsed and return the data for later use, set return_doctype_dict to True
[ "to", "extract", "the", "doctype", "details", "from", "the", "file", "when", "parsed", "and", "return", "the", "data", "for", "later", "use", "set", "return_doctype_dict", "to", "True" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/xmlio.py#L41-L66
train
elifesciences/elife-tools
elifetools/xmlio.py
add_tag_before
def add_tag_before(tag_name, tag_text, parent_tag, before_tag_name): """ Helper function to refactor the adding of new tags especially for when converting text to role tags """ new_tag = Element(tag_name) new_tag.text = tag_text if get_first_element_index(parent_tag, before_tag_name): ...
python
def add_tag_before(tag_name, tag_text, parent_tag, before_tag_name): """ Helper function to refactor the adding of new tags especially for when converting text to role tags """ new_tag = Element(tag_name) new_tag.text = tag_text if get_first_element_index(parent_tag, before_tag_name): ...
[ "def", "add_tag_before", "(", "tag_name", ",", "tag_text", ",", "parent_tag", ",", "before_tag_name", ")", ":", "new_tag", "=", "Element", "(", "tag_name", ")", "new_tag", ".", "text", "=", "tag_text", "if", "get_first_element_index", "(", "parent_tag", ",", "...
Helper function to refactor the adding of new tags especially for when converting text to role tags
[ "Helper", "function", "to", "refactor", "the", "adding", "of", "new", "tags", "especially", "for", "when", "converting", "text", "to", "role", "tags" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/xmlio.py#L68-L77
train
elifesciences/elife-tools
elifetools/xmlio.py
get_first_element_index
def get_first_element_index(root, tag_name): """ In order to use Element.insert() in a convenient way, this function will find the first child tag with tag_name and return its index position The index can then be used to insert an element before or after the found tag using Element.insert() ...
python
def get_first_element_index(root, tag_name): """ In order to use Element.insert() in a convenient way, this function will find the first child tag with tag_name and return its index position The index can then be used to insert an element before or after the found tag using Element.insert() ...
[ "def", "get_first_element_index", "(", "root", ",", "tag_name", ")", ":", "tag_index", "=", "1", "for", "tag", "in", "root", ":", "if", "tag", ".", "tag", "==", "tag_name", ":", "# Return the first one found if there is a match", "return", "tag_index", "tag_index"...
In order to use Element.insert() in a convenient way, this function will find the first child tag with tag_name and return its index position The index can then be used to insert an element before or after the found tag using Element.insert()
[ "In", "order", "to", "use", "Element", ".", "insert", "()", "in", "a", "convenient", "way", "this", "function", "will", "find", "the", "first", "child", "tag", "with", "tag_name", "and", "return", "its", "index", "position", "The", "index", "can", "then", ...
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/xmlio.py#L80-L95
train
elifesciences/elife-tools
elifetools/xmlio.py
rewrite_subject_group
def rewrite_subject_group(root, subjects, subject_group_type, overwrite=True): "add or rewrite subject tags inside subj-group tags" parent_tag_name = 'subj-group' tag_name = 'subject' wrap_tag_name = 'article-categories' tag_attribute = 'subj-group-type' # the parent tag where it should be found...
python
def rewrite_subject_group(root, subjects, subject_group_type, overwrite=True): "add or rewrite subject tags inside subj-group tags" parent_tag_name = 'subj-group' tag_name = 'subject' wrap_tag_name = 'article-categories' tag_attribute = 'subj-group-type' # the parent tag where it should be found...
[ "def", "rewrite_subject_group", "(", "root", ",", "subjects", ",", "subject_group_type", ",", "overwrite", "=", "True", ")", ":", "parent_tag_name", "=", "'subj-group'", "tag_name", "=", "'subject'", "wrap_tag_name", "=", "'article-categories'", "tag_attribute", "=", ...
add or rewrite subject tags inside subj-group tags
[ "add", "or", "rewrite", "subject", "tags", "inside", "subj", "-", "group", "tags" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/xmlio.py#L119-L169
train
elifesciences/elife-tools
elifetools/xmlio.py
build_doctype
def build_doctype(qualifiedName, publicId=None, systemId=None, internalSubset=None): """ Instantiate an ElifeDocumentType, a subclass of minidom.DocumentType, with some properties so it is more testable """ doctype = ElifeDocumentType(qualifiedName) doctype._identified_mixin_init(publicId, syste...
python
def build_doctype(qualifiedName, publicId=None, systemId=None, internalSubset=None): """ Instantiate an ElifeDocumentType, a subclass of minidom.DocumentType, with some properties so it is more testable """ doctype = ElifeDocumentType(qualifiedName) doctype._identified_mixin_init(publicId, syste...
[ "def", "build_doctype", "(", "qualifiedName", ",", "publicId", "=", "None", ",", "systemId", "=", "None", ",", "internalSubset", "=", "None", ")", ":", "doctype", "=", "ElifeDocumentType", "(", "qualifiedName", ")", "doctype", ".", "_identified_mixin_init", "(",...
Instantiate an ElifeDocumentType, a subclass of minidom.DocumentType, with some properties so it is more testable
[ "Instantiate", "an", "ElifeDocumentType", "a", "subclass", "of", "minidom", ".", "DocumentType", "with", "some", "properties", "so", "it", "is", "more", "testable" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/xmlio.py#L209-L218
train
elifesciences/elife-tools
elifetools/xmlio.py
append_minidom_xml_to_elementtree_xml
def append_minidom_xml_to_elementtree_xml(parent, xml, recursive=False, attributes=None): """ Recursively, Given an ElementTree.Element as parent, and a minidom instance as xml, append the tags and content from xml to parent Used primarily for adding a snippet of XML with <italic> tags attribute...
python
def append_minidom_xml_to_elementtree_xml(parent, xml, recursive=False, attributes=None): """ Recursively, Given an ElementTree.Element as parent, and a minidom instance as xml, append the tags and content from xml to parent Used primarily for adding a snippet of XML with <italic> tags attribute...
[ "def", "append_minidom_xml_to_elementtree_xml", "(", "parent", ",", "xml", ",", "recursive", "=", "False", ",", "attributes", "=", "None", ")", ":", "# Get the root tag name", "if", "recursive", "is", "False", ":", "tag_name", "=", "xml", ".", "documentElement", ...
Recursively, Given an ElementTree.Element as parent, and a minidom instance as xml, append the tags and content from xml to parent Used primarily for adding a snippet of XML with <italic> tags attributes: a list of attribute names to copy
[ "Recursively", "Given", "an", "ElementTree", ".", "Element", "as", "parent", "and", "a", "minidom", "instance", "as", "xml", "append", "the", "tags", "and", "content", "from", "xml", "to", "parent", "Used", "primarily", "for", "adding", "a", "snippet", "of",...
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/xmlio.py#L245-L290
train
elifesciences/elife-tools
elifetools/json_rewrite.py
rewrite_json
def rewrite_json(rewrite_type, soup, json_content): """ Due to XML content that will not conform with the strict JSON schema validation rules, for elife articles only, rewrite the JSON to make it valid """ if not soup: return json_content if not elifetools.rawJATS.doi(soup) or not elifet...
python
def rewrite_json(rewrite_type, soup, json_content): """ Due to XML content that will not conform with the strict JSON schema validation rules, for elife articles only, rewrite the JSON to make it valid """ if not soup: return json_content if not elifetools.rawJATS.doi(soup) or not elifet...
[ "def", "rewrite_json", "(", "rewrite_type", ",", "soup", ",", "json_content", ")", ":", "if", "not", "soup", ":", "return", "json_content", "if", "not", "elifetools", ".", "rawJATS", ".", "doi", "(", "soup", ")", "or", "not", "elifetools", ".", "rawJATS", ...
Due to XML content that will not conform with the strict JSON schema validation rules, for elife articles only, rewrite the JSON to make it valid
[ "Due", "to", "XML", "content", "that", "will", "not", "conform", "with", "the", "strict", "JSON", "schema", "validation", "rules", "for", "elife", "articles", "only", "rewrite", "the", "JSON", "to", "make", "it", "valid" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/json_rewrite.py#L10-L32
train
elifesciences/elife-tools
elifetools/json_rewrite.py
rewrite_elife_references_json
def rewrite_elife_references_json(json_content, doi): """ this does the work of rewriting elife references json """ references_rewrite_json = elife_references_rewrite_json() if doi in references_rewrite_json: json_content = rewrite_references_json(json_content, references_rewrite_json[doi]) # E...
python
def rewrite_elife_references_json(json_content, doi): """ this does the work of rewriting elife references json """ references_rewrite_json = elife_references_rewrite_json() if doi in references_rewrite_json: json_content = rewrite_references_json(json_content, references_rewrite_json[doi]) # E...
[ "def", "rewrite_elife_references_json", "(", "json_content", ",", "doi", ")", ":", "references_rewrite_json", "=", "elife_references_rewrite_json", "(", ")", "if", "doi", "in", "references_rewrite_json", ":", "json_content", "=", "rewrite_references_json", "(", "json_cont...
this does the work of rewriting elife references json
[ "this", "does", "the", "work", "of", "rewriting", "elife", "references", "json" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/json_rewrite.py#L40-L52
train
elifesciences/elife-tools
elifetools/json_rewrite.py
rewrite_references_json
def rewrite_references_json(json_content, rewrite_json): """ general purpose references json rewriting by matching the id value """ for ref in json_content: if ref.get("id") and ref.get("id") in rewrite_json: for key, value in iteritems(rewrite_json.get(ref.get("id"))): ref[k...
python
def rewrite_references_json(json_content, rewrite_json): """ general purpose references json rewriting by matching the id value """ for ref in json_content: if ref.get("id") and ref.get("id") in rewrite_json: for key, value in iteritems(rewrite_json.get(ref.get("id"))): ref[k...
[ "def", "rewrite_references_json", "(", "json_content", ",", "rewrite_json", ")", ":", "for", "ref", "in", "json_content", ":", "if", "ref", ".", "get", "(", "\"id\"", ")", "and", "ref", ".", "get", "(", "\"id\"", ")", "in", "rewrite_json", ":", "for", "k...
general purpose references json rewriting by matching the id value
[ "general", "purpose", "references", "json", "rewriting", "by", "matching", "the", "id", "value" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/json_rewrite.py#L54-L60
train
elifesciences/elife-tools
elifetools/json_rewrite.py
elife_references_rewrite_json
def elife_references_rewrite_json(): """ Here is the DOI and references json replacements data for elife """ references_rewrite_json = {} references_rewrite_json["10.7554/eLife.00051"] = {"bib25": {"date": "2012"}} references_rewrite_json["10.7554/eLife.00278"] = {"bib11": {"date": "2013"}} referen...
python
def elife_references_rewrite_json(): """ Here is the DOI and references json replacements data for elife """ references_rewrite_json = {} references_rewrite_json["10.7554/eLife.00051"] = {"bib25": {"date": "2012"}} references_rewrite_json["10.7554/eLife.00278"] = {"bib11": {"date": "2013"}} referen...
[ "def", "elife_references_rewrite_json", "(", ")", ":", "references_rewrite_json", "=", "{", "}", "references_rewrite_json", "[", "\"10.7554/eLife.00051\"", "]", "=", "{", "\"bib25\"", ":", "{", "\"date\"", ":", "\"2012\"", "}", "}", "references_rewrite_json", "[", "...
Here is the DOI and references json replacements data for elife
[ "Here", "is", "the", "DOI", "and", "references", "json", "replacements", "data", "for", "elife" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/json_rewrite.py#L62-L391
train
elifesciences/elife-tools
elifetools/json_rewrite.py
rewrite_elife_body_json
def rewrite_elife_body_json(json_content, doi): """ rewrite elife body json """ # Edge case add an id to a section if doi == "10.7554/eLife.00013": if (json_content and len(json_content) > 0): if (json_content[0].get("type") and json_content[0].get("type") == "section" a...
python
def rewrite_elife_body_json(json_content, doi): """ rewrite elife body json """ # Edge case add an id to a section if doi == "10.7554/eLife.00013": if (json_content and len(json_content) > 0): if (json_content[0].get("type") and json_content[0].get("type") == "section" a...
[ "def", "rewrite_elife_body_json", "(", "json_content", ",", "doi", ")", ":", "# Edge case add an id to a section", "if", "doi", "==", "\"10.7554/eLife.00013\"", ":", "if", "(", "json_content", "and", "len", "(", "json_content", ")", ">", "0", ")", ":", "if", "("...
rewrite elife body json
[ "rewrite", "elife", "body", "json" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/json_rewrite.py#L393-L477
train
elifesciences/elife-tools
elifetools/json_rewrite.py
rewrite_elife_funding_awards
def rewrite_elife_funding_awards(json_content, doi): """ rewrite elife funding awards """ # remove a funding award if doi == "10.7554/eLife.00801": for i, award in enumerate(json_content): if "id" in award and award["id"] == "par-2": del json_content[i] # add fundin...
python
def rewrite_elife_funding_awards(json_content, doi): """ rewrite elife funding awards """ # remove a funding award if doi == "10.7554/eLife.00801": for i, award in enumerate(json_content): if "id" in award and award["id"] == "par-2": del json_content[i] # add fundin...
[ "def", "rewrite_elife_funding_awards", "(", "json_content", ",", "doi", ")", ":", "# remove a funding award", "if", "doi", "==", "\"10.7554/eLife.00801\"", ":", "for", "i", ",", "award", "in", "enumerate", "(", "json_content", ")", ":", "if", "\"id\"", "in", "aw...
rewrite elife funding awards
[ "rewrite", "elife", "funding", "awards" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/json_rewrite.py#L480-L505
train
elifesciences/elife-tools
elifetools/json_rewrite.py
rewrite_elife_authors_json
def rewrite_elife_authors_json(json_content, doi): """ this does the work of rewriting elife authors json """ # Convert doi from testing doi if applicable article_doi = elifetools.utils.convert_testing_doi(doi) # Edge case fix an affiliation name if article_doi == "10.7554/eLife.06956": fo...
python
def rewrite_elife_authors_json(json_content, doi): """ this does the work of rewriting elife authors json """ # Convert doi from testing doi if applicable article_doi = elifetools.utils.convert_testing_doi(doi) # Edge case fix an affiliation name if article_doi == "10.7554/eLife.06956": fo...
[ "def", "rewrite_elife_authors_json", "(", "json_content", ",", "doi", ")", ":", "# Convert doi from testing doi if applicable", "article_doi", "=", "elifetools", ".", "utils", ".", "convert_testing_doi", "(", "doi", ")", "# Edge case fix an affiliation name", "if", "article...
this does the work of rewriting elife authors json
[ "this", "does", "the", "work", "of", "rewriting", "elife", "authors", "json" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/json_rewrite.py#L507-L624
train
elifesciences/elife-tools
elifetools/json_rewrite.py
rewrite_elife_datasets_json
def rewrite_elife_datasets_json(json_content, doi): """ this does the work of rewriting elife datasets json """ # Add dates in bulk elife_dataset_dates = [] elife_dataset_dates.append(("10.7554/eLife.00348", "used", "dataro17", u"2010")) elife_dataset_dates.append(("10.7554/eLife.01179", "used", "d...
python
def rewrite_elife_datasets_json(json_content, doi): """ this does the work of rewriting elife datasets json """ # Add dates in bulk elife_dataset_dates = [] elife_dataset_dates.append(("10.7554/eLife.00348", "used", "dataro17", u"2010")) elife_dataset_dates.append(("10.7554/eLife.01179", "used", "d...
[ "def", "rewrite_elife_datasets_json", "(", "json_content", ",", "doi", ")", ":", "# Add dates in bulk", "elife_dataset_dates", "=", "[", "]", "elife_dataset_dates", ".", "append", "(", "(", "\"10.7554/eLife.00348\"", ",", "\"used\"", ",", "\"dataro17\"", ",", "u\"2010...
this does the work of rewriting elife datasets json
[ "this", "does", "the", "work", "of", "rewriting", "elife", "datasets", "json" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/json_rewrite.py#L626-L925
train
elifesciences/elife-tools
elifetools/json_rewrite.py
rewrite_elife_editors_json
def rewrite_elife_editors_json(json_content, doi): """ this does the work of rewriting elife editors json """ # Remove affiliations with no name value for i, ref in enumerate(json_content): if ref.get("affiliations"): for aff in ref.get("affiliations"): if "name" not in ...
python
def rewrite_elife_editors_json(json_content, doi): """ this does the work of rewriting elife editors json """ # Remove affiliations with no name value for i, ref in enumerate(json_content): if ref.get("affiliations"): for aff in ref.get("affiliations"): if "name" not in ...
[ "def", "rewrite_elife_editors_json", "(", "json_content", ",", "doi", ")", ":", "# Remove affiliations with no name value", "for", "i", ",", "ref", "in", "enumerate", "(", "json_content", ")", ":", "if", "ref", ".", "get", "(", "\"affiliations\"", ")", ":", "for...
this does the work of rewriting elife editors json
[ "this", "does", "the", "work", "of", "rewriting", "elife", "editors", "json" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/json_rewrite.py#L937-L1169
train
elifesciences/elife-tools
elifetools/json_rewrite.py
person_same_name_map
def person_same_name_map(json_content, role_from): "to merge multiple editors into one record, filter by role values and group by name" matched_editors = [(i, person) for i, person in enumerate(json_content) if person.get('role') in role_from] same_name_map = {} for i, editor in m...
python
def person_same_name_map(json_content, role_from): "to merge multiple editors into one record, filter by role values and group by name" matched_editors = [(i, person) for i, person in enumerate(json_content) if person.get('role') in role_from] same_name_map = {} for i, editor in m...
[ "def", "person_same_name_map", "(", "json_content", ",", "role_from", ")", ":", "matched_editors", "=", "[", "(", "i", ",", "person", ")", "for", "i", ",", "person", "in", "enumerate", "(", "json_content", ")", "if", "person", ".", "get", "(", "'role'", ...
to merge multiple editors into one record, filter by role values and group by name
[ "to", "merge", "multiple", "editors", "into", "one", "record", "filter", "by", "role", "values", "and", "group", "by", "name" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/json_rewrite.py#L1172-L1185
train
elifesciences/elife-tools
elifetools/json_rewrite.py
rewrite_elife_title_prefix_json
def rewrite_elife_title_prefix_json(json_content, doi): """ this does the work of rewriting elife title prefix json values""" if not json_content: return json_content # title prefix rewrites by article DOI title_prefix_values = {} title_prefix_values["10.7554/eLife.00452"] = "Point of View"...
python
def rewrite_elife_title_prefix_json(json_content, doi): """ this does the work of rewriting elife title prefix json values""" if not json_content: return json_content # title prefix rewrites by article DOI title_prefix_values = {} title_prefix_values["10.7554/eLife.00452"] = "Point of View"...
[ "def", "rewrite_elife_title_prefix_json", "(", "json_content", ",", "doi", ")", ":", "if", "not", "json_content", ":", "return", "json_content", "# title prefix rewrites by article DOI", "title_prefix_values", "=", "{", "}", "title_prefix_values", "[", "\"10.7554/eLife.0045...
this does the work of rewriting elife title prefix json values
[ "this", "does", "the", "work", "of", "rewriting", "elife", "title", "prefix", "json", "values" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/json_rewrite.py#L1188-L1364
train
canonical-ols/acceptable
acceptable/lint.py
metadata_lint
def metadata_lint(old, new, locations): """Run the linter over the new metadata, comparing to the old.""" # ensure we don't modify the metadata old = old.copy() new = new.copy() # remove version info old.pop('$version', None) new.pop('$version', None) for old_group_name in old: ...
python
def metadata_lint(old, new, locations): """Run the linter over the new metadata, comparing to the old.""" # ensure we don't modify the metadata old = old.copy() new = new.copy() # remove version info old.pop('$version', None) new.pop('$version', None) for old_group_name in old: ...
[ "def", "metadata_lint", "(", "old", ",", "new", ",", "locations", ")", ":", "# ensure we don't modify the metadata", "old", "=", "old", ".", "copy", "(", ")", "new", "=", "new", ".", "copy", "(", ")", "# remove version info", "old", ".", "pop", "(", "'$ver...
Run the linter over the new metadata, comparing to the old.
[ "Run", "the", "linter", "over", "the", "new", "metadata", "comparing", "to", "the", "old", "." ]
6ccbe969078166a5315d857da38b59b43b29fadc
https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/lint.py#L72-L95
train
canonical-ols/acceptable
acceptable/lint.py
lint_api
def lint_api(api_name, old, new, locations): """Lint an acceptable api metadata.""" is_new_api = not old api_location = locations['api'] changelog = new.get('changelog', {}) changelog_location = api_location if locations['changelog']: changelog_location = list(locations['changelog'].val...
python
def lint_api(api_name, old, new, locations): """Lint an acceptable api metadata.""" is_new_api = not old api_location = locations['api'] changelog = new.get('changelog', {}) changelog_location = api_location if locations['changelog']: changelog_location = list(locations['changelog'].val...
[ "def", "lint_api", "(", "api_name", ",", "old", ",", "new", ",", "locations", ")", ":", "is_new_api", "=", "not", "old", "api_location", "=", "locations", "[", "'api'", "]", "changelog", "=", "new", ".", "get", "(", "'changelog'", ",", "{", "}", ")", ...
Lint an acceptable api metadata.
[ "Lint", "an", "acceptable", "api", "metadata", "." ]
6ccbe969078166a5315d857da38b59b43b29fadc
https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/lint.py#L98-L182
train
canonical-ols/acceptable
acceptable/_service.py
APIMetadata.bind
def bind(self, flask_app, service, group=None): """Bind the service API urls to a flask app.""" if group not in self.services[service]: raise RuntimeError( 'API group {} does not exist in service {}'.format( group, service) ) for name, ...
python
def bind(self, flask_app, service, group=None): """Bind the service API urls to a flask app.""" if group not in self.services[service]: raise RuntimeError( 'API group {} does not exist in service {}'.format( group, service) ) for name, ...
[ "def", "bind", "(", "self", ",", "flask_app", ",", "service", ",", "group", "=", "None", ")", ":", "if", "group", "not", "in", "self", ".", "services", "[", "service", "]", ":", "raise", "RuntimeError", "(", "'API group {} does not exist in service {}'", "."...
Bind the service API urls to a flask app.
[ "Bind", "the", "service", "API", "urls", "to", "a", "flask", "app", "." ]
6ccbe969078166a5315d857da38b59b43b29fadc
https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/_service.py#L87-L100
train
canonical-ols/acceptable
acceptable/_service.py
APIMetadata.serialize
def serialize(self): """Serialize into JSONable dict, and associated locations data.""" api_metadata = OrderedDict() # $ char makes this come first in sort ordering api_metadata['$version'] = self.current_version locations = {} for svc_name, group in self.groups(): ...
python
def serialize(self): """Serialize into JSONable dict, and associated locations data.""" api_metadata = OrderedDict() # $ char makes this come first in sort ordering api_metadata['$version'] = self.current_version locations = {} for svc_name, group in self.groups(): ...
[ "def", "serialize", "(", "self", ")", ":", "api_metadata", "=", "OrderedDict", "(", ")", "# $ char makes this come first in sort ordering", "api_metadata", "[", "'$version'", "]", "=", "self", ".", "current_version", "locations", "=", "{", "}", "for", "svc_name", ...
Serialize into JSONable dict, and associated locations data.
[ "Serialize", "into", "JSONable", "dict", "and", "associated", "locations", "data", "." ]
6ccbe969078166a5315d857da38b59b43b29fadc
https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/_service.py#L118-L167
train
canonical-ols/acceptable
acceptable/_service.py
AcceptableService.api
def api(self, url, name, introduced_at=None, undocumented=False, deprecated_at=None, title=None, **options): """Add an API to the service. :param url: This is the url that the API should be registered at. :param...
python
def api(self, url, name, introduced_at=None, undocumented=False, deprecated_at=None, title=None, **options): """Add an API to the service. :param url: This is the url that the API should be registered at. :param...
[ "def", "api", "(", "self", ",", "url", ",", "name", ",", "introduced_at", "=", "None", ",", "undocumented", "=", "False", ",", "deprecated_at", "=", "None", ",", "title", "=", "None", ",", "*", "*", "options", ")", ":", "location", "=", "get_callsite_l...
Add an API to the service. :param url: This is the url that the API should be registered at. :param name: This is the name of the api, and will be registered with flask apps under. Other keyword arguments may be used, and they will be passed to the flask application when in...
[ "Add", "an", "API", "to", "the", "service", "." ]
6ccbe969078166a5315d857da38b59b43b29fadc
https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/_service.py#L234-L266
train
canonical-ols/acceptable
acceptable/_service.py
AcceptableService.django_api
def django_api( self, name, introduced_at, undocumented=False, deprecated_at=None, title=None, **options): """Add a django API handler to the service. :param name: This is the name of the django url to use. The...
python
def django_api( self, name, introduced_at, undocumented=False, deprecated_at=None, title=None, **options): """Add a django API handler to the service. :param name: This is the name of the django url to use. The...
[ "def", "django_api", "(", "self", ",", "name", ",", "introduced_at", ",", "undocumented", "=", "False", ",", "deprecated_at", "=", "None", ",", "title", "=", "None", ",", "*", "*", "options", ")", ":", "from", "acceptable", ".", "djangoutil", "import", "...
Add a django API handler to the service. :param name: This is the name of the django url to use. The 'methods' paramater can be supplied as normal, you can also user the @api.handler decorator to link this API to its handler.
[ "Add", "a", "django", "API", "handler", "to", "the", "service", "." ]
6ccbe969078166a5315d857da38b59b43b29fadc
https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/_service.py#L268-L297
train
canonical-ols/acceptable
acceptable/_service.py
AcceptableService.bind
def bind(self, flask_app): """Bind the service API urls to a flask app.""" self.metadata.bind(flask_app, self.name, self.group)
python
def bind(self, flask_app): """Bind the service API urls to a flask app.""" self.metadata.bind(flask_app, self.name, self.group)
[ "def", "bind", "(", "self", ",", "flask_app", ")", ":", "self", ".", "metadata", ".", "bind", "(", "flask_app", ",", "self", ".", "name", ",", "self", ".", "group", ")" ]
Bind the service API urls to a flask app.
[ "Bind", "the", "service", "API", "urls", "to", "a", "flask", "app", "." ]
6ccbe969078166a5315d857da38b59b43b29fadc
https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/_service.py#L299-L301
train
canonical-ols/acceptable
acceptable/_service.py
AcceptableAPI.changelog
def changelog(self, api_version, doc): """Add a changelog entry for this api.""" doc = textwrap.dedent(doc).strip() self._changelog[api_version] = doc self._changelog_locations[api_version] = get_callsite_location()
python
def changelog(self, api_version, doc): """Add a changelog entry for this api.""" doc = textwrap.dedent(doc).strip() self._changelog[api_version] = doc self._changelog_locations[api_version] = get_callsite_location()
[ "def", "changelog", "(", "self", ",", "api_version", ",", "doc", ")", ":", "doc", "=", "textwrap", ".", "dedent", "(", "doc", ")", ".", "strip", "(", ")", "self", ".", "_changelog", "[", "api_version", "]", "=", "doc", "self", ".", "_changelog_location...
Add a changelog entry for this api.
[ "Add", "a", "changelog", "entry", "for", "this", "api", "." ]
6ccbe969078166a5315d857da38b59b43b29fadc
https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/_service.py#L375-L379
train
elifesciences/elife-tools
elifetools/parseJATS.py
title_prefix
def title_prefix(soup): "titlePrefix for article JSON is only articles with certain display_channel values" prefix = None display_channel_match_list = ['feature article', 'insight', 'editorial'] for d_channel in display_channel(soup): if d_channel.lower() in display_channel_match_list: ...
python
def title_prefix(soup): "titlePrefix for article JSON is only articles with certain display_channel values" prefix = None display_channel_match_list = ['feature article', 'insight', 'editorial'] for d_channel in display_channel(soup): if d_channel.lower() in display_channel_match_list: ...
[ "def", "title_prefix", "(", "soup", ")", ":", "prefix", "=", "None", "display_channel_match_list", "=", "[", "'feature article'", ",", "'insight'", ",", "'editorial'", "]", "for", "d_channel", "in", "display_channel", "(", "soup", ")", ":", "if", "d_channel", ...
titlePrefix for article JSON is only articles with certain display_channel values
[ "titlePrefix", "for", "article", "JSON", "is", "only", "articles", "with", "certain", "display_channel", "values" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L37-L45
train
elifesciences/elife-tools
elifetools/parseJATS.py
title_prefix_json
def title_prefix_json(soup): "titlePrefix with capitalisation changed" prefix = title_prefix(soup) prefix_rewritten = elifetools.json_rewrite.rewrite_json("title_prefix_json", soup, prefix) return prefix_rewritten
python
def title_prefix_json(soup): "titlePrefix with capitalisation changed" prefix = title_prefix(soup) prefix_rewritten = elifetools.json_rewrite.rewrite_json("title_prefix_json", soup, prefix) return prefix_rewritten
[ "def", "title_prefix_json", "(", "soup", ")", ":", "prefix", "=", "title_prefix", "(", "soup", ")", "prefix_rewritten", "=", "elifetools", ".", "json_rewrite", ".", "rewrite_json", "(", "\"title_prefix_json\"", ",", "soup", ",", "prefix", ")", "return", "prefix_...
titlePrefix with capitalisation changed
[ "titlePrefix", "with", "capitalisation", "changed" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L47-L51
train
elifesciences/elife-tools
elifetools/parseJATS.py
research_organism
def research_organism(soup): "Find the research-organism from the set of kwd-group tags" if not raw_parser.research_organism_keywords(soup): return [] return list(map(node_text, raw_parser.research_organism_keywords(soup)))
python
def research_organism(soup): "Find the research-organism from the set of kwd-group tags" if not raw_parser.research_organism_keywords(soup): return [] return list(map(node_text, raw_parser.research_organism_keywords(soup)))
[ "def", "research_organism", "(", "soup", ")", ":", "if", "not", "raw_parser", ".", "research_organism_keywords", "(", "soup", ")", ":", "return", "[", "]", "return", "list", "(", "map", "(", "node_text", ",", "raw_parser", ".", "research_organism_keywords", "(...
Find the research-organism from the set of kwd-group tags
[ "Find", "the", "research", "-", "organism", "from", "the", "set", "of", "kwd", "-", "group", "tags" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L86-L90
train
elifesciences/elife-tools
elifetools/parseJATS.py
full_research_organism
def full_research_organism(soup): "research-organism list including inline tags, such as italic" if not raw_parser.research_organism_keywords(soup): return [] return list(map(node_contents_str, raw_parser.research_organism_keywords(soup)))
python
def full_research_organism(soup): "research-organism list including inline tags, such as italic" if not raw_parser.research_organism_keywords(soup): return [] return list(map(node_contents_str, raw_parser.research_organism_keywords(soup)))
[ "def", "full_research_organism", "(", "soup", ")", ":", "if", "not", "raw_parser", ".", "research_organism_keywords", "(", "soup", ")", ":", "return", "[", "]", "return", "list", "(", "map", "(", "node_contents_str", ",", "raw_parser", ".", "research_organism_ke...
research-organism list including inline tags, such as italic
[ "research", "-", "organism", "list", "including", "inline", "tags", "such", "as", "italic" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L92-L96
train
elifesciences/elife-tools
elifetools/parseJATS.py
keywords
def keywords(soup): """ Find the keywords from the set of kwd-group tags which are typically labelled as the author keywords """ if not raw_parser.author_keywords(soup): return [] return list(map(node_text, raw_parser.author_keywords(soup)))
python
def keywords(soup): """ Find the keywords from the set of kwd-group tags which are typically labelled as the author keywords """ if not raw_parser.author_keywords(soup): return [] return list(map(node_text, raw_parser.author_keywords(soup)))
[ "def", "keywords", "(", "soup", ")", ":", "if", "not", "raw_parser", ".", "author_keywords", "(", "soup", ")", ":", "return", "[", "]", "return", "list", "(", "map", "(", "node_text", ",", "raw_parser", ".", "author_keywords", "(", "soup", ")", ")", ")...
Find the keywords from the set of kwd-group tags which are typically labelled as the author keywords
[ "Find", "the", "keywords", "from", "the", "set", "of", "kwd", "-", "group", "tags", "which", "are", "typically", "labelled", "as", "the", "author", "keywords" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L98-L105
train
elifesciences/elife-tools
elifetools/parseJATS.py
full_keywords
def full_keywords(soup): "author keywords list including inline tags, such as italic" if not raw_parser.author_keywords(soup): return [] return list(map(node_contents_str, raw_parser.author_keywords(soup)))
python
def full_keywords(soup): "author keywords list including inline tags, such as italic" if not raw_parser.author_keywords(soup): return [] return list(map(node_contents_str, raw_parser.author_keywords(soup)))
[ "def", "full_keywords", "(", "soup", ")", ":", "if", "not", "raw_parser", ".", "author_keywords", "(", "soup", ")", ":", "return", "[", "]", "return", "list", "(", "map", "(", "node_contents_str", ",", "raw_parser", ".", "author_keywords", "(", "soup", ")"...
author keywords list including inline tags, such as italic
[ "author", "keywords", "list", "including", "inline", "tags", "such", "as", "italic" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L107-L111
train
elifesciences/elife-tools
elifetools/parseJATS.py
version_history
def version_history(soup, html_flag=True): "extract the article version history details" convert = lambda xml_string: xml_to_html(html_flag, xml_string) version_history = [] related_object_tags = raw_parser.related_object(raw_parser.article_meta(soup)) for tag in related_object_tags: article...
python
def version_history(soup, html_flag=True): "extract the article version history details" convert = lambda xml_string: xml_to_html(html_flag, xml_string) version_history = [] related_object_tags = raw_parser.related_object(raw_parser.article_meta(soup)) for tag in related_object_tags: article...
[ "def", "version_history", "(", "soup", ",", "html_flag", "=", "True", ")", ":", "convert", "=", "lambda", "xml_string", ":", "xml_to_html", "(", "html_flag", ",", "xml_string", ")", "version_history", "=", "[", "]", "related_object_tags", "=", "raw_parser", "....
extract the article version history details
[ "extract", "the", "article", "version", "history", "details" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L131-L150
train
elifesciences/elife-tools
elifetools/parseJATS.py
article_id_list
def article_id_list(soup): """return a list of article-id data""" id_list = [] for article_id_tag in raw_parser.article_id(soup): id_details = OrderedDict() set_if_value(id_details, "type", article_id_tag.get("pub-id-type")) set_if_value(id_details, "value", article_id_tag.text) ...
python
def article_id_list(soup): """return a list of article-id data""" id_list = [] for article_id_tag in raw_parser.article_id(soup): id_details = OrderedDict() set_if_value(id_details, "type", article_id_tag.get("pub-id-type")) set_if_value(id_details, "value", article_id_tag.text) ...
[ "def", "article_id_list", "(", "soup", ")", ":", "id_list", "=", "[", "]", "for", "article_id_tag", "in", "raw_parser", ".", "article_id", "(", "soup", ")", ":", "id_details", "=", "OrderedDict", "(", ")", "set_if_value", "(", "id_details", ",", "\"type\"", ...
return a list of article-id data
[ "return", "a", "list", "of", "article", "-", "id", "data" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L163-L172
train
elifesciences/elife-tools
elifetools/parseJATS.py
copyright_holder_json
def copyright_holder_json(soup): "for json output add a full stop if ends in et al" holder = None permissions_tag = raw_parser.article_permissions(soup) if permissions_tag: holder = node_text(raw_parser.copyright_holder(permissions_tag)) if holder is not None and holder.endswith('et al'): ...
python
def copyright_holder_json(soup): "for json output add a full stop if ends in et al" holder = None permissions_tag = raw_parser.article_permissions(soup) if permissions_tag: holder = node_text(raw_parser.copyright_holder(permissions_tag)) if holder is not None and holder.endswith('et al'): ...
[ "def", "copyright_holder_json", "(", "soup", ")", ":", "holder", "=", "None", "permissions_tag", "=", "raw_parser", ".", "article_permissions", "(", "soup", ")", "if", "permissions_tag", ":", "holder", "=", "node_text", "(", "raw_parser", ".", "copyright_holder", ...
for json output add a full stop if ends in et al
[ "for", "json", "output", "add", "a", "full", "stop", "if", "ends", "in", "et", "al" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L241-L249
train
elifesciences/elife-tools
elifetools/parseJATS.py
subject_area
def subject_area(soup): """ Find the subject areas from article-categories subject tags """ subject_area = [] tags = raw_parser.subject_area(soup) for tag in tags: subject_area.append(node_text(tag)) return subject_area
python
def subject_area(soup): """ Find the subject areas from article-categories subject tags """ subject_area = [] tags = raw_parser.subject_area(soup) for tag in tags: subject_area.append(node_text(tag)) return subject_area
[ "def", "subject_area", "(", "soup", ")", ":", "subject_area", "=", "[", "]", "tags", "=", "raw_parser", ".", "subject_area", "(", "soup", ")", "for", "tag", "in", "tags", ":", "subject_area", ".", "append", "(", "node_text", "(", "tag", ")", ")", "retu...
Find the subject areas from article-categories subject tags
[ "Find", "the", "subject", "areas", "from", "article", "-", "categories", "subject", "tags" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L298-L308
train
elifesciences/elife-tools
elifetools/parseJATS.py
display_channel
def display_channel(soup): """ Find the subject areas of type display-channel """ display_channel = [] tags = raw_parser.display_channel(soup) for tag in tags: display_channel.append(node_text(tag)) return display_channel
python
def display_channel(soup): """ Find the subject areas of type display-channel """ display_channel = [] tags = raw_parser.display_channel(soup) for tag in tags: display_channel.append(node_text(tag)) return display_channel
[ "def", "display_channel", "(", "soup", ")", ":", "display_channel", "=", "[", "]", "tags", "=", "raw_parser", ".", "display_channel", "(", "soup", ")", "for", "tag", "in", "tags", ":", "display_channel", ".", "append", "(", "node_text", "(", "tag", ")", ...
Find the subject areas of type display-channel
[ "Find", "the", "subject", "areas", "of", "type", "display", "-", "channel" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L321-L331
train
elifesciences/elife-tools
elifetools/parseJATS.py
category
def category(soup): """ Find the category from subject areas """ category = [] tags = raw_parser.category(soup) for tag in tags: category.append(node_text(tag)) return category
python
def category(soup): """ Find the category from subject areas """ category = [] tags = raw_parser.category(soup) for tag in tags: category.append(node_text(tag)) return category
[ "def", "category", "(", "soup", ")", ":", "category", "=", "[", "]", "tags", "=", "raw_parser", ".", "category", "(", "soup", ")", "for", "tag", "in", "tags", ":", "category", ".", "append", "(", "node_text", "(", "tag", ")", ")", "return", "category...
Find the category from subject areas
[ "Find", "the", "category", "from", "subject", "areas" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L333-L343
train
elifesciences/elife-tools
elifetools/parseJATS.py
ymd
def ymd(soup): """ Get the year, month and day from child tags """ day = node_text(raw_parser.day(soup)) month = node_text(raw_parser.month(soup)) year = node_text(raw_parser.year(soup)) return (day, month, year)
python
def ymd(soup): """ Get the year, month and day from child tags """ day = node_text(raw_parser.day(soup)) month = node_text(raw_parser.month(soup)) year = node_text(raw_parser.year(soup)) return (day, month, year)
[ "def", "ymd", "(", "soup", ")", ":", "day", "=", "node_text", "(", "raw_parser", ".", "day", "(", "soup", ")", ")", "month", "=", "node_text", "(", "raw_parser", ".", "month", "(", "soup", ")", ")", "year", "=", "node_text", "(", "raw_parser", ".", ...
Get the year, month and day from child tags
[ "Get", "the", "year", "month", "and", "day", "from", "child", "tags" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L345-L352
train
elifesciences/elife-tools
elifetools/parseJATS.py
pub_date
def pub_date(soup): """ Return the publishing date in struct format pub_date_date, pub_date_day, pub_date_month, pub_date_year, pub_date_timestamp Default date_type is pub """ pub_date = first(raw_parser.pub_date(soup, date_type="pub")) if pub_date is None: pub_date = first(raw_parse...
python
def pub_date(soup): """ Return the publishing date in struct format pub_date_date, pub_date_day, pub_date_month, pub_date_year, pub_date_timestamp Default date_type is pub """ pub_date = first(raw_parser.pub_date(soup, date_type="pub")) if pub_date is None: pub_date = first(raw_parse...
[ "def", "pub_date", "(", "soup", ")", ":", "pub_date", "=", "first", "(", "raw_parser", ".", "pub_date", "(", "soup", ",", "date_type", "=", "\"pub\"", ")", ")", "if", "pub_date", "is", "None", ":", "pub_date", "=", "first", "(", "raw_parser", ".", "pub...
Return the publishing date in struct format pub_date_date, pub_date_day, pub_date_month, pub_date_year, pub_date_timestamp Default date_type is pub
[ "Return", "the", "publishing", "date", "in", "struct", "format", "pub_date_date", "pub_date_day", "pub_date_month", "pub_date_year", "pub_date_timestamp", "Default", "date_type", "is", "pub" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L354-L366
train
elifesciences/elife-tools
elifetools/parseJATS.py
pub_dates
def pub_dates(soup): """ return a list of all the pub dates """ pub_dates = [] tags = raw_parser.pub_date(soup) for tag in tags: pub_date = OrderedDict() copy_attribute(tag.attrs, 'publication-format', pub_date) copy_attribute(tag.attrs, 'date-type', pub_date) cop...
python
def pub_dates(soup): """ return a list of all the pub dates """ pub_dates = [] tags = raw_parser.pub_date(soup) for tag in tags: pub_date = OrderedDict() copy_attribute(tag.attrs, 'publication-format', pub_date) copy_attribute(tag.attrs, 'date-type', pub_date) cop...
[ "def", "pub_dates", "(", "soup", ")", ":", "pub_dates", "=", "[", "]", "tags", "=", "raw_parser", ".", "pub_date", "(", "soup", ")", "for", "tag", "in", "tags", ":", "pub_date", "=", "OrderedDict", "(", ")", "copy_attribute", "(", "tag", ".", "attrs", ...
return a list of all the pub dates
[ "return", "a", "list", "of", "all", "the", "pub", "dates" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L368-L387
train
elifesciences/elife-tools
elifetools/parseJATS.py
history_date
def history_date(soup, date_type = None): """ Find a date in the history tag for the specific date_type typical date_type values: received, accepted """ if(date_type == None): return None history_date = raw_parser.history_date(soup, date_type) if history_date is None: return...
python
def history_date(soup, date_type = None): """ Find a date in the history tag for the specific date_type typical date_type values: received, accepted """ if(date_type == None): return None history_date = raw_parser.history_date(soup, date_type) if history_date is None: return...
[ "def", "history_date", "(", "soup", ",", "date_type", "=", "None", ")", ":", "if", "(", "date_type", "==", "None", ")", ":", "return", "None", "history_date", "=", "raw_parser", ".", "history_date", "(", "soup", ",", "date_type", ")", "if", "history_date",...
Find a date in the history tag for the specific date_type typical date_type values: received, accepted
[ "Find", "a", "date", "in", "the", "history", "tag", "for", "the", "specific", "date_type", "typical", "date_type", "values", ":", "received", "accepted" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L389-L401
train
elifesciences/elife-tools
elifetools/parseJATS.py
collection_year
def collection_year(soup): """ Pub date of type collection will hold a year element for VOR articles """ pub_date = first(raw_parser.pub_date(soup, pub_type="collection")) if not pub_date: pub_date = first(raw_parser.pub_date(soup, date_type="collection")) if not pub_date: return...
python
def collection_year(soup): """ Pub date of type collection will hold a year element for VOR articles """ pub_date = first(raw_parser.pub_date(soup, pub_type="collection")) if not pub_date: pub_date = first(raw_parser.pub_date(soup, date_type="collection")) if not pub_date: return...
[ "def", "collection_year", "(", "soup", ")", ":", "pub_date", "=", "first", "(", "raw_parser", ".", "pub_date", "(", "soup", ",", "pub_type", "=", "\"collection\"", ")", ")", "if", "not", "pub_date", ":", "pub_date", "=", "first", "(", "raw_parser", ".", ...
Pub date of type collection will hold a year element for VOR articles
[ "Pub", "date", "of", "type", "collection", "will", "hold", "a", "year", "element", "for", "VOR", "articles" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L493-L508
train
elifesciences/elife-tools
elifetools/parseJATS.py
abstracts
def abstracts(soup): """ Find the article abstract and format it """ abstracts = [] abstract_tags = raw_parser.abstract(soup) for tag in abstract_tags: abstract = {} abstract["abstract_type"] = tag.get("abstract-type") title_tag = raw_parser.title(tag) if titl...
python
def abstracts(soup): """ Find the article abstract and format it """ abstracts = [] abstract_tags = raw_parser.abstract(soup) for tag in abstract_tags: abstract = {} abstract["abstract_type"] = tag.get("abstract-type") title_tag = raw_parser.title(tag) if titl...
[ "def", "abstracts", "(", "soup", ")", ":", "abstracts", "=", "[", "]", "abstract_tags", "=", "raw_parser", ".", "abstract", "(", "soup", ")", "for", "tag", "in", "abstract_tags", ":", "abstract", "=", "{", "}", "abstract", "[", "\"abstract_type\"", "]", ...
Find the article abstract and format it
[ "Find", "the", "article", "abstract", "and", "format", "it" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L520-L557
train
elifesciences/elife-tools
elifetools/parseJATS.py
component_doi
def component_doi(soup): """ Look for all object-id of pub-type-id = doi, these are the component DOI tags """ component_doi = [] object_id_tags = raw_parser.object_id(soup, pub_id_type = "doi") # Get components too for later component_list = components(soup) position = 1 for tag...
python
def component_doi(soup): """ Look for all object-id of pub-type-id = doi, these are the component DOI tags """ component_doi = [] object_id_tags = raw_parser.object_id(soup, pub_id_type = "doi") # Get components too for later component_list = components(soup) position = 1 for tag...
[ "def", "component_doi", "(", "soup", ")", ":", "component_doi", "=", "[", "]", "object_id_tags", "=", "raw_parser", ".", "object_id", "(", "soup", ",", "pub_id_type", "=", "\"doi\"", ")", "# Get components too for later", "component_list", "=", "components", "(", ...
Look for all object-id of pub-type-id = doi, these are the component DOI tags
[ "Look", "for", "all", "object", "-", "id", "of", "pub", "-", "type", "-", "id", "=", "doi", "these", "are", "the", "component", "DOI", "tags" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L648-L675
train
elifesciences/elife-tools
elifetools/parseJATS.py
tag_details
def tag_details(tag, nodenames): """ Used in media and graphics to extract data from their parent tags """ details = {} details['type'] = tag.name details['ordinal'] = tag_ordinal(tag) # Ordinal value if tag_details_sibling_ordinal(tag): details['sibling_ordinal'] = tag_details...
python
def tag_details(tag, nodenames): """ Used in media and graphics to extract data from their parent tags """ details = {} details['type'] = tag.name details['ordinal'] = tag_ordinal(tag) # Ordinal value if tag_details_sibling_ordinal(tag): details['sibling_ordinal'] = tag_details...
[ "def", "tag_details", "(", "tag", ",", "nodenames", ")", ":", "details", "=", "{", "}", "details", "[", "'type'", "]", "=", "tag", ".", "name", "details", "[", "'ordinal'", "]", "=", "tag_ordinal", "(", "tag", ")", "# Ordinal value", "if", "tag_details_s...
Used in media and graphics to extract data from their parent tags
[ "Used", "in", "media", "and", "graphics", "to", "extract", "data", "from", "their", "parent", "tags" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L726-L747
train
elifesciences/elife-tools
elifetools/parseJATS.py
media
def media(soup): """ All media tags and some associated data about the related component doi and the parent of that doi (not always present) """ media = [] media_tags = raw_parser.media(soup) position = 1 for tag in media_tags: media_item = {} copy_attribute(tag.attrs...
python
def media(soup): """ All media tags and some associated data about the related component doi and the parent of that doi (not always present) """ media = [] media_tags = raw_parser.media(soup) position = 1 for tag in media_tags: media_item = {} copy_attribute(tag.attrs...
[ "def", "media", "(", "soup", ")", ":", "media", "=", "[", "]", "media_tags", "=", "raw_parser", ".", "media", "(", "soup", ")", "position", "=", "1", "for", "tag", "in", "media_tags", ":", "media_item", "=", "{", "}", "copy_attribute", "(", "tag", "....
All media tags and some associated data about the related component doi and the parent of that doi (not always present)
[ "All", "media", "tags", "and", "some", "associated", "data", "about", "the", "related", "component", "doi", "and", "the", "parent", "of", "that", "doi", "(", "not", "always", "present", ")" ]
4b9e38cbe485c61a4ed7cbd8970c6b318334fd86
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L750-L821
train