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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
get_connection | (backend=None, fail_silently=False, **kwds) | Load an email backend and return an instance of it.
If backend is None (default) settings.EMAIL_BACKEND is used.
Both fail_silently and other keyword arguments are used in the
constructor of the backend.
| Load an email backend and return an instance of it. | def get_connection(backend=None, fail_silently=False, **kwds):
"""Load an email backend and return an instance of it.
If backend is None (default) settings.EMAIL_BACKEND is used.
Both fail_silently and other keyword arguments are used in the
constructor of the backend.
"""
klass = import_strin... | [
"def",
"get_connection",
"(",
"backend",
"=",
"None",
",",
"fail_silently",
"=",
"False",
",",
"*",
"*",
"kwds",
")",
":",
"klass",
"=",
"import_string",
"(",
"backend",
"or",
"settings",
".",
"EMAIL_BACKEND",
")",
"return",
"klass",
"(",
"fail_silently",
... | [
27,
0
] | [
36,
53
] | python | en | ['en', 'en', 'en'] | True |
send_mail | (subject, message, from_email, recipient_list,
fail_silently=False, auth_user=None, auth_password=None,
connection=None, html_message=None) |
Easy wrapper for sending a single message to a recipient list. All members
of the recipient list will see the other recipients in the 'To' field.
If auth_user is None, the EMAIL_HOST_USER setting is used.
If auth_password is None, the EMAIL_HOST_PASSWORD setting is used.
Note: The API for this me... |
Easy wrapper for sending a single message to a recipient list. All members
of the recipient list will see the other recipients in the 'To' field. | def send_mail(subject, message, from_email, recipient_list,
fail_silently=False, auth_user=None, auth_password=None,
connection=None, html_message=None):
"""
Easy wrapper for sending a single message to a recipient list. All members
of the recipient list will see the other recipi... | [
"def",
"send_mail",
"(",
"subject",
",",
"message",
",",
"from_email",
",",
"recipient_list",
",",
"fail_silently",
"=",
"False",
",",
"auth_user",
"=",
"None",
",",
"auth_password",
"=",
"None",
",",
"connection",
"=",
"None",
",",
"html_message",
"=",
"Non... | [
39,
0
] | [
61,
22
] | python | en | ['en', 'error', 'th'] | False |
send_mass_mail | (datatuple, fail_silently=False, auth_user=None,
auth_password=None, connection=None) |
Given a datatuple of (subject, message, from_email, recipient_list), sends
each message to each recipient list. Returns the number of emails sent.
If from_email is None, the DEFAULT_FROM_EMAIL setting is used.
If auth_user and auth_password are set, they're used to log in.
If auth_user is None, th... |
Given a datatuple of (subject, message, from_email, recipient_list), sends
each message to each recipient list. Returns the number of emails sent. | def send_mass_mail(datatuple, fail_silently=False, auth_user=None,
auth_password=None, connection=None):
"""
Given a datatuple of (subject, message, from_email, recipient_list), sends
each message to each recipient list. Returns the number of emails sent.
If from_email is None, the D... | [
"def",
"send_mass_mail",
"(",
"datatuple",
",",
"fail_silently",
"=",
"False",
",",
"auth_user",
"=",
"None",
",",
"auth_password",
"=",
"None",
",",
"connection",
"=",
"None",
")",
":",
"connection",
"=",
"connection",
"or",
"get_connection",
"(",
"username",... | [
64,
0
] | [
87,
45
] | python | en | ['en', 'error', 'th'] | False |
mail_admins | (subject, message, fail_silently=False, connection=None,
html_message=None) | Sends a message to the admins, as defined by the ADMINS setting. | Sends a message to the admins, as defined by the ADMINS setting. | def mail_admins(subject, message, fail_silently=False, connection=None,
html_message=None):
"""Sends a message to the admins, as defined by the ADMINS setting."""
if not settings.ADMINS:
return
mail = EmailMultiAlternatives(
'%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), ... | [
"def",
"mail_admins",
"(",
"subject",
",",
"message",
",",
"fail_silently",
"=",
"False",
",",
"connection",
"=",
"None",
",",
"html_message",
"=",
"None",
")",
":",
"if",
"not",
"settings",
".",
"ADMINS",
":",
"return",
"mail",
"=",
"EmailMultiAlternatives"... | [
90,
0
] | [
102,
42
] | python | en | ['en', 'en', 'en'] | True |
mail_managers | (subject, message, fail_silently=False, connection=None,
html_message=None) | Sends a message to the managers, as defined by the MANAGERS setting. | Sends a message to the managers, as defined by the MANAGERS setting. | def mail_managers(subject, message, fail_silently=False, connection=None,
html_message=None):
"""Sends a message to the managers, as defined by the MANAGERS setting."""
if not settings.MANAGERS:
return
mail = EmailMultiAlternatives(
'%s%s' % (settings.EMAIL_SUBJECT_PREFIX, ... | [
"def",
"mail_managers",
"(",
"subject",
",",
"message",
",",
"fail_silently",
"=",
"False",
",",
"connection",
"=",
"None",
",",
"html_message",
"=",
"None",
")",
":",
"if",
"not",
"settings",
".",
"MANAGERS",
":",
"return",
"mail",
"=",
"EmailMultiAlternati... | [
105,
0
] | [
117,
42
] | python | en | ['en', 'en', 'en'] | True |
MpoImageFile.adopt | (jpeg_instance, mpheader=None) |
Transform the instance of JpegImageFile into
an instance of MpoImageFile.
After the call, the JpegImageFile is extended
to be an MpoImageFile.
This is essentially useful when opening a JPEG
file that reveals itself as an MPO, to avoid
double call to _open.
... |
Transform the instance of JpegImageFile into
an instance of MpoImageFile.
After the call, the JpegImageFile is extended
to be an MpoImageFile. | def adopt(jpeg_instance, mpheader=None):
"""
Transform the instance of JpegImageFile into
an instance of MpoImageFile.
After the call, the JpegImageFile is extended
to be an MpoImageFile.
This is essentially useful when opening a JPEG
file that reveals itself as ... | [
"def",
"adopt",
"(",
"jpeg_instance",
",",
"mpheader",
"=",
"None",
")",
":",
"jpeg_instance",
".",
"__class__",
"=",
"MpoImageFile",
"jpeg_instance",
".",
"_after_jpeg_open",
"(",
"mpheader",
")",
"return",
"jpeg_instance"
] | [
106,
4
] | [
119,
28
] | python | en | ['en', 'error', 'th'] | False |
AartfaacCasaImage.parse_frequency | (self, table) |
Extract frequency related information from headers
(Overrides the implementation in CasaImage, which pulls the entries
from the 'spectral2' sub-table.)
|
Extract frequency related information from headers | def parse_frequency(self, table):
"""
Extract frequency related information from headers
(Overrides the implementation in CasaImage, which pulls the entries
from the 'spectral2' sub-table.)
"""
keywords = table.getkeywords()
# due to some undocumented casacore ... | [
"def",
"parse_frequency",
"(",
"self",
",",
"table",
")",
":",
"keywords",
"=",
"table",
".",
"getkeywords",
"(",
")",
"# due to some undocumented casacore feature, the 'spectral' keyword",
"# changes from spectral1 to spectral2 when AARTFAAC imaging developers",
"# changed some of... | [
19,
4
] | [
41,
32
] | python | en | ['en', 'error', 'th'] | False |
execute_store_varmetric | (dataset_id, session=None) |
Executes the storing varmetric function. Will create a database session
if none is supplied.
args:
dataset_id: the ID of the dataset for which you want to store the
varmetrics
session: An optional SQLAlchemy session
|
Executes the storing varmetric function. Will create a database session
if none is supplied. | def execute_store_varmetric(dataset_id, session=None):
"""
Executes the storing varmetric function. Will create a database session
if none is supplied.
args:
dataset_id: the ID of the dataset for which you want to store the
varmetrics
session: An optional SQLAlchemy ... | [
"def",
"execute_store_varmetric",
"(",
"dataset_id",
",",
"session",
"=",
"None",
")",
":",
"if",
"not",
"session",
":",
"database",
"=",
"Database",
"(",
")",
"session",
"=",
"database",
".",
"Session",
"(",
")",
"dataset",
"=",
"Dataset",
"(",
"id",
"=... | [
5,
0
] | [
24,
20
] | python | en | ['en', 'error', 'th'] | False |
IcoFile.__init__ | (self, buf) |
Parse image from file-like object containing ico file data
|
Parse image from file-like object containing ico file data
| def __init__(self, buf):
"""
Parse image from file-like object containing ico file data
"""
# check magic
s = buf.read(6)
if not _accept(s):
raise SyntaxError("not an ICO file")
self.buf = buf
self.entry = []
# Number of items in fil... | [
"def",
"__init__",
"(",
"self",
",",
"buf",
")",
":",
"# check magic",
"s",
"=",
"buf",
".",
"read",
"(",
"6",
")",
"if",
"not",
"_accept",
"(",
"s",
")",
":",
"raise",
"SyntaxError",
"(",
"\"not an ICO file\"",
")",
"self",
".",
"buf",
"=",
"buf",
... | [
88,
4
] | [
144,
28
] | python | en | ['en', 'error', 'th'] | False |
IcoFile.sizes | (self) |
Get a list of all available icon sizes and color depths.
|
Get a list of all available icon sizes and color depths.
| def sizes(self):
"""
Get a list of all available icon sizes and color depths.
"""
return {(h["width"], h["height"]) for h in self.entry} | [
"def",
"sizes",
"(",
"self",
")",
":",
"return",
"{",
"(",
"h",
"[",
"\"width\"",
"]",
",",
"h",
"[",
"\"height\"",
"]",
")",
"for",
"h",
"in",
"self",
".",
"entry",
"}"
] | [
146,
4
] | [
150,
62
] | python | en | ['en', 'error', 'th'] | False |
IcoFile.getimage | (self, size, bpp=False) |
Get an image from the icon
|
Get an image from the icon
| def getimage(self, size, bpp=False):
"""
Get an image from the icon
"""
return self.frame(self.getentryindex(size, bpp)) | [
"def",
"getimage",
"(",
"self",
",",
"size",
",",
"bpp",
"=",
"False",
")",
":",
"return",
"self",
".",
"frame",
"(",
"self",
".",
"getentryindex",
"(",
"size",
",",
"bpp",
")",
")"
] | [
158,
4
] | [
162,
56
] | python | en | ['en', 'error', 'th'] | False |
IcoFile.frame | (self, idx) |
Get an image from frame idx
|
Get an image from frame idx
| def frame(self, idx):
"""
Get an image from frame idx
"""
header = self.entry[idx]
self.buf.seek(header["offset"])
data = self.buf.read(8)
self.buf.seek(header["offset"])
if data[:8] == PngImagePlugin._MAGIC:
# png frame
im = Png... | [
"def",
"frame",
"(",
"self",
",",
"idx",
")",
":",
"header",
"=",
"self",
".",
"entry",
"[",
"idx",
"]",
"self",
".",
"buf",
".",
"seek",
"(",
"header",
"[",
"\"offset\"",
"]",
")",
"data",
"=",
"self",
".",
"buf",
".",
"read",
"(",
"8",
")",
... | [
164,
4
] | [
246,
17
] | python | en | ['en', 'error', 'th'] | False |
get_default_compiler | (osname=None, platform=None) | Determine the default compiler to use for the given platform.
osname should be one of the standard Python OS names (i.e. the
ones returned by os.name) and platform the common value
returned by sys.platform for the platform in question.
The default values are os.name and sys.platform in cas... | Determine the default compiler to use for the given platform. | def get_default_compiler(osname=None, platform=None):
"""Determine the default compiler to use for the given platform.
osname should be one of the standard Python OS names (i.e. the
ones returned by os.name) and platform the common value
returned by sys.platform for the platform in question.
... | [
"def",
"get_default_compiler",
"(",
"osname",
"=",
"None",
",",
"platform",
"=",
"None",
")",
":",
"if",
"osname",
"is",
"None",
":",
"osname",
"=",
"os",
".",
"name",
"if",
"platform",
"is",
"None",
":",
"platform",
"=",
"sys",
".",
"platform",
"for",... | [
936,
0
] | [
955,
17
] | python | en | ['en', 'en', 'en'] | True |
show_compilers | () | Print list of available compilers (used by the "--help-compiler"
options to "build", "build_ext", "build_clib").
| Print list of available compilers (used by the "--help-compiler"
options to "build", "build_ext", "build_clib").
| def show_compilers():
"""Print list of available compilers (used by the "--help-compiler"
options to "build", "build_ext", "build_clib").
"""
# XXX this "knows" that the compiler option it's describing is
# "--compiler", which just happens to be the case for the three
# commands that use it.
... | [
"def",
"show_compilers",
"(",
")",
":",
"# XXX this \"knows\" that the compiler option it's describing is",
"# \"--compiler\", which just happens to be the case for the three",
"# commands that use it.",
"from",
"distutils",
".",
"fancy_getopt",
"import",
"FancyGetopt",
"compilers",
"=... | [
972,
0
] | [
986,
61
] | python | en | ['en', 'en', 'en'] | True |
new_compiler | (plat=None, compiler=None, verbose=0, dry_run=0, force=0) | Generate an instance of some CCompiler subclass for the supplied
platform/compiler combination. 'plat' defaults to 'os.name'
(eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler
for that platform. Currently only 'posix' and 'nt' are supported, and
the default compilers are "traditional... | Generate an instance of some CCompiler subclass for the supplied
platform/compiler combination. 'plat' defaults to 'os.name'
(eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler
for that platform. Currently only 'posix' and 'nt' are supported, and
the default compilers are "traditional... | def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0):
"""Generate an instance of some CCompiler subclass for the supplied
platform/compiler combination. 'plat' defaults to 'os.name'
(eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler
for that platform. Currently o... | [
"def",
"new_compiler",
"(",
"plat",
"=",
"None",
",",
"compiler",
"=",
"None",
",",
"verbose",
"=",
"0",
",",
"dry_run",
"=",
"0",
",",
"force",
"=",
"0",
")",
":",
"if",
"plat",
"is",
"None",
":",
"plat",
"=",
"os",
".",
"name",
"try",
":",
"i... | [
989,
0
] | [
1031,
38
] | python | en | ['en', 'en', 'en'] | True |
gen_preprocess_options | (macros, include_dirs) | Generate C pre-processor options (-D, -U, -I) as used by at least
two types of compilers: the typical Unix compiler and Visual C++.
'macros' is the usual thing, a list of 1- or 2-tuples, where (name,)
means undefine (-U) macro 'name', and (name,value) means define (-D)
macro 'name' to 'value'. 'include... | Generate C pre-processor options (-D, -U, -I) as used by at least
two types of compilers: the typical Unix compiler and Visual C++.
'macros' is the usual thing, a list of 1- or 2-tuples, where (name,)
means undefine (-U) macro 'name', and (name,value) means define (-D)
macro 'name' to 'value'. 'include... | def gen_preprocess_options(macros, include_dirs):
"""Generate C pre-processor options (-D, -U, -I) as used by at least
two types of compilers: the typical Unix compiler and Visual C++.
'macros' is the usual thing, a list of 1- or 2-tuples, where (name,)
means undefine (-U) macro 'name', and (name,value)... | [
"def",
"gen_preprocess_options",
"(",
"macros",
",",
"include_dirs",
")",
":",
"# XXX it would be nice (mainly aesthetic, and so we don't generate",
"# stupid-looking command lines) to go over 'macros' and eliminate",
"# redundant definitions/undefinitions (ie. ensure that only the",
"# latest... | [
1034,
0
] | [
1076,
18
] | python | en | ['en', 'en', 'en'] | True |
gen_lib_options | (compiler, library_dirs, runtime_library_dirs, libraries) | Generate linker options for searching library directories and
linking with specific libraries. 'libraries' and 'library_dirs' are,
respectively, lists of library names (not filenames!) and search
directories. Returns a list of command-line options suitable for use
with some compiler (depending on the ... | Generate linker options for searching library directories and
linking with specific libraries. 'libraries' and 'library_dirs' are,
respectively, lists of library names (not filenames!) and search
directories. Returns a list of command-line options suitable for use
with some compiler (depending on the ... | def gen_lib_options (compiler, library_dirs, runtime_library_dirs, libraries):
"""Generate linker options for searching library directories and
linking with specific libraries. 'libraries' and 'library_dirs' are,
respectively, lists of library names (not filenames!) and search
directories. Returns a l... | [
"def",
"gen_lib_options",
"(",
"compiler",
",",
"library_dirs",
",",
"runtime_library_dirs",
",",
"libraries",
")",
":",
"lib_opts",
"=",
"[",
"]",
"for",
"dir",
"in",
"library_dirs",
":",
"lib_opts",
".",
"append",
"(",
"compiler",
".",
"library_dir_option",
... | [
1079,
0
] | [
1115,
19
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.set_executables | (self, **kwargs) | Define the executables (and options for them) that will be run
to perform the various stages of compilation. The exact set of
executables that may be specified here depends on the compiler
class (via the 'executables' class attribute), but most will have:
compiler the C/C++ compi... | Define the executables (and options for them) that will be run
to perform the various stages of compilation. The exact set of
executables that may be specified here depends on the compiler
class (via the 'executables' class attribute), but most will have:
compiler the C/C++ compi... | def set_executables(self, **kwargs):
"""Define the executables (and options for them) that will be run
to perform the various stages of compilation. The exact set of
executables that may be specified here depends on the compiler
class (via the 'executables' class attribute), but most wi... | [
"def",
"set_executables",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Note that some CCompiler implementation classes will define class",
"# attributes 'cpp', 'cc', etc. with hard-coded executable names;",
"# this is appropriate when a compiler class is for exactly one",
"# compiler... | [
120,
4
] | [
150,
49
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._check_macro_definitions | (self, definitions) | Ensures that every element of 'definitions' is a valid macro
definition, ie. either (name,value) 2-tuple or a (name,) tuple. Do
nothing if all definitions are OK, raise TypeError otherwise.
| Ensures that every element of 'definitions' is a valid macro
definition, ie. either (name,value) 2-tuple or a (name,) tuple. Do
nothing if all definitions are OK, raise TypeError otherwise.
| def _check_macro_definitions(self, definitions):
"""Ensures that every element of 'definitions' is a valid macro
definition, ie. either (name,value) 2-tuple or a (name,) tuple. Do
nothing if all definitions are OK, raise TypeError otherwise.
"""
for defn in definitions:
... | [
"def",
"_check_macro_definitions",
"(",
"self",
",",
"definitions",
")",
":",
"for",
"defn",
"in",
"definitions",
":",
"if",
"not",
"(",
"isinstance",
"(",
"defn",
",",
"tuple",
")",
"and",
"(",
"len",
"(",
"defn",
")",
"in",
"(",
"1",
",",
"2",
")",... | [
166,
4
] | [
178,
39
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.define_macro | (self, name, value=None) | Define a preprocessor macro for all compilations driven by this
compiler object. The optional parameter 'value' should be a
string; if it is not supplied, then the macro will be defined
without an explicit value and the exact outcome depends on the
compiler used (XXX true? does ANSI say... | Define a preprocessor macro for all compilations driven by this
compiler object. The optional parameter 'value' should be a
string; if it is not supplied, then the macro will be defined
without an explicit value and the exact outcome depends on the
compiler used (XXX true? does ANSI say... | def define_macro(self, name, value=None):
"""Define a preprocessor macro for all compilations driven by this
compiler object. The optional parameter 'value' should be a
string; if it is not supplied, then the macro will be defined
without an explicit value and the exact outcome depends ... | [
"def",
"define_macro",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
")",
":",
"# Delete from the list of macro definitions/undefinitions if",
"# already there (so that this one will take precedence).",
"i",
"=",
"self",
".",
"_find_macro",
"(",
"name",
")",
"if",
... | [
183,
4
] | [
196,
41
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.undefine_macro | (self, name) | Undefine a preprocessor macro for all compilations driven by
this compiler object. If the same macro is defined by
'define_macro()' and undefined by 'undefine_macro()' the last call
takes precedence (including multiple redefinitions or
undefinitions). If the macro is redefined/undefine... | Undefine a preprocessor macro for all compilations driven by
this compiler object. If the same macro is defined by
'define_macro()' and undefined by 'undefine_macro()' the last call
takes precedence (including multiple redefinitions or
undefinitions). If the macro is redefined/undefine... | def undefine_macro(self, name):
"""Undefine a preprocessor macro for all compilations driven by
this compiler object. If the same macro is defined by
'define_macro()' and undefined by 'undefine_macro()' the last call
takes precedence (including multiple redefinitions or
undefini... | [
"def",
"undefine_macro",
"(",
"self",
",",
"name",
")",
":",
"# Delete from the list of macro definitions/undefinitions if",
"# already there (so that this one will take precedence).",
"i",
"=",
"self",
".",
"_find_macro",
"(",
"name",
")",
"if",
"i",
"is",
"not",
"None",... | [
198,
4
] | [
214,
34
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.add_include_dir | (self, dir) | Add 'dir' to the list of directories that will be searched for
header files. The compiler is instructed to search directories in
the order in which they are supplied by successive calls to
'add_include_dir()'.
| Add 'dir' to the list of directories that will be searched for
header files. The compiler is instructed to search directories in
the order in which they are supplied by successive calls to
'add_include_dir()'.
| def add_include_dir(self, dir):
"""Add 'dir' to the list of directories that will be searched for
header files. The compiler is instructed to search directories in
the order in which they are supplied by successive calls to
'add_include_dir()'.
"""
self.include_dirs.appe... | [
"def",
"add_include_dir",
"(",
"self",
",",
"dir",
")",
":",
"self",
".",
"include_dirs",
".",
"append",
"(",
"dir",
")"
] | [
216,
4
] | [
222,
37
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.set_include_dirs | (self, dirs) | Set the list of directories that will be searched to 'dirs' (a
list of strings). Overrides any preceding calls to
'add_include_dir()'; subsequence calls to 'add_include_dir()' add
to the list passed to 'set_include_dirs()'. This does not affect
any list of standard include directories ... | Set the list of directories that will be searched to 'dirs' (a
list of strings). Overrides any preceding calls to
'add_include_dir()'; subsequence calls to 'add_include_dir()' add
to the list passed to 'set_include_dirs()'. This does not affect
any list of standard include directories ... | def set_include_dirs(self, dirs):
"""Set the list of directories that will be searched to 'dirs' (a
list of strings). Overrides any preceding calls to
'add_include_dir()'; subsequence calls to 'add_include_dir()' add
to the list passed to 'set_include_dirs()'. This does not affect
... | [
"def",
"set_include_dirs",
"(",
"self",
",",
"dirs",
")",
":",
"self",
".",
"include_dirs",
"=",
"dirs",
"[",
":",
"]"
] | [
224,
4
] | [
232,
35
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.add_library | (self, libname) | Add 'libname' to the list of libraries that will be included in
all links driven by this compiler object. Note that 'libname'
should *not* be the name of a file containing a library, but the
name of the library itself: the actual filename will be inferred by
the linker, the compiler, or... | Add 'libname' to the list of libraries that will be included in
all links driven by this compiler object. Note that 'libname'
should *not* be the name of a file containing a library, but the
name of the library itself: the actual filename will be inferred by
the linker, the compiler, or... | def add_library(self, libname):
"""Add 'libname' to the list of libraries that will be included in
all links driven by this compiler object. Note that 'libname'
should *not* be the name of a file containing a library, but the
name of the library itself: the actual filename will be infer... | [
"def",
"add_library",
"(",
"self",
",",
"libname",
")",
":",
"self",
".",
"libraries",
".",
"append",
"(",
"libname",
")"
] | [
234,
4
] | [
248,
38
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.set_libraries | (self, libnames) | Set the list of libraries to be included in all links driven by
this compiler object to 'libnames' (a list of strings). This does
not affect any standard system libraries that the linker may
include by default.
| Set the list of libraries to be included in all links driven by
this compiler object to 'libnames' (a list of strings). This does
not affect any standard system libraries that the linker may
include by default.
| def set_libraries(self, libnames):
"""Set the list of libraries to be included in all links driven by
this compiler object to 'libnames' (a list of strings). This does
not affect any standard system libraries that the linker may
include by default.
"""
self.libraries = l... | [
"def",
"set_libraries",
"(",
"self",
",",
"libnames",
")",
":",
"self",
".",
"libraries",
"=",
"libnames",
"[",
":",
"]"
] | [
250,
4
] | [
256,
36
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.add_library_dir | (self, dir) | Add 'dir' to the list of directories that will be searched for
libraries specified to 'add_library()' and 'set_libraries()'. The
linker will be instructed to search for libraries in the order they
are supplied to 'add_library_dir()' and/or 'set_library_dirs()'.
| Add 'dir' to the list of directories that will be searched for
libraries specified to 'add_library()' and 'set_libraries()'. The
linker will be instructed to search for libraries in the order they
are supplied to 'add_library_dir()' and/or 'set_library_dirs()'.
| def add_library_dir(self, dir):
"""Add 'dir' to the list of directories that will be searched for
libraries specified to 'add_library()' and 'set_libraries()'. The
linker will be instructed to search for libraries in the order they
are supplied to 'add_library_dir()' and/or 'set_library... | [
"def",
"add_library_dir",
"(",
"self",
",",
"dir",
")",
":",
"self",
".",
"library_dirs",
".",
"append",
"(",
"dir",
")"
] | [
258,
4
] | [
264,
37
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.set_library_dirs | (self, dirs) | Set the list of library search directories to 'dirs' (a list of
strings). This does not affect any standard library search path
that the linker may search by default.
| Set the list of library search directories to 'dirs' (a list of
strings). This does not affect any standard library search path
that the linker may search by default.
| def set_library_dirs(self, dirs):
"""Set the list of library search directories to 'dirs' (a list of
strings). This does not affect any standard library search path
that the linker may search by default.
"""
self.library_dirs = dirs[:] | [
"def",
"set_library_dirs",
"(",
"self",
",",
"dirs",
")",
":",
"self",
".",
"library_dirs",
"=",
"dirs",
"[",
":",
"]"
] | [
266,
4
] | [
271,
35
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.add_runtime_library_dir | (self, dir) | Add 'dir' to the list of directories that will be searched for
shared libraries at runtime.
| Add 'dir' to the list of directories that will be searched for
shared libraries at runtime.
| def add_runtime_library_dir(self, dir):
"""Add 'dir' to the list of directories that will be searched for
shared libraries at runtime.
"""
self.runtime_library_dirs.append(dir) | [
"def",
"add_runtime_library_dir",
"(",
"self",
",",
"dir",
")",
":",
"self",
".",
"runtime_library_dirs",
".",
"append",
"(",
"dir",
")"
] | [
273,
4
] | [
277,
45
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.set_runtime_library_dirs | (self, dirs) | Set the list of directories to search for shared libraries at
runtime to 'dirs' (a list of strings). This does not affect any
standard search path that the runtime linker may search by
default.
| Set the list of directories to search for shared libraries at
runtime to 'dirs' (a list of strings). This does not affect any
standard search path that the runtime linker may search by
default.
| def set_runtime_library_dirs(self, dirs):
"""Set the list of directories to search for shared libraries at
runtime to 'dirs' (a list of strings). This does not affect any
standard search path that the runtime linker may search by
default.
"""
self.runtime_library_dirs = ... | [
"def",
"set_runtime_library_dirs",
"(",
"self",
",",
"dirs",
")",
":",
"self",
".",
"runtime_library_dirs",
"=",
"dirs",
"[",
":",
"]"
] | [
279,
4
] | [
285,
43
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.add_link_object | (self, object) | Add 'object' to the list of object files (or analogues, such as
explicitly named library files or the output of "resource
compilers") to be included in every link driven by this compiler
object.
| Add 'object' to the list of object files (or analogues, such as
explicitly named library files or the output of "resource
compilers") to be included in every link driven by this compiler
object.
| def add_link_object(self, object):
"""Add 'object' to the list of object files (or analogues, such as
explicitly named library files or the output of "resource
compilers") to be included in every link driven by this compiler
object.
"""
self.objects.append(object) | [
"def",
"add_link_object",
"(",
"self",
",",
"object",
")",
":",
"self",
".",
"objects",
".",
"append",
"(",
"object",
")"
] | [
287,
4
] | [
293,
35
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.set_link_objects | (self, objects) | Set the list of object files (or analogues) to be included in
every link to 'objects'. This does not affect any standard object
files that the linker may include by default (such as system
libraries).
| Set the list of object files (or analogues) to be included in
every link to 'objects'. This does not affect any standard object
files that the linker may include by default (such as system
libraries).
| def set_link_objects(self, objects):
"""Set the list of object files (or analogues) to be included in
every link to 'objects'. This does not affect any standard object
files that the linker may include by default (such as system
libraries).
"""
self.objects = objects[:] | [
"def",
"set_link_objects",
"(",
"self",
",",
"objects",
")",
":",
"self",
".",
"objects",
"=",
"objects",
"[",
":",
"]"
] | [
295,
4
] | [
301,
33
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._setup_compile | (self, outdir, macros, incdirs, sources, depends,
extra) | Process arguments and decide which source files to compile. | Process arguments and decide which source files to compile. | def _setup_compile(self, outdir, macros, incdirs, sources, depends,
extra):
"""Process arguments and decide which source files to compile."""
if outdir is None:
outdir = self.output_dir
elif not isinstance(outdir, str):
raise TypeError("'output_dir'... | [
"def",
"_setup_compile",
"(",
"self",
",",
"outdir",
",",
"macros",
",",
"incdirs",
",",
"sources",
",",
"depends",
",",
"extra",
")",
":",
"if",
"outdir",
"is",
"None",
":",
"outdir",
"=",
"self",
".",
"output_dir",
"elif",
"not",
"isinstance",
"(",
"... | [
309,
4
] | [
350,
53
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._fix_compile_args | (self, output_dir, macros, include_dirs) | Typecheck and fix-up some of the arguments to the 'compile()'
method, and return fixed-up values. Specifically: if 'output_dir'
is None, replaces it with 'self.output_dir'; ensures that 'macros'
is a list, and augments it with 'self.macros'; ensures that
'include_dirs' is a list, and au... | Typecheck and fix-up some of the arguments to the 'compile()'
method, and return fixed-up values. Specifically: if 'output_dir'
is None, replaces it with 'self.output_dir'; ensures that 'macros'
is a list, and augments it with 'self.macros'; ensures that
'include_dirs' is a list, and au... | def _fix_compile_args(self, output_dir, macros, include_dirs):
"""Typecheck and fix-up some of the arguments to the 'compile()'
method, and return fixed-up values. Specifically: if 'output_dir'
is None, replaces it with 'self.output_dir'; ensures that 'macros'
is a list, and augments it... | [
"def",
"_fix_compile_args",
"(",
"self",
",",
"output_dir",
",",
"macros",
",",
"include_dirs",
")",
":",
"if",
"output_dir",
"is",
"None",
":",
"output_dir",
"=",
"self",
".",
"output_dir",
"elif",
"not",
"isinstance",
"(",
"output_dir",
",",
"str",
")",
... | [
361,
4
] | [
391,
47
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._prep_compile | (self, sources, output_dir, depends=None) | Decide which souce files must be recompiled.
Determine the list of object files corresponding to 'sources',
and figure out which ones really need to be recompiled.
Return a list of all object files and a dictionary telling
which source files can be skipped.
| Decide which souce files must be recompiled. | def _prep_compile(self, sources, output_dir, depends=None):
"""Decide which souce files must be recompiled.
Determine the list of object files corresponding to 'sources',
and figure out which ones really need to be recompiled.
Return a list of all object files and a dictionary telling
... | [
"def",
"_prep_compile",
"(",
"self",
",",
"sources",
",",
"output_dir",
",",
"depends",
"=",
"None",
")",
":",
"# Get the list of expected output (object) files",
"objects",
"=",
"self",
".",
"object_filenames",
"(",
"sources",
",",
"output_dir",
"=",
"output_dir",
... | [
393,
4
] | [
407,
26
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._fix_object_args | (self, objects, output_dir) | Typecheck and fix up some arguments supplied to various methods.
Specifically: ensure that 'objects' is a list; if output_dir is
None, replace with self.output_dir. Return fixed versions of
'objects' and 'output_dir'.
| Typecheck and fix up some arguments supplied to various methods.
Specifically: ensure that 'objects' is a list; if output_dir is
None, replace with self.output_dir. Return fixed versions of
'objects' and 'output_dir'.
| def _fix_object_args(self, objects, output_dir):
"""Typecheck and fix up some arguments supplied to various methods.
Specifically: ensure that 'objects' is a list; if output_dir is
None, replace with self.output_dir. Return fixed versions of
'objects' and 'output_dir'.
"""
... | [
"def",
"_fix_object_args",
"(",
"self",
",",
"objects",
",",
"output_dir",
")",
":",
"if",
"not",
"isinstance",
"(",
"objects",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"'objects' must be a list or tuple of strings\"",
")",
"... | [
409,
4
] | [
424,
36
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._fix_lib_args | (self, libraries, library_dirs, runtime_library_dirs) | Typecheck and fix up some of the arguments supplied to the
'link_*' methods. Specifically: ensure that all arguments are
lists, and augment them with their permanent versions
(eg. 'self.libraries' augments 'libraries'). Return a tuple with
fixed versions of all arguments.
| Typecheck and fix up some of the arguments supplied to the
'link_*' methods. Specifically: ensure that all arguments are
lists, and augment them with their permanent versions
(eg. 'self.libraries' augments 'libraries'). Return a tuple with
fixed versions of all arguments.
| def _fix_lib_args(self, libraries, library_dirs, runtime_library_dirs):
"""Typecheck and fix up some of the arguments supplied to the
'link_*' methods. Specifically: ensure that all arguments are
lists, and augment them with their permanent versions
(eg. 'self.libraries' augments 'libra... | [
"def",
"_fix_lib_args",
"(",
"self",
",",
"libraries",
",",
"library_dirs",
",",
"runtime_library_dirs",
")",
":",
"if",
"libraries",
"is",
"None",
":",
"libraries",
"=",
"self",
".",
"libraries",
"elif",
"isinstance",
"(",
"libraries",
",",
"(",
"list",
","... | [
426,
4
] | [
458,
62
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._need_link | (self, objects, output_file) | Return true if we need to relink the files listed in 'objects'
to recreate 'output_file'.
| Return true if we need to relink the files listed in 'objects'
to recreate 'output_file'.
| def _need_link(self, objects, output_file):
"""Return true if we need to relink the files listed in 'objects'
to recreate 'output_file'.
"""
if self.force:
return True
else:
if self.dry_run:
newer = newer_group (objects, output_file, missin... | [
"def",
"_need_link",
"(",
"self",
",",
"objects",
",",
"output_file",
")",
":",
"if",
"self",
".",
"force",
":",
"return",
"True",
"else",
":",
"if",
"self",
".",
"dry_run",
":",
"newer",
"=",
"newer_group",
"(",
"objects",
",",
"output_file",
",",
"mi... | [
460,
4
] | [
471,
24
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.detect_language | (self, sources) | Detect the language of a given file, or list of files. Uses
language_map, and language_order to do the job.
| Detect the language of a given file, or list of files. Uses
language_map, and language_order to do the job.
| def detect_language(self, sources):
"""Detect the language of a given file, or list of files. Uses
language_map, and language_order to do the job.
"""
if not isinstance(sources, list):
sources = [sources]
lang = None
index = len(self.language_order)
fo... | [
"def",
"detect_language",
"(",
"self",
",",
"sources",
")",
":",
"if",
"not",
"isinstance",
"(",
"sources",
",",
"list",
")",
":",
"sources",
"=",
"[",
"sources",
"]",
"lang",
"=",
"None",
"index",
"=",
"len",
"(",
"self",
".",
"language_order",
")",
... | [
473,
4
] | [
491,
19
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.preprocess | (self, source, output_file=None, macros=None,
include_dirs=None, extra_preargs=None, extra_postargs=None) | Preprocess a single C/C++ source file, named in 'source'.
Output will be written to file named 'output_file', or stdout if
'output_file' not supplied. 'macros' is a list of macro
definitions as for 'compile()', which will augment the macros set
with 'define_macro()' and 'undefine_macro(... | Preprocess a single C/C++ source file, named in 'source'.
Output will be written to file named 'output_file', or stdout if
'output_file' not supplied. 'macros' is a list of macro
definitions as for 'compile()', which will augment the macros set
with 'define_macro()' and 'undefine_macro(... | def preprocess(self, source, output_file=None, macros=None,
include_dirs=None, extra_preargs=None, extra_postargs=None):
"""Preprocess a single C/C++ source file, named in 'source'.
Output will be written to file named 'output_file', or stdout if
'output_file' not supplied. '... | [
"def",
"preprocess",
"(",
"self",
",",
"source",
",",
"output_file",
"=",
"None",
",",
"macros",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"extra_preargs",
"=",
"None",
",",
"extra_postargs",
"=",
"None",
")",
":",
"pass"
] | [
497,
4
] | [
508,
12
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.compile | (self, sources, output_dir=None, macros=None,
include_dirs=None, debug=0, extra_preargs=None,
extra_postargs=None, depends=None) | Compile one or more source files.
'sources' must be a list of filenames, most likely C/C++
files, but in reality anything that can be handled by a
particular compiler and compiler class (eg. MSVCCompiler can
handle resource files in 'sources'). Return a list of object
filenames... | Compile one or more source files. | def compile(self, sources, output_dir=None, macros=None,
include_dirs=None, debug=0, extra_preargs=None,
extra_postargs=None, depends=None):
"""Compile one or more source files.
'sources' must be a list of filenames, most likely C/C++
files, but in reality anythi... | [
"def",
"compile",
"(",
"self",
",",
"sources",
",",
"output_dir",
"=",
"None",
",",
"macros",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"debug",
"=",
"0",
",",
"extra_preargs",
"=",
"None",
",",
"extra_postargs",
"=",
"None",
",",
"depends",
... | [
510,
4
] | [
576,
22
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._compile | (self, obj, src, ext, cc_args, extra_postargs, pp_opts) | Compile 'src' to product 'obj'. | Compile 'src' to product 'obj'. | def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
"""Compile 'src' to product 'obj'."""
# A concrete compiler class that does not override compile()
# should implement _compile().
pass | [
"def",
"_compile",
"(",
"self",
",",
"obj",
",",
"src",
",",
"ext",
",",
"cc_args",
",",
"extra_postargs",
",",
"pp_opts",
")",
":",
"# A concrete compiler class that does not override compile()",
"# should implement _compile().",
"pass"
] | [
578,
4
] | [
582,
12
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.create_static_lib | (self, objects, output_libname, output_dir=None,
debug=0, target_lang=None) | Link a bunch of stuff together to create a static library file.
The "bunch of stuff" consists of the list of object files supplied
as 'objects', the extra object files supplied to
'add_link_object()' and/or 'set_link_objects()', the libraries
supplied to 'add_library()' and/or 'set_libra... | Link a bunch of stuff together to create a static library file.
The "bunch of stuff" consists of the list of object files supplied
as 'objects', the extra object files supplied to
'add_link_object()' and/or 'set_link_objects()', the libraries
supplied to 'add_library()' and/or 'set_libra... | def create_static_lib(self, objects, output_libname, output_dir=None,
debug=0, target_lang=None):
"""Link a bunch of stuff together to create a static library file.
The "bunch of stuff" consists of the list of object files supplied
as 'objects', the extra object files s... | [
"def",
"create_static_lib",
"(",
"self",
",",
"objects",
",",
"output_libname",
",",
"output_dir",
"=",
"None",
",",
"debug",
"=",
"0",
",",
"target_lang",
"=",
"None",
")",
":",
"pass"
] | [
584,
4
] | [
608,
12
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.link | (self,
target_desc,
objects,
output_filename,
output_dir=None,
libraries=None,
library_dirs=None,
runtime_library_dirs=None,
export_symbols=None,
debug=0,
extra_preargs=None,
ex... | Link a bunch of stuff together to create an executable or
shared library file.
The "bunch of stuff" consists of the list of object files supplied
as 'objects'. 'output_filename' should be a filename. If
'output_dir' is supplied, 'output_filename' is relative to it
(i.e. 'outpu... | Link a bunch of stuff together to create an executable or
shared library file. | def link(self,
target_desc,
objects,
output_filename,
output_dir=None,
libraries=None,
library_dirs=None,
runtime_library_dirs=None,
export_symbols=None,
debug=0,
extra_preargs=None,
... | [
"def",
"link",
"(",
"self",
",",
"target_desc",
",",
"objects",
",",
"output_filename",
",",
"output_dir",
"=",
"None",
",",
"libraries",
"=",
"None",
",",
"library_dirs",
"=",
"None",
",",
"runtime_library_dirs",
"=",
"None",
",",
"export_symbols",
"=",
"No... | [
616,
4
] | [
673,
33
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.library_dir_option | (self, dir) | Return the compiler option to add 'dir' to the list of
directories searched for libraries.
| Return the compiler option to add 'dir' to the list of
directories searched for libraries.
| def library_dir_option(self, dir):
"""Return the compiler option to add 'dir' to the list of
directories searched for libraries.
"""
raise NotImplementedError | [
"def",
"library_dir_option",
"(",
"self",
",",
"dir",
")",
":",
"raise",
"NotImplementedError"
] | [
741,
4
] | [
745,
33
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.runtime_library_dir_option | (self, dir) | Return the compiler option to add 'dir' to the list of
directories searched for runtime libraries.
| Return the compiler option to add 'dir' to the list of
directories searched for runtime libraries.
| def runtime_library_dir_option(self, dir):
"""Return the compiler option to add 'dir' to the list of
directories searched for runtime libraries.
"""
raise NotImplementedError | [
"def",
"runtime_library_dir_option",
"(",
"self",
",",
"dir",
")",
":",
"raise",
"NotImplementedError"
] | [
747,
4
] | [
751,
33
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.library_option | (self, lib) | Return the compiler option to add 'lib' to the list of libraries
linked into the shared library or executable.
| Return the compiler option to add 'lib' to the list of libraries
linked into the shared library or executable.
| def library_option(self, lib):
"""Return the compiler option to add 'lib' to the list of libraries
linked into the shared library or executable.
"""
raise NotImplementedError | [
"def",
"library_option",
"(",
"self",
",",
"lib",
")",
":",
"raise",
"NotImplementedError"
] | [
753,
4
] | [
757,
33
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.has_function | (self, funcname, includes=None, include_dirs=None,
libraries=None, library_dirs=None) | Return a boolean indicating whether funcname is supported on
the current platform. The optional arguments can be used to
augment the compilation environment.
| Return a boolean indicating whether funcname is supported on
the current platform. The optional arguments can be used to
augment the compilation environment.
| def has_function(self, funcname, includes=None, include_dirs=None,
libraries=None, library_dirs=None):
"""Return a boolean indicating whether funcname is supported on
the current platform. The optional arguments can be used to
augment the compilation environment.
""... | [
"def",
"has_function",
"(",
"self",
",",
"funcname",
",",
"includes",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"libraries",
"=",
"None",
",",
"library_dirs",
"=",
"None",
")",
":",
"# this can't be included at module scope because it tries to",
"# import ... | [
759,
4
] | [
801,
19
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.find_library_file | (self, dirs, lib, debug=0) | Search the specified list of directories for a static or shared
library file 'lib' and return the full path to that file. If
'debug' true, look for a debugging version (if that makes sense on
the current platform). Return None if 'lib' wasn't found in any of
the specified directories.
... | Search the specified list of directories for a static or shared
library file 'lib' and return the full path to that file. If
'debug' true, look for a debugging version (if that makes sense on
the current platform). Return None if 'lib' wasn't found in any of
the specified directories.
... | def find_library_file (self, dirs, lib, debug=0):
"""Search the specified list of directories for a static or shared
library file 'lib' and return the full path to that file. If
'debug' true, look for a debugging version (if that makes sense on
the current platform). Return None if 'li... | [
"def",
"find_library_file",
"(",
"self",
",",
"dirs",
",",
"lib",
",",
"debug",
"=",
"0",
")",
":",
"raise",
"NotImplementedError"
] | [
803,
4
] | [
810,
33
] | python | en | ['en', 'en', 'en'] | True |
Item.on_animation_proxy | (self, *args) | When we create an animation proxy for an item, we need to bind to
the animated property to update our own.
| When we create an animation proxy for an item, we need to bind to
the animated property to update our own.
| def on_animation_proxy(self, *args):
"""When we create an animation proxy for an item, we need to bind to
the animated property to update our own.
"""
if self._animation_proxy:
self._animation_proxy.unbind(opacity=self.update_opacity)
self._animation_proxy = self.ani... | [
"def",
"on_animation_proxy",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"self",
".",
"_animation_proxy",
":",
"self",
".",
"_animation_proxy",
".",
"unbind",
"(",
"opacity",
"=",
"self",
".",
"update_opacity",
")",
"self",
".",
"_animation_proxy",
"=",
... | [
53,
4
] | [
69,
28
] | python | en | ['en', 'en', 'en'] | True |
extract | (path, to_path='') |
Unpack the tar or zip file at the specified path to the directory
specified by to_path.
|
Unpack the tar or zip file at the specified path to the directory
specified by to_path.
| def extract(path, to_path=''):
"""
Unpack the tar or zip file at the specified path to the directory
specified by to_path.
"""
with Archive(path) as archive:
archive.extract(to_path) | [
"def",
"extract",
"(",
"path",
",",
"to_path",
"=",
"''",
")",
":",
"with",
"Archive",
"(",
"path",
")",
"as",
"archive",
":",
"archive",
".",
"extract",
"(",
"to_path",
")"
] | [
44,
0
] | [
50,
32
] | python | en | ['en', 'error', 'th'] | False |
BaseArchive._copy_permissions | (mode, filename) |
If the file in the archive has some permissions (this assumes a file
won't be writable/executable without being readable), apply those
permissions to the unarchived file.
|
If the file in the archive has some permissions (this assumes a file
won't be writable/executable without being readable), apply those
permissions to the unarchived file.
| def _copy_permissions(mode, filename):
"""
If the file in the archive has some permissions (this assumes a file
won't be writable/executable without being readable), apply those
permissions to the unarchived file.
"""
if mode & stat.S_IROTH:
os.chmod(filename,... | [
"def",
"_copy_permissions",
"(",
"mode",
",",
"filename",
")",
":",
"if",
"mode",
"&",
"stat",
".",
"S_IROTH",
":",
"os",
".",
"chmod",
"(",
"filename",
",",
"mode",
")"
] | [
102,
4
] | [
109,
36
] | python | en | ['en', 'error', 'th'] | False |
BaseArchive.has_leading_dir | (self, paths) |
Returns true if all the paths have the same leading path name
(i.e., everything is in one subdirectory in an archive)
|
Returns true if all the paths have the same leading path name
(i.e., everything is in one subdirectory in an archive)
| def has_leading_dir(self, paths):
"""
Returns true if all the paths have the same leading path name
(i.e., everything is in one subdirectory in an archive)
"""
common_prefix = None
for path in paths:
prefix, rest = self.split_leading_dir(path)
if n... | [
"def",
"has_leading_dir",
"(",
"self",
",",
"paths",
")",
":",
"common_prefix",
"=",
"None",
"for",
"path",
"in",
"paths",
":",
"prefix",
",",
"rest",
"=",
"self",
".",
"split_leading_dir",
"(",
"path",
")",
"if",
"not",
"prefix",
":",
"return",
"False",... | [
121,
4
] | [
135,
19
] | python | en | ['en', 'error', 'th'] | False |
cleavage_lr | (bw, chrom, upslic, downslic) |
Generate a log odds ratio similar to endCut but for nanopore data:
instead of the ratio of cut site 5' tags to
|
Generate a log odds ratio similar to endCut but for nanopore data:
instead of the ratio of cut site 5' tags to
| def cleavage_lr(bw, chrom, upslic, downslic):
'''
Generate a log odds ratio similar to endCut but for nanopore data:
instead of the ratio of cut site 5' tags to
'''
upstream_cut = sum([
np.nansum(bw.values(str(chrom), i, j)) for i, j in upslic
])
downstream_cut = sum([
np.na... | [
"def",
"cleavage_lr",
"(",
"bw",
",",
"chrom",
",",
"upslic",
",",
"downslic",
")",
":",
"upstream_cut",
"=",
"sum",
"(",
"[",
"np",
".",
"nansum",
"(",
"bw",
".",
"values",
"(",
"str",
"(",
"chrom",
")",
",",
"i",
",",
"j",
")",
")",
"for",
"i... | [
43,
0
] | [
54,
61
] | python | en | ['en', 'error', 'th'] | False |
UniBucket.__init__ | (self, hash_name) | Just keeps the name. | Just keeps the name. | def __init__(self, hash_name):
""" Just keeps the name. """
super(UniBucket, self).__init__(hash_name)
self.dim = None | [
"def",
"__init__",
"(",
"self",
",",
"hash_name",
")",
":",
"super",
"(",
"UniBucket",
",",
"self",
")",
".",
"__init__",
"(",
"hash_name",
")",
"self",
".",
"dim",
"=",
"None"
] | [
33,
4
] | [
36,
23
] | python | en | ['en', 'en', 'en'] | True |
UniBucket.reset | (self, dim) | Resets / Initializes the hash for the specified dimension. | Resets / Initializes the hash for the specified dimension. | def reset(self, dim):
""" Resets / Initializes the hash for the specified dimension. """
self.dim = dim | [
"def",
"reset",
"(",
"self",
",",
"dim",
")",
":",
"self",
".",
"dim",
"=",
"dim"
] | [
38,
4
] | [
40,
22
] | python | en | ['en', 'en', 'en'] | True |
UniBucket.hash_vector | (self, v, querying=False) |
Hashes the vector and returns the bucket key as string.
|
Hashes the vector and returns the bucket key as string.
| def hash_vector(self, v, querying=False):
"""
Hashes the vector and returns the bucket key as string.
"""
# Return bucket key identical to vector string representation
return [self.hash_name+''] | [
"def",
"hash_vector",
"(",
"self",
",",
"v",
",",
"querying",
"=",
"False",
")",
":",
"# Return bucket key identical to vector string representation",
"return",
"[",
"self",
".",
"hash_name",
"+",
"''",
"]"
] | [
42,
4
] | [
47,
34
] | python | en | ['en', 'error', 'th'] | False |
UniBucket.get_config | (self) |
Returns pickle-serializable configuration struct for storage.
|
Returns pickle-serializable configuration struct for storage.
| def get_config(self):
"""
Returns pickle-serializable configuration struct for storage.
"""
return {
'hash_name': self.hash_name,
'dim': self.dim
} | [
"def",
"get_config",
"(",
"self",
")",
":",
"return",
"{",
"'hash_name'",
":",
"self",
".",
"hash_name",
",",
"'dim'",
":",
"self",
".",
"dim",
"}"
] | [
49,
4
] | [
56,
9
] | python | en | ['en', 'error', 'th'] | False |
UniBucket.apply_config | (self, config) |
Applies config
|
Applies config
| def apply_config(self, config):
"""
Applies config
"""
self.hash_name = config['hash_name']
self.dim = config['dim'] | [
"def",
"apply_config",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"hash_name",
"=",
"config",
"[",
"'hash_name'",
"]",
"self",
".",
"dim",
"=",
"config",
"[",
"'dim'",
"]"
] | [
58,
4
] | [
63,
32
] | python | en | ['en', 'error', 'th'] | False |
ThreadWorker.get_thread_pool | (self) | Override this method to customize how the thread pool is created | Override this method to customize how the thread pool is created | def get_thread_pool(self):
"""Override this method to customize how the thread pool is created"""
return futures.ThreadPoolExecutor(max_workers=self.cfg.threads) | [
"def",
"get_thread_pool",
"(",
"self",
")",
":",
"return",
"futures",
".",
"ThreadPoolExecutor",
"(",
"max_workers",
"=",
"self",
".",
"cfg",
".",
"threads",
")"
] | [
93,
4
] | [
95,
71
] | python | en | ['en', 'en', 'en'] | True |
_dnsname_match | (dn, hostname, max_wildcards=1) | Matching according to RFC 6125, section 6.4.3
http://tools.ietf.org/html/rfc6125#section-6.4.3
| Matching according to RFC 6125, section 6.4.3 | def _dnsname_match(dn, hostname, max_wildcards=1):
"""Matching according to RFC 6125, section 6.4.3
http://tools.ietf.org/html/rfc6125#section-6.4.3
"""
pats = []
if not dn:
return False
# Ported from python3-syntax:
# leftmost, *remainder = dn.split(r'.')
parts = dn.split(r"."... | [
"def",
"_dnsname_match",
"(",
"dn",
",",
"hostname",
",",
"max_wildcards",
"=",
"1",
")",
":",
"pats",
"=",
"[",
"]",
"if",
"not",
"dn",
":",
"return",
"False",
"# Ported from python3-syntax:",
"# leftmost, *remainder = dn.split(r'.')",
"parts",
"=",
"dn",
".",
... | [
24,
0
] | [
75,
30
] | python | en | ['en', 'en', 'en'] | True |
_ipaddress_match | (ipname, host_ip) | Exact matching of IP addresses.
RFC 6125 explicitly doesn't define an algorithm for this
(section 1.7.2 - "Out of Scope").
| Exact matching of IP addresses. | def _ipaddress_match(ipname, host_ip):
"""Exact matching of IP addresses.
RFC 6125 explicitly doesn't define an algorithm for this
(section 1.7.2 - "Out of Scope").
"""
# OpenSSL may add a trailing newline to a subjectAltName's IP address
# Divergence from upstream: ipaddress can't handle byte ... | [
"def",
"_ipaddress_match",
"(",
"ipname",
",",
"host_ip",
")",
":",
"# OpenSSL may add a trailing newline to a subjectAltName's IP address",
"# Divergence from upstream: ipaddress can't handle byte str",
"ip",
"=",
"ipaddress",
".",
"ip_address",
"(",
"_to_unicode",
"(",
"ipname"... | [
84,
0
] | [
93,
24
] | python | en | ['en', 'sn', 'en'] | True |
match_hostname | (cert, hostname) | Verify that *cert* (in decoded format as returned by
SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125
rules are followed, but IP addresses are not accepted for *hostname*.
CertificateError is raised on failure. On success, the function
returns nothing.
| Verify that *cert* (in decoded format as returned by
SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125
rules are followed, but IP addresses are not accepted for *hostname*. | def match_hostname(cert, hostname):
"""Verify that *cert* (in decoded format as returned by
SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125
rules are followed, but IP addresses are not accepted for *hostname*.
CertificateError is raised on failure. On success, the function
r... | [
"def",
"match_hostname",
"(",
"cert",
",",
"hostname",
")",
":",
"if",
"not",
"cert",
":",
"raise",
"ValueError",
"(",
"\"empty or no certificate, match_hostname needs a \"",
"\"SSL socket or SSL context with either \"",
"\"CERT_OPTIONAL or CERT_REQUIRED\"",
")",
"try",
":",
... | [
96,
0
] | [
159,
9
] | python | en | ['en', 'en', 'en'] | True |
parse_index_file | (filename) | Parse index file. | Parse index file. | def parse_index_file(filename):
"""Parse index file."""
index = []
for line in open(filename):
index.append(int(line.strip()))
return index | [
"def",
"parse_index_file",
"(",
"filename",
")",
":",
"index",
"=",
"[",
"]",
"for",
"line",
"in",
"open",
"(",
"filename",
")",
":",
"index",
".",
"append",
"(",
"int",
"(",
"line",
".",
"strip",
"(",
")",
")",
")",
"return",
"index"
] | [
91,
0
] | [
96,
16
] | python | en | ['en', 'la', 'en'] | True |
sample_mask | (idx, l) | Create mask. | Create mask. | def sample_mask(idx, l):
"""Create mask."""
mask = np.zeros(l)
mask[idx] = 1
return np.array(mask, dtype=np.bool) | [
"def",
"sample_mask",
"(",
"idx",
",",
"l",
")",
":",
"mask",
"=",
"np",
".",
"zeros",
"(",
"l",
")",
"mask",
"[",
"idx",
"]",
"=",
"1",
"return",
"np",
".",
"array",
"(",
"mask",
",",
"dtype",
"=",
"np",
".",
"bool",
")"
] | [
98,
0
] | [
102,
40
] | python | en | ['en', 'sm', 'en'] | False |
sparse_to_tuple | (sparse_mx, insert_batch=False) | Convert sparse matrix to tuple representation. | Convert sparse matrix to tuple representation. | def sparse_to_tuple(sparse_mx, insert_batch=False):
"""Convert sparse matrix to tuple representation."""
"""Set insert_batch=True if you want to insert a batch dimension."""
def to_tuple(mx):
if not sp.isspmatrix_coo(mx):
mx = mx.tocoo()
if insert_batch:
coords = np.v... | [
"def",
"sparse_to_tuple",
"(",
"sparse_mx",
",",
"insert_batch",
"=",
"False",
")",
":",
"\"\"\"Set insert_batch=True if you want to insert a batch dimension.\"\"\"",
"def",
"to_tuple",
"(",
"mx",
")",
":",
"if",
"not",
"sp",
".",
"isspmatrix_coo",
"(",
"mx",
")",
"... | [
143,
0
] | [
165,
20
] | python | it | ['en', 'it', 'it'] | True |
standardize_data | (f, train_mask) | Standardize feature matrix and convert to tuple representation | Standardize feature matrix and convert to tuple representation | def standardize_data(f, train_mask):
"""Standardize feature matrix and convert to tuple representation"""
# standardize data
f = f.todense()
mu = f[train_mask == True, :].mean(axis=0)
sigma = f[train_mask == True, :].std(axis=0)
f = f[:, np.squeeze(np.array(sigma > 0))]
mu = f[train_mask == ... | [
"def",
"standardize_data",
"(",
"f",
",",
"train_mask",
")",
":",
"# standardize data",
"f",
"=",
"f",
".",
"todense",
"(",
")",
"mu",
"=",
"f",
"[",
"train_mask",
"==",
"True",
",",
":",
"]",
".",
"mean",
"(",
"axis",
"=",
"0",
")",
"sigma",
"=",
... | [
167,
0
] | [
177,
12
] | python | en | ['en', 'ny', 'en'] | True |
preprocess_features | (features) | Row-normalize feature matrix and convert to tuple representation | Row-normalize feature matrix and convert to tuple representation | def preprocess_features(features):
"""Row-normalize feature matrix and convert to tuple representation"""
rowsum = np.array(features.sum(1))
r_inv = np.power(rowsum, -1).flatten()
r_inv[np.isinf(r_inv)] = 0.
r_mat_inv = sp.diags(r_inv)
features = r_mat_inv.dot(features)
return features.toden... | [
"def",
"preprocess_features",
"(",
"features",
")",
":",
"rowsum",
"=",
"np",
".",
"array",
"(",
"features",
".",
"sum",
"(",
"1",
")",
")",
"r_inv",
"=",
"np",
".",
"power",
"(",
"rowsum",
",",
"-",
"1",
")",
".",
"flatten",
"(",
")",
"r_inv",
"... | [
179,
0
] | [
186,
56
] | python | en | ['en', 'en', 'en'] | True |
normalize_adj | (adj) | Symmetrically normalize adjacency matrix. | Symmetrically normalize adjacency matrix. | def normalize_adj(adj):
"""Symmetrically normalize adjacency matrix."""
adj = sp.coo_matrix(adj)
rowsum = np.array(adj.sum(1))
d_inv_sqrt = np.power(rowsum, -0.5).flatten()
d_inv_sqrt[np.isinf(d_inv_sqrt)] = 0.
d_mat_inv_sqrt = sp.diags(d_inv_sqrt)
return adj.dot(d_mat_inv_sqrt).transpose().... | [
"def",
"normalize_adj",
"(",
"adj",
")",
":",
"adj",
"=",
"sp",
".",
"coo_matrix",
"(",
"adj",
")",
"rowsum",
"=",
"np",
".",
"array",
"(",
"adj",
".",
"sum",
"(",
"1",
")",
")",
"d_inv_sqrt",
"=",
"np",
".",
"power",
"(",
"rowsum",
",",
"-",
"... | [
188,
0
] | [
195,
74
] | python | en | ['en', 'cs', 'en'] | True |
preprocess_adj | (adj) | Preprocessing of adjacency matrix for simple GCN model and conversion to tuple representation. | Preprocessing of adjacency matrix for simple GCN model and conversion to tuple representation. | def preprocess_adj(adj):
"""Preprocessing of adjacency matrix for simple GCN model and conversion to tuple representation."""
adj_normalized = normalize_adj(adj + sp.eye(adj.shape[0]))
return sparse_to_tuple(adj_normalized) | [
"def",
"preprocess_adj",
"(",
"adj",
")",
":",
"adj_normalized",
"=",
"normalize_adj",
"(",
"adj",
"+",
"sp",
".",
"eye",
"(",
"adj",
".",
"shape",
"[",
"0",
"]",
")",
")",
"return",
"sparse_to_tuple",
"(",
"adj_normalized",
")"
] | [
198,
0
] | [
201,
42
] | python | en | ['en', 'en', 'en'] | True |
sparse_mx_to_torch_sparse_tensor | (sparse_mx) | Convert a scipy sparse matrix to a torch sparse tensor. | Convert a scipy sparse matrix to a torch sparse tensor. | def sparse_mx_to_torch_sparse_tensor(sparse_mx):
"""Convert a scipy sparse matrix to a torch sparse tensor."""
sparse_mx = sparse_mx.tocoo().astype(np.float32)
indices = torch.from_numpy(
np.vstack((sparse_mx.row, sparse_mx.col)).astype(np.int64))
values = torch.from_numpy(sparse_mx.data)
sh... | [
"def",
"sparse_mx_to_torch_sparse_tensor",
"(",
"sparse_mx",
")",
":",
"sparse_mx",
"=",
"sparse_mx",
".",
"tocoo",
"(",
")",
".",
"astype",
"(",
"np",
".",
"float32",
")",
"indices",
"=",
"torch",
".",
"from_numpy",
"(",
"np",
".",
"vstack",
"(",
"(",
"... | [
203,
0
] | [
210,
59
] | python | en | ['en', 'en', 'it'] | True |
mask_test_edges | (adj, test_frac=.1, val_frac=.05, prevent_disconnect=True, verbose=False) | from https://github.com/tkipf/gae | from https://github.com/tkipf/gae | def mask_test_edges(adj, test_frac=.1, val_frac=.05, prevent_disconnect=True, verbose=False):
# NOTE: Splits are randomized and results might slightly deviate from reported numbers in the paper.
"from https://github.com/tkipf/gae"
if verbose == True:
print('preprocessing...')
# Remove diag... | [
"def",
"mask_test_edges",
"(",
"adj",
",",
"test_frac",
"=",
".1",
",",
"val_frac",
"=",
".05",
",",
"prevent_disconnect",
"=",
"True",
",",
"verbose",
"=",
"False",
")",
":",
"# NOTE: Splits are randomized and results might slightly deviate from reported numbers in the p... | [
216,
0
] | [
385,
64
] | python | en | ['en', 'no', 'sw'] | False |
tempdir | () | Create a temporary directory in a context manager. | Create a temporary directory in a context manager. | def tempdir():
"""Create a temporary directory in a context manager."""
td = tempfile.mkdtemp()
try:
yield td
finally:
shutil.rmtree(td) | [
"def",
"tempdir",
"(",
")",
":",
"td",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"try",
":",
"yield",
"td",
"finally",
":",
"shutil",
".",
"rmtree",
"(",
"td",
")"
] | [
10,
0
] | [
16,
25
] | python | en | ['en', 'en', 'en'] | True |
mkdir_p | (*args, **kwargs) | Like `mkdir`, but does not raise an exception if the
directory already exists.
| Like `mkdir`, but does not raise an exception if the
directory already exists.
| def mkdir_p(*args, **kwargs):
"""Like `mkdir`, but does not raise an exception if the
directory already exists.
"""
try:
return os.mkdir(*args, **kwargs)
except OSError as exc:
if exc.errno != errno.EEXIST:
raise | [
"def",
"mkdir_p",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"os",
".",
"mkdir",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"OSError",
"as",
"exc",
":",
"if",
"exc",
".",
"errno",
"!=",
"errno",
".... | [
19,
0
] | [
27,
17
] | python | en | ['en', 'en', 'en'] | True |
dir_to_zipfile | (root) | Construct an in-memory zip file for a directory. | Construct an in-memory zip file for a directory. | def dir_to_zipfile(root):
"""Construct an in-memory zip file for a directory."""
buffer = io.BytesIO()
zip_file = zipfile.ZipFile(buffer, 'w')
for root, dirs, files in os.walk(root):
for path in dirs:
fs_path = os.path.join(root, path)
rel_path = os.path.relpath(fs_path, ... | [
"def",
"dir_to_zipfile",
"(",
"root",
")",
":",
"buffer",
"=",
"io",
".",
"BytesIO",
"(",
")",
"zip_file",
"=",
"zipfile",
".",
"ZipFile",
"(",
"buffer",
",",
"'w'",
")",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"root... | [
30,
0
] | [
43,
19
] | python | en | ['br', 'en', 'en'] | True |
execute_command | (cmd, cwd=None) |
Execute a command, capture and return its output.
|
Execute a command, capture and return its output.
| def execute_command(cmd, cwd=None):
"""
Execute a command, capture and return its output.
"""
kwargs = {
'stdin': subprocess.PIPE,
'stdout': subprocess.PIPE,
'stderr': subprocess.PIPE,
'cwd': cwd
}
p = subprocess.Popen(cmd, **kwargs)
out, err = p.communicate()... | [
"def",
"execute_command",
"(",
"cmd",
",",
"cwd",
"=",
"None",
")",
":",
"kwargs",
"=",
"{",
"'stdin'",
":",
"subprocess",
".",
"PIPE",
",",
"'stdout'",
":",
"subprocess",
".",
"PIPE",
",",
"'stderr'",
":",
"subprocess",
".",
"PIPE",
",",
"'cwd'",
":",... | [
45,
0
] | [
60,
29
] | python | en | ['en', 'error', 'th'] | False |
execute_command_verbose | (cmd, cwd=None, verbose=False) |
Execute a command and print its output on failure.
|
Execute a command and print its output on failure.
| def execute_command_verbose(cmd, cwd=None, verbose=False):
"""
Execute a command and print its output on failure.
"""
out, err, exitCode = execute_command(cmd, cwd=cwd)
if exitCode != 0 or verbose:
report = "Command: %s\n" % ' '.join(["'%s'" % a for a in cmd])
if exitCode != 0:
... | [
"def",
"execute_command_verbose",
"(",
"cmd",
",",
"cwd",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"out",
",",
"err",
",",
"exitCode",
"=",
"execute_command",
"(",
"cmd",
",",
"cwd",
"=",
"cwd",
")",
"if",
"exitCode",
"!=",
"0",
"or",
"ve... | [
63,
0
] | [
80,
40
] | python | en | ['en', 'error', 'th'] | False |
maybe_send_to_registration | (
request: HttpRequest,
email: str,
full_name: str = "",
mobile_flow_otp: Optional[str] = None,
desktop_flow_otp: Optional[str] = None,
is_signup: bool = False,
password_required: bool = True,
multiuse_object_key: str = "",
full_name_validated: bool = False,
) | Given a successful authentication for an email address (i.e. we've
confirmed the user controls the email address) that does not
currently have a Zulip account in the target realm, send them to
the registration flow or the "continue to registration" flow,
depending on is_signup, whether the email address... | Given a successful authentication for an email address (i.e. we've
confirmed the user controls the email address) that does not
currently have a Zulip account in the target realm, send them to
the registration flow or the "continue to registration" flow,
depending on is_signup, whether the email address... | def maybe_send_to_registration(
request: HttpRequest,
email: str,
full_name: str = "",
mobile_flow_otp: Optional[str] = None,
desktop_flow_otp: Optional[str] = None,
is_signup: bool = False,
password_required: bool = True,
multiuse_object_key: str = "",
full_name_validated: bool = Fa... | [
"def",
"maybe_send_to_registration",
"(",
"request",
":",
"HttpRequest",
",",
"email",
":",
"str",
",",
"full_name",
":",
"str",
"=",
"\"\"",
",",
"mobile_flow_otp",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"desktop_flow_otp",
":",
"Optional",
"["... | [
122,
0
] | [
243,
72
] | python | en | ['en', 'en', 'en'] | True |
login_or_register_remote_user | (request: HttpRequest, result: ExternalAuthResult) | Given a successful authentication showing the user controls given
email address (email) and potentially a UserProfile
object (if the user already has a Zulip account), redirect the
browser to the appropriate place:
* The logged-in app if the user already has a Zulip account and is
trying to log i... | Given a successful authentication showing the user controls given
email address (email) and potentially a UserProfile
object (if the user already has a Zulip account), redirect the
browser to the appropriate place: | def login_or_register_remote_user(request: HttpRequest, result: ExternalAuthResult) -> HttpResponse:
"""Given a successful authentication showing the user controls given
email address (email) and potentially a UserProfile
object (if the user already has a Zulip account), redirect the
browser to the appr... | [
"def",
"login_or_register_remote_user",
"(",
"request",
":",
"HttpRequest",
",",
"result",
":",
"ExternalAuthResult",
")",
"->",
"HttpResponse",
":",
"user_profile",
"=",
"result",
".",
"user_profile",
"if",
"user_profile",
"is",
"None",
"or",
"user_profile",
".",
... | [
260,
0
] | [
303,
44
] | python | en | ['en', 'en', 'en'] | True |
finish_desktop_flow | (request: HttpRequest, user_profile: UserProfile, otp: str) |
The desktop otp flow returns to the app (through the clipboard)
a token that allows obtaining (through log_into_subdomain) a logged in session
for the user account we authenticated in this flow.
The token can only be used once and within ExternalAuthResult.LOGIN_KEY_EXPIRATION_SECONDS
of being crea... |
The desktop otp flow returns to the app (through the clipboard)
a token that allows obtaining (through log_into_subdomain) a logged in session
for the user account we authenticated in this flow.
The token can only be used once and within ExternalAuthResult.LOGIN_KEY_EXPIRATION_SECONDS
of being crea... | def finish_desktop_flow(request: HttpRequest, user_profile: UserProfile, otp: str) -> HttpResponse:
"""
The desktop otp flow returns to the app (through the clipboard)
a token that allows obtaining (through log_into_subdomain) a logged in session
for the user account we authenticated in this flow.
T... | [
"def",
"finish_desktop_flow",
"(",
"request",
":",
"HttpRequest",
",",
"user_profile",
":",
"UserProfile",
",",
"otp",
":",
"str",
")",
"->",
"HttpResponse",
":",
"result",
"=",
"ExternalAuthResult",
"(",
"user_profile",
"=",
"user_profile",
")",
"token",
"=",
... | [
306,
0
] | [
325,
75
] | python | en | ['en', 'error', 'th'] | False |
start_remote_user_sso | (request: HttpRequest) |
The purpose of this endpoint is to provide an initial step in the flow
on which we can handle the special behavior for the desktop app.
/accounts/login/sso may have Apache intercepting requests to it
to do authentication, so we need this additional endpoint.
|
The purpose of this endpoint is to provide an initial step in the flow
on which we can handle the special behavior for the desktop app.
/accounts/login/sso may have Apache intercepting requests to it
to do authentication, so we need this additional endpoint.
| def start_remote_user_sso(request: HttpRequest) -> HttpResponse:
"""
The purpose of this endpoint is to provide an initial step in the flow
on which we can handle the special behavior for the desktop app.
/accounts/login/sso may have Apache intercepting requests to it
to do authentication, so we nee... | [
"def",
"start_remote_user_sso",
"(",
"request",
":",
"HttpRequest",
")",
"->",
"HttpResponse",
":",
"query",
"=",
"request",
".",
"META",
"[",
"\"QUERY_STRING\"",
"]",
"return",
"redirect",
"(",
"add_query_to_redirect_url",
"(",
"reverse",
"(",
"remote_user_sso",
... | [
532,
0
] | [
540,
79
] | python | en | ['en', 'error', 'th'] | False |
log_into_subdomain | (request: HttpRequest, token: str) | Given a valid authentication token (generated by
redirect_and_log_into_subdomain called on auth.zulip.example.com),
call login_or_register_remote_user, passing all the authentication
result data that has been stored in Redis, associated with this token.
| Given a valid authentication token (generated by
redirect_and_log_into_subdomain called on auth.zulip.example.com),
call login_or_register_remote_user, passing all the authentication
result data that has been stored in Redis, associated with this token.
| def log_into_subdomain(request: HttpRequest, token: str) -> HttpResponse:
"""Given a valid authentication token (generated by
redirect_and_log_into_subdomain called on auth.zulip.example.com),
call login_or_register_remote_user, passing all the authentication
result data that has been stored in Redis, a... | [
"def",
"log_into_subdomain",
"(",
"request",
":",
"HttpRequest",
",",
"token",
":",
"str",
")",
"->",
"HttpResponse",
":",
"# The tokens are intended to have the same format as API keys.",
"if",
"not",
"has_api_key_format",
"(",
"token",
")",
":",
"logging",
".",
"war... | [
606,
0
] | [
627,
57
] | python | en | ['en', 'en', 'en'] | True |
start_two_factor_auth | (
request: HttpRequest, extra_context: ExtraContext = None, **kwargs: Any
) |
This is how Django implements as_view(), so extra_context will be passed
to the __init__ method of TwoFactorLoginView.
def as_view(cls, **initkwargs):
def view(request, *args, **kwargs):
self = cls(**initkwargs)
...
return view
|
This is how Django implements as_view(), so extra_context will be passed
to the __init__ method of TwoFactorLoginView. | def start_two_factor_auth(
request: HttpRequest, extra_context: ExtraContext = None, **kwargs: Any
) -> HttpResponse:
two_fa_form_field = "two_factor_login_view-current_step"
if two_fa_form_field not in request.POST:
# Here we inject the 2FA step in the request context if it's missing to
# f... | [
"def",
"start_two_factor_auth",
"(",
"request",
":",
"HttpRequest",
",",
"extra_context",
":",
"ExtraContext",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"HttpResponse",
":",
"two_fa_form_field",
"=",
"\"two_factor_login_view-current_step\"",
"if",... | [
783,
0
] | [
811,
41
] | python | en | ['en', 'error', 'th'] | False |
get_auth_backends_data | (request: HttpRequest) | Returns which authentication methods are enabled on the server | Returns which authentication methods are enabled on the server | def get_auth_backends_data(request: HttpRequest) -> Dict[str, Any]:
"""Returns which authentication methods are enabled on the server"""
subdomain = get_subdomain(request)
try:
realm = Realm.objects.get(string_id=subdomain)
except Realm.DoesNotExist:
# If not the root subdomain, this is ... | [
"def",
"get_auth_backends_data",
"(",
"request",
":",
"HttpRequest",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"subdomain",
"=",
"get_subdomain",
"(",
"request",
")",
"try",
":",
"realm",
"=",
"Realm",
".",
"objects",
".",
"get",
"(",
"string_... | [
877,
0
] | [
900,
17
] | python | en | ['en', 'en', 'en'] | True |
saml_sp_metadata | (request: HttpRequest, **kwargs: Any) |
This is the view function for generating our SP metadata
for SAML authentication. It's meant for helping check the correctness
of the configuration when setting up SAML, or for obtaining the XML metadata
if the IdP requires it.
Taken from https://python-social-auth.readthedocs.io/en/latest/backends... |
This is the view function for generating our SP metadata
for SAML authentication. It's meant for helping check the correctness
of the configuration when setting up SAML, or for obtaining the XML metadata
if the IdP requires it.
Taken from https://python-social-auth.readthedocs.io/en/latest/backends... | def saml_sp_metadata(request: HttpRequest, **kwargs: Any) -> HttpResponse: # nocoverage
"""
This is the view function for generating our SP metadata
for SAML authentication. It's meant for helping check the correctness
of the configuration when setting up SAML, or for obtaining the XML metadata
if ... | [
"def",
"saml_sp_metadata",
"(",
"request",
":",
"HttpRequest",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"HttpResponse",
":",
"# nocoverage",
"if",
"not",
"saml_auth_enabled",
"(",
")",
":",
"return",
"config_error",
"(",
"request",
",",
"\"saml\"",
")... | [
973,
0
] | [
990,
61
] | python | en | ['en', 'error', 'th'] | False |
TwoFactorLoginView.done | (self, form_list: List[Form], **kwargs: Any) |
Log in the user and redirect to the desired page.
We need to override this function so that we can redirect to
realm.uri instead of '/'.
|
Log in the user and redirect to the desired page. | def done(self, form_list: List[Form], **kwargs: Any) -> HttpResponse:
"""
Log in the user and redirect to the desired page.
We need to override this function so that we can redirect to
realm.uri instead of '/'.
"""
realm_uri = self.get_user().realm.uri
# This moc... | [
"def",
"done",
"(",
"self",
",",
"form_list",
":",
"List",
"[",
"Form",
"]",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"HttpResponse",
":",
"realm_uri",
"=",
"self",
".",
"get_user",
"(",
")",
".",
"realm",
".",
"uri",
"# This mock.patch business... | [
695,
4
] | [
712,
52
] | python | en | ['en', 'error', 'th'] | False |
toposort | (data) | Dependencies are expressed as a dictionary whose keys are items
and whose values are a set of dependent items. Output is a list of
sets in topological order. The first set consists of items with no
dependences, each subsequent set consists of items that depend upon
items in the preceeding sets. | Dependencies are expressed as a dictionary whose keys are items
and whose values are a set of dependent items. Output is a list of
sets in topological order. The first set consists of items with no
dependences, each subsequent set consists of items that depend upon
items in the preceeding sets. | def toposort(data):
"""Dependencies are expressed as a dictionary whose keys are items
and whose values are a set of dependent items. Output is a list of
sets in topological order. The first set consists of items with no
dependences, each subsequent set consists of items that depend upon
items in th... | [
"def",
"toposort",
"(",
"data",
")",
":",
"# Special case empty input.",
"if",
"len",
"(",
"data",
")",
"==",
"0",
":",
"return",
"# Copy the input so as to leave it unmodified.",
"data",
"=",
"data",
".",
"copy",
"(",
")",
"# Ignore self dependencies.",
"for",
"k... | [
51,
0
] | [
79,
43
] | python | en | ['en', 'en', 'en'] | True |
random_result | (*kwargs) | Random objective. | Random objective. | def random_result(*kwargs):
"""Random objective."""
return round(random.random(),3) * 100 | [
"def",
"random_result",
"(",
"*",
"kwargs",
")",
":",
"return",
"round",
"(",
"random",
".",
"random",
"(",
")",
",",
"3",
")",
"*",
"100"
] | [
21,
0
] | [
24,
41
] | python | en | ['en', 'mg', 'en'] | False |
Settings.get_endpoint | (self, endpoint) | Helper method used to navigate to a specific settings endpoint.
(Pdb) settings_pg.get_endpoint('all')
| Helper method used to navigate to a specific settings endpoint.
(Pdb) settings_pg.get_endpoint('all')
| def get_endpoint(self, endpoint):
"""Helper method used to navigate to a specific settings endpoint.
(Pdb) settings_pg.get_endpoint('all')
"""
base_url = '{0}{1}/'.format(self.endpoint, endpoint)
return self.walk(base_url) | [
"def",
"get_endpoint",
"(",
"self",
",",
"endpoint",
")",
":",
"base_url",
"=",
"'{0}{1}/'",
".",
"format",
"(",
"self",
".",
"endpoint",
",",
"endpoint",
")",
"return",
"self",
".",
"walk",
"(",
"base_url",
")"
] | [
35,
4
] | [
40,
34
] | python | en | ['en', 'en', 'en'] | True |
CustomSubmissionsListView.get_csv_filename | (self) | Returns the filename for CSV file with page title at start | Returns the filename for CSV file with page title at start | def get_csv_filename(self):
""" Returns the filename for CSV file with page title at start"""
filename = super().get_csv_filename()
return self.form_page.slug + '-' + filename | [
"def",
"get_csv_filename",
"(",
"self",
")",
":",
"filename",
"=",
"super",
"(",
")",
".",
"get_csv_filename",
"(",
")",
"return",
"self",
".",
"form_page",
".",
"slug",
"+",
"'-'",
"+",
"filename"
] | [
32,
4
] | [
35,
51
] | python | en | ['en', 'en', 'en'] | True |
SessionStore._key_to_file | (self, session_key=None) |
Get the file associated with this session key.
|
Get the file associated with this session key.
| def _key_to_file(self, session_key=None):
"""
Get the file associated with this session key.
"""
if session_key is None:
session_key = self._get_or_create_session_key()
# Make sure we're not vulnerable to directory traversal. Session keys
# should always be m... | [
"def",
"_key_to_file",
"(",
"self",
",",
"session_key",
"=",
"None",
")",
":",
"if",
"session_key",
"is",
"None",
":",
"session_key",
"=",
"self",
".",
"_get_or_create_session_key",
"(",
")",
"# Make sure we're not vulnerable to directory traversal. Session keys",
"# sh... | [
45,
4
] | [
59,
78
] | python | en | ['en', 'error', 'th'] | False |
SessionStore._last_modification | (self) |
Return the modification time of the file storing the session's content.
|
Return the modification time of the file storing the session's content.
| def _last_modification(self):
"""
Return the modification time of the file storing the session's content.
"""
modification = os.stat(self._key_to_file()).st_mtime
if settings.USE_TZ:
modification = datetime.datetime.utcfromtimestamp(modification)
modificat... | [
"def",
"_last_modification",
"(",
"self",
")",
":",
"modification",
"=",
"os",
".",
"stat",
"(",
"self",
".",
"_key_to_file",
"(",
")",
")",
".",
"st_mtime",
"if",
"settings",
".",
"USE_TZ",
":",
"modification",
"=",
"datetime",
".",
"datetime",
".",
"ut... | [
61,
4
] | [
71,
27
] | python | en | ['en', 'error', 'th'] | False |
SessionStore._expiry_date | (self, session_data) |
Return the expiry time of the file storing the session's content.
|
Return the expiry time of the file storing the session's content.
| def _expiry_date(self, session_data):
"""
Return the expiry time of the file storing the session's content.
"""
expiry = session_data.get('_session_expiry')
if not expiry:
expiry = self._last_modification() + datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE)
... | [
"def",
"_expiry_date",
"(",
"self",
",",
"session_data",
")",
":",
"expiry",
"=",
"session_data",
".",
"get",
"(",
"'_session_expiry'",
")",
"if",
"not",
"expiry",
":",
"expiry",
"=",
"self",
".",
"_last_modification",
"(",
")",
"+",
"datetime",
".",
"time... | [
73,
4
] | [
80,
21
] | python | en | ['en', 'error', 'th'] | False |
get_func_full_args | (func) |
Return a list of (argument name, default value) tuples. If the argument
does not have a default value, omit it in the tuple. Arguments such as
*args and **kwargs are also included.
|
Return a list of (argument name, default value) tuples. If the argument
does not have a default value, omit it in the tuple. Arguments such as
*args and **kwargs are also included.
| def get_func_full_args(func):
"""
Return a list of (argument name, default value) tuples. If the argument
does not have a default value, omit it in the tuple. Arguments such as
*args and **kwargs are also included.
"""
if six.PY2:
argspec = inspect.getargspec(func)
args = argspec... | [
"def",
"get_func_full_args",
"(",
"func",
")",
":",
"if",
"six",
".",
"PY2",
":",
"argspec",
"=",
"inspect",
".",
"getargspec",
"(",
"func",
")",
"args",
"=",
"argspec",
".",
"args",
"[",
"1",
":",
"]",
"# ignore 'self'",
"defaults",
"=",
"argspec",
".... | [
45,
0
] | [
80,
15
] | python | en | ['en', 'error', 'th'] | False |
func_accepts_var_args | (func) |
Return True if function 'func' accepts positional arguments *args.
|
Return True if function 'func' accepts positional arguments *args.
| def func_accepts_var_args(func):
"""
Return True if function 'func' accepts positional arguments *args.
"""
if six.PY2:
return inspect.getargspec(func)[1] is not None
return any(
p for p in inspect.signature(func).parameters.values()
if p.kind == p.VAR_POSITIONAL
) | [
"def",
"func_accepts_var_args",
"(",
"func",
")",
":",
"if",
"six",
".",
"PY2",
":",
"return",
"inspect",
".",
"getargspec",
"(",
"func",
")",
"[",
"1",
"]",
"is",
"not",
"None",
"return",
"any",
"(",
"p",
"for",
"p",
"in",
"inspect",
".",
"signature... | [
104,
0
] | [
114,
5
] | python | en | ['en', 'error', 'th'] | False |
TestCLI.test_unicode_logging | (self) | check whether unicode symbols are logged correctly into file | check whether unicode symbols are logged correctly into file | def test_unicode_logging(self):
""" check whether unicode symbols are logged correctly into file """
self.verbose = False
for handler in self.logger.handlers:
if isinstance(handler, logging.FileHandler):
handler.setLevel(logging.DEBUG)
u_symbol = b'\xe3\x81\xb... | [
"def",
"test_unicode_logging",
"(",
"self",
")",
":",
"self",
".",
"verbose",
"=",
"False",
"for",
"handler",
"in",
"self",
".",
"logger",
".",
"handlers",
":",
"if",
"isinstance",
"(",
"handler",
",",
"logging",
".",
"FileHandler",
")",
":",
"handler",
... | [
62,
4
] | [
75,
44
] | python | en | ['en', 'en', 'en'] | True |
set_topic_mutes | (
user_profile: UserProfile,
muted_topics: List[List[str]],
date_muted: Optional[datetime.datetime] = None,
) |
This is only used in tests.
|
This is only used in tests.
| def set_topic_mutes(
user_profile: UserProfile,
muted_topics: List[List[str]],
date_muted: Optional[datetime.datetime] = None,
) -> None:
"""
This is only used in tests.
"""
MutedTopic.objects.filter(
user_profile=user_profile,
).delete()
if date_muted is None:
date... | [
"def",
"set_topic_mutes",
"(",
"user_profile",
":",
"UserProfile",
",",
"muted_topics",
":",
"List",
"[",
"List",
"[",
"str",
"]",
"]",
",",
"date_muted",
":",
"Optional",
"[",
"datetime",
".",
"datetime",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
... | [
30,
0
] | [
55,
9
] | python | en | ['en', 'error', 'th'] | False |
FreshpingHookTests.test_freshping_check_test | (self) |
Tests if freshping check test is handled correctly
|
Tests if freshping check test is handled correctly
| def test_freshping_check_test(self) -> None:
"""
Tests if freshping check test is handled correctly
"""
expected_topic = "Freshping"
expected_message = "Freshping webhook has been successfully configured."
self.check_webhook("freshping_check_test", expected_topic, expecte... | [
"def",
"test_freshping_check_test",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Freshping\"",
"expected_message",
"=",
"\"Freshping webhook has been successfully configured.\"",
"self",
".",
"check_webhook",
"(",
"\"freshping_check_test\"",
",",
"expected_t... | [
8,
4
] | [
14,
84
] | python | en | ['en', 'error', 'th'] | False |
FreshpingHookTests.test_freshping_check_unreachable | (self) |
Tests if freshping check unreachable is handled correctly
|
Tests if freshping check unreachable is handled correctly
| def test_freshping_check_unreachable(self) -> None:
"""
Tests if freshping check unreachable is handled correctly
"""
expected_topic = "Test Check"
expected_message = """
https://example.com has just become unreachable.
Error code: 521.
""".strip()
self.check_webhook("fre... | [
"def",
"test_freshping_check_unreachable",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Test Check\"",
"expected_message",
"=",
"\"\"\"\nhttps://example.com has just become unreachable.\nError code: 521.\n\"\"\"",
".",
"strip",
"(",
")",
"self",
".",
"check_... | [
16,
4
] | [
25,
91
] | python | en | ['en', 'error', 'th'] | False |
FreshpingHookTests.test_freshping_check_reachable | (self) |
Tests if freshping check reachable is handled correctly
|
Tests if freshping check reachable is handled correctly
| def test_freshping_check_reachable(self) -> None:
"""
Tests if freshping check reachable is handled correctly
"""
expected_topic = "Test Check"
expected_message = "https://example.com is back up and no longer unreachable."
self.check_webhook("freshping_check_reachable", e... | [
"def",
"test_freshping_check_reachable",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Test Check\"",
"expected_message",
"=",
"\"https://example.com is back up and no longer unreachable.\"",
"self",
".",
"check_webhook",
"(",
"\"freshping_check_reachable\"",
"... | [
27,
4
] | [
33,
89
] | python | en | ['en', 'error', 'th'] | False |
convertPrintParameterToInches | (parameter: Union[None, int, float, str]
) | Convert print parameter to inches. | Convert print parameter to inches. | def convertPrintParameterToInches(parameter: Union[None, int, float, str]
) -> Optional[float]:
"""Convert print parameter to inches."""
if parameter is None:
return None
if isinstance(parameter, (int, float)):
pixels = parameter
elif isinstance(paramete... | [
"def",
"convertPrintParameterToInches",
"(",
"parameter",
":",
"Union",
"[",
"None",
",",
"int",
",",
"float",
",",
"str",
"]",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"if",
"parameter",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"("... | [
1743,
0
] | [
1766,
22
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.