id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
51,500
mryellow/maze_explorer
mazeexp/engine/world_items.py
WorldItems.update_collisions
def update_collisions(self): """ Test player for collisions with items """ if not self.mode['items'] or len(self.mode['items']) == 0: return # update collman # FIXME: Why update each frame? self.collman.clear() for z, node in self.children: if...
python
def update_collisions(self): """ Test player for collisions with items """ if not self.mode['items'] or len(self.mode['items']) == 0: return # update collman # FIXME: Why update each frame? self.collman.clear() for z, node in self.children: if...
[ "def", "update_collisions", "(", "self", ")", ":", "if", "not", "self", ".", "mode", "[", "'items'", "]", "or", "len", "(", "self", ".", "mode", "[", "'items'", "]", ")", "==", "0", ":", "return", "# update collman", "# FIXME: Why update each frame?", "sel...
Test player for collisions with items
[ "Test", "player", "for", "collisions", "with", "items" ]
ab8a25ccd05105d2fe57e0213d690cfc07e45827
https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world_items.py#L116-L151
51,501
inveniosoftware/invenio-admin
invenio_admin/ext.py
_AdminState.register_view
def register_view(self, view_class, *args, **kwargs): """Register an admin view on this admin instance. :param view_class: The view class name passed to the view factory. :param args: Positional arugments for view class. :param kwargs: Keyword arguments to view class. """ ...
python
def register_view(self, view_class, *args, **kwargs): """Register an admin view on this admin instance. :param view_class: The view class name passed to the view factory. :param args: Positional arugments for view class. :param kwargs: Keyword arguments to view class. """ ...
[ "def", "register_view", "(", "self", ",", "view_class", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "protected_view_class", "=", "self", ".", "view_class_factory", "(", "view_class", ")", "if", "'endpoint'", "not", "in", "kwargs", ":", "kwargs", "...
Register an admin view on this admin instance. :param view_class: The view class name passed to the view factory. :param args: Positional arugments for view class. :param kwargs: Keyword arguments to view class.
[ "Register", "an", "admin", "view", "on", "this", "admin", "instance", "." ]
b5ff8f7de66d1d6b67efc9f81ff094eb2428f969
https://github.com/inveniosoftware/invenio-admin/blob/b5ff8f7de66d1d6b67efc9f81ff094eb2428f969/invenio_admin/ext.py#L41-L51
51,502
inveniosoftware/invenio-admin
invenio_admin/ext.py
_AdminState.load_entry_point_group
def load_entry_point_group(self, entry_point_group): """Load administration interface from entry point group. :param str entry_point_group: Name of the entry point group. """ for ep in pkg_resources.iter_entry_points(group=entry_point_group): admin_ep = dict(ep.load()) ...
python
def load_entry_point_group(self, entry_point_group): """Load administration interface from entry point group. :param str entry_point_group: Name of the entry point group. """ for ep in pkg_resources.iter_entry_points(group=entry_point_group): admin_ep = dict(ep.load()) ...
[ "def", "load_entry_point_group", "(", "self", ",", "entry_point_group", ")", ":", "for", "ep", "in", "pkg_resources", ".", "iter_entry_points", "(", "group", "=", "entry_point_group", ")", ":", "admin_ep", "=", "dict", "(", "ep", ".", "load", "(", ")", ")", ...
Load administration interface from entry point group. :param str entry_point_group: Name of the entry point group.
[ "Load", "administration", "interface", "from", "entry", "point", "group", "." ]
b5ff8f7de66d1d6b67efc9f81ff094eb2428f969
https://github.com/inveniosoftware/invenio-admin/blob/b5ff8f7de66d1d6b67efc9f81ff094eb2428f969/invenio_admin/ext.py#L53-L84
51,503
erinxocon/spotify-local
src/spotify_local/utils.py
get_url
def get_url(url): """Ranomdly generates a url for use in requests. Generates a hostname with the port and the provided suffix url provided :param url: A url fragment to use in the creation of the master url """ sub = "{0}.spotilocal.com".format("".join(choices(ascii_lowercase, k=10))) return "h...
python
def get_url(url): """Ranomdly generates a url for use in requests. Generates a hostname with the port and the provided suffix url provided :param url: A url fragment to use in the creation of the master url """ sub = "{0}.spotilocal.com".format("".join(choices(ascii_lowercase, k=10))) return "h...
[ "def", "get_url", "(", "url", ")", ":", "sub", "=", "\"{0}.spotilocal.com\"", ".", "format", "(", "\"\"", ".", "join", "(", "choices", "(", "ascii_lowercase", ",", "k", "=", "10", ")", ")", ")", "return", "\"http://{0}:{1}{2}\"", ".", "format", "(", "sub...
Ranomdly generates a url for use in requests. Generates a hostname with the port and the provided suffix url provided :param url: A url fragment to use in the creation of the master url
[ "Ranomdly", "generates", "a", "url", "for", "use", "in", "requests", ".", "Generates", "a", "hostname", "with", "the", "port", "and", "the", "provided", "suffix", "url", "provided" ]
8188eef221e3d8b9f408ff430d80e74560360459
https://github.com/erinxocon/spotify-local/blob/8188eef221e3d8b9f408ff430d80e74560360459/src/spotify_local/utils.py#L17-L24
51,504
erinxocon/spotify-local
src/spotify_local/utils.py
get_oauth_token
def get_oauth_token(): """Retrieve a simple OAuth Token for use with the local http client.""" url = "{0}/token".format(DEFAULT_ORIGIN["Origin"]) r = s.get(url=url) return r.json()["t"]
python
def get_oauth_token(): """Retrieve a simple OAuth Token for use with the local http client.""" url = "{0}/token".format(DEFAULT_ORIGIN["Origin"]) r = s.get(url=url) return r.json()["t"]
[ "def", "get_oauth_token", "(", ")", ":", "url", "=", "\"{0}/token\"", ".", "format", "(", "DEFAULT_ORIGIN", "[", "\"Origin\"", "]", ")", "r", "=", "s", ".", "get", "(", "url", "=", "url", ")", "return", "r", ".", "json", "(", ")", "[", "\"t\"", "]"...
Retrieve a simple OAuth Token for use with the local http client.
[ "Retrieve", "a", "simple", "OAuth", "Token", "for", "use", "with", "the", "local", "http", "client", "." ]
8188eef221e3d8b9f408ff430d80e74560360459
https://github.com/erinxocon/spotify-local/blob/8188eef221e3d8b9f408ff430d80e74560360459/src/spotify_local/utils.py#L27-L31
51,505
erinxocon/spotify-local
src/spotify_local/utils.py
get_csrf_token
def get_csrf_token(): """Retrieve a simple csrf token for to prevent cross site request forgery.""" url = get_url("/simplecsrf/token.json") r = s.get(url=url, headers=DEFAULT_ORIGIN) return r.json()["token"]
python
def get_csrf_token(): """Retrieve a simple csrf token for to prevent cross site request forgery.""" url = get_url("/simplecsrf/token.json") r = s.get(url=url, headers=DEFAULT_ORIGIN) return r.json()["token"]
[ "def", "get_csrf_token", "(", ")", ":", "url", "=", "get_url", "(", "\"/simplecsrf/token.json\"", ")", "r", "=", "s", ".", "get", "(", "url", "=", "url", ",", "headers", "=", "DEFAULT_ORIGIN", ")", "return", "r", ".", "json", "(", ")", "[", "\"token\""...
Retrieve a simple csrf token for to prevent cross site request forgery.
[ "Retrieve", "a", "simple", "csrf", "token", "for", "to", "prevent", "cross", "site", "request", "forgery", "." ]
8188eef221e3d8b9f408ff430d80e74560360459
https://github.com/erinxocon/spotify-local/blob/8188eef221e3d8b9f408ff430d80e74560360459/src/spotify_local/utils.py#L34-L38
51,506
inveniosoftware/invenio-admin
invenio_admin/views.py
protected_adminview_factory
def protected_adminview_factory(base_class): """Factory for creating protected admin view classes. The factory will ensure that the admin view will check if a user is authenticated and has the necessary permissions (as defined by the permission factory). The factory creates a new class using the pr...
python
def protected_adminview_factory(base_class): """Factory for creating protected admin view classes. The factory will ensure that the admin view will check if a user is authenticated and has the necessary permissions (as defined by the permission factory). The factory creates a new class using the pr...
[ "def", "protected_adminview_factory", "(", "base_class", ")", ":", "class", "ProtectedAdminView", "(", "base_class", ")", ":", "\"\"\"Admin view class protected by authentication.\"\"\"", "def", "_handle_view", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", "...
Factory for creating protected admin view classes. The factory will ensure that the admin view will check if a user is authenticated and has the necessary permissions (as defined by the permission factory). The factory creates a new class using the provided class as base class and overwrites ``is_a...
[ "Factory", "for", "creating", "protected", "admin", "view", "classes", "." ]
b5ff8f7de66d1d6b67efc9f81ff094eb2428f969
https://github.com/inveniosoftware/invenio-admin/blob/b5ff8f7de66d1d6b67efc9f81ff094eb2428f969/invenio_admin/views.py#L46-L100
51,507
inveniosoftware/invenio-oauth2server
invenio_oauth2server/views/settings.py
client_getter
def client_getter(): """Decorator to retrieve Client object and check user permission.""" def wrapper(f): @wraps(f) def decorated(*args, **kwargs): if 'client_id' not in kwargs: abort(500) client = Client.query.filter_by( client_id=kwargs....
python
def client_getter(): """Decorator to retrieve Client object and check user permission.""" def wrapper(f): @wraps(f) def decorated(*args, **kwargs): if 'client_id' not in kwargs: abort(500) client = Client.query.filter_by( client_id=kwargs....
[ "def", "client_getter", "(", ")", ":", "def", "wrapper", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "decorated", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'client_id'", "not", "in", "kwargs", ":", "abort", "(", "500...
Decorator to retrieve Client object and check user permission.
[ "Decorator", "to", "retrieve", "Client", "object", "and", "check", "user", "permission", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/views/settings.py#L40-L58
51,508
inveniosoftware/invenio-oauth2server
invenio_oauth2server/views/settings.py
token_getter
def token_getter(is_personal=True, is_internal=False): """Decorator to retrieve Token object and check user permission. :param is_personal: Search for a personal token. (Default: ``True``) :param is_internal: Search for a internal token. (Default: ``False``) """ def wrapper(f): @wraps(f) ...
python
def token_getter(is_personal=True, is_internal=False): """Decorator to retrieve Token object and check user permission. :param is_personal: Search for a personal token. (Default: ``True``) :param is_internal: Search for a internal token. (Default: ``False``) """ def wrapper(f): @wraps(f) ...
[ "def", "token_getter", "(", "is_personal", "=", "True", ",", "is_internal", "=", "False", ")", ":", "def", "wrapper", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "decorated", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", ...
Decorator to retrieve Token object and check user permission. :param is_personal: Search for a personal token. (Default: ``True``) :param is_internal: Search for a internal token. (Default: ``False``)
[ "Decorator", "to", "retrieve", "Token", "object", "and", "check", "user", "permission", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/views/settings.py#L61-L85
51,509
inveniosoftware/invenio-oauth2server
invenio_oauth2server/views/settings.py
index
def index(): """List user tokens.""" clients = Client.query.filter_by( user_id=current_user.get_id(), is_internal=False, ).all() tokens = Token.query.options(db.joinedload('client')).filter( Token.user_id == current_user.get_id(), Token.is_personal == True, # noqa ...
python
def index(): """List user tokens.""" clients = Client.query.filter_by( user_id=current_user.get_id(), is_internal=False, ).all() tokens = Token.query.options(db.joinedload('client')).filter( Token.user_id == current_user.get_id(), Token.is_personal == True, # noqa ...
[ "def", "index", "(", ")", ":", "clients", "=", "Client", ".", "query", ".", "filter_by", "(", "user_id", "=", "current_user", ".", "get_id", "(", ")", ",", "is_internal", "=", "False", ",", ")", ".", "all", "(", ")", "tokens", "=", "Token", ".", "q...
List user tokens.
[ "List", "user", "tokens", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/views/settings.py#L103-L129
51,510
inveniosoftware/invenio-oauth2server
invenio_oauth2server/views/settings.py
client_new
def client_new(): """Create new client.""" form = ClientForm(request.form) if form.validate_on_submit(): c = Client(user_id=current_user.get_id()) c.gen_salt() form.populate_obj(c) db.session.add(c) db.session.commit() return redirect(url_for('.client_view', ...
python
def client_new(): """Create new client.""" form = ClientForm(request.form) if form.validate_on_submit(): c = Client(user_id=current_user.get_id()) c.gen_salt() form.populate_obj(c) db.session.add(c) db.session.commit() return redirect(url_for('.client_view', ...
[ "def", "client_new", "(", ")", ":", "form", "=", "ClientForm", "(", "request", ".", "form", ")", "if", "form", ".", "validate_on_submit", "(", ")", ":", "c", "=", "Client", "(", "user_id", "=", "current_user", ".", "get_id", "(", ")", ")", "c", ".", ...
Create new client.
[ "Create", "new", "client", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/views/settings.py#L137-L152
51,511
inveniosoftware/invenio-oauth2server
invenio_oauth2server/views/settings.py
client_view
def client_view(client): """Show client's detail.""" if request.method == 'POST' and 'delete' in request.form: db.session.delete(client) db.session.commit() return redirect(url_for('.index')) form = ClientForm(request.form, obj=client) if form.validate_on_submit(): form....
python
def client_view(client): """Show client's detail.""" if request.method == 'POST' and 'delete' in request.form: db.session.delete(client) db.session.commit() return redirect(url_for('.index')) form = ClientForm(request.form, obj=client) if form.validate_on_submit(): form....
[ "def", "client_view", "(", "client", ")", ":", "if", "request", ".", "method", "==", "'POST'", "and", "'delete'", "in", "request", ".", "form", ":", "db", ".", "session", ".", "delete", "(", "client", ")", "db", ".", "session", ".", "commit", "(", ")...
Show client's detail.
[ "Show", "client", "s", "detail", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/views/settings.py#L161-L177
51,512
inveniosoftware/invenio-oauth2server
invenio_oauth2server/views/settings.py
client_reset
def client_reset(client): """Reset client's secret.""" if request.form.get('reset') == 'yes': client.reset_client_secret() db.session.commit() return redirect(url_for('.client_view', client_id=client.client_id))
python
def client_reset(client): """Reset client's secret.""" if request.form.get('reset') == 'yes': client.reset_client_secret() db.session.commit() return redirect(url_for('.client_view', client_id=client.client_id))
[ "def", "client_reset", "(", "client", ")", ":", "if", "request", ".", "form", ".", "get", "(", "'reset'", ")", "==", "'yes'", ":", "client", ".", "reset_client_secret", "(", ")", "db", ".", "session", ".", "commit", "(", ")", "return", "redirect", "(",...
Reset client's secret.
[ "Reset", "client", "s", "secret", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/views/settings.py#L183-L188
51,513
inveniosoftware/invenio-oauth2server
invenio_oauth2server/views/settings.py
token_new
def token_new(): """Create new token.""" form = TokenForm(request.form) form.scopes.choices = current_oauth2server.scope_choices() if form.validate_on_submit(): t = Token.create_personal( form.data['name'], current_user.get_id(), scopes=form.scopes.data ) db.session....
python
def token_new(): """Create new token.""" form = TokenForm(request.form) form.scopes.choices = current_oauth2server.scope_choices() if form.validate_on_submit(): t = Token.create_personal( form.data['name'], current_user.get_id(), scopes=form.scopes.data ) db.session....
[ "def", "token_new", "(", ")", ":", "form", "=", "TokenForm", "(", "request", ".", "form", ")", "form", ".", "scopes", ".", "choices", "=", "current_oauth2server", ".", "scope_choices", "(", ")", "if", "form", ".", "validate_on_submit", "(", ")", ":", "t"...
Create new token.
[ "Create", "new", "token", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/views/settings.py#L199-L218
51,514
inveniosoftware/invenio-oauth2server
invenio_oauth2server/views/settings.py
token_view
def token_view(token): """Show token details.""" if request.method == "POST" and 'delete' in request.form: db.session.delete(token) db.session.commit() return redirect(url_for('.index')) show_token = session.pop('show_personal_access_token', False) form = TokenForm(request.form...
python
def token_view(token): """Show token details.""" if request.method == "POST" and 'delete' in request.form: db.session.delete(token) db.session.commit() return redirect(url_for('.index')) show_token = session.pop('show_personal_access_token', False) form = TokenForm(request.form...
[ "def", "token_view", "(", "token", ")", ":", "if", "request", ".", "method", "==", "\"POST\"", "and", "'delete'", "in", "request", ".", "form", ":", "db", ".", "session", ".", "delete", "(", "token", ")", "db", ".", "session", ".", "commit", "(", ")"...
Show token details.
[ "Show", "token", "details", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/views/settings.py#L227-L252
51,515
inveniosoftware/invenio-oauth2server
invenio_oauth2server/views/settings.py
token_revoke
def token_revoke(token): """Revoke Authorized Application token.""" db.session.delete(token) db.session.commit() return redirect(url_for('.index'))
python
def token_revoke(token): """Revoke Authorized Application token.""" db.session.delete(token) db.session.commit() return redirect(url_for('.index'))
[ "def", "token_revoke", "(", "token", ")", ":", "db", ".", "session", ".", "delete", "(", "token", ")", "db", ".", "session", ".", "commit", "(", ")", "return", "redirect", "(", "url_for", "(", "'.index'", ")", ")" ]
Revoke Authorized Application token.
[ "Revoke", "Authorized", "Application", "token", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/views/settings.py#L258-L262
51,516
inveniosoftware/invenio-oauth2server
invenio_oauth2server/views/settings.py
token_permission_view
def token_permission_view(token): """Show permission garanted to authorized application token.""" scopes = [current_oauth2server.scopes[x] for x in token.scopes] return render_template( "invenio_oauth2server/settings/token_permission_view.html", token=token, scopes=scopes, )
python
def token_permission_view(token): """Show permission garanted to authorized application token.""" scopes = [current_oauth2server.scopes[x] for x in token.scopes] return render_template( "invenio_oauth2server/settings/token_permission_view.html", token=token, scopes=scopes, )
[ "def", "token_permission_view", "(", "token", ")", ":", "scopes", "=", "[", "current_oauth2server", ".", "scopes", "[", "x", "]", "for", "x", "in", "token", ".", "scopes", "]", "return", "render_template", "(", "\"invenio_oauth2server/settings/token_permission_view....
Show permission garanted to authorized application token.
[ "Show", "permission", "garanted", "to", "authorized", "application", "token", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/views/settings.py#L268-L275
51,517
lucuma/Clay
clay/markdown_ext/md_delinsmark.py
DelInsMarkExtension.extendMarkdown
def extendMarkdown(self, md, md_globals): """Modifies inline patterns.""" md.inlinePatterns.add('del', SimpleTagPattern(DEL_RE, 'del'), '<not_strong') md.inlinePatterns.add('ins', SimpleTagPattern(INS_RE, 'ins'), '<not_strong') md.inlinePatterns.add('mark', SimpleTagPattern(MARK_RE, 'mar...
python
def extendMarkdown(self, md, md_globals): """Modifies inline patterns.""" md.inlinePatterns.add('del', SimpleTagPattern(DEL_RE, 'del'), '<not_strong') md.inlinePatterns.add('ins', SimpleTagPattern(INS_RE, 'ins'), '<not_strong') md.inlinePatterns.add('mark', SimpleTagPattern(MARK_RE, 'mar...
[ "def", "extendMarkdown", "(", "self", ",", "md", ",", "md_globals", ")", ":", "md", ".", "inlinePatterns", ".", "add", "(", "'del'", ",", "SimpleTagPattern", "(", "DEL_RE", ",", "'del'", ")", ",", "'<not_strong'", ")", "md", ".", "inlinePatterns", ".", "...
Modifies inline patterns.
[ "Modifies", "inline", "patterns", "." ]
620d37086b712bdc4d13930ced43a5b7c9a5f46d
https://github.com/lucuma/Clay/blob/620d37086b712bdc4d13930ced43a5b7c9a5f46d/clay/markdown_ext/md_delinsmark.py#L32-L36
51,518
resync/resync
resync/client_state.py
ClientState.set_state
def set_state(self, site, timestamp=None): """Write status dict to client status file. FIXME - should have some file lock to avoid race """ parser = ConfigParser() parser.read(self.status_file) status_section = 'incremental' if (not parser.has_section(status_sect...
python
def set_state(self, site, timestamp=None): """Write status dict to client status file. FIXME - should have some file lock to avoid race """ parser = ConfigParser() parser.read(self.status_file) status_section = 'incremental' if (not parser.has_section(status_sect...
[ "def", "set_state", "(", "self", ",", "site", ",", "timestamp", "=", "None", ")", ":", "parser", "=", "ConfigParser", "(", ")", "parser", ".", "read", "(", "self", ".", "status_file", ")", "status_section", "=", "'incremental'", "if", "(", "not", "parser...
Write status dict to client status file. FIXME - should have some file lock to avoid race
[ "Write", "status", "dict", "to", "client", "status", "file", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client_state.py#L28-L49
51,519
resync/resync
resync/client_state.py
ClientState.get_state
def get_state(self, site): """Read client status file and return dict.""" parser = ConfigParser() status_section = 'incremental' parser.read(self.status_file) timestamp = None try: timestamp = float( parser.get( status_secti...
python
def get_state(self, site): """Read client status file and return dict.""" parser = ConfigParser() status_section = 'incremental' parser.read(self.status_file) timestamp = None try: timestamp = float( parser.get( status_secti...
[ "def", "get_state", "(", "self", ",", "site", ")", ":", "parser", "=", "ConfigParser", "(", ")", "status_section", "=", "'incremental'", "parser", ".", "read", "(", "self", ".", "status_file", ")", "timestamp", "=", "None", "try", ":", "timestamp", "=", ...
Read client status file and return dict.
[ "Read", "client", "status", "file", "and", "return", "dict", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client_state.py#L51-L66
51,520
pappasam/latexbuild
latexbuild/latex_parse.py
escape_latex_str_if_str
def escape_latex_str_if_str(value): '''Escape a latex string''' if not isinstance(value, str): return value for regex, replace_text in REGEX_ESCAPE_CHARS: value = re.sub(regex, replace_text, value) value = re.sub(REGEX_BACKSLASH, r'\\\\', value) return value
python
def escape_latex_str_if_str(value): '''Escape a latex string''' if not isinstance(value, str): return value for regex, replace_text in REGEX_ESCAPE_CHARS: value = re.sub(regex, replace_text, value) value = re.sub(REGEX_BACKSLASH, r'\\\\', value) return value
[ "def", "escape_latex_str_if_str", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "str", ")", ":", "return", "value", "for", "regex", ",", "replace_text", "in", "REGEX_ESCAPE_CHARS", ":", "value", "=", "re", ".", "sub", "(", "regex", ...
Escape a latex string
[ "Escape", "a", "latex", "string" ]
596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5
https://github.com/pappasam/latexbuild/blob/596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5/latexbuild/latex_parse.py#L44-L51
51,521
resync/resync
resync/sitemap.py
Sitemap.resources_as_xml
def resources_as_xml(self, resources, sitemapindex=False, fh=None): """Write or return XML for a set of resources in sitemap format. Arguments: - resources - either an iterable or iterator of Resource objects; if there an md attribute this will go to <rs:md> ...
python
def resources_as_xml(self, resources, sitemapindex=False, fh=None): """Write or return XML for a set of resources in sitemap format. Arguments: - resources - either an iterable or iterator of Resource objects; if there an md attribute this will go to <rs:md> ...
[ "def", "resources_as_xml", "(", "self", ",", "resources", ",", "sitemapindex", "=", "False", ",", "fh", "=", "None", ")", ":", "# element names depending on sitemapindex or not", "root_element", "=", "(", "'sitemapindex'", "if", "(", "sitemapindex", ")", "else", "...
Write or return XML for a set of resources in sitemap format. Arguments: - resources - either an iterable or iterator of Resource objects; if there an md attribute this will go to <rs:md> if there an ln attribute this will go to <rs:ln> - sitemapindex...
[ "Write", "or", "return", "XML", "for", "a", "set", "of", "resources", "in", "sitemap", "format", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/sitemap.py#L85-L138
51,522
resync/resync
resync/sitemap.py
Sitemap.parse_xml
def parse_xml(self, fh=None, etree=None, resources=None, capability=None, sitemapindex=None): """Parse XML Sitemap and add to resources object. Reads from fh or etree and adds resources to a resorces object (which must support the add method). Returns the resources object. ...
python
def parse_xml(self, fh=None, etree=None, resources=None, capability=None, sitemapindex=None): """Parse XML Sitemap and add to resources object. Reads from fh or etree and adds resources to a resorces object (which must support the add method). Returns the resources object. ...
[ "def", "parse_xml", "(", "self", ",", "fh", "=", "None", ",", "etree", "=", "None", ",", "resources", "=", "None", ",", "capability", "=", "None", ",", "sitemapindex", "=", "None", ")", ":", "if", "(", "resources", "is", "None", ")", ":", "resources"...
Parse XML Sitemap and add to resources object. Reads from fh or etree and adds resources to a resorces object (which must support the add method). Returns the resources object. Also sets self.resources_created to be the number of resources created. We adopt a very lax approach here. Th...
[ "Parse", "XML", "Sitemap", "and", "add", "to", "resources", "object", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/sitemap.py#L142-L243
51,523
resync/resync
resync/sitemap.py
Sitemap.resource_etree_element
def resource_etree_element(self, resource, element_name='url'): """Return xml.etree.ElementTree.Element representing the resource. Returns and element for the specified resource, of the form <url> with enclosed properties that are based on the sitemap with extensions for ResourceSync. ...
python
def resource_etree_element(self, resource, element_name='url'): """Return xml.etree.ElementTree.Element representing the resource. Returns and element for the specified resource, of the form <url> with enclosed properties that are based on the sitemap with extensions for ResourceSync. ...
[ "def", "resource_etree_element", "(", "self", ",", "resource", ",", "element_name", "=", "'url'", ")", ":", "e", "=", "Element", "(", "element_name", ")", "sub", "=", "Element", "(", "'loc'", ")", "sub", ".", "text", "=", "resource", ".", "uri", "e", "...
Return xml.etree.ElementTree.Element representing the resource. Returns and element for the specified resource, of the form <url> with enclosed properties that are based on the sitemap with extensions for ResourceSync.
[ "Return", "xml", ".", "etree", ".", "ElementTree", ".", "Element", "representing", "the", "resource", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/sitemap.py#L247-L279
51,524
resync/resync
resync/sitemap.py
Sitemap.resource_as_xml
def resource_as_xml(self, resource): """Return string for the resource as part of an XML sitemap. Returns a string with the XML snippet representing the resource, without any XML declaration. """ e = self.resource_etree_element(resource) if (sys.version_info >= (3, 0)): ...
python
def resource_as_xml(self, resource): """Return string for the resource as part of an XML sitemap. Returns a string with the XML snippet representing the resource, without any XML declaration. """ e = self.resource_etree_element(resource) if (sys.version_info >= (3, 0)): ...
[ "def", "resource_as_xml", "(", "self", ",", "resource", ")", ":", "e", "=", "self", ".", "resource_etree_element", "(", "resource", ")", "if", "(", "sys", ".", "version_info", ">=", "(", "3", ",", "0", ")", ")", ":", "# python3.x", "return", "(", "tost...
Return string for the resource as part of an XML sitemap. Returns a string with the XML snippet representing the resource, without any XML declaration.
[ "Return", "string", "for", "the", "resource", "as", "part", "of", "an", "XML", "sitemap", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/sitemap.py#L281-L297
51,525
resync/resync
resync/sitemap.py
Sitemap.resource_from_etree
def resource_from_etree(self, etree, resource_class): """Construct a Resource from an etree. Parameters: etree - the etree to parse resource_class - class of Resource object to create The parsing is properly namespace aware but we search just for the elements wanted a...
python
def resource_from_etree(self, etree, resource_class): """Construct a Resource from an etree. Parameters: etree - the etree to parse resource_class - class of Resource object to create The parsing is properly namespace aware but we search just for the elements wanted a...
[ "def", "resource_from_etree", "(", "self", ",", "etree", ",", "resource_class", ")", ":", "loc_elements", "=", "etree", ".", "findall", "(", "'{'", "+", "SITEMAP_NS", "+", "\"}loc\"", ")", "if", "(", "len", "(", "loc_elements", ")", ">", "1", ")", ":", ...
Construct a Resource from an etree. Parameters: etree - the etree to parse resource_class - class of Resource object to create The parsing is properly namespace aware but we search just for the elements wanted and leave everything else alone. Will raise an error if th...
[ "Construct", "a", "Resource", "from", "an", "etree", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/sitemap.py#L299-L361
51,526
resync/resync
resync/sitemap.py
Sitemap.add_element_with_atts_to_etree
def add_element_with_atts_to_etree(self, etree, name, atts): """Add element with name and atts to etree iff there are any atts. Parameters: etree - an etree object name - XML element name atts - dicts of attribute values. Attribute names are transformed """...
python
def add_element_with_atts_to_etree(self, etree, name, atts): """Add element with name and atts to etree iff there are any atts. Parameters: etree - an etree object name - XML element name atts - dicts of attribute values. Attribute names are transformed """...
[ "def", "add_element_with_atts_to_etree", "(", "self", ",", "etree", ",", "name", ",", "atts", ")", ":", "xml_atts", "=", "{", "}", "for", "att", "in", "atts", ".", "keys", "(", ")", ":", "val", "=", "atts", "[", "att", "]", "if", "(", "val", "is", ...
Add element with name and atts to etree iff there are any atts. Parameters: etree - an etree object name - XML element name atts - dicts of attribute values. Attribute names are transformed
[ "Add", "element", "with", "name", "and", "atts", "to", "etree", "iff", "there", "are", "any", "atts", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/sitemap.py#L449-L466
51,527
resync/resync
resync/mapper.py
Mapper.dst_to_src
def dst_to_src(self, dst_file): """Map destination path to source URI.""" for map in self.mappings: src_uri = map.dst_to_src(dst_file) if (src_uri is not None): return(src_uri) # Must have failed if loop exited raise MapperError( "Unabl...
python
def dst_to_src(self, dst_file): """Map destination path to source URI.""" for map in self.mappings: src_uri = map.dst_to_src(dst_file) if (src_uri is not None): return(src_uri) # Must have failed if loop exited raise MapperError( "Unabl...
[ "def", "dst_to_src", "(", "self", ",", "dst_file", ")", ":", "for", "map", "in", "self", ".", "mappings", ":", "src_uri", "=", "map", ".", "dst_to_src", "(", "dst_file", ")", "if", "(", "src_uri", "is", "not", "None", ")", ":", "return", "(", "src_ur...
Map destination path to source URI.
[ "Map", "destination", "path", "to", "source", "URI", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/mapper.py#L100-L109
51,528
resync/resync
resync/mapper.py
Mapper.src_to_dst
def src_to_dst(self, src_uri): """Map source URI to destination path.""" for map in self.mappings: dst_path = map.src_to_dst(src_uri) if (dst_path is not None): return(dst_path) # Must have failed if loop exited raise MapperError( "Unab...
python
def src_to_dst(self, src_uri): """Map source URI to destination path.""" for map in self.mappings: dst_path = map.src_to_dst(src_uri) if (dst_path is not None): return(dst_path) # Must have failed if loop exited raise MapperError( "Unab...
[ "def", "src_to_dst", "(", "self", ",", "src_uri", ")", ":", "for", "map", "in", "self", ".", "mappings", ":", "dst_path", "=", "map", ".", "src_to_dst", "(", "src_uri", ")", "if", "(", "dst_path", "is", "not", "None", ")", ":", "return", "(", "dst_pa...
Map source URI to destination path.
[ "Map", "source", "URI", "to", "destination", "path", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/mapper.py#L111-L120
51,529
resync/resync
resync/mapper.py
Mapper.path_from_uri
def path_from_uri(self, uri): """Make a safe path name from uri. In the case that uri is already a local path then the same path is returned. """ (scheme, netloc, path, params, query, frag) = urlparse(uri) if (netloc == ''): return(uri) path = '/'.joi...
python
def path_from_uri(self, uri): """Make a safe path name from uri. In the case that uri is already a local path then the same path is returned. """ (scheme, netloc, path, params, query, frag) = urlparse(uri) if (netloc == ''): return(uri) path = '/'.joi...
[ "def", "path_from_uri", "(", "self", ",", "uri", ")", ":", "(", "scheme", ",", "netloc", ",", "path", ",", "params", ",", "query", ",", "frag", ")", "=", "urlparse", "(", "uri", ")", "if", "(", "netloc", "==", "''", ")", ":", "return", "(", "uri"...
Make a safe path name from uri. In the case that uri is already a local path then the same path is returned.
[ "Make", "a", "safe", "path", "name", "from", "uri", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/mapper.py#L122-L136
51,530
resync/resync
resync/mapper.py
Map.strip_trailing_slashes
def strip_trailing_slashes(self, path): """Return input path minus any trailing slashes.""" m = re.match(r"(.*)/+$", path) if (m is None): return(path) return(m.group(1))
python
def strip_trailing_slashes(self, path): """Return input path minus any trailing slashes.""" m = re.match(r"(.*)/+$", path) if (m is None): return(path) return(m.group(1))
[ "def", "strip_trailing_slashes", "(", "self", ",", "path", ")", ":", "m", "=", "re", ".", "match", "(", "r\"(.*)/+$\"", ",", "path", ")", "if", "(", "m", "is", "None", ")", ":", "return", "(", "path", ")", "return", "(", "m", ".", "group", "(", "...
Return input path minus any trailing slashes.
[ "Return", "input", "path", "minus", "any", "trailing", "slashes", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/mapper.py#L163-L168
51,531
resync/resync
resync/mapper.py
Map.dst_to_src
def dst_to_src(self, dst_file): """Return the src URI from the dst filepath. This does not rely on the destination filepath actually existing on the local filesystem, just on pattern matching. Return source URI on success, None on failure. """ m = re.match(self.dst_path ...
python
def dst_to_src(self, dst_file): """Return the src URI from the dst filepath. This does not rely on the destination filepath actually existing on the local filesystem, just on pattern matching. Return source URI on success, None on failure. """ m = re.match(self.dst_path ...
[ "def", "dst_to_src", "(", "self", ",", "dst_file", ")", ":", "m", "=", "re", ".", "match", "(", "self", ".", "dst_path", "+", "\"/(.*)$\"", ",", "dst_file", ")", "if", "(", "m", "is", "None", ")", ":", "return", "(", "None", ")", "rel_path", "=", ...
Return the src URI from the dst filepath. This does not rely on the destination filepath actually existing on the local filesystem, just on pattern matching. Return source URI on success, None on failure.
[ "Return", "the", "src", "URI", "from", "the", "dst", "filepath", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/mapper.py#L170-L181
51,532
resync/resync
resync/mapper.py
Map.src_to_dst
def src_to_dst(self, src_uri): """Return the dst filepath from the src URI. Returns None on failure, destination path on success. """ m = re.match(self.src_uri + "/(.*)$", src_uri) if (m is None): return(None) rel_path = m.group(1) return(self.dst_pat...
python
def src_to_dst(self, src_uri): """Return the dst filepath from the src URI. Returns None on failure, destination path on success. """ m = re.match(self.src_uri + "/(.*)$", src_uri) if (m is None): return(None) rel_path = m.group(1) return(self.dst_pat...
[ "def", "src_to_dst", "(", "self", ",", "src_uri", ")", ":", "m", "=", "re", ".", "match", "(", "self", ".", "src_uri", "+", "\"/(.*)$\"", ",", "src_uri", ")", "if", "(", "m", "is", "None", ")", ":", "return", "(", "None", ")", "rel_path", "=", "m...
Return the dst filepath from the src URI. Returns None on failure, destination path on success.
[ "Return", "the", "dst", "filepath", "from", "the", "src", "URI", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/mapper.py#L183-L192
51,533
resync/resync
resync/mapper.py
Map.unsafe
def unsafe(self): """True if the mapping is unsafe for an update. Applies only to local source. Returns True if the paths for source and destination are the same, or if one is a component of the other path. """ (scheme, netloc, path, params, query, frag) = urlparse(self.src_uri)...
python
def unsafe(self): """True if the mapping is unsafe for an update. Applies only to local source. Returns True if the paths for source and destination are the same, or if one is a component of the other path. """ (scheme, netloc, path, params, query, frag) = urlparse(self.src_uri)...
[ "def", "unsafe", "(", "self", ")", ":", "(", "scheme", ",", "netloc", ",", "path", ",", "params", ",", "query", ",", "frag", ")", "=", "urlparse", "(", "self", ".", "src_uri", ")", "if", "(", "scheme", "!=", "''", ")", ":", "return", "(", "False"...
True if the mapping is unsafe for an update. Applies only to local source. Returns True if the paths for source and destination are the same, or if one is a component of the other path.
[ "True", "if", "the", "mapping", "is", "unsafe", "for", "an", "update", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/mapper.py#L194-L206
51,534
CameronLonsdale/lantern
lantern/util.py
remove
def remove(text, exclude): """Remove ``exclude`` symbols from ``text``. Example: >>> remove("example text", string.whitespace) 'exampletext' Args: text (str): The text to modify exclude (iterable): The symbols to exclude Returns: ``text`` with ``exclude`` symbo...
python
def remove(text, exclude): """Remove ``exclude`` symbols from ``text``. Example: >>> remove("example text", string.whitespace) 'exampletext' Args: text (str): The text to modify exclude (iterable): The symbols to exclude Returns: ``text`` with ``exclude`` symbo...
[ "def", "remove", "(", "text", ",", "exclude", ")", ":", "exclude", "=", "''", ".", "join", "(", "str", "(", "symbol", ")", "for", "symbol", "in", "exclude", ")", "return", "text", ".", "translate", "(", "str", ".", "maketrans", "(", "''", ",", "''"...
Remove ``exclude`` symbols from ``text``. Example: >>> remove("example text", string.whitespace) 'exampletext' Args: text (str): The text to modify exclude (iterable): The symbols to exclude Returns: ``text`` with ``exclude`` symbols removed
[ "Remove", "exclude", "symbols", "from", "text", "." ]
235e163e96bf0719d49c54204ee576b2ca93abb6
https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/util.py#L6-L21
51,535
CameronLonsdale/lantern
lantern/util.py
split_columns
def split_columns(text, n_columns): """Split ``text`` into ``n_columns`` many columns. Example: >>> split_columns("example", 2) ['eape', 'xml'] Args: text (str): The text to split n_columns (int): The number of columns to create Returns: List of columns Ra...
python
def split_columns(text, n_columns): """Split ``text`` into ``n_columns`` many columns. Example: >>> split_columns("example", 2) ['eape', 'xml'] Args: text (str): The text to split n_columns (int): The number of columns to create Returns: List of columns Ra...
[ "def", "split_columns", "(", "text", ",", "n_columns", ")", ":", "if", "n_columns", "<=", "0", "or", "n_columns", ">", "len", "(", "text", ")", ":", "raise", "ValueError", "(", "\"n_columns must be within the bounds of 1 and text length\"", ")", "return", "[", "...
Split ``text`` into ``n_columns`` many columns. Example: >>> split_columns("example", 2) ['eape', 'xml'] Args: text (str): The text to split n_columns (int): The number of columns to create Returns: List of columns Raises: ValueError: If n_cols is <= 0...
[ "Split", "text", "into", "n_columns", "many", "columns", "." ]
235e163e96bf0719d49c54204ee576b2ca93abb6
https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/util.py#L24-L44
51,536
CameronLonsdale/lantern
lantern/util.py
combine_columns
def combine_columns(columns): """Combine ``columns`` into a single string. Example: >>> combine_columns(['eape', 'xml']) 'example' Args: columns (iterable): ordered columns to combine Returns: String of combined columns """ columns_zipped = itertools.zip_longes...
python
def combine_columns(columns): """Combine ``columns`` into a single string. Example: >>> combine_columns(['eape', 'xml']) 'example' Args: columns (iterable): ordered columns to combine Returns: String of combined columns """ columns_zipped = itertools.zip_longes...
[ "def", "combine_columns", "(", "columns", ")", ":", "columns_zipped", "=", "itertools", ".", "zip_longest", "(", "*", "columns", ")", "return", "''", ".", "join", "(", "x", "for", "zipped", "in", "columns_zipped", "for", "x", "in", "zipped", "if", "x", "...
Combine ``columns`` into a single string. Example: >>> combine_columns(['eape', 'xml']) 'example' Args: columns (iterable): ordered columns to combine Returns: String of combined columns
[ "Combine", "columns", "into", "a", "single", "string", "." ]
235e163e96bf0719d49c54204ee576b2ca93abb6
https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/util.py#L47-L61
51,537
CameronLonsdale/lantern
lantern/util.py
iterate_ngrams
def iterate_ngrams(text, n): """Generator to yield ngrams in ``text``. Example: >>> for ngram in iterate_ngrams("example", 4): ... print(ngram) exam xamp ampl mple Args: text (str): text to iterate over n (int): size of window for iterati...
python
def iterate_ngrams(text, n): """Generator to yield ngrams in ``text``. Example: >>> for ngram in iterate_ngrams("example", 4): ... print(ngram) exam xamp ampl mple Args: text (str): text to iterate over n (int): size of window for iterati...
[ "def", "iterate_ngrams", "(", "text", ",", "n", ")", ":", "if", "n", "<=", "0", ":", "raise", "ValueError", "(", "\"n must be a positive integer\"", ")", "return", "[", "text", "[", "i", ":", "i", "+", "n", "]", "for", "i", "in", "range", "(", "len",...
Generator to yield ngrams in ``text``. Example: >>> for ngram in iterate_ngrams("example", 4): ... print(ngram) exam xamp ampl mple Args: text (str): text to iterate over n (int): size of window for iteration Returns: Generator e...
[ "Generator", "to", "yield", "ngrams", "in", "text", "." ]
235e163e96bf0719d49c54204ee576b2ca93abb6
https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/util.py#L64-L88
51,538
CameronLonsdale/lantern
lantern/util.py
group
def group(text, size): """Group ``text`` into blocks of ``size``. Example: >>> group("test", 2) ['te', 'st'] Args: text (str): text to separate size (int): size of groups to split the text into Returns: List of n-sized groups of text Raises: ValueE...
python
def group(text, size): """Group ``text`` into blocks of ``size``. Example: >>> group("test", 2) ['te', 'st'] Args: text (str): text to separate size (int): size of groups to split the text into Returns: List of n-sized groups of text Raises: ValueE...
[ "def", "group", "(", "text", ",", "size", ")", ":", "if", "size", "<=", "0", ":", "raise", "ValueError", "(", "\"n must be a positive integer\"", ")", "return", "[", "text", "[", "i", ":", "i", "+", "size", "]", "for", "i", "in", "range", "(", "0", ...
Group ``text`` into blocks of ``size``. Example: >>> group("test", 2) ['te', 'st'] Args: text (str): text to separate size (int): size of groups to split the text into Returns: List of n-sized groups of text Raises: ValueError: If n is non positive
[ "Group", "text", "into", "blocks", "of", "size", "." ]
235e163e96bf0719d49c54204ee576b2ca93abb6
https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/util.py#L91-L111
51,539
davidrpugh/pyCollocation
pycollocation/solvers/solvers.py
SolverLike._evaluate_rhs
def _evaluate_rhs(cls, funcs, nodes, problem): """ Compute the value of the right-hand side of the system of ODEs. Parameters ---------- basis_funcs : list(function) nodes : numpy.ndarray problem : TwoPointBVPLike Returns ------- evaluate...
python
def _evaluate_rhs(cls, funcs, nodes, problem): """ Compute the value of the right-hand side of the system of ODEs. Parameters ---------- basis_funcs : list(function) nodes : numpy.ndarray problem : TwoPointBVPLike Returns ------- evaluate...
[ "def", "_evaluate_rhs", "(", "cls", ",", "funcs", ",", "nodes", ",", "problem", ")", ":", "evald_funcs", "=", "cls", ".", "_evaluate_functions", "(", "funcs", ",", "nodes", ")", "evald_rhs", "=", "problem", ".", "rhs", "(", "nodes", ",", "*", "evald_func...
Compute the value of the right-hand side of the system of ODEs. Parameters ---------- basis_funcs : list(function) nodes : numpy.ndarray problem : TwoPointBVPLike Returns ------- evaluated_rhs : list(float)
[ "Compute", "the", "value", "of", "the", "right", "-", "hand", "side", "of", "the", "system", "of", "ODEs", "." ]
9376f3488a992dc416cfd2a4dbb396d094927569
https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/solvers/solvers.py#L41-L58
51,540
davidrpugh/pyCollocation
pycollocation/solvers/solvers.py
SolverLike._compute_residuals
def _compute_residuals(self, coefs_array, basis_kwargs, boundary_points, nodes, problem): """ Return collocation residuals. Parameters ---------- coefs_array : numpy.ndarray basis_kwargs : dict problem : TwoPointBVPLike Returns ------- re...
python
def _compute_residuals(self, coefs_array, basis_kwargs, boundary_points, nodes, problem): """ Return collocation residuals. Parameters ---------- coefs_array : numpy.ndarray basis_kwargs : dict problem : TwoPointBVPLike Returns ------- re...
[ "def", "_compute_residuals", "(", "self", ",", "coefs_array", ",", "basis_kwargs", ",", "boundary_points", ",", "nodes", ",", "problem", ")", ":", "coefs_list", "=", "self", ".", "_array_to_list", "(", "coefs_array", ",", "problem", ".", "number_odes", ")", "d...
Return collocation residuals. Parameters ---------- coefs_array : numpy.ndarray basis_kwargs : dict problem : TwoPointBVPLike Returns ------- resids : numpy.ndarray
[ "Return", "collocation", "residuals", "." ]
9376f3488a992dc416cfd2a4dbb396d094927569
https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/solvers/solvers.py#L124-L143
51,541
davidrpugh/pyCollocation
pycollocation/solvers/solvers.py
SolverLike._construct_approximation
def _construct_approximation(self, basis_kwargs, coefs_list): """ Construct a collection of derivatives and functions that approximate the solution to the boundary value problem. Parameters ---------- basis_kwargs : dict(str: ) coefs_list : list(numpy.ndarray) ...
python
def _construct_approximation(self, basis_kwargs, coefs_list): """ Construct a collection of derivatives and functions that approximate the solution to the boundary value problem. Parameters ---------- basis_kwargs : dict(str: ) coefs_list : list(numpy.ndarray) ...
[ "def", "_construct_approximation", "(", "self", ",", "basis_kwargs", ",", "coefs_list", ")", ":", "derivs", "=", "self", ".", "_construct_derivatives", "(", "coefs_list", ",", "*", "*", "basis_kwargs", ")", "funcs", "=", "self", ".", "_construct_functions", "(",...
Construct a collection of derivatives and functions that approximate the solution to the boundary value problem. Parameters ---------- basis_kwargs : dict(str: ) coefs_list : list(numpy.ndarray) Returns ------- basis_derivs : list(function) basis...
[ "Construct", "a", "collection", "of", "derivatives", "and", "functions", "that", "approximate", "the", "solution", "to", "the", "boundary", "value", "problem", "." ]
9376f3488a992dc416cfd2a4dbb396d094927569
https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/solvers/solvers.py#L145-L163
51,542
davidrpugh/pyCollocation
pycollocation/solvers/solvers.py
SolverLike._construct_derivatives
def _construct_derivatives(self, coefs, **kwargs): """Return a list of derivatives given a list of coefficients.""" return [self.basis_functions.derivatives_factory(coef, **kwargs) for coef in coefs]
python
def _construct_derivatives(self, coefs, **kwargs): """Return a list of derivatives given a list of coefficients.""" return [self.basis_functions.derivatives_factory(coef, **kwargs) for coef in coefs]
[ "def", "_construct_derivatives", "(", "self", ",", "coefs", ",", "*", "*", "kwargs", ")", ":", "return", "[", "self", ".", "basis_functions", ".", "derivatives_factory", "(", "coef", ",", "*", "*", "kwargs", ")", "for", "coef", "in", "coefs", "]" ]
Return a list of derivatives given a list of coefficients.
[ "Return", "a", "list", "of", "derivatives", "given", "a", "list", "of", "coefficients", "." ]
9376f3488a992dc416cfd2a4dbb396d094927569
https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/solvers/solvers.py#L165-L167
51,543
davidrpugh/pyCollocation
pycollocation/solvers/solvers.py
SolverLike._construct_functions
def _construct_functions(self, coefs, **kwargs): """Return a list of functions given a list of coefficients.""" return [self.basis_functions.functions_factory(coef, **kwargs) for coef in coefs]
python
def _construct_functions(self, coefs, **kwargs): """Return a list of functions given a list of coefficients.""" return [self.basis_functions.functions_factory(coef, **kwargs) for coef in coefs]
[ "def", "_construct_functions", "(", "self", ",", "coefs", ",", "*", "*", "kwargs", ")", ":", "return", "[", "self", ".", "basis_functions", ".", "functions_factory", "(", "coef", ",", "*", "*", "kwargs", ")", "for", "coef", "in", "coefs", "]" ]
Return a list of functions given a list of coefficients.
[ "Return", "a", "list", "of", "functions", "given", "a", "list", "of", "coefficients", "." ]
9376f3488a992dc416cfd2a4dbb396d094927569
https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/solvers/solvers.py#L169-L171
51,544
davidrpugh/pyCollocation
pycollocation/solvers/solvers.py
SolverLike._solution_factory
def _solution_factory(self, basis_kwargs, coefs_array, nodes, problem, result): """ Construct a representation of the solution to the boundary value problem. Parameters ---------- basis_kwargs : dict(str : ) coefs_array : numpy.ndarray problem : TwoPointBVPLike ...
python
def _solution_factory(self, basis_kwargs, coefs_array, nodes, problem, result): """ Construct a representation of the solution to the boundary value problem. Parameters ---------- basis_kwargs : dict(str : ) coefs_array : numpy.ndarray problem : TwoPointBVPLike ...
[ "def", "_solution_factory", "(", "self", ",", "basis_kwargs", ",", "coefs_array", ",", "nodes", ",", "problem", ",", "result", ")", ":", "soln_coefs", "=", "self", ".", "_array_to_list", "(", "coefs_array", ",", "problem", ".", "number_odes", ")", "soln_derivs...
Construct a representation of the solution to the boundary value problem. Parameters ---------- basis_kwargs : dict(str : ) coefs_array : numpy.ndarray problem : TwoPointBVPLike result : OptimizeResult Returns ------- solution : SolutionLike
[ "Construct", "a", "representation", "of", "the", "solution", "to", "the", "boundary", "value", "problem", "." ]
9376f3488a992dc416cfd2a4dbb396d094927569
https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/solvers/solvers.py#L173-L197
51,545
davidrpugh/pyCollocation
pycollocation/solvers/solvers.py
Solver.solve
def solve(self, basis_kwargs, boundary_points, coefs_array, nodes, problem, **solver_options): """ Solve a boundary value problem using the collocation method. Parameters ---------- basis_kwargs : dict Dictionary of keyword arguments used to build basis...
python
def solve(self, basis_kwargs, boundary_points, coefs_array, nodes, problem, **solver_options): """ Solve a boundary value problem using the collocation method. Parameters ---------- basis_kwargs : dict Dictionary of keyword arguments used to build basis...
[ "def", "solve", "(", "self", ",", "basis_kwargs", ",", "boundary_points", ",", "coefs_array", ",", "nodes", ",", "problem", ",", "*", "*", "solver_options", ")", ":", "result", "=", "optimize", ".", "root", "(", "self", ".", "_compute_residuals", ",", "x0"...
Solve a boundary value problem using the collocation method. Parameters ---------- basis_kwargs : dict Dictionary of keyword arguments used to build basis functions. coefs_array : numpy.ndarray Array of coefficients for basis functions defining the initial ...
[ "Solve", "a", "boundary", "value", "problem", "using", "the", "collocation", "method", "." ]
9376f3488a992dc416cfd2a4dbb396d094927569
https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/solvers/solvers.py#L234-L267
51,546
resync/resync
resync/w3c_datetime.py
datetime_to_str
def datetime_to_str(dt='now', no_fractions=False): """The Last-Modified data in ISO8601 syntax, Z notation. The lastmod is stored as unix timestamp which is already in UTC. At preesent this code will return 6 decimal digits if any fraction of a second is given. It would perhaps be better to return ...
python
def datetime_to_str(dt='now', no_fractions=False): """The Last-Modified data in ISO8601 syntax, Z notation. The lastmod is stored as unix timestamp which is already in UTC. At preesent this code will return 6 decimal digits if any fraction of a second is given. It would perhaps be better to return ...
[ "def", "datetime_to_str", "(", "dt", "=", "'now'", ",", "no_fractions", "=", "False", ")", ":", "if", "(", "dt", "is", "None", ")", ":", "return", "None", "elif", "(", "dt", "==", "'now'", ")", ":", "dt", "=", "time", ".", "time", "(", ")", "if",...
The Last-Modified data in ISO8601 syntax, Z notation. The lastmod is stored as unix timestamp which is already in UTC. At preesent this code will return 6 decimal digits if any fraction of a second is given. It would perhaps be better to return only the number of decimal digits necessary, up to a r...
[ "The", "Last", "-", "Modified", "data", "in", "ISO8601", "syntax", "Z", "notation", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/w3c_datetime.py#L17-L38
51,547
resync/resync
resync/w3c_datetime.py
str_to_datetime
def str_to_datetime(s, context='datetime'): """Set timestamp from an W3C Datetime Last-Modified value. The sitemaps.org specification says that <lastmod> values must comply with the W3C Datetime format (http://www.w3.org/TR/NOTE-datetime). This is a restricted subset of ISO8601. In particular, all ...
python
def str_to_datetime(s, context='datetime'): """Set timestamp from an W3C Datetime Last-Modified value. The sitemaps.org specification says that <lastmod> values must comply with the W3C Datetime format (http://www.w3.org/TR/NOTE-datetime). This is a restricted subset of ISO8601. In particular, all ...
[ "def", "str_to_datetime", "(", "s", ",", "context", "=", "'datetime'", ")", ":", "t", "=", "None", "if", "(", "s", "is", "None", ")", ":", "return", "(", "t", ")", "if", "(", "s", "==", "''", ")", ":", "raise", "ValueError", "(", "'Attempt to set e...
Set timestamp from an W3C Datetime Last-Modified value. The sitemaps.org specification says that <lastmod> values must comply with the W3C Datetime format (http://www.w3.org/TR/NOTE-datetime). This is a restricted subset of ISO8601. In particular, all forms that include a time must include a timezo...
[ "Set", "timestamp", "from", "an", "W3C", "Datetime", "Last", "-", "Modified", "value", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/w3c_datetime.py#L41-L121
51,548
cvng/django-geocoder
django_geocoder/mixins.py
GeoMixin.need_geocoding
def need_geocoding(self): """ Returns True if any of the required address components is missing """ need_geocoding = False for attribute, component in self.required_address_components.items(): if not getattr(self, attribute): need_geocoding = True ...
python
def need_geocoding(self): """ Returns True if any of the required address components is missing """ need_geocoding = False for attribute, component in self.required_address_components.items(): if not getattr(self, attribute): need_geocoding = True ...
[ "def", "need_geocoding", "(", "self", ")", ":", "need_geocoding", "=", "False", "for", "attribute", ",", "component", "in", "self", ".", "required_address_components", ".", "items", "(", ")", ":", "if", "not", "getattr", "(", "self", ",", "attribute", ")", ...
Returns True if any of the required address components is missing
[ "Returns", "True", "if", "any", "of", "the", "required", "address", "components", "is", "missing" ]
3b276995c51326b9f75c4d46c17ca546052382ff
https://github.com/cvng/django-geocoder/blob/3b276995c51326b9f75c4d46c17ca546052382ff/django_geocoder/mixins.py#L10-L19
51,549
cvng/django-geocoder
django_geocoder/mixins.py
GeoMixin.geocode
def geocode(self, commit=False, force=False): """ Do a backend geocoding if needed """ if self.need_geocoding() or force: result = get_cached(getattr(self, self.geocoded_by), provider='google') if result.status == 'OK': for attribute, components in...
python
def geocode(self, commit=False, force=False): """ Do a backend geocoding if needed """ if self.need_geocoding() or force: result = get_cached(getattr(self, self.geocoded_by), provider='google') if result.status == 'OK': for attribute, components in...
[ "def", "geocode", "(", "self", ",", "commit", "=", "False", ",", "force", "=", "False", ")", ":", "if", "self", ".", "need_geocoding", "(", ")", "or", "force", ":", "result", "=", "get_cached", "(", "getattr", "(", "self", ",", "self", ".", "geocoded...
Do a backend geocoding if needed
[ "Do", "a", "backend", "geocoding", "if", "needed" ]
3b276995c51326b9f75c4d46c17ca546052382ff
https://github.com/cvng/django-geocoder/blob/3b276995c51326b9f75c4d46c17ca546052382ff/django_geocoder/mixins.py#L21-L36
51,550
resync/resync
resync/resource_container.py
ResourceContainer.link
def link(self, rel): """Look for link with specified rel, return else None.""" for link in self.ln: if ('rel' in link and link['rel'] == rel): return(link) return(None)
python
def link(self, rel): """Look for link with specified rel, return else None.""" for link in self.ln: if ('rel' in link and link['rel'] == rel): return(link) return(None)
[ "def", "link", "(", "self", ",", "rel", ")", ":", "for", "link", "in", "self", ".", "ln", ":", "if", "(", "'rel'", "in", "link", "and", "link", "[", "'rel'", "]", "==", "rel", ")", ":", "return", "(", "link", ")", "return", "(", "None", ")" ]
Look for link with specified rel, return else None.
[ "Look", "for", "link", "with", "specified", "rel", "return", "else", "None", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_container.py#L114-L120
51,551
resync/resync
resync/resource_container.py
ResourceContainer.link_href
def link_href(self, rel): """Look for link with specified rel, return href from it or None.""" link = self.link(rel) if (link is not None): link = link['href'] return(link)
python
def link_href(self, rel): """Look for link with specified rel, return href from it or None.""" link = self.link(rel) if (link is not None): link = link['href'] return(link)
[ "def", "link_href", "(", "self", ",", "rel", ")", ":", "link", "=", "self", ".", "link", "(", "rel", ")", "if", "(", "link", "is", "not", "None", ")", ":", "link", "=", "link", "[", "'href'", "]", "return", "(", "link", ")" ]
Look for link with specified rel, return href from it or None.
[ "Look", "for", "link", "with", "specified", "rel", "return", "href", "from", "it", "or", "None", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_container.py#L122-L127
51,552
resync/resync
resync/resource_container.py
ResourceContainer.default_capability
def default_capability(self): """Set capability name in md. Every ResourceSync document should have the top-level capability attributes. """ if ('capability' not in self.md and self.capability_name is not None): self.md['capability'] = self.capability_name
python
def default_capability(self): """Set capability name in md. Every ResourceSync document should have the top-level capability attributes. """ if ('capability' not in self.md and self.capability_name is not None): self.md['capability'] = self.capability_name
[ "def", "default_capability", "(", "self", ")", ":", "if", "(", "'capability'", "not", "in", "self", ".", "md", "and", "self", ".", "capability_name", "is", "not", "None", ")", ":", "self", ".", "md", "[", "'capability'", "]", "=", "self", ".", "capabil...
Set capability name in md. Every ResourceSync document should have the top-level capability attributes.
[ "Set", "capability", "name", "in", "md", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_container.py#L179-L186
51,553
resync/resync
resync/resource_container.py
ResourceContainer.add
def add(self, resource): """Add a resource or an iterable collection of resources to this container. Must be implemented in derived class. """ if isinstance(resource, collections.Iterable): for r in resource: self.resources.append(r) else: ...
python
def add(self, resource): """Add a resource or an iterable collection of resources to this container. Must be implemented in derived class. """ if isinstance(resource, collections.Iterable): for r in resource: self.resources.append(r) else: ...
[ "def", "add", "(", "self", ",", "resource", ")", ":", "if", "isinstance", "(", "resource", ",", "collections", ".", "Iterable", ")", ":", "for", "r", "in", "resource", ":", "self", ".", "resources", ".", "append", "(", "r", ")", "else", ":", "self", ...
Add a resource or an iterable collection of resources to this container. Must be implemented in derived class.
[ "Add", "a", "resource", "or", "an", "iterable", "collection", "of", "resources", "to", "this", "container", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_container.py#L188-L197
51,554
resync/resync
resync/resource_container.py
ResourceContainer.prune_before
def prune_before(self, timestamp): """Remove all resources with timestamp earlier than that given. Returns the number of entries removed. Will raise an excpetion if there are any entries without a timestamp. """ n = 0 pruned = [] for r in self.resources: ...
python
def prune_before(self, timestamp): """Remove all resources with timestamp earlier than that given. Returns the number of entries removed. Will raise an excpetion if there are any entries without a timestamp. """ n = 0 pruned = [] for r in self.resources: ...
[ "def", "prune_before", "(", "self", ",", "timestamp", ")", ":", "n", "=", "0", "pruned", "=", "[", "]", "for", "r", "in", "self", ".", "resources", ":", "if", "(", "r", ".", "timestamp", "is", "None", ")", ":", "raise", "Exception", "(", "\"Entry %...
Remove all resources with timestamp earlier than that given. Returns the number of entries removed. Will raise an excpetion if there are any entries without a timestamp.
[ "Remove", "all", "resources", "with", "timestamp", "earlier", "than", "that", "given", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_container.py#L206-L222
51,555
resync/resync
resync/resource_container.py
ResourceContainer.prune_dupes
def prune_dupes(self): """Remove all but the last entry for a given resource URI. Returns the number of entries removed. Also removes all entries for a given URI where the first entry is a create and the last entry is a delete. """ n = 0 pruned1 = [] seen...
python
def prune_dupes(self): """Remove all but the last entry for a given resource URI. Returns the number of entries removed. Also removes all entries for a given URI where the first entry is a create and the last entry is a delete. """ n = 0 pruned1 = [] seen...
[ "def", "prune_dupes", "(", "self", ")", ":", "n", "=", "0", "pruned1", "=", "[", "]", "seen", "=", "set", "(", ")", "deletes", "=", "{", "}", "for", "r", "in", "reversed", "(", "self", ".", "resources", ")", ":", "if", "(", "r", ".", "uri", "...
Remove all but the last entry for a given resource URI. Returns the number of entries removed. Also removes all entries for a given URI where the first entry is a create and the last entry is a delete.
[ "Remove", "all", "but", "the", "last", "entry", "for", "a", "given", "resource", "URI", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_container.py#L224-L253
51,556
resync/resync
resync/resource_container.py
ResourceContainer._str_datetime_now
def _str_datetime_now(self, x=None): """Return datetime string for use with time attributes. Handling depends on input: 'now' - returns datetime for now number - assume datetime values, generate string other - no change, return same value """ if (x == ...
python
def _str_datetime_now(self, x=None): """Return datetime string for use with time attributes. Handling depends on input: 'now' - returns datetime for now number - assume datetime values, generate string other - no change, return same value """ if (x == ...
[ "def", "_str_datetime_now", "(", "self", ",", "x", "=", "None", ")", ":", "if", "(", "x", "==", "'now'", ")", ":", "# Now, this is wht datetime_to_str() with no arg gives", "return", "(", "datetime_to_str", "(", ")", ")", "try", ":", "# Test for number", "junk",...
Return datetime string for use with time attributes. Handling depends on input: 'now' - returns datetime for now number - assume datetime values, generate string other - no change, return same value
[ "Return", "datetime", "string", "for", "use", "with", "time", "attributes", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_container.py#L262-L279
51,557
mryellow/maze_explorer
mazeexp/engine/generator.py
Generator.map
def map(self, width, height): """ Creates and returns a new randomly generated map """ template = ti.load(os.path.join(script_dir, 'assets', 'template.tmx'))['map0'] #template.set_view(0, 0, template.px_width, template.px_height) template.set_view(0, 0, width*template.tw,...
python
def map(self, width, height): """ Creates and returns a new randomly generated map """ template = ti.load(os.path.join(script_dir, 'assets', 'template.tmx'))['map0'] #template.set_view(0, 0, template.px_width, template.px_height) template.set_view(0, 0, width*template.tw,...
[ "def", "map", "(", "self", ",", "width", ",", "height", ")", ":", "template", "=", "ti", ".", "load", "(", "os", ".", "path", ".", "join", "(", "script_dir", ",", "'assets'", ",", "'template.tmx'", ")", ")", "[", "'map0'", "]", "#template.set_view(0, 0...
Creates and returns a new randomly generated map
[ "Creates", "and", "returns", "a", "new", "randomly", "generated", "map" ]
ab8a25ccd05105d2fe57e0213d690cfc07e45827
https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/generator.py#L20-L44
51,558
robertpeteuil/multi-cloud-control
mcc/core.py
make_node_dict
def make_node_dict(outer_list, sort="zone"): """Convert node data from nested-list to sorted dict.""" raw_dict = {} x = 1 for inner_list in outer_list: for node in inner_list: raw_dict[x] = node x += 1 if sort == "name": # sort by provider - name srt_dict = O...
python
def make_node_dict(outer_list, sort="zone"): """Convert node data from nested-list to sorted dict.""" raw_dict = {} x = 1 for inner_list in outer_list: for node in inner_list: raw_dict[x] = node x += 1 if sort == "name": # sort by provider - name srt_dict = O...
[ "def", "make_node_dict", "(", "outer_list", ",", "sort", "=", "\"zone\"", ")", ":", "raw_dict", "=", "{", "}", "x", "=", "1", "for", "inner_list", "in", "outer_list", ":", "for", "node", "in", "inner_list", ":", "raw_dict", "[", "x", "]", "=", "node", ...
Convert node data from nested-list to sorted dict.
[ "Convert", "node", "data", "from", "nested", "-", "list", "to", "sorted", "dict", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/core.py#L60-L79
51,559
robertpeteuil/multi-cloud-control
mcc/core.py
config_read
def config_read(): """Read config info from config file.""" config_file = (u"{0}config.ini".format(CONFIG_DIR)) if not os.path.isfile(config_file): config_make(config_file) config = configparser.ConfigParser(allow_no_value=True) try: config.read(config_file, encoding='utf-8') exc...
python
def config_read(): """Read config info from config file.""" config_file = (u"{0}config.ini".format(CONFIG_DIR)) if not os.path.isfile(config_file): config_make(config_file) config = configparser.ConfigParser(allow_no_value=True) try: config.read(config_file, encoding='utf-8') exc...
[ "def", "config_read", "(", ")", ":", "config_file", "=", "(", "u\"{0}config.ini\"", ".", "format", "(", "CONFIG_DIR", ")", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "config_file", ")", ":", "config_make", "(", "config_file", ")", "config", ...
Read config info from config file.
[ "Read", "config", "info", "from", "config", "file", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/core.py#L82-L100
51,560
robertpeteuil/multi-cloud-control
mcc/core.py
config_prov
def config_prov(config): """Read providers from configfile and de-duplicate it.""" try: providers = [e.strip() for e in (config['info'] ['providers']).split(',')] except KeyError as e: print("Error reading config item: {}".format(e)) sys.exit(...
python
def config_prov(config): """Read providers from configfile and de-duplicate it.""" try: providers = [e.strip() for e in (config['info'] ['providers']).split(',')] except KeyError as e: print("Error reading config item: {}".format(e)) sys.exit(...
[ "def", "config_prov", "(", "config", ")", ":", "try", ":", "providers", "=", "[", "e", ".", "strip", "(", ")", "for", "e", "in", "(", "config", "[", "'info'", "]", "[", "'providers'", "]", ")", ".", "split", "(", "','", ")", "]", "except", "KeyEr...
Read providers from configfile and de-duplicate it.
[ "Read", "providers", "from", "configfile", "and", "de", "-", "duplicate", "it", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/core.py#L103-L112
51,561
robertpeteuil/multi-cloud-control
mcc/core.py
config_cred
def config_cred(config, providers): """Read credentials from configfile.""" expected = ['aws', 'azure', 'gcp', 'alicloud'] cred = {} to_remove = [] for item in providers: if any(item.startswith(itemb) for itemb in expected): try: cred[item] = dict(list(config[item...
python
def config_cred(config, providers): """Read credentials from configfile.""" expected = ['aws', 'azure', 'gcp', 'alicloud'] cred = {} to_remove = [] for item in providers: if any(item.startswith(itemb) for itemb in expected): try: cred[item] = dict(list(config[item...
[ "def", "config_cred", "(", "config", ",", "providers", ")", ":", "expected", "=", "[", "'aws'", ",", "'azure'", ",", "'gcp'", ",", "'alicloud'", "]", "cred", "=", "{", "}", "to_remove", "=", "[", "]", "for", "item", "in", "providers", ":", "if", "any...
Read credentials from configfile.
[ "Read", "credentials", "from", "configfile", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/core.py#L115-L132
51,562
robertpeteuil/multi-cloud-control
mcc/core.py
config_make
def config_make(config_file): """Create config.ini on first use, make dir and copy sample.""" from pkg_resources import resource_filename import shutil if not os.path.exists(CONFIG_DIR): os.makedirs(CONFIG_DIR) filename = resource_filename("mcc", "config.ini") try: shutil.copyfil...
python
def config_make(config_file): """Create config.ini on first use, make dir and copy sample.""" from pkg_resources import resource_filename import shutil if not os.path.exists(CONFIG_DIR): os.makedirs(CONFIG_DIR) filename = resource_filename("mcc", "config.ini") try: shutil.copyfil...
[ "def", "config_make", "(", "config_file", ")", ":", "from", "pkg_resources", "import", "resource_filename", "import", "shutil", "if", "not", "os", ".", "path", ".", "exists", "(", "CONFIG_DIR", ")", ":", "os", ".", "makedirs", "(", "CONFIG_DIR", ")", "filena...
Create config.ini on first use, make dir and copy sample.
[ "Create", "config", ".", "ini", "on", "first", "use", "make", "dir", "and", "copy", "sample", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/core.py#L135-L148
51,563
resync/resync
resync/resource.py
Resource.hash
def hash(self): """Provide access to the complete hash string. The hash string may have zero or more hash values with appropriate prefixes. All hash values are assumed to be strings """ hashvals = [] if (self.md5 is not None): hashvals.append('md5:' +...
python
def hash(self): """Provide access to the complete hash string. The hash string may have zero or more hash values with appropriate prefixes. All hash values are assumed to be strings """ hashvals = [] if (self.md5 is not None): hashvals.append('md5:' +...
[ "def", "hash", "(", "self", ")", ":", "hashvals", "=", "[", "]", "if", "(", "self", ".", "md5", "is", "not", "None", ")", ":", "hashvals", ".", "append", "(", "'md5:'", "+", "self", ".", "md5", ")", "if", "(", "self", ".", "sha1", "is", "not", ...
Provide access to the complete hash string. The hash string may have zero or more hash values with appropriate prefixes. All hash values are assumed to be strings
[ "Provide", "access", "to", "the", "complete", "hash", "string", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource.py#L244-L260
51,564
resync/resync
resync/resource.py
Resource.hash
def hash(self, hash): """Parse space separated set of values. See specification at: http://tools.ietf.org/html/draft-snell-atompub-link-extensions-09 which defines many types. We implement md5, sha-1, sha-256 """ self.md5 = None self.sha1 = None self.sha2...
python
def hash(self, hash): """Parse space separated set of values. See specification at: http://tools.ietf.org/html/draft-snell-atompub-link-extensions-09 which defines many types. We implement md5, sha-1, sha-256 """ self.md5 = None self.sha1 = None self.sha2...
[ "def", "hash", "(", "self", ",", "hash", ")", ":", "self", ".", "md5", "=", "None", "self", ".", "sha1", "=", "None", "self", ".", "sha256", "=", "None", "if", "(", "hash", "is", "None", ")", ":", "return", "hash_seen", "=", "set", "(", ")", "e...
Parse space separated set of values. See specification at: http://tools.ietf.org/html/draft-snell-atompub-link-extensions-09 which defines many types. We implement md5, sha-1, sha-256
[ "Parse", "space", "separated", "set", "of", "values", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource.py#L263-L293
51,565
resync/resync
resync/resource.py
Resource.link_add
def link_add(self, rel, href, **atts): """Create an link with specified rel. Will add a link even if one with that rel already exists. """ self.link_set(rel, href, allow_duplicates=True, **atts)
python
def link_add(self, rel, href, **atts): """Create an link with specified rel. Will add a link even if one with that rel already exists. """ self.link_set(rel, href, allow_duplicates=True, **atts)
[ "def", "link_add", "(", "self", ",", "rel", ",", "href", ",", "*", "*", "atts", ")", ":", "self", ".", "link_set", "(", "rel", ",", "href", ",", "allow_duplicates", "=", "True", ",", "*", "*", "atts", ")" ]
Create an link with specified rel. Will add a link even if one with that rel already exists.
[ "Create", "an", "link", "with", "specified", "rel", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource.py#L344-L349
51,566
resync/resync
resync/resource.py
Resource.equal
def equal(self, other, delta=0.0): """Equality or near equality test for resources. Equality means: 1. same uri, AND 2. same timestamp WITHIN delta if specified for either, AND 3. same md5 if specified for both, AND 4. same length if specified for both """ ...
python
def equal(self, other, delta=0.0): """Equality or near equality test for resources. Equality means: 1. same uri, AND 2. same timestamp WITHIN delta if specified for either, AND 3. same md5 if specified for both, AND 4. same length if specified for both """ ...
[ "def", "equal", "(", "self", ",", "other", ",", "delta", "=", "0.0", ")", ":", "if", "(", "other", "is", "None", ")", ":", "return", "False", "if", "(", "self", ".", "uri", "!=", "other", ".", "uri", ")", ":", "return", "(", "False", ")", "if",...
Equality or near equality test for resources. Equality means: 1. same uri, AND 2. same timestamp WITHIN delta if specified for either, AND 3. same md5 if specified for both, AND 4. same length if specified for both
[ "Equality", "or", "near", "equality", "test", "for", "resources", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource.py#L410-L435
51,567
CameronLonsdale/lantern
lantern/fitness/chisquared.py
ChiSquared
def ChiSquared(target_frequency): """Score a text by comparing its frequency distribution against another. Note: It is easy to be penalised without knowing it when using this scorer. English frequency ngrams are capital letters, meaning when using it any text you score against must be a...
python
def ChiSquared(target_frequency): """Score a text by comparing its frequency distribution against another. Note: It is easy to be penalised without knowing it when using this scorer. English frequency ngrams are capital letters, meaning when using it any text you score against must be a...
[ "def", "ChiSquared", "(", "target_frequency", ")", ":", "def", "inner", "(", "text", ")", ":", "text", "=", "''", ".", "join", "(", "text", ")", "return", "-", "chi_squared", "(", "frequency_analyze", "(", "text", ")", ",", "target_frequency", ")", "retu...
Score a text by comparing its frequency distribution against another. Note: It is easy to be penalised without knowing it when using this scorer. English frequency ngrams are capital letters, meaning when using it any text you score against must be all capitals for it to give correct result...
[ "Score", "a", "text", "by", "comparing", "its", "frequency", "distribution", "against", "another", "." ]
235e163e96bf0719d49c54204ee576b2ca93abb6
https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/fitness/chisquared.py#L6-L31
51,568
resync/resync
examples/sitemapindex_and_generator.py
my_resource_list
def my_resource_list(): """Simulate the generator used by simulator""" rl = ResourceList( resources=iter(my_resources), count=len(my_resources) ) rl.max_sitemap_entries = max_sitemap_entries return(rl)
python
def my_resource_list(): """Simulate the generator used by simulator""" rl = ResourceList( resources=iter(my_resources), count=len(my_resources) ) rl.max_sitemap_entries = max_sitemap_entries return(rl)
[ "def", "my_resource_list", "(", ")", ":", "rl", "=", "ResourceList", "(", "resources", "=", "iter", "(", "my_resources", ")", ",", "count", "=", "len", "(", "my_resources", ")", ")", "rl", ".", "max_sitemap_entries", "=", "max_sitemap_entries", "return", "("...
Simulate the generator used by simulator
[ "Simulate", "the", "generator", "used", "by", "simulator" ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/examples/sitemapindex_and_generator.py#L16-L20
51,569
resync/resync
resync/resource_list.py
ResourceListOrdered.add
def add(self, resource, replace=False): """Add a single resource, check for dupes.""" uri = resource.uri for r in self: if (uri == r.uri): if (replace): r = resource return else: raise Resourc...
python
def add(self, resource, replace=False): """Add a single resource, check for dupes.""" uri = resource.uri for r in self: if (uri == r.uri): if (replace): r = resource return else: raise Resourc...
[ "def", "add", "(", "self", ",", "resource", ",", "replace", "=", "False", ")", ":", "uri", "=", "resource", ".", "uri", "for", "r", "in", "self", ":", "if", "(", "uri", "==", "r", ".", "uri", ")", ":", "if", "(", "replace", ")", ":", "r", "="...
Add a single resource, check for dupes.
[ "Add", "a", "single", "resource", "check", "for", "dupes", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_list.py#L86-L98
51,570
resync/resync
resync/resource_list.py
ResourceList.add
def add(self, resource, replace=False): """Add a resource or an iterable collection of resources. Will throw a ValueError if the resource (ie. same uri) already exists in the ResourceList, unless replace=True. """ if isinstance(resource, collections.Iterable): for r ...
python
def add(self, resource, replace=False): """Add a resource or an iterable collection of resources. Will throw a ValueError if the resource (ie. same uri) already exists in the ResourceList, unless replace=True. """ if isinstance(resource, collections.Iterable): for r ...
[ "def", "add", "(", "self", ",", "resource", ",", "replace", "=", "False", ")", ":", "if", "isinstance", "(", "resource", ",", "collections", ".", "Iterable", ")", ":", "for", "r", "in", "resource", ":", "self", ".", "resources", ".", "add", "(", "r",...
Add a resource or an iterable collection of resources. Will throw a ValueError if the resource (ie. same uri) already exists in the ResourceList, unless replace=True.
[ "Add", "a", "resource", "or", "an", "iterable", "collection", "of", "resources", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_list.py#L150-L160
51,571
resync/resync
resync/resource_list.py
ResourceList.compare
def compare(self, src): """Compare this ResourceList object with that specified as src. The parameter src must also be a ResourceList object, it is assumed to be the source, and the current object is the destination. This written to work for any objects in self and sc, provided that the...
python
def compare(self, src): """Compare this ResourceList object with that specified as src. The parameter src must also be a ResourceList object, it is assumed to be the source, and the current object is the destination. This written to work for any objects in self and sc, provided that the...
[ "def", "compare", "(", "self", ",", "src", ")", ":", "dst_iter", "=", "iter", "(", "self", ".", "resources", ")", "src_iter", "=", "iter", "(", "src", ".", "resources", ")", "same", "=", "ResourceList", "(", ")", "updated", "=", "ResourceList", "(", ...
Compare this ResourceList object with that specified as src. The parameter src must also be a ResourceList object, it is assumed to be the source, and the current object is the destination. This written to work for any objects in self and sc, provided that the == operator can be used to...
[ "Compare", "this", "ResourceList", "object", "with", "that", "specified", "as", "src", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_list.py#L162-L206
51,572
resync/resync
resync/resource_list.py
ResourceList.hashes
def hashes(self): """Return set of hashes uses in this resource_list.""" hashes = set() if (self.resources is not None): for resource in self: if (resource.md5 is not None): hashes.add('md5') if (resource.sha1 is not None): ...
python
def hashes(self): """Return set of hashes uses in this resource_list.""" hashes = set() if (self.resources is not None): for resource in self: if (resource.md5 is not None): hashes.add('md5') if (resource.sha1 is not None): ...
[ "def", "hashes", "(", "self", ")", ":", "hashes", "=", "set", "(", ")", "if", "(", "self", ".", "resources", "is", "not", "None", ")", ":", "for", "resource", "in", "self", ":", "if", "(", "resource", ".", "md5", "is", "not", "None", ")", ":", ...
Return set of hashes uses in this resource_list.
[ "Return", "set", "of", "hashes", "uses", "in", "this", "resource_list", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_list.py#L208-L219
51,573
cmck/pybrowserstack-screenshots
client.py
_build_sliced_filepath
def _build_sliced_filepath(filename, slice_count): """ append slice_count to the end of a filename """ root = os.path.splitext(filename)[0] ext = os.path.splitext(filename)[1] new_filepath = ''.join((root, str(slice_count), ext)) return _build_filepath_for_phantomcss(new_filepath)
python
def _build_sliced_filepath(filename, slice_count): """ append slice_count to the end of a filename """ root = os.path.splitext(filename)[0] ext = os.path.splitext(filename)[1] new_filepath = ''.join((root, str(slice_count), ext)) return _build_filepath_for_phantomcss(new_filepath)
[ "def", "_build_sliced_filepath", "(", "filename", ",", "slice_count", ")", ":", "root", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "[", "0", "]", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "[", "1", "]",...
append slice_count to the end of a filename
[ "append", "slice_count", "to", "the", "end", "of", "a", "filename" ]
598358fc5b9a41678b3f913f2c082a288011322d
https://github.com/cmck/pybrowserstack-screenshots/blob/598358fc5b9a41678b3f913f2c082a288011322d/client.py#L33-L38
51,574
cmck/pybrowserstack-screenshots
client.py
_build_filepath_for_phantomcss
def _build_filepath_for_phantomcss(filepath): """ Prepare screenshot filename for use with phantomcss. ie, append 'diff' to the end of the file if a baseline exists """ try: if os.path.exists(filepath): new_root = '.'.join((os.path.splitext(filepath)[0], 'diff')) ext = os...
python
def _build_filepath_for_phantomcss(filepath): """ Prepare screenshot filename for use with phantomcss. ie, append 'diff' to the end of the file if a baseline exists """ try: if os.path.exists(filepath): new_root = '.'.join((os.path.splitext(filepath)[0], 'diff')) ext = os...
[ "def", "_build_filepath_for_phantomcss", "(", "filepath", ")", ":", "try", ":", "if", "os", ".", "path", ".", "exists", "(", "filepath", ")", ":", "new_root", "=", "'.'", ".", "join", "(", "(", "os", ".", "path", ".", "splitext", "(", "filepath", ")", ...
Prepare screenshot filename for use with phantomcss. ie, append 'diff' to the end of the file if a baseline exists
[ "Prepare", "screenshot", "filename", "for", "use", "with", "phantomcss", ".", "ie", "append", "diff", "to", "the", "end", "of", "the", "file", "if", "a", "baseline", "exists" ]
598358fc5b9a41678b3f913f2c082a288011322d
https://github.com/cmck/pybrowserstack-screenshots/blob/598358fc5b9a41678b3f913f2c082a288011322d/client.py#L41-L56
51,575
cmck/pybrowserstack-screenshots
client.py
_build_filename_from_browserstack_json
def _build_filename_from_browserstack_json(j): """ Build a useful filename for an image from the screenshot json metadata """ filename = '' device = j['device'] if j['device'] else 'Desktop' if j['state'] == 'done' and j['image_url']: detail = [device, j['os'], j['os_version'], ...
python
def _build_filename_from_browserstack_json(j): """ Build a useful filename for an image from the screenshot json metadata """ filename = '' device = j['device'] if j['device'] else 'Desktop' if j['state'] == 'done' and j['image_url']: detail = [device, j['os'], j['os_version'], ...
[ "def", "_build_filename_from_browserstack_json", "(", "j", ")", ":", "filename", "=", "''", "device", "=", "j", "[", "'device'", "]", "if", "j", "[", "'device'", "]", "else", "'Desktop'", "if", "j", "[", "'state'", "]", "==", "'done'", "and", "j", "[", ...
Build a useful filename for an image from the screenshot json metadata
[ "Build", "a", "useful", "filename", "for", "an", "image", "from", "the", "screenshot", "json", "metadata" ]
598358fc5b9a41678b3f913f2c082a288011322d
https://github.com/cmck/pybrowserstack-screenshots/blob/598358fc5b9a41678b3f913f2c082a288011322d/client.py#L59-L69
51,576
cmck/pybrowserstack-screenshots
client.py
_long_image_slice
def _long_image_slice(in_filepath, out_filepath, slice_size): """ Slice an image into parts slice_size tall. """ print 'slicing image: {0}'.format(in_filepath) img = Image.open(in_filepath) width, height = img.size upper = 0 left = 0 slices = int(math.ceil(height / slice_size)) count = ...
python
def _long_image_slice(in_filepath, out_filepath, slice_size): """ Slice an image into parts slice_size tall. """ print 'slicing image: {0}'.format(in_filepath) img = Image.open(in_filepath) width, height = img.size upper = 0 left = 0 slices = int(math.ceil(height / slice_size)) count = ...
[ "def", "_long_image_slice", "(", "in_filepath", ",", "out_filepath", ",", "slice_size", ")", ":", "print", "'slicing image: {0}'", ".", "format", "(", "in_filepath", ")", "img", "=", "Image", ".", "open", "(", "in_filepath", ")", "width", ",", "height", "=", ...
Slice an image into parts slice_size tall.
[ "Slice", "an", "image", "into", "parts", "slice_size", "tall", "." ]
598358fc5b9a41678b3f913f2c082a288011322d
https://github.com/cmck/pybrowserstack-screenshots/blob/598358fc5b9a41678b3f913f2c082a288011322d/client.py#L72-L95
51,577
cmck/pybrowserstack-screenshots
client.py
_purge
def _purge(dir, pattern, reason=''): """ delete files in dir that match pattern """ for f in os.listdir(dir): if re.search(pattern, f): print "Purging file {0}. {1}".format(f, reason) os.remove(os.path.join(dir, f))
python
def _purge(dir, pattern, reason=''): """ delete files in dir that match pattern """ for f in os.listdir(dir): if re.search(pattern, f): print "Purging file {0}. {1}".format(f, reason) os.remove(os.path.join(dir, f))
[ "def", "_purge", "(", "dir", ",", "pattern", ",", "reason", "=", "''", ")", ":", "for", "f", "in", "os", ".", "listdir", "(", "dir", ")", ":", "if", "re", ".", "search", "(", "pattern", ",", "f", ")", ":", "print", "\"Purging file {0}. {1}\"", ".",...
delete files in dir that match pattern
[ "delete", "files", "in", "dir", "that", "match", "pattern" ]
598358fc5b9a41678b3f913f2c082a288011322d
https://github.com/cmck/pybrowserstack-screenshots/blob/598358fc5b9a41678b3f913f2c082a288011322d/client.py#L127-L132
51,578
CameronLonsdale/lantern
lantern/modules/simplesubstitution.py
crack
def crack(ciphertext, *fitness_functions, ntrials=30, nswaps=3000): """Break ``ciphertext`` using hill climbing. Note: Currently ntrails and nswaps default to magic numbers. Generally the trend is, the longer the text, the lower the number of trials you need to run, because the hill cli...
python
def crack(ciphertext, *fitness_functions, ntrials=30, nswaps=3000): """Break ``ciphertext`` using hill climbing. Note: Currently ntrails and nswaps default to magic numbers. Generally the trend is, the longer the text, the lower the number of trials you need to run, because the hill cli...
[ "def", "crack", "(", "ciphertext", ",", "*", "fitness_functions", ",", "ntrials", "=", "30", ",", "nswaps", "=", "3000", ")", ":", "if", "ntrials", "<=", "0", "or", "nswaps", "<=", "0", ":", "raise", "ValueError", "(", "\"ntrials and nswaps must be positive ...
Break ``ciphertext`` using hill climbing. Note: Currently ntrails and nswaps default to magic numbers. Generally the trend is, the longer the text, the lower the number of trials you need to run, because the hill climbing will lead to the best answer faster. Because randomness is in...
[ "Break", "ciphertext", "using", "hill", "climbing", "." ]
235e163e96bf0719d49c54204ee576b2ca93abb6
https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/modules/simplesubstitution.py#L11-L60
51,579
CameronLonsdale/lantern
lantern/modules/simplesubstitution.py
decrypt
def decrypt(key, ciphertext): """Decrypt Simple Substitution enciphered ``ciphertext`` using ``key``. Example: >>> decrypt("PQSTUVWXYZCODEBRAKINGFHJLM", "XUOOB") HELLO Args: key (iterable): The key to use ciphertext (str): The text to decrypt Returns: Decrypted...
python
def decrypt(key, ciphertext): """Decrypt Simple Substitution enciphered ``ciphertext`` using ``key``. Example: >>> decrypt("PQSTUVWXYZCODEBRAKINGFHJLM", "XUOOB") HELLO Args: key (iterable): The key to use ciphertext (str): The text to decrypt Returns: Decrypted...
[ "def", "decrypt", "(", "key", ",", "ciphertext", ")", ":", "# TODO: Is it worth keeping this here I should I only accept strings?", "key", "=", "''", ".", "join", "(", "key", ")", "alphabet", "=", "string", ".", "ascii_letters", "cipher_alphabet", "=", "key", ".", ...
Decrypt Simple Substitution enciphered ``ciphertext`` using ``key``. Example: >>> decrypt("PQSTUVWXYZCODEBRAKINGFHJLM", "XUOOB") HELLO Args: key (iterable): The key to use ciphertext (str): The text to decrypt Returns: Decrypted ciphertext
[ "Decrypt", "Simple", "Substitution", "enciphered", "ciphertext", "using", "key", "." ]
235e163e96bf0719d49c54204ee576b2ca93abb6
https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/modules/simplesubstitution.py#L63-L81
51,580
faulkner/sphero
sphero/core.py
Sphero.set_heading
def set_heading(self, value): """value can be between 0 and 359""" return self.write(request.SetHeading(self.seq, value))
python
def set_heading(self, value): """value can be between 0 and 359""" return self.write(request.SetHeading(self.seq, value))
[ "def", "set_heading", "(", "self", ",", "value", ")", ":", "return", "self", ".", "write", "(", "request", ".", "SetHeading", "(", "self", ".", "seq", ",", "value", ")", ")" ]
value can be between 0 and 359
[ "value", "can", "be", "between", "0", "and", "359" ]
a7663df1804ae758e650a04770d50f607be486ae
https://github.com/faulkner/sphero/blob/a7663df1804ae758e650a04770d50f607be486ae/sphero/core.py#L139-L141
51,581
faulkner/sphero
sphero/core.py
Sphero.set_back_led_output
def set_back_led_output(self, value): """value can be between 0x00 and 0xFF""" return self.write(request.SetBackLEDOutput(self.seq, value))
python
def set_back_led_output(self, value): """value can be between 0x00 and 0xFF""" return self.write(request.SetBackLEDOutput(self.seq, value))
[ "def", "set_back_led_output", "(", "self", ",", "value", ")", ":", "return", "self", ".", "write", "(", "request", ".", "SetBackLEDOutput", "(", "self", ".", "seq", ",", "value", ")", ")" ]
value can be between 0x00 and 0xFF
[ "value", "can", "be", "between", "0x00", "and", "0xFF" ]
a7663df1804ae758e650a04770d50f607be486ae
https://github.com/faulkner/sphero/blob/a7663df1804ae758e650a04770d50f607be486ae/sphero/core.py#L178-L180
51,582
faulkner/sphero
sphero/core.py
Sphero.roll
def roll(self, speed, heading, state=1): """ speed can have value between 0x00 and 0xFF heading can have value between 0 and 359 """ return self.write(request.Roll(self.seq, speed, heading, state ))
python
def roll(self, speed, heading, state=1): """ speed can have value between 0x00 and 0xFF heading can have value between 0 and 359 """ return self.write(request.Roll(self.seq, speed, heading, state ))
[ "def", "roll", "(", "self", ",", "speed", ",", "heading", ",", "state", "=", "1", ")", ":", "return", "self", ".", "write", "(", "request", ".", "Roll", "(", "self", ".", "seq", ",", "speed", ",", "heading", ",", "state", ")", ")" ]
speed can have value between 0x00 and 0xFF heading can have value between 0 and 359
[ "speed", "can", "have", "value", "between", "0x00", "and", "0xFF", "heading", "can", "have", "value", "between", "0", "and", "359" ]
a7663df1804ae758e650a04770d50f607be486ae
https://github.com/faulkner/sphero/blob/a7663df1804ae758e650a04770d50f607be486ae/sphero/core.py#L182-L188
51,583
secnot/django-isbn-field
isbn_field/validators.py
ISBNValidator
def ISBNValidator(raw_isbn): """ Check string is a valid ISBN number""" isbn_to_check = raw_isbn.replace('-', '').replace(' ', '') if not isinstance(isbn_to_check, string_types): raise ValidationError(_(u'Invalid ISBN: Not a string')) if len(isbn_to_check) != 10 and len(isbn_to_check) != 13: ...
python
def ISBNValidator(raw_isbn): """ Check string is a valid ISBN number""" isbn_to_check = raw_isbn.replace('-', '').replace(' ', '') if not isinstance(isbn_to_check, string_types): raise ValidationError(_(u'Invalid ISBN: Not a string')) if len(isbn_to_check) != 10 and len(isbn_to_check) != 13: ...
[ "def", "ISBNValidator", "(", "raw_isbn", ")", ":", "isbn_to_check", "=", "raw_isbn", ".", "replace", "(", "'-'", ",", "''", ")", ".", "replace", "(", "' '", ",", "''", ")", "if", "not", "isinstance", "(", "isbn_to_check", ",", "string_types", ")", ":", ...
Check string is a valid ISBN number
[ "Check", "string", "is", "a", "valid", "ISBN", "number" ]
203b7c94a644ab9901370b615d995c2f388219f5
https://github.com/secnot/django-isbn-field/blob/203b7c94a644ab9901370b615d995c2f388219f5/isbn_field/validators.py#L7-L23
51,584
mryellow/maze_explorer
mazeexp/engine/world_rewards.py
WorldRewards.reward_battery
def reward_battery(self): """ Add a battery level reward """ if not 'battery' in self.mode: return mode = self.mode['battery'] if mode and mode and self.__test_cond(mode): self.logger.debug('Battery out') self.player.stats['reward'] += ...
python
def reward_battery(self): """ Add a battery level reward """ if not 'battery' in self.mode: return mode = self.mode['battery'] if mode and mode and self.__test_cond(mode): self.logger.debug('Battery out') self.player.stats['reward'] += ...
[ "def", "reward_battery", "(", "self", ")", ":", "if", "not", "'battery'", "in", "self", ".", "mode", ":", "return", "mode", "=", "self", ".", "mode", "[", "'battery'", "]", "if", "mode", "and", "mode", "and", "self", ".", "__test_cond", "(", "mode", ...
Add a battery level reward
[ "Add", "a", "battery", "level", "reward" ]
ab8a25ccd05105d2fe57e0213d690cfc07e45827
https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world_rewards.py#L16-L27
51,585
mryellow/maze_explorer
mazeexp/engine/world_rewards.py
WorldRewards.reward_item
def reward_item(self, item_type): """ Add a food collision reward """ assert isinstance(item_type, str) if not 'items' in self.mode: return mode = self.mode['items'] if mode and mode[item_type] and self.__test_cond(mode[item_type]): self.l...
python
def reward_item(self, item_type): """ Add a food collision reward """ assert isinstance(item_type, str) if not 'items' in self.mode: return mode = self.mode['items'] if mode and mode[item_type] and self.__test_cond(mode[item_type]): self.l...
[ "def", "reward_item", "(", "self", ",", "item_type", ")", ":", "assert", "isinstance", "(", "item_type", ",", "str", ")", "if", "not", "'items'", "in", "self", ".", "mode", ":", "return", "mode", "=", "self", ".", "mode", "[", "'items'", "]", "if", "...
Add a food collision reward
[ "Add", "a", "food", "collision", "reward" ]
ab8a25ccd05105d2fe57e0213d690cfc07e45827
https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world_rewards.py#L29-L43
51,586
mryellow/maze_explorer
mazeexp/engine/world_rewards.py
WorldRewards.reward_wall
def reward_wall(self): """ Add a wall collision reward """ if not 'wall' in self.mode: return mode = self.mode['wall'] if mode and mode and self.__test_cond(mode): self.logger.debug("Wall {x}/{y}'".format(x=self.bumped_x, y=self.bumped_y)) ...
python
def reward_wall(self): """ Add a wall collision reward """ if not 'wall' in self.mode: return mode = self.mode['wall'] if mode and mode and self.__test_cond(mode): self.logger.debug("Wall {x}/{y}'".format(x=self.bumped_x, y=self.bumped_y)) ...
[ "def", "reward_wall", "(", "self", ")", ":", "if", "not", "'wall'", "in", "self", ".", "mode", ":", "return", "mode", "=", "self", ".", "mode", "[", "'wall'", "]", "if", "mode", "and", "mode", "and", "self", ".", "__test_cond", "(", "mode", ")", ":...
Add a wall collision reward
[ "Add", "a", "wall", "collision", "reward" ]
ab8a25ccd05105d2fe57e0213d690cfc07e45827
https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world_rewards.py#L45-L56
51,587
mryellow/maze_explorer
mazeexp/engine/world_rewards.py
WorldRewards.reward_explore
def reward_explore(self): """ Add an exploration reward """ if not 'explore' in self.mode: return mode = self.mode['explore'] if mode and mode['reward'] and self.__test_cond(mode): self.player.stats['reward'] += mode['reward'] self.play...
python
def reward_explore(self): """ Add an exploration reward """ if not 'explore' in self.mode: return mode = self.mode['explore'] if mode and mode['reward'] and self.__test_cond(mode): self.player.stats['reward'] += mode['reward'] self.play...
[ "def", "reward_explore", "(", "self", ")", ":", "if", "not", "'explore'", "in", "self", ".", "mode", ":", "return", "mode", "=", "self", ".", "mode", "[", "'explore'", "]", "if", "mode", "and", "mode", "[", "'reward'", "]", "and", "self", ".", "__tes...
Add an exploration reward
[ "Add", "an", "exploration", "reward" ]
ab8a25ccd05105d2fe57e0213d690cfc07e45827
https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world_rewards.py#L58-L69
51,588
mryellow/maze_explorer
mazeexp/engine/world_rewards.py
WorldRewards.reward_goal
def reward_goal(self): """ Add an end goal reward """ if not 'goal' in self.mode: return mode = self.mode['goal'] if mode and mode['reward'] and self.__test_cond(mode): if mode['reward'] > 0: self.logger.info("Escaped!!") ...
python
def reward_goal(self): """ Add an end goal reward """ if not 'goal' in self.mode: return mode = self.mode['goal'] if mode and mode['reward'] and self.__test_cond(mode): if mode['reward'] > 0: self.logger.info("Escaped!!") ...
[ "def", "reward_goal", "(", "self", ")", ":", "if", "not", "'goal'", "in", "self", ".", "mode", ":", "return", "mode", "=", "self", ".", "mode", "[", "'goal'", "]", "if", "mode", "and", "mode", "[", "'reward'", "]", "and", "self", ".", "__test_cond", ...
Add an end goal reward
[ "Add", "an", "end", "goal", "reward" ]
ab8a25ccd05105d2fe57e0213d690cfc07e45827
https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world_rewards.py#L71-L84
51,589
mryellow/maze_explorer
mazeexp/engine/world_rewards.py
WorldRewards.reward_proximity
def reward_proximity(self): """ Add a wall proximity reward """ if not 'proximity' in self.mode: return mode = self.mode['proximity'] # Calculate proximity reward reward = 0 for sensor in self.player.sensors: if sensor.sensed_type ...
python
def reward_proximity(self): """ Add a wall proximity reward """ if not 'proximity' in self.mode: return mode = self.mode['proximity'] # Calculate proximity reward reward = 0 for sensor in self.player.sensors: if sensor.sensed_type ...
[ "def", "reward_proximity", "(", "self", ")", ":", "if", "not", "'proximity'", "in", "self", ".", "mode", ":", "return", "mode", "=", "self", ".", "mode", "[", "'proximity'", "]", "# Calculate proximity reward", "reward", "=", "0", "for", "sensor", "in", "s...
Add a wall proximity reward
[ "Add", "a", "wall", "proximity", "reward" ]
ab8a25ccd05105d2fe57e0213d690cfc07e45827
https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world_rewards.py#L86-L111
51,590
resync/resync
resync/client.py
Client.sitemap
def sitemap(self): """Return the sitemap URI based on maps or explicit settings.""" if (self.sitemap_name is not None): return(self.sitemap_name) return(self.sitemap_uri(self.resource_list_name))
python
def sitemap(self): """Return the sitemap URI based on maps or explicit settings.""" if (self.sitemap_name is not None): return(self.sitemap_name) return(self.sitemap_uri(self.resource_list_name))
[ "def", "sitemap", "(", "self", ")", ":", "if", "(", "self", ".", "sitemap_name", "is", "not", "None", ")", ":", "return", "(", "self", ".", "sitemap_name", ")", "return", "(", "self", ".", "sitemap_uri", "(", "self", ".", "resource_list_name", ")", ")"...
Return the sitemap URI based on maps or explicit settings.
[ "Return", "the", "sitemap", "URI", "based", "on", "maps", "or", "explicit", "settings", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L87-L91
51,591
resync/resync
resync/client.py
Client.read_resource_list
def read_resource_list(self, uri): """Read resource list from specified URI else raise exception.""" self.logger.info("Reading resource list %s" % (uri)) try: resource_list = ResourceList(allow_multifile=self.allow_multifile, mapper=self.mappe...
python
def read_resource_list(self, uri): """Read resource list from specified URI else raise exception.""" self.logger.info("Reading resource list %s" % (uri)) try: resource_list = ResourceList(allow_multifile=self.allow_multifile, mapper=self.mappe...
[ "def", "read_resource_list", "(", "self", ",", "uri", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Reading resource list %s\"", "%", "(", "uri", ")", ")", "try", ":", "resource_list", "=", "ResourceList", "(", "allow_multifile", "=", "self", ".", ...
Read resource list from specified URI else raise exception.
[ "Read", "resource", "list", "from", "specified", "URI", "else", "raise", "exception", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L93-L104
51,592
resync/resync
resync/client.py
Client.find_resource_list_from_source_description
def find_resource_list_from_source_description(self, uri): """Read source description to find resource list. Raises a ClientError in cases where the client might look for a source description in another location, but a ClientFatalError if a source description is found but there is some ...
python
def find_resource_list_from_source_description(self, uri): """Read source description to find resource list. Raises a ClientError in cases where the client might look for a source description in another location, but a ClientFatalError if a source description is found but there is some ...
[ "def", "find_resource_list_from_source_description", "(", "self", ",", "uri", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Reading source description %s\"", "%", "(", "uri", ")", ")", "try", ":", "sd", "=", "SourceDescription", "(", ")", "sd", ".", ...
Read source description to find resource list. Raises a ClientError in cases where the client might look for a source description in another location, but a ClientFatalError if a source description is found but there is some problem using it.
[ "Read", "source", "description", "to", "find", "resource", "list", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L106-L131
51,593
resync/resync
resync/client.py
Client.find_resource_list_from_capability_list
def find_resource_list_from_capability_list(self, uri): """Read capability list to find resource list. Raises a ClientError in cases where the client might look for a capability list in another location, but a ClientFatalError if a capability list is found but there is some problem usin...
python
def find_resource_list_from_capability_list(self, uri): """Read capability list to find resource list. Raises a ClientError in cases where the client might look for a capability list in another location, but a ClientFatalError if a capability list is found but there is some problem usin...
[ "def", "find_resource_list_from_capability_list", "(", "self", ",", "uri", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Reading capability list %s\"", "%", "(", "uri", ")", ")", "try", ":", "cl", "=", "CapabilityList", "(", ")", "cl", ".", "read", ...
Read capability list to find resource list. Raises a ClientError in cases where the client might look for a capability list in another location, but a ClientFatalError if a capability list is found but there is some problem using it.
[ "Read", "capability", "list", "to", "find", "resource", "list", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L133-L152
51,594
resync/resync
resync/client.py
Client.find_resource_list
def find_resource_list(self): """Finf resource list by hueristics, returns ResourceList object. 1. Use explicitly specified self.sitemap_name (and fail if that doesn't work) 2. Use explicitly specified self.capability_list_uri (and fail is that doesn't work) 3. L...
python
def find_resource_list(self): """Finf resource list by hueristics, returns ResourceList object. 1. Use explicitly specified self.sitemap_name (and fail if that doesn't work) 2. Use explicitly specified self.capability_list_uri (and fail is that doesn't work) 3. L...
[ "def", "find_resource_list", "(", "self", ")", ":", "# 1 & 2", "if", "(", "self", ".", "sitemap_name", "is", "not", "None", ")", ":", "return", "(", "self", ".", "read_resource_list", "(", "self", ".", "sitemap_name", ")", ")", "if", "(", "self", ".", ...
Finf resource list by hueristics, returns ResourceList object. 1. Use explicitly specified self.sitemap_name (and fail if that doesn't work) 2. Use explicitly specified self.capability_list_uri (and fail is that doesn't work) 3. Look for base_url/.well-known/resourcesync...
[ "Finf", "resource", "list", "by", "hueristics", "returns", "ResourceList", "object", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L154-L198
51,595
resync/resync
resync/client.py
Client.build_resource_list
def build_resource_list(self, paths=None, set_path=False): """Return a resource list for files on local disk. The set of files is taken by disk scan from the paths specified or else defaults to the paths specified in the current mappings paths - override paths from mappings if specifie...
python
def build_resource_list(self, paths=None, set_path=False): """Return a resource list for files on local disk. The set of files is taken by disk scan from the paths specified or else defaults to the paths specified in the current mappings paths - override paths from mappings if specifie...
[ "def", "build_resource_list", "(", "self", ",", "paths", "=", "None", ",", "set_path", "=", "False", ")", ":", "# 0. Sanity checks, parse paths is specified", "if", "(", "len", "(", "self", ".", "mapper", ")", "<", "1", ")", ":", "raise", "ClientFatalError", ...
Return a resource list for files on local disk. The set of files is taken by disk scan from the paths specified or else defaults to the paths specified in the current mappings paths - override paths from mappings if specified set_path - set true to set the path information for each re...
[ "Return", "a", "resource", "list", "for", "files", "on", "local", "disk", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L200-L235
51,596
resync/resync
resync/client.py
Client.update_resource
def update_resource(self, resource, filename, change=None): """Update resource from uri to filename on local system. Update means three things: 1. GET resources 2. set mtime in local time to be equal to timestamp in UTC (should perhaps or at least warn if different from LastModi...
python
def update_resource(self, resource, filename, change=None): """Update resource from uri to filename on local system. Update means three things: 1. GET resources 2. set mtime in local time to be equal to timestamp in UTC (should perhaps or at least warn if different from LastModi...
[ "def", "update_resource", "(", "self", ",", "resource", ",", "filename", ",", "change", "=", "None", ")", ":", "path", "=", "os", ".", "path", ".", "dirname", "(", "filename", ")", "distutils", ".", "dir_util", ".", "mkpath", "(", "path", ")", "num_upd...
Update resource from uri to filename on local system. Update means three things: 1. GET resources 2. set mtime in local time to be equal to timestamp in UTC (should perhaps or at least warn if different from LastModified from the GET response instead but maybe warn if different ...
[ "Update", "resource", "from", "uri", "to", "filename", "on", "local", "system", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L476-L546
51,597
resync/resync
resync/client.py
Client.check_hashes
def check_hashes(self, filename, resource): """Check all hashes present in self.hashes _and_ resource object. Simply shows warning for mismatch, does not raise exception or otherwise stop process. """ # which hashes to calculate? hashes = [] if ('md5' in self.has...
python
def check_hashes(self, filename, resource): """Check all hashes present in self.hashes _and_ resource object. Simply shows warning for mismatch, does not raise exception or otherwise stop process. """ # which hashes to calculate? hashes = [] if ('md5' in self.has...
[ "def", "check_hashes", "(", "self", ",", "filename", ",", "resource", ")", ":", "# which hashes to calculate?", "hashes", "=", "[", "]", "if", "(", "'md5'", "in", "self", ".", "hashes", "and", "resource", ".", "md5", "is", "not", "None", ")", ":", "hashe...
Check all hashes present in self.hashes _and_ resource object. Simply shows warning for mismatch, does not raise exception or otherwise stop process.
[ "Check", "all", "hashes", "present", "in", "self", ".", "hashes", "_and_", "resource", "object", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L548-L576
51,598
resync/resync
resync/client.py
Client.delete_resource
def delete_resource(self, resource, filename, allow_deletion=False): """Delete copy of resource in filename on local system. Will only actually do the deletion if allow_deletion is True. Regardless of whether the deletion occurs, self.last_timestamp will be updated if the resource.times...
python
def delete_resource(self, resource, filename, allow_deletion=False): """Delete copy of resource in filename on local system. Will only actually do the deletion if allow_deletion is True. Regardless of whether the deletion occurs, self.last_timestamp will be updated if the resource.times...
[ "def", "delete_resource", "(", "self", ",", "resource", ",", "filename", ",", "allow_deletion", "=", "False", ")", ":", "num_deleted", "=", "0", "uri", "=", "resource", ".", "uri", "if", "(", "resource", ".", "timestamp", "is", "not", "None", "and", "res...
Delete copy of resource in filename on local system. Will only actually do the deletion if allow_deletion is True. Regardless of whether the deletion occurs, self.last_timestamp will be updated if the resource.timestamp is later than the current value. Returns the number of files actua...
[ "Delete", "copy", "of", "resource", "in", "filename", "on", "local", "system", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L578-L618
51,599
resync/resync
resync/client.py
Client.parse_document
def parse_document(self): """Parse any ResourceSync document and show information. Will use sitemap URI taken either from explicit self.sitemap_name or derived from the mappings supplied. """ s = Sitemap() self.logger.info("Reading sitemap(s) from %s ..." % (self.sitemap...
python
def parse_document(self): """Parse any ResourceSync document and show information. Will use sitemap URI taken either from explicit self.sitemap_name or derived from the mappings supplied. """ s = Sitemap() self.logger.info("Reading sitemap(s) from %s ..." % (self.sitemap...
[ "def", "parse_document", "(", "self", ")", ":", "s", "=", "Sitemap", "(", ")", "self", ".", "logger", ".", "info", "(", "\"Reading sitemap(s) from %s ...\"", "%", "(", "self", ".", "sitemap", ")", ")", "try", ":", "list", "=", "s", ".", "parse_xml", "(...
Parse any ResourceSync document and show information. Will use sitemap URI taken either from explicit self.sitemap_name or derived from the mappings supplied.
[ "Parse", "any", "ResourceSync", "document", "and", "show", "information", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L620-L652