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
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
trentm/cmdln
examples/svn.py
MySVN.do_mkdir
def do_mkdir(self, subcmd, opts, *args): """Create a new directory under version control. usage: 1. mkdir PATH... 2. mkdir URL... Create version controlled directories. 1. Each directory specified by a working copy PATH is created locally ...
python
def do_mkdir(self, subcmd, opts, *args): """Create a new directory under version control. usage: 1. mkdir PATH... 2. mkdir URL... Create version controlled directories. 1. Each directory specified by a working copy PATH is created locally ...
[ "def", "do_mkdir", "(", "self", ",", "subcmd", ",", "opts", ",", "*", "args", ")", ":", "print", "\"'svn %s' opts: %s\"", "%", "(", "subcmd", ",", "opts", ")", "print", "\"'svn %s' args: %s\"", "%", "(", "subcmd", ",", "args", ")" ]
Create a new directory under version control. usage: 1. mkdir PATH... 2. mkdir URL... Create version controlled directories. 1. Each directory specified by a working copy PATH is created locally and scheduled for addition upon the next commit....
[ "Create", "a", "new", "directory", "under", "version", "control", "." ]
55e980cf52c9b03e62d2349a7e62c9101d08ae10
https://github.com/trentm/cmdln/blob/55e980cf52c9b03e62d2349a7e62c9101d08ae10/examples/svn.py#L628-L648
train
65,600
trentm/cmdln
examples/svn.py
MySVN.do_propdel
def do_propdel(self, subcmd, opts, *args): """Remove PROPNAME from files, dirs, or revisions. usage: 1. propdel PROPNAME [PATH...] 2. propdel PROPNAME --revprop -r REV [URL] 1. Removes versioned props in working copy. 2. Removes unversioned remote prop o...
python
def do_propdel(self, subcmd, opts, *args): """Remove PROPNAME from files, dirs, or revisions. usage: 1. propdel PROPNAME [PATH...] 2. propdel PROPNAME --revprop -r REV [URL] 1. Removes versioned props in working copy. 2. Removes unversioned remote prop o...
[ "def", "do_propdel", "(", "self", ",", "subcmd", ",", "opts", ",", "*", "args", ")", ":", "print", "\"'svn %s' opts: %s\"", "%", "(", "subcmd", ",", "opts", ")", "print", "\"'svn %s' args: %s\"", "%", "(", "subcmd", ",", "args", ")" ]
Remove PROPNAME from files, dirs, or revisions. usage: 1. propdel PROPNAME [PATH...] 2. propdel PROPNAME --revprop -r REV [URL] 1. Removes versioned props in working copy. 2. Removes unversioned remote prop on repos revision. ${cmd_option_list}
[ "Remove", "PROPNAME", "from", "files", "dirs", "or", "revisions", "." ]
55e980cf52c9b03e62d2349a7e62c9101d08ae10
https://github.com/trentm/cmdln/blob/55e980cf52c9b03e62d2349a7e62c9101d08ae10/examples/svn.py#L713-L726
train
65,601
trentm/cmdln
examples/svn.py
MySVN.do_propedit
def do_propedit(self, subcmd, opts, *args): """Edit property PROPNAME with an external editor on targets. usage: 1. propedit PROPNAME PATH... 2. propedit PROPNAME --revprop -r REV [URL] 1. Edits versioned props in working copy. 2. Edits unversioned remot...
python
def do_propedit(self, subcmd, opts, *args): """Edit property PROPNAME with an external editor on targets. usage: 1. propedit PROPNAME PATH... 2. propedit PROPNAME --revprop -r REV [URL] 1. Edits versioned props in working copy. 2. Edits unversioned remot...
[ "def", "do_propedit", "(", "self", ",", "subcmd", ",", "opts", ",", "*", "args", ")", ":", "print", "\"'svn %s' opts: %s\"", "%", "(", "subcmd", ",", "opts", ")", "print", "\"'svn %s' args: %s\"", "%", "(", "subcmd", ",", "args", ")" ]
Edit property PROPNAME with an external editor on targets. usage: 1. propedit PROPNAME PATH... 2. propedit PROPNAME --revprop -r REV [URL] 1. Edits versioned props in working copy. 2. Edits unversioned remote prop on repos revision. ${cmd_option_list}
[ "Edit", "property", "PROPNAME", "with", "an", "external", "editor", "on", "targets", "." ]
55e980cf52c9b03e62d2349a7e62c9101d08ae10
https://github.com/trentm/cmdln/blob/55e980cf52c9b03e62d2349a7e62c9101d08ae10/examples/svn.py#L749-L762
train
65,602
trentm/cmdln
examples/svn.py
MySVN.do_propget
def do_propget(self, subcmd, opts, *args): """Print value of PROPNAME on files, dirs, or revisions. usage: 1. propget PROPNAME [PATH...] 2. propget PROPNAME --revprop -r REV [URL] 1. Prints versioned prop in working copy. 2. Prints unversioned remote pro...
python
def do_propget(self, subcmd, opts, *args): """Print value of PROPNAME on files, dirs, or revisions. usage: 1. propget PROPNAME [PATH...] 2. propget PROPNAME --revprop -r REV [URL] 1. Prints versioned prop in working copy. 2. Prints unversioned remote pro...
[ "def", "do_propget", "(", "self", ",", "subcmd", ",", "opts", ",", "*", "args", ")", ":", "print", "\"'svn %s' opts: %s\"", "%", "(", "subcmd", ",", "opts", ")", "print", "\"'svn %s' args: %s\"", "%", "(", "subcmd", ",", "args", ")" ]
Print value of PROPNAME on files, dirs, or revisions. usage: 1. propget PROPNAME [PATH...] 2. propget PROPNAME --revprop -r REV [URL] 1. Prints versioned prop in working copy. 2. Prints unversioned remote prop on repos revision. By default, this...
[ "Print", "value", "of", "PROPNAME", "on", "files", "dirs", "or", "revisions", "." ]
55e980cf52c9b03e62d2349a7e62c9101d08ae10
https://github.com/trentm/cmdln/blob/55e980cf52c9b03e62d2349a7e62c9101d08ae10/examples/svn.py#L783-L803
train
65,603
trentm/cmdln
examples/svn.py
MySVN.do_proplist
def do_proplist(self, subcmd, opts, *args): """List all properties on files, dirs, or revisions. usage: 1. proplist [PATH...] 2. proplist --revprop -r REV [URL] 1. Lists versioned props in working copy. 2. Lists unversioned remote props on repos revision...
python
def do_proplist(self, subcmd, opts, *args): """List all properties on files, dirs, or revisions. usage: 1. proplist [PATH...] 2. proplist --revprop -r REV [URL] 1. Lists versioned props in working copy. 2. Lists unversioned remote props on repos revision...
[ "def", "do_proplist", "(", "self", ",", "subcmd", ",", "opts", ",", "*", "args", ")", ":", "print", "\"'svn %s' opts: %s\"", "%", "(", "subcmd", ",", "opts", ")", "print", "\"'svn %s' args: %s\"", "%", "(", "subcmd", ",", "args", ")" ]
List all properties on files, dirs, or revisions. usage: 1. proplist [PATH...] 2. proplist --revprop -r REV [URL] 1. Lists versioned props in working copy. 2. Lists unversioned remote props on repos revision. ${cmd_option_list}
[ "List", "all", "properties", "on", "files", "dirs", "or", "revisions", "." ]
55e980cf52c9b03e62d2349a7e62c9101d08ae10
https://github.com/trentm/cmdln/blob/55e980cf52c9b03e62d2349a7e62c9101d08ae10/examples/svn.py#L826-L839
train
65,604
trentm/cmdln
examples/svn.py
MySVN.do_propset
def do_propset(self, subcmd, opts, *args): """Set PROPNAME to PROPVAL on files, dirs, or revisions. usage: 1. propset PROPNAME [PROPVAL | -F VALFILE] PATH... 2. propset PROPNAME --revprop -r REV [PROPVAL | -F VALFILE] [URL] 1. Creates a versioned, local propchan...
python
def do_propset(self, subcmd, opts, *args): """Set PROPNAME to PROPVAL on files, dirs, or revisions. usage: 1. propset PROPNAME [PROPVAL | -F VALFILE] PATH... 2. propset PROPNAME --revprop -r REV [PROPVAL | -F VALFILE] [URL] 1. Creates a versioned, local propchan...
[ "def", "do_propset", "(", "self", ",", "subcmd", ",", "opts", ",", "*", "args", ")", ":", "print", "\"'svn %s' opts: %s\"", "%", "(", "subcmd", ",", "opts", ")", "print", "\"'svn %s' args: %s\"", "%", "(", "subcmd", ",", "args", ")" ]
Set PROPNAME to PROPVAL on files, dirs, or revisions. usage: 1. propset PROPNAME [PROPVAL | -F VALFILE] PATH... 2. propset PROPNAME --revprop -r REV [PROPVAL | -F VALFILE] [URL] 1. Creates a versioned, local propchange in working copy. 2. Creates an unversioned,...
[ "Set", "PROPNAME", "to", "PROPVAL", "on", "files", "dirs", "or", "revisions", "." ]
55e980cf52c9b03e62d2349a7e62c9101d08ae10
https://github.com/trentm/cmdln/blob/55e980cf52c9b03e62d2349a7e62c9101d08ae10/examples/svn.py#L868-L907
train
65,605
trentm/cmdln
examples/svn.py
MySVN.do_resolved
def do_resolved(self, subcmd, opts, *args): """Remove 'conflicted' state on working copy files or directories. usage: resolved PATH... Note: this subcommand does not semantically resolve conflicts or remove conflict markers; it merely removes the conflict-related ...
python
def do_resolved(self, subcmd, opts, *args): """Remove 'conflicted' state on working copy files or directories. usage: resolved PATH... Note: this subcommand does not semantically resolve conflicts or remove conflict markers; it merely removes the conflict-related ...
[ "def", "do_resolved", "(", "self", ",", "subcmd", ",", "opts", ",", "*", "args", ")", ":", "print", "\"'svn %s' opts: %s\"", "%", "(", "subcmd", ",", "opts", ")", "print", "\"'svn %s' args: %s\"", "%", "(", "subcmd", ",", "args", ")" ]
Remove 'conflicted' state on working copy files or directories. usage: resolved PATH... Note: this subcommand does not semantically resolve conflicts or remove conflict markers; it merely removes the conflict-related artifact files and allows PATH to be committed a...
[ "Remove", "conflicted", "state", "on", "working", "copy", "files", "or", "directories", "." ]
55e980cf52c9b03e62d2349a7e62c9101d08ae10
https://github.com/trentm/cmdln/blob/55e980cf52c9b03e62d2349a7e62c9101d08ae10/examples/svn.py#L917-L930
train
65,606
trentm/cmdln
examples/svn.py
MySVN.do_status
def do_status(self, subcmd, opts, *args): """Print the status of working copy files and directories. usage: status [PATH...] With no args, print only locally modified items (no network access). With -u, add working revision and server out-of-date information. ...
python
def do_status(self, subcmd, opts, *args): """Print the status of working copy files and directories. usage: status [PATH...] With no args, print only locally modified items (no network access). With -u, add working revision and server out-of-date information. ...
[ "def", "do_status", "(", "self", ",", "subcmd", ",", "opts", ",", "*", "args", ")", ":", "print", "\"'svn %s' opts: %s\"", "%", "(", "subcmd", ",", "opts", ")", "print", "\"'svn %s' args: %s\"", "%", "(", "subcmd", ",", "args", ")" ]
Print the status of working copy files and directories. usage: status [PATH...] With no args, print only locally modified items (no network access). With -u, add working revision and server out-of-date information. With -v, print full revision information on every i...
[ "Print", "the", "status", "of", "working", "copy", "files", "and", "directories", "." ]
55e980cf52c9b03e62d2349a7e62c9101d08ae10
https://github.com/trentm/cmdln/blob/55e980cf52c9b03e62d2349a7e62c9101d08ae10/examples/svn.py#L975-L1044
train
65,607
trentm/cmdln
examples/svn.py
MySVN.do_switch
def do_switch(self, subcmd, opts, *args): """Update the working copy to a different URL. usage: 1. switch URL [PATH] 2. switch --relocate FROM TO [PATH...] 1. Update the working copy to mirror a new URL within the repository. This behaviour is similar...
python
def do_switch(self, subcmd, opts, *args): """Update the working copy to a different URL. usage: 1. switch URL [PATH] 2. switch --relocate FROM TO [PATH...] 1. Update the working copy to mirror a new URL within the repository. This behaviour is similar...
[ "def", "do_switch", "(", "self", ",", "subcmd", ",", "opts", ",", "*", "args", ")", ":", "print", "\"'svn %s' opts: %s\"", "%", "(", "subcmd", ",", "opts", ")", "print", "\"'svn %s' args: %s\"", "%", "(", "subcmd", ",", "args", ")" ]
Update the working copy to a different URL. usage: 1. switch URL [PATH] 2. switch --relocate FROM TO [PATH...] 1. Update the working copy to mirror a new URL within the repository. This behaviour is similar to 'svn update', and is the way to move a...
[ "Update", "the", "working", "copy", "to", "a", "different", "URL", "." ]
55e980cf52c9b03e62d2349a7e62c9101d08ae10
https://github.com/trentm/cmdln/blob/55e980cf52c9b03e62d2349a7e62c9101d08ae10/examples/svn.py#L1067-L1086
train
65,608
trentm/cmdln
examples/svn.py
MySVN.do_update
def do_update(self, subcmd, opts, *args): """Bring changes from the repository into the working copy. usage: update [PATH...] If no revision given, bring working copy up-to-date with HEAD rev. Else synchronize working copy to revision given by -r. F...
python
def do_update(self, subcmd, opts, *args): """Bring changes from the repository into the working copy. usage: update [PATH...] If no revision given, bring working copy up-to-date with HEAD rev. Else synchronize working copy to revision given by -r. F...
[ "def", "do_update", "(", "self", ",", "subcmd", ",", "opts", ",", "*", "args", ")", ":", "print", "\"'svn %s' opts: %s\"", "%", "(", "subcmd", ",", "opts", ")", "print", "\"'svn %s' args: %s\"", "%", "(", "subcmd", ",", "args", ")" ]
Bring changes from the repository into the working copy. usage: update [PATH...] If no revision given, bring working copy up-to-date with HEAD rev. Else synchronize working copy to revision given by -r. For each updated item a line will start with a charact...
[ "Bring", "changes", "from", "the", "repository", "into", "the", "working", "copy", "." ]
55e980cf52c9b03e62d2349a7e62c9101d08ae10
https://github.com/trentm/cmdln/blob/55e980cf52c9b03e62d2349a7e62c9101d08ae10/examples/svn.py#L1107-L1131
train
65,609
stefanfoulis/django-class-based-auth-views
class_based_auth_views/utils.py
default_redirect
def default_redirect(request, fallback_url, **kwargs): """ Evaluates a redirect url by consulting GET, POST and the session. """ redirect_field_name = kwargs.get("redirect_field_name", "next") next = request.POST.get(redirect_field_name, request.GET.get(redirect_field_nam...
python
def default_redirect(request, fallback_url, **kwargs): """ Evaluates a redirect url by consulting GET, POST and the session. """ redirect_field_name = kwargs.get("redirect_field_name", "next") next = request.POST.get(redirect_field_name, request.GET.get(redirect_field_nam...
[ "def", "default_redirect", "(", "request", ",", "fallback_url", ",", "*", "*", "kwargs", ")", ":", "redirect_field_name", "=", "kwargs", ".", "get", "(", "\"redirect_field_name\"", ",", "\"next\"", ")", "next", "=", "request", ".", "POST", ".", "get", "(", ...
Evaluates a redirect url by consulting GET, POST and the session.
[ "Evaluates", "a", "redirect", "url", "by", "consulting", "GET", "POST", "and", "the", "session", "." ]
9998e2b8c1e5714c33a774a23c1a07d7a5928597
https://github.com/stefanfoulis/django-class-based-auth-views/blob/9998e2b8c1e5714c33a774a23c1a07d7a5928597/class_based_auth_views/utils.py#L10-L32
train
65,610
maximkulkin/lollipop
lollipop/errors.py
ValidationErrorBuilder.add_error
def add_error(self, path, error): """Add error message for given field path. Example: :: builder = ValidationErrorBuilder() builder.add_error('foo.bar.baz', 'Some error') print builder.errors # => {'foo': {'bar': {'baz': 'Some error'}}} :param s...
python
def add_error(self, path, error): """Add error message for given field path. Example: :: builder = ValidationErrorBuilder() builder.add_error('foo.bar.baz', 'Some error') print builder.errors # => {'foo': {'bar': {'baz': 'Some error'}}} :param s...
[ "def", "add_error", "(", "self", ",", "path", ",", "error", ")", ":", "self", ".", "errors", "=", "merge_errors", "(", "self", ".", "errors", ",", "self", ".", "_make_error", "(", "path", ",", "error", ")", ")" ]
Add error message for given field path. Example: :: builder = ValidationErrorBuilder() builder.add_error('foo.bar.baz', 'Some error') print builder.errors # => {'foo': {'bar': {'baz': 'Some error'}}} :param str path: '.'-separated list of field names ...
[ "Add", "error", "message", "for", "given", "field", "path", "." ]
042e8a24508cc3b28630863253c38ffbfc52c882
https://github.com/maximkulkin/lollipop/blob/042e8a24508cc3b28630863253c38ffbfc52c882/lollipop/errors.py#L147-L160
train
65,611
mwolff44/django-simple-invoice
invoice/utils/friendly_id.py
find_suitable_period
def find_suitable_period(): """ Automatically find a suitable period to use. Factors are best, because they will have 1 left over when dividing SIZE+1. This only needs to be run once, on import. """ # The highest acceptable factor will be the square root of the size. highest_acce...
python
def find_suitable_period(): """ Automatically find a suitable period to use. Factors are best, because they will have 1 left over when dividing SIZE+1. This only needs to be run once, on import. """ # The highest acceptable factor will be the square root of the size. highest_acce...
[ "def", "find_suitable_period", "(", ")", ":", "# The highest acceptable factor will be the square root of the size.", "highest_acceptable_factor", "=", "int", "(", "math", ".", "sqrt", "(", "SIZE", ")", ")", "# Too high a factor (eg SIZE/2) and the interval is too small, too", "#...
Automatically find a suitable period to use. Factors are best, because they will have 1 left over when dividing SIZE+1. This only needs to be run once, on import.
[ "Automatically", "find", "a", "suitable", "period", "to", "use", ".", "Factors", "are", "best", "because", "they", "will", "have", "1", "left", "over", "when", "dividing", "SIZE", "+", "1", ".", "This", "only", "needs", "to", "be", "run", "once", "on", ...
ab14d905a69f37cd27e137c039750e6630bce4ef
https://github.com/mwolff44/django-simple-invoice/blob/ab14d905a69f37cd27e137c039750e6630bce4ef/invoice/utils/friendly_id.py#L55-L75
train
65,612
mwolff44/django-simple-invoice
invoice/utils/friendly_id.py
friendly_number
def friendly_number(num): """ Convert a base 10 number to a base X string. Charcters from VALID_CHARS are chosen, to convert the number to eg base 24, if there are 24 characters to choose from. Use valid chars to choose characters that are friendly, avoiding ones that could be confus...
python
def friendly_number(num): """ Convert a base 10 number to a base X string. Charcters from VALID_CHARS are chosen, to convert the number to eg base 24, if there are 24 characters to choose from. Use valid chars to choose characters that are friendly, avoiding ones that could be confus...
[ "def", "friendly_number", "(", "num", ")", ":", "# Convert to a (shorter) string for human consumption", "string", "=", "\"\"", "# The length of the string can be determined by STRING_LENGTH or by how many", "# characters are necessary to present a base 30 representation of SIZE.", "while", ...
Convert a base 10 number to a base X string. Charcters from VALID_CHARS are chosen, to convert the number to eg base 24, if there are 24 characters to choose from. Use valid chars to choose characters that are friendly, avoiding ones that could be confused in print or over the phone.
[ "Convert", "a", "base", "10", "number", "to", "a", "base", "X", "string", ".", "Charcters", "from", "VALID_CHARS", "are", "chosen", "to", "convert", "the", "number", "to", "eg", "base", "24", "if", "there", "are", "24", "characters", "to", "choose", "fro...
ab14d905a69f37cd27e137c039750e6630bce4ef
https://github.com/mwolff44/django-simple-invoice/blob/ab14d905a69f37cd27e137c039750e6630bce4ef/invoice/utils/friendly_id.py#L89-L105
train
65,613
happyleavesaoc/python-fedexdeliverymanager
fedexdeliverymanager/__init__.py
_login
def _login(session): """Login to Fedex Delivery Manager.""" session.get(LOGIN_REFERER) resp = session.post(LOGIN_URL, { 'user': session.auth.username, 'pwd': session.auth.password }, headers={ 'Referer': LOGIN_REFERER, 'X-Requested-With': 'XMLHttpRequest' }) if re...
python
def _login(session): """Login to Fedex Delivery Manager.""" session.get(LOGIN_REFERER) resp = session.post(LOGIN_URL, { 'user': session.auth.username, 'pwd': session.auth.password }, headers={ 'Referer': LOGIN_REFERER, 'X-Requested-With': 'XMLHttpRequest' }) if re...
[ "def", "_login", "(", "session", ")", ":", "session", ".", "get", "(", "LOGIN_REFERER", ")", "resp", "=", "session", ".", "post", "(", "LOGIN_URL", ",", "{", "'user'", ":", "session", ".", "auth", ".", "username", ",", "'pwd'", ":", "session", ".", "...
Login to Fedex Delivery Manager.
[ "Login", "to", "Fedex", "Delivery", "Manager", "." ]
cff2f1104a86573569500d41e69be54b90b596c6
https://github.com/happyleavesaoc/python-fedexdeliverymanager/blob/cff2f1104a86573569500d41e69be54b90b596c6/fedexdeliverymanager/__init__.py#L71-L86
train
65,614
happyleavesaoc/python-fedexdeliverymanager
fedexdeliverymanager/__init__.py
get_packages
def get_packages(session): """Get packages.""" resp = session.post(TRACKING_URL, { 'data': json.dumps(SHIPMENT_LIST_REQUEST), 'action': SHIPMENT_LIST_ACTION, 'format': SHIPMENT_LIST_FORMAT, 'locale': session.auth.locale, 'version': 1 }) data = resp.json().get('Shi...
python
def get_packages(session): """Get packages.""" resp = session.post(TRACKING_URL, { 'data': json.dumps(SHIPMENT_LIST_REQUEST), 'action': SHIPMENT_LIST_ACTION, 'format': SHIPMENT_LIST_FORMAT, 'locale': session.auth.locale, 'version': 1 }) data = resp.json().get('Shi...
[ "def", "get_packages", "(", "session", ")", ":", "resp", "=", "session", ".", "post", "(", "TRACKING_URL", ",", "{", "'data'", ":", "json", ".", "dumps", "(", "SHIPMENT_LIST_REQUEST", ")", ",", "'action'", ":", "SHIPMENT_LIST_ACTION", ",", "'format'", ":", ...
Get packages.
[ "Get", "packages", "." ]
cff2f1104a86573569500d41e69be54b90b596c6
https://github.com/happyleavesaoc/python-fedexdeliverymanager/blob/cff2f1104a86573569500d41e69be54b90b596c6/fedexdeliverymanager/__init__.py#L90-L123
train
65,615
maximkulkin/lollipop
lollipop/types.py
dict_value_hint
def dict_value_hint(key, mapper=None): """Returns a function that takes a dictionary and returns value of particular key. The returned value can be optionally processed by `mapper` function. To be used as a type hint in :class:`OneOf`. """ if mapper is None: mapper = identity def h...
python
def dict_value_hint(key, mapper=None): """Returns a function that takes a dictionary and returns value of particular key. The returned value can be optionally processed by `mapper` function. To be used as a type hint in :class:`OneOf`. """ if mapper is None: mapper = identity def h...
[ "def", "dict_value_hint", "(", "key", ",", "mapper", "=", "None", ")", ":", "if", "mapper", "is", "None", ":", "mapper", "=", "identity", "def", "hinter", "(", "data", ")", ":", "return", "mapper", "(", "data", ".", "get", "(", "key", ")", ")", "re...
Returns a function that takes a dictionary and returns value of particular key. The returned value can be optionally processed by `mapper` function. To be used as a type hint in :class:`OneOf`.
[ "Returns", "a", "function", "that", "takes", "a", "dictionary", "and", "returns", "value", "of", "particular", "key", ".", "The", "returned", "value", "can", "be", "optionally", "processed", "by", "mapper", "function", "." ]
042e8a24508cc3b28630863253c38ffbfc52c882
https://github.com/maximkulkin/lollipop/blob/042e8a24508cc3b28630863253c38ffbfc52c882/lollipop/types.py#L603-L616
train
65,616
maximkulkin/lollipop
lollipop/types.py
validated_type
def validated_type(base_type, name=None, validate=None): """Convenient way to create a new type by adding validation to existing type. Example: :: Ipv4Address = validated_type( String, 'Ipv4Address', # regexp simplified for demo purposes Regexp('^\d+\.\d+\.\d+\.\d+$...
python
def validated_type(base_type, name=None, validate=None): """Convenient way to create a new type by adding validation to existing type. Example: :: Ipv4Address = validated_type( String, 'Ipv4Address', # regexp simplified for demo purposes Regexp('^\d+\.\d+\.\d+\.\d+$...
[ "def", "validated_type", "(", "base_type", ",", "name", "=", "None", ",", "validate", "=", "None", ")", ":", "if", "validate", "is", "None", ":", "validate", "=", "[", "]", "if", "not", "is_sequence", "(", "validate", ")", ":", "validate", "=", "[", ...
Convenient way to create a new type by adding validation to existing type. Example: :: Ipv4Address = validated_type( String, 'Ipv4Address', # regexp simplified for demo purposes Regexp('^\d+\.\d+\.\d+\.\d+$', error='Invalid IP address') ) Percentage = v...
[ "Convenient", "way", "to", "create", "a", "new", "type", "by", "adding", "validation", "to", "existing", "type", "." ]
042e8a24508cc3b28630863253c38ffbfc52c882
https://github.com/maximkulkin/lollipop/blob/042e8a24508cc3b28630863253c38ffbfc52c882/lollipop/types.py#L1767-L1812
train
65,617
maximkulkin/lollipop
lollipop/types.py
Type.validate
def validate(self, data, context=None): """Takes serialized data and returns validation errors or None. :param data: Data to validate. :param context: Context data. :returns: validation errors or None """ try: self.load(data, context) return None ...
python
def validate(self, data, context=None): """Takes serialized data and returns validation errors or None. :param data: Data to validate. :param context: Context data. :returns: validation errors or None """ try: self.load(data, context) return None ...
[ "def", "validate", "(", "self", ",", "data", ",", "context", "=", "None", ")", ":", "try", ":", "self", ".", "load", "(", "data", ",", "context", ")", "return", "None", "except", "ValidationError", "as", "ve", ":", "return", "ve", ".", "messages" ]
Takes serialized data and returns validation errors or None. :param data: Data to validate. :param context: Context data. :returns: validation errors or None
[ "Takes", "serialized", "data", "and", "returns", "validation", "errors", "or", "None", "." ]
042e8a24508cc3b28630863253c38ffbfc52c882
https://github.com/maximkulkin/lollipop/blob/042e8a24508cc3b28630863253c38ffbfc52c882/lollipop/types.py#L114-L125
train
65,618
maximkulkin/lollipop
lollipop/types.py
Object.load_into
def load_into(self, obj, data, inplace=True, *args, **kwargs): """Load data and update existing object. :param obj: Object to update with deserialized data. :param data: Raw data to get value to deserialize from. :param bool inplace: If True update data inplace; otherwise - ...
python
def load_into(self, obj, data, inplace=True, *args, **kwargs): """Load data and update existing object. :param obj: Object to update with deserialized data. :param data: Raw data to get value to deserialize from. :param bool inplace: If True update data inplace; otherwise - ...
[ "def", "load_into", "(", "self", ",", "obj", ",", "data", ",", "inplace", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "obj", "is", "None", ":", "raise", "ValueError", "(", "'Load target should not be None'", ")", "if", "data...
Load data and update existing object. :param obj: Object to update with deserialized data. :param data: Raw data to get value to deserialize from. :param bool inplace: If True update data inplace; otherwise - create new data. :param kwargs: Same keyword arguments as for :met...
[ "Load", "data", "and", "update", "existing", "object", "." ]
042e8a24508cc3b28630863253c38ffbfc52c882
https://github.com/maximkulkin/lollipop/blob/042e8a24508cc3b28630863253c38ffbfc52c882/lollipop/types.py#L1450-L1532
train
65,619
maximkulkin/lollipop
lollipop/types.py
Object.validate_for
def validate_for(self, obj, data, *args, **kwargs): """Takes target object and serialized data, tries to update that object with data and validate result. Returns validation errors or None. Object is not updated. :param obj: Object to check data validity against. In case the data is ...
python
def validate_for(self, obj, data, *args, **kwargs): """Takes target object and serialized data, tries to update that object with data and validate result. Returns validation errors or None. Object is not updated. :param obj: Object to check data validity against. In case the data is ...
[ "def", "validate_for", "(", "self", ",", "obj", ",", "data", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "self", ".", "load_into", "(", "obj", ",", "data", ",", "inplace", "=", "False", ",", "*", "args", ",", "*", "*", "kwa...
Takes target object and serialized data, tries to update that object with data and validate result. Returns validation errors or None. Object is not updated. :param obj: Object to check data validity against. In case the data is partial object is used to get the rest of data from. ...
[ "Takes", "target", "object", "and", "serialized", "data", "tries", "to", "update", "that", "object", "with", "data", "and", "validate", "result", ".", "Returns", "validation", "errors", "or", "None", ".", "Object", "is", "not", "updated", "." ]
042e8a24508cc3b28630863253c38ffbfc52c882
https://github.com/maximkulkin/lollipop/blob/042e8a24508cc3b28630863253c38ffbfc52c882/lollipop/types.py#L1534-L1550
train
65,620
miguelcb84/coc-client
coc/utils.py
filter_country_locations
def filter_country_locations(api_response, is_country=True): """ Filter the response to only include the elements that are countries. This uses the 'api_response' object as input. Plain `list`s are also valid, but they must contain the location elements, not the `items` wrapper. """ ret...
python
def filter_country_locations(api_response, is_country=True): """ Filter the response to only include the elements that are countries. This uses the 'api_response' object as input. Plain `list`s are also valid, but they must contain the location elements, not the `items` wrapper. """ ret...
[ "def", "filter_country_locations", "(", "api_response", ",", "is_country", "=", "True", ")", ":", "return", "[", "item", "for", "item", "in", "api_response", "if", "item", "[", "ISCOUNTRY", "]", "==", "is_country", "]" ]
Filter the response to only include the elements that are countries. This uses the 'api_response' object as input. Plain `list`s are also valid, but they must contain the location elements, not the `items` wrapper.
[ "Filter", "the", "response", "to", "only", "include", "the", "elements", "that", "are", "countries", ".", "This", "uses", "the", "api_response", "object", "as", "input", ".", "Plain", "list", "s", "are", "also", "valid", "but", "they", "must", "contain", "...
7d249211a850538cfc1b5b286dff1d83df443db7
https://github.com/miguelcb84/coc-client/blob/7d249211a850538cfc1b5b286dff1d83df443db7/coc/utils.py#L3-L10
train
65,621
mwolff44/django-simple-invoice
invoice/models.py
Invoice._get_next_number
def _get_next_number(self): """ Returnes next invoice number - reset yearly. .. warning:: This is only used to prepopulate ``number`` field on saving new invoice. To get invoice number always use ``number`` field. .. note:: To get invoice full numb...
python
def _get_next_number(self): """ Returnes next invoice number - reset yearly. .. warning:: This is only used to prepopulate ``number`` field on saving new invoice. To get invoice number always use ``number`` field. .. note:: To get invoice full numb...
[ "def", "_get_next_number", "(", "self", ")", ":", "# Recupere les facture de l annee", "relative_invoices", "=", "Invoice", ".", "objects", ".", "filter", "(", "invoice_date__year", "=", "self", ".", "invoice_date", ".", "year", ")", "# on prend le numero le plus eleve ...
Returnes next invoice number - reset yearly. .. warning:: This is only used to prepopulate ``number`` field on saving new invoice. To get invoice number always use ``number`` field. .. note:: To get invoice full number use ``invoice_id`` field. :return: s...
[ "Returnes", "next", "invoice", "number", "-", "reset", "yearly", "." ]
ab14d905a69f37cd27e137c039750e6630bce4ef
https://github.com/mwolff44/django-simple-invoice/blob/ab14d905a69f37cd27e137c039750e6630bce4ef/invoice/models.py#L155-L176
train
65,622
maximkulkin/lollipop
lollipop/utils.py
make_context_aware
def make_context_aware(func, numargs): """ Check if given function has no more arguments than given. If so, wrap it into another function that takes extra argument and drops it. Used to support user providing callback functions that are not context aware. """ try: if inspect.ismethod(fun...
python
def make_context_aware(func, numargs): """ Check if given function has no more arguments than given. If so, wrap it into another function that takes extra argument and drops it. Used to support user providing callback functions that are not context aware. """ try: if inspect.ismethod(fun...
[ "def", "make_context_aware", "(", "func", ",", "numargs", ")", ":", "try", ":", "if", "inspect", ".", "ismethod", "(", "func", ")", ":", "arg_count", "=", "len", "(", "inspect", ".", "getargspec", "(", "func", ")", ".", "args", ")", "-", "1", "elif",...
Check if given function has no more arguments than given. If so, wrap it into another function that takes extra argument and drops it. Used to support user providing callback functions that are not context aware.
[ "Check", "if", "given", "function", "has", "no", "more", "arguments", "than", "given", ".", "If", "so", "wrap", "it", "into", "another", "function", "that", "takes", "extra", "argument", "and", "drops", "it", ".", "Used", "to", "support", "user", "providin...
042e8a24508cc3b28630863253c38ffbfc52c882
https://github.com/maximkulkin/lollipop/blob/042e8a24508cc3b28630863253c38ffbfc52c882/lollipop/utils.py#L32-L56
train
65,623
maximkulkin/lollipop
lollipop/utils.py
call_with_context
def call_with_context(func, context, *args): """ Check if given function has more arguments than given. Call it with context as last argument or without it. """ return make_context_aware(func, len(args))(*args + (context,))
python
def call_with_context(func, context, *args): """ Check if given function has more arguments than given. Call it with context as last argument or without it. """ return make_context_aware(func, len(args))(*args + (context,))
[ "def", "call_with_context", "(", "func", ",", "context", ",", "*", "args", ")", ":", "return", "make_context_aware", "(", "func", ",", "len", "(", "args", ")", ")", "(", "*", "args", "+", "(", "context", ",", ")", ")" ]
Check if given function has more arguments than given. Call it with context as last argument or without it.
[ "Check", "if", "given", "function", "has", "more", "arguments", "than", "given", ".", "Call", "it", "with", "context", "as", "last", "argument", "or", "without", "it", "." ]
042e8a24508cc3b28630863253c38ffbfc52c882
https://github.com/maximkulkin/lollipop/blob/042e8a24508cc3b28630863253c38ffbfc52c882/lollipop/utils.py#L59-L64
train
65,624
maximkulkin/lollipop
lollipop/utils.py
to_snake_case
def to_snake_case(s): """Converts camel-case identifiers to snake-case.""" return re.sub('([^_A-Z])([A-Z])', lambda m: m.group(1) + '_' + m.group(2).lower(), s)
python
def to_snake_case(s): """Converts camel-case identifiers to snake-case.""" return re.sub('([^_A-Z])([A-Z])', lambda m: m.group(1) + '_' + m.group(2).lower(), s)
[ "def", "to_snake_case", "(", "s", ")", ":", "return", "re", ".", "sub", "(", "'([^_A-Z])([A-Z])'", ",", "lambda", "m", ":", "m", ".", "group", "(", "1", ")", "+", "'_'", "+", "m", ".", "group", "(", "2", ")", ".", "lower", "(", ")", ",", "s", ...
Converts camel-case identifiers to snake-case.
[ "Converts", "camel", "-", "case", "identifiers", "to", "snake", "-", "case", "." ]
042e8a24508cc3b28630863253c38ffbfc52c882
https://github.com/maximkulkin/lollipop/blob/042e8a24508cc3b28630863253c38ffbfc52c882/lollipop/utils.py#L67-L69
train
65,625
stormpath/stormpath-django
django_stormpath/helpers.py
validate_settings
def validate_settings(settings): """Ensure all user-supplied settings exist, or throw a useful error message. :param obj settings: The Django settings object. """ if not (settings.STORMPATH_ID and settings.STORMPATH_SECRET): raise ImproperlyConfigured('Both STORMPATH_ID and STORMPATH_SECRET mus...
python
def validate_settings(settings): """Ensure all user-supplied settings exist, or throw a useful error message. :param obj settings: The Django settings object. """ if not (settings.STORMPATH_ID and settings.STORMPATH_SECRET): raise ImproperlyConfigured('Both STORMPATH_ID and STORMPATH_SECRET mus...
[ "def", "validate_settings", "(", "settings", ")", ":", "if", "not", "(", "settings", ".", "STORMPATH_ID", "and", "settings", ".", "STORMPATH_SECRET", ")", ":", "raise", "ImproperlyConfigured", "(", "'Both STORMPATH_ID and STORMPATH_SECRET must be specified in settings.py.'"...
Ensure all user-supplied settings exist, or throw a useful error message. :param obj settings: The Django settings object.
[ "Ensure", "all", "user", "-", "supplied", "settings", "exist", "or", "throw", "a", "useful", "error", "message", "." ]
af60eb5da2115d94ac313613c5d4e6b9f3d16157
https://github.com/stormpath/stormpath-django/blob/af60eb5da2115d94ac313613c5d4e6b9f3d16157/django_stormpath/helpers.py#L7-L16
train
65,626
stormpath/stormpath-django
django_stormpath/models.py
get_default_is_active
def get_default_is_active(): """ Stormpath user is active by default if e-mail verification is disabled. """ directory = APPLICATION.default_account_store_mapping.account_store verif_email = directory.account_creation_policy.verification_email_status return verif_email == AccountCreationPoli...
python
def get_default_is_active(): """ Stormpath user is active by default if e-mail verification is disabled. """ directory = APPLICATION.default_account_store_mapping.account_store verif_email = directory.account_creation_policy.verification_email_status return verif_email == AccountCreationPoli...
[ "def", "get_default_is_active", "(", ")", ":", "directory", "=", "APPLICATION", ".", "default_account_store_mapping", ".", "account_store", "verif_email", "=", "directory", ".", "account_creation_policy", ".", "verification_email_status", "return", "verif_email", "==", "A...
Stormpath user is active by default if e-mail verification is disabled.
[ "Stormpath", "user", "is", "active", "by", "default", "if", "e", "-", "mail", "verification", "is", "disabled", "." ]
af60eb5da2115d94ac313613c5d4e6b9f3d16157
https://github.com/stormpath/stormpath-django/blob/af60eb5da2115d94ac313613c5d4e6b9f3d16157/django_stormpath/models.py#L48-L55
train
65,627
stormpath/stormpath-django
django_stormpath/backends.py
StormpathBackend._stormpath_authenticate
def _stormpath_authenticate(self, username, password): """Check if Stormpath authentication works :param username: Can be actual username or email :param password: Account password Returns an account object if successful or None otherwise. """ APPLICATION = get_applicat...
python
def _stormpath_authenticate(self, username, password): """Check if Stormpath authentication works :param username: Can be actual username or email :param password: Account password Returns an account object if successful or None otherwise. """ APPLICATION = get_applicat...
[ "def", "_stormpath_authenticate", "(", "self", ",", "username", ",", "password", ")", ":", "APPLICATION", "=", "get_application", "(", ")", "try", ":", "result", "=", "APPLICATION", ".", "authenticate_account", "(", "username", ",", "password", ")", "return", ...
Check if Stormpath authentication works :param username: Can be actual username or email :param password: Account password Returns an account object if successful or None otherwise.
[ "Check", "if", "Stormpath", "authentication", "works" ]
af60eb5da2115d94ac313613c5d4e6b9f3d16157
https://github.com/stormpath/stormpath-django/blob/af60eb5da2115d94ac313613c5d4e6b9f3d16157/django_stormpath/backends.py#L22-L36
train
65,628
stormpath/stormpath-django
django_stormpath/backends.py
StormpathBackend._get_group_difference
def _get_group_difference(self, sp_groups): """Helper method for gettings the groups that are present in the local db but not on stormpath and the other way around.""" db_groups = set(Group.objects.all().values_list('name', flat=True)) missing_from_db = set(sp_groups).difference(...
python
def _get_group_difference(self, sp_groups): """Helper method for gettings the groups that are present in the local db but not on stormpath and the other way around.""" db_groups = set(Group.objects.all().values_list('name', flat=True)) missing_from_db = set(sp_groups).difference(...
[ "def", "_get_group_difference", "(", "self", ",", "sp_groups", ")", ":", "db_groups", "=", "set", "(", "Group", ".", "objects", ".", "all", "(", ")", ".", "values_list", "(", "'name'", ",", "flat", "=", "True", ")", ")", "missing_from_db", "=", "set", ...
Helper method for gettings the groups that are present in the local db but not on stormpath and the other way around.
[ "Helper", "method", "for", "gettings", "the", "groups", "that", "are", "present", "in", "the", "local", "db", "but", "not", "on", "stormpath", "and", "the", "other", "way", "around", "." ]
af60eb5da2115d94ac313613c5d4e6b9f3d16157
https://github.com/stormpath/stormpath-django/blob/af60eb5da2115d94ac313613c5d4e6b9f3d16157/django_stormpath/backends.py#L38-L46
train
65,629
stormpath/stormpath-django
django_stormpath/backends.py
StormpathBackend._mirror_groups_from_stormpath
def _mirror_groups_from_stormpath(self): """Helper method for saving to the local db groups that are missing but are on Stormpath""" APPLICATION = get_application() sp_groups = [g.name for g in APPLICATION.groups] missing_from_db, missing_from_sp = self._get_group_difference(sp_g...
python
def _mirror_groups_from_stormpath(self): """Helper method for saving to the local db groups that are missing but are on Stormpath""" APPLICATION = get_application() sp_groups = [g.name for g in APPLICATION.groups] missing_from_db, missing_from_sp = self._get_group_difference(sp_g...
[ "def", "_mirror_groups_from_stormpath", "(", "self", ")", ":", "APPLICATION", "=", "get_application", "(", ")", "sp_groups", "=", "[", "g", ".", "name", "for", "g", "in", "APPLICATION", ".", "groups", "]", "missing_from_db", ",", "missing_from_sp", "=", "self"...
Helper method for saving to the local db groups that are missing but are on Stormpath
[ "Helper", "method", "for", "saving", "to", "the", "local", "db", "groups", "that", "are", "missing", "but", "are", "on", "Stormpath" ]
af60eb5da2115d94ac313613c5d4e6b9f3d16157
https://github.com/stormpath/stormpath-django/blob/af60eb5da2115d94ac313613c5d4e6b9f3d16157/django_stormpath/backends.py#L48-L61
train
65,630
edibledinos/pwnypack
pwnypack/fmtstring.py
fmtstring
def fmtstring(offset, writes, written=0, max_width=2, target=None): """ Build a format string that writes given data to given locations. Can be used easily create format strings to exploit format string bugs. `writes` is a list of 2- or 3-item tuples. Each tuple represents a memory write starting w...
python
def fmtstring(offset, writes, written=0, max_width=2, target=None): """ Build a format string that writes given data to given locations. Can be used easily create format strings to exploit format string bugs. `writes` is a list of 2- or 3-item tuples. Each tuple represents a memory write starting w...
[ "def", "fmtstring", "(", "offset", ",", "writes", ",", "written", "=", "0", ",", "max_width", "=", "2", ",", "target", "=", "None", ")", ":", "if", "max_width", "not", "in", "(", "1", ",", "2", ",", "4", ")", ":", "raise", "ValueError", "(", "'ma...
Build a format string that writes given data to given locations. Can be used easily create format strings to exploit format string bugs. `writes` is a list of 2- or 3-item tuples. Each tuple represents a memory write starting with an absolute address, then the data to write as an integer and finally th...
[ "Build", "a", "format", "string", "that", "writes", "given", "data", "to", "given", "locations", ".", "Can", "be", "used", "easily", "create", "format", "strings", "to", "exploit", "format", "string", "bugs", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/fmtstring.py#L21-L99
train
65,631
RacingTadpole/django-private-media
private_media/views.py
get_class
def get_class(import_path=None): """ Largely based on django.core.files.storage's get_storage_class """ from django.core.exceptions import ImproperlyConfigured if import_path is None: raise ImproperlyConfigured('No class path specified.') try: dot = import_path.rindex('.') ex...
python
def get_class(import_path=None): """ Largely based on django.core.files.storage's get_storage_class """ from django.core.exceptions import ImproperlyConfigured if import_path is None: raise ImproperlyConfigured('No class path specified.') try: dot = import_path.rindex('.') ex...
[ "def", "get_class", "(", "import_path", "=", "None", ")", ":", "from", "django", ".", "core", ".", "exceptions", "import", "ImproperlyConfigured", "if", "import_path", "is", "None", ":", "raise", "ImproperlyConfigured", "(", "'No class path specified.'", ")", "try...
Largely based on django.core.files.storage's get_storage_class
[ "Largely", "based", "on", "django", ".", "core", ".", "files", ".", "storage", "s", "get_storage_class" ]
7510f2f63ddf0653679b4134a0542cd78317a5c8
https://github.com/RacingTadpole/django-private-media/blob/7510f2f63ddf0653679b4134a0542cd78317a5c8/private_media/views.py#L14-L33
train
65,632
RacingTadpole/django-private-media
private_media/views.py
serve_private_file
def serve_private_file(request, path): """ Serve private files to users with read permission. """ logger.debug('Serving {0} to {1}'.format(path, request.user)) if not permissions.has_read_permission(request, path): if settings.DEBUG: raise PermissionDenied else: ...
python
def serve_private_file(request, path): """ Serve private files to users with read permission. """ logger.debug('Serving {0} to {1}'.format(path, request.user)) if not permissions.has_read_permission(request, path): if settings.DEBUG: raise PermissionDenied else: ...
[ "def", "serve_private_file", "(", "request", ",", "path", ")", ":", "logger", ".", "debug", "(", "'Serving {0} to {1}'", ".", "format", "(", "path", ",", "request", ".", "user", ")", ")", "if", "not", "permissions", ".", "has_read_permission", "(", "request"...
Serve private files to users with read permission.
[ "Serve", "private", "files", "to", "users", "with", "read", "permission", "." ]
7510f2f63ddf0653679b4134a0542cd78317a5c8
https://github.com/RacingTadpole/django-private-media/blob/7510f2f63ddf0653679b4134a0542cd78317a5c8/private_media/views.py#L44-L54
train
65,633
edibledinos/pwnypack
pwnypack/elf.py
symbols_app
def symbols_app(parser, _, args): # pragma: no cover """ List ELF symbol table. """ parser.add_argument('file', help='ELF file to list the symbols of') parser.add_argument('symbol', nargs='?', help='show only this symbol') parser.add_argument('--exact', '-e', action='store_const', const=True, ...
python
def symbols_app(parser, _, args): # pragma: no cover """ List ELF symbol table. """ parser.add_argument('file', help='ELF file to list the symbols of') parser.add_argument('symbol', nargs='?', help='show only this symbol') parser.add_argument('--exact', '-e', action='store_const', const=True, ...
[ "def", "symbols_app", "(", "parser", ",", "_", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'file'", ",", "help", "=", "'ELF file to list the symbols of'", ")", "parser", ".", "add_argument", "(", "'symbol'", ",", "nargs", ...
List ELF symbol table.
[ "List", "ELF", "symbol", "table", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/elf.py#L976-L1023
train
65,634
edibledinos/pwnypack
pwnypack/elf.py
extract_symbol_app
def extract_symbol_app(parser, _, args): # pragma: no cover """ Extract a symbol from an ELF file. """ parser.add_argument('file', help='ELF file to extract a symbol from') parser.add_argument('symbol', help='the symbol to extract') args = parser.parse_args(args) return ELF(args.file).get_...
python
def extract_symbol_app(parser, _, args): # pragma: no cover """ Extract a symbol from an ELF file. """ parser.add_argument('file', help='ELF file to extract a symbol from') parser.add_argument('symbol', help='the symbol to extract') args = parser.parse_args(args) return ELF(args.file).get_...
[ "def", "extract_symbol_app", "(", "parser", ",", "_", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'file'", ",", "help", "=", "'ELF file to extract a symbol from'", ")", "parser", ".", "add_argument", "(", "'symbol'", ",", "h...
Extract a symbol from an ELF file.
[ "Extract", "a", "symbol", "from", "an", "ELF", "file", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/elf.py#L1027-L1035
train
65,635
edibledinos/pwnypack
pwnypack/elf.py
ELF._parse_header
def _parse_header(self, data): """ Parse the ELF header in ``data`` and populate the properties. Args: data(bytes): The ELF header. """ (magic, word_size, byte_order, version, osabi, abi_version, _), data = \ unpack('4sBBBBB7s', data[:16]), data[16:] ...
python
def _parse_header(self, data): """ Parse the ELF header in ``data`` and populate the properties. Args: data(bytes): The ELF header. """ (magic, word_size, byte_order, version, osabi, abi_version, _), data = \ unpack('4sBBBBB7s', data[:16]), data[16:] ...
[ "def", "_parse_header", "(", "self", ",", "data", ")", ":", "(", "magic", ",", "word_size", ",", "byte_order", ",", "version", ",", "osabi", ",", "abi_version", ",", "_", ")", ",", "data", "=", "unpack", "(", "'4sBBBBB7s'", ",", "data", "[", ":", "16...
Parse the ELF header in ``data`` and populate the properties. Args: data(bytes): The ELF header.
[ "Parse", "the", "ELF", "header", "in", "data", "and", "populate", "the", "properties", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/elf.py#L690-L754
train
65,636
edibledinos/pwnypack
pwnypack/elf.py
ELF.parse_file
def parse_file(self, f): """ Parse an ELF file and fill the class' properties. Arguments: f(file or str): The (path to) the ELF file to read. """ if type(f) is str: self.f = open(f, 'rb') else: self.f = f self._parse_header(se...
python
def parse_file(self, f): """ Parse an ELF file and fill the class' properties. Arguments: f(file or str): The (path to) the ELF file to read. """ if type(f) is str: self.f = open(f, 'rb') else: self.f = f self._parse_header(se...
[ "def", "parse_file", "(", "self", ",", "f", ")", ":", "if", "type", "(", "f", ")", "is", "str", ":", "self", ".", "f", "=", "open", "(", "f", ",", "'rb'", ")", "else", ":", "self", ".", "f", "=", "f", "self", ".", "_parse_header", "(", "self"...
Parse an ELF file and fill the class' properties. Arguments: f(file or str): The (path to) the ELF file to read.
[ "Parse", "an", "ELF", "file", "and", "fill", "the", "class", "properties", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/elf.py#L756-L768
train
65,637
edibledinos/pwnypack
pwnypack/elf.py
ELF.get_section_header
def get_section_header(self, section): """ Get a specific section header by index or name. Args: section(int or str): The index or name of the section header to return. Returns: :class:`~ELF.SectionHeader`: The section header. Raises: KeyErr...
python
def get_section_header(self, section): """ Get a specific section header by index or name. Args: section(int or str): The index or name of the section header to return. Returns: :class:`~ELF.SectionHeader`: The section header. Raises: KeyErr...
[ "def", "get_section_header", "(", "self", ",", "section", ")", ":", "self", ".", "_ensure_section_headers_loaded", "(", ")", "if", "type", "(", "section", ")", "is", "int", ":", "return", "self", ".", "_section_headers_by_index", "[", "section", "]", "else", ...
Get a specific section header by index or name. Args: section(int or str): The index or name of the section header to return. Returns: :class:`~ELF.SectionHeader`: The section header. Raises: KeyError: The requested section header does not exist.
[ "Get", "a", "specific", "section", "header", "by", "index", "or", "name", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/elf.py#L837-L855
train
65,638
edibledinos/pwnypack
pwnypack/elf.py
ELF.get_symbol
def get_symbol(self, symbol): """ Get a specific symbol by index or name. Args: symbol(int or str): The index or name of the symbol to return. Returns: ELF.Symbol: The symbol. Raises: KeyError: The requested symbol does not exist. ""...
python
def get_symbol(self, symbol): """ Get a specific symbol by index or name. Args: symbol(int or str): The index or name of the symbol to return. Returns: ELF.Symbol: The symbol. Raises: KeyError: The requested symbol does not exist. ""...
[ "def", "get_symbol", "(", "self", ",", "symbol", ")", ":", "self", ".", "_ensure_symbols_loaded", "(", ")", "if", "type", "(", "symbol", ")", "is", "int", ":", "return", "self", ".", "_symbols_by_index", "[", "symbol", "]", "else", ":", "return", "self",...
Get a specific symbol by index or name. Args: symbol(int or str): The index or name of the symbol to return. Returns: ELF.Symbol: The symbol. Raises: KeyError: The requested symbol does not exist.
[ "Get", "a", "specific", "symbol", "by", "index", "or", "name", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/elf.py#L911-L929
train
65,639
xflows/rdm
rdm/db/datasource.py
DataSource.connected
def connected(self, tables, cols, find_connections=False): ''' Returns a list of tuples of connected table pairs. :param tables: a list of table names :param cols: a list of column names :param find_connections: set this to True to detect relationships from column na...
python
def connected(self, tables, cols, find_connections=False): ''' Returns a list of tuples of connected table pairs. :param tables: a list of table names :param cols: a list of column names :param find_connections: set this to True to detect relationships from column na...
[ "def", "connected", "(", "self", ",", "tables", ",", "cols", ",", "find_connections", "=", "False", ")", ":", "connected", "=", "defaultdict", "(", "list", ")", "fkeys", "=", "defaultdict", "(", "set", ")", "reverse_fkeys", "=", "{", "}", "pkeys", "=", ...
Returns a list of tuples of connected table pairs. :param tables: a list of table names :param cols: a list of column names :param find_connections: set this to True to detect relationships from column names. :return: a tuple (connected, pkeys, fkeys, reverse_fkeys)
[ "Returns", "a", "list", "of", "tuples", "of", "connected", "table", "pairs", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/datasource.py#L49-L87
train
65,640
edibledinos/pwnypack
pwnypack/marshal.py
pyc_load
def pyc_load(fp): """ Load a .pyc file from a file-like object. Arguments: fp(file): The file-like object to read. Returns: PycFile: The parsed representation of the .pyc file. """ magic_1 = U16(fp.read(2), target=MARSHAL_TARGET) magic_2 = U16(fp.read(2), target=MARSHAL_TA...
python
def pyc_load(fp): """ Load a .pyc file from a file-like object. Arguments: fp(file): The file-like object to read. Returns: PycFile: The parsed representation of the .pyc file. """ magic_1 = U16(fp.read(2), target=MARSHAL_TARGET) magic_2 = U16(fp.read(2), target=MARSHAL_TA...
[ "def", "pyc_load", "(", "fp", ")", ":", "magic_1", "=", "U16", "(", "fp", ".", "read", "(", "2", ")", ",", "target", "=", "MARSHAL_TARGET", ")", "magic_2", "=", "U16", "(", "fp", ".", "read", "(", "2", ")", ",", "target", "=", "MARSHAL_TARGET", "...
Load a .pyc file from a file-like object. Arguments: fp(file): The file-like object to read. Returns: PycFile: The parsed representation of the .pyc file.
[ "Load", "a", ".", "pyc", "file", "from", "a", "file", "-", "like", "object", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/marshal.py#L286-L316
train
65,641
xflows/rdm
rdm/db/converters.py
ILPConverter.mode
def mode(self, predicate, args, recall=1, head=False): ''' Emits mode declarations in Aleph-like format. :param predicate: predicate name :param args: predicate arguments with input/output specification, e.g.: >>> [('+', 'train'), ('-', 'car')] :param r...
python
def mode(self, predicate, args, recall=1, head=False): ''' Emits mode declarations in Aleph-like format. :param predicate: predicate name :param args: predicate arguments with input/output specification, e.g.: >>> [('+', 'train'), ('-', 'car')] :param r...
[ "def", "mode", "(", "self", ",", "predicate", ",", "args", ",", "recall", "=", "1", ",", "head", "=", "False", ")", ":", "return", "':- mode%s(%s, %s(%s)).'", "%", "(", "'h'", "if", "head", "else", "'b'", ",", "str", "(", "recall", ")", ",", "predica...
Emits mode declarations in Aleph-like format. :param predicate: predicate name :param args: predicate arguments with input/output specification, e.g.: >>> [('+', 'train'), ('-', 'car')] :param recall: recall setting (see `Aleph manual <http://www.cs.ox.ac.uk/activities...
[ "Emits", "mode", "declarations", "in", "Aleph", "-", "like", "format", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L51-L64
train
65,642
xflows/rdm
rdm/db/converters.py
RSDConverter.all_examples
def all_examples(self, pred_name=None): ''' Emits all examples in prolog form for RSD. :param pred_name: override for the emitted predicate name ''' target = self.db.target_table pred_name = pred_name if pred_name else target examples = self.db.rows(target, [...
python
def all_examples(self, pred_name=None): ''' Emits all examples in prolog form for RSD. :param pred_name: override for the emitted predicate name ''' target = self.db.target_table pred_name = pred_name if pred_name else target examples = self.db.rows(target, [...
[ "def", "all_examples", "(", "self", ",", "pred_name", "=", "None", ")", ":", "target", "=", "self", ".", "db", ".", "target_table", "pred_name", "=", "pred_name", "if", "pred_name", "else", "target", "examples", "=", "self", ".", "db", ".", "rows", "(", ...
Emits all examples in prolog form for RSD. :param pred_name: override for the emitted predicate name
[ "Emits", "all", "examples", "in", "prolog", "form", "for", "RSD", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L157-L166
train
65,643
xflows/rdm
rdm/db/converters.py
RSDConverter.background_knowledge
def background_knowledge(self): ''' Emits the background knowledge in prolog form for RSD. ''' modeslist, getters = [self.mode(self.db.target_table, [('+', self.db.target_table)], head=True)], [] for (table, ref_table) in self.db.connected.keys(): if ref_table == self...
python
def background_knowledge(self): ''' Emits the background knowledge in prolog form for RSD. ''' modeslist, getters = [self.mode(self.db.target_table, [('+', self.db.target_table)], head=True)], [] for (table, ref_table) in self.db.connected.keys(): if ref_table == self...
[ "def", "background_knowledge", "(", "self", ")", ":", "modeslist", ",", "getters", "=", "[", "self", ".", "mode", "(", "self", ".", "db", ".", "target_table", ",", "[", "(", "'+'", ",", "self", ".", "db", ".", "target_table", ")", "]", ",", "head", ...
Emits the background knowledge in prolog form for RSD.
[ "Emits", "the", "background", "knowledge", "in", "prolog", "form", "for", "RSD", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L168-L187
train
65,644
xflows/rdm
rdm/db/converters.py
AlephConverter.background_knowledge
def background_knowledge(self): ''' Emits the background knowledge in prolog form for Aleph. ''' modeslist, getters = [self.mode(self.__target_predicate(), [('+', self.db.target_table)], head=True)], [] determinations, types = [], [] for (table, ref_table) in self.db.conn...
python
def background_knowledge(self): ''' Emits the background knowledge in prolog form for Aleph. ''' modeslist, getters = [self.mode(self.__target_predicate(), [('+', self.db.target_table)], head=True)], [] determinations, types = [], [] for (table, ref_table) in self.db.conn...
[ "def", "background_knowledge", "(", "self", ")", ":", "modeslist", ",", "getters", "=", "[", "self", ".", "mode", "(", "self", ".", "__target_predicate", "(", ")", ",", "[", "(", "'+'", ",", "self", ".", "db", ".", "target_table", ")", "]", ",", "hea...
Emits the background knowledge in prolog form for Aleph.
[ "Emits", "the", "background", "knowledge", "in", "prolog", "form", "for", "Aleph", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L249-L274
train
65,645
xflows/rdm
rdm/db/converters.py
OrangeConverter.target_Orange_table
def target_Orange_table(self): ''' Returns the target table as an Orange example table. :rtype: orange.ExampleTable ''' table, cls_att = self.db.target_table, self.db.target_att if not self.db.orng_tables: return self.convert_table(table, cls_att=cls_att)...
python
def target_Orange_table(self): ''' Returns the target table as an Orange example table. :rtype: orange.ExampleTable ''' table, cls_att = self.db.target_table, self.db.target_att if not self.db.orng_tables: return self.convert_table(table, cls_att=cls_att)...
[ "def", "target_Orange_table", "(", "self", ")", ":", "table", ",", "cls_att", "=", "self", ".", "db", ".", "target_table", ",", "self", ".", "db", ".", "target_att", "if", "not", "self", ".", "db", ".", "orng_tables", ":", "return", "self", ".", "conve...
Returns the target table as an Orange example table. :rtype: orange.ExampleTable
[ "Returns", "the", "target", "table", "as", "an", "Orange", "example", "table", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L304-L314
train
65,646
xflows/rdm
rdm/db/converters.py
OrangeConverter.other_Orange_tables
def other_Orange_tables(self): ''' Returns the related tables as Orange example tables. :rtype: list ''' target_table = self.db.target_table if not self.db.orng_tables: return [self.convert_table(table, None) for table in self.db.tables if table != ta...
python
def other_Orange_tables(self): ''' Returns the related tables as Orange example tables. :rtype: list ''' target_table = self.db.target_table if not self.db.orng_tables: return [self.convert_table(table, None) for table in self.db.tables if table != ta...
[ "def", "other_Orange_tables", "(", "self", ")", ":", "target_table", "=", "self", ".", "db", ".", "target_table", "if", "not", "self", ".", "db", ".", "orng_tables", ":", "return", "[", "self", ".", "convert_table", "(", "table", ",", "None", ")", "for",...
Returns the related tables as Orange example tables. :rtype: list
[ "Returns", "the", "related", "tables", "as", "Orange", "example", "tables", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L316-L326
train
65,647
xflows/rdm
rdm/db/converters.py
OrangeConverter.convert_table
def convert_table(self, table_name, cls_att=None): ''' Returns the specified table as an orange example table. :param table_name: table name to convert :cls_att: class attribute name :rtype: orange.ExampleTable ''' import Orange cols = self.d...
python
def convert_table(self, table_name, cls_att=None): ''' Returns the specified table as an orange example table. :param table_name: table name to convert :cls_att: class attribute name :rtype: orange.ExampleTable ''' import Orange cols = self.d...
[ "def", "convert_table", "(", "self", ",", "table_name", ",", "cls_att", "=", "None", ")", ":", "import", "Orange", "cols", "=", "self", ".", "db", ".", "cols", "[", "table_name", "]", "attributes", ",", "metas", ",", "class_var", "=", "[", "]", ",", ...
Returns the specified table as an orange example table. :param table_name: table name to convert :cls_att: class attribute name :rtype: orange.ExampleTable
[ "Returns", "the", "specified", "table", "as", "an", "orange", "example", "table", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L328-L369
train
65,648
xflows/rdm
rdm/db/converters.py
OrangeConverter.orng_type
def orng_type(self, table_name, col): ''' Returns an Orange datatype for a given mysql column. :param table_name: target table name :param col: column to determine the Orange datatype ''' mysql_type = self.types[table_name][col] n_vals = len(self.db.col_v...
python
def orng_type(self, table_name, col): ''' Returns an Orange datatype for a given mysql column. :param table_name: target table name :param col: column to determine the Orange datatype ''' mysql_type = self.types[table_name][col] n_vals = len(self.db.col_v...
[ "def", "orng_type", "(", "self", ",", "table_name", ",", "col", ")", ":", "mysql_type", "=", "self", ".", "types", "[", "table_name", "]", "[", "col", "]", "n_vals", "=", "len", "(", "self", ".", "db", ".", "col_vals", "[", "table_name", "]", "[", ...
Returns an Orange datatype for a given mysql column. :param table_name: target table name :param col: column to determine the Orange datatype
[ "Returns", "an", "Orange", "datatype", "for", "a", "given", "mysql", "column", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L371-L386
train
65,649
xflows/rdm
rdm/db/converters.py
TreeLikerConverter._discretize_check
def _discretize_check(self, table, att, col): ''' Replaces the value with an appropriate interval symbol, if available. ''' label = "'%s'" % col if table in self.discr_intervals and att in self.discr_intervals[table]: intervals = self.discr_intervals[table][att] ...
python
def _discretize_check(self, table, att, col): ''' Replaces the value with an appropriate interval symbol, if available. ''' label = "'%s'" % col if table in self.discr_intervals and att in self.discr_intervals[table]: intervals = self.discr_intervals[table][att] ...
[ "def", "_discretize_check", "(", "self", ",", "table", ",", "att", ",", "col", ")", ":", "label", "=", "\"'%s'\"", "%", "col", "if", "table", "in", "self", ".", "discr_intervals", "and", "att", "in", "self", ".", "discr_intervals", "[", "table", "]", "...
Replaces the value with an appropriate interval symbol, if available.
[ "Replaces", "the", "value", "with", "an", "appropriate", "interval", "symbol", "if", "available", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L516-L545
train
65,650
xflows/rdm
rdm/db/converters.py
TreeLikerConverter.dataset
def dataset(self): ''' Returns the DBContext as a list of interpretations, i.e., a list of facts true for each example in the format for TreeLiker. ''' target = self.db.target_table db_examples = self.db.rows(target, [self.db.target_att, self.db.pkeys[target]]) e...
python
def dataset(self): ''' Returns the DBContext as a list of interpretations, i.e., a list of facts true for each example in the format for TreeLiker. ''' target = self.db.target_table db_examples = self.db.rows(target, [self.db.target_att, self.db.pkeys[target]]) e...
[ "def", "dataset", "(", "self", ")", ":", "target", "=", "self", ".", "db", ".", "target_table", "db_examples", "=", "self", ".", "db", ".", "rows", "(", "target", ",", "[", "self", ".", "db", ".", "target_att", ",", "self", ".", "db", ".", "pkeys",...
Returns the DBContext as a list of interpretations, i.e., a list of facts true for each example in the format for TreeLiker.
[ "Returns", "the", "DBContext", "as", "a", "list", "of", "interpretations", "i", ".", "e", ".", "a", "list", "of", "facts", "true", "for", "each", "example", "in", "the", "format", "for", "TreeLiker", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L547-L560
train
65,651
xflows/rdm
rdm/db/converters.py
PrdFctConverter.create_prd_file
def create_prd_file(self): ''' Emits the background knowledge in prd format. ''' prd_str = '' prd_str += '--INDIVIDUAL\n' prd_str += '%s 1 %s cwa\n' % (self.db.target_table, self.db.target_table) prd_str += '--STRUCTURAL\n' for ftable, ptable in self.db.re...
python
def create_prd_file(self): ''' Emits the background knowledge in prd format. ''' prd_str = '' prd_str += '--INDIVIDUAL\n' prd_str += '%s 1 %s cwa\n' % (self.db.target_table, self.db.target_table) prd_str += '--STRUCTURAL\n' for ftable, ptable in self.db.re...
[ "def", "create_prd_file", "(", "self", ")", ":", "prd_str", "=", "''", "prd_str", "+=", "'--INDIVIDUAL\\n'", "prd_str", "+=", "'%s 1 %s cwa\\n'", "%", "(", "self", ".", "db", ".", "target_table", ",", "self", ".", "db", ".", "target_table", ")", "prd_str", ...
Emits the background knowledge in prd format.
[ "Emits", "the", "background", "knowledge", "in", "prd", "format", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L583-L600
train
65,652
xflows/rdm
rdm/db/converters.py
PrdFctConverter.create_fct_file
def create_fct_file(self): ''' Emits examples in fct format. ''' fct_str = '' fct_str += self.fct_rec(self.db.target_table) return fct_str
python
def create_fct_file(self): ''' Emits examples in fct format. ''' fct_str = '' fct_str += self.fct_rec(self.db.target_table) return fct_str
[ "def", "create_fct_file", "(", "self", ")", ":", "fct_str", "=", "''", "fct_str", "+=", "self", ".", "fct_rec", "(", "self", ".", "db", ".", "target_table", ")", "return", "fct_str" ]
Emits examples in fct format.
[ "Emits", "examples", "in", "fct", "format", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L602-L608
train
65,653
transitland/mapzen-gtfs
mzgtfs/geom.py
convex_hull
def convex_hull(features): """Returns points on convex hull of an array of points in CCW order.""" points = sorted([s.point() for s in features]) l = reduce(_keep_left, points, []) u = reduce(_keep_left, reversed(points), []) return l.extend(u[i] for i in xrange(1, len(u) - 1)) or l
python
def convex_hull(features): """Returns points on convex hull of an array of points in CCW order.""" points = sorted([s.point() for s in features]) l = reduce(_keep_left, points, []) u = reduce(_keep_left, reversed(points), []) return l.extend(u[i] for i in xrange(1, len(u) - 1)) or l
[ "def", "convex_hull", "(", "features", ")", ":", "points", "=", "sorted", "(", "[", "s", ".", "point", "(", ")", "for", "s", "in", "features", "]", ")", "l", "=", "reduce", "(", "_keep_left", ",", "points", ",", "[", "]", ")", "u", "=", "reduce",...
Returns points on convex hull of an array of points in CCW order.
[ "Returns", "points", "on", "convex", "hull", "of", "an", "array", "of", "points", "in", "CCW", "order", "." ]
d445f1588ed10713eea9a1ca2878eef792121eca
https://github.com/transitland/mapzen-gtfs/blob/d445f1588ed10713eea9a1ca2878eef792121eca/mzgtfs/geom.py#L30-L35
train
65,654
edibledinos/pwnypack
pwnypack/bytecode.py
CodeObject.disassemble
def disassemble(self, annotate=False, blocks=False): """ Disassemble the bytecode of this code object into a series of opcodes and labels. Can also annotate the opcodes and group the opcodes into blocks based on the labels. Arguments: annotate(bool): Whether to annot...
python
def disassemble(self, annotate=False, blocks=False): """ Disassemble the bytecode of this code object into a series of opcodes and labels. Can also annotate the opcodes and group the opcodes into blocks based on the labels. Arguments: annotate(bool): Whether to annot...
[ "def", "disassemble", "(", "self", ",", "annotate", "=", "False", ",", "blocks", "=", "False", ")", ":", "ops", "=", "disassemble", "(", "self", ".", "co_code", ",", "self", ".", "internals", ")", "if", "annotate", ":", "ops", "=", "[", "self", ".", ...
Disassemble the bytecode of this code object into a series of opcodes and labels. Can also annotate the opcodes and group the opcodes into blocks based on the labels. Arguments: annotate(bool): Whether to annotate the operations. blocks(bool): Whether to group the operat...
[ "Disassemble", "the", "bytecode", "of", "this", "code", "object", "into", "a", "series", "of", "opcodes", "and", "labels", ".", "Can", "also", "annotate", "the", "opcodes", "and", "group", "the", "opcodes", "into", "blocks", "based", "on", "the", "labels", ...
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/bytecode.py#L607-L630
train
65,655
edibledinos/pwnypack
pwnypack/bytecode.py
CodeObject.to_code
def to_code(self): """ Convert this instance back into a native python code object. This only works if the internals of the code object are compatible with those of the running python version. Returns: types.CodeType: The native python code object. """ ...
python
def to_code(self): """ Convert this instance back into a native python code object. This only works if the internals of the code object are compatible with those of the running python version. Returns: types.CodeType: The native python code object. """ ...
[ "def", "to_code", "(", "self", ")", ":", "if", "self", ".", "internals", "is", "not", "get_py_internals", "(", ")", ":", "raise", "ValueError", "(", "'CodeObject is not compatible with the running python internals.'", ")", "if", "six", ".", "PY2", ":", "return", ...
Convert this instance back into a native python code object. This only works if the internals of the code object are compatible with those of the running python version. Returns: types.CodeType: The native python code object.
[ "Convert", "this", "instance", "back", "into", "a", "native", "python", "code", "object", ".", "This", "only", "works", "if", "the", "internals", "of", "the", "code", "object", "are", "compatible", "with", "those", "of", "the", "running", "python", "version"...
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/bytecode.py#L653-L677
train
65,656
openpaperwork/paperwork-backend
paperwork_backend/docsearch.py
DocSearch.reload_index
def reload_index(self, progress_cb=dummy_progress_cb): """ Read the index, and load the document list from it Arguments: callback --- called during the indexation (may be called *often*). step : DocSearch.INDEX_STEP_READING or DocSearch.INDEX_STEP...
python
def reload_index(self, progress_cb=dummy_progress_cb): """ Read the index, and load the document list from it Arguments: callback --- called during the indexation (may be called *often*). step : DocSearch.INDEX_STEP_READING or DocSearch.INDEX_STEP...
[ "def", "reload_index", "(", "self", ",", "progress_cb", "=", "dummy_progress_cb", ")", ":", "nb_results", "=", "self", ".", "index", ".", "start_reload_index", "(", ")", "progress", "=", "0", "while", "self", ".", "index", ".", "continue_reload_index", "(", ...
Read the index, and load the document list from it Arguments: callback --- called during the indexation (may be called *often*). step : DocSearch.INDEX_STEP_READING or DocSearch.INDEX_STEP_SORTING progression : how many elements done yet ...
[ "Read", "the", "index", "and", "load", "the", "document", "list", "from", "it" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/docsearch.py#L308-L327
train
65,657
openpaperwork/paperwork-backend
paperwork_backend/docsearch.py
DocSearch.update_label
def update_label(self, old_label, new_label, callback=dummy_progress_cb): """ Replace 'old_label' by 'new_label' on all the documents. Takes care of updating the index. """ current = 0 total = self.index.get_nb_docs() self.index.start_update_label(old_label, new_l...
python
def update_label(self, old_label, new_label, callback=dummy_progress_cb): """ Replace 'old_label' by 'new_label' on all the documents. Takes care of updating the index. """ current = 0 total = self.index.get_nb_docs() self.index.start_update_label(old_label, new_l...
[ "def", "update_label", "(", "self", ",", "old_label", ",", "new_label", ",", "callback", "=", "dummy_progress_cb", ")", ":", "current", "=", "0", "total", "=", "self", ".", "index", ".", "get_nb_docs", "(", ")", "self", ".", "index", ".", "start_update_lab...
Replace 'old_label' by 'new_label' on all the documents. Takes care of updating the index.
[ "Replace", "old_label", "by", "new_label", "on", "all", "the", "documents", ".", "Takes", "care", "of", "updating", "the", "index", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/docsearch.py#L405-L419
train
65,658
openpaperwork/paperwork-backend
paperwork_backend/docsearch.py
DocSearch.destroy_label
def destroy_label(self, label, callback=dummy_progress_cb): """ Remove the label 'label' from all the documents. Takes care of updating the index. """ current = 0 total = self.index.get_nb_docs() self.index.start_destroy_label(label) while True: ...
python
def destroy_label(self, label, callback=dummy_progress_cb): """ Remove the label 'label' from all the documents. Takes care of updating the index. """ current = 0 total = self.index.get_nb_docs() self.index.start_destroy_label(label) while True: ...
[ "def", "destroy_label", "(", "self", ",", "label", ",", "callback", "=", "dummy_progress_cb", ")", ":", "current", "=", "0", "total", "=", "self", ".", "index", ".", "get_nb_docs", "(", ")", "self", ".", "index", ".", "start_destroy_label", "(", "label", ...
Remove the label 'label' from all the documents. Takes care of updating the index.
[ "Remove", "the", "label", "label", "from", "all", "the", "documents", ".", "Takes", "care", "of", "updating", "the", "index", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/docsearch.py#L421-L435
train
65,659
xflows/rdm
rdm/db/library.py
_update_context
def _update_context(context, postdata): ''' Updates the default selections with user's selections. ''' listCheck = lambda el: el[0] if type(el) == list else el # For handling lists of size 1 widget_id = listCheck(postdata.get('widget_id')) context.target_table = listCheck(postdata.get('target_t...
python
def _update_context(context, postdata): ''' Updates the default selections with user's selections. ''' listCheck = lambda el: el[0] if type(el) == list else el # For handling lists of size 1 widget_id = listCheck(postdata.get('widget_id')) context.target_table = listCheck(postdata.get('target_t...
[ "def", "_update_context", "(", "context", ",", "postdata", ")", ":", "listCheck", "=", "lambda", "el", ":", "el", "[", "0", "]", "if", "type", "(", "el", ")", "==", "list", "else", "el", "# For handling lists of size 1", "widget_id", "=", "listCheck", "(",...
Updates the default selections with user's selections.
[ "Updates", "the", "default", "selections", "with", "user", "s", "selections", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/library.py#L39-L66
train
65,660
xflows/rdm
rdm/db/library.py
do_map
def do_map(input_dict, feature_format, positive_class=None): ''' Maps a new example to a set of features. ''' # Context of the unseen example(s) train_context = input_dict['train_ctx'] test_context = input_dict['test_ctx'] # Currently known examples & background knowledge features = inp...
python
def do_map(input_dict, feature_format, positive_class=None): ''' Maps a new example to a set of features. ''' # Context of the unseen example(s) train_context = input_dict['train_ctx'] test_context = input_dict['test_ctx'] # Currently known examples & background knowledge features = inp...
[ "def", "do_map", "(", "input_dict", ",", "feature_format", ",", "positive_class", "=", "None", ")", ":", "# Context of the unseen example(s)", "train_context", "=", "input_dict", "[", "'train_ctx'", "]", "test_context", "=", "input_dict", "[", "'test_ctx'", "]", "# ...
Maps a new example to a set of features.
[ "Maps", "a", "new", "example", "to", "a", "set", "of", "features", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/library.py#L133-L148
train
65,661
specialunderwear/django-easymode
easymode/tree/xml/serializers.py
RecursiveXmlSerializer.serialize
def serialize(self, queryset, **options): """ Serialize a queryset. THE OUTPUT OF THIS SERIALIZER IS NOT MEANT TO BE SERIALIZED BACK INTO THE DB. """ self.options = options self.stream = options.get("stream", StringIO()) self.selected_fields = opt...
python
def serialize(self, queryset, **options): """ Serialize a queryset. THE OUTPUT OF THIS SERIALIZER IS NOT MEANT TO BE SERIALIZED BACK INTO THE DB. """ self.options = options self.stream = options.get("stream", StringIO()) self.selected_fields = opt...
[ "def", "serialize", "(", "self", ",", "queryset", ",", "*", "*", "options", ")", ":", "self", ".", "options", "=", "options", "self", ".", "stream", "=", "options", ".", "get", "(", "\"stream\"", ",", "StringIO", "(", ")", ")", "self", ".", "selected...
Serialize a queryset. THE OUTPUT OF THIS SERIALIZER IS NOT MEANT TO BE SERIALIZED BACK INTO THE DB.
[ "Serialize", "a", "queryset", ".", "THE", "OUTPUT", "OF", "THIS", "SERIALIZER", "IS", "NOT", "MEANT", "TO", "BE", "SERIALIZED", "BACK", "INTO", "THE", "DB", "." ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/tree/xml/serializers.py#L44-L67
train
65,662
specialunderwear/django-easymode
easymode/tree/xml/serializers.py
RecursiveXmlSerializer.serialize_object
def serialize_object(self, obj): """ Write one item to the object stream """ self.start_object(obj) for field in obj._meta.local_fields: if field.serialize and getattr(field, 'include_in_xml', True): if field.rel is None: if self.se...
python
def serialize_object(self, obj): """ Write one item to the object stream """ self.start_object(obj) for field in obj._meta.local_fields: if field.serialize and getattr(field, 'include_in_xml', True): if field.rel is None: if self.se...
[ "def", "serialize_object", "(", "self", ",", "obj", ")", ":", "self", ".", "start_object", "(", "obj", ")", "for", "field", "in", "obj", ".", "_meta", ".", "local_fields", ":", "if", "field", ".", "serialize", "and", "getattr", "(", "field", ",", "'inc...
Write one item to the object stream
[ "Write", "one", "item", "to", "the", "object", "stream" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/tree/xml/serializers.py#L69-L121
train
65,663
specialunderwear/django-easymode
easymode/tree/xml/serializers.py
RecursiveXmlSerializer.handle_m2m_field
def handle_m2m_field(self, obj, field): """ while easymode follows inverse relations for foreign keys, for manytomayfields it follows the forward relation. While easymode excludes all relations to "self" you could still create a loop if you add one extra level of indirec...
python
def handle_m2m_field(self, obj, field): """ while easymode follows inverse relations for foreign keys, for manytomayfields it follows the forward relation. While easymode excludes all relations to "self" you could still create a loop if you add one extra level of indirec...
[ "def", "handle_m2m_field", "(", "self", ",", "obj", ",", "field", ")", ":", "if", "field", ".", "rel", ".", "through", ".", "_meta", ".", "auto_created", ":", "# and obj.__class__ is not field.rel.to:", "# keep approximate recursion level", "with", "recursion_depth",...
while easymode follows inverse relations for foreign keys, for manytomayfields it follows the forward relation. While easymode excludes all relations to "self" you could still create a loop if you add one extra level of indirection.
[ "while", "easymode", "follows", "inverse", "relations", "for", "foreign", "keys", "for", "manytomayfields", "it", "follows", "the", "forward", "relation", ".", "While", "easymode", "excludes", "all", "relations", "to", "self", "you", "could", "still", "create", ...
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/tree/xml/serializers.py#L204-L227
train
65,664
edibledinos/pwnypack
pwnypack/asm.py
prepare_capstone
def prepare_capstone(syntax=AsmSyntax.att, target=None): """ Prepare a capstone disassembler instance for a given target and syntax. Args: syntax(AsmSyntax): The assembler syntax (Intel or AT&T). target(~pwnypack.target.Target): The target to create a disassembler instance for. ...
python
def prepare_capstone(syntax=AsmSyntax.att, target=None): """ Prepare a capstone disassembler instance for a given target and syntax. Args: syntax(AsmSyntax): The assembler syntax (Intel or AT&T). target(~pwnypack.target.Target): The target to create a disassembler instance for. ...
[ "def", "prepare_capstone", "(", "syntax", "=", "AsmSyntax", ".", "att", ",", "target", "=", "None", ")", ":", "if", "not", "HAVE_CAPSTONE", ":", "raise", "NotImplementedError", "(", "'pwnypack requires capstone to disassemble to AT&T and Intel syntax'", ")", "if", "ta...
Prepare a capstone disassembler instance for a given target and syntax. Args: syntax(AsmSyntax): The assembler syntax (Intel or AT&T). target(~pwnypack.target.Target): The target to create a disassembler instance for. The global target is used if this argument is ``None``. ...
[ "Prepare", "a", "capstone", "disassembler", "instance", "for", "a", "given", "target", "and", "syntax", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/asm.py#L320-L384
train
65,665
edibledinos/pwnypack
pwnypack/asm.py
disasm
def disasm(code, addr=0, syntax=None, target=None): """ Disassemble machine readable code into human readable statements. Args: code(bytes): The machine code that is to be disassembled. addr(int): The memory address of the code (used for relative references). syntax(AsmS...
python
def disasm(code, addr=0, syntax=None, target=None): """ Disassemble machine readable code into human readable statements. Args: code(bytes): The machine code that is to be disassembled. addr(int): The memory address of the code (used for relative references). syntax(AsmS...
[ "def", "disasm", "(", "code", ",", "addr", "=", "0", ",", "syntax", "=", "None", ",", "target", "=", "None", ")", ":", "if", "target", "is", "None", ":", "target", "=", "pwnypack", ".", "target", ".", "target", "if", "syntax", "is", "None", ":", ...
Disassemble machine readable code into human readable statements. Args: code(bytes): The machine code that is to be disassembled. addr(int): The memory address of the code (used for relative references). syntax(AsmSyntax): The output assembler syntax. This defaults to ...
[ "Disassemble", "machine", "readable", "code", "into", "human", "readable", "statements", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/asm.py#L387-L458
train
65,666
edibledinos/pwnypack
pwnypack/asm.py
asm_app
def asm_app(parser, cmd, args): # pragma: no cover """ Assemble code from commandline or stdin. Please not that all semi-colons are replaced with carriage returns unless source is read from stdin. """ parser.add_argument('source', help='the code to assemble, read from stdin if omitted', nargs...
python
def asm_app(parser, cmd, args): # pragma: no cover """ Assemble code from commandline or stdin. Please not that all semi-colons are replaced with carriage returns unless source is read from stdin. """ parser.add_argument('source', help='the code to assemble, read from stdin if omitted', nargs...
[ "def", "asm_app", "(", "parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'source'", ",", "help", "=", "'the code to assemble, read from stdin if omitted'", ",", "nargs", "=", "'?'", ")", "pwnypack", ".", "mai...
Assemble code from commandline or stdin. Please not that all semi-colons are replaced with carriage returns unless source is read from stdin.
[ "Assemble", "code", "from", "commandline", "or", "stdin", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/asm.py#L462-L500
train
65,667
edibledinos/pwnypack
pwnypack/asm.py
disasm_app
def disasm_app(_parser, cmd, args): # pragma: no cover """ Disassemble code from commandline or stdin. """ parser = argparse.ArgumentParser( prog=_parser.prog, description=_parser.description, ) parser.add_argument('code', help='the code to disassemble, read from stdin if omitt...
python
def disasm_app(_parser, cmd, args): # pragma: no cover """ Disassemble code from commandline or stdin. """ parser = argparse.ArgumentParser( prog=_parser.prog, description=_parser.description, ) parser.add_argument('code', help='the code to disassemble, read from stdin if omitt...
[ "def", "disasm_app", "(", "_parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "_parser", ".", "prog", ",", "description", "=", "_parser", ".", "description", ",", ")", "par...
Disassemble code from commandline or stdin.
[ "Disassemble", "code", "from", "commandline", "or", "stdin", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/asm.py#L504-L550
train
65,668
edibledinos/pwnypack
pwnypack/asm.py
disasm_symbol_app
def disasm_symbol_app(_parser, _, args): # pragma: no cover """ Disassemble a symbol from an ELF file. """ parser = argparse.ArgumentParser( prog=_parser.prog, description=_parser.description, ) parser.add_argument( '--syntax', '-s', choices=AsmSyntax.__members_...
python
def disasm_symbol_app(_parser, _, args): # pragma: no cover """ Disassemble a symbol from an ELF file. """ parser = argparse.ArgumentParser( prog=_parser.prog, description=_parser.description, ) parser.add_argument( '--syntax', '-s', choices=AsmSyntax.__members_...
[ "def", "disasm_symbol_app", "(", "_parser", ",", "_", ",", "args", ")", ":", "# pragma: no cover", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "_parser", ".", "prog", ",", "description", "=", "_parser", ".", "description", ",", ")", ...
Disassemble a symbol from an ELF file.
[ "Disassemble", "a", "symbol", "from", "an", "ELF", "file", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/asm.py#L554-L578
train
65,669
xflows/rdm
rdm/wrappers/rsd/rsd.py
RSD.settingsAsFacts
def settingsAsFacts(self, settings): """ Parses a string of settings. :param setting: String of settings in the form: ``set(name1, val1), set(name2, val2)...`` """ pattern = re.compile('set\(([a-zA-Z0-9_]+),(\[a-zA-Z0-9_]+)\)') pairs = pattern.findall(se...
python
def settingsAsFacts(self, settings): """ Parses a string of settings. :param setting: String of settings in the form: ``set(name1, val1), set(name2, val2)...`` """ pattern = re.compile('set\(([a-zA-Z0-9_]+),(\[a-zA-Z0-9_]+)\)') pairs = pattern.findall(se...
[ "def", "settingsAsFacts", "(", "self", ",", "settings", ")", ":", "pattern", "=", "re", ".", "compile", "(", "'set\\(([a-zA-Z0-9_]+),(\\[a-zA-Z0-9_]+)\\)'", ")", "pairs", "=", "pattern", ".", "findall", "(", "settings", ")", "for", "name", ",", "val", "in", ...
Parses a string of settings. :param setting: String of settings in the form: ``set(name1, val1), set(name2, val2)...``
[ "Parses", "a", "string", "of", "settings", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/rsd/rsd.py#L78-L89
train
65,670
xflows/rdm
rdm/wrappers/rsd/rsd.py
RSD.__scripts
def __scripts(self, filestem): """ Generates the required scripts. """ script_construct = open('%s/%s' % (self.tmpdir, RSD.CONSTRUCT), 'w') script_save = open('%s/%s' % (self.tmpdir, RSD.SAVE), 'w') script_subgroups = open('%s/%s' % (self.tmpdir, RSD.SUBGROUPS), 'w') ...
python
def __scripts(self, filestem): """ Generates the required scripts. """ script_construct = open('%s/%s' % (self.tmpdir, RSD.CONSTRUCT), 'w') script_save = open('%s/%s' % (self.tmpdir, RSD.SAVE), 'w') script_subgroups = open('%s/%s' % (self.tmpdir, RSD.SUBGROUPS), 'w') ...
[ "def", "__scripts", "(", "self", ",", "filestem", ")", ":", "script_construct", "=", "open", "(", "'%s/%s'", "%", "(", "self", ".", "tmpdir", ",", "RSD", ".", "CONSTRUCT", ")", ",", "'w'", ")", "script_save", "=", "open", "(", "'%s/%s'", "%", "(", "s...
Generates the required scripts.
[ "Generates", "the", "required", "scripts", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/rsd/rsd.py#L184-L233
train
65,671
edibledinos/pwnypack
pwnypack/util.py
deBruijn
def deBruijn(n, k): """ An implementation of the FKM algorithm for generating the de Bruijn sequence containing all k-ary strings of length n, as described in "Combinatorial Generation" by Frank Ruskey. """ a = [ 0 ] * (n + 1) def gen(t, p): if t > n: for v in a[1:p + 1...
python
def deBruijn(n, k): """ An implementation of the FKM algorithm for generating the de Bruijn sequence containing all k-ary strings of length n, as described in "Combinatorial Generation" by Frank Ruskey. """ a = [ 0 ] * (n + 1) def gen(t, p): if t > n: for v in a[1:p + 1...
[ "def", "deBruijn", "(", "n", ",", "k", ")", ":", "a", "=", "[", "0", "]", "*", "(", "n", "+", "1", ")", "def", "gen", "(", "t", ",", "p", ")", ":", "if", "t", ">", "n", ":", "for", "v", "in", "a", "[", "1", ":", "p", "+", "1", "]", ...
An implementation of the FKM algorithm for generating the de Bruijn sequence containing all k-ary strings of length n, as described in "Combinatorial Generation" by Frank Ruskey.
[ "An", "implementation", "of", "the", "FKM", "algorithm", "for", "generating", "the", "de", "Bruijn", "sequence", "containing", "all", "k", "-", "ary", "strings", "of", "length", "n", "as", "described", "in", "Combinatorial", "Generation", "by", "Frank", "Ruske...
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/util.py#L24-L48
train
65,672
edibledinos/pwnypack
pwnypack/util.py
cycle_find
def cycle_find(key, width=4): """ Given an element of a de Bruijn sequence, find its index in that sequence. Args: key(str): The piece of the de Bruijn sequence to find. width(int): The width of each element in the sequence. Returns: int: The index of ``key`` in the de Bruijn s...
python
def cycle_find(key, width=4): """ Given an element of a de Bruijn sequence, find its index in that sequence. Args: key(str): The piece of the de Bruijn sequence to find. width(int): The width of each element in the sequence. Returns: int: The index of ``key`` in the de Bruijn s...
[ "def", "cycle_find", "(", "key", ",", "width", "=", "4", ")", ":", "key_len", "=", "len", "(", "key", ")", "buf", "=", "''", "it", "=", "deBruijn", "(", "width", ",", "26", ")", "for", "i", "in", "range", "(", "key_len", ")", ":", "buf", "+=", ...
Given an element of a de Bruijn sequence, find its index in that sequence. Args: key(str): The piece of the de Bruijn sequence to find. width(int): The width of each element in the sequence. Returns: int: The index of ``key`` in the de Bruijn sequence.
[ "Given", "an", "element", "of", "a", "de", "Bruijn", "sequence", "find", "its", "index", "in", "that", "sequence", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/util.py#L76-L104
train
65,673
edibledinos/pwnypack
pwnypack/util.py
cycle_app
def cycle_app(parser, cmd, args): # pragma: no cover """ Generate a de Bruijn sequence of a given length. """ parser.add_argument('-w', '--width', type=int, default=4, help='the length of the cycled value') parser.add_argument('length', type=int, help='the cycle length to generate') args = par...
python
def cycle_app(parser, cmd, args): # pragma: no cover """ Generate a de Bruijn sequence of a given length. """ parser.add_argument('-w', '--width', type=int, default=4, help='the length of the cycled value') parser.add_argument('length', type=int, help='the cycle length to generate') args = par...
[ "def", "cycle_app", "(", "parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'-w'", ",", "'--width'", ",", "type", "=", "int", ",", "default", "=", "4", ",", "help", "=", "'the length of the cycled value'",...
Generate a de Bruijn sequence of a given length.
[ "Generate", "a", "de", "Bruijn", "sequence", "of", "a", "given", "length", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/util.py#L164-L172
train
65,674
edibledinos/pwnypack
pwnypack/util.py
cycle_find_app
def cycle_find_app(_parser, cmd, args): # pragma: no cover """ Find the first position of a value in a de Bruijn sequence. """ parser = argparse.ArgumentParser( prog=_parser.prog, description=_parser.description, ) parser.add_argument('-w', '--width', type=int, default=4, help=...
python
def cycle_find_app(_parser, cmd, args): # pragma: no cover """ Find the first position of a value in a de Bruijn sequence. """ parser = argparse.ArgumentParser( prog=_parser.prog, description=_parser.description, ) parser.add_argument('-w', '--width', type=int, default=4, help=...
[ "def", "cycle_find_app", "(", "_parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "_parser", ".", "prog", ",", "description", "=", "_parser", ".", "description", ",", ")", ...
Find the first position of a value in a de Bruijn sequence.
[ "Find", "the", "first", "position", "of", "a", "value", "in", "a", "de", "Bruijn", "sequence", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/util.py#L176-L193
train
65,675
specialunderwear/django-easymode
easymode/utils/xmlutils.py
unescape_all
def unescape_all(string): """Resolve all html entities to their corresponding unicode character""" def escape_single(matchobj): return _unicode_for_entity_with_name(matchobj.group(1)) return entities.sub(escape_single, string)
python
def unescape_all(string): """Resolve all html entities to their corresponding unicode character""" def escape_single(matchobj): return _unicode_for_entity_with_name(matchobj.group(1)) return entities.sub(escape_single, string)
[ "def", "unescape_all", "(", "string", ")", ":", "def", "escape_single", "(", "matchobj", ")", ":", "return", "_unicode_for_entity_with_name", "(", "matchobj", ".", "group", "(", "1", ")", ")", "return", "entities", ".", "sub", "(", "escape_single", ",", "str...
Resolve all html entities to their corresponding unicode character
[ "Resolve", "all", "html", "entities", "to", "their", "corresponding", "unicode", "character" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/utils/xmlutils.py#L26-L30
train
65,676
specialunderwear/django-easymode
easymode/utils/xmlutils.py
is_valid
def is_valid(xml_string): """validates a unicode string containing xml""" xml_file = StringIO.StringIO(xml_string.encode('utf-8')) parser = XmlScanner() parser.setContentHandler(ContentHandler()) try: parser.parse(xml_file) except SAXParseException: return False ret...
python
def is_valid(xml_string): """validates a unicode string containing xml""" xml_file = StringIO.StringIO(xml_string.encode('utf-8')) parser = XmlScanner() parser.setContentHandler(ContentHandler()) try: parser.parse(xml_file) except SAXParseException: return False ret...
[ "def", "is_valid", "(", "xml_string", ")", ":", "xml_file", "=", "StringIO", ".", "StringIO", "(", "xml_string", ".", "encode", "(", "'utf-8'", ")", ")", "parser", "=", "XmlScanner", "(", ")", "parser", ".", "setContentHandler", "(", "ContentHandler", "(", ...
validates a unicode string containing xml
[ "validates", "a", "unicode", "string", "containing", "xml" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/utils/xmlutils.py#L32-L43
train
65,677
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.__inst_doc
def __inst_doc(self, docid, doc_type_name=None): """ Instantiate a document based on its document id. The information are taken from the whoosh index. """ doc = None docpath = self.fs.join(self.rootdir, docid) if not self.fs.exists(docpath): return Non...
python
def __inst_doc(self, docid, doc_type_name=None): """ Instantiate a document based on its document id. The information are taken from the whoosh index. """ doc = None docpath = self.fs.join(self.rootdir, docid) if not self.fs.exists(docpath): return Non...
[ "def", "__inst_doc", "(", "self", ",", "docid", ",", "doc_type_name", "=", "None", ")", ":", "doc", "=", "None", "docpath", "=", "self", ".", "fs", ".", "join", "(", "self", ".", "rootdir", ",", "docid", ")", "if", "not", "self", ".", "fs", ".", ...
Instantiate a document based on its document id. The information are taken from the whoosh index.
[ "Instantiate", "a", "document", "based", "on", "its", "document", "id", ".", "The", "information", "are", "taken", "from", "the", "whoosh", "index", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L204-L232
train
65,678
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.get_doc_from_docid
def get_doc_from_docid(self, docid, doc_type_name=None, inst=True): """ Try to find a document based on its document id. if inst=True, if it hasn't been instantiated yet, it will be. """ assert(docid is not None) if docid in self._docs_by_id: return self._docs...
python
def get_doc_from_docid(self, docid, doc_type_name=None, inst=True): """ Try to find a document based on its document id. if inst=True, if it hasn't been instantiated yet, it will be. """ assert(docid is not None) if docid in self._docs_by_id: return self._docs...
[ "def", "get_doc_from_docid", "(", "self", ",", "docid", ",", "doc_type_name", "=", "None", ",", "inst", "=", "True", ")", ":", "assert", "(", "docid", "is", "not", "None", ")", "if", "docid", "in", "self", ".", "_docs_by_id", ":", "return", "self", "."...
Try to find a document based on its document id. if inst=True, if it hasn't been instantiated yet, it will be.
[ "Try", "to", "find", "a", "document", "based", "on", "its", "document", "id", ".", "if", "inst", "=", "True", "if", "it", "hasn", "t", "been", "instantiated", "yet", "it", "will", "be", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L280-L294
train
65,679
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex._delete_doc_from_index
def _delete_doc_from_index(index_writer, docid): """ Remove a document from the index """ query = whoosh.query.Term("docid", docid) index_writer.delete_by_query(query)
python
def _delete_doc_from_index(index_writer, docid): """ Remove a document from the index """ query = whoosh.query.Term("docid", docid) index_writer.delete_by_query(query)
[ "def", "_delete_doc_from_index", "(", "index_writer", ",", "docid", ")", ":", "query", "=", "whoosh", ".", "query", ".", "Term", "(", "\"docid\"", ",", "docid", ")", "index_writer", ".", "delete_by_query", "(", "query", ")" ]
Remove a document from the index
[ "Remove", "a", "document", "from", "the", "index" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L380-L385
train
65,680
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.upd_doc
def upd_doc(self, doc, index_update=True, label_guesser_update=True): """ Update a document in the index """ if not self.index_writer and index_update: self.index_writer = self.index.writer() if not self.label_guesser_updater and label_guesser_update: self...
python
def upd_doc(self, doc, index_update=True, label_guesser_update=True): """ Update a document in the index """ if not self.index_writer and index_update: self.index_writer = self.index.writer() if not self.label_guesser_updater and label_guesser_update: self...
[ "def", "upd_doc", "(", "self", ",", "doc", ",", "index_update", "=", "True", ",", "label_guesser_update", "=", "True", ")", ":", "if", "not", "self", ".", "index_writer", "and", "index_update", ":", "self", ".", "index_writer", "=", "self", ".", "index", ...
Update a document in the index
[ "Update", "a", "document", "in", "the", "index" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L403-L415
train
65,681
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.cancel
def cancel(self): """ Forget about the changes """ logger.info("Index: Index update cancelled") if self.index_writer: self.index_writer.cancel() del self.index_writer self.index_writer = None if self.label_guesser_updater: self....
python
def cancel(self): """ Forget about the changes """ logger.info("Index: Index update cancelled") if self.index_writer: self.index_writer.cancel() del self.index_writer self.index_writer = None if self.label_guesser_updater: self....
[ "def", "cancel", "(", "self", ")", ":", "logger", ".", "info", "(", "\"Index: Index update cancelled\"", ")", "if", "self", ".", "index_writer", ":", "self", ".", "index_writer", ".", "cancel", "(", ")", "del", "self", ".", "index_writer", "self", ".", "in...
Forget about the changes
[ "Forget", "about", "the", "changes" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L457-L468
train
65,682
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.get
def get(self, obj_id): """ Get a document or a page using its ID Won't instantiate them if they are not yet available """ if BasicPage.PAGE_ID_SEPARATOR in obj_id: (docid, page_nb) = obj_id.split(BasicPage.PAGE_ID_SEPARATOR) page_nb = int(page_nb) ...
python
def get(self, obj_id): """ Get a document or a page using its ID Won't instantiate them if they are not yet available """ if BasicPage.PAGE_ID_SEPARATOR in obj_id: (docid, page_nb) = obj_id.split(BasicPage.PAGE_ID_SEPARATOR) page_nb = int(page_nb) ...
[ "def", "get", "(", "self", ",", "obj_id", ")", ":", "if", "BasicPage", ".", "PAGE_ID_SEPARATOR", "in", "obj_id", ":", "(", "docid", ",", "page_nb", ")", "=", "obj_id", ".", "split", "(", "BasicPage", ".", "PAGE_ID_SEPARATOR", ")", "page_nb", "=", "int", ...
Get a document or a page using its ID Won't instantiate them if they are not yet available
[ "Get", "a", "document", "or", "a", "page", "using", "its", "ID", "Won", "t", "instantiate", "them", "if", "they", "are", "not", "yet", "available" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L495-L504
train
65,683
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.find_documents
def find_documents(self, sentence, limit=None, must_sort=True, search_type='fuzzy'): """ Returns all the documents matching the given keywords Arguments: sentence --- a sentenced query Returns: An array of document (doc objects) """...
python
def find_documents(self, sentence, limit=None, must_sort=True, search_type='fuzzy'): """ Returns all the documents matching the given keywords Arguments: sentence --- a sentenced query Returns: An array of document (doc objects) """...
[ "def", "find_documents", "(", "self", ",", "sentence", ",", "limit", "=", "None", ",", "must_sort", "=", "True", ",", "search_type", "=", "'fuzzy'", ")", ":", "sentence", "=", "sentence", ".", "strip", "(", ")", "sentence", "=", "strip_accents", "(", "se...
Returns all the documents matching the given keywords Arguments: sentence --- a sentenced query Returns: An array of document (doc objects)
[ "Returns", "all", "the", "documents", "matching", "the", "given", "keywords" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L506-L564
train
65,684
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.find_suggestions
def find_suggestions(self, sentence): """ Search all possible suggestions. Suggestions returned always have at least one document matching. Arguments: sentence --- keywords (single strings) for which we want suggestions Return: An array of...
python
def find_suggestions(self, sentence): """ Search all possible suggestions. Suggestions returned always have at least one document matching. Arguments: sentence --- keywords (single strings) for which we want suggestions Return: An array of...
[ "def", "find_suggestions", "(", "self", ",", "sentence", ")", ":", "if", "not", "isinstance", "(", "sentence", ",", "str", ")", ":", "sentence", "=", "str", "(", "sentence", ")", "keywords", "=", "sentence", ".", "split", "(", "\" \"", ")", "query_parser...
Search all possible suggestions. Suggestions returned always have at least one document matching. Arguments: sentence --- keywords (single strings) for which we want suggestions Return: An array of sets of keywords. Each set of keywords (-> one string) ...
[ "Search", "all", "possible", "suggestions", ".", "Suggestions", "returned", "always", "have", "at", "least", "one", "document", "matching", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L566-L611
train
65,685
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.add_label
def add_label(self, doc, label, update_index=True): """ Add a label on a document. Arguments: label --- The new label (see labels.Label) doc --- The first document on which this label has been added """ label = copy.copy(label) assert(label in sel...
python
def add_label(self, doc, label, update_index=True): """ Add a label on a document. Arguments: label --- The new label (see labels.Label) doc --- The first document on which this label has been added """ label = copy.copy(label) assert(label in sel...
[ "def", "add_label", "(", "self", ",", "doc", ",", "label", ",", "update_index", "=", "True", ")", ":", "label", "=", "copy", ".", "copy", "(", "label", ")", "assert", "(", "label", "in", "self", ".", "labels", ".", "values", "(", ")", ")", "doc", ...
Add a label on a document. Arguments: label --- The new label (see labels.Label) doc --- The first document on which this label has been added
[ "Add", "a", "label", "on", "a", "document", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L631-L644
train
65,686
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.destroy_index
def destroy_index(self): """ Destroy the index. Don't use this Index object anymore after this call. Index will have to be rebuilt from scratch """ self.close() logger.info("Destroying the index ...") rm_rf(self.indexdir) rm_rf(self.label_guesser_dir) ...
python
def destroy_index(self): """ Destroy the index. Don't use this Index object anymore after this call. Index will have to be rebuilt from scratch """ self.close() logger.info("Destroying the index ...") rm_rf(self.indexdir) rm_rf(self.label_guesser_dir) ...
[ "def", "destroy_index", "(", "self", ")", ":", "self", ".", "close", "(", ")", "logger", ".", "info", "(", "\"Destroying the index ...\"", ")", "rm_rf", "(", "self", ".", "indexdir", ")", "rm_rf", "(", "self", ".", "label_guesser_dir", ")", "logger", ".", ...
Destroy the index. Don't use this Index object anymore after this call. Index will have to be rebuilt from scratch
[ "Destroy", "the", "index", ".", "Don", "t", "use", "this", "Index", "object", "anymore", "after", "this", "call", ".", "Index", "will", "have", "to", "be", "rebuilt", "from", "scratch" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L732-L741
train
65,687
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.is_hash_in_index
def is_hash_in_index(self, filehash): """ Check if there is a document using this file hash """ filehash = (u"%X" % filehash) results = self.__searcher.search( whoosh.query.Term('docfilehash', filehash)) return bool(results)
python
def is_hash_in_index(self, filehash): """ Check if there is a document using this file hash """ filehash = (u"%X" % filehash) results = self.__searcher.search( whoosh.query.Term('docfilehash', filehash)) return bool(results)
[ "def", "is_hash_in_index", "(", "self", ",", "filehash", ")", ":", "filehash", "=", "(", "u\"%X\"", "%", "filehash", ")", "results", "=", "self", ".", "__searcher", ".", "search", "(", "whoosh", ".", "query", ".", "Term", "(", "'docfilehash'", ",", "file...
Check if there is a document using this file hash
[ "Check", "if", "there", "is", "a", "document", "using", "this", "file", "hash" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L743-L750
train
65,688
specialunderwear/django-easymode
easymode/i18n/meta/utils.py
get_fallback_languages
def get_fallback_languages(): """Retrieve the fallback languages from the settings.py""" lang = translation.get_language() fallback_list = settings.FALLBACK_LANGUAGES.get(lang, None) if fallback_list: return fallback_list return settings.FALLBACK_LANGUAGES.get(lang[:2], [])
python
def get_fallback_languages(): """Retrieve the fallback languages from the settings.py""" lang = translation.get_language() fallback_list = settings.FALLBACK_LANGUAGES.get(lang, None) if fallback_list: return fallback_list return settings.FALLBACK_LANGUAGES.get(lang[:2], [])
[ "def", "get_fallback_languages", "(", ")", ":", "lang", "=", "translation", ".", "get_language", "(", ")", "fallback_list", "=", "settings", ".", "FALLBACK_LANGUAGES", ".", "get", "(", "lang", ",", "None", ")", "if", "fallback_list", ":", "return", "fallback_l...
Retrieve the fallback languages from the settings.py
[ "Retrieve", "the", "fallback", "languages", "from", "the", "settings", ".", "py" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/meta/utils.py#L17-L24
train
65,689
specialunderwear/django-easymode
easymode/i18n/meta/utils.py
get_localized_field_name
def get_localized_field_name(context, field): """Get the name of the localized field""" attrs = [ translation.get_language(), translation.get_language()[:2], settings.LANGUAGE_CODE ] def predicate(x): field_name = get_real_fieldname(f...
python
def get_localized_field_name(context, field): """Get the name of the localized field""" attrs = [ translation.get_language(), translation.get_language()[:2], settings.LANGUAGE_CODE ] def predicate(x): field_name = get_real_fieldname(f...
[ "def", "get_localized_field_name", "(", "context", ",", "field", ")", ":", "attrs", "=", "[", "translation", ".", "get_language", "(", ")", ",", "translation", ".", "get_language", "(", ")", "[", ":", "2", "]", ",", "settings", ".", "LANGUAGE_CODE", "]", ...
Get the name of the localized field
[ "Get", "the", "name", "of", "the", "localized", "field" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/meta/utils.py#L53-L67
train
65,690
specialunderwear/django-easymode
easymode/i18n/meta/utils.py
get_field_from_model_by_name
def get_field_from_model_by_name(model_class, field_name): """ Get a field by name from a model class without messing with the app cache. """ return first_match(lambda x: x if x.name == field_name else None, model_class._meta.fields)
python
def get_field_from_model_by_name(model_class, field_name): """ Get a field by name from a model class without messing with the app cache. """ return first_match(lambda x: x if x.name == field_name else None, model_class._meta.fields)
[ "def", "get_field_from_model_by_name", "(", "model_class", ",", "field_name", ")", ":", "return", "first_match", "(", "lambda", "x", ":", "x", "if", "x", ".", "name", "==", "field_name", "else", "None", ",", "model_class", ".", "_meta", ".", "fields", ")" ]
Get a field by name from a model class without messing with the app cache.
[ "Get", "a", "field", "by", "name", "from", "a", "model", "class", "without", "messing", "with", "the", "app", "cache", "." ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/meta/utils.py#L69-L73
train
65,691
yoch/sparse-som
python/sparse_som/classifier.py
SomClassifier.fit
def fit(self, data, labels, **kwargs): """\ Training the SOM on the the data and calibrate itself. After the training, `self.quant_error` and `self.topog_error` are respectively set. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`...
python
def fit(self, data, labels, **kwargs): """\ Training the SOM on the the data and calibrate itself. After the training, `self.quant_error` and `self.topog_error` are respectively set. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`...
[ "def", "fit", "(", "self", ",", "data", ",", "labels", ",", "*", "*", "kwargs", ")", ":", "# train the network", "self", ".", "_som", ".", "train", "(", "data", ",", "*", "*", "kwargs", ")", "# retrieve first and second bmus and distances", "bmus", ",", "q...
\ Training the SOM on the the data and calibrate itself. After the training, `self.quant_error` and `self.topog_error` are respectively set. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`scipy.sparse.csr_matrix` :param labels: th...
[ "\\", "Training", "the", "SOM", "on", "the", "the", "data", "and", "calibrate", "itself", "." ]
327ee76b0da1da7f846d9b3fce0c39bace841f64
https://github.com/yoch/sparse-som/blob/327ee76b0da1da7f846d9b3fce0c39bace841f64/python/sparse_som/classifier.py#L21-L44
train
65,692
yoch/sparse-som
python/sparse_som/classifier.py
SomClassifier._calibrate
def _calibrate(self, data, labels): """\ Calibrate the network using `self._bmus`. """ # network calibration classifier = defaultdict(Counter) for (i,j), label in zip(self._bmus, labels): classifier[i,j][label] += 1 self.classifier = {} for ij,...
python
def _calibrate(self, data, labels): """\ Calibrate the network using `self._bmus`. """ # network calibration classifier = defaultdict(Counter) for (i,j), label in zip(self._bmus, labels): classifier[i,j][label] += 1 self.classifier = {} for ij,...
[ "def", "_calibrate", "(", "self", ",", "data", ",", "labels", ")", ":", "# network calibration", "classifier", "=", "defaultdict", "(", "Counter", ")", "for", "(", "i", ",", "j", ")", ",", "label", "in", "zip", "(", "self", ".", "_bmus", ",", "labels",...
\ Calibrate the network using `self._bmus`.
[ "\\", "Calibrate", "the", "network", "using", "self", ".", "_bmus", "." ]
327ee76b0da1da7f846d9b3fce0c39bace841f64
https://github.com/yoch/sparse-som/blob/327ee76b0da1da7f846d9b3fce0c39bace841f64/python/sparse_som/classifier.py#L46-L58
train
65,693
yoch/sparse-som
python/sparse_som/classifier.py
SomClassifier.predict
def predict(self, data, unkown=None): """\ Classify data according to previous calibration. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`scipy.sparse.csr_matrix` :param unkown: the label to attribute if no label is known :returns:...
python
def predict(self, data, unkown=None): """\ Classify data according to previous calibration. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`scipy.sparse.csr_matrix` :param unkown: the label to attribute if no label is known :returns:...
[ "def", "predict", "(", "self", ",", "data", ",", "unkown", "=", "None", ")", ":", "assert", "self", ".", "classifier", "is", "not", "None", ",", "'not calibrated'", "bmus", "=", "self", ".", "_som", ".", "bmus", "(", "data", ")", "return", "self", "....
\ Classify data according to previous calibration. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`scipy.sparse.csr_matrix` :param unkown: the label to attribute if no label is known :returns: the labels guessed for data :rtype: `num...
[ "\\", "Classify", "data", "according", "to", "previous", "calibration", "." ]
327ee76b0da1da7f846d9b3fce0c39bace841f64
https://github.com/yoch/sparse-som/blob/327ee76b0da1da7f846d9b3fce0c39bace841f64/python/sparse_som/classifier.py#L86-L98
train
65,694
yoch/sparse-som
python/sparse_som/classifier.py
SomClassifier.fit_predict
def fit_predict(self, data, labels, unkown=None): """\ Fit and classify data efficiently. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`scipy.sparse.csr_matrix` :param labels: the labels associated with data :type labels: iterable ...
python
def fit_predict(self, data, labels, unkown=None): """\ Fit and classify data efficiently. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`scipy.sparse.csr_matrix` :param labels: the labels associated with data :type labels: iterable ...
[ "def", "fit_predict", "(", "self", ",", "data", ",", "labels", ",", "unkown", "=", "None", ")", ":", "self", ".", "fit", "(", "data", ",", "labels", ")", "return", "self", ".", "_predict_from_bmus", "(", "self", ".", "_bmus", ",", "unkown", ")" ]
\ Fit and classify data efficiently. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`scipy.sparse.csr_matrix` :param labels: the labels associated with data :type labels: iterable :param unkown: the label to attribute if no label is ...
[ "\\", "Fit", "and", "classify", "data", "efficiently", "." ]
327ee76b0da1da7f846d9b3fce0c39bace841f64
https://github.com/yoch/sparse-som/blob/327ee76b0da1da7f846d9b3fce0c39bace841f64/python/sparse_som/classifier.py#L100-L113
train
65,695
yoch/sparse-som
python/sparse_som/classifier.py
SomClassifier.histogram
def histogram(self, bmus=None): """\ Return a 2D histogram of bmus. :param bmus: the best-match units indexes for underlying data. :type bmus: :class:`numpy.ndarray` :returns: the computed 2D histogram of bmus. :rtype: :class:`numpy.ndarray` """ if bmus i...
python
def histogram(self, bmus=None): """\ Return a 2D histogram of bmus. :param bmus: the best-match units indexes for underlying data. :type bmus: :class:`numpy.ndarray` :returns: the computed 2D histogram of bmus. :rtype: :class:`numpy.ndarray` """ if bmus i...
[ "def", "histogram", "(", "self", ",", "bmus", "=", "None", ")", ":", "if", "bmus", "is", "None", ":", "assert", "self", ".", "_bmus", "is", "not", "None", ",", "'not trained'", "bmus", "=", "self", ".", "_bmus", "arr", "=", "np", ".", "zeros", "(",...
\ Return a 2D histogram of bmus. :param bmus: the best-match units indexes for underlying data. :type bmus: :class:`numpy.ndarray` :returns: the computed 2D histogram of bmus. :rtype: :class:`numpy.ndarray`
[ "\\", "Return", "a", "2D", "histogram", "of", "bmus", "." ]
327ee76b0da1da7f846d9b3fce0c39bace841f64
https://github.com/yoch/sparse-som/blob/327ee76b0da1da7f846d9b3fce0c39bace841f64/python/sparse_som/classifier.py#L126-L141
train
65,696
edibledinos/pwnypack
pwnypack/pickle.py
get_protocol_version
def get_protocol_version(protocol=None, target=None): """ Return a suitable pickle protocol version for a given target. Arguments: target: The internals description of the targeted python version. If this is ``None`` the specification of the currently running python version ...
python
def get_protocol_version(protocol=None, target=None): """ Return a suitable pickle protocol version for a given target. Arguments: target: The internals description of the targeted python version. If this is ``None`` the specification of the currently running python version ...
[ "def", "get_protocol_version", "(", "protocol", "=", "None", ",", "target", "=", "None", ")", ":", "target", "=", "get_py_internals", "(", "target", ")", "if", "protocol", "is", "None", ":", "protocol", "=", "target", "[", "'pickle_default_protocol'", "]", "...
Return a suitable pickle protocol version for a given target. Arguments: target: The internals description of the targeted python version. If this is ``None`` the specification of the currently running python version will be used. protocol(None or int): The requested protoco...
[ "Return", "a", "suitable", "pickle", "protocol", "version", "for", "a", "given", "target", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/pickle.py#L28-L57
train
65,697
edibledinos/pwnypack
pwnypack/pickle.py
translate_opcodes
def translate_opcodes(code_obj, target): """ Very crude inter-python version opcode translator. Raises SyntaxError when the opcode doesn't exist in the destination opmap. Used to transcribe python code objects between python versions. Arguments: code_obj(pwnypack.bytecode.CodeObject): The c...
python
def translate_opcodes(code_obj, target): """ Very crude inter-python version opcode translator. Raises SyntaxError when the opcode doesn't exist in the destination opmap. Used to transcribe python code objects between python versions. Arguments: code_obj(pwnypack.bytecode.CodeObject): The c...
[ "def", "translate_opcodes", "(", "code_obj", ",", "target", ")", ":", "target", "=", "get_py_internals", "(", "target", ")", "src_ops", "=", "code_obj", ".", "disassemble", "(", ")", "dst_opmap", "=", "target", "[", "'opmap'", "]", "dst_ops", "=", "[", "]"...
Very crude inter-python version opcode translator. Raises SyntaxError when the opcode doesn't exist in the destination opmap. Used to transcribe python code objects between python versions. Arguments: code_obj(pwnypack.bytecode.CodeObject): The code object representation to translate. ...
[ "Very", "crude", "inter", "-", "python", "version", "opcode", "translator", ".", "Raises", "SyntaxError", "when", "the", "opcode", "doesn", "t", "exist", "in", "the", "destination", "opmap", ".", "Used", "to", "transcribe", "python", "code", "objects", "betwee...
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/pickle.py#L96-L153
train
65,698
transitland/mapzen-gtfs
mzgtfs/route.py
Route.stops
def stops(self): """Return stops served by this route.""" serves = set() for trip in self.trips(): for stop_time in trip.stop_times(): serves |= stop_time.stops() return serves
python
def stops(self): """Return stops served by this route.""" serves = set() for trip in self.trips(): for stop_time in trip.stop_times(): serves |= stop_time.stops() return serves
[ "def", "stops", "(", "self", ")", ":", "serves", "=", "set", "(", ")", "for", "trip", "in", "self", ".", "trips", "(", ")", ":", "for", "stop_time", "in", "trip", ".", "stop_times", "(", ")", ":", "serves", "|=", "stop_time", ".", "stops", "(", "...
Return stops served by this route.
[ "Return", "stops", "served", "by", "this", "route", "." ]
d445f1588ed10713eea9a1ca2878eef792121eca
https://github.com/transitland/mapzen-gtfs/blob/d445f1588ed10713eea9a1ca2878eef792121eca/mzgtfs/route.py#L226-L232
train
65,699