partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
members
List user group members.
invenio_groups/views.py
def members(group_id): """List user group members.""" page = request.args.get('page', 1, type=int) per_page = request.args.get('per_page', 5, type=int) q = request.args.get('q', '') s = request.args.get('s', '') group = Group.query.get_or_404(group_id) if group.can_see_members(current_user)...
def members(group_id): """List user group members.""" page = request.args.get('page', 1, type=int) per_page = request.args.get('per_page', 5, type=int) q = request.args.get('q', '') s = request.args.get('s', '') group = Group.query.get_or_404(group_id) if group.can_see_members(current_user)...
[ "List", "user", "group", "members", "." ]
inveniosoftware-contrib/invenio-groups
python
https://github.com/inveniosoftware-contrib/invenio-groups/blob/109481d6b02701db00b72223dd4a65e167c589a6/invenio_groups/views.py#L229-L262
[ "def", "members", "(", "group_id", ")", ":", "page", "=", "request", ".", "args", ".", "get", "(", "'page'", ",", "1", ",", "type", "=", "int", ")", "per_page", "=", "request", ".", "args", ".", "get", "(", "'per_page'", ",", "5", ",", "type", "=...
109481d6b02701db00b72223dd4a65e167c589a6
valid
leave
Leave group.
invenio_groups/views.py
def leave(group_id): """Leave group.""" group = Group.query.get_or_404(group_id) if group.can_leave(current_user): try: group.remove_member(current_user) except Exception as e: flash(str(e), "error") return redirect(url_for('.index')) flash( ...
def leave(group_id): """Leave group.""" group = Group.query.get_or_404(group_id) if group.can_leave(current_user): try: group.remove_member(current_user) except Exception as e: flash(str(e), "error") return redirect(url_for('.index')) flash( ...
[ "Leave", "group", "." ]
inveniosoftware-contrib/invenio-groups
python
https://github.com/inveniosoftware-contrib/invenio-groups/blob/109481d6b02701db00b72223dd4a65e167c589a6/invenio_groups/views.py#L267-L294
[ "def", "leave", "(", "group_id", ")", ":", "group", "=", "Group", ".", "query", ".", "get_or_404", "(", "group_id", ")", "if", "group", ".", "can_leave", "(", "current_user", ")", ":", "try", ":", "group", ".", "remove_member", "(", "current_user", ")", ...
109481d6b02701db00b72223dd4a65e167c589a6
valid
approve
Approve a user.
invenio_groups/views.py
def approve(group_id, user_id): """Approve a user.""" membership = Membership.query.get_or_404((user_id, group_id)) group = membership.group if group.can_edit(current_user): try: membership.accept() except Exception as e: flash(str(e), 'error') return...
def approve(group_id, user_id): """Approve a user.""" membership = Membership.query.get_or_404((user_id, group_id)) group = membership.group if group.can_edit(current_user): try: membership.accept() except Exception as e: flash(str(e), 'error') return...
[ "Approve", "a", "user", "." ]
inveniosoftware-contrib/invenio-groups
python
https://github.com/inveniosoftware-contrib/invenio-groups/blob/109481d6b02701db00b72223dd4a65e167c589a6/invenio_groups/views.py#L300-L324
[ "def", "approve", "(", "group_id", ",", "user_id", ")", ":", "membership", "=", "Membership", ".", "query", ".", "get_or_404", "(", "(", "user_id", ",", "group_id", ")", ")", "group", "=", "membership", ".", "group", "if", "group", ".", "can_edit", "(", ...
109481d6b02701db00b72223dd4a65e167c589a6
valid
remove
Remove user from a group.
invenio_groups/views.py
def remove(group_id, user_id): """Remove user from a group.""" group = Group.query.get_or_404(group_id) user = User.query.get_or_404(user_id) if group.can_edit(current_user): try: group.remove_member(user) except Exception as e: flash(str(e), "error") ...
def remove(group_id, user_id): """Remove user from a group.""" group = Group.query.get_or_404(group_id) user = User.query.get_or_404(user_id) if group.can_edit(current_user): try: group.remove_member(user) except Exception as e: flash(str(e), "error") ...
[ "Remove", "user", "from", "a", "group", "." ]
inveniosoftware-contrib/invenio-groups
python
https://github.com/inveniosoftware-contrib/invenio-groups/blob/109481d6b02701db00b72223dd4a65e167c589a6/invenio_groups/views.py#L330-L353
[ "def", "remove", "(", "group_id", ",", "user_id", ")", ":", "group", "=", "Group", ".", "query", ".", "get_or_404", "(", "group_id", ")", "user", "=", "User", ".", "query", ".", "get_or_404", "(", "user_id", ")", "if", "group", ".", "can_edit", "(", ...
109481d6b02701db00b72223dd4a65e167c589a6
valid
accept
Accpet pending invitation.
invenio_groups/views.py
def accept(group_id): """Accpet pending invitation.""" membership = Membership.query.get_or_404((current_user.get_id(), group_id)) # no permission check, because they are checked during Memberships creating try: membership.accept() except Exception as e: flash(str(e), 'error') ...
def accept(group_id): """Accpet pending invitation.""" membership = Membership.query.get_or_404((current_user.get_id(), group_id)) # no permission check, because they are checked during Memberships creating try: membership.accept() except Exception as e: flash(str(e), 'error') ...
[ "Accpet", "pending", "invitation", "." ]
inveniosoftware-contrib/invenio-groups
python
https://github.com/inveniosoftware-contrib/invenio-groups/blob/109481d6b02701db00b72223dd4a65e167c589a6/invenio_groups/views.py#L359-L374
[ "def", "accept", "(", "group_id", ")", ":", "membership", "=", "Membership", ".", "query", ".", "get_or_404", "(", "(", "current_user", ".", "get_id", "(", ")", ",", "group_id", ")", ")", "# no permission check, because they are checked during Memberships creating", ...
109481d6b02701db00b72223dd4a65e167c589a6
valid
new_member
Add (invite) new member.
invenio_groups/views.py
def new_member(group_id): """Add (invite) new member.""" group = Group.query.get_or_404(group_id) if group.can_invite_others(current_user): form = NewMemberForm() if form.validate_on_submit(): emails = filter(None, form.data['emails'].splitlines()) group.invite_by_e...
def new_member(group_id): """Add (invite) new member.""" group = Group.query.get_or_404(group_id) if group.can_invite_others(current_user): form = NewMemberForm() if form.validate_on_submit(): emails = filter(None, form.data['emails'].splitlines()) group.invite_by_e...
[ "Add", "(", "invite", ")", "new", "member", "." ]
inveniosoftware-contrib/invenio-groups
python
https://github.com/inveniosoftware-contrib/invenio-groups/blob/109481d6b02701db00b72223dd4a65e167c589a6/invenio_groups/views.py#L403-L430
[ "def", "new_member", "(", "group_id", ")", ":", "group", "=", "Group", ".", "query", ".", "get_or_404", "(", "group_id", ")", "if", "group", ".", "can_invite_others", "(", "current_user", ")", ":", "form", "=", "NewMemberForm", "(", ")", "if", "form", "....
109481d6b02701db00b72223dd4a65e167c589a6
valid
locate_spheres
Get an initial featuring of sphere positions in an image. Parameters ----------- image : :class:`peri.util.Image` object Image object which defines the image file as well as the region. feature_rad : float Radius of objects to find, in pixels. This is a featuring radius and not...
peri/runner.py
def locate_spheres(image, feature_rad, dofilter=False, order=(3 ,3, 3), trim_edge=True, **kwargs): """ Get an initial featuring of sphere positions in an image. Parameters ----------- image : :class:`peri.util.Image` object Image object which defines the image file as we...
def locate_spheres(image, feature_rad, dofilter=False, order=(3 ,3, 3), trim_edge=True, **kwargs): """ Get an initial featuring of sphere positions in an image. Parameters ----------- image : :class:`peri.util.Image` object Image object which defines the image file as we...
[ "Get", "an", "initial", "featuring", "of", "sphere", "positions", "in", "an", "image", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/runner.py#L35-L96
[ "def", "locate_spheres", "(", "image", ",", "feature_rad", ",", "dofilter", "=", "False", ",", "order", "=", "(", "3", ",", "3", ",", "3", ")", ",", "trim_edge", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# We just want a smoothed field model of the ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
get_initial_featuring
Completely optimizes a state from an image of roughly monodisperse particles. The user can interactively select the image. The state is periodically saved during optimization, with different filename for different stages of the optimization. Parameters ---------- statemaker : Function ...
peri/runner.py
def get_initial_featuring(statemaker, feature_rad, actual_rad=None, im_name=None, tile=None, invert=True, desc='', use_full_path=False, featuring_params={}, statemaker_kwargs={}, **kwargs): """ Completely optimizes a state from an image of roughly monodisperse particles. The user can in...
def get_initial_featuring(statemaker, feature_rad, actual_rad=None, im_name=None, tile=None, invert=True, desc='', use_full_path=False, featuring_params={}, statemaker_kwargs={}, **kwargs): """ Completely optimizes a state from an image of roughly monodisperse particles. The user can in...
[ "Completely", "optimizes", "a", "state", "from", "an", "image", "of", "roughly", "monodisperse", "particles", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/runner.py#L99-L208
[ "def", "get_initial_featuring", "(", "statemaker", ",", "feature_rad", ",", "actual_rad", "=", "None", ",", "im_name", "=", "None", ",", "tile", "=", "None", ",", "invert", "=", "True", ",", "desc", "=", "''", ",", "use_full_path", "=", "False", ",", "fe...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
feature_from_pos_rad
Gets a completely-optimized state from an image and an initial guess of particle positions and radii. The state is periodically saved during optimization, with different filename for different stages of the optimization. The user can select the image. Parameters ---------- statemaker :...
peri/runner.py
def feature_from_pos_rad(statemaker, pos, rad, im_name=None, tile=None, desc='', use_full_path=False, statemaker_kwargs={}, **kwargs): """ Gets a completely-optimized state from an image and an initial guess of particle positions and radii. The state is periodically saved during optimization, w...
def feature_from_pos_rad(statemaker, pos, rad, im_name=None, tile=None, desc='', use_full_path=False, statemaker_kwargs={}, **kwargs): """ Gets a completely-optimized state from an image and an initial guess of particle positions and radii. The state is periodically saved during optimization, w...
[ "Gets", "a", "completely", "-", "optimized", "state", "from", "an", "image", "and", "an", "initial", "guess", "of", "particle", "positions", "and", "radii", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/runner.py#L211-L309
[ "def", "feature_from_pos_rad", "(", "statemaker", ",", "pos", ",", "rad", ",", "im_name", "=", "None", ",", "tile", "=", "None", ",", "desc", "=", "''", ",", "use_full_path", "=", "False", ",", "statemaker_kwargs", "=", "{", "}", ",", "*", "*", "kwargs...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
optimize_from_initial
Optimizes a state from an initial set of positions and radii, without any known microscope parameters. Parameters ---------- s : :class:`peri.states.ImageState` The state to optimize. It is modified internally and returned. max_mem : Numeric, optional The maximum mem...
peri/runner.py
def optimize_from_initial(s, max_mem=1e9, invert='guess', desc='', rz_order=3, min_rad=None, max_rad=None): """ Optimizes a state from an initial set of positions and radii, without any known microscope parameters. Parameters ---------- s : :class:`peri.states.ImageState` ...
def optimize_from_initial(s, max_mem=1e9, invert='guess', desc='', rz_order=3, min_rad=None, max_rad=None): """ Optimizes a state from an initial set of positions and radii, without any known microscope parameters. Parameters ---------- s : :class:`peri.states.ImageState` ...
[ "Optimizes", "a", "state", "from", "an", "initial", "set", "of", "positions", "and", "radii", "without", "any", "known", "microscope", "parameters", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/runner.py#L312-L377
[ "def", "optimize_from_initial", "(", "s", ",", "max_mem", "=", "1e9", ",", "invert", "=", "'guess'", ",", "desc", "=", "''", ",", "rz_order", "=", "3", ",", "min_rad", "=", "None", ",", "max_rad", "=", "None", ")", ":", "RLOG", ".", "info", "(", "'...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
translate_featuring
Translates one optimized state into another image where the particles have moved by a small amount (~1 particle radius). Returns a completely-optimized state. The user can interactively selects the initial state and the second raw image. The state is periodically saved during optimization, with differe...
peri/runner.py
def translate_featuring(state_name=None, im_name=None, use_full_path=False, **kwargs): """ Translates one optimized state into another image where the particles have moved by a small amount (~1 particle radius). Returns a completely-optimized state. The user can interactively selects the in...
def translate_featuring(state_name=None, im_name=None, use_full_path=False, **kwargs): """ Translates one optimized state into another image where the particles have moved by a small amount (~1 particle radius). Returns a completely-optimized state. The user can interactively selects the in...
[ "Translates", "one", "optimized", "state", "into", "another", "image", "where", "the", "particles", "have", "moved", "by", "a", "small", "amount", "(", "~1", "particle", "radius", ")", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/runner.py#L380-L470
[ "def", "translate_featuring", "(", "state_name", "=", "None", ",", "im_name", "=", "None", ",", "use_full_path", "=", "False", ",", "*", "*", "kwargs", ")", ":", "state_name", ",", "im_name", "=", "_pick_state_im_name", "(", "state_name", ",", "im_name", ","...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
get_particles_featuring
Combines centroid featuring with the globals from a previous state. Runs trackpy.locate on an image, sets the globals from a previous state, calls _translate_particles Parameters ---------- feature_rad : Int, odd The particle radius for featuring, as passed to locate_spheres. ...
peri/runner.py
def get_particles_featuring(feature_rad, state_name=None, im_name=None, use_full_path=False, actual_rad=None, invert=True, featuring_params={}, **kwargs): """ Combines centroid featuring with the globals from a previous state. Runs trackpy.locate on an image, sets the globals from a previou...
def get_particles_featuring(feature_rad, state_name=None, im_name=None, use_full_path=False, actual_rad=None, invert=True, featuring_params={}, **kwargs): """ Combines centroid featuring with the globals from a previous state. Runs trackpy.locate on an image, sets the globals from a previou...
[ "Combines", "centroid", "featuring", "with", "the", "globals", "from", "a", "previous", "state", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/runner.py#L473-L580
[ "def", "get_particles_featuring", "(", "feature_rad", ",", "state_name", "=", "None", ",", "im_name", "=", "None", ",", "use_full_path", "=", "False", ",", "actual_rad", "=", "None", ",", "invert", "=", "True", ",", "featuring_params", "=", "{", "}", ",", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
_pick_state_im_name
If state_name or im_name is None, picks them interactively through Tk, and then sets with or without the full path. Parameters ---------- state_name : {string, None} The name of the state. If None, selected through Tk. im_name : {string, None} The name of the image. ...
peri/runner.py
def _pick_state_im_name(state_name, im_name, use_full_path=False): """ If state_name or im_name is None, picks them interactively through Tk, and then sets with or without the full path. Parameters ---------- state_name : {string, None} The name of the state. If None, selected t...
def _pick_state_im_name(state_name, im_name, use_full_path=False): """ If state_name or im_name is None, picks them interactively through Tk, and then sets with or without the full path. Parameters ---------- state_name : {string, None} The name of the state. If None, selected t...
[ "If", "state_name", "or", "im_name", "is", "None", "picks", "them", "interactively", "through", "Tk", "and", "then", "sets", "with", "or", "without", "the", "full", "path", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/runner.py#L583-L617
[ "def", "_pick_state_im_name", "(", "state_name", ",", "im_name", ",", "use_full_path", "=", "False", ")", ":", "initial_dir", "=", "os", ".", "getcwd", "(", ")", "if", "(", "state_name", "is", "None", ")", "or", "(", "im_name", "is", "None", ")", ":", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
_translate_particles
Workhorse for translating particles. See get_particles_featuring for docs.
peri/runner.py
def _translate_particles(s, max_mem=1e9, desc='', min_rad='calc', max_rad='calc', invert='guess', rz_order=0, do_polish=True): """ Workhorse for translating particles. See get_particles_featuring for docs. """ if desc is not None: desc_trans = desc + 'translate-particles' desc_bu...
def _translate_particles(s, max_mem=1e9, desc='', min_rad='calc', max_rad='calc', invert='guess', rz_order=0, do_polish=True): """ Workhorse for translating particles. See get_particles_featuring for docs. """ if desc is not None: desc_trans = desc + 'translate-particles' desc_bu...
[ "Workhorse", "for", "translating", "particles", ".", "See", "get_particles_featuring", "for", "docs", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/runner.py#L620-L651
[ "def", "_translate_particles", "(", "s", ",", "max_mem", "=", "1e9", ",", "desc", "=", "''", ",", "min_rad", "=", "'calc'", ",", "max_rad", "=", "'calc'", ",", "invert", "=", "'guess'", ",", "rz_order", "=", "0", ",", "do_polish", "=", "True", ")", "...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
link_zscale
Links the state ``st`` psf zscale with the global zscale
peri/runner.py
def link_zscale(st): """Links the state ``st`` psf zscale with the global zscale""" # FIXME should be made more generic to other parameters and categories psf = st.get('psf') psf.param_dict['zscale'] = psf.param_dict['psf-zscale'] psf.params[psf.params.index('psf-zscale')] = 'zscale' psf.global_...
def link_zscale(st): """Links the state ``st`` psf zscale with the global zscale""" # FIXME should be made more generic to other parameters and categories psf = st.get('psf') psf.param_dict['zscale'] = psf.param_dict['psf-zscale'] psf.params[psf.params.index('psf-zscale')] = 'zscale' psf.global_...
[ "Links", "the", "state", "st", "psf", "zscale", "with", "the", "global", "zscale" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/runner.py#L654-L663
[ "def", "link_zscale", "(", "st", ")", ":", "# FIXME should be made more generic to other parameters and categories", "psf", "=", "st", ".", "get", "(", "'psf'", ")", "psf", ".", "param_dict", "[", "'zscale'", "]", "=", "psf", ".", "param_dict", "[", "'psf-zscale'"...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
finish_state
Final optimization for the best-possible state. Runs a local add-subtract to capture any difficult-to-feature particles, then does another set of optimization designed to get to the best possible fit. Parameters ---------- st : :class:`peri.states.ImageState` The state to finis...
peri/runner.py
def finish_state(st, desc='finish-state', invert='guess'): """ Final optimization for the best-possible state. Runs a local add-subtract to capture any difficult-to-feature particles, then does another set of optimization designed to get to the best possible fit. Parameters ---------- ...
def finish_state(st, desc='finish-state', invert='guess'): """ Final optimization for the best-possible state. Runs a local add-subtract to capture any difficult-to-feature particles, then does another set of optimization designed to get to the best possible fit. Parameters ---------- ...
[ "Final", "optimization", "for", "the", "best", "-", "possible", "state", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/runner.py#L666-L701
[ "def", "finish_state", "(", "st", ",", "desc", "=", "'finish-state'", ",", "invert", "=", "'guess'", ")", ":", "for", "minmass", "in", "[", "None", ",", "0", "]", ":", "for", "_", "in", "range", "(", "3", ")", ":", "npart", ",", "poses", "=", "ad...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
optimize_particle
Methods available are gn : Gauss-Newton with JTJ (recommended) nr : Newton-Rhaphson with hessian if doradius, also optimize the radius.
peri/opt/scalar.py
def optimize_particle(state, index, method='gn', doradius=True): """ Methods available are gn : Gauss-Newton with JTJ (recommended) nr : Newton-Rhaphson with hessian if doradius, also optimize the radius. """ blocks = state.param_particle(index) if not doradius: blocks ...
def optimize_particle(state, index, method='gn', doradius=True): """ Methods available are gn : Gauss-Newton with JTJ (recommended) nr : Newton-Rhaphson with hessian if doradius, also optimize the radius. """ blocks = state.param_particle(index) if not doradius: blocks ...
[ "Methods", "available", "are", "gn", ":", "Gauss", "-", "Newton", "with", "JTJ", "(", "recommended", ")", "nr", ":", "Newton", "-", "Rhaphson", "with", "hessian" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/scalar.py#L11-L34
[ "def", "optimize_particle", "(", "state", ",", "index", ",", "method", "=", "'gn'", ",", "doradius", "=", "True", ")", ":", "blocks", "=", "state", ".", "param_particle", "(", "index", ")", "if", "not", "doradius", ":", "blocks", "=", "blocks", "[", ":...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
makestate
Workhorse for creating & optimizing states with an initial centroid guess. This is an example function that works for a particular microscope. For your own microscope, you'll need to change particulars such as the psf type and the orders of the background and illumination. Parameters ---------...
scripts/statemaker_example.py
def makestate(im, pos, rad, slab=None, mem_level='hi'): """ Workhorse for creating & optimizing states with an initial centroid guess. This is an example function that works for a particular microscope. For your own microscope, you'll need to change particulars such as the psf type and the orde...
def makestate(im, pos, rad, slab=None, mem_level='hi'): """ Workhorse for creating & optimizing states with an initial centroid guess. This is an example function that works for a particular microscope. For your own microscope, you'll need to change particulars such as the psf type and the orde...
[ "Workhorse", "for", "creating", "&", "optimizing", "states", "with", "an", "initial", "centroid", "guess", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/scripts/statemaker_example.py#L5-L59
[ "def", "makestate", "(", "im", ",", "pos", ",", "rad", ",", "slab", "=", "None", ",", "mem_level", "=", "'hi'", ")", ":", "if", "slab", "is", "not", "None", ":", "o", "=", "comp", ".", "ComponentCollection", "(", "[", "objs", ".", "PlatonicSpheresCol...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
_calc_ilm_order
Calculates an ilm order based on the shape of an image. This is based on something that works for our particular images. Your mileage will vary. Parameters ---------- imshape : 3-element list-like The shape of the image. Returns ------- npts : tuple The numb...
scripts/statemaker_example.py
def _calc_ilm_order(imshape): """ Calculates an ilm order based on the shape of an image. This is based on something that works for our particular images. Your mileage will vary. Parameters ---------- imshape : 3-element list-like The shape of the image. Returns -------...
def _calc_ilm_order(imshape): """ Calculates an ilm order based on the shape of an image. This is based on something that works for our particular images. Your mileage will vary. Parameters ---------- imshape : 3-element list-like The shape of the image. Returns -------...
[ "Calculates", "an", "ilm", "order", "based", "on", "the", "shape", "of", "an", "image", ".", "This", "is", "based", "on", "something", "that", "works", "for", "our", "particular", "images", ".", "Your", "mileage", "will", "vary", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/scripts/statemaker_example.py#L61-L86
[ "def", "_calc_ilm_order", "(", "imshape", ")", ":", "zorder", "=", "int", "(", "imshape", "[", "0", "]", "/", "6.25", ")", "+", "1", "l_npts", "=", "int", "(", "imshape", "[", "1", "]", "/", "42.5", ")", "+", "1", "npts", "=", "(", ")", "for", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ResponseObject._check_for_inception
Used to check if there is a dict in a dict
buffpy/response.py
def _check_for_inception(self, root_dict): ''' Used to check if there is a dict in a dict ''' for key in root_dict: if isinstance(root_dict[key], dict): root_dict[key] = ResponseObject(root_dict[key]) return root_dict
def _check_for_inception(self, root_dict): ''' Used to check if there is a dict in a dict ''' for key in root_dict: if isinstance(root_dict[key], dict): root_dict[key] = ResponseObject(root_dict[key]) return root_dict
[ "Used", "to", "check", "if", "there", "is", "a", "dict", "in", "a", "dict" ]
vtemian/buffpy
python
https://github.com/vtemian/buffpy/blob/6c9236fd3b6a8f9e2d70dbf1bc01529242b73075/buffpy/response.py#L20-L29
[ "def", "_check_for_inception", "(", "self", ",", "root_dict", ")", ":", "for", "key", "in", "root_dict", ":", "if", "isinstance", "(", "root_dict", "[", "key", "]", ",", "dict", ")", ":", "root_dict", "[", "key", "]", "=", "ResponseObject", "(", "root_di...
6c9236fd3b6a8f9e2d70dbf1bc01529242b73075
valid
BarnesStreakLegPoly2P1D.randomize_parameters
Create random parameters for this ILM that mimic experiments as closely as possible without real assumptions.
peri/comp/ilms.py
def randomize_parameters(self, ptp=0.2, fourier=False, vmin=None, vmax=None): """ Create random parameters for this ILM that mimic experiments as closely as possible without real assumptions. """ if vmin is not None and vmax is not None: ptp = vmax - vmin elif...
def randomize_parameters(self, ptp=0.2, fourier=False, vmin=None, vmax=None): """ Create random parameters for this ILM that mimic experiments as closely as possible without real assumptions. """ if vmin is not None and vmax is not None: ptp = vmax - vmin elif...
[ "Create", "random", "parameters", "for", "this", "ILM", "that", "mimic", "experiments", "as", "closely", "as", "possible", "without", "real", "assumptions", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/ilms.py#L717-L759
[ "def", "randomize_parameters", "(", "self", ",", "ptp", "=", "0.2", ",", "fourier", "=", "False", ",", "vmin", "=", "None", ",", "vmax", "=", "None", ")", ":", "if", "vmin", "is", "not", "None", "and", "vmax", "is", "not", "None", ":", "ptp", "=", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
BarnesXYLegPolyZ._barnes
Creates a barnes interpolant & calculates its values
peri/comp/ilms.py
def _barnes(self, pos): """Creates a barnes interpolant & calculates its values""" b_in = self.b_in dist = lambda x: np.sqrt(np.dot(x,x)) #we take a filter size as the max distance between the grids along #x or y: sz = self.npts[1] coeffs = self.get_values(self.ba...
def _barnes(self, pos): """Creates a barnes interpolant & calculates its values""" b_in = self.b_in dist = lambda x: np.sqrt(np.dot(x,x)) #we take a filter size as the max distance between the grids along #x or y: sz = self.npts[1] coeffs = self.get_values(self.ba...
[ "Creates", "a", "barnes", "interpolant", "&", "calculates", "its", "values" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/ilms.py#L823-L837
[ "def", "_barnes", "(", "self", ",", "pos", ")", ":", "b_in", "=", "self", ".", "b_in", "dist", "=", "lambda", "x", ":", "np", ".", "sqrt", "(", "np", ".", "dot", "(", "x", ",", "x", ")", ")", "#we take a filter size as the max distance between the grids ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Profile.schedules
Returns details of the posting schedules associated with a social media profile.
buffpy/models/profile.py
def schedules(self): ''' Returns details of the posting schedules associated with a social media profile. ''' url = PATHS['GET_SCHEDULES'] % self.id self.__schedules = self.api.get(url=url) return self.__schedules
def schedules(self): ''' Returns details of the posting schedules associated with a social media profile. ''' url = PATHS['GET_SCHEDULES'] % self.id self.__schedules = self.api.get(url=url) return self.__schedules
[ "Returns", "details", "of", "the", "posting", "schedules", "associated", "with", "a", "social", "media", "profile", "." ]
vtemian/buffpy
python
https://github.com/vtemian/buffpy/blob/6c9236fd3b6a8f9e2d70dbf1bc01529242b73075/buffpy/models/profile.py#L23-L33
[ "def", "schedules", "(", "self", ")", ":", "url", "=", "PATHS", "[", "'GET_SCHEDULES'", "]", "%", "self", ".", "id", "self", ".", "__schedules", "=", "self", ".", "api", ".", "get", "(", "url", "=", "url", ")", "return", "self", ".", "__schedules" ]
6c9236fd3b6a8f9e2d70dbf1bc01529242b73075
valid
Profile.schedules
Set the posting schedules for the specified social media profile.
buffpy/models/profile.py
def schedules(self, schedules): ''' Set the posting schedules for the specified social media profile. ''' url = PATHS['UPDATE_SCHEDULES'] % self.id data_format = "schedules[0][%s][]=%s&" post_data = "" for format_type, values in schedules.iteritems(): for value in values: ...
def schedules(self, schedules): ''' Set the posting schedules for the specified social media profile. ''' url = PATHS['UPDATE_SCHEDULES'] % self.id data_format = "schedules[0][%s][]=%s&" post_data = "" for format_type, values in schedules.iteritems(): for value in values: ...
[ "Set", "the", "posting", "schedules", "for", "the", "specified", "social", "media", "profile", "." ]
vtemian/buffpy
python
https://github.com/vtemian/buffpy/blob/6c9236fd3b6a8f9e2d70dbf1bc01529242b73075/buffpy/models/profile.py#L36-L50
[ "def", "schedules", "(", "self", ",", "schedules", ")", ":", "url", "=", "PATHS", "[", "'UPDATE_SCHEDULES'", "]", "%", "self", ".", "id", "data_format", "=", "\"schedules[0][%s][]=%s&\"", "post_data", "=", "\"\"", "for", "format_type", ",", "values", "in", "...
6c9236fd3b6a8f9e2d70dbf1bc01529242b73075
valid
moment
Calculates the moments of the probability distribution p with vector v
peri/comp/exactpsf.py
def moment(p, v, order=1): """ Calculates the moments of the probability distribution p with vector v """ if order == 1: return (v*p).sum() elif order == 2: return np.sqrt( ((v**2)*p).sum() - (v*p).sum()**2 )
def moment(p, v, order=1): """ Calculates the moments of the probability distribution p with vector v """ if order == 1: return (v*p).sum() elif order == 2: return np.sqrt( ((v**2)*p).sum() - (v*p).sum()**2 )
[ "Calculates", "the", "moments", "of", "the", "probability", "distribution", "p", "with", "vector", "v" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/exactpsf.py#L14-L19
[ "def", "moment", "(", "p", ",", "v", ",", "order", "=", "1", ")", ":", "if", "order", "==", "1", ":", "return", "(", "v", "*", "p", ")", ".", "sum", "(", ")", "elif", "order", "==", "2", ":", "return", "np", ".", "sqrt", "(", "(", "(", "v...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ExactPSF.psf_slice
Calculates the 3D psf at a particular z pixel height Parameters ---------- zint : float z pixel height in image coordinates , converted to 1/k by the function using the slab position as well size : int, list, tuple The size over which to calculate th...
peri/comp/exactpsf.py
def psf_slice(self, zint, size=11, zoffset=0., getextent=False): """ Calculates the 3D psf at a particular z pixel height Parameters ---------- zint : float z pixel height in image coordinates , converted to 1/k by the function using the slab position as ...
def psf_slice(self, zint, size=11, zoffset=0., getextent=False): """ Calculates the 3D psf at a particular z pixel height Parameters ---------- zint : float z pixel height in image coordinates , converted to 1/k by the function using the slab position as ...
[ "Calculates", "the", "3D", "psf", "at", "a", "particular", "z", "pixel", "height" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/exactpsf.py#L227-L309
[ "def", "psf_slice", "(", "self", ",", "zint", ",", "size", "=", "11", ",", "zoffset", "=", "0.", ",", "getextent", "=", "False", ")", ":", "# calculate the current pixel value in 1/k, making sure we are above the slab", "zint", "=", "max", "(", "self", ".", "_p2...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ExactPSF._p2k
Convert from pixel to 1/k_incoming (laser_wavelength/(2\pi)) units
peri/comp/exactpsf.py
def _p2k(self, v): """ Convert from pixel to 1/k_incoming (laser_wavelength/(2\pi)) units """ return 2*np.pi*self.pxsize*v/self.param_dict['psf-laser-wavelength']
def _p2k(self, v): """ Convert from pixel to 1/k_incoming (laser_wavelength/(2\pi)) units """ return 2*np.pi*self.pxsize*v/self.param_dict['psf-laser-wavelength']
[ "Convert", "from", "pixel", "to", "1", "/", "k_incoming", "(", "laser_wavelength", "/", "(", "2", "\\", "pi", "))", "units" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/exactpsf.py#L321-L323
[ "def", "_p2k", "(", "self", ",", "v", ")", ":", "return", "2", "*", "np", ".", "pi", "*", "self", ".", "pxsize", "*", "v", "/", "self", ".", "param_dict", "[", "'psf-laser-wavelength'", "]" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ExactPSF._tz
Transform z to real-space coordinates from tile coordinates
peri/comp/exactpsf.py
def _tz(self, z): """ Transform z to real-space coordinates from tile coordinates """ return (z-self.param_dict['psf-zslab'])*self.param_dict[self.zscale]
def _tz(self, z): """ Transform z to real-space coordinates from tile coordinates """ return (z-self.param_dict['psf-zslab'])*self.param_dict[self.zscale]
[ "Transform", "z", "to", "real", "-", "space", "coordinates", "from", "tile", "coordinates" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/exactpsf.py#L325-L327
[ "def", "_tz", "(", "self", ",", "z", ")", ":", "return", "(", "z", "-", "self", ".", "param_dict", "[", "'psf-zslab'", "]", ")", "*", "self", ".", "param_dict", "[", "self", ".", "zscale", "]" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ExactPSF.measure_size_drift
Returns the 'size' of the psf in each direction a particular z (px)
peri/comp/exactpsf.py
def measure_size_drift(self, z, size=31, zoffset=0.): """ Returns the 'size' of the psf in each direction a particular z (px) """ drift = 0.0 for i in range(self.measurement_iterations): psf, vec = self.psf_slice(z, size=size, zoffset=zoffset+drift) psf = psf / psf.sum() ...
def measure_size_drift(self, z, size=31, zoffset=0.): """ Returns the 'size' of the psf in each direction a particular z (px) """ drift = 0.0 for i in range(self.measurement_iterations): psf, vec = self.psf_slice(z, size=size, zoffset=zoffset+drift) psf = psf / psf.sum() ...
[ "Returns", "the", "size", "of", "the", "psf", "in", "each", "direction", "a", "particular", "z", "(", "px", ")" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/exactpsf.py#L333-L342
[ "def", "measure_size_drift", "(", "self", ",", "z", ",", "size", "=", "31", ",", "zoffset", "=", "0.", ")", ":", "drift", "=", "0.0", "for", "i", "in", "range", "(", "self", ".", "measurement_iterations", ")", ":", "psf", ",", "vec", "=", "self", "...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ExactPSF.characterize_psf
Get support size and drift polynomial for current set of params
peri/comp/exactpsf.py
def characterize_psf(self): """ Get support size and drift polynomial for current set of params """ # there may be an issue with the support and characterization-- # it might be best to do the characterization with the same support # as the calculated psf. l,u = max(self.zrange[0...
def characterize_psf(self): """ Get support size and drift polynomial for current set of params """ # there may be an issue with the support and characterization-- # it might be best to do the characterization with the same support # as the calculated psf. l,u = max(self.zrange[0...
[ "Get", "support", "size", "and", "drift", "polynomial", "for", "current", "set", "of", "params" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/exactpsf.py#L344-L363
[ "def", "characterize_psf", "(", "self", ")", ":", "# there may be an issue with the support and characterization--", "# it might be best to do the characterization with the same support", "# as the calculated psf.", "l", ",", "u", "=", "max", "(", "self", ".", "zrange", "[", "0...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ExactPSF._kpad
fftshift and pad the field with zeros until it has size finalshape. if zpad is off, then no padding is put on the z direction. returns the fourier transform of the field
peri/comp/exactpsf.py
def _kpad(self, field, finalshape, zpad=False, norm=True): """ fftshift and pad the field with zeros until it has size finalshape. if zpad is off, then no padding is put on the z direction. returns the fourier transform of the field """ currshape = np.array(field.shape) ...
def _kpad(self, field, finalshape, zpad=False, norm=True): """ fftshift and pad the field with zeros until it has size finalshape. if zpad is off, then no padding is put on the z direction. returns the fourier transform of the field """ currshape = np.array(field.shape) ...
[ "fftshift", "and", "pad", "the", "field", "with", "zeros", "until", "it", "has", "size", "finalshape", ".", "if", "zpad", "is", "off", "then", "no", "padding", "is", "put", "on", "the", "z", "direction", ".", "returns", "the", "fourier", "transform", "of...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/exactpsf.py#L404-L432
[ "def", "_kpad", "(", "self", ",", "field", ",", "finalshape", ",", "zpad", "=", "False", ",", "norm", "=", "True", ")", ":", "currshape", "=", "np", ".", "array", "(", "field", ".", "shape", ")", "if", "any", "(", "finalshape", "<", "currshape", ")...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ExactLineScanConfocalPSF.pack_args
Pack the parameters into the form necessary for the integration routines above. For example, packs for calculate_linescan_psf
peri/comp/exactpsf.py
def pack_args(self): """ Pack the parameters into the form necessary for the integration routines above. For example, packs for calculate_linescan_psf """ mapper = { 'psf-kfki': 'kfki', 'psf-alpha': 'alpha', 'psf-n2n1': 'n2n1', 'ps...
def pack_args(self): """ Pack the parameters into the form necessary for the integration routines above. For example, packs for calculate_linescan_psf """ mapper = { 'psf-kfki': 'kfki', 'psf-alpha': 'alpha', 'psf-n2n1': 'n2n1', 'ps...
[ "Pack", "the", "parameters", "into", "the", "form", "necessary", "for", "the", "integration", "routines", "above", ".", "For", "example", "packs", "for", "calculate_linescan_psf" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/exactpsf.py#L624-L659
[ "def", "pack_args", "(", "self", ")", ":", "mapper", "=", "{", "'psf-kfki'", ":", "'kfki'", ",", "'psf-alpha'", ":", "'alpha'", ",", "'psf-n2n1'", ":", "'n2n1'", ",", "'psf-sigkf'", ":", "'sigkf'", ",", "'psf-sph6-ab'", ":", "'sph6_ab'", ",", "'psf-laser-wav...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ExactLineScanConfocalPSF.psffunc
Calculates a linescan psf
peri/comp/exactpsf.py
def psffunc(self, *args, **kwargs): """Calculates a linescan psf""" if self.polychromatic: func = psfcalc.calculate_polychrome_linescan_psf else: func = psfcalc.calculate_linescan_psf return func(*args, **kwargs)
def psffunc(self, *args, **kwargs): """Calculates a linescan psf""" if self.polychromatic: func = psfcalc.calculate_polychrome_linescan_psf else: func = psfcalc.calculate_linescan_psf return func(*args, **kwargs)
[ "Calculates", "a", "linescan", "psf" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/exactpsf.py#L661-L667
[ "def", "psffunc", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "polychromatic", ":", "func", "=", "psfcalc", ".", "calculate_polychrome_linescan_psf", "else", ":", "func", "=", "psfcalc", ".", "calculate_linescan_psf",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ExactPinholeConfocalPSF.psffunc
Calculates a pinhole psf
peri/comp/exactpsf.py
def psffunc(self, x, y, z, **kwargs): """Calculates a pinhole psf""" #do_pinhole?? FIXME if self.polychromatic: func = psfcalc.calculate_polychrome_pinhole_psf else: func = psfcalc.calculate_pinhole_psf x0, y0 = [psfcalc.vec_to_halfvec(v) for v in [x,y]] ...
def psffunc(self, x, y, z, **kwargs): """Calculates a pinhole psf""" #do_pinhole?? FIXME if self.polychromatic: func = psfcalc.calculate_polychrome_pinhole_psf else: func = psfcalc.calculate_pinhole_psf x0, y0 = [psfcalc.vec_to_halfvec(v) for v in [x,y]] ...
[ "Calculates", "a", "pinhole", "psf" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/exactpsf.py#L818-L827
[ "def", "psffunc", "(", "self", ",", "x", ",", "y", ",", "z", ",", "*", "*", "kwargs", ")", ":", "#do_pinhole?? FIXME", "if", "self", ".", "polychromatic", ":", "func", "=", "psfcalc", ".", "calculate_polychrome_pinhole_psf", "else", ":", "func", "=", "ps...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
FixedSSChebPSF.characterize_psf
Get support size and drift polynomial for current set of params
peri/comp/exactpsf.py
def characterize_psf(self): """ Get support size and drift polynomial for current set of params """ l,u = max(self.zrange[0], self.param_dict['psf-zslab']), self.zrange[1] size_l, drift_l = self.measure_size_drift(l, size=self.support) size_u, drift_u = self.measure_size_drift(u, size=s...
def characterize_psf(self): """ Get support size and drift polynomial for current set of params """ l,u = max(self.zrange[0], self.param_dict['psf-zslab']), self.zrange[1] size_l, drift_l = self.measure_size_drift(l, size=self.support) size_u, drift_u = self.measure_size_drift(u, size=s...
[ "Get", "support", "size", "and", "drift", "polynomial", "for", "current", "set", "of", "params" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/exactpsf.py#L903-L910
[ "def", "characterize_psf", "(", "self", ")", ":", "l", ",", "u", "=", "max", "(", "self", ".", "zrange", "[", "0", "]", ",", "self", ".", "param_dict", "[", "'psf-zslab'", "]", ")", ",", "self", ".", "zrange", "[", "1", "]", "size_l", ",", "drift...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
BetsApi._req
Make request and convert JSON response to python objects
bets/__init__.py
def _req(self, url, method='GET', **kw): '''Make request and convert JSON response to python objects''' send = requests.post if method == 'POST' else requests.get try: r = send( url, headers=self._token_header(), timeout=self.settings['...
def _req(self, url, method='GET', **kw): '''Make request and convert JSON response to python objects''' send = requests.post if method == 'POST' else requests.get try: r = send( url, headers=self._token_header(), timeout=self.settings['...
[ "Make", "request", "and", "convert", "JSON", "response", "to", "python", "objects" ]
42cc/bets-api
python
https://github.com/42cc/bets-api/blob/63a8227c7d8c65eef9974374607bc34effff5c7c/bets/__init__.py#L65-L82
[ "def", "_req", "(", "self", ",", "url", ",", "method", "=", "'GET'", ",", "*", "*", "kw", ")", ":", "send", "=", "requests", ".", "post", "if", "method", "==", "'POST'", "else", "requests", ".", "get", "try", ":", "r", "=", "send", "(", "url", ...
63a8227c7d8c65eef9974374607bc34effff5c7c
valid
BetsApi.get_active_bets
Returns all active bets
bets/__init__.py
def get_active_bets(self, project_id=None): '''Returns all active bets''' url = urljoin( self.settings['bets_url'], 'bets?state=fresh,active,accept_end&page=1&page_size=100') if project_id is not None: url += '&kava_project_id={}'.format(project_id) ...
def get_active_bets(self, project_id=None): '''Returns all active bets''' url = urljoin( self.settings['bets_url'], 'bets?state=fresh,active,accept_end&page=1&page_size=100') if project_id is not None: url += '&kava_project_id={}'.format(project_id) ...
[ "Returns", "all", "active", "bets" ]
42cc/bets-api
python
https://github.com/42cc/bets-api/blob/63a8227c7d8c65eef9974374607bc34effff5c7c/bets/__init__.py#L84-L101
[ "def", "get_active_bets", "(", "self", ",", "project_id", "=", "None", ")", ":", "url", "=", "urljoin", "(", "self", ".", "settings", "[", "'bets_url'", "]", ",", "'bets?state=fresh,active,accept_end&page=1&page_size=100'", ")", "if", "project_id", "is", "not", ...
63a8227c7d8c65eef9974374607bc34effff5c7c
valid
BetsApi.get_bets
Return bets with given filters and ordering. :param type: return bets only with this type. Use None to include all (default). :param order_by: '-last_stake' or 'last_stake' to sort by stake's created date or None for default ordering. :param state: ...
bets/__init__.py
def get_bets(self, type=None, order_by=None, state=None, project_id=None, page=None, page_size=None): """Return bets with given filters and ordering. :param type: return bets only with this type. Use None to include all (default). :param order_by: '-last_st...
def get_bets(self, type=None, order_by=None, state=None, project_id=None, page=None, page_size=None): """Return bets with given filters and ordering. :param type: return bets only with this type. Use None to include all (default). :param order_by: '-last_st...
[ "Return", "bets", "with", "given", "filters", "and", "ordering", "." ]
42cc/bets-api
python
https://github.com/42cc/bets-api/blob/63a8227c7d8c65eef9974374607bc34effff5c7c/bets/__init__.py#L103-L139
[ "def", "get_bets", "(", "self", ",", "type", "=", "None", ",", "order_by", "=", "None", ",", "state", "=", "None", ",", "project_id", "=", "None", ",", "page", "=", "None", ",", "page_size", "=", "None", ")", ":", "if", "page", "is", "None", ":", ...
63a8227c7d8c65eef9974374607bc34effff5c7c
valid
BetsApi.get_project_slug
Return slug of a project that given bet is associated with or None if bet is not associated with any project.
bets/__init__.py
def get_project_slug(self, bet): '''Return slug of a project that given bet is associated with or None if bet is not associated with any project. ''' if bet.get('form_params'): params = json.loads(bet['form_params']) return params.get('project') return Non...
def get_project_slug(self, bet): '''Return slug of a project that given bet is associated with or None if bet is not associated with any project. ''' if bet.get('form_params'): params = json.loads(bet['form_params']) return params.get('project') return Non...
[ "Return", "slug", "of", "a", "project", "that", "given", "bet", "is", "associated", "with", "or", "None", "if", "bet", "is", "not", "associated", "with", "any", "project", "." ]
42cc/bets-api
python
https://github.com/42cc/bets-api/blob/63a8227c7d8c65eef9974374607bc34effff5c7c/bets/__init__.py#L141-L148
[ "def", "get_project_slug", "(", "self", ",", "bet", ")", ":", "if", "bet", ".", "get", "(", "'form_params'", ")", ":", "params", "=", "json", ".", "loads", "(", "bet", "[", "'form_params'", "]", ")", "return", "params", ".", "get", "(", "'project'", ...
63a8227c7d8c65eef9974374607bc34effff5c7c
valid
BetsApi.subscribe
Subscribe to event for given bet ids.
bets/__init__.py
def subscribe(self, event, bet_ids): '''Subscribe to event for given bet ids.''' if not self._subscriptions.get(event): self._subscriptions[event] = set() self._subscriptions[event] = self._subscriptions[event].union(bet_ids)
def subscribe(self, event, bet_ids): '''Subscribe to event for given bet ids.''' if not self._subscriptions.get(event): self._subscriptions[event] = set() self._subscriptions[event] = self._subscriptions[event].union(bet_ids)
[ "Subscribe", "to", "event", "for", "given", "bet", "ids", "." ]
42cc/bets-api
python
https://github.com/42cc/bets-api/blob/63a8227c7d8c65eef9974374607bc34effff5c7c/bets/__init__.py#L306-L310
[ "def", "subscribe", "(", "self", ",", "event", ",", "bet_ids", ")", ":", "if", "not", "self", ".", "_subscriptions", ".", "get", "(", "event", ")", ":", "self", ".", "_subscriptions", "[", "event", "]", "=", "set", "(", ")", "self", ".", "_subscripti...
63a8227c7d8c65eef9974374607bc34effff5c7c
valid
preview
Opens local preview of your blog website
danube_delta/cli/preview.py
def preview(context): """Opens local preview of your blog website""" config = context.obj pelican(config, '--verbose', '--ignore-cache') server_proc = None os.chdir(config['OUTPUT_DIR']) try: try: command = 'python -m http.server ' + str(PORT) server_proc = run...
def preview(context): """Opens local preview of your blog website""" config = context.obj pelican(config, '--verbose', '--ignore-cache') server_proc = None os.chdir(config['OUTPUT_DIR']) try: try: command = 'python -m http.server ' + str(PORT) server_proc = run...
[ "Opens", "local", "preview", "of", "your", "blog", "website" ]
honzajavorek/danube-delta
python
https://github.com/honzajavorek/danube-delta/blob/d0a72f0704d52b888e7fb2b68c4fdc696d370018/danube_delta/cli/preview.py#L15-L39
[ "def", "preview", "(", "context", ")", ":", "config", "=", "context", ".", "obj", "pelican", "(", "config", ",", "'--verbose'", ",", "'--ignore-cache'", ")", "server_proc", "=", "None", "os", ".", "chdir", "(", "config", "[", "'OUTPUT_DIR'", "]", ")", "t...
d0a72f0704d52b888e7fb2b68c4fdc696d370018
valid
APIConnected.get_collection_endpoint
Get the relative path to the API resource collection If self.collection_endpoint is not set, it will default to the lowercase name of the resource class plus an "s" and the terminating "/" :param cls: Resource class :return: Relative path to the resource collection
pyrestcli/resources.py
def get_collection_endpoint(cls): """ Get the relative path to the API resource collection If self.collection_endpoint is not set, it will default to the lowercase name of the resource class plus an "s" and the terminating "/" :param cls: Resource class :return: Relative path to...
def get_collection_endpoint(cls): """ Get the relative path to the API resource collection If self.collection_endpoint is not set, it will default to the lowercase name of the resource class plus an "s" and the terminating "/" :param cls: Resource class :return: Relative path to...
[ "Get", "the", "relative", "path", "to", "the", "API", "resource", "collection" ]
danicarrion/pyrestcli
python
https://github.com/danicarrion/pyrestcli/blob/cde9a2ed856b81cac86386e8d87d901fa03d7b11/pyrestcli/resources.py#L46-L54
[ "def", "get_collection_endpoint", "(", "cls", ")", ":", "return", "cls", ".", "Meta", ".", "collection_endpoint", "if", "cls", ".", "Meta", ".", "collection_endpoint", "is", "not", "None", "else", "cls", ".", "__name__", ".", "lower", "(", ")", "+", "\"s/\...
cde9a2ed856b81cac86386e8d87d901fa03d7b11
valid
APIConnected.send
Make the actual request to the API :param url: URL :param http_method: The method used to make the request to the API :param client_args: Arguments to be sent to the auth client :return: requests' response object
pyrestcli/resources.py
def send(self, url, http_method, **client_args): """ Make the actual request to the API :param url: URL :param http_method: The method used to make the request to the API :param client_args: Arguments to be sent to the auth client :return: requests' response object ...
def send(self, url, http_method, **client_args): """ Make the actual request to the API :param url: URL :param http_method: The method used to make the request to the API :param client_args: Arguments to be sent to the auth client :return: requests' response object ...
[ "Make", "the", "actual", "request", "to", "the", "API", ":", "param", "url", ":", "URL", ":", "param", "http_method", ":", "The", "method", "used", "to", "make", "the", "request", "to", "the", "API", ":", "param", "client_args", ":", "Arguments", "to", ...
danicarrion/pyrestcli
python
https://github.com/danicarrion/pyrestcli/blob/cde9a2ed856b81cac86386e8d87d901fa03d7b11/pyrestcli/resources.py#L56-L64
[ "def", "send", "(", "self", ",", "url", ",", "http_method", ",", "*", "*", "client_args", ")", ":", "return", "self", ".", "client", ".", "send", "(", "url", ",", "http_method", ",", "*", "*", "client_args", ")" ]
cde9a2ed856b81cac86386e8d87d901fa03d7b11
valid
Manager.get
Get one single resource from the API :param resource_id: Id of the resource to be retrieved :return: Retrieved resource
pyrestcli/resources.py
def get(self, resource_id): """ Get one single resource from the API :param resource_id: Id of the resource to be retrieved :return: Retrieved resource """ response = self.send(self.get_resource_endpoint(resource_id), "get") try: resource = self.resou...
def get(self, resource_id): """ Get one single resource from the API :param resource_id: Id of the resource to be retrieved :return: Retrieved resource """ response = self.send(self.get_resource_endpoint(resource_id), "get") try: resource = self.resou...
[ "Get", "one", "single", "resource", "from", "the", "API", ":", "param", "resource_id", ":", "Id", "of", "the", "resource", "to", "be", "retrieved", ":", "return", ":", "Retrieved", "resource" ]
danicarrion/pyrestcli
python
https://github.com/danicarrion/pyrestcli/blob/cde9a2ed856b81cac86386e8d87d901fa03d7b11/pyrestcli/resources.py#L261-L275
[ "def", "get", "(", "self", ",", "resource_id", ")", ":", "response", "=", "self", ".", "send", "(", "self", ".", "get_resource_endpoint", "(", "resource_id", ")", ",", "\"get\"", ")", "try", ":", "resource", "=", "self", ".", "resource_class", "(", "self...
cde9a2ed856b81cac86386e8d87d901fa03d7b11
valid
Manager.filter
Get a filtered list of resources :param search_args: To be translated into ?arg1=value1&arg2=value2... :return: A list of resources
pyrestcli/resources.py
def filter(self, **search_args): """ Get a filtered list of resources :param search_args: To be translated into ?arg1=value1&arg2=value2... :return: A list of resources """ search_args = search_args or {} raw_resources = [] for url, paginator_params in se...
def filter(self, **search_args): """ Get a filtered list of resources :param search_args: To be translated into ?arg1=value1&arg2=value2... :return: A list of resources """ search_args = search_args or {} raw_resources = [] for url, paginator_params in se...
[ "Get", "a", "filtered", "list", "of", "resources", ":", "param", "search_args", ":", "To", "be", "translated", "into", "?arg1", "=", "value1&arg2", "=", "value2", "...", ":", "return", ":", "A", "list", "of", "resources" ]
danicarrion/pyrestcli
python
https://github.com/danicarrion/pyrestcli/blob/cde9a2ed856b81cac86386e8d87d901fa03d7b11/pyrestcli/resources.py#L277-L302
[ "def", "filter", "(", "self", ",", "*", "*", "search_args", ")", ":", "search_args", "=", "search_args", "or", "{", "}", "raw_resources", "=", "[", "]", "for", "url", ",", "paginator_params", "in", "self", ".", "paginator", ".", "get_urls", "(", "self", ...
cde9a2ed856b81cac86386e8d87d901fa03d7b11
valid
Manager.create
Create a resource on the server :params kwargs: Attributes (field names and values) of the new resource
pyrestcli/resources.py
def create(self, **kwargs): """ Create a resource on the server :params kwargs: Attributes (field names and values) of the new resource """ resource = self.resource_class(self.client) resource.update_from_dict(kwargs) resource.save(force_create=True) retu...
def create(self, **kwargs): """ Create a resource on the server :params kwargs: Attributes (field names and values) of the new resource """ resource = self.resource_class(self.client) resource.update_from_dict(kwargs) resource.save(force_create=True) retu...
[ "Create", "a", "resource", "on", "the", "server", ":", "params", "kwargs", ":", "Attributes", "(", "field", "names", "and", "values", ")", "of", "the", "new", "resource" ]
danicarrion/pyrestcli
python
https://github.com/danicarrion/pyrestcli/blob/cde9a2ed856b81cac86386e8d87d901fa03d7b11/pyrestcli/resources.py#L311-L320
[ "def", "create", "(", "self", ",", "*", "*", "kwargs", ")", ":", "resource", "=", "self", ".", "resource_class", "(", "self", ".", "client", ")", "resource", ".", "update_from_dict", "(", "kwargs", ")", "resource", ".", "save", "(", "force_create", "=", ...
cde9a2ed856b81cac86386e8d87d901fa03d7b11
valid
BaseAuthClient.send
Subclasses must implement this method, that will be used to send API requests with proper auth :param relative_path: URL path relative to self.base_url :param http_method: HTTP method :param requests_args: kargs to be sent to requests :return:
pyrestcli/auth.py
def send(self, relative_path, http_method, **requests_args): """ Subclasses must implement this method, that will be used to send API requests with proper auth :param relative_path: URL path relative to self.base_url :param http_method: HTTP method :param requests_args: kargs to ...
def send(self, relative_path, http_method, **requests_args): """ Subclasses must implement this method, that will be used to send API requests with proper auth :param relative_path: URL path relative to self.base_url :param http_method: HTTP method :param requests_args: kargs to ...
[ "Subclasses", "must", "implement", "this", "method", "that", "will", "be", "used", "to", "send", "API", "requests", "with", "proper", "auth", ":", "param", "relative_path", ":", "URL", "path", "relative", "to", "self", ".", "base_url", ":", "param", "http_me...
danicarrion/pyrestcli
python
https://github.com/danicarrion/pyrestcli/blob/cde9a2ed856b81cac86386e8d87d901fa03d7b11/pyrestcli/auth.py#L26-L36
[ "def", "send", "(", "self", ",", "relative_path", ",", "http_method", ",", "*", "*", "requests_args", ")", ":", "url", "=", "urljoin", "(", "self", ".", "base_url", ",", "relative_path", ")", "return", "self", ".", "session", ".", "request", "(", "http_m...
cde9a2ed856b81cac86386e8d87d901fa03d7b11
valid
BaseAuthClient.get_response_data
Get response data or throw an appropiate exception :param response: requests response object :param parse_json: if True, response will be parsed as JSON :return: response data, either as json or as a regular response.content object
pyrestcli/auth.py
def get_response_data(self, response, parse_json=True): """ Get response data or throw an appropiate exception :param response: requests response object :param parse_json: if True, response will be parsed as JSON :return: response data, either as json or as a regular response.con...
def get_response_data(self, response, parse_json=True): """ Get response data or throw an appropiate exception :param response: requests response object :param parse_json: if True, response will be parsed as JSON :return: response data, either as json or as a regular response.con...
[ "Get", "response", "data", "or", "throw", "an", "appropiate", "exception", ":", "param", "response", ":", "requests", "response", "object", ":", "param", "parse_json", ":", "if", "True", "response", "will", "be", "parsed", "as", "JSON", ":", "return", ":", ...
danicarrion/pyrestcli
python
https://github.com/danicarrion/pyrestcli/blob/cde9a2ed856b81cac86386e8d87d901fa03d7b11/pyrestcli/auth.py#L38-L62
[ "def", "get_response_data", "(", "self", ",", "response", ",", "parse_json", "=", "True", ")", ":", "if", "response", ".", "status_code", "in", "(", "requests", ".", "codes", ".", "ok", ",", "requests", ".", "codes", ".", "created", ")", ":", "if", "pa...
cde9a2ed856b81cac86386e8d87d901fa03d7b11
valid
NoAuthClient.send
Make a unauthorized request :param relative_path: URL path relative to self.base_url :param http_method: HTTP method :param requests_args: kargs to be sent to requests :return: requests' response object
pyrestcli/auth.py
def send(self, relative_path, http_method, **requests_args): """ Make a unauthorized request :param relative_path: URL path relative to self.base_url :param http_method: HTTP method :param requests_args: kargs to be sent to requests :return: requests' response object ...
def send(self, relative_path, http_method, **requests_args): """ Make a unauthorized request :param relative_path: URL path relative to self.base_url :param http_method: HTTP method :param requests_args: kargs to be sent to requests :return: requests' response object ...
[ "Make", "a", "unauthorized", "request", ":", "param", "relative_path", ":", "URL", "path", "relative", "to", "self", ".", "base_url", ":", "param", "http_method", ":", "HTTP", "method", ":", "param", "requests_args", ":", "kargs", "to", "be", "sent", "to", ...
danicarrion/pyrestcli
python
https://github.com/danicarrion/pyrestcli/blob/cde9a2ed856b81cac86386e8d87d901fa03d7b11/pyrestcli/auth.py#L70-L81
[ "def", "send", "(", "self", ",", "relative_path", ",", "http_method", ",", "*", "*", "requests_args", ")", ":", "if", "http_method", "!=", "\"get\"", ":", "warnings", ".", "warn", "(", "_", "(", "\"You are using methods other than get with no authentication!!!\"", ...
cde9a2ed856b81cac86386e8d87d901fa03d7b11
valid
write
Starts a new article
danube_delta/cli/write.py
def write(context): """Starts a new article""" config = context.obj title = click.prompt('Title') author = click.prompt('Author', default=config.get('DEFAULT_AUTHOR')) slug = slugify(title) creation_date = datetime.now() basename = '{:%Y-%m-%d}_{}.md'.format(creation_date, slug) meta ...
def write(context): """Starts a new article""" config = context.obj title = click.prompt('Title') author = click.prompt('Author', default=config.get('DEFAULT_AUTHOR')) slug = slugify(title) creation_date = datetime.now() basename = '{:%Y-%m-%d}_{}.md'.format(creation_date, slug) meta ...
[ "Starts", "a", "new", "article" ]
honzajavorek/danube-delta
python
https://github.com/honzajavorek/danube-delta/blob/d0a72f0704d52b888e7fb2b68c4fdc696d370018/danube_delta/cli/write.py#L12-L44
[ "def", "write", "(", "context", ")", ":", "config", "=", "context", ".", "obj", "title", "=", "click", ".", "prompt", "(", "'Title'", ")", "author", "=", "click", ".", "prompt", "(", "'Author'", ",", "default", "=", "config", ".", "get", "(", "'DEFAU...
d0a72f0704d52b888e7fb2b68c4fdc696d370018
valid
lint
Looks for errors in source code of your blog
danube_delta/cli/lint.py
def lint(context): """Looks for errors in source code of your blog""" config = context.obj try: run('flake8 {dir} --exclude={exclude}'.format( dir=config['CWD'], exclude=','.join(EXCLUDE), )) except SubprocessError: context.exit(1)
def lint(context): """Looks for errors in source code of your blog""" config = context.obj try: run('flake8 {dir} --exclude={exclude}'.format( dir=config['CWD'], exclude=','.join(EXCLUDE), )) except SubprocessError: context.exit(1)
[ "Looks", "for", "errors", "in", "source", "code", "of", "your", "blog" ]
honzajavorek/danube-delta
python
https://github.com/honzajavorek/danube-delta/blob/d0a72f0704d52b888e7fb2b68c4fdc696d370018/danube_delta/cli/lint.py#L14-L24
[ "def", "lint", "(", "context", ")", ":", "config", "=", "context", ".", "obj", "try", ":", "run", "(", "'flake8 {dir} --exclude={exclude}'", ".", "format", "(", "dir", "=", "config", "[", "'CWD'", "]", ",", "exclude", "=", "','", ".", "join", "(", "EXC...
d0a72f0704d52b888e7fb2b68c4fdc696d370018
valid
ResourceField.set_real_value_class
value_class is initially a string with the import path to the resource class, but we need to get the actual class before doing any work We do not expect the actual clas to be in value_class since the beginning to avoid nasty import egg-before-chicken errors
pyrestcli/fields.py
def set_real_value_class(self): """ value_class is initially a string with the import path to the resource class, but we need to get the actual class before doing any work We do not expect the actual clas to be in value_class since the beginning to avoid nasty import egg-before-chicken errors ...
def set_real_value_class(self): """ value_class is initially a string with the import path to the resource class, but we need to get the actual class before doing any work We do not expect the actual clas to be in value_class since the beginning to avoid nasty import egg-before-chicken errors ...
[ "value_class", "is", "initially", "a", "string", "with", "the", "import", "path", "to", "the", "resource", "class", "but", "we", "need", "to", "get", "the", "actual", "class", "before", "doing", "any", "work" ]
danicarrion/pyrestcli
python
https://github.com/danicarrion/pyrestcli/blob/cde9a2ed856b81cac86386e8d87d901fa03d7b11/pyrestcli/fields.py#L109-L119
[ "def", "set_real_value_class", "(", "self", ")", ":", "if", "self", ".", "value_class", "is", "not", "None", "and", "isinstance", "(", "self", ".", "value_class", ",", "str", ")", ":", "module_name", ",", "dot", ",", "class_name", "=", "self", ".", "valu...
cde9a2ed856b81cac86386e8d87d901fa03d7b11
valid
publish
Saves changes and sends them to GitHub
danube_delta/cli/publish.py
def publish(context): """Saves changes and sends them to GitHub""" header('Recording changes...') run('git add -A') header('Displaying changes...') run('git -c color.status=always status') if not click.confirm('\nContinue publishing'): run('git reset HEAD --') abort(context) ...
def publish(context): """Saves changes and sends them to GitHub""" header('Recording changes...') run('git add -A') header('Displaying changes...') run('git -c color.status=always status') if not click.confirm('\nContinue publishing'): run('git reset HEAD --') abort(context) ...
[ "Saves", "changes", "and", "sends", "them", "to", "GitHub" ]
honzajavorek/danube-delta
python
https://github.com/honzajavorek/danube-delta/blob/d0a72f0704d52b888e7fb2b68c4fdc696d370018/danube_delta/cli/publish.py#L13-L43
[ "def", "publish", "(", "context", ")", ":", "header", "(", "'Recording changes...'", ")", "run", "(", "'git add -A'", ")", "header", "(", "'Displaying changes...'", ")", "run", "(", "'git -c color.status=always status'", ")", "if", "not", "click", ".", "confirm", ...
d0a72f0704d52b888e7fb2b68c4fdc696d370018
valid
deploy
Uploads new version of the blog website
danube_delta/cli/deploy.py
def deploy(context): """Uploads new version of the blog website""" config = context.obj header('Generating HTML...') pelican(config, '--verbose', production=True) header('Removing unnecessary output...') unnecessary_paths = [ 'author', 'category', 'tag', 'feeds', 'tags.html', ...
def deploy(context): """Uploads new version of the blog website""" config = context.obj header('Generating HTML...') pelican(config, '--verbose', production=True) header('Removing unnecessary output...') unnecessary_paths = [ 'author', 'category', 'tag', 'feeds', 'tags.html', ...
[ "Uploads", "new", "version", "of", "the", "blog", "website" ]
honzajavorek/danube-delta
python
https://github.com/honzajavorek/danube-delta/blob/d0a72f0704d52b888e7fb2b68c4fdc696d370018/danube_delta/cli/deploy.py#L12-L51
[ "def", "deploy", "(", "context", ")", ":", "config", "=", "context", ".", "obj", "header", "(", "'Generating HTML...'", ")", "pelican", "(", "config", ",", "'--verbose'", ",", "production", "=", "True", ")", "header", "(", "'Removing unnecessary output...'", "...
d0a72f0704d52b888e7fb2b68c4fdc696d370018
valid
signed_number
Return the given number as a string with a sign in front of it, ie. `+` if the number is positive, `-` otherwise.
taxi_zebra/commands.py
def signed_number(number, precision=2): """ Return the given number as a string with a sign in front of it, ie. `+` if the number is positive, `-` otherwise. """ prefix = '' if number <= 0 else '+' number_str = '{}{:.{precision}f}'.format(prefix, number, precision=precision) return number_str
def signed_number(number, precision=2): """ Return the given number as a string with a sign in front of it, ie. `+` if the number is positive, `-` otherwise. """ prefix = '' if number <= 0 else '+' number_str = '{}{:.{precision}f}'.format(prefix, number, precision=precision) return number_str
[ "Return", "the", "given", "number", "as", "a", "string", "with", "a", "sign", "in", "front", "of", "it", "ie", ".", "+", "if", "the", "number", "is", "positive", "-", "otherwise", "." ]
sephii/taxi-zebra
python
https://github.com/sephii/taxi-zebra/blob/36affa22d4167e7ce5a8c7c6eaf5adc4cbfcfb5d/taxi_zebra/commands.py#L29-L36
[ "def", "signed_number", "(", "number", ",", "precision", "=", "2", ")", ":", "prefix", "=", "''", "if", "number", "<=", "0", "else", "'+'", "number_str", "=", "'{}{:.{precision}f}'", ".", "format", "(", "prefix", ",", "number", ",", "precision", "=", "pr...
36affa22d4167e7ce5a8c7c6eaf5adc4cbfcfb5d
valid
balance
Show Zebra balance. Like the hours balance, vacation left, etc.
taxi_zebra/commands.py
def balance(ctx): """ Show Zebra balance. Like the hours balance, vacation left, etc. """ backend = plugins_registry.get_backends_by_class(ZebraBackend)[0] timesheet_collection = get_timesheet_collection_for_context(ctx, None) hours_to_be_pushed = timesheet_collection.get_hours(pushed=Fals...
def balance(ctx): """ Show Zebra balance. Like the hours balance, vacation left, etc. """ backend = plugins_registry.get_backends_by_class(ZebraBackend)[0] timesheet_collection = get_timesheet_collection_for_context(ctx, None) hours_to_be_pushed = timesheet_collection.get_hours(pushed=Fals...
[ "Show", "Zebra", "balance", "." ]
sephii/taxi-zebra
python
https://github.com/sephii/taxi-zebra/blob/36affa22d4167e7ce5a8c7c6eaf5adc4cbfcfb5d/taxi_zebra/commands.py#L55-L79
[ "def", "balance", "(", "ctx", ")", ":", "backend", "=", "plugins_registry", ".", "get_backends_by_class", "(", "ZebraBackend", ")", "[", "0", "]", "timesheet_collection", "=", "get_timesheet_collection_for_context", "(", "ctx", ",", "None", ")", "hours_to_be_pushed"...
36affa22d4167e7ce5a8c7c6eaf5adc4cbfcfb5d
valid
to_zebra_params
Transforms the given `params` dict to values that are understood by Zebra (eg. False is represented as 'false')
taxi_zebra/backend.py
def to_zebra_params(params): """ Transforms the given `params` dict to values that are understood by Zebra (eg. False is represented as 'false') """ def to_zebra_value(value): transform_funcs = { bool: lambda v: 'true' if v else 'false', } return transform_funcs.get(...
def to_zebra_params(params): """ Transforms the given `params` dict to values that are understood by Zebra (eg. False is represented as 'false') """ def to_zebra_value(value): transform_funcs = { bool: lambda v: 'true' if v else 'false', } return transform_funcs.get(...
[ "Transforms", "the", "given", "params", "dict", "to", "values", "that", "are", "understood", "by", "Zebra", "(", "eg", ".", "False", "is", "represented", "as", "false", ")" ]
sephii/taxi-zebra
python
https://github.com/sephii/taxi-zebra/blob/36affa22d4167e7ce5a8c7c6eaf5adc4cbfcfb5d/taxi_zebra/backend.py#L49-L60
[ "def", "to_zebra_params", "(", "params", ")", ":", "def", "to_zebra_value", "(", "value", ")", ":", "transform_funcs", "=", "{", "bool", ":", "lambda", "v", ":", "'true'", "if", "v", "else", "'false'", ",", "}", "return", "transform_funcs", ".", "get", "...
36affa22d4167e7ce5a8c7c6eaf5adc4cbfcfb5d
valid
show_response_messages
Show all messages in the `messages` key of the given dict.
taxi_zebra/backend.py
def show_response_messages(response_json): """ Show all messages in the `messages` key of the given dict. """ message_type_kwargs = { 'warning': {'fg': 'yellow'}, 'error': {'fg': 'red'}, } for message in response_json.get('messages', []): click.secho(message['text'], **me...
def show_response_messages(response_json): """ Show all messages in the `messages` key of the given dict. """ message_type_kwargs = { 'warning': {'fg': 'yellow'}, 'error': {'fg': 'red'}, } for message in response_json.get('messages', []): click.secho(message['text'], **me...
[ "Show", "all", "messages", "in", "the", "messages", "key", "of", "the", "given", "dict", "." ]
sephii/taxi-zebra
python
https://github.com/sephii/taxi-zebra/blob/36affa22d4167e7ce5a8c7c6eaf5adc4cbfcfb5d/taxi_zebra/backend.py#L63-L72
[ "def", "show_response_messages", "(", "response_json", ")", ":", "message_type_kwargs", "=", "{", "'warning'", ":", "{", "'fg'", ":", "'yellow'", "}", ",", "'error'", ":", "{", "'fg'", ":", "'red'", "}", ",", "}", "for", "message", "in", "response_json", "...
36affa22d4167e7ce5a8c7c6eaf5adc4cbfcfb5d
valid
update_alias_mapping
Override `alias` mapping in the user configuration file with the given `new_mapping`, which should be a tuple with 2 or 3 elements (in the form `(project_id, activity_id, role_id)`).
taxi_zebra/backend.py
def update_alias_mapping(settings, alias, new_mapping): """ Override `alias` mapping in the user configuration file with the given `new_mapping`, which should be a tuple with 2 or 3 elements (in the form `(project_id, activity_id, role_id)`). """ mapping = aliases_database[alias] new_mapping = M...
def update_alias_mapping(settings, alias, new_mapping): """ Override `alias` mapping in the user configuration file with the given `new_mapping`, which should be a tuple with 2 or 3 elements (in the form `(project_id, activity_id, role_id)`). """ mapping = aliases_database[alias] new_mapping = M...
[ "Override", "alias", "mapping", "in", "the", "user", "configuration", "file", "with", "the", "given", "new_mapping", "which", "should", "be", "a", "tuple", "with", "2", "or", "3", "elements", "(", "in", "the", "form", "(", "project_id", "activity_id", "role_...
sephii/taxi-zebra
python
https://github.com/sephii/taxi-zebra/blob/36affa22d4167e7ce5a8c7c6eaf5adc4cbfcfb5d/taxi_zebra/backend.py#L139-L148
[ "def", "update_alias_mapping", "(", "settings", ",", "alias", ",", "new_mapping", ")", ":", "mapping", "=", "aliases_database", "[", "alias", "]", "new_mapping", "=", "Mapping", "(", "mapping", "=", "new_mapping", ",", "backend", "=", "mapping", ".", "backend"...
36affa22d4167e7ce5a8c7c6eaf5adc4cbfcfb5d
valid
photos
Adds images to the last article
danube_delta/cli/photos.py
def photos(context, path): """Adds images to the last article""" config = context.obj header('Looking for the latest article...') article_filename = find_last_article(config['CONTENT_DIR']) if not article_filename: return click.secho('No articles.', fg='red') click.echo(os.path.basenam...
def photos(context, path): """Adds images to the last article""" config = context.obj header('Looking for the latest article...') article_filename = find_last_article(config['CONTENT_DIR']) if not article_filename: return click.secho('No articles.', fg='red') click.echo(os.path.basenam...
[ "Adds", "images", "to", "the", "last", "article" ]
honzajavorek/danube-delta
python
https://github.com/honzajavorek/danube-delta/blob/d0a72f0704d52b888e7fb2b68c4fdc696d370018/danube_delta/cli/photos.py#L24-L67
[ "def", "photos", "(", "context", ",", "path", ")", ":", "config", "=", "context", ".", "obj", "header", "(", "'Looking for the latest article...'", ")", "article_filename", "=", "find_last_article", "(", "config", "[", "'CONTENT_DIR'", "]", ")", "if", "not", "...
d0a72f0704d52b888e7fb2b68c4fdc696d370018
valid
HashRing._generate_circle
Generates the circle.
src/hashring/hashring.py
def _generate_circle(self): """Generates the circle. """ total_weight = 0 for node in self.nodes: total_weight += self.weights.get(node, 1) for node in self.nodes: weight = 1 if node in self.weights: weight = self.weights.get(...
def _generate_circle(self): """Generates the circle. """ total_weight = 0 for node in self.nodes: total_weight += self.weights.get(node, 1) for node in self.nodes: weight = 1 if node in self.weights: weight = self.weights.get(...
[ "Generates", "the", "circle", "." ]
goller/hashring
python
https://github.com/goller/hashring/blob/9bee95074f7d853b6aa656968dfd359d02b3b710/src/hashring/hashring.py#L65-L88
[ "def", "_generate_circle", "(", "self", ")", ":", "total_weight", "=", "0", "for", "node", "in", "self", ".", "nodes", ":", "total_weight", "+=", "self", ".", "weights", ".", "get", "(", "node", ",", "1", ")", "for", "node", "in", "self", ".", "nodes...
9bee95074f7d853b6aa656968dfd359d02b3b710
valid
HashRing.get_node
Given a string key a corresponding node in the hash ring is returned. If the hash ring is empty, `None` is returned.
src/hashring/hashring.py
def get_node(self, string_key): """Given a string key a corresponding node in the hash ring is returned. If the hash ring is empty, `None` is returned. """ pos = self.get_node_pos(string_key) if pos is None: return None return self.ring[self._sorted_keys[pos]...
def get_node(self, string_key): """Given a string key a corresponding node in the hash ring is returned. If the hash ring is empty, `None` is returned. """ pos = self.get_node_pos(string_key) if pos is None: return None return self.ring[self._sorted_keys[pos]...
[ "Given", "a", "string", "key", "a", "corresponding", "node", "in", "the", "hash", "ring", "is", "returned", "." ]
goller/hashring
python
https://github.com/goller/hashring/blob/9bee95074f7d853b6aa656968dfd359d02b3b710/src/hashring/hashring.py#L90-L98
[ "def", "get_node", "(", "self", ",", "string_key", ")", ":", "pos", "=", "self", ".", "get_node_pos", "(", "string_key", ")", "if", "pos", "is", "None", ":", "return", "None", "return", "self", ".", "ring", "[", "self", ".", "_sorted_keys", "[", "pos",...
9bee95074f7d853b6aa656968dfd359d02b3b710
valid
HashRing.get_node_pos
Given a string key a corresponding node in the hash ring is returned along with it's position in the ring. If the hash ring is empty, (`None`, `None`) is returned.
src/hashring/hashring.py
def get_node_pos(self, string_key): """Given a string key a corresponding node in the hash ring is returned along with it's position in the ring. If the hash ring is empty, (`None`, `None`) is returned. """ if not self.ring: return None key = self.gen_key(st...
def get_node_pos(self, string_key): """Given a string key a corresponding node in the hash ring is returned along with it's position in the ring. If the hash ring is empty, (`None`, `None`) is returned. """ if not self.ring: return None key = self.gen_key(st...
[ "Given", "a", "string", "key", "a", "corresponding", "node", "in", "the", "hash", "ring", "is", "returned", "along", "with", "it", "s", "position", "in", "the", "ring", "." ]
goller/hashring
python
https://github.com/goller/hashring/blob/9bee95074f7d853b6aa656968dfd359d02b3b710/src/hashring/hashring.py#L100-L117
[ "def", "get_node_pos", "(", "self", ",", "string_key", ")", ":", "if", "not", "self", ".", "ring", ":", "return", "None", "key", "=", "self", ".", "gen_key", "(", "string_key", ")", "nodes", "=", "self", ".", "_sorted_keys", "pos", "=", "bisect", "(", ...
9bee95074f7d853b6aa656968dfd359d02b3b710
valid
HashRing.iterate_nodes
Given a string key it returns the nodes as a generator that can hold the key. The generator iterates one time through the ring starting at the correct position. if `distinct` is set, then the nodes returned will be unique, i.e. no virtual copies will be returned.
src/hashring/hashring.py
def iterate_nodes(self, string_key, distinct=True): """Given a string key it returns the nodes as a generator that can hold the key. The generator iterates one time through the ring starting at the correct position. if `distinct` is set, then the nodes returned will be unique, ...
def iterate_nodes(self, string_key, distinct=True): """Given a string key it returns the nodes as a generator that can hold the key. The generator iterates one time through the ring starting at the correct position. if `distinct` is set, then the nodes returned will be unique, ...
[ "Given", "a", "string", "key", "it", "returns", "the", "nodes", "as", "a", "generator", "that", "can", "hold", "the", "key", "." ]
goller/hashring
python
https://github.com/goller/hashring/blob/9bee95074f7d853b6aa656968dfd359d02b3b710/src/hashring/hashring.py#L119-L148
[ "def", "iterate_nodes", "(", "self", ",", "string_key", ",", "distinct", "=", "True", ")", ":", "if", "not", "self", ".", "ring", ":", "yield", "None", ",", "None", "returned_values", "=", "set", "(", ")", "def", "distinct_filter", "(", "value", ")", "...
9bee95074f7d853b6aa656968dfd359d02b3b710
valid
HashRing.gen_key
Given a string key it returns a long value, this long value represents a place on the hash ring. md5 is currently used because it mixes well.
src/hashring/hashring.py
def gen_key(self, key): """Given a string key it returns a long value, this long value represents a place on the hash ring. md5 is currently used because it mixes well. """ b_key = self._hash_digest(key) return self._hash_val(b_key, lambda x: x)
def gen_key(self, key): """Given a string key it returns a long value, this long value represents a place on the hash ring. md5 is currently used because it mixes well. """ b_key = self._hash_digest(key) return self._hash_val(b_key, lambda x: x)
[ "Given", "a", "string", "key", "it", "returns", "a", "long", "value", "this", "long", "value", "represents", "a", "place", "on", "the", "hash", "ring", "." ]
goller/hashring
python
https://github.com/goller/hashring/blob/9bee95074f7d853b6aa656968dfd359d02b3b710/src/hashring/hashring.py#L150-L157
[ "def", "gen_key", "(", "self", ",", "key", ")", ":", "b_key", "=", "self", ".", "_hash_digest", "(", "key", ")", "return", "self", ".", "_hash_val", "(", "b_key", ",", "lambda", "x", ":", "x", ")" ]
9bee95074f7d853b6aa656968dfd359d02b3b710
valid
get_number_of_app_ports
Get the number of ports for the given app JSON. This roughly follows the logic in marathon-lb for finding app IPs/ports, although we are only interested in the quantity of ports an app should have and don't consider the specific IPs/ports of individual tasks: https://github.com/mesosphere/marathon-lb/bl...
marathon_acme/marathon_util.py
def get_number_of_app_ports(app): """ Get the number of ports for the given app JSON. This roughly follows the logic in marathon-lb for finding app IPs/ports, although we are only interested in the quantity of ports an app should have and don't consider the specific IPs/ports of individual tasks: ...
def get_number_of_app_ports(app): """ Get the number of ports for the given app JSON. This roughly follows the logic in marathon-lb for finding app IPs/ports, although we are only interested in the quantity of ports an app should have and don't consider the specific IPs/ports of individual tasks: ...
[ "Get", "the", "number", "of", "ports", "for", "the", "given", "app", "JSON", ".", "This", "roughly", "follows", "the", "logic", "in", "marathon", "-", "lb", "for", "finding", "app", "IPs", "/", "ports", "although", "we", "are", "only", "interested", "in"...
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/marathon_util.py#L1-L31
[ "def", "get_number_of_app_ports", "(", "app", ")", ":", "mode", "=", "_get_networking_mode", "(", "app", ")", "ports_list", "=", "None", "if", "mode", "==", "'host'", ":", "ports_list", "=", "_get_port_definitions", "(", "app", ")", "elif", "mode", "==", "'c...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
_get_networking_mode
Get the Marathon networking mode for the app.
marathon_acme/marathon_util.py
def _get_networking_mode(app): """ Get the Marathon networking mode for the app. """ # Marathon 1.5+: there is a `networks` field networks = app.get('networks') if networks: # Modes cannot be mixed, so assigning the last mode is fine return networks[-1].get('mode', 'container') ...
def _get_networking_mode(app): """ Get the Marathon networking mode for the app. """ # Marathon 1.5+: there is a `networks` field networks = app.get('networks') if networks: # Modes cannot be mixed, so assigning the last mode is fine return networks[-1].get('mode', 'container') ...
[ "Get", "the", "Marathon", "networking", "mode", "for", "the", "app", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/marathon_util.py#L34-L53
[ "def", "_get_networking_mode", "(", "app", ")", ":", "# Marathon 1.5+: there is a `networks` field", "networks", "=", "app", ".", "get", "(", "'networks'", ")", "if", "networks", ":", "# Modes cannot be mixed, so assigning the last mode is fine", "return", "networks", "[", ...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
_get_container_port_mappings
Get the ``portMappings`` field for the app container.
marathon_acme/marathon_util.py
def _get_container_port_mappings(app): """ Get the ``portMappings`` field for the app container. """ container = app['container'] # Marathon 1.5+: container.portMappings field port_mappings = container.get('portMappings') # Older Marathon: container.docker.portMappings field if port_ma...
def _get_container_port_mappings(app): """ Get the ``portMappings`` field for the app container. """ container = app['container'] # Marathon 1.5+: container.portMappings field port_mappings = container.get('portMappings') # Older Marathon: container.docker.portMappings field if port_ma...
[ "Get", "the", "portMappings", "field", "for", "the", "app", "container", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/marathon_util.py#L56-L69
[ "def", "_get_container_port_mappings", "(", "app", ")", ":", "container", "=", "app", "[", "'container'", "]", "# Marathon 1.5+: container.portMappings field", "port_mappings", "=", "container", ".", "get", "(", "'portMappings'", ")", "# Older Marathon: container.docker.por...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
sort_pem_objects
Given a list of pem objects, sort the objects into the private key, leaf certificate, and list of CA certificates in the trust chain. This function assumes that the list of pem objects will contain exactly one private key and exactly one leaf certificate and that only key and certificate type objects ar...
marathon_acme/vault_store.py
def sort_pem_objects(pem_objects): """ Given a list of pem objects, sort the objects into the private key, leaf certificate, and list of CA certificates in the trust chain. This function assumes that the list of pem objects will contain exactly one private key and exactly one leaf certificate and th...
def sort_pem_objects(pem_objects): """ Given a list of pem objects, sort the objects into the private key, leaf certificate, and list of CA certificates in the trust chain. This function assumes that the list of pem objects will contain exactly one private key and exactly one leaf certificate and th...
[ "Given", "a", "list", "of", "pem", "objects", "sort", "the", "objects", "into", "the", "private", "key", "leaf", "certificate", "and", "list", "of", "CA", "certificates", "in", "the", "trust", "chain", ".", "This", "function", "assumes", "that", "the", "li...
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/vault_store.py#L20-L42
[ "def", "sort_pem_objects", "(", "pem_objects", ")", ":", "keys", ",", "certs", ",", "ca_certs", "=", "[", "]", ",", "[", "]", ",", "[", "]", "for", "pem_object", "in", "pem_objects", ":", "if", "isinstance", "(", "pem_object", ",", "pem", ".", "Key", ...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
_cert_data_to_pem_objects
Given a non-None response from the Vault key/value store, convert the key/values into a list of PEM objects.
marathon_acme/vault_store.py
def _cert_data_to_pem_objects(cert_data): """ Given a non-None response from the Vault key/value store, convert the key/values into a list of PEM objects. """ pem_objects = [] for key in ['privkey', 'cert', 'chain']: pem_objects.extend(pem.parse(cert_data[key].encode('utf-8'))) retu...
def _cert_data_to_pem_objects(cert_data): """ Given a non-None response from the Vault key/value store, convert the key/values into a list of PEM objects. """ pem_objects = [] for key in ['privkey', 'cert', 'chain']: pem_objects.extend(pem.parse(cert_data[key].encode('utf-8'))) retu...
[ "Given", "a", "non", "-", "None", "response", "from", "the", "Vault", "key", "/", "value", "store", "convert", "the", "key", "/", "values", "into", "a", "list", "of", "PEM", "objects", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/vault_store.py#L61-L70
[ "def", "_cert_data_to_pem_objects", "(", "cert_data", ")", ":", "pem_objects", "=", "[", "]", "for", "key", "in", "[", "'privkey'", ",", "'cert'", ",", "'chain'", "]", ":", "pem_objects", ".", "extend", "(", "pem", ".", "parse", "(", "cert_data", "[", "k...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
raise_for_not_ok_status
Raises a `requests.exceptions.HTTPError` if the response has a non-200 status code.
marathon_acme/clients/marathon.py
def raise_for_not_ok_status(response): """ Raises a `requests.exceptions.HTTPError` if the response has a non-200 status code. """ if response.code != OK: raise HTTPError('Non-200 response code (%s) for url: %s' % ( response.code, uridecode(response.request.absoluteURI))) re...
def raise_for_not_ok_status(response): """ Raises a `requests.exceptions.HTTPError` if the response has a non-200 status code. """ if response.code != OK: raise HTTPError('Non-200 response code (%s) for url: %s' % ( response.code, uridecode(response.request.absoluteURI))) re...
[ "Raises", "a", "requests", ".", "exceptions", ".", "HTTPError", "if", "the", "response", "has", "a", "non", "-", "200", "status", "code", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/marathon.py#L16-L25
[ "def", "raise_for_not_ok_status", "(", "response", ")", ":", "if", "response", ".", "code", "!=", "OK", ":", "raise", "HTTPError", "(", "'Non-200 response code (%s) for url: %s'", "%", "(", "response", ".", "code", ",", "uridecode", "(", "response", ".", "reques...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
_sse_content_with_protocol
Sometimes we need the protocol object so that we can manipulate the underlying transport in tests.
marathon_acme/clients/marathon.py
def _sse_content_with_protocol(response, handler, **sse_kwargs): """ Sometimes we need the protocol object so that we can manipulate the underlying transport in tests. """ protocol = SseProtocol(handler, **sse_kwargs) finished = protocol.when_finished() response.deliverBody(protocol) r...
def _sse_content_with_protocol(response, handler, **sse_kwargs): """ Sometimes we need the protocol object so that we can manipulate the underlying transport in tests. """ protocol = SseProtocol(handler, **sse_kwargs) finished = protocol.when_finished() response.deliverBody(protocol) r...
[ "Sometimes", "we", "need", "the", "protocol", "object", "so", "that", "we", "can", "manipulate", "the", "underlying", "transport", "in", "tests", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/marathon.py#L28-L38
[ "def", "_sse_content_with_protocol", "(", "response", ",", "handler", ",", "*", "*", "sse_kwargs", ")", ":", "protocol", "=", "SseProtocol", "(", "handler", ",", "*", "*", "sse_kwargs", ")", "finished", "=", "protocol", ".", "when_finished", "(", ")", "respo...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
sse_content
Callback to collect the Server-Sent Events content of a response. Callbacks passed will receive event data. :param response: The response from the SSE request. :param handler: The handler for the SSE protocol.
marathon_acme/clients/marathon.py
def sse_content(response, handler, **sse_kwargs): """ Callback to collect the Server-Sent Events content of a response. Callbacks passed will receive event data. :param response: The response from the SSE request. :param handler: The handler for the SSE protocol. """ # An SS...
def sse_content(response, handler, **sse_kwargs): """ Callback to collect the Server-Sent Events content of a response. Callbacks passed will receive event data. :param response: The response from the SSE request. :param handler: The handler for the SSE protocol. """ # An SS...
[ "Callback", "to", "collect", "the", "Server", "-", "Sent", "Events", "content", "of", "a", "response", ".", "Callbacks", "passed", "will", "receive", "event", "data", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/marathon.py#L41-L56
[ "def", "sse_content", "(", "response", ",", "handler", ",", "*", "*", "sse_kwargs", ")", ":", "# An SSE response must be 200/OK and have content-type 'text/event-stream'", "raise_for_not_ok_status", "(", "response", ")", "raise_for_header", "(", "response", ",", "'Content-T...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
MarathonClient._request
Recursively make requests to each endpoint in ``endpoints``.
marathon_acme/clients/marathon.py
def _request(self, failure, endpoints, *args, **kwargs): """ Recursively make requests to each endpoint in ``endpoints``. """ # We've run out of endpoints, fail if not endpoints: return failure endpoint = endpoints.pop(0) d = super(MarathonClient, sel...
def _request(self, failure, endpoints, *args, **kwargs): """ Recursively make requests to each endpoint in ``endpoints``. """ # We've run out of endpoints, fail if not endpoints: return failure endpoint = endpoints.pop(0) d = super(MarathonClient, sel...
[ "Recursively", "make", "requests", "to", "each", "endpoint", "in", "endpoints", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/marathon.py#L76-L90
[ "def", "_request", "(", "self", ",", "failure", ",", "endpoints", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# We've run out of endpoints, fail", "if", "not", "endpoints", ":", "return", "failure", "endpoint", "=", "endpoints", ".", "pop", "(", ...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
MarathonClient.get_json_field
Perform a GET request and get the contents of the JSON response. Marathon's JSON responses tend to contain an object with a single key which points to the actual data of the response. For example /v2/apps returns something like {"apps": [ {"app1"}, {"app2"} ]}. We're interested in the c...
marathon_acme/clients/marathon.py
def get_json_field(self, field, **kwargs): """ Perform a GET request and get the contents of the JSON response. Marathon's JSON responses tend to contain an object with a single key which points to the actual data of the response. For example /v2/apps returns something like {"ap...
def get_json_field(self, field, **kwargs): """ Perform a GET request and get the contents of the JSON response. Marathon's JSON responses tend to contain an object with a single key which points to the actual data of the response. For example /v2/apps returns something like {"ap...
[ "Perform", "a", "GET", "request", "and", "get", "the", "contents", "of", "the", "JSON", "response", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/marathon.py#L99-L118
[ "def", "get_json_field", "(", "self", ",", "field", ",", "*", "*", "kwargs", ")", ":", "d", "=", "self", ".", "request", "(", "'GET'", ",", "headers", "=", "{", "'Accept'", ":", "'application/json'", "}", ",", "*", "*", "kwargs", ")", "d", ".", "ad...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
MarathonClient._get_json_field
Get a JSON field from the response JSON. :param: response_json: The parsed JSON content of the response. :param: field_name: The name of the field in the JSON to get.
marathon_acme/clients/marathon.py
def _get_json_field(self, response_json, field_name): """ Get a JSON field from the response JSON. :param: response_json: The parsed JSON content of the response. :param: field_name: The name of the field in the JSON to get. """ if field_name not ...
def _get_json_field(self, response_json, field_name): """ Get a JSON field from the response JSON. :param: response_json: The parsed JSON content of the response. :param: field_name: The name of the field in the JSON to get. """ if field_name not ...
[ "Get", "a", "JSON", "field", "from", "the", "response", "JSON", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/marathon.py#L120-L134
[ "def", "_get_json_field", "(", "self", ",", "response_json", ",", "field_name", ")", ":", "if", "field_name", "not", "in", "response_json", ":", "raise", "KeyError", "(", "'Unable to get value for \"%s\" from Marathon '", "'response: \"%s\"'", "%", "(", "field_name", ...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
MarathonClient.get_events
Attach to Marathon's event stream using Server-Sent Events (SSE). :param callbacks: A dict mapping event types to functions that handle the event data
marathon_acme/clients/marathon.py
def get_events(self, callbacks): """ Attach to Marathon's event stream using Server-Sent Events (SSE). :param callbacks: A dict mapping event types to functions that handle the event data """ d = self.request( 'GET', path='/v2/events', unbuffered=True, ...
def get_events(self, callbacks): """ Attach to Marathon's event stream using Server-Sent Events (SSE). :param callbacks: A dict mapping event types to functions that handle the event data """ d = self.request( 'GET', path='/v2/events', unbuffered=True, ...
[ "Attach", "to", "Marathon", "s", "event", "stream", "using", "Server", "-", "Sent", "Events", "(", "SSE", ")", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/marathon.py#L143-L169
[ "def", "get_events", "(", "self", ",", "callbacks", ")", ":", "d", "=", "self", ".", "request", "(", "'GET'", ",", "path", "=", "'/v2/events'", ",", "unbuffered", "=", "True", ",", "# The event_type parameter was added in Marathon 1.3.7. It can be", "# used to speci...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
Config.parse
Parse value from string. Convert :code:`value` to .. code-block:: python >>> parser = Config() >>> parser.parse('12345', type_=int) <<< 12345 >>> >>> parser.parse('1,2,3,4', type_=list, subtype=int) <<< [1, 2, 3, 4] :param val...
twelvefactor.py
def parse( self, value: str, type_: typing.Type[typing.Any] = str, subtype: typing.Type[typing.Any] = str, ) -> typing.Any: """ Parse value from string. Convert :code:`value` to .. code-block:: python >>> parser = Config() >>> ...
def parse( self, value: str, type_: typing.Type[typing.Any] = str, subtype: typing.Type[typing.Any] = str, ) -> typing.Any: """ Parse value from string. Convert :code:`value` to .. code-block:: python >>> parser = Config() >>> ...
[ "Parse", "value", "from", "string", "." ]
artisanofcode/python-twelvefactor
python
https://github.com/artisanofcode/python-twelvefactor/blob/d6c921bb1d3f57d42ed9088d128af7a7dfabb579/twelvefactor.py#L101-L142
[ "def", "parse", "(", "self", ",", "value", ":", "str", ",", "type_", ":", "typing", ".", "Type", "[", "typing", ".", "Any", "]", "=", "str", ",", "subtype", ":", "typing", ".", "Type", "[", "typing", ".", "Any", "]", "=", "str", ",", ")", "->",...
d6c921bb1d3f57d42ed9088d128af7a7dfabb579
valid
Config.get
Parse a value from an environment variable. .. code-block:: python >>> os.environ['FOO'] <<< '12345' >>> >>> os.environ['BAR'] <<< '1,2,3,4' >>> >>> 'BAZ' in os.environ <<< False >>> >>> parser = Conf...
twelvefactor.py
def get( self, key: str, default: typing.Any = UNSET, type_: typing.Type[typing.Any] = str, subtype: typing.Type[typing.Any] = str, mapper: typing.Optional[typing.Callable[[object], object]] = None, ) -> typing.Any: """ Parse a value from an environmen...
def get( self, key: str, default: typing.Any = UNSET, type_: typing.Type[typing.Any] = str, subtype: typing.Type[typing.Any] = str, mapper: typing.Optional[typing.Callable[[object], object]] = None, ) -> typing.Any: """ Parse a value from an environmen...
[ "Parse", "a", "value", "from", "an", "environment", "variable", "." ]
artisanofcode/python-twelvefactor
python
https://github.com/artisanofcode/python-twelvefactor/blob/d6c921bb1d3f57d42ed9088d128af7a7dfabb579/twelvefactor.py#L144-L200
[ "def", "get", "(", "self", ",", "key", ":", "str", ",", "default", ":", "typing", ".", "Any", "=", "UNSET", ",", "type_", ":", "typing", ".", "Type", "[", "typing", ".", "Any", "]", "=", "str", ",", "subtype", ":", "typing", ".", "Type", "[", "...
d6c921bb1d3f57d42ed9088d128af7a7dfabb579
valid
MarathonLbClient._request
Perform a request to a specific endpoint. Raise an error if the status code indicates a client or server error.
marathon_acme/clients/marathon_lb.py
def _request(self, endpoint, *args, **kwargs): """ Perform a request to a specific endpoint. Raise an error if the status code indicates a client or server error. """ kwargs['url'] = endpoint return (super(MarathonLbClient, self).request(*args, **kwargs) ....
def _request(self, endpoint, *args, **kwargs): """ Perform a request to a specific endpoint. Raise an error if the status code indicates a client or server error. """ kwargs['url'] = endpoint return (super(MarathonLbClient, self).request(*args, **kwargs) ....
[ "Perform", "a", "request", "to", "a", "specific", "endpoint", ".", "Raise", "an", "error", "if", "the", "status", "code", "indicates", "a", "client", "or", "server", "error", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/marathon_lb.py#L29-L36
[ "def", "_request", "(", "self", ",", "endpoint", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'url'", "]", "=", "endpoint", "return", "(", "super", "(", "MarathonLbClient", ",", "self", ")", ".", "request", "(", "*", "args", ...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
MarathonLbClient._check_request_results
Check the result of each request that we made. If a failure occurred, but some requests succeeded, log and count the failures. If all requests failed, raise an error. :return: The list of responses, with a None value for any requests that failed.
marathon_acme/clients/marathon_lb.py
def _check_request_results(self, results): """ Check the result of each request that we made. If a failure occurred, but some requests succeeded, log and count the failures. If all requests failed, raise an error. :return: The list of responses, with a None value for...
def _check_request_results(self, results): """ Check the result of each request that we made. If a failure occurred, but some requests succeeded, log and count the failures. If all requests failed, raise an error. :return: The list of responses, with a None value for...
[ "Check", "the", "result", "of", "each", "request", "that", "we", "made", ".", "If", "a", "failure", "occurred", "but", "some", "requests", "succeeded", "log", "and", "count", "the", "failures", ".", "If", "all", "requests", "failed", "raise", "an", "error"...
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/marathon_lb.py#L38-L72
[ "def", "_check_request_results", "(", "self", ",", "results", ")", ":", "responses", "=", "[", "]", "failed_endpoints", "=", "[", "]", "for", "index", ",", "result_tuple", "in", "enumerate", "(", "results", ")", ":", "success", ",", "result", "=", "result_...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
maybe_key
Set up a client key if one does not exist already. https://gist.github.com/glyph/27867a478bb71d8b6046fbfb176e1a33#file-local-certs-py-L32-L50 :type pem_path: twisted.python.filepath.FilePath :param pem_path: The path to the certificate directory to use. :rtype: twisted.internet.defer.Deferred
marathon_acme/acme_util.py
def maybe_key(pem_path): """ Set up a client key if one does not exist already. https://gist.github.com/glyph/27867a478bb71d8b6046fbfb176e1a33#file-local-certs-py-L32-L50 :type pem_path: twisted.python.filepath.FilePath :param pem_path: The path to the certificate directory to use. :rt...
def maybe_key(pem_path): """ Set up a client key if one does not exist already. https://gist.github.com/glyph/27867a478bb71d8b6046fbfb176e1a33#file-local-certs-py-L32-L50 :type pem_path: twisted.python.filepath.FilePath :param pem_path: The path to the certificate directory to use. :rt...
[ "Set", "up", "a", "client", "key", "if", "one", "does", "not", "exist", "already", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/acme_util.py#L38-L55
[ "def", "maybe_key", "(", "pem_path", ")", ":", "acme_key_file", "=", "pem_path", ".", "child", "(", "u'client.key'", ")", "if", "acme_key_file", ".", "exists", "(", ")", ":", "key", "=", "_load_pem_private_key_bytes", "(", "acme_key_file", ".", "getContent", "...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
maybe_key_vault
Set up a client key in Vault if one does not exist already. :param client: The Vault API client to use. :param mount_path: The Vault key/value mount path to use. :rtype: twisted.internet.defer.Deferred
marathon_acme/acme_util.py
def maybe_key_vault(client, mount_path): """ Set up a client key in Vault if one does not exist already. :param client: The Vault API client to use. :param mount_path: The Vault key/value mount path to use. :rtype: twisted.internet.defer.Deferred """ d = client.read_kv2('cli...
def maybe_key_vault(client, mount_path): """ Set up a client key in Vault if one does not exist already. :param client: The Vault API client to use. :param mount_path: The Vault key/value mount path to use. :rtype: twisted.internet.defer.Deferred """ d = client.read_kv2('cli...
[ "Set", "up", "a", "client", "key", "in", "Vault", "if", "one", "does", "not", "exist", "already", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/acme_util.py#L58-L85
[ "def", "maybe_key_vault", "(", "client", ",", "mount_path", ")", ":", "d", "=", "client", ".", "read_kv2", "(", "'client_key'", ",", "mount_path", "=", "mount_path", ")", "def", "get_or_create_key", "(", "client_key", ")", ":", "if", "client_key", "is", "not...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
create_txacme_client_creator
Create a creator for txacme clients to provide to the txacme service. See ``txacme.client.Client.from_url()``. We create the underlying JWSClient with a non-persistent pool to avoid https://github.com/mithrandi/txacme/issues/86. :return: a callable that returns a deffered that returns the client
marathon_acme/acme_util.py
def create_txacme_client_creator(key, reactor, url, alg=RS256): """ Create a creator for txacme clients to provide to the txacme service. See ``txacme.client.Client.from_url()``. We create the underlying JWSClient with a non-persistent pool to avoid https://github.com/mithrandi/txacme/issues/86. ...
def create_txacme_client_creator(key, reactor, url, alg=RS256): """ Create a creator for txacme clients to provide to the txacme service. See ``txacme.client.Client.from_url()``. We create the underlying JWSClient with a non-persistent pool to avoid https://github.com/mithrandi/txacme/issues/86. ...
[ "Create", "a", "creator", "for", "txacme", "clients", "to", "provide", "to", "the", "txacme", "service", ".", "See", "txacme", ".", "client", ".", "Client", ".", "from_url", "()", ".", "We", "create", "the", "underlying", "JWSClient", "with", "a", "non", ...
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/acme_util.py#L88-L101
[ "def", "create_txacme_client_creator", "(", "key", ",", "reactor", ",", "url", ",", "alg", "=", "RS256", ")", ":", "# Creating an Agent without specifying a pool gives us the default pool", "# which is non-persistent.", "jws_client", "=", "JWSClient", "(", "HTTPClient", "("...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
generate_wildcard_pem_bytes
Generate a wildcard (subject name '*') self-signed certificate valid for 10 years. https://cryptography.io/en/latest/x509/tutorial/#creating-a-self-signed-certificate :return: Bytes representation of the PEM certificate data
marathon_acme/acme_util.py
def generate_wildcard_pem_bytes(): """ Generate a wildcard (subject name '*') self-signed certificate valid for 10 years. https://cryptography.io/en/latest/x509/tutorial/#creating-a-self-signed-certificate :return: Bytes representation of the PEM certificate data """ key = generate_private...
def generate_wildcard_pem_bytes(): """ Generate a wildcard (subject name '*') self-signed certificate valid for 10 years. https://cryptography.io/en/latest/x509/tutorial/#creating-a-self-signed-certificate :return: Bytes representation of the PEM certificate data """ key = generate_private...
[ "Generate", "a", "wildcard", "(", "subject", "name", "*", ")", "self", "-", "signed", "certificate", "valid", "for", "10", "years", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/acme_util.py#L104-L135
[ "def", "generate_wildcard_pem_bytes", "(", ")", ":", "key", "=", "generate_private_key", "(", "u'rsa'", ")", "name", "=", "x509", ".", "Name", "(", "[", "x509", ".", "NameAttribute", "(", "NameOID", ".", "COMMON_NAME", ",", "u'*'", ")", "]", ")", "cert", ...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
VaultClient.from_env
Create a Vault client with configuration from the environment. Supports a limited number of the available config options: https://www.vaultproject.io/docs/commands/index.html#environment-variables https://github.com/hashicorp/vault/blob/v0.11.3/api/client.go#L28-L40 Supported: -...
marathon_acme/clients/vault.py
def from_env(cls, reactor=None, env=os.environ): """ Create a Vault client with configuration from the environment. Supports a limited number of the available config options: https://www.vaultproject.io/docs/commands/index.html#environment-variables https://github.com/hashicorp/v...
def from_env(cls, reactor=None, env=os.environ): """ Create a Vault client with configuration from the environment. Supports a limited number of the available config options: https://www.vaultproject.io/docs/commands/index.html#environment-variables https://github.com/hashicorp/v...
[ "Create", "a", "Vault", "client", "with", "configuration", "from", "the", "environment", ".", "Supports", "a", "limited", "number", "of", "the", "available", "config", "options", ":", "https", ":", "//", "www", ".", "vaultproject", ".", "io", "/", "docs", ...
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/vault.py#L45-L83
[ "def", "from_env", "(", "cls", ",", "reactor", "=", "None", ",", "env", "=", "os", ".", "environ", ")", ":", "address", "=", "env", ".", "get", "(", "'VAULT_ADDR'", ",", "'https://127.0.0.1:8200'", ")", "# This seems to be what the Vault CLI defaults to", "token...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
VaultClient.read
Read data from Vault. Returns the JSON-decoded response.
marathon_acme/clients/vault.py
def read(self, path, **params): """ Read data from Vault. Returns the JSON-decoded response. """ d = self.request('GET', '/v1/' + path, params=params) return d.addCallback(self._handle_response)
def read(self, path, **params): """ Read data from Vault. Returns the JSON-decoded response. """ d = self.request('GET', '/v1/' + path, params=params) return d.addCallback(self._handle_response)
[ "Read", "data", "from", "Vault", ".", "Returns", "the", "JSON", "-", "decoded", "response", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/vault.py#L131-L136
[ "def", "read", "(", "self", ",", "path", ",", "*", "*", "params", ")", ":", "d", "=", "self", ".", "request", "(", "'GET'", ",", "'/v1/'", "+", "path", ",", "params", "=", "params", ")", "return", "d", ".", "addCallback", "(", "self", ".", "_hand...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
VaultClient.write
Write data to Vault. Returns the JSON-decoded response.
marathon_acme/clients/vault.py
def write(self, path, **data): """ Write data to Vault. Returns the JSON-decoded response. """ d = self.request('PUT', '/v1/' + path, json=data) return d.addCallback(self._handle_response, check_cas=True)
def write(self, path, **data): """ Write data to Vault. Returns the JSON-decoded response. """ d = self.request('PUT', '/v1/' + path, json=data) return d.addCallback(self._handle_response, check_cas=True)
[ "Write", "data", "to", "Vault", ".", "Returns", "the", "JSON", "-", "decoded", "response", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/vault.py#L138-L143
[ "def", "write", "(", "self", ",", "path", ",", "*", "*", "data", ")", ":", "d", "=", "self", ".", "request", "(", "'PUT'", ",", "'/v1/'", "+", "path", ",", "json", "=", "data", ")", "return", "d", ".", "addCallback", "(", "self", ".", "_handle_re...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
VaultClient.read_kv2
Read some data from a key/value version 2 secret engine.
marathon_acme/clients/vault.py
def read_kv2(self, path, version=None, mount_path='secret'): """ Read some data from a key/value version 2 secret engine. """ params = {} if version is not None: params['version'] = version read_path = '{}/data/{}'.format(mount_path, path) return self...
def read_kv2(self, path, version=None, mount_path='secret'): """ Read some data from a key/value version 2 secret engine. """ params = {} if version is not None: params['version'] = version read_path = '{}/data/{}'.format(mount_path, path) return self...
[ "Read", "some", "data", "from", "a", "key", "/", "value", "version", "2", "secret", "engine", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/vault.py#L145-L154
[ "def", "read_kv2", "(", "self", ",", "path", ",", "version", "=", "None", ",", "mount_path", "=", "'secret'", ")", ":", "params", "=", "{", "}", "if", "version", "is", "not", "None", ":", "params", "[", "'version'", "]", "=", "version", "read_path", ...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
VaultClient.create_or_update_kv2
Create or update some data in a key/value version 2 secret engine. :raises CasError: Raises an error if the ``cas`` value, when provided, doesn't match Vault's version for the key.
marathon_acme/clients/vault.py
def create_or_update_kv2(self, path, data, cas=None, mount_path='secret'): """ Create or update some data in a key/value version 2 secret engine. :raises CasError: Raises an error if the ``cas`` value, when provided, doesn't match Vault's version for the key. """...
def create_or_update_kv2(self, path, data, cas=None, mount_path='secret'): """ Create or update some data in a key/value version 2 secret engine. :raises CasError: Raises an error if the ``cas`` value, when provided, doesn't match Vault's version for the key. """...
[ "Create", "or", "update", "some", "data", "in", "a", "key", "/", "value", "version", "2", "secret", "engine", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/vault.py#L156-L172
[ "def", "create_or_update_kv2", "(", "self", ",", "path", ",", "data", ",", "cas", "=", "None", ",", "mount_path", "=", "'secret'", ")", ":", "params", "=", "{", "'options'", ":", "{", "}", ",", "'data'", ":", "data", "}", "if", "cas", "is", "not", ...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
get_single_header
Get a single value for the given key out of the given set of headers. :param twisted.web.http_headers.Headers headers: The set of headers in which to look for the header value :param str key: The header key
marathon_acme/clients/_base.py
def get_single_header(headers, key): """ Get a single value for the given key out of the given set of headers. :param twisted.web.http_headers.Headers headers: The set of headers in which to look for the header value :param str key: The header key """ raw_headers = headers.getRa...
def get_single_header(headers, key): """ Get a single value for the given key out of the given set of headers. :param twisted.web.http_headers.Headers headers: The set of headers in which to look for the header value :param str key: The header key """ raw_headers = headers.getRa...
[ "Get", "a", "single", "value", "for", "the", "given", "key", "out", "of", "the", "given", "set", "of", "headers", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/_base.py#L12-L27
[ "def", "get_single_header", "(", "headers", ",", "key", ")", ":", "raw_headers", "=", "headers", ".", "getRawHeaders", "(", "key", ")", "if", "raw_headers", "is", "None", ":", "return", "None", "# Take the final header as the authorative", "header", ",", "_", "=...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
raise_for_status
Raises a `requests.exceptions.HTTPError` if the response did not succeed. Adapted from the Requests library: https://github.com/kennethreitz/requests/blob/v2.8.1/requests/models.py#L825-L837
marathon_acme/clients/_base.py
def raise_for_status(response): """ Raises a `requests.exceptions.HTTPError` if the response did not succeed. Adapted from the Requests library: https://github.com/kennethreitz/requests/blob/v2.8.1/requests/models.py#L825-L837 """ http_error_msg = '' if 400 <= response.code < 500: h...
def raise_for_status(response): """ Raises a `requests.exceptions.HTTPError` if the response did not succeed. Adapted from the Requests library: https://github.com/kennethreitz/requests/blob/v2.8.1/requests/models.py#L825-L837 """ http_error_msg = '' if 400 <= response.code < 500: h...
[ "Raises", "a", "requests", ".", "exceptions", ".", "HTTPError", "if", "the", "response", "did", "not", "succeed", ".", "Adapted", "from", "the", "Requests", "library", ":", "https", ":", "//", "github", ".", "com", "/", "kennethreitz", "/", "requests", "/"...
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/_base.py#L30-L49
[ "def", "raise_for_status", "(", "response", ")", ":", "http_error_msg", "=", "''", "if", "400", "<=", "response", ".", "code", "<", "500", ":", "http_error_msg", "=", "'%s Client Error for url: %s'", "%", "(", "response", ".", "code", ",", "uridecode", "(", ...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
HTTPClient._compose_url
Compose a URL starting with the given URL (or self.url if that URL is None) and using the values in kwargs. :param str url: The base URL to use. If None, ``self.url`` will be used instead. :param dict kwargs: A dictionary of values to override in the base URL. Relevant k...
marathon_acme/clients/_base.py
def _compose_url(self, url, kwargs): """ Compose a URL starting with the given URL (or self.url if that URL is None) and using the values in kwargs. :param str url: The base URL to use. If None, ``self.url`` will be used instead. :param dict kwargs: A dic...
def _compose_url(self, url, kwargs): """ Compose a URL starting with the given URL (or self.url if that URL is None) and using the values in kwargs. :param str url: The base URL to use. If None, ``self.url`` will be used instead. :param dict kwargs: A dic...
[ "Compose", "a", "URL", "starting", "with", "the", "given", "URL", "(", "or", "self", ".", "url", "if", "that", "URL", "is", "None", ")", "and", "using", "the", "values", "in", "kwargs", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/_base.py#L91-L131
[ "def", "_compose_url", "(", "self", ",", "url", ",", "kwargs", ")", ":", "if", "url", "is", "None", ":", "url", "=", "self", ".", "url", "if", "url", "is", "None", ":", "raise", "ValueError", "(", "'url not provided and this client has no url attribute'", ")...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
HTTPClient.request
Perform a request. :param: method: The HTTP method to use (example is `GET`). :param: url: The URL to use. The default value is the URL this client was created with (`self.url`) (example is `http://localhost:8080`) :param: kwargs: Any other parame...
marathon_acme/clients/_base.py
def request(self, method, url=None, **kwargs): """ Perform a request. :param: method: The HTTP method to use (example is `GET`). :param: url: The URL to use. The default value is the URL this client was created with (`self.url`) (example is `http://lo...
def request(self, method, url=None, **kwargs): """ Perform a request. :param: method: The HTTP method to use (example is `GET`). :param: url: The URL to use. The default value is the URL this client was created with (`self.url`) (example is `http://lo...
[ "Perform", "a", "request", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/_base.py#L133-L156
[ "def", "request", "(", "self", ",", "method", ",", "url", "=", "None", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "_compose_url", "(", "url", ",", "kwargs", ")", "kwargs", ".", "setdefault", "(", "'timeout'", ",", "self", ".", "_ti...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
MarathonAcmeServer.listen
Run the server, i.e. start listening for requests on the given host and port. :param reactor: The ``IReactorTCP`` to use. :param endpoint_description: The Twisted description for the endpoint to listen on. :return: A deferred that returns an object that provides ...
marathon_acme/server.py
def listen(self, reactor, endpoint_description): """ Run the server, i.e. start listening for requests on the given host and port. :param reactor: The ``IReactorTCP`` to use. :param endpoint_description: The Twisted description for the endpoint to listen on. ...
def listen(self, reactor, endpoint_description): """ Run the server, i.e. start listening for requests on the given host and port. :param reactor: The ``IReactorTCP`` to use. :param endpoint_description: The Twisted description for the endpoint to listen on. ...
[ "Run", "the", "server", "i", ".", "e", ".", "start", "listening", "for", "requests", "on", "the", "given", "host", "and", "port", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/server.py#L30-L42
[ "def", "listen", "(", "self", ",", "reactor", ",", "endpoint_description", ")", ":", "endpoint", "=", "serverFromString", "(", "reactor", ",", "endpoint_description", ")", "return", "endpoint", ".", "listen", "(", "Site", "(", "self", ".", "app", ".", "resou...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
MarathonAcmeServer.health
Listens to incoming health checks from Marathon on ``/health``.
marathon_acme/server.py
def health(self, request): """ Listens to incoming health checks from Marathon on ``/health``. """ if self.health_handler is None: return self._no_health_handler(request) health = self.health_handler() response_code = OK if health.healthy else SERVICE_UNAVAILABLE req...
def health(self, request): """ Listens to incoming health checks from Marathon on ``/health``. """ if self.health_handler is None: return self._no_health_handler(request) health = self.health_handler() response_code = OK if health.healthy else SERVICE_UNAVAILABLE req...
[ "Listens", "to", "incoming", "health", "checks", "from", "Marathon", "on", "/", "health", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/server.py#L72-L80
[ "def", "health", "(", "self", ",", "request", ")", ":", "if", "self", ".", "health_handler", "is", "None", ":", "return", "self", ".", "_no_health_handler", "(", "request", ")", "health", "=", "self", ".", "health_handler", "(", ")", "response_code", "=", ...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
main
A tool to automatically request, renew and distribute Let's Encrypt certificates for apps running on Marathon and served by marathon-lb.
marathon_acme/cli.py
def main(reactor, argv=sys.argv[1:], env=os.environ, acme_url=LETSENCRYPT_DIRECTORY.asText()): """ A tool to automatically request, renew and distribute Let's Encrypt certificates for apps running on Marathon and served by marathon-lb. """ parser = argparse.ArgumentParser( descripti...
def main(reactor, argv=sys.argv[1:], env=os.environ, acme_url=LETSENCRYPT_DIRECTORY.asText()): """ A tool to automatically request, renew and distribute Let's Encrypt certificates for apps running on Marathon and served by marathon-lb. """ parser = argparse.ArgumentParser( descripti...
[ "A", "tool", "to", "automatically", "request", "renew", "and", "distribute", "Let", "s", "Encrypt", "certificates", "for", "apps", "running", "on", "Marathon", "and", "served", "by", "marathon", "-", "lb", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/cli.py#L30-L143
[ "def", "main", "(", "reactor", ",", "argv", "=", "sys", ".", "argv", "[", "1", ":", "]", ",", "env", "=", "os", ".", "environ", ",", "acme_url", "=", "LETSENCRYPT_DIRECTORY", ".", "asText", "(", ")", ")", ":", "parser", "=", "argparse", ".", "Argum...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
parse_listen_addr
Parse an address of the form [ipaddress]:port into a tcp or tcp6 Twisted endpoint description string for use with ``twisted.internet.endpoints.serverFromString``.
marathon_acme/cli.py
def parse_listen_addr(listen_addr): """ Parse an address of the form [ipaddress]:port into a tcp or tcp6 Twisted endpoint description string for use with ``twisted.internet.endpoints.serverFromString``. """ if ':' not in listen_addr: raise ValueError( "'%s' does not have the ...
def parse_listen_addr(listen_addr): """ Parse an address of the form [ipaddress]:port into a tcp or tcp6 Twisted endpoint description string for use with ``twisted.internet.endpoints.serverFromString``. """ if ':' not in listen_addr: raise ValueError( "'%s' does not have the ...
[ "Parse", "an", "address", "of", "the", "form", "[", "ipaddress", "]", ":", "port", "into", "a", "tcp", "or", "tcp6", "Twisted", "endpoint", "description", "string", "for", "use", "with", "twisted", ".", "internet", ".", "endpoints", ".", "serverFromString", ...
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/cli.py#L152-L183
[ "def", "parse_listen_addr", "(", "listen_addr", ")", ":", "if", "':'", "not", "in", "listen_addr", ":", "raise", "ValueError", "(", "\"'%s' does not have the correct form for a listen address: \"", "'[ipaddress]:port'", "%", "(", "listen_addr", ",", ")", ")", "host", ...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
create_marathon_acme
Create a marathon-acme instance. :param client_creator: The txacme client creator function. :param cert_store: The txacme certificate store instance. :param acme_email: Email address to use when registering with the ACME service. :param allow_multiple_certs: Whether to a...
marathon_acme/cli.py
def create_marathon_acme( client_creator, cert_store, acme_email, allow_multiple_certs, marathon_addrs, marathon_timeout, sse_timeout, mlb_addrs, group, reactor): """ Create a marathon-acme instance. :param client_creator: The txacme client creator function. :param cert_store: ...
def create_marathon_acme( client_creator, cert_store, acme_email, allow_multiple_certs, marathon_addrs, marathon_timeout, sse_timeout, mlb_addrs, group, reactor): """ Create a marathon-acme instance. :param client_creator: The txacme client creator function. :param cert_store: ...
[ "Create", "a", "marathon", "-", "acme", "instance", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/cli.py#L192-L238
[ "def", "create_marathon_acme", "(", "client_creator", ",", "cert_store", ",", "acme_email", ",", "allow_multiple_certs", ",", "marathon_addrs", ",", "marathon_timeout", ",", "sse_timeout", ",", "mlb_addrs", ",", "group", ",", "reactor", ")", ":", "marathon_client", ...
b1b71e3dde0ba30e575089280658bd32890e3325
valid
init_storage_dir
Initialise the storage directory with the certificates directory and a default wildcard self-signed certificate for HAProxy. :return: the storage path and certs path
marathon_acme/cli.py
def init_storage_dir(storage_dir): """ Initialise the storage directory with the certificates directory and a default wildcard self-signed certificate for HAProxy. :return: the storage path and certs path """ storage_path = FilePath(storage_dir) # Create the default wildcard certificate if...
def init_storage_dir(storage_dir): """ Initialise the storage directory with the certificates directory and a default wildcard self-signed certificate for HAProxy. :return: the storage path and certs path """ storage_path = FilePath(storage_dir) # Create the default wildcard certificate if...
[ "Initialise", "the", "storage", "directory", "with", "the", "certificates", "directory", "and", "a", "default", "wildcard", "self", "-", "signed", "certificate", "for", "HAProxy", "." ]
praekeltfoundation/marathon-acme
python
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/cli.py#L241-L268
[ "def", "init_storage_dir", "(", "storage_dir", ")", ":", "storage_path", "=", "FilePath", "(", "storage_dir", ")", "# Create the default wildcard certificate if it doesn't already exist", "default_cert_path", "=", "storage_path", ".", "child", "(", "'default.pem'", ")", "if...
b1b71e3dde0ba30e575089280658bd32890e3325