Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
main
(argv=None)
Run the tutorial using command line flags.
Run the tutorial using command line flags.
def main(argv=None): """ Run the tutorial using command line flags. """ from cleverhans_tutorials import check_installation check_installation(__file__) mnist_tutorial( nb_epochs=FLAGS.nb_epochs, batch_size=FLAGS.batch_size, learning_rate=FLAGS.learning_rate, cl...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "from", "cleverhans_tutorials", "import", "check_installation", "check_installation", "(", "__file__", ")", "mnist_tutorial", "(", "nb_epochs", "=", "FLAGS", ".", "nb_epochs", ",", "batch_size", "=", "FLAGS", "....
[ 213, 0 ]
[ 228, 5 ]
python
en
['en', 'error', 'th']
False
picknthweekday
(year, month, dayofweek, hour, minute, whichweek)
dayofweek == 0 means Sunday, whichweek 5 means last instance
dayofweek == 0 means Sunday, whichweek 5 means last instance
def picknthweekday(year, month, dayofweek, hour, minute, whichweek): """dayofweek == 0 means Sunday, whichweek 5 means last instance""" first = datetime.datetime(year, month, 1, hour, minute) weekdayone = first.replace(day=((dayofweek-first.isoweekday())%7+1)) for n in xrange(whichweek): dt = we...
[ "def", "picknthweekday", "(", "year", ",", "month", ",", "dayofweek", ",", "hour", ",", "minute", ",", "whichweek", ")", ":", "first", "=", "datetime", ".", "datetime", "(", "year", ",", "month", ",", "1", ",", "hour", ",", "minute", ")", "weekdayone",...
[ 163, 0 ]
[ 170, 21 ]
python
en
['en', 'en', 'en']
True
valuestodict
(key)
Convert a registry key's values to a dictionary.
Convert a registry key's values to a dictionary.
def valuestodict(key): """Convert a registry key's values to a dictionary.""" dict = {} size = _winreg.QueryInfoKey(key)[1] for i in range(size): data = _winreg.EnumValue(key, i) dict[data[0]] = data[1] return dict
[ "def", "valuestodict", "(", "key", ")", ":", "dict", "=", "{", "}", "size", "=", "_winreg", ".", "QueryInfoKey", "(", "key", ")", "[", "1", "]", "for", "i", "in", "range", "(", "size", ")", ":", "data", "=", "_winreg", ".", "EnumValue", "(", "key...
[ 172, 0 ]
[ 179, 15 ]
python
en
['en', 'en', 'en']
True
tzwinbase.list
()
Return a list of all time zones known to the system.
Return a list of all time zones known to the system.
def list(): """Return a list of all time zones known to the system.""" handle = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE) tzkey = _winreg.OpenKey(handle, TZKEYNAME) result = [_winreg.EnumKey(tzkey, i) for i in range(_winreg.QueryInfoKey(tzkey)[0])] ...
[ "def", "list", "(", ")", ":", "handle", "=", "_winreg", ".", "ConnectRegistry", "(", "None", ",", "_winreg", ".", "HKEY_LOCAL_MACHINE", ")", "tzkey", "=", "_winreg", ".", "OpenKey", "(", "handle", ",", "TZKEYNAME", ")", "result", "=", "[", "_winreg", "."...
[ 49, 4 ]
[ 57, 21 ]
python
en
['en', 'en', 'en']
True
Command.write_migration_files
(self, changes)
Takes a changes dict and writes them out as migration files.
Takes a changes dict and writes them out as migration files.
def write_migration_files(self, changes): """ Takes a changes dict and writes them out as migration files. """ directory_created = {} for app_label, app_migrations in changes.items(): if self.verbosity >= 1: self.stdout.write(self.style.MIGRATE_HEADING...
[ "def", "write_migration_files", "(", "self", ",", "changes", ")", ":", "directory_created", "=", "{", "}", "for", "app_label", ",", "app_migrations", "in", "changes", ".", "items", "(", ")", ":", "if", "self", ".", "verbosity", ">=", "1", ":", "self", "....
[ 134, 4 ]
[ 170, 66 ]
python
en
['en', 'error', 'th']
False
Command.handle_merge
(self, loader, conflicts)
Handles merging together conflicted migrations interactively, if it's safe; otherwise, advises on how to fix it.
Handles merging together conflicted migrations interactively, if it's safe; otherwise, advises on how to fix it.
def handle_merge(self, loader, conflicts): """ Handles merging together conflicted migrations interactively, if it's safe; otherwise, advises on how to fix it. """ if self.interactive: questioner = InteractiveMigrationQuestioner() else: questioner ...
[ "def", "handle_merge", "(", "self", ",", "loader", ",", "conflicts", ")", ":", "if", "self", ".", "interactive", ":", "questioner", "=", "InteractiveMigrationQuestioner", "(", ")", "else", ":", "questioner", "=", "MigrationQuestioner", "(", "defaults", "=", "{...
[ 172, 4 ]
[ 235, 87 ]
python
en
['en', 'error', 'th']
False
update_whitelist
()
Add files to the whitelist
Add files to the whitelist
def update_whitelist(): """Add files to the whitelist""" global whitelist_pep8 # We don't want to test RL-attack because it has so many dependencies # not used elsewhere, and pylint wants to import them all whitelist_pep8.extend( [ os.path.relpath(path, cleverhans.__path__[0]) ...
[ "def", "update_whitelist", "(", ")", ":", "global", "whitelist_pep8", "# We don't want to test RL-attack because it has so many dependencies", "# not used elsewhere, and pylint wants to import them all", "whitelist_pep8", ".", "extend", "(", "[", "os", ".", "path", ".", "relpath"...
[ 23, 0 ]
[ 74, 5 ]
python
en
['en', 'en', 'en']
True
test_format_pep8
()
Test if pep8 is respected.
Test if pep8 is respected.
def test_format_pep8(): """ Test if pep8 is respected. """ files_to_check = [] module_dir = cleverhans.__path__[0] for path in all_py_files: rel_path = os.path.relpath(path, module_dir) if rel_path in whitelist_pep8: continue else: files_to_check.a...
[ "def", "test_format_pep8", "(", ")", ":", "files_to_check", "=", "[", "]", "module_dir", "=", "cleverhans", ".", "__path__", "[", "0", "]", "for", "path", "in", "all_py_files", ":", "rel_path", "=", "os", ".", "path", ".", "relpath", "(", "path", ",", ...
[ 83, 0 ]
[ 135, 50 ]
python
en
['en', 'error', 'th']
False
TemplateCommand.handle_template
(self, template, subdir)
Determine where the app or project templates are. Use django.__path__[0] as the default because the Django install directory isn't known.
Determine where the app or project templates are. Use django.__path__[0] as the default because the Django install directory isn't known.
def handle_template(self, template, subdir): """ Determine where the app or project templates are. Use django.__path__[0] as the default because the Django install directory isn't known. """ if template is None: return os.path.join(django.__path__[0], 'conf', ...
[ "def", "handle_template", "(", "self", ",", "template", ",", "subdir", ")", ":", "if", "template", "is", "None", ":", "return", "os", ".", "path", ".", "join", "(", "django", ".", "__path__", "[", "0", "]", ",", "'conf'", ",", "subdir", ")", "else", ...
[ 183, 4 ]
[ 207, 59 ]
python
en
['en', 'error', 'th']
False
TemplateCommand.download
(self, url)
Download the given URL and return the file name.
Download the given URL and return the file name.
def download(self, url): """ Download the given URL and return the file name. """ def cleanup_url(url): tmp = url.rstrip('/') filename = tmp.split('/')[-1] if url.endswith('/'): display_url = tmp + '/' else: ...
[ "def", "download", "(", "self", ",", "url", ")", ":", "def", "cleanup_url", "(", "url", ")", ":", "tmp", "=", "url", ".", "rstrip", "(", "'/'", ")", "filename", "=", "tmp", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", "if", "url", ".", ...
[ 242, 4 ]
[ 294, 23 ]
python
en
['en', 'error', 'th']
False
TemplateCommand.splitext
(self, the_path)
Like os.path.splitext, but takes off .tar, too
Like os.path.splitext, but takes off .tar, too
def splitext(self, the_path): """ Like os.path.splitext, but takes off .tar, too """ base, ext = posixpath.splitext(the_path) if base.lower().endswith('.tar'): ext = base[-4:] + ext base = base[:-4] return base, ext
[ "def", "splitext", "(", "self", ",", "the_path", ")", ":", "base", ",", "ext", "=", "posixpath", ".", "splitext", "(", "the_path", ")", "if", "base", ".", "lower", "(", ")", ".", "endswith", "(", "'.tar'", ")", ":", "ext", "=", "base", "[", "-", ...
[ 296, 4 ]
[ 304, 24 ]
python
en
['en', 'error', 'th']
False
TemplateCommand.extract
(self, filename)
Extract the given file to a temporarily and return the path of the directory with the extracted content.
Extract the given file to a temporarily and return the path of the directory with the extracted content.
def extract(self, filename): """ Extract the given file to a temporarily and return the path of the directory with the extracted content. """ prefix = 'django_%s_template_' % self.app_or_project tempdir = tempfile.mkdtemp(prefix=prefix, suffix='_extract') self.pat...
[ "def", "extract", "(", "self", ",", "filename", ")", ":", "prefix", "=", "'django_%s_template_'", "%", "self", ".", "app_or_project", "tempdir", "=", "tempfile", ".", "mkdtemp", "(", "prefix", "=", "prefix", ",", "suffix", "=", "'_extract'", ")", "self", "...
[ 306, 4 ]
[ 321, 54 ]
python
en
['en', 'error', 'th']
False
TemplateCommand.is_url
(self, template)
Return True if the name looks like a URL.
Return True if the name looks like a URL.
def is_url(self, template): """Return True if the name looks like a URL.""" if ':' not in template: return False scheme = template.split(':', 1)[0].lower() return scheme in self.url_schemes
[ "def", "is_url", "(", "self", ",", "template", ")", ":", "if", "':'", "not", "in", "template", ":", "return", "False", "scheme", "=", "template", ".", "split", "(", "':'", ",", "1", ")", "[", "0", "]", ".", "lower", "(", ")", "return", "scheme", ...
[ 323, 4 ]
[ 328, 41 ]
python
en
['en', 'ig', 'en']
True
TemplateCommand.make_writeable
(self, filename)
Make sure that the file is writeable. Useful if our source is read-only.
Make sure that the file is writeable. Useful if our source is read-only.
def make_writeable(self, filename): """ Make sure that the file is writeable. Useful if our source is read-only. """ if not os.access(filename, os.W_OK): st = os.stat(filename) new_permissions = stat.S_IMODE(st.st_mode) | stat.S_IWUSR os.chmod(...
[ "def", "make_writeable", "(", "self", ",", "filename", ")", ":", "if", "not", "os", ".", "access", "(", "filename", ",", "os", ".", "W_OK", ")", ":", "st", "=", "os", ".", "stat", "(", "filename", ")", "new_permissions", "=", "stat", ".", "S_IMODE", ...
[ 330, 4 ]
[ 338, 47 ]
python
en
['en', 'error', 'th']
False
exhaust
(stream_or_iterable)
Completely exhausts an iterator or stream. Raise a MultiPartParserError if the argument is not a stream or an iterable.
Completely exhausts an iterator or stream.
def exhaust(stream_or_iterable): """ Completely exhausts an iterator or stream. Raise a MultiPartParserError if the argument is not a stream or an iterable. """ iterator = None try: iterator = iter(stream_or_iterable) except TypeError: iterator = ChunkIter(stream_or_iterable...
[ "def", "exhaust", "(", "stream_or_iterable", ")", ":", "iterator", "=", "None", "try", ":", "iterator", "=", "iter", "(", "stream_or_iterable", ")", "except", "TypeError", ":", "iterator", "=", "ChunkIter", "(", "stream_or_iterable", ",", "16384", ")", "if", ...
[ 538, 0 ]
[ 554, 12 ]
python
en
['en', 'error', 'th']
False
parse_boundary_stream
(stream, max_header_size)
Parses one and exactly one stream that encapsulates a boundary.
Parses one and exactly one stream that encapsulates a boundary.
def parse_boundary_stream(stream, max_header_size): """ Parses one and exactly one stream that encapsulates a boundary. """ # Stream at beginning of header, look for end of header # and parse it if found. The header must fit within one # chunk. chunk = stream.read(max_header_size) # 'fi...
[ "def", "parse_boundary_stream", "(", "stream", ",", "max_header_size", ")", ":", "# Stream at beginning of header, look for end of header", "# and parse it if found. The header must fit within one", "# chunk.", "chunk", "=", "stream", ".", "read", "(", "max_header_size", ")", "...
[ 557, 0 ]
[ 613, 34 ]
python
en
['en', 'error', 'th']
False
parse_header
(line)
Parse the header into a key-value. Input (line): bytes, output: unicode for key/name, bytes for value which will be decoded later
Parse the header into a key-value. Input (line): bytes, output: unicode for key/name, bytes for value which will be decoded later
def parse_header(line): """ Parse the header into a key-value. Input (line): bytes, output: unicode for key/name, bytes for value which will be decoded later """ plist = _parse_header_params(b';' + line) key = plist.pop(0).lower().decode('ascii') pdict = {} for p in plist: ...
[ "def", "parse_header", "(", "line", ")", ":", "plist", "=", "_parse_header_params", "(", "b';'", "+", "line", ")", "key", "=", "plist", ".", "pop", "(", "0", ")", ".", "lower", "(", ")", ".", "decode", "(", "'ascii'", ")", "pdict", "=", "{", "}", ...
[ 628, 0 ]
[ 657, 21 ]
python
en
['en', 'en', 'en']
True
MultiPartParser.__init__
(self, META, input_data, upload_handlers, encoding=None)
Initialize the MultiPartParser object. :META: The standard ``META`` dictionary in Django request objects. :input_data: The raw post data, as a file-like object. :upload_handlers: A list of UploadHandler instances that perform operations on the upload...
Initialize the MultiPartParser object.
def __init__(self, META, input_data, upload_handlers, encoding=None): """ Initialize the MultiPartParser object. :META: The standard ``META`` dictionary in Django request objects. :input_data: The raw post data, as a file-like object. :upload_handlers: ...
[ "def", "__init__", "(", "self", ",", "META", ",", "input_data", ",", "upload_handlers", ",", "encoding", "=", "None", ")", ":", "#", "# Content-Type should contain multipart and the boundary information.", "#", "content_type", "=", "META", ".", "get", "(", "'HTTP_CO...
[ 49, 4 ]
[ 102, 47 ]
python
en
['en', 'error', 'th']
False
MultiPartParser.parse
(self)
Parse the POST data and break it into a FILES MultiValueDict and a POST MultiValueDict. Returns a tuple containing the POST and FILES dictionary, respectively.
Parse the POST data and break it into a FILES MultiValueDict and a POST MultiValueDict.
def parse(self): """ Parse the POST data and break it into a FILES MultiValueDict and a POST MultiValueDict. Returns a tuple containing the POST and FILES dictionary, respectively. """ # We have to import QueryDict down here to avoid a circular import. from djang...
[ "def", "parse", "(", "self", ")", ":", "# We have to import QueryDict down here to avoid a circular import.", "from", "django", ".", "http", "import", "QueryDict", "encoding", "=", "self", ".", "_encoding", "handlers", "=", "self", ".", "_upload_handlers", "# HTTP spec ...
[ 104, 4 ]
[ 259, 38 ]
python
en
['en', 'error', 'th']
False
MultiPartParser.handle_file_complete
(self, old_field_name, counters)
Handle all the signaling that takes place when a file is complete.
Handle all the signaling that takes place when a file is complete.
def handle_file_complete(self, old_field_name, counters): """ Handle all the signaling that takes place when a file is complete. """ for i, handler in enumerate(self._upload_handlers): file_obj = handler.file_complete(counters[i]) if file_obj: # If...
[ "def", "handle_file_complete", "(", "self", ",", "old_field_name", ",", "counters", ")", ":", "for", "i", ",", "handler", "in", "enumerate", "(", "self", ".", "_upload_handlers", ")", ":", "file_obj", "=", "handler", ".", "file_complete", "(", "counters", "[...
[ 261, 4 ]
[ 272, 21 ]
python
en
['en', 'error', 'th']
False
MultiPartParser.IE_sanitize
(self, filename)
Cleanup filename from Internet Explorer full paths.
Cleanup filename from Internet Explorer full paths.
def IE_sanitize(self, filename): """Cleanup filename from Internet Explorer full paths.""" return filename and filename[filename.rfind("\\") + 1:].strip()
[ "def", "IE_sanitize", "(", "self", ",", "filename", ")", ":", "return", "filename", "and", "filename", "[", "filename", ".", "rfind", "(", "\"\\\\\"", ")", "+", "1", ":", "]", ".", "strip", "(", ")" ]
[ 274, 4 ]
[ 276, 71 ]
python
en
['en', 'en', 'en']
True
LazyStream.__init__
(self, producer, length=None)
Every LazyStream must have a producer when instantiated. A producer is an iterable that returns a string each time it is called.
Every LazyStream must have a producer when instantiated.
def __init__(self, producer, length=None): """ Every LazyStream must have a producer when instantiated. A producer is an iterable that returns a string each time it is called. """ self._producer = producer self._empty = False self._leftover = b'' ...
[ "def", "__init__", "(", "self", ",", "producer", ",", "length", "=", "None", ")", ":", "self", ".", "_producer", "=", "producer", "self", ".", "_empty", "=", "False", "self", ".", "_leftover", "=", "b''", "self", ".", "length", "=", "length", "self", ...
[ 295, 4 ]
[ 308, 32 ]
python
en
['en', 'error', 'th']
False
LazyStream.__next__
(self)
Used when the exact number of bytes to read is unimportant. This procedure just returns whatever is chunk is conveniently returned from the iterator instead. Useful to avoid unnecessary bookkeeping if performance is an issue.
Used when the exact number of bytes to read is unimportant.
def __next__(self): """ Used when the exact number of bytes to read is unimportant. This procedure just returns whatever is chunk is conveniently returned from the iterator instead. Useful to avoid unnecessary bookkeeping if performance is an issue. """ if self._...
[ "def", "__next__", "(", "self", ")", ":", "if", "self", ".", "_leftover", ":", "output", "=", "self", ".", "_leftover", "self", ".", "_leftover", "=", "b''", "else", ":", "output", "=", "next", "(", "self", ".", "_producer", ")", "self", ".", "_unget...
[ 337, 4 ]
[ 352, 21 ]
python
en
['en', 'error', 'th']
False
LazyStream.close
(self)
Used to invalidate/disable this lazy stream. Replaces the producer with an empty list. Any leftover bytes that have already been read will still be reported upon read() and/or next().
Used to invalidate/disable this lazy stream.
def close(self): """ Used to invalidate/disable this lazy stream. Replaces the producer with an empty list. Any leftover bytes that have already been read will still be reported upon read() and/or next(). """ self._producer = []
[ "def", "close", "(", "self", ")", ":", "self", ".", "_producer", "=", "[", "]" ]
[ 354, 4 ]
[ 361, 27 ]
python
en
['en', 'error', 'th']
False
LazyStream.unget
(self, bytes)
Places bytes back onto the front of the lazy stream. Future calls to read() will return those bytes first. The stream position and thus tell() will be rewound.
Places bytes back onto the front of the lazy stream.
def unget(self, bytes): """ Places bytes back onto the front of the lazy stream. Future calls to read() will return those bytes first. The stream position and thus tell() will be rewound. """ if not bytes: return self._update_unget_history(len(bytes))...
[ "def", "unget", "(", "self", ",", "bytes", ")", ":", "if", "not", "bytes", ":", "return", "self", ".", "_update_unget_history", "(", "len", "(", "bytes", ")", ")", "self", ".", "position", "-=", "len", "(", "bytes", ")", "self", ".", "_leftover", "="...
[ 366, 4 ]
[ 377, 58 ]
python
en
['en', 'error', 'th']
False
LazyStream._update_unget_history
(self, num_bytes)
Updates the unget history as a sanity check to see if we've pushed back the same number of bytes in one chunk. If we keep ungetting the same number of bytes many times (here, 50), we're mostly likely in an infinite loop of some sort. This is usually caused by a maliciously-malfo...
Updates the unget history as a sanity check to see if we've pushed back the same number of bytes in one chunk. If we keep ungetting the same number of bytes many times (here, 50), we're mostly likely in an infinite loop of some sort. This is usually caused by a maliciously-malfo...
def _update_unget_history(self, num_bytes): """ Updates the unget history as a sanity check to see if we've pushed back the same number of bytes in one chunk. If we keep ungetting the same number of bytes many times (here, 50), we're mostly likely in an infinite loop of some sort...
[ "def", "_update_unget_history", "(", "self", ",", "num_bytes", ")", ":", "self", ".", "_unget_history", "=", "[", "num_bytes", "]", "+", "self", ".", "_unget_history", "[", ":", "49", "]", "number_equal", "=", "len", "(", "[", "current_number", "for", "cur...
[ 379, 4 ]
[ 396, 13 ]
python
en
['en', 'error', 'th']
False
BoundaryIter._find_boundary
(self, data, eof=False)
Finds a multipart boundary in data. Should no boundary exist in the data None is returned instead. Otherwise a tuple containing the indices of the following are returned: * the end of current encapsulation * the start of the next encapsulation
Finds a multipart boundary in data.
def _find_boundary(self, data, eof=False): """ Finds a multipart boundary in data. Should no boundary exist in the data None is returned instead. Otherwise a tuple containing the indices of the following are returned: * the end of current encapsulation * the start of ...
[ "def", "_find_boundary", "(", "self", ",", "data", ",", "eof", "=", "False", ")", ":", "index", "=", "data", ".", "find", "(", "self", ".", "_boundary", ")", "if", "index", "<", "0", ":", "return", "None", "else", ":", "end", "=", "index", "next", ...
[ 512, 4 ]
[ 535, 28 ]
python
en
['en', 'error', 'th']
False
formset_factory
(form, formset=BaseFormSet, extra=1, can_order=False, can_delete=False, max_num=None, validate_max=False, min_num=None, validate_min=False)
Return a FormSet for the given form class.
Return a FormSet for the given form class.
def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False, can_delete=False, max_num=None, validate_max=False, min_num=None, validate_min=False): """Return a FormSet for the given form class.""" if min_num is None: min_num = DEFAULT_MIN_NUM if ma...
[ "def", "formset_factory", "(", "form", ",", "formset", "=", "BaseFormSet", ",", "extra", "=", "1", ",", "can_order", "=", "False", ",", "can_delete", "=", "False", ",", "max_num", "=", "None", ",", "validate_max", "=", "False", ",", "min_num", "=", "None...
[ 413, 0 ]
[ 430, 66 ]
python
en
['en', 'en', 'en']
True
all_valid
(formsets)
Returns true if every formset in formsets is valid.
Returns true if every formset in formsets is valid.
def all_valid(formsets): """Returns true if every formset in formsets is valid.""" valid = True for formset in formsets: if not formset.is_valid(): valid = False return valid
[ "def", "all_valid", "(", "formsets", ")", ":", "valid", "=", "True", "for", "formset", "in", "formsets", ":", "if", "not", "formset", ".", "is_valid", "(", ")", ":", "valid", "=", "False", "return", "valid" ]
[ 433, 0 ]
[ 439, 16 ]
python
en
['en', 'en', 'en']
True
GeoIP.__init__
(self, path=None, cache=0, country=None, city=None)
Initializes the GeoIP object, no parameters are required to use default settings. Keyword arguments may be passed in to customize the locations of the GeoIP data sets. * path: Base directory to where GeoIP data is located or the full path to where the city or country data ...
Initializes the GeoIP object, no parameters are required to use default settings. Keyword arguments may be passed in to customize the locations of the GeoIP data sets.
def __init__(self, path=None, cache=0, country=None, city=None): """ Initializes the GeoIP object, no parameters are required to use default settings. Keyword arguments may be passed in to customize the locations of the GeoIP data sets. * path: Base directory to where GeoIP dat...
[ "def", "__init__", "(", "self", ",", "path", "=", "None", ",", "cache", "=", "0", ",", "country", "=", "None", ",", "city", "=", "None", ")", ":", "# Checking the given cache option.", "if", "cache", "in", "self", ".", "cache_options", ":", "self", ".", ...
[ 60, 4 ]
[ 128, 81 ]
python
en
['en', 'error', 'th']
False
GeoIP._check_query
(self, query, country=False, city=False, city_or_country=False)
Helper routine for checking the query and database availability.
Helper routine for checking the query and database availability.
def _check_query(self, query, country=False, city=False, city_or_country=False): "Helper routine for checking the query and database availability." # Making sure a string was passed in for the query. if not isinstance(query, six.string_types): raise TypeError('GeoIP query must be a s...
[ "def", "_check_query", "(", "self", ",", "query", ",", "country", "=", "False", ",", "city", "=", "False", ",", "city_or_country", "=", "False", ")", ":", "# Making sure a string was passed in for the query.", "if", "not", "isinstance", "(", "query", ",", "six",...
[ 139, 4 ]
[ 154, 33 ]
python
en
['en', 'en', 'en']
True
GeoIP.city
(self, query)
Returns a dictionary of city information for the given IP address or Fully Qualified Domain Name (FQDN). Some information in the dictionary may be undefined (None).
Returns a dictionary of city information for the given IP address or Fully Qualified Domain Name (FQDN). Some information in the dictionary may be undefined (None).
def city(self, query): """ Returns a dictionary of city information for the given IP address or Fully Qualified Domain Name (FQDN). Some information in the dictionary may be undefined (None). """ enc_query = self._check_query(query, city=True) if ipv4_re.match(qu...
[ "def", "city", "(", "self", ",", "query", ")", ":", "enc_query", "=", "self", ".", "_check_query", "(", "query", ",", "city", "=", "True", ")", "if", "ipv4_re", ".", "match", "(", "query", ")", ":", "# If an IP address was passed in", "return", "GeoIP_reco...
[ 156, 4 ]
[ 168, 72 ]
python
en
['en', 'error', 'th']
False
GeoIP.country_code
(self, query)
Returns the country code for the given IP Address or FQDN.
Returns the country code for the given IP Address or FQDN.
def country_code(self, query): "Returns the country code for the given IP Address or FQDN." enc_query = self._check_query(query, city_or_country=True) if self._country: if ipv4_re.match(query): return GeoIP_country_code_by_addr(self._country, enc_query) el...
[ "def", "country_code", "(", "self", ",", "query", ")", ":", "enc_query", "=", "self", ".", "_check_query", "(", "query", ",", "city_or_country", "=", "True", ")", "if", "self", ".", "_country", ":", "if", "ipv4_re", ".", "match", "(", "query", ")", ":"...
[ 170, 4 ]
[ 179, 51 ]
python
en
['en', 'en', 'en']
True
GeoIP.country_name
(self, query)
Returns the country name for the given IP Address or FQDN.
Returns the country name for the given IP Address or FQDN.
def country_name(self, query): "Returns the country name for the given IP Address or FQDN." enc_query = self._check_query(query, city_or_country=True) if self._country: if ipv4_re.match(query): return GeoIP_country_name_by_addr(self._country, enc_query) el...
[ "def", "country_name", "(", "self", ",", "query", ")", ":", "enc_query", "=", "self", ".", "_check_query", "(", "query", ",", "city_or_country", "=", "True", ")", "if", "self", ".", "_country", ":", "if", "ipv4_re", ".", "match", "(", "query", ")", ":"...
[ 181, 4 ]
[ 190, 51 ]
python
en
['en', 'en', 'en']
True
GeoIP.country
(self, query)
Returns a dictionary with the country code and name when given an IP address or a Fully Qualified Domain Name (FQDN). For example, both '24.124.1.80' and 'djangoproject.com' are valid parameters.
Returns a dictionary with the country code and name when given an IP address or a Fully Qualified Domain Name (FQDN). For example, both '24.124.1.80' and 'djangoproject.com' are valid parameters.
def country(self, query): """ Returns a dictionary with the country code and name when given an IP address or a Fully Qualified Domain Name (FQDN). For example, both '24.124.1.80' and 'djangoproject.com' are valid parameters. """ # Returning the country code and name ...
[ "def", "country", "(", "self", ",", "query", ")", ":", "# Returning the country code and name", "return", "{", "'country_code'", ":", "self", ".", "country_code", "(", "query", ")", ",", "'country_name'", ":", "self", ".", "country_name", "(", "query", ")", ",...
[ 192, 4 ]
[ 201, 17 ]
python
en
['en', 'error', 'th']
False
GeoIP.lon_lat
(self, query)
Returns a tuple of the (longitude, latitude) for the given query.
Returns a tuple of the (longitude, latitude) for the given query.
def lon_lat(self, query): "Returns a tuple of the (longitude, latitude) for the given query." return self.coords(query)
[ "def", "lon_lat", "(", "self", ",", "query", ")", ":", "return", "self", ".", "coords", "(", "query", ")" ]
[ 211, 4 ]
[ 213, 33 ]
python
en
['en', 'en', 'en']
True
GeoIP.lat_lon
(self, query)
Returns a tuple of the (latitude, longitude) for the given query.
Returns a tuple of the (latitude, longitude) for the given query.
def lat_lon(self, query): "Returns a tuple of the (latitude, longitude) for the given query." return self.coords(query, ('latitude', 'longitude'))
[ "def", "lat_lon", "(", "self", ",", "query", ")", ":", "return", "self", ".", "coords", "(", "query", ",", "(", "'latitude'", ",", "'longitude'", ")", ")" ]
[ 215, 4 ]
[ 217, 60 ]
python
en
['en', 'en', 'en']
True
GeoIP.geos
(self, query)
Returns a GEOS Point object for the given query.
Returns a GEOS Point object for the given query.
def geos(self, query): "Returns a GEOS Point object for the given query." ll = self.lon_lat(query) if ll: from django.contrib.gis.geos import Point return Point(ll, srid=4326) else: return None
[ "def", "geos", "(", "self", ",", "query", ")", ":", "ll", "=", "self", ".", "lon_lat", "(", "query", ")", "if", "ll", ":", "from", "django", ".", "contrib", ".", "gis", ".", "geos", "import", "Point", "return", "Point", "(", "ll", ",", "srid", "=...
[ 219, 4 ]
[ 226, 23 ]
python
en
['en', 'en', 'en']
True
GeoIP.country_info
(self)
Returns information about the GeoIP country database.
Returns information about the GeoIP country database.
def country_info(self): "Returns information about the GeoIP country database." if self._country is None: ci = 'No GeoIP Country data in "%s"' % self._country_file else: ci = GeoIP_database_info(self._country) return ci
[ "def", "country_info", "(", "self", ")", ":", "if", "self", ".", "_country", "is", "None", ":", "ci", "=", "'No GeoIP Country data in \"%s\"'", "%", "self", ".", "_country_file", "else", ":", "ci", "=", "GeoIP_database_info", "(", "self", ".", "_country", ")...
[ 230, 4 ]
[ 236, 17 ]
python
en
['en', 'en', 'en']
True
GeoIP.city_info
(self)
Returns information about the GeoIP city database.
Returns information about the GeoIP city database.
def city_info(self): "Returns information about the GeoIP city database." if self._city is None: ci = 'No GeoIP City data in "%s"' % self._city_file else: ci = GeoIP_database_info(self._city) return ci
[ "def", "city_info", "(", "self", ")", ":", "if", "self", ".", "_city", "is", "None", ":", "ci", "=", "'No GeoIP City data in \"%s\"'", "%", "self", ".", "_city_file", "else", ":", "ci", "=", "GeoIP_database_info", "(", "self", ".", "_city", ")", "return", ...
[ 239, 4 ]
[ 245, 17 ]
python
en
['en', 'en', 'en']
True
GeoIP.info
(self)
Returns information about the GeoIP library and databases in use.
Returns information about the GeoIP library and databases in use.
def info(self): "Returns information about the GeoIP library and databases in use." info = '' if GeoIP_lib_version: info += 'GeoIP Library:\n\t%s\n' % GeoIP_lib_version() return info + 'Country:\n\t%s\nCity:\n\t%s' % (self.country_info, self.city_info)
[ "def", "info", "(", "self", ")", ":", "info", "=", "''", "if", "GeoIP_lib_version", ":", "info", "+=", "'GeoIP Library:\\n\\t%s\\n'", "%", "GeoIP_lib_version", "(", ")", "return", "info", "+", "'Country:\\n\\t%s\\nCity:\\n\\t%s'", "%", "(", "self", ".", "country...
[ 248, 4 ]
[ 253, 89 ]
python
en
['en', 'en', 'en']
True
one_hot
(x, k, dtype=np.float32)
Create a one-hot encoding of x of size k.
Create a one-hot encoding of x of size k.
def one_hot(x, k, dtype=np.float32): """Create a one-hot encoding of x of size k.""" return np.array(x[:, None] == np.arange(k), dtype)
[ "def", "one_hot", "(", "x", ",", "k", ",", "dtype", "=", "np", ".", "float32", ")", ":", "return", "np", ".", "array", "(", "x", "[", ":", ",", "None", "]", "==", "np", ".", "arange", "(", "k", ")", ",", "dtype", ")" ]
[ 3, 0 ]
[ 5, 54 ]
python
en
['en', 'en', 'en']
True
partial_flatten
(x)
Flatten all but the first dimension of an ndarray.
Flatten all but the first dimension of an ndarray.
def partial_flatten(x): """Flatten all but the first dimension of an ndarray.""" return np.reshape(x, (x.shape[0], -1))
[ "def", "partial_flatten", "(", "x", ")", ":", "return", "np", ".", "reshape", "(", "x", ",", "(", "x", ".", "shape", "[", "0", "]", ",", "-", "1", ")", ")" ]
[ 8, 0 ]
[ 10, 42 ]
python
en
['en', 'lb', 'en']
True
clip_eta
(eta, norm, eps)
Helper function to clip the perturbation to epsilon norm ball. :param eta: A tensor with the current perturbation. :param norm: Order of the norm (mimics Numpy). Possible values: np.inf or 2. :param eps: Epsilon, bound of the perturbation.
Helper function to clip the perturbation to epsilon norm ball. :param eta: A tensor with the current perturbation. :param norm: Order of the norm (mimics Numpy). Possible values: np.inf or 2. :param eps: Epsilon, bound of the perturbation.
def clip_eta(eta, norm, eps): """ Helper function to clip the perturbation to epsilon norm ball. :param eta: A tensor with the current perturbation. :param norm: Order of the norm (mimics Numpy). Possible values: np.inf or 2. :param eps: Epsilon, bound of the perturbation. """ ...
[ "def", "clip_eta", "(", "eta", ",", "norm", ",", "eps", ")", ":", "# Clipping perturbation eta to self.norm norm ball", "if", "norm", "not", "in", "[", "np", ".", "inf", ",", "2", "]", ":", "raise", "ValueError", "(", "\"norm must be np.inf or 2.\"", ")", "axi...
[ 13, 0 ]
[ 38, 14 ]
python
en
['en', 'error', 'th']
False
get_srid_info
(srid, connection)
Return the units, unit name, and spheroid WKT associated with the given SRID from the `spatial_ref_sys` (or equivalent) spatial database table for the given database connection. These results are cached.
Return the units, unit name, and spheroid WKT associated with the given SRID from the `spatial_ref_sys` (or equivalent) spatial database table for the given database connection. These results are cached.
def get_srid_info(srid, connection): """ Return the units, unit name, and spheroid WKT associated with the given SRID from the `spatial_ref_sys` (or equivalent) spatial database table for the given database connection. These results are cached. """ from django.contrib.gis.gdal import SpatialRef...
[ "def", "get_srid_info", "(", "srid", ",", "connection", ")", ":", "from", "django", ".", "contrib", ".", "gis", ".", "gdal", "import", "SpatialReference", "global", "_srid_cache", "try", ":", "# The SpatialRefSys model for the spatial backend.", "SpatialRefSys", "=", ...
[ 22, 0 ]
[ 52, 35 ]
python
en
['en', 'error', 'th']
False
BaseSpatialField.__init__
(self, verbose_name=None, srid=4326, spatial_index=True, **kwargs)
The initialization function for base spatial fields. Takes the following as keyword arguments: srid: The spatial reference system identifier, an OGC standard. Defaults to 4326 (WGS84). spatial_index: Indicates whether to create a spatial index. Defaults to ...
The initialization function for base spatial fields. Takes the following as keyword arguments:
def __init__(self, verbose_name=None, srid=4326, spatial_index=True, **kwargs): """ The initialization function for base spatial fields. Takes the following as keyword arguments: srid: The spatial reference system identifier, an OGC standard. Defaults to 4326 (WGS84). ...
[ "def", "__init__", "(", "self", ",", "verbose_name", "=", "None", ",", "srid", "=", "4326", ",", "spatial_index", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# Setting the index flag with the value of the `spatial_index` keyword.", "self", ".", "spatial_index",...
[ 66, 4 ]
[ 92, 34 ]
python
en
['en', 'error', 'th']
False
BaseSpatialField.geodetic
(self, connection)
Return true if this field's SRID corresponds with a coordinate system that uses non-projected units (e.g., latitude/longitude).
Return true if this field's SRID corresponds with a coordinate system that uses non-projected units (e.g., latitude/longitude).
def geodetic(self, connection): """ Return true if this field's SRID corresponds with a coordinate system that uses non-projected units (e.g., latitude/longitude). """ return get_srid_info(self.srid, connection).geodetic
[ "def", "geodetic", "(", "self", ",", "connection", ")", ":", "return", "get_srid_info", "(", "self", ".", "srid", ",", "connection", ")", ".", "geodetic" ]
[ 115, 4 ]
[ 120, 60 ]
python
en
['en', 'error', 'th']
False
BaseSpatialField.get_placeholder
(self, value, compiler, connection)
Return the placeholder for the spatial column for the given value.
Return the placeholder for the spatial column for the given value.
def get_placeholder(self, value, compiler, connection): """ Return the placeholder for the spatial column for the given value. """ return connection.ops.get_geom_placeholder(self, value, compiler)
[ "def", "get_placeholder", "(", "self", ",", "value", ",", "compiler", ",", "connection", ")", ":", "return", "connection", ".", "ops", ".", "get_geom_placeholder", "(", "self", ",", "value", ",", "compiler", ")" ]
[ 122, 4 ]
[ 127, 73 ]
python
en
['en', 'error', 'th']
False
BaseSpatialField.get_srid
(self, obj)
Return the default SRID for the given geometry or raster, taking into account the SRID set for the field. For example, if the input geometry or raster doesn't have an SRID, then the SRID of the field will be returned.
Return the default SRID for the given geometry or raster, taking into account the SRID set for the field. For example, if the input geometry or raster doesn't have an SRID, then the SRID of the field will be returned.
def get_srid(self, obj): """ Return the default SRID for the given geometry or raster, taking into account the SRID set for the field. For example, if the input geometry or raster doesn't have an SRID, then the SRID of the field will be returned. """ srid = obj.sr...
[ "def", "get_srid", "(", "self", ",", "obj", ")", ":", "srid", "=", "obj", ".", "srid", "# SRID of given geometry.", "if", "srid", "is", "None", "or", "self", ".", "srid", "==", "-", "1", "or", "(", "srid", "==", "-", "1", "and", "self", ".", "srid"...
[ 129, 4 ]
[ 140, 23 ]
python
en
['en', 'error', 'th']
False
BaseSpatialField.get_raster_prep_value
(self, value, is_candidate)
Return a GDALRaster if conversion is successful, otherwise return None.
Return a GDALRaster if conversion is successful, otherwise return None.
def get_raster_prep_value(self, value, is_candidate): """ Return a GDALRaster if conversion is successful, otherwise return None. """ if isinstance(value, gdal.GDALRaster): return value elif is_candidate: try: return gdal.GDALRaster(value) ...
[ "def", "get_raster_prep_value", "(", "self", ",", "value", ",", "is_candidate", ")", ":", "if", "isinstance", "(", "value", ",", "gdal", ".", "GDALRaster", ")", ":", "return", "value", "elif", "is_candidate", ":", "try", ":", "return", "gdal", ".", "GDALRa...
[ 150, 4 ]
[ 165, 98 ]
python
en
['en', 'error', 'th']
False
GeometryField.__init__
(self, verbose_name=None, dim=2, geography=False, *, extent=(-180.0, -90.0, 180.0, 90.0), tolerance=0.05, **kwargs)
The initialization function for geometry fields. In addition to the parameters from BaseSpatialField, it takes the following as keyword arguments: dim: The number of dimensions for this geometry. Defaults to 2. extent: Customize the extent, in a 4-tuple of W...
The initialization function for geometry fields. In addition to the parameters from BaseSpatialField, it takes the following as keyword arguments:
def __init__(self, verbose_name=None, dim=2, geography=False, *, extent=(-180.0, -90.0, 180.0, 90.0), tolerance=0.05, **kwargs): """ The initialization function for geometry fields. In addition to the parameters from BaseSpatialField, it takes the following as keyword ar...
[ "def", "__init__", "(", "self", ",", "verbose_name", "=", "None", ",", "dim", "=", "2", ",", "geography", "=", "False", ",", "*", ",", "extent", "=", "(", "-", "180.0", ",", "-", "90.0", ",", "180.0", ",", "90.0", ")", ",", "tolerance", "=", "0.0...
[ 206, 4 ]
[ 236, 61 ]
python
en
['en', 'error', 'th']
False
GeometryField.select_format
(self, compiler, sql, params)
Return the selection format string, depending on the requirements of the spatial backend. For example, Oracle and MySQL require custom selection formats in order to retrieve geometries in OGC WKB.
Return the selection format string, depending on the requirements of the spatial backend. For example, Oracle and MySQL require custom selection formats in order to retrieve geometries in OGC WKB.
def select_format(self, compiler, sql, params): """ Return the selection format string, depending on the requirements of the spatial backend. For example, Oracle and MySQL require custom selection formats in order to retrieve geometries in OGC WKB. """ if not compiler.que...
[ "def", "select_format", "(", "self", ",", "compiler", ",", "sql", ",", "params", ")", ":", "if", "not", "compiler", ".", "query", ".", "subquery", ":", "return", "compiler", ".", "connection", ".", "ops", ".", "select", "%", "sql", ",", "params", "retu...
[ 268, 4 ]
[ 276, 26 ]
python
en
['en', 'error', 'th']
False
write_emoticon_data
( realm_id: int, custom_emoji_data: List[Dict[str, Any]], data_dir: str, output_dir: str )
This function does most of the work for processing emoticons, the bulk of which is copying files. We also write a json file with metadata. Finally, we return a list of RealmEmoji dicts to our caller. In our data_dir we have a pretty simple setup: The exported JSON file will have emoji rows i...
This function does most of the work for processing emoticons, the bulk of which is copying files. We also write a json file with metadata. Finally, we return a list of RealmEmoji dicts to our caller.
def write_emoticon_data( realm_id: int, custom_emoji_data: List[Dict[str, Any]], data_dir: str, output_dir: str ) -> List[ZerverFieldsT]: """ This function does most of the work for processing emoticons, the bulk of which is copying files. We also write a json file with metadata. Finally, we return...
[ "def", "write_emoticon_data", "(", "realm_id", ":", "int", ",", "custom_emoji_data", ":", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ",", "data_dir", ":", "str", ",", "output_dir", ":", "str", ")", "->", "List", "[", "ZerverFieldsT", "]", "...
[ 597, 0 ]
[ 678, 21 ]
python
en
['en', 'error', 'th']
False
add_missing_messages
(user_profile: UserProfile)
This function takes a soft-deactivated user, and computes and adds to the database any UserMessage rows that were not created while the user was soft-deactivated. The end result is that from the perspective of the message database, it should be impossible to tell that the user was soft-deactivated at a...
This function takes a soft-deactivated user, and computes and adds to the database any UserMessage rows that were not created while the user was soft-deactivated. The end result is that from the perspective of the message database, it should be impossible to tell that the user was soft-deactivated at a...
def add_missing_messages(user_profile: UserProfile) -> None: """This function takes a soft-deactivated user, and computes and adds to the database any UserMessage rows that were not created while the user was soft-deactivated. The end result is that from the perspective of the message database, it shou...
[ "def", "add_missing_messages", "(", "user_profile", ":", "UserProfile", ")", "->", "None", ":", "assert", "user_profile", ".", "last_active_message_id", "is", "not", "None", "all_stream_subs", "=", "list", "(", "Subscription", ".", "objects", ".", "filter", "(", ...
[ 102, 0 ]
[ 227, 67 ]
python
en
['en', 'en', 'en']
True
MultiValueDict.__getitem__
(self, key)
Return the last data value for this key, or [] if it's an empty list; raise KeyError if not found.
Return the last data value for this key, or [] if it's an empty list; raise KeyError if not found.
def __getitem__(self, key): """ Return the last data value for this key, or [] if it's an empty list; raise KeyError if not found. """ try: list_ = super().__getitem__(key) except KeyError: raise MultiValueDictKeyError(key) try: ...
[ "def", "__getitem__", "(", "self", ",", "key", ")", ":", "try", ":", "list_", "=", "super", "(", ")", ".", "__getitem__", "(", "key", ")", "except", "KeyError", ":", "raise", "MultiValueDictKeyError", "(", "key", ")", "try", ":", "return", "list_", "["...
[ 69, 4 ]
[ 81, 21 ]
python
en
['en', 'error', 'th']
False
MultiValueDict.get
(self, key, default=None)
Return the last data value for the passed key. If key doesn't exist or value is an empty list, return `default`.
Return the last data value for the passed key. If key doesn't exist or value is an empty list, return `default`.
def get(self, key, default=None): """ Return the last data value for the passed key. If key doesn't exist or value is an empty list, return `default`. """ try: val = self[key] except KeyError: return default if val == []: return...
[ "def", "get", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "try", ":", "val", "=", "self", "[", "key", "]", "except", "KeyError", ":", "return", "default", "if", "val", "==", "[", "]", ":", "return", "default", "return", "val" ]
[ 109, 4 ]
[ 120, 18 ]
python
en
['en', 'error', 'th']
False
MultiValueDict._getlist
(self, key, default=None, force_list=False)
Return a list of values for the key. Used internally to manipulate values list. If force_list is True, return a new copy of values.
Return a list of values for the key.
def _getlist(self, key, default=None, force_list=False): """ Return a list of values for the key. Used internally to manipulate values list. If force_list is True, return a new copy of values. """ try: values = super().__getitem__(key) except KeyError...
[ "def", "_getlist", "(", "self", ",", "key", ",", "default", "=", "None", ",", "force_list", "=", "False", ")", ":", "try", ":", "values", "=", "super", "(", ")", ".", "__getitem__", "(", "key", ")", "except", "KeyError", ":", "if", "default", "is", ...
[ 122, 4 ]
[ 138, 25 ]
python
en
['en', 'error', 'th']
False
MultiValueDict.getlist
(self, key, default=None)
Return the list of values for the key. If key doesn't exist, return a default value.
Return the list of values for the key. If key doesn't exist, return a default value.
def getlist(self, key, default=None): """ Return the list of values for the key. If key doesn't exist, return a default value. """ return self._getlist(key, default, force_list=True)
[ "def", "getlist", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "return", "self", ".", "_getlist", "(", "key", ",", "default", ",", "force_list", "=", "True", ")" ]
[ 140, 4 ]
[ 145, 59 ]
python
en
['en', 'error', 'th']
False
MultiValueDict.appendlist
(self, key, value)
Append an item to the internal list associated with key.
Append an item to the internal list associated with key.
def appendlist(self, key, value): """Append an item to the internal list associated with key.""" self.setlistdefault(key).append(value)
[ "def", "appendlist", "(", "self", ",", "key", ",", "value", ")", ":", "self", ".", "setlistdefault", "(", "key", ")", ".", "append", "(", "value", ")" ]
[ 166, 4 ]
[ 168, 46 ]
python
en
['en', 'en', 'en']
True
MultiValueDict.items
(self)
Yield (key, value) pairs, where value is the last item in the list associated with the key.
Yield (key, value) pairs, where value is the last item in the list associated with the key.
def items(self): """ Yield (key, value) pairs, where value is the last item in the list associated with the key. """ for key in self: yield key, self[key]
[ "def", "items", "(", "self", ")", ":", "for", "key", "in", "self", ":", "yield", "key", ",", "self", "[", "key", "]" ]
[ 170, 4 ]
[ 176, 32 ]
python
en
['en', 'error', 'th']
False
MultiValueDict.lists
(self)
Yield (key, list) pairs.
Yield (key, list) pairs.
def lists(self): """Yield (key, list) pairs.""" return iter(super().items())
[ "def", "lists", "(", "self", ")", ":", "return", "iter", "(", "super", "(", ")", ".", "items", "(", ")", ")" ]
[ 178, 4 ]
[ 180, 36 ]
python
en
['en', 'hmn', 'en']
True
MultiValueDict.values
(self)
Yield the last value on every key list.
Yield the last value on every key list.
def values(self): """Yield the last value on every key list.""" for key in self: yield self[key]
[ "def", "values", "(", "self", ")", ":", "for", "key", "in", "self", ":", "yield", "self", "[", "key", "]" ]
[ 182, 4 ]
[ 185, 27 ]
python
en
['en', 'en', 'en']
True
MultiValueDict.copy
(self)
Return a shallow copy of this object.
Return a shallow copy of this object.
def copy(self): """Return a shallow copy of this object.""" return copy.copy(self)
[ "def", "copy", "(", "self", ")", ":", "return", "copy", ".", "copy", "(", "self", ")" ]
[ 187, 4 ]
[ 189, 30 ]
python
en
['en', 'en', 'en']
True
MultiValueDict.update
(self, *args, **kwargs)
Extend rather than replace existing key lists.
Extend rather than replace existing key lists.
def update(self, *args, **kwargs): """Extend rather than replace existing key lists.""" if len(args) > 1: raise TypeError("update expected at most 1 argument, got %d" % len(args)) if args: other_dict = args[0] if isinstance(other_dict, MultiValueDict): ...
[ "def", "update", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", ">", "1", ":", "raise", "TypeError", "(", "\"update expected at most 1 argument, got %d\"", "%", "len", "(", "args", ")", ")", "if", "args...
[ 191, 4 ]
[ 207, 50 ]
python
en
['en', 'en', 'en']
True
MultiValueDict.dict
(self)
Return current object as a dict with singular values.
Return current object as a dict with singular values.
def dict(self): """Return current object as a dict with singular values.""" return {key: self[key] for key in self}
[ "def", "dict", "(", "self", ")", ":", "return", "{", "key", ":", "self", "[", "key", "]", "for", "key", "in", "self", "}" ]
[ 209, 4 ]
[ 211, 47 ]
python
en
['en', 'en', 'en']
True
DictWrapper.__getitem__
(self, key)
Retrieve the real value after stripping the prefix string (if present). If the prefix is present, pass the value through self.func before returning, otherwise return the raw value.
Retrieve the real value after stripping the prefix string (if present). If the prefix is present, pass the value through self.func before returning, otherwise return the raw value.
def __getitem__(self, key): """ Retrieve the real value after stripping the prefix string (if present). If the prefix is present, pass the value through self.func before returning, otherwise return the raw value. """ use_func = key.startswith(self.prefix) if use_f...
[ "def", "__getitem__", "(", "self", ",", "key", ")", ":", "use_func", "=", "key", ".", "startswith", "(", "self", ".", "prefix", ")", "if", "use_func", ":", "key", "=", "key", "[", "len", "(", "self", ".", "prefix", ")", ":", "]", "value", "=", "s...
[ 268, 4 ]
[ 280, 20 ]
python
en
['en', 'error', 'th']
False
test_disallowed_methods
(all_user_types_api_client, list_url, detail_url)
Tests that only safe methods are allowed to resource type list and detail endpoints.
Tests that only safe methods are allowed to resource type list and detail endpoints.
def test_disallowed_methods(all_user_types_api_client, list_url, detail_url): """ Tests that only safe methods are allowed to resource type list and detail endpoints. """ check_only_safe_methods_allowed(all_user_types_api_client, (list_url, detail_url))
[ "def", "test_disallowed_methods", "(", "all_user_types_api_client", ",", "list_url", ",", "detail_url", ")", ":", "check_only_safe_methods_allowed", "(", "all_user_types_api_client", ",", "(", "list_url", ",", "detail_url", ")", ")" ]
[ 21, 0 ]
[ 25, 86 ]
python
en
['en', 'error', 'th']
False
translate_pattern
(glob)
Translate a file path glob like '*.txt' in to a regular expression. This differs from fnmatch.translate which allows wildcards to match directory separators. It also knows about '**/' which matches any number of directories.
Translate a file path glob like '*.txt' in to a regular expression. This differs from fnmatch.translate which allows wildcards to match directory separators. It also knows about '**/' which matches any number of directories.
def translate_pattern(glob): """ Translate a file path glob like '*.txt' in to a regular expression. This differs from fnmatch.translate which allows wildcards to match directory separators. It also knows about '**/' which matches any number of directories. """ pat = '' # This will spli...
[ "def", "translate_pattern", "(", "glob", ")", ":", "pat", "=", "''", "# This will split on '/' within [character classes]. This is deliberate.", "chunks", "=", "glob", ".", "split", "(", "os", ".", "path", ".", "sep", ")", "sep", "=", "re", ".", "escape", "(", ...
[ 36, 0 ]
[ 116, 58 ]
python
en
['en', 'error', 'th']
False
write_file
(filename, contents)
Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it.
Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it.
def write_file(filename, contents): """Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it. """ contents = "\n".join(contents) # assuming the contents has been vetted for utf-8 encoding contents = contents.encode("utf-8") with o...
[ "def", "write_file", "(", "filename", ",", "contents", ")", ":", "contents", "=", "\"\\n\"", ".", "join", "(", "contents", ")", "# assuming the contents has been vetted for utf-8 encoding", "contents", "=", "contents", ".", "encode", "(", "\"utf-8\"", ")", "with", ...
[ 598, 0 ]
[ 608, 25 ]
python
en
['en', 'en', 'en']
True
get_pkg_info_revision
()
Get a -r### off of PKG-INFO Version in case this is an sdist of a subversion revision.
Get a -r### off of PKG-INFO Version in case this is an sdist of a subversion revision.
def get_pkg_info_revision(): """ Get a -r### off of PKG-INFO Version in case this is an sdist of a subversion revision. """ warnings.warn( "get_pkg_info_revision is deprecated.", EggInfoDeprecationWarning) if os.path.exists('PKG-INFO'): with io.open('PKG-INFO') as f: ...
[ "def", "get_pkg_info_revision", "(", ")", ":", "warnings", ".", "warn", "(", "\"get_pkg_info_revision is deprecated.\"", ",", "EggInfoDeprecationWarning", ")", "if", "os", ".", "path", ".", "exists", "(", "'PKG-INFO'", ")", ":", "with", "io", ".", "open", "(", ...
[ 703, 0 ]
[ 716, 12 ]
python
en
['en', 'error', 'th']
False
egg_info.save_version_info
(self, filename)
Materialize the value of date into the build tag. Install build keys in a deterministic order to avoid arbitrary reordering on subsequent builds.
Materialize the value of date into the build tag. Install build keys in a deterministic order to avoid arbitrary reordering on subsequent builds.
def save_version_info(self, filename): """ Materialize the value of date into the build tag. Install build keys in a deterministic order to avoid arbitrary reordering on subsequent builds. """ egg_info = collections.OrderedDict() # follow the order these keys woul...
[ "def", "save_version_info", "(", "self", ",", "filename", ")", ":", "egg_info", "=", "collections", ".", "OrderedDict", "(", ")", "# follow the order these keys would have been added", "# when PYTHONHASHSEED=0", "egg_info", "[", "'tag_build'", "]", "=", "self", ".", "...
[ 180, 4 ]
[ 191, 54 ]
python
en
['en', 'error', 'th']
False
egg_info.write_or_delete_file
(self, what, filename, data, force=False)
Write `data` to `filename` or delete if empty If `data` is non-empty, this routine is the same as ``write_file()``. If `data` is empty but not ``None``, this is the same as calling ``delete_file(filename)`. If `data` is ``None``, then this is a no-op unless `filename` exists, in which ...
Write `data` to `filename` or delete if empty
def write_or_delete_file(self, what, filename, data, force=False): """Write `data` to `filename` or delete if empty If `data` is non-empty, this routine is the same as ``write_file()``. If `data` is empty but not ``None``, this is the same as calling ``delete_file(filename)`. If `data`...
[ "def", "write_or_delete_file", "(", "self", ",", "what", ",", "filename", ",", "data", ",", "force", "=", "False", ")", ":", "if", "data", ":", "self", ".", "write_file", "(", "what", ",", "filename", ",", "data", ")", "elif", "os", ".", "path", ".",...
[ 242, 4 ]
[ 260, 42 ]
python
en
['en', 'el-Latn', 'en']
True
egg_info.write_file
(self, what, filename, data)
Write `data` to `filename` (if not a dry run) after announcing it `what` is used in a log message to identify what is being written to the file.
Write `data` to `filename` (if not a dry run) after announcing it
def write_file(self, what, filename, data): """Write `data` to `filename` (if not a dry run) after announcing it `what` is used in a log message to identify what is being written to the file. """ log.info("writing %s to %s", what, filename) if not six.PY2: da...
[ "def", "write_file", "(", "self", ",", "what", ",", "filename", ",", "data", ")", ":", "log", ".", "info", "(", "\"writing %s to %s\"", ",", "what", ",", "filename", ")", "if", "not", "six", ".", "PY2", ":", "data", "=", "data", ".", "encode", "(", ...
[ 262, 4 ]
[ 274, 21 ]
python
en
['en', 'en', 'en']
True
egg_info.delete_file
(self, filename)
Delete `filename` (if not a dry run) after announcing it
Delete `filename` (if not a dry run) after announcing it
def delete_file(self, filename): """Delete `filename` (if not a dry run) after announcing it""" log.info("deleting %s", filename) if not self.dry_run: os.unlink(filename)
[ "def", "delete_file", "(", "self", ",", "filename", ")", ":", "log", ".", "info", "(", "\"deleting %s\"", ",", "filename", ")", "if", "not", "self", ".", "dry_run", ":", "os", ".", "unlink", "(", "filename", ")" ]
[ 276, 4 ]
[ 280, 31 ]
python
en
['en', 'en', 'en']
True
egg_info.find_sources
(self)
Generate SOURCES.txt manifest file
Generate SOURCES.txt manifest file
def find_sources(self): """Generate SOURCES.txt manifest file""" manifest_filename = os.path.join(self.egg_info, "SOURCES.txt") mm = manifest_maker(self.distribution) mm.manifest = manifest_filename mm.run() self.filelist = mm.filelist
[ "def", "find_sources", "(", "self", ")", ":", "manifest_filename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "egg_info", ",", "\"SOURCES.txt\"", ")", "mm", "=", "manifest_maker", "(", "self", ".", "distribution", ")", "mm", ".", "manifest", ...
[ 298, 4 ]
[ 304, 35 ]
python
en
['en', 'en', 'it']
True
FileList._remove_files
(self, predicate)
Remove all files from the file list that match the predicate. Return True if any matching files were removed
Remove all files from the file list that match the predicate. Return True if any matching files were removed
def _remove_files(self, predicate): """ Remove all files from the file list that match the predicate. Return True if any matching files were removed """ found = False for i in range(len(self.files) - 1, -1, -1): if predicate(self.files[i]): sel...
[ "def", "_remove_files", "(", "self", ",", "predicate", ")", ":", "found", "=", "False", "for", "i", "in", "range", "(", "len", "(", "self", ".", "files", ")", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "if", "predicate", "(", "self", "."...
[ 398, 4 ]
[ 409, 20 ]
python
en
['en', 'error', 'th']
False
FileList.include
(self, pattern)
Include files that match 'pattern'.
Include files that match 'pattern'.
def include(self, pattern): """Include files that match 'pattern'.""" found = [f for f in glob(pattern) if not os.path.isdir(f)] self.extend(found) return bool(found)
[ "def", "include", "(", "self", ",", "pattern", ")", ":", "found", "=", "[", "f", "for", "f", "in", "glob", "(", "pattern", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "f", ")", "]", "self", ".", "extend", "(", "found", ")", "return"...
[ 411, 4 ]
[ 415, 26 ]
python
en
['en', 'en', 'en']
True
FileList.exclude
(self, pattern)
Exclude files that match 'pattern'.
Exclude files that match 'pattern'.
def exclude(self, pattern): """Exclude files that match 'pattern'.""" match = translate_pattern(pattern) return self._remove_files(match.match)
[ "def", "exclude", "(", "self", ",", "pattern", ")", ":", "match", "=", "translate_pattern", "(", "pattern", ")", "return", "self", ".", "_remove_files", "(", "match", ".", "match", ")" ]
[ 417, 4 ]
[ 420, 46 ]
python
en
['en', 'en', 'en']
True
FileList.recursive_include
(self, dir, pattern)
Include all files anywhere in 'dir/' that match the pattern.
Include all files anywhere in 'dir/' that match the pattern.
def recursive_include(self, dir, pattern): """ Include all files anywhere in 'dir/' that match the pattern. """ full_pattern = os.path.join(dir, '**', pattern) found = [f for f in glob(full_pattern, recursive=True) if not os.path.isdir(f)] self.extend(fou...
[ "def", "recursive_include", "(", "self", ",", "dir", ",", "pattern", ")", ":", "full_pattern", "=", "os", ".", "path", ".", "join", "(", "dir", ",", "'**'", ",", "pattern", ")", "found", "=", "[", "f", "for", "f", "in", "glob", "(", "full_pattern", ...
[ 422, 4 ]
[ 430, 26 ]
python
en
['en', 'error', 'th']
False
FileList.recursive_exclude
(self, dir, pattern)
Exclude any file anywhere in 'dir/' that match the pattern.
Exclude any file anywhere in 'dir/' that match the pattern.
def recursive_exclude(self, dir, pattern): """ Exclude any file anywhere in 'dir/' that match the pattern. """ match = translate_pattern(os.path.join(dir, '**', pattern)) return self._remove_files(match.match)
[ "def", "recursive_exclude", "(", "self", ",", "dir", ",", "pattern", ")", ":", "match", "=", "translate_pattern", "(", "os", ".", "path", ".", "join", "(", "dir", ",", "'**'", ",", "pattern", ")", ")", "return", "self", ".", "_remove_files", "(", "matc...
[ 432, 4 ]
[ 437, 46 ]
python
en
['en', 'error', 'th']
False
FileList.graft
(self, dir)
Include all files from 'dir/'.
Include all files from 'dir/'.
def graft(self, dir): """Include all files from 'dir/'.""" found = [ item for match_dir in glob(dir) for item in distutils.filelist.findall(match_dir) ] self.extend(found) return bool(found)
[ "def", "graft", "(", "self", ",", "dir", ")", ":", "found", "=", "[", "item", "for", "match_dir", "in", "glob", "(", "dir", ")", "for", "item", "in", "distutils", ".", "filelist", ".", "findall", "(", "match_dir", ")", "]", "self", ".", "extend", "...
[ 439, 4 ]
[ 447, 26 ]
python
en
['en', 'en', 'en']
True
FileList.prune
(self, dir)
Filter out files from 'dir/'.
Filter out files from 'dir/'.
def prune(self, dir): """Filter out files from 'dir/'.""" match = translate_pattern(os.path.join(dir, '**')) return self._remove_files(match.match)
[ "def", "prune", "(", "self", ",", "dir", ")", ":", "match", "=", "translate_pattern", "(", "os", ".", "path", ".", "join", "(", "dir", ",", "'**'", ")", ")", "return", "self", ".", "_remove_files", "(", "match", ".", "match", ")" ]
[ 449, 4 ]
[ 452, 46 ]
python
en
['en', 'en', 'en']
True
FileList.global_include
(self, pattern)
Include all files anywhere in the current directory that match the pattern. This is very inefficient on large file trees.
Include all files anywhere in the current directory that match the pattern. This is very inefficient on large file trees.
def global_include(self, pattern): """ Include all files anywhere in the current directory that match the pattern. This is very inefficient on large file trees. """ if self.allfiles is None: self.findall() match = translate_pattern(os.path.join('**', pattern))...
[ "def", "global_include", "(", "self", ",", "pattern", ")", ":", "if", "self", ".", "allfiles", "is", "None", ":", "self", ".", "findall", "(", ")", "match", "=", "translate_pattern", "(", "os", ".", "path", ".", "join", "(", "'**'", ",", "pattern", "...
[ 454, 4 ]
[ 464, 26 ]
python
en
['en', 'error', 'th']
False
FileList.global_exclude
(self, pattern)
Exclude all files anywhere that match the pattern.
Exclude all files anywhere that match the pattern.
def global_exclude(self, pattern): """ Exclude all files anywhere that match the pattern. """ match = translate_pattern(os.path.join('**', pattern)) return self._remove_files(match.match)
[ "def", "global_exclude", "(", "self", ",", "pattern", ")", ":", "match", "=", "translate_pattern", "(", "os", ".", "path", ".", "join", "(", "'**'", ",", "pattern", ")", ")", "return", "self", ".", "_remove_files", "(", "match", ".", "match", ")" ]
[ 466, 4 ]
[ 471, 46 ]
python
en
['en', 'error', 'th']
False
FileList._repair
(self)
Replace self.files with only safe paths Because some owners of FileList manipulate the underlying ``files`` attribute directly, this method must be called to repair those paths.
Replace self.files with only safe paths
def _repair(self): """ Replace self.files with only safe paths Because some owners of FileList manipulate the underlying ``files`` attribute directly, this method must be called to repair those paths. """ self.files = list(filter(self._safe_path, self.files))
[ "def", "_repair", "(", "self", ")", ":", "self", ".", "files", "=", "list", "(", "filter", "(", "self", ".", "_safe_path", ",", "self", ".", "files", ")", ")" ]
[ 484, 4 ]
[ 492, 62 ]
python
en
['en', 'error', 'th']
False
manifest_maker.write_manifest
(self)
Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'.
Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'.
def write_manifest(self): """ Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'. """ self.filelist._repair() # Now _repairs should encodability, but not unicode files = [self._manifest_normalize(f) for f in self.filelist.files] ...
[ "def", "write_manifest", "(", "self", ")", ":", "self", ".", "filelist", ".", "_repair", "(", ")", "# Now _repairs should encodability, but not unicode", "files", "=", "[", "self", ".", "_manifest_normalize", "(", "f", ")", "for", "f", "in", "self", ".", "file...
[ 546, 4 ]
[ 556, 61 ]
python
en
['en', 'error', 'th']
False
manifest_maker._should_suppress_warning
(msg)
suppress missing-file warnings from sdist
suppress missing-file warnings from sdist
def _should_suppress_warning(msg): """ suppress missing-file warnings from sdist """ return re.match(r"standard file .*not found", msg)
[ "def", "_should_suppress_warning", "(", "msg", ")", ":", "return", "re", ".", "match", "(", "r\"standard file .*not found\"", ",", "msg", ")" ]
[ 563, 4 ]
[ 567, 58 ]
python
en
['en', 'error', 'th']
False
PyDialog.__init__
(self, *args, **kw)
Dialog(database, name, x, y, w, h, attributes, title, first, default, cancel, bitmap=true)
Dialog(database, name, x, y, w, h, attributes, title, first, default, cancel, bitmap=true)
def __init__(self, *args, **kw): """Dialog(database, name, x, y, w, h, attributes, title, first, default, cancel, bitmap=true)""" Dialog.__init__(self, *args) ruler = self.h - 36 bmwidth = 152*ruler/328 #if kw.get("bitmap", True): # self.bitmap("Bitmap", 0, 0, ...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "Dialog", ".", "__init__", "(", "self", ",", "*", "args", ")", "ruler", "=", "self", ".", "h", "-", "36", "bmwidth", "=", "152", "*", "ruler", "/", "328", "#if kw....
[ 26, 4 ]
[ 34, 52 ]
python
en
['en', 'en', 'pl']
True
PyDialog.title
(self, title)
Set the title text of the dialog at the top.
Set the title text of the dialog at the top.
def title(self, title): "Set the title text of the dialog at the top." # name, x, y, w, h, flags=Visible|Enabled|Transparent|NoPrefix, # text, in VerdanaBold10 self.text("Title", 15, 10, 320, 60, 0x30003, r"{\VerdanaBold10}%s" % title)
[ "def", "title", "(", "self", ",", "title", ")", ":", "# name, x, y, w, h, flags=Visible|Enabled|Transparent|NoPrefix,", "# text, in VerdanaBold10", "self", ".", "text", "(", "\"Title\"", ",", "15", ",", "10", ",", "320", ",", "60", ",", "0x30003", ",", "r\"{\\Verd...
[ 36, 4 ]
[ 41, 48 ]
python
en
['en', 'en', 'en']
True
PyDialog.back
(self, title, next, name = "Back", active = 1)
Add a back button with a given title, the tab-next button, its name in the Control table, possibly initially disabled. Return the button, so that events can be associated
Add a back button with a given title, the tab-next button, its name in the Control table, possibly initially disabled.
def back(self, title, next, name = "Back", active = 1): """Add a back button with a given title, the tab-next button, its name in the Control table, possibly initially disabled. Return the button, so that events can be associated""" if active: flags = 3 # Visible|Enabled ...
[ "def", "back", "(", "self", ",", "title", ",", "next", ",", "name", "=", "\"Back\"", ",", "active", "=", "1", ")", ":", "if", "active", ":", "flags", "=", "3", "# Visible|Enabled", "else", ":", "flags", "=", "1", "# Visible", "return", "self", ".", ...
[ 43, 4 ]
[ 52, 81 ]
python
en
['en', 'en', 'en']
True
PyDialog.cancel
(self, title, next, name = "Cancel", active = 1)
Add a cancel button with a given title, the tab-next button, its name in the Control table, possibly initially disabled. Return the button, so that events can be associated
Add a cancel button with a given title, the tab-next button, its name in the Control table, possibly initially disabled.
def cancel(self, title, next, name = "Cancel", active = 1): """Add a cancel button with a given title, the tab-next button, its name in the Control table, possibly initially disabled. Return the button, so that events can be associated""" if active: flags = 3 # Visible|Enabl...
[ "def", "cancel", "(", "self", ",", "title", ",", "next", ",", "name", "=", "\"Cancel\"", ",", "active", "=", "1", ")", ":", "if", "active", ":", "flags", "=", "3", "# Visible|Enabled", "else", ":", "flags", "=", "1", "# Visible", "return", "self", "....
[ 54, 4 ]
[ 63, 80 ]
python
en
['en', 'en', 'en']
True
PyDialog.next
(self, title, next, name = "Next", active = 1)
Add a Next button with a given title, the tab-next button, its name in the Control table, possibly initially disabled. Return the button, so that events can be associated
Add a Next button with a given title, the tab-next button, its name in the Control table, possibly initially disabled.
def next(self, title, next, name = "Next", active = 1): """Add a Next button with a given title, the tab-next button, its name in the Control table, possibly initially disabled. Return the button, so that events can be associated""" if active: flags = 3 # Visible|Enabled ...
[ "def", "next", "(", "self", ",", "title", ",", "next", ",", "name", "=", "\"Next\"", ",", "active", "=", "1", ")", ":", "if", "active", ":", "flags", "=", "3", "# Visible|Enabled", "else", ":", "flags", "=", "1", "# Visible", "return", "self", ".", ...
[ 65, 4 ]
[ 74, 80 ]
python
en
['en', 'en', 'en']
True
PyDialog.xbutton
(self, name, title, next, xpos)
Add a button with a given title, the tab-next button, its name in the Control table, giving its x position; the y-position is aligned with the other buttons. Return the button, so that events can be associated
Add a button with a given title, the tab-next button, its name in the Control table, giving its x position; the y-position is aligned with the other buttons.
def xbutton(self, name, title, next, xpos): """Add a button with a given title, the tab-next button, its name in the Control table, giving its x position; the y-position is aligned with the other buttons. Return the button, so that events can be associated""" return self.pushbut...
[ "def", "xbutton", "(", "self", ",", "name", ",", "title", ",", "next", ",", "xpos", ")", ":", "return", "self", ".", "pushbutton", "(", "name", ",", "int", "(", "self", ".", "w", "*", "xpos", "-", "28", ")", ",", "self", ".", "h", "-", "27", ...
[ 76, 4 ]
[ 82, 94 ]
python
en
['en', 'en', 'en']
True
bdist_msi.add_find_python
(self)
Adds code to the installer to compute the location of Python. Properties PYTHON.MACHINE.X.Y and PYTHON.USER.X.Y will be set from the registry for each version of Python. Properties TARGETDIRX.Y will be set from PYTHON.USER.X.Y if defined, else from PYTHON.MACHINE.X.Y. Properti...
Adds code to the installer to compute the location of Python.
def add_find_python(self): """Adds code to the installer to compute the location of Python. Properties PYTHON.MACHINE.X.Y and PYTHON.USER.X.Y will be set from the registry for each version of Python. Properties TARGETDIRX.Y will be set from PYTHON.USER.X.Y if defined, else from...
[ "def", "add_find_python", "(", "self", ")", ":", "start", "=", "402", "for", "ver", "in", "self", ".", "versions", ":", "install_path", "=", "r\"SOFTWARE\\Python\\PythonCore\\%s\\InstallPath\"", "%", "ver", "machine_reg", "=", "\"python.machine.\"", "+", "ver", "u...
[ 330, 4 ]
[ 382, 30 ]
python
en
['en', 'en', 'en']
True
test_no_logits
()
test_no_logits: Check that a model without logits causes an error
test_no_logits: Check that a model without logits causes an error
def test_no_logits(): """test_no_logits: Check that a model without logits causes an error""" batch_size = 2 nb_classes = 3 class NoLogitsModel(Model): """ A model that neither defines logits nor makes it possible to find logits by inspecting the inputs to a softmax op. ...
[ "def", "test_no_logits", "(", ")", ":", "batch_size", "=", "2", "nb_classes", "=", "3", "class", "NoLogitsModel", "(", "Model", ")", ":", "\"\"\"\n A model that neither defines logits nor makes it possible to find logits\n by inspecting the inputs to a softmax op.\n ...
[ 14, 0 ]
[ 32, 58 ]
python
en
['en', 'en', 'en']
True
test_rejects_callable
()
test_rejects_callable: Check that callables are not accepted as models
test_rejects_callable: Check that callables are not accepted as models
def test_rejects_callable(): """test_rejects_callable: Check that callables are not accepted as models""" def model(x): """Mock model""" return x sess = tf.Session() assert_raises(TypeError, ProjectedGradientDescent, model, sess)
[ "def", "test_rejects_callable", "(", ")", ":", "def", "model", "(", "x", ")", ":", "\"\"\"Mock model\"\"\"", "return", "x", "sess", "=", "tf", ".", "Session", "(", ")", "assert_raises", "(", "TypeError", ",", "ProjectedGradientDescent", ",", "model", ",", "s...
[ 35, 0 ]
[ 43, 67 ]
python
en
['en', 'en', 'en']
True
get_admin_log
(parser, token)
Populate a template variable with the admin log for the given criteria. Usage:: {% get_admin_log [limit] as [varname] for_user [context_var_containing_user_obj] %} Examples:: {% get_admin_log 10 as admin_log for_user 23 %} {% get_admin_log 10 as admin_log for_user user %} ...
Populate a template variable with the admin log for the given criteria.
def get_admin_log(parser, token): """ Populate a template variable with the admin log for the given criteria. Usage:: {% get_admin_log [limit] as [varname] for_user [context_var_containing_user_obj] %} Examples:: {% get_admin_log 10 as admin_log for_user 23 %} {% get_admin_lo...
[ "def", "get_admin_log", "(", "parser", ",", "token", ")", ":", "tokens", "=", "token", ".", "contents", ".", "split", "(", ")", "if", "len", "(", "tokens", ")", "<", "4", ":", "raise", "template", ".", "TemplateSyntaxError", "(", "\"'get_admin_log' stateme...
[ 26, 0 ]
[ 58, 106 ]
python
en
['en', 'error', 'th']
False
create_main_parser
()
Creates and returns the main parser for pip's CLI
Creates and returns the main parser for pip's CLI
def create_main_parser(): # type: () -> ConfigOptionParser """Creates and returns the main parser for pip's CLI """ parser_kw = { 'usage': '\n%prog <command> [options]', 'add_help_option': False, 'formatter': UpdatingDefaultsHelpFormatter(), 'name': 'global', 'pr...
[ "def", "create_main_parser", "(", ")", ":", "# type: () -> ConfigOptionParser", "parser_kw", "=", "{", "'usage'", ":", "'\\n%prog <command> [options]'", ",", "'add_help_option'", ":", "False", ",", "'formatter'", ":", "UpdatingDefaultsHelpFormatter", "(", ")", ",", "'na...
[ 23, 0 ]
[ 55, 17 ]
python
en
['en', 'en', 'en']
True
generate_django_secretkey
()
Secret key generation taken from Django's startproject.py
Secret key generation taken from Django's startproject.py
def generate_django_secretkey() -> str: """Secret key generation taken from Django's startproject.py""" # We do in-function imports so that we only do the expensive work # of importing cryptography modules when necessary. # # This helps optimize noop provision performance. from django.utils.cry...
[ "def", "generate_django_secretkey", "(", ")", "->", "str", ":", "# We do in-function imports so that we only do the expensive work", "# of importing cryptography modules when necessary.", "#", "# This helps optimize noop provision performance.", "from", "django", ".", "utils", ".", "...
[ 49, 0 ]
[ 59, 39 ]
python
en
['en', 'fy', 'en']
True
normalize_version_info
(py_version_info)
Convert a tuple of ints representing a Python version to one of length three. :param py_version_info: a tuple of ints representing a Python version, or None to specify no version. The tuple can have any length. :return: a tuple of length three if `py_version_info` is non-None. Otherwi...
Convert a tuple of ints representing a Python version to one of length three.
def normalize_version_info(py_version_info): # type: (Tuple[int, ...]) -> Tuple[int, int, int] """ Convert a tuple of ints representing a Python version to one of length three. :param py_version_info: a tuple of ints representing a Python version, or None to specify no version. The tuple ca...
[ "def", "normalize_version_info", "(", "py_version_info", ")", ":", "# type: (Tuple[int, ...]) -> Tuple[int, int, int]", "if", "len", "(", "py_version_info", ")", "<", "3", ":", "py_version_info", "+=", "(", "3", "-", "len", "(", "py_version_info", ")", ")", "*", "...
[ 86, 0 ]
[ 103, 47 ]
python
en
['en', 'error', 'th']
False