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
_init_pathinfo
()
Return a set containing all existing directory entries from sys.path
Return a set containing all existing directory entries from sys.path
def _init_pathinfo(): """Return a set containing all existing directory entries from sys.path""" d = set() for dir in sys.path: try: if os.path.isdir(dir): dir, dircase = makepath(dir) d.add(dircase) except TypeError: continue retur...
[ "def", "_init_pathinfo", "(", ")", ":", "d", "=", "set", "(", ")", "for", "dir", "in", "sys", ".", "path", ":", "try", ":", "if", "os", ".", "path", ".", "isdir", "(", "dir", ")", ":", "dir", ",", "dircase", "=", "makepath", "(", "dir", ")", ...
[ 138, 0 ]
[ 148, 12 ]
python
en
['en', 'en', 'en']
True
addpackage
(sitedir, name, known_paths)
Add a new path to known_paths by combining sitedir and 'name' or execute sitedir if it starts with 'import
Add a new path to known_paths by combining sitedir and 'name' or execute sitedir if it starts with 'import
def addpackage(sitedir, name, known_paths): """Add a new path to known_paths by combining sitedir and 'name' or execute sitedir if it starts with 'import'""" if known_paths is None: _init_pathinfo() reset = 1 else: reset = 0 fullname = os.path.join(sitedir, name) try: ...
[ "def", "addpackage", "(", "sitedir", ",", "name", ",", "known_paths", ")", ":", "if", "known_paths", "is", "None", ":", "_init_pathinfo", "(", ")", "reset", "=", "1", "else", ":", "reset", "=", "0", "fullname", "=", "os", ".", "path", ".", "join", "(...
[ 151, 0 ]
[ 180, 22 ]
python
en
['en', 'en', 'en']
True
addsitedir
(sitedir, known_paths=None)
Add 'sitedir' argument to sys.path if missing and handle .pth files in 'sitedir
Add 'sitedir' argument to sys.path if missing and handle .pth files in 'sitedir
def addsitedir(sitedir, known_paths=None): """Add 'sitedir' argument to sys.path if missing and handle .pth files in 'sitedir'""" if known_paths is None: known_paths = _init_pathinfo() reset = 1 else: reset = 0 sitedir, sitedircase = makepath(sitedir) if not sitedircase i...
[ "def", "addsitedir", "(", "sitedir", ",", "known_paths", "=", "None", ")", ":", "if", "known_paths", "is", "None", ":", "known_paths", "=", "_init_pathinfo", "(", ")", "reset", "=", "1", "else", ":", "reset", "=", "0", "sitedir", ",", "sitedircase", "=",...
[ 183, 0 ]
[ 204, 22 ]
python
en
['en', 'en', 'en']
True
addsitepackages
(known_paths, sys_prefix=sys.prefix, exec_prefix=sys.exec_prefix)
Add site-packages (and possibly site-python) to sys.path
Add site-packages (and possibly site-python) to sys.path
def addsitepackages(known_paths, sys_prefix=sys.prefix, exec_prefix=sys.exec_prefix): """Add site-packages (and possibly site-python) to sys.path""" prefixes = [os.path.join(sys_prefix, "local"), sys_prefix] if exec_prefix != sys_prefix: prefixes.append(os.path.join(exec_prefix, "local")) for p...
[ "def", "addsitepackages", "(", "known_paths", ",", "sys_prefix", "=", "sys", ".", "prefix", ",", "exec_prefix", "=", "sys", ".", "exec_prefix", ")", ":", "prefixes", "=", "[", "os", ".", "path", ".", "join", "(", "sys_prefix", ",", "\"local\"", ")", ",",...
[ 207, 0 ]
[ 271, 15 ]
python
en
['en', 'en', 'en']
True
check_enableusersite
()
Check if user site directory is safe for inclusion The function tests for the command line flag (including environment var), process uid/gid equal to effective uid/gid. None: Disabled for security reasons False: Disabled by user (command line option) True: Safe and enabled
Check if user site directory is safe for inclusion
def check_enableusersite(): """Check if user site directory is safe for inclusion The function tests for the command line flag (including environment var), process uid/gid equal to effective uid/gid. None: Disabled for security reasons False: Disabled by user (command line option) True: Safe a...
[ "def", "check_enableusersite", "(", ")", ":", "if", "hasattr", "(", "sys", ",", "\"flags\"", ")", "and", "getattr", "(", "sys", ".", "flags", ",", "\"no_user_site\"", ",", "False", ")", ":", "return", "False", "if", "hasattr", "(", "os", ",", "\"getuid\"...
[ 274, 0 ]
[ 296, 15 ]
python
en
['en', 'en', 'en']
True
addusersitepackages
(known_paths)
Add a per user site-package to sys.path Each user has its own python directory with site-packages in the home directory. USER_BASE is the root directory for all Python versions USER_SITE is the user specific site-packages directory USER_SITE/.. can be used for data.
Add a per user site-package to sys.path
def addusersitepackages(known_paths): """Add a per user site-package to sys.path Each user has its own python directory with site-packages in the home directory. USER_BASE is the root directory for all Python versions USER_SITE is the user specific site-packages directory USER_SITE/.. can be...
[ "def", "addusersitepackages", "(", "known_paths", ")", ":", "global", "USER_BASE", ",", "USER_SITE", ",", "ENABLE_USER_SITE", "env_base", "=", "os", ".", "environ", ".", "get", "(", "\"PYTHONUSERBASE\"", ",", "None", ")", "def", "joinuser", "(", "*", "args", ...
[ 299, 0 ]
[ 342, 22 ]
python
en
['en', 'en', 'it']
True
setBEGINLIBPATH
()
The OS/2 EMX port has optional extension modules that do double duty as DLLs (and must use the .DLL file extension) for other extensions. The library search path needs to be amended so these will be found during module import. Use BEGINLIBPATH so that these are at the start of the library search path. ...
The OS/2 EMX port has optional extension modules that do double duty as DLLs (and must use the .DLL file extension) for other extensions. The library search path needs to be amended so these will be found during module import. Use BEGINLIBPATH so that these are at the start of the library search path.
def setBEGINLIBPATH(): """The OS/2 EMX port has optional extension modules that do double duty as DLLs (and must use the .DLL file extension) for other extensions. The library search path needs to be amended so these will be found during module import. Use BEGINLIBPATH so that these are at the start ...
[ "def", "setBEGINLIBPATH", "(", ")", ":", "dllpath", "=", "os", ".", "path", ".", "join", "(", "sys", ".", "prefix", ",", "\"Lib\"", ",", "\"lib-dynload\"", ")", "libpath", "=", "os", ".", "environ", "[", "\"BEGINLIBPATH\"", "]", ".", "split", "(", "\";...
[ 345, 0 ]
[ 359, 50 ]
python
en
['en', 'en', 'en']
True
setquit
()
Define new built-ins 'quit' and 'exit'. These are simply strings that display a hint on how to exit.
Define new built-ins 'quit' and 'exit'. These are simply strings that display a hint on how to exit.
def setquit(): """Define new built-ins 'quit' and 'exit'. These are simply strings that display a hint on how to exit. """ if os.sep == ":": eof = "Cmd-Q" elif os.sep == "\\": eof = "Ctrl-Z plus Return" else: eof = "Ctrl-D (i.e. EOF)" class Quitter(object): ...
[ "def", "setquit", "(", ")", ":", "if", "os", ".", "sep", "==", "\":\"", ":", "eof", "=", "\"Cmd-Q\"", "elif", "os", ".", "sep", "==", "\"\\\\\"", ":", "eof", "=", "\"Ctrl-Z plus Return\"", "else", ":", "eof", "=", "\"Ctrl-D (i.e. EOF)\"", "class", "Quitt...
[ 362, 0 ]
[ 391, 35 ]
python
en
['en', 'en', 'en']
True
setcopyright
()
Set 'copyright' and 'credits' in __builtin__
Set 'copyright' and 'credits' in __builtin__
def setcopyright(): """Set 'copyright' and 'credits' in __builtin__""" builtins.copyright = _Printer("copyright", sys.copyright) if _is_pypy: builtins.credits = _Printer("credits", "PyPy is maintained by the PyPy developers: http://pypy.org/") else: builtins.credits = _Printer( ...
[ "def", "setcopyright", "(", ")", ":", "builtins", ".", "copyright", "=", "_Printer", "(", "\"copyright\"", ",", "sys", ".", "copyright", ")", "if", "_is_pypy", ":", "builtins", ".", "credits", "=", "_Printer", "(", "\"credits\"", ",", "\"PyPy is maintained by ...
[ 459, 0 ]
[ 477, 5 ]
python
en
['en', 'en', 'en']
True
aliasmbcs
()
On Windows, some default encodings are not provided by Python, while they are always available as "mbcs" in each locale. Make them usable by aliasing to "mbcs" in such a case.
On Windows, some default encodings are not provided by Python, while they are always available as "mbcs" in each locale. Make them usable by aliasing to "mbcs" in such a case.
def aliasmbcs(): """On Windows, some default encodings are not provided by Python, while they are always available as "mbcs" in each locale. Make them usable by aliasing to "mbcs" in such a case.""" if sys.platform == "win32": import locale, codecs enc = locale.getdefaultlocale()[1] ...
[ "def", "aliasmbcs", "(", ")", ":", "if", "sys", ".", "platform", "==", "\"win32\"", ":", "import", "locale", ",", "codecs", "enc", "=", "locale", ".", "getdefaultlocale", "(", ")", "[", "1", "]", "if", "enc", ".", "startswith", "(", "\"cp\"", ")", ":...
[ 499, 0 ]
[ 514, 55 ]
python
en
['en', 'en', 'en']
True
setencoding
()
Set the string encoding used by the Unicode implementation. The default is 'ascii', but if you're willing to experiment, you can change this.
Set the string encoding used by the Unicode implementation. The default is 'ascii', but if you're willing to experiment, you can change this.
def setencoding(): """Set the string encoding used by the Unicode implementation. The default is 'ascii', but if you're willing to experiment, you can change this.""" encoding = "ascii" # Default value set by _PyUnicode_Init() if 0: # Enable to support locale aware default string encodings...
[ "def", "setencoding", "(", ")", ":", "encoding", "=", "\"ascii\"", "# Default value set by _PyUnicode_Init()", "if", "0", ":", "# Enable to support locale aware default string encodings.", "import", "locale", "loc", "=", "locale", ".", "getdefaultlocale", "(", ")", "if", ...
[ 517, 0 ]
[ 535, 40 ]
python
en
['en', 'en', 'en']
True
execsitecustomize
()
Run custom site specific code, if available.
Run custom site specific code, if available.
def execsitecustomize(): """Run custom site specific code, if available.""" try: import sitecustomize except ImportError: pass
[ "def", "execsitecustomize", "(", ")", ":", "try", ":", "import", "sitecustomize", "except", "ImportError", ":", "pass" ]
[ 538, 0 ]
[ 543, 12 ]
python
en
['en', 'en', 'en']
True
force_global_eggs_after_local_site_packages
()
Force easy_installed eggs in the global environment to get placed in sys.path after all packages inside the virtualenv. This maintains the "least surprise" result that packages in the virtualenv always mask global packages, never the other way around.
Force easy_installed eggs in the global environment to get placed in sys.path after all packages inside the virtualenv. This maintains the "least surprise" result that packages in the virtualenv always mask global packages, never the other way around.
def force_global_eggs_after_local_site_packages(): """ Force easy_installed eggs in the global environment to get placed in sys.path after all packages inside the virtualenv. This maintains the "least surprise" result that packages in the virtualenv always mask global packages, never the other way ...
[ "def", "force_global_eggs_after_local_site_packages", "(", ")", ":", "egginsert", "=", "getattr", "(", "sys", ",", "\"__egginsert\"", ",", "0", ")", "for", "i", ",", "path", "in", "enumerate", "(", "sys", ".", "path", ")", ":", "if", "i", ">", "egginsert",...
[ 618, 0 ]
[ 631, 35 ]
python
en
['en', 'error', 'th']
False
execusercustomize
()
Run custom user specific code, if available.
Run custom user specific code, if available.
def execusercustomize(): """Run custom user specific code, if available.""" try: import usercustomize except ImportError: pass
[ "def", "execusercustomize", "(", ")", ":", "try", ":", "import", "usercustomize", "except", "ImportError", ":", "pass" ]
[ 639, 0 ]
[ 644, 12 ]
python
en
['en', 'en', 'en']
True
enablerlcompleter
()
Enable default readline configuration on interactive prompts, by registering a sys.__interactivehook__. If the readline module can be imported, the hook will set the Tab key as completion key and register ~/.python_history as history file. This can be overridden in the sitecustomize or usercustomize mod...
Enable default readline configuration on interactive prompts, by registering a sys.__interactivehook__. If the readline module can be imported, the hook will set the Tab key as completion key and register ~/.python_history as history file. This can be overridden in the sitecustomize or usercustomize mod...
def enablerlcompleter(): """Enable default readline configuration on interactive prompts, by registering a sys.__interactivehook__. If the readline module can be imported, the hook will set the Tab key as completion key and register ~/.python_history as history file. This can be overridden in the si...
[ "def", "enablerlcompleter", "(", ")", ":", "def", "register_readline", "(", ")", ":", "import", "atexit", "try", ":", "import", "readline", "import", "rlcompleter", "except", "ImportError", ":", "return", "# Reading the initialization (config) file may not be enough to se...
[ 647, 0 ]
[ 704, 47 ]
python
en
['fr', 'en', 'en']
True
check_requires_python
(requires_python, version_info)
Check if the given Python version matches a "Requires-Python" specifier. :param version_info: A 3-tuple of ints representing a Python major-minor-micro version to check (e.g. `sys.version_info[:3]`). :return: `True` if the given Python version satisfies the requirement. Otherwise, return ...
Check if the given Python version matches a "Requires-Python" specifier.
def check_requires_python(requires_python, version_info): # type: (Optional[str], Tuple[int, ...]) -> bool """ Check if the given Python version matches a "Requires-Python" specifier. :param version_info: A 3-tuple of ints representing a Python major-minor-micro version to check (e.g. `sys.vers...
[ "def", "check_requires_python", "(", "requires_python", ",", "version_info", ")", ":", "# type: (Optional[str], Tuple[int, ...]) -> bool", "if", "requires_python", "is", "None", ":", "# The package provides no information", "return", "True", "requires_python_specifier", "=", "s...
[ 21, 0 ]
[ 40, 54 ]
python
en
['en', 'error', 'th']
False
get_metadata
(dist)
:raises NoneMetadataError: if the distribution reports `has_metadata()` True but `get_metadata()` returns None.
:raises NoneMetadataError: if the distribution reports `has_metadata()` True but `get_metadata()` returns None.
def get_metadata(dist): # type: (Distribution) -> Message """ :raises NoneMetadataError: if the distribution reports `has_metadata()` True but `get_metadata()` returns None. """ metadata_name = 'METADATA' if (isinstance(dist, pkg_resources.DistInfoDistribution) and dist.has_m...
[ "def", "get_metadata", "(", "dist", ")", ":", "# type: (Distribution) -> Message", "metadata_name", "=", "'METADATA'", "if", "(", "isinstance", "(", "dist", ",", "pkg_resources", ".", "DistInfoDistribution", ")", "and", "dist", ".", "has_metadata", "(", "metadata_na...
[ 43, 0 ]
[ 67, 30 ]
python
en
['en', 'error', 'th']
False
get_requires_python
(dist)
Return the "Requires-Python" metadata for a distribution, or None if not present.
Return the "Requires-Python" metadata for a distribution, or None if not present.
def get_requires_python(dist): # type: (pkg_resources.Distribution) -> Optional[str] """ Return the "Requires-Python" metadata for a distribution, or None if not present. """ pkg_info_dict = get_metadata(dist) requires_python = pkg_info_dict.get('Requires-Python') if requires_python is ...
[ "def", "get_requires_python", "(", "dist", ")", ":", "# type: (pkg_resources.Distribution) -> Optional[str]", "pkg_info_dict", "=", "get_metadata", "(", "dist", ")", "requires_python", "=", "pkg_info_dict", ".", "get", "(", "'Requires-Python'", ")", "if", "requires_python...
[ 70, 0 ]
[ 84, 26 ]
python
en
['en', 'error', 'th']
False
AbstractProvider.identify
(self, dependency)
Given a dependency, return an identifier for it. This is used in many places to identify the dependency, e.g. whether two requirements should have their specifier parts merged, whether two specifications would conflict with each other (because they the same name but different versions)....
Given a dependency, return an identifier for it.
def identify(self, dependency): """Given a dependency, return an identifier for it. This is used in many places to identify the dependency, e.g. whether two requirements should have their specifier parts merged, whether two specifications would conflict with each other (because they the...
[ "def", "identify", "(", "self", ",", "dependency", ")", ":", "raise", "NotImplementedError" ]
[ 4, 4 ]
[ 12, 33 ]
python
en
['en', 'en', 'en']
True
AbstractProvider.get_preference
(self, resolution, candidates, information)
Produce a sort key for given specification based on preference. The preference is defined as "I think this requirement should be resolved first". The lower the return value is, the more preferred this group of arguments is. :param resolution: Currently pinned candidate, or `None`. ...
Produce a sort key for given specification based on preference.
def get_preference(self, resolution, candidates, information): """Produce a sort key for given specification based on preference. The preference is defined as "I think this requirement should be resolved first". The lower the return value is, the more preferred this group of arguments i...
[ "def", "get_preference", "(", "self", ",", "resolution", ",", "candidates", ",", "information", ")", ":", "raise", "NotImplementedError" ]
[ 14, 4 ]
[ 48, 33 ]
python
en
['en', 'en', 'en']
True
AbstractProvider.find_matches
(self, requirements)
Find all possible candidates that satisfy the given requirements. This should try to get candidates based on the requirements' types. For VCS, local, and archive requirements, the one-and-only match is returned, and for a "named" requirement, the index(es) should be consulted to find co...
Find all possible candidates that satisfy the given requirements.
def find_matches(self, requirements): """Find all possible candidates that satisfy the given requirements. This should try to get candidates based on the requirements' types. For VCS, local, and archive requirements, the one-and-only match is returned, and for a "named" requirement, the...
[ "def", "find_matches", "(", "self", ",", "requirements", ")", ":", "raise", "NotImplementedError" ]
[ 50, 4 ]
[ 64, 33 ]
python
en
['en', 'en', 'en']
True
AbstractProvider.is_satisfied_by
(self, requirement, candidate)
Whether the given requirement can be satisfied by a candidate. The candidate is guarenteed to have been generated from the requirement. A boolean should be returned to indicate whether `candidate` is a viable solution to the requirement.
Whether the given requirement can be satisfied by a candidate.
def is_satisfied_by(self, requirement, candidate): """Whether the given requirement can be satisfied by a candidate. The candidate is guarenteed to have been generated from the requirement. A boolean should be returned to indicate whether `candidate` is a viable solution to the...
[ "def", "is_satisfied_by", "(", "self", ",", "requirement", ",", "candidate", ")", ":", "raise", "NotImplementedError" ]
[ 66, 4 ]
[ 75, 33 ]
python
en
['en', 'en', 'en']
True
AbstractProvider.get_dependencies
(self, candidate)
Get dependencies of a candidate. This should return a collection of requirements that `candidate` specifies as its dependencies.
Get dependencies of a candidate.
def get_dependencies(self, candidate): """Get dependencies of a candidate. This should return a collection of requirements that `candidate` specifies as its dependencies. """ raise NotImplementedError
[ "def", "get_dependencies", "(", "self", ",", "candidate", ")", ":", "raise", "NotImplementedError" ]
[ 77, 4 ]
[ 83, 33 ]
python
en
['en', 'en', 'en']
True
AbstractResolver.resolve
(self, requirements, **kwargs)
Take a collection of constraints, spit out the resolution result. This returns a representation of the final resolution state, with one guarenteed attribute ``mapping`` that contains resolved candidates as values. The keys are their respective identifiers. :param requirements: A collec...
Take a collection of constraints, spit out the resolution result.
def resolve(self, requirements, **kwargs): """Take a collection of constraints, spit out the resolution result. This returns a representation of the final resolution state, with one guarenteed attribute ``mapping`` that contains resolved candidates as values. The keys are their respecti...
[ "def", "resolve", "(", "self", ",", "requirements", ",", "*", "*", "kwargs", ")", ":", "raise", "NotImplementedError" ]
[ 96, 4 ]
[ 108, 33 ]
python
en
['en', 'en', 'en']
True
user_home
(request)
Reversible named view to direct a user to the appropriate homepage.
Reversible named view to direct a user to the appropriate homepage.
def user_home(request): """Reversible named view to direct a user to the appropriate homepage.""" return shortcuts.redirect(horizon.get_user_home(request.user))
[ "def", "user_home", "(", "request", ")", ":", "return", "shortcuts", ".", "redirect", "(", "horizon", ".", "get_user_home", "(", "request", ".", "user", ")", ")" ]
[ 93, 0 ]
[ 95, 66 ]
python
en
['en', 'en', 'en']
True
PageTitleMixin.render_context_with_title
(self, context)
Render a page title and insert it into the context. This function takes in a context dict and uses it to render the page_title variable. It then appends this title to the context using the 'page_title' key. If there is already a page_title key defined in context received then this funct...
Render a page title and insert it into the context.
def render_context_with_title(self, context): """Render a page title and insert it into the context. This function takes in a context dict and uses it to render the page_title variable. It then appends this title to the context using the 'page_title' key. If there is already a page_titl...
[ "def", "render_context_with_title", "(", "self", ",", "context", ")", ":", "if", "\"page_title\"", "not", "in", "context", ":", "con", "=", "template", ".", "Context", "(", "context", ")", "# NOTE(sambetts): Use force_text to ensure lazy translations", "# are handled co...
[ 44, 4 ]
[ 59, 22 ]
python
en
['en', 'en', 'en']
True
PageTitleMixin.render_to_response
(self, context)
render_to_response() with a page title. This is an override of the default render_to_response function that exists in the django generic views. This is here to inject the page title into the context before the main template is rendered.
render_to_response() with a page title.
def render_to_response(self, context): """render_to_response() with a page title. This is an override of the default render_to_response function that exists in the django generic views. This is here to inject the page title into the context before the main template is rendered. ...
[ "def", "render_to_response", "(", "self", ",", "context", ")", ":", "context", "=", "self", ".", "render_context_with_title", "(", "context", ")", "return", "super", "(", "PageTitleMixin", ",", "self", ")", ".", "render_to_response", "(", "context", ")" ]
[ 61, 4 ]
[ 70, 70 ]
python
en
['en', 'en', 'en']
True
APIView.get_data
(self, request, context, *args, **kwargs)
Load necessary API data into the context. This method should handle any necessary API calls, update the context object, and return the context object at the end.
Load necessary API data into the context.
def get_data(self, request, context, *args, **kwargs): """Load necessary API data into the context. This method should handle any necessary API calls, update the context object, and return the context object at the end. """ return context
[ "def", "get_data", "(", "self", ",", "request", ",", "context", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "context" ]
[ 109, 4 ]
[ 115, 22 ]
python
en
['en', 'mg', 'en']
True
Action.get_param_name
(self)
Returns the full POST parameter name for this action. Defaults to ``{{ table.name }}__{{ action.name }}``.
Returns the full POST parameter name for this action.
def get_param_name(self): """Returns the full POST parameter name for this action. Defaults to ``{{ table.name }}__{{ action.name }}``. """ return "__".join([self.table.name, self.name])
[ "def", "get_param_name", "(", "self", ")", ":", "return", "\"__\"", ".", "join", "(", "[", "self", ".", "table", ".", "name", ",", "self", ".", "name", "]", ")" ]
[ 307, 4 ]
[ 313, 54 ]
python
en
['en', 'en', 'en']
True
LinkAction.get_link_url
(self, datum=None)
Returns the final URL based on the value of ``url``. If ``url`` is callable it will call the function. If not, it will then try to call ``reverse`` on ``url``. Failing that, it will simply return the value of ``url`` as-is. When called for a row action, the current row data object will...
Returns the final URL based on the value of ``url``.
def get_link_url(self, datum=None): """Returns the final URL based on the value of ``url``. If ``url`` is callable it will call the function. If not, it will then try to call ``reverse`` on ``url``. Failing that, it will simply return the value of ``url`` as-is. When called for...
[ "def", "get_link_url", "(", "self", ",", "datum", "=", "None", ")", ":", "if", "not", "self", ".", "url", ":", "raise", "NotImplementedError", "(", "'A LinkAction class must have a '", "'url attribute or define its own '", "'get_link_url method.'", ")", "if", "callabl...
[ 385, 4 ]
[ 410, 27 ]
python
en
['en', 'en', 'en']
True
FilterAction.get_param_name
(self)
Returns the full query parameter name for this action. Defaults to ``{{ table.name }}__{{ action.name }}__{{ action.param_name }}``.
Returns the full query parameter name for this action.
def get_param_name(self): """Returns the full query parameter name for this action. Defaults to ``{{ table.name }}__{{ action.name }}__{{ action.param_name }}``. """ return "__".join([self.table.name, self.name, self.param_name])
[ "def", "get_param_name", "(", "self", ")", ":", "return", "\"__\"", ".", "join", "(", "[", "self", ".", "table", ".", "name", ",", "self", ".", "name", ",", "self", ".", "param_name", "]", ")" ]
[ 489, 4 ]
[ 495, 71 ]
python
en
['en', 'en', 'en']
True
FilterAction.filter
(self, table, data, filter_string)
Provides the actual filtering logic. This method must be overridden by subclasses and return the filtered data.
Provides the actual filtering logic.
def filter(self, table, data, filter_string): """Provides the actual filtering logic. This method must be overridden by subclasses and return the filtered data. """ return data
[ "def", "filter", "(", "self", ",", "table", ",", "data", ",", "filter_string", ")", ":", "return", "data" ]
[ 523, 4 ]
[ 529, 19 ]
python
en
['en', 'en', 'en']
True
FilterAction.is_api_filter
(self, filter_field)
Determine if agiven filter field should be used as an API filter.
Determine if agiven filter field should be used as an API filter.
def is_api_filter(self, filter_field): """Determine if agiven filter field should be used as an API filter.""" if self.filter_type == 'server': for choice in self.filter_choices: if (choice[0] == filter_field and len(choice) > 2 and choice[2]): ...
[ "def", "is_api_filter", "(", "self", ",", "filter_field", ")", ":", "if", "self", ".", "filter_type", "==", "'server'", ":", "for", "choice", "in", "self", ".", "filter_choices", ":", "if", "(", "choice", "[", "0", "]", "==", "filter_field", "and", "len"...
[ 531, 4 ]
[ 538, 20 ]
python
en
['en', 'en', 'en']
True
FilterAction.get_select_options
(self)
Provide the value, string, and help_text for the template to render. help_text is returned if applicable.
Provide the value, string, and help_text for the template to render.
def get_select_options(self): """Provide the value, string, and help_text for the template to render. help_text is returned if applicable. """ if self.filter_choices: return [choice[:4] for choice in self.filter_choices # Display it If the fifth element i...
[ "def", "get_select_options", "(", "self", ")", ":", "if", "self", ".", "filter_choices", ":", "return", "[", "choice", "[", ":", "4", "]", "for", "choice", "in", "self", ".", "filter_choices", "# Display it If the fifth element is True or does not exist", "if", "l...
[ 540, 4 ]
[ 548, 52 ]
python
en
['en', 'en', 'en']
True
NameFilterAction.filter
(self, table, items, filter_string)
Naive case-insensitive search.
Naive case-insensitive search.
def filter(self, table, items, filter_string): """Naive case-insensitive search.""" query = filter_string.lower() return [item for item in items if query in item.name.lower()]
[ "def", "filter", "(", "self", ",", "table", ",", "items", ",", "filter_string", ")", ":", "query", "=", "filter_string", ".", "lower", "(", ")", "return", "[", "item", "for", "item", "in", "items", "if", "query", "in", "item", ".", "name", ".", "lowe...
[ 554, 4 ]
[ 558, 46 ]
python
en
['en', 'it', 'en']
True
FixedFilterAction.get_fixed_buttons
(self)
Returns a list of dict describing fixed buttons used for filtering. Each list item should be a dict with the following keys: * ``text``: Text to display on the button * ``icon``: Icon class for icon element (inserted before text). * ``value``: Value returned when the button is clicked....
Returns a list of dict describing fixed buttons used for filtering.
def get_fixed_buttons(self): """Returns a list of dict describing fixed buttons used for filtering. Each list item should be a dict with the following keys: * ``text``: Text to display on the button * ``icon``: Icon class for icon element (inserted before text). * ``value``: Va...
[ "def", "get_fixed_buttons", "(", "self", ")", ":", "return", "[", "]" ]
[ 582, 4 ]
[ 592, 17 ]
python
en
['en', 'en', 'en']
True
FixedFilterAction.categorize
(self, table, rows)
Override to separate rows into categories. To have filtering working properly on the client, each row will need CSS class(es) beginning with 'category-', followed by the value of the fixed button. Return a dict with a key for the value of each fixed button, and a value that is ...
Override to separate rows into categories.
def categorize(self, table, rows): """Override to separate rows into categories. To have filtering working properly on the client, each row will need CSS class(es) beginning with 'category-', followed by the value of the fixed button. Return a dict with a key for the value of e...
[ "def", "categorize", "(", "self", ",", "table", ",", "rows", ")", ":", "return", "{", "}" ]
[ 594, 4 ]
[ 604, 17 ]
python
en
['en', 'en', 'en']
True
BatchAction._get_action_name
(self, items=None, past=False)
Retreive action name based on the number of items and `past` flag. :param items: A list or tuple of items (or container with a __len__ method) to count the number of concerned items for which this method is called. When this method is called for a single item (b...
Retreive action name based on the number of items and `past` flag.
def _get_action_name(self, items=None, past=False): """Retreive action name based on the number of items and `past` flag. :param items: A list or tuple of items (or container with a __len__ method) to count the number of concerned items for which this method is call...
[ "def", "_get_action_name", "(", "self", ",", "items", "=", "None", ",", "past", "=", "False", ")", ":", "action_type", "=", "\"past\"", "if", "past", "else", "\"present\"", "if", "items", "is", "None", ":", "# Called without items parameter (by a single instance.)...
[ 694, 4 ]
[ 727, 21 ]
python
en
['en', 'en', 'en']
True
BatchAction.action
(self, request, datum_id)
Accepts a single object id and performs the specific action. This method is required. Return values are discarded, errors raised are caught and logged.
Accepts a single object id and performs the specific action.
def action(self, request, datum_id): """Accepts a single object id and performs the specific action. This method is required. Return values are discarded, errors raised are caught and logged. """
[ "def", "action", "(", "self", ",", "request", ",", "datum_id", ")", ":" ]
[ 729, 4 ]
[ 735, 11 ]
python
en
['en', 'en', 'en']
True
BatchAction.update
(self, request, datum)
Switches the action verbose name, if needed.
Switches the action verbose name, if needed.
def update(self, request, datum): """Switches the action verbose name, if needed.""" if getattr(self, 'action_present', False): self.verbose_name = self._get_action_name() self.verbose_name_plural = self._get_action_name('plural')
[ "def", "update", "(", "self", ",", "request", ",", "datum", ")", ":", "if", "getattr", "(", "self", ",", "'action_present'", ",", "False", ")", ":", "self", ".", "verbose_name", "=", "self", ".", "_get_action_name", "(", ")", "self", ".", "verbose_name_p...
[ 737, 4 ]
[ 741, 70 ]
python
en
['en', 'en', 'en']
True
BatchAction.get_success_url
(self, request=None)
Returns the URL to redirect to after a successful action.
Returns the URL to redirect to after a successful action.
def get_success_url(self, request=None): """Returns the URL to redirect to after a successful action.""" if self.success_url: return self.success_url return request.get_full_path()
[ "def", "get_success_url", "(", "self", ",", "request", "=", "None", ")", ":", "if", "self", ".", "success_url", ":", "return", "self", ".", "success_url", "return", "request", ".", "get_full_path", "(", ")" ]
[ 743, 4 ]
[ 747, 38 ]
python
en
['en', 'en', 'en']
True
BatchAction.get_default_attrs
(self)
Returns a list of the default HTML attributes for the action.
Returns a list of the default HTML attributes for the action.
def get_default_attrs(self): """Returns a list of the default HTML attributes for the action.""" attrs = super(BatchAction, self).get_default_attrs() attrs.update({'data-batch-action': 'true'}) return attrs
[ "def", "get_default_attrs", "(", "self", ")", ":", "attrs", "=", "super", "(", "BatchAction", ",", "self", ")", ".", "get_default_attrs", "(", ")", "attrs", ".", "update", "(", "{", "'data-batch-action'", ":", "'true'", "}", ")", "return", "attrs" ]
[ 749, 4 ]
[ 753, 20 ]
python
en
['en', 'en', 'en']
True
DeleteAction.action
(self, request, obj_id)
Action entry point. Overrides base class' action method. Accepts a single object id passing it over to the delete method responsible for the object's destruction.
Action entry point. Overrides base class' action method.
def action(self, request, obj_id): """Action entry point. Overrides base class' action method. Accepts a single object id passing it over to the delete method responsible for the object's destruction. """ return self.delete(request, obj_id)
[ "def", "action", "(", "self", ",", "request", ",", "obj_id", ")", ":", "return", "self", ".", "delete", "(", "request", ",", "obj_id", ")" ]
[ 879, 4 ]
[ 885, 43 ]
python
en
['en', 'en', 'en']
True
DeleteAction.delete
(self, request, obj_id)
Required. Deletes an object referenced by obj_id. Override to provide delete functionality specific to your data.
Required. Deletes an object referenced by obj_id.
def delete(self, request, obj_id): """Required. Deletes an object referenced by obj_id. Override to provide delete functionality specific to your data. """
[ "def", "delete", "(", "self", ",", "request", ",", "obj_id", ")", ":" ]
[ 887, 4 ]
[ 891, 11 ]
python
en
['en', 'en', 'en']
True
ajax
(authenticated=True, data_required=False, json_encoder=json.JSONEncoder)
Decorator to allow the wrappered view to exist in an AJAX environment. Provide a decorator to wrap a view method so that it may exist in an entirely AJAX environment: - data decoded from JSON as input and data coded as JSON as output - result status is coded in the HTTP status code; any non-2xx respon...
Decorator to allow the wrappered view to exist in an AJAX environment.
def ajax(authenticated=True, data_required=False, json_encoder=json.JSONEncoder): """Decorator to allow the wrappered view to exist in an AJAX environment. Provide a decorator to wrap a view method so that it may exist in an entirely AJAX environment: - data decoded from JSON as input and dat...
[ "def", "ajax", "(", "authenticated", "=", "True", ",", "data_required", "=", "False", ",", "json_encoder", "=", "json", ".", "JSONEncoder", ")", ":", "def", "decorator", "(", "function", ",", "authenticated", "=", "authenticated", ",", "data_required", "=", ...
[ 75, 0 ]
[ 148, 20 ]
python
en
['en', 'en', 'en']
True
parse_filters_kwargs
(request, client_keywords=None)
Extract REST filter parameters from the request GET args. Client processes some keywords separately from filters and takes them as separate inputs. This will ignore those keys to avoid potential conflicts.
Extract REST filter parameters from the request GET args.
def parse_filters_kwargs(request, client_keywords=None): """Extract REST filter parameters from the request GET args. Client processes some keywords separately from filters and takes them as separate inputs. This will ignore those keys to avoid potential conflicts. """ filters = {} kwargs =...
[ "def", "parse_filters_kwargs", "(", "request", ",", "client_keywords", "=", "None", ")", ":", "filters", "=", "{", "}", "kwargs", "=", "{", "}", "client_keywords", "=", "client_keywords", "or", "{", "}", "for", "param", "in", "request", ".", "GET", ":", ...
[ 158, 0 ]
[ 174, 26 ]
python
en
['en', 'en', 'en']
True
post2data
(func)
Decorator to restore original form values along with their types. The sole purpose of this decorator is to restore original form values along with their types stored on client-side under key $$originalJSON. This in turn prevents the loss of field types when they are passed with header 'Content-Type: mu...
Decorator to restore original form values along with their types.
def post2data(func): """Decorator to restore original form values along with their types. The sole purpose of this decorator is to restore original form values along with their types stored on client-side under key $$originalJSON. This in turn prevents the loss of field types when they are passed with ...
[ "def", "post2data", "(", "func", ")", ":", "def", "wrapper", "(", "self", ",", "request", ")", ":", "request", ".", "DATA", "=", "request", ".", "POST", "if", "'$$originalJSON'", "in", "request", ".", "POST", ":", "request", ".", "DATA", "=", "jsonutil...
[ 177, 0 ]
[ 193, 18 ]
python
en
['en', 'en', 'en']
True
ConcreteCache.start_caching
(self)
Turns on caching.
Turns on caching.
def start_caching(self): """Turns on caching. """ self._should_cache = True
[ "def", "start_caching", "(", "self", ")", ":", "self", ".", "_should_cache", "=", "True" ]
[ 20, 4 ]
[ 23, 33 ]
python
en
['en', 'en', 'en']
True
ConcreteCache.stop_caching
(self)
Turns off caching.
Turns off caching.
def stop_caching(self): """Turns off caching. """ self._should_cache = False
[ "def", "stop_caching", "(", "self", ")", ":", "self", ".", "_should_cache", "=", "False" ]
[ 24, 4 ]
[ 27, 34 ]
python
en
['en', 'en', 'en']
True
ConcreteCache.cache_size
(self)
Returns the size of the cache.
Returns the size of the cache.
def cache_size(self): """Returns the size of the cache. """ return len(self.cache)
[ "def", "cache_size", "(", "self", ")", ":", "return", "len", "(", "self", ".", "cache", ")" ]
[ 28, 4 ]
[ 31, 30 ]
python
en
['en', 'en', 'en']
True
ConcreteCache.get_cache_key
(self, ctxt, val, pathvars)
Makes a cache key string by hashing the state of the context, value, and path variables involved in the concretization. :param ctxt: Output channel (viewer). :type ctxt: T, where policies have type T -> bool :param val: Value to concretize. :type v: FExpr :param pathvars...
Makes a cache key string by hashing the state of the context, value, and path variables involved in the concretization.
def get_cache_key(self, ctxt, val, pathvars): """Makes a cache key string by hashing the state of the context, value, and path variables involved in the concretization. :param ctxt: Output channel (viewer). :type ctxt: T, where policies have type T -> bool :param val: Value to c...
[ "def", "get_cache_key", "(", "self", ",", "ctxt", ",", "val", ",", "pathvars", ")", ":", "if", "self", ".", "_should_cache", ":", "return", "str", "(", "hash", "(", "pickle", ".", "dumps", "(", "ctxt", ")", ")", ")", "+", "\"__\"", "+", "str", "(",...
[ 33, 4 ]
[ 51, 21 ]
python
en
['en', 'en', 'en']
True
ConcreteCache.cache_value
(self, cache_key, cache_value)
Caches the value if caching is turned on. :param cache_key: Caching key. :type cache_key: String. :returns: Whether caching occurred.
Caches the value if caching is turned on.
def cache_value(self, cache_key, cache_value): """Caches the value if caching is turned on. :param cache_key: Caching key. :type cache_key: String. :returns: Whether caching occurred. """ if self._should_cache: self._cache[cache_key] = cache_value ...
[ "def", "cache_value", "(", "self", ",", "cache_key", ",", "cache_value", ")", ":", "if", "self", ".", "_should_cache", ":", "self", ".", "_cache", "[", "cache_key", "]", "=", "cache_value", "return", "True", "else", ":", "return", "False" ]
[ 53, 4 ]
[ 64, 24 ]
python
en
['en', 'en', 'en']
True
ConcreteCache.cache_lookup
(self, cache_key)
Looks up the value in the cache. :param cache_key: Caching key. :type cache_key: String. :returns: The concrete (non-faceted) version of T under the policies in the environment.
Looks up the value in the cache. :param cache_key: Caching key. :type cache_key: String. :returns: The concrete (non-faceted) version of T under the policies in the environment.
def cache_lookup(self, cache_key): """Looks up the value in the cache. :param cache_key: Caching key. :type cache_key: String. :returns: The concrete (non-faceted) version of T under the policies in the environment. """ if self._should_cache: ...
[ "def", "cache_lookup", "(", "self", ",", "cache_key", ")", ":", "if", "self", ".", "_should_cache", ":", "try", ":", "return", "self", ".", "_cache", "[", "cache_key", "]", "except", "KeyError", ":", "return", "None", "return", "None" ]
[ 65, 4 ]
[ 78, 19 ]
python
en
['en', 'en', 'en']
True
ConcreteCache.clear_cache
(self)
Clears the cache of concrete values.
Clears the cache of concrete values.
def clear_cache(self): """Clears the cache of concrete values. """ self._cache = {}
[ "def", "clear_cache", "(", "self", ")", ":", "self", ".", "_cache", "=", "{", "}" ]
[ 80, 4 ]
[ 83, 24 ]
python
en
['en', 'en', 'en']
True
InterruptibleMixin.__init__
(self, *args, **kwargs)
Save the original SIGINT handler for later.
Save the original SIGINT handler for later.
def __init__(self, *args, **kwargs): # type: (List[Any], Dict[Any, Any]) -> None """ Save the original SIGINT handler for later. """ # https://github.com/python/mypy/issues/5887 super(InterruptibleMixin, self).__init__( # type: ignore *args, **kwa...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# type: (List[Any], Dict[Any, Any]) -> None", "# https://github.com/python/mypy/issues/5887", "super", "(", "InterruptibleMixin", ",", "self", ")", ".", "__init__", "(", "# type: ign...
[ 75, 4 ]
[ 94, 55 ]
python
en
['en', 'error', 'th']
False
InterruptibleMixin.finish
(self)
Restore the original SIGINT handler after finishing. This should happen regardless of whether the progress display finishes normally, or gets interrupted.
Restore the original SIGINT handler after finishing.
def finish(self): # type: () -> None """ Restore the original SIGINT handler after finishing. This should happen regardless of whether the progress display finishes normally, or gets interrupted. """ super(InterruptibleMixin, self).finish() # type: ignore ...
[ "def", "finish", "(", "self", ")", ":", "# type: () -> None", "super", "(", "InterruptibleMixin", ",", "self", ")", ".", "finish", "(", ")", "# type: ignore", "signal", "(", "SIGINT", ",", "self", ".", "original_handler", ")" ]
[ 96, 4 ]
[ 105, 45 ]
python
en
['en', 'error', 'th']
False
InterruptibleMixin.handle_sigint
(self, signum, frame)
Call self.finish() before delegating to the original SIGINT handler. This handler should only be in place while the progress display is active.
Call self.finish() before delegating to the original SIGINT handler.
def handle_sigint(self, signum, frame): # type: ignore """ Call self.finish() before delegating to the original SIGINT handler. This handler should only be in place while the progress display is active. """ self.finish() self.original_handler(signum, frame)
[ "def", "handle_sigint", "(", "self", ",", "signum", ",", "frame", ")", ":", "# type: ignore", "self", ".", "finish", "(", ")", "self", ".", "original_handler", "(", "signum", ",", "frame", ")" ]
[ 107, 4 ]
[ 115, 44 ]
python
en
['en', 'error', 'th']
False
get_build_version
()
Return the version of MSVC that was used to build Python. For Python 2.3 and up, the version number is included in sys.version. For earlier versions, assume the compiler is MSVC 6.
Return the version of MSVC that was used to build Python.
def get_build_version(): """Return the version of MSVC that was used to build Python. For Python 2.3 and up, the version number is included in sys.version. For earlier versions, assume the compiler is MSVC 6. """ prefix = "MSC v." i = sys.version.find(prefix) if i == -1: return 6 ...
[ "def", "get_build_version", "(", ")", ":", "prefix", "=", "\"MSC v.\"", "i", "=", "sys", ".", "version", ".", "find", "(", "prefix", ")", "if", "i", "==", "-", "1", ":", "return", "6", "i", "=", "i", "+", "len", "(", "prefix", ")", "s", ",", "r...
[ 166, 0 ]
[ 189, 15 ]
python
en
['en', 'en', 'en']
True
normalize_and_reduce_paths
(paths)
Return a list of normalized paths with duplicates removed. The current order of paths is maintained.
Return a list of normalized paths with duplicates removed.
def normalize_and_reduce_paths(paths): """Return a list of normalized paths with duplicates removed. The current order of paths is maintained. """ # Paths are normalized so things like: /a and /a/ aren't both preserved. reduced_paths = [] for p in paths: np = os.path.normpath(p) ...
[ "def", "normalize_and_reduce_paths", "(", "paths", ")", ":", "# Paths are normalized so things like: /a and /a/ aren't both preserved.", "reduced_paths", "=", "[", "]", "for", "p", "in", "paths", ":", "np", "=", "os", ".", "path", ".", "normpath", "(", "p", ")", ...
[ 191, 0 ]
[ 203, 24 ]
python
en
['en', 'en', 'en']
True
removeDuplicates
(variable)
Remove duplicate values of an environment variable.
Remove duplicate values of an environment variable.
def removeDuplicates(variable): """Remove duplicate values of an environment variable. """ oldList = variable.split(os.pathsep) newList = [] for i in oldList: if i not in newList: newList.append(i) newVariable = os.pathsep.join(newList) return newVariable
[ "def", "removeDuplicates", "(", "variable", ")", ":", "oldList", "=", "variable", ".", "split", "(", "os", ".", "pathsep", ")", "newList", "=", "[", "]", "for", "i", "in", "oldList", ":", "if", "i", "not", "in", "newList", ":", "newList", ".", "appen...
[ 205, 0 ]
[ 214, 22 ]
python
en
['en', 'en', 'en']
True
find_vcvarsall
(version)
Find the vcvarsall.bat file At first it tries to find the productdir of VS 2008 in the registry. If that fails it falls back to the VS90COMNTOOLS env var.
Find the vcvarsall.bat file
def find_vcvarsall(version): """Find the vcvarsall.bat file At first it tries to find the productdir of VS 2008 in the registry. If that fails it falls back to the VS90COMNTOOLS env var. """ vsbase = VS_BASE % version try: productdir = Reg.get_value(r"%s\Setup\VC" % vsbase, ...
[ "def", "find_vcvarsall", "(", "version", ")", ":", "vsbase", "=", "VS_BASE", "%", "version", "try", ":", "productdir", "=", "Reg", ".", "get_value", "(", "r\"%s\\Setup\\VC\"", "%", "vsbase", ",", "\"productdir\"", ")", "except", "KeyError", ":", "log", ".", ...
[ 216, 0 ]
[ 249, 15 ]
python
en
['en', 'en', 'en']
True
query_vcvarsall
(version, arch="x86")
Launch vcvarsall.bat and read the settings from its environment
Launch vcvarsall.bat and read the settings from its environment
def query_vcvarsall(version, arch="x86"): """Launch vcvarsall.bat and read the settings from its environment """ vcvarsall = find_vcvarsall(version) interesting = {"include", "lib", "libpath", "path"} result = {} if vcvarsall is None: raise DistutilsPlatformError("Unable to find vcvarsa...
[ "def", "query_vcvarsall", "(", "version", ",", "arch", "=", "\"x86\"", ")", ":", "vcvarsall", "=", "find_vcvarsall", "(", "version", ")", "interesting", "=", "{", "\"include\"", ",", "\"lib\"", ",", "\"libpath\"", ",", "\"path\"", "}", "result", "=", "{", ...
[ 251, 0 ]
[ 289, 17 ]
python
en
['en', 'en', 'en']
True
Reg.read_keys
(cls, base, key)
Return list of registry keys.
Return list of registry keys.
def read_keys(cls, base, key): """Return list of registry keys.""" try: handle = RegOpenKeyEx(base, key) except RegError: return None L = [] i = 0 while True: try: k = RegEnumKey(handle, i) except RegError: ...
[ "def", "read_keys", "(", "cls", ",", "base", ",", "key", ")", ":", "try", ":", "handle", "=", "RegOpenKeyEx", "(", "base", ",", "key", ")", "except", "RegError", ":", "return", "None", "L", "=", "[", "]", "i", "=", "0", "while", "True", ":", "try...
[ 70, 4 ]
[ 85, 16 ]
python
en
['en', 'no', 'en']
True
Reg.read_values
(cls, base, key)
Return dict of registry keys and values. All names are converted to lowercase.
Return dict of registry keys and values.
def read_values(cls, base, key): """Return dict of registry keys and values. All names are converted to lowercase. """ try: handle = RegOpenKeyEx(base, key) except RegError: return None d = {} i = 0 while True: try: ...
[ "def", "read_values", "(", "cls", ",", "base", ",", "key", ")", ":", "try", ":", "handle", "=", "RegOpenKeyEx", "(", "base", ",", "key", ")", "except", "RegError", ":", "return", "None", "d", "=", "{", "}", "i", "=", "0", "while", "True", ":", "t...
[ 88, 4 ]
[ 107, 16 ]
python
en
['en', 'en', 'en']
True
MSVCCompiler.find_exe
(self, exe)
Return path to an MSVC executable program. Tries to find the program in several places: first, one of the MSVC program search paths from the registry; next, the directories in the PATH environment variable. If any of those work, return an absolute path that is known to exist. If none ...
Return path to an MSVC executable program.
def find_exe(self, exe): """Return path to an MSVC executable program. Tries to find the program in several places: first, one of the MSVC program search paths from the registry; next, the directories in the PATH environment variable. If any of those work, return an absolute pa...
[ "def", "find_exe", "(", "self", ",", "exe", ")", ":", "for", "p", "in", "self", ".", "__paths", ":", "fn", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "abspath", "(", "p", ")", ",", "exe", ")", "if", "os", ".", "path", ...
[ 767, 4 ]
[ 787, 18 ]
python
en
['en', 'en', 'en']
True
PianorollEncoderDecoder.__init__
(self, input_size=88)
Initialize a PianorollEncoderDecoder object. Args: input_size: The size of the input vector.
Initialize a PianorollEncoderDecoder object.
def __init__(self, input_size=88): """Initialize a PianorollEncoderDecoder object. Args: input_size: The size of the input vector. """ self._input_size = input_size
[ "def", "__init__", "(", "self", ",", "input_size", "=", "88", ")", ":", "self", ".", "_input_size", "=", "input_size" ]
[ 30, 2 ]
[ 36, 33 ]
python
it
['it', 'en', 'it']
True
PianorollEncoderDecoder.events_to_input
(self, events, position)
Returns the input vector for the given position in the event sequence. Args: events: A list-like sequence of PianorollSequence events. position: An integer event position in the event sequence. Returns: An input vector, a list of floats.
Returns the input vector for the given position in the event sequence.
def events_to_input(self, events, position): """Returns the input vector for the given position in the event sequence. Args: events: A list-like sequence of PianorollSequence events. position: An integer event position in the event sequence. Returns: An input vector, a list of floats. ...
[ "def", "events_to_input", "(", "self", ",", "events", ",", "position", ")", ":", "return", "self", ".", "_event_to_input", "(", "events", "[", "position", "]", ")" ]
[ 61, 2 ]
[ 71, 49 ]
python
en
['en', 'en', 'en']
True
PianorollEncoderDecoder.events_to_label
(self, events, position)
Returns the label for the given position in the event sequence. Args: events: A list-like sequence of PianorollSequence events. position: An integer event position in the event sequence. Returns: A label, an integer.
Returns the label for the given position in the event sequence.
def events_to_label(self, events, position): """Returns the label for the given position in the event sequence. Args: events: A list-like sequence of PianorollSequence events. position: An integer event position in the event sequence. Returns: A label, an integer. """ return self...
[ "def", "events_to_label", "(", "self", ",", "events", ",", "position", ")", ":", "return", "self", ".", "_event_to_label", "(", "events", "[", "position", "]", ")" ]
[ 73, 2 ]
[ 83, 49 ]
python
en
['en', 'en', 'en']
True
PianorollEncoderDecoder.class_index_to_event
(self, class_index, events)
Returns the event for the given class index. This is the reverse process of the self.events_to_label method. Args: class_index: An integer in the range [0, self.num_classes). events: A list-like sequence of events. This object is not used in this implementation. Returns: An Pi...
Returns the event for the given class index.
def class_index_to_event(self, class_index, events): """Returns the event for the given class index. This is the reverse process of the self.events_to_label method. Args: class_index: An integer in the range [0, self.num_classes). events: A list-like sequence of events. This object is not used...
[ "def", "class_index_to_event", "(", "self", ",", "class_index", ",", "events", ")", ":", "assert", "class_index", "<", "self", ".", "num_classes", "event", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "input_size", ")", ":", "if", "class_i...
[ 85, 2 ]
[ 105, 23 ]
python
en
['en', 'en', 'en']
True
PianorollEncoderDecoder.extend_event_sequences
(self, pianoroll_seqs, samples)
Extends the event sequences by adding the new samples. Args: pianoroll_seqs: A collection of PianorollSequences to append `samples` to. samples: A collection of binary arrays with active pitches set to 1 and inactive pitches set to 0, which will be added to the corresponding `pianorol...
Extends the event sequences by adding the new samples.
def extend_event_sequences(self, pianoroll_seqs, samples): """Extends the event sequences by adding the new samples. Args: pianoroll_seqs: A collection of PianorollSequences to append `samples` to. samples: A collection of binary arrays with active pitches set to 1 and inactive pitches set...
[ "def", "extend_event_sequences", "(", "self", ",", "pianoroll_seqs", ",", "samples", ")", ":", "if", "len", "(", "pianoroll_seqs", ")", "!=", "len", "(", "samples", ")", ":", "raise", "ValueError", "(", "'`pianoroll_seqs` and `samples` must have equal lengths.'", ")...
[ 107, 2 ]
[ 123, 33 ]
python
en
['en', 'en', 'en']
True
_script_names
(dist, script_name, is_gui)
Create the fully qualified name of the files created by {console,gui}_scripts for the given ``dist``. Returns the list of file names
Create the fully qualified name of the files created by {console,gui}_scripts for the given ``dist``. Returns the list of file names
def _script_names(dist, script_name, is_gui): # type: (Distribution, str, bool) -> List[str] """Create the fully qualified name of the files created by {console,gui}_scripts for the given ``dist``. Returns the list of file names """ if dist_in_usersite(dist): bin_dir = bin_user else:...
[ "def", "_script_names", "(", "dist", ",", "script_name", ",", "is_gui", ")", ":", "# type: (Distribution, str, bool) -> List[str]", "if", "dist_in_usersite", "(", "dist", ")", ":", "bin_dir", "=", "bin_user", "else", ":", "bin_dir", "=", "bin_py", "exe_name", "=",...
[ 38, 0 ]
[ 57, 26 ]
python
en
['en', 'en', 'en']
True
uninstallation_paths
(dist)
Yield all the uninstallation paths for dist based on RECORD-without-.py[co] Yield paths to all the files in RECORD. For each .py file in RECORD, add the .pyc and .pyo in the same directory. UninstallPathSet.add() takes care of the __pycache__ .py[co].
Yield all the uninstallation paths for dist based on RECORD-without-.py[co]
def uninstallation_paths(dist): # type: (Distribution) -> Iterator[str] """ Yield all the uninstallation paths for dist based on RECORD-without-.py[co] Yield paths to all the files in RECORD. For each .py file in RECORD, add the .pyc and .pyo in the same directory. UninstallPathSet.add() takes...
[ "def", "uninstallation_paths", "(", "dist", ")", ":", "# type: (Distribution) -> Iterator[str]", "r", "=", "csv", ".", "reader", "(", "FakeFile", "(", "dist", ".", "get_metadata_lines", "(", "'RECORD'", ")", ")", ")", "for", "row", "in", "r", ":", "path", "=...
[ 74, 0 ]
[ 94, 22 ]
python
en
['en', 'error', 'th']
False
compact
(paths)
Compact a path set to contain the minimal number of paths necessary to contain all paths in the set. If /a/path/ and /a/path/to/a/file.txt are both in the set, leave only the shorter path.
Compact a path set to contain the minimal number of paths necessary to contain all paths in the set. If /a/path/ and /a/path/to/a/file.txt are both in the set, leave only the shorter path.
def compact(paths): # type: (Iterable[str]) -> Set[str] """Compact a path set to contain the minimal number of paths necessary to contain all paths in the set. If /a/path/ and /a/path/to/a/file.txt are both in the set, leave only the shorter path.""" sep = os.path.sep short_paths = set() #...
[ "def", "compact", "(", "paths", ")", ":", "# type: (Iterable[str]) -> Set[str]", "sep", "=", "os", ".", "path", ".", "sep", "short_paths", "=", "set", "(", ")", "# type: Set[str]", "for", "path", "in", "sorted", "(", "paths", ",", "key", "=", "len", ")", ...
[ 97, 0 ]
[ 114, 22 ]
python
en
['en', 'en', 'en']
True
compress_for_rename
(paths)
Returns a set containing the paths that need to be renamed. This set may include directories when the original sequence of paths included every file on disk.
Returns a set containing the paths that need to be renamed.
def compress_for_rename(paths): # type: (Iterable[str]) -> Set[str] """Returns a set containing the paths that need to be renamed. This set may include directories when the original sequence of paths included every file on disk. """ case_map = dict((os.path.normcase(p), p) for p in paths) r...
[ "def", "compress_for_rename", "(", "paths", ")", ":", "# type: (Iterable[str]) -> Set[str]", "case_map", "=", "dict", "(", "(", "os", ".", "path", ".", "normcase", "(", "p", ")", ",", "p", ")", "for", "p", "in", "paths", ")", "remaining", "=", "set", "("...
[ 117, 0 ]
[ 154, 64 ]
python
en
['en', 'en', 'en']
True
compress_for_output_listing
(paths)
Returns a tuple of 2 sets of which paths to display to user The first set contains paths that would be deleted. Files of a package are not added and the top-level directory of the package has a '*' added at the end - to signify that all it's contents are removed. The second set contains files that wou...
Returns a tuple of 2 sets of which paths to display to user
def compress_for_output_listing(paths): # type: (Iterable[str]) -> Tuple[Set[str], Set[str]] """Returns a tuple of 2 sets of which paths to display to user The first set contains paths that would be deleted. Files of a package are not added and the top-level directory of the package has a '*' added ...
[ "def", "compress_for_output_listing", "(", "paths", ")", ":", "# type: (Iterable[str]) -> Tuple[Set[str], Set[str]]", "will_remove", "=", "set", "(", "paths", ")", "will_skip", "=", "set", "(", ")", "# Determine folders and files", "folders", "=", "set", "(", ")", "fi...
[ 157, 0 ]
[ 205, 33 ]
python
en
['en', 'en', 'en']
True
StashedUninstallPathSet._get_directory_stash
(self, path)
Stashes a directory. Directories are stashed adjacent to their original location if possible, or else moved/copied into the user's temp dir.
Stashes a directory.
def _get_directory_stash(self, path): # type: (str) -> str """Stashes a directory. Directories are stashed adjacent to their original location if possible, or else moved/copied into the user's temp dir.""" try: save_dir = AdjacentTempDirectory(path) # type: TempDir...
[ "def", "_get_directory_stash", "(", "self", ",", "path", ")", ":", "# type: (str) -> str", "try", ":", "save_dir", "=", "AdjacentTempDirectory", "(", "path", ")", "# type: TempDirectory", "except", "OSError", ":", "save_dir", "=", "TempDirectory", "(", "kind", "="...
[ 220, 4 ]
[ 233, 28 ]
python
en
['en', 'en', 'en']
True
StashedUninstallPathSet._get_file_stash
(self, path)
Stashes a file. If no root has been provided, one will be created for the directory in the user's temp directory.
Stashes a file.
def _get_file_stash(self, path): # type: (str) -> str """Stashes a file. If no root has been provided, one will be created for the directory in the user's temp directory.""" path = os.path.normcase(path) head, old_head = os.path.dirname(path), None save_dir = Non...
[ "def", "_get_file_stash", "(", "self", ",", "path", ")", ":", "# type: (str) -> str", "path", "=", "os", ".", "path", ".", "normcase", "(", "path", ")", "head", ",", "old_head", "=", "os", ".", "path", ".", "dirname", "(", "path", ")", ",", "None", "...
[ 235, 4 ]
[ 261, 28 ]
python
en
['en', 'en', 'en']
True
StashedUninstallPathSet.stash
(self, path)
Stashes the directory or file and returns its new location. Handle symlinks as files to avoid modifying the symlink targets.
Stashes the directory or file and returns its new location. Handle symlinks as files to avoid modifying the symlink targets.
def stash(self, path): # type: (str) -> str """Stashes the directory or file and returns its new location. Handle symlinks as files to avoid modifying the symlink targets. """ path_is_dir = os.path.isdir(path) and not os.path.islink(path) if path_is_dir: new_p...
[ "def", "stash", "(", "self", ",", "path", ")", ":", "# type: (str) -> str", "path_is_dir", "=", "os", ".", "path", ".", "isdir", "(", "path", ")", "and", "not", "os", ".", "path", ".", "islink", "(", "path", ")", "if", "path_is_dir", ":", "new_path", ...
[ 263, 4 ]
[ 283, 23 ]
python
en
['en', 'en', 'en']
True
StashedUninstallPathSet.commit
(self)
Commits the uninstall by removing stashed files.
Commits the uninstall by removing stashed files.
def commit(self): # type: () -> None """Commits the uninstall by removing stashed files.""" for _, save_dir in self._save_dirs.items(): save_dir.cleanup() self._moves = [] self._save_dirs = {}
[ "def", "commit", "(", "self", ")", ":", "# type: () -> None", "for", "_", ",", "save_dir", "in", "self", ".", "_save_dirs", ".", "items", "(", ")", ":", "save_dir", ".", "cleanup", "(", ")", "self", ".", "_moves", "=", "[", "]", "self", ".", "_save_d...
[ 285, 4 ]
[ 291, 28 ]
python
en
['en', 'en', 'en']
True
StashedUninstallPathSet.rollback
(self)
Undoes the uninstall by moving stashed files back.
Undoes the uninstall by moving stashed files back.
def rollback(self): # type: () -> None """Undoes the uninstall by moving stashed files back.""" for p in self._moves: logger.info("Moving to %s\n from %s", *p) for new_path, path in self._moves: try: logger.debug('Replacing %s from %s', new_path, ...
[ "def", "rollback", "(", "self", ")", ":", "# type: () -> None", "for", "p", "in", "self", ".", "_moves", ":", "logger", ".", "info", "(", "\"Moving to %s\\n from %s\"", ",", "*", "p", ")", "for", "new_path", ",", "path", "in", "self", ".", "_moves", ":",...
[ 293, 4 ]
[ 311, 21 ]
python
en
['en', 'en', 'en']
True
UninstallPathSet._permitted
(self, path)
Return True if the given path is one we are permitted to remove/modify, False otherwise.
Return True if the given path is one we are permitted to remove/modify, False otherwise.
def _permitted(self, path): # type: (str) -> bool """ Return True if the given path is one we are permitted to remove/modify, False otherwise. """ return is_local(path)
[ "def", "_permitted", "(", "self", ",", "path", ")", ":", "# type: (str) -> bool", "return", "is_local", "(", "path", ")" ]
[ 330, 4 ]
[ 337, 29 ]
python
en
['en', 'error', 'th']
False
UninstallPathSet.remove
(self, auto_confirm=False, verbose=False)
Remove paths in ``self.paths`` with confirmation (unless ``auto_confirm`` is True).
Remove paths in ``self.paths`` with confirmation (unless ``auto_confirm`` is True).
def remove(self, auto_confirm=False, verbose=False): # type: (bool, bool) -> None """Remove paths in ``self.paths`` with confirmation (unless ``auto_confirm`` is True).""" if not self.paths: logger.info( "Can't uninstall '%s'. No files were found to uninstall...
[ "def", "remove", "(", "self", ",", "auto_confirm", "=", "False", ",", "verbose", "=", "False", ")", ":", "# type: (bool, bool) -> None", "if", "not", "self", ".", "paths", ":", "logger", ".", "info", "(", "\"Can't uninstall '%s'. No files were found to uninstall.\""...
[ 369, 4 ]
[ 399, 77 ]
python
en
['en', 'en', 'en']
True
UninstallPathSet._allowed_to_proceed
(self, verbose)
Display which files would be deleted and prompt for confirmation
Display which files would be deleted and prompt for confirmation
def _allowed_to_proceed(self, verbose): # type: (bool) -> bool """Display which files would be deleted and prompt for confirmation """ def _display(msg, paths): # type: (str, Iterable[str]) -> None if not paths: return logger.info(msg...
[ "def", "_allowed_to_proceed", "(", "self", ",", "verbose", ")", ":", "# type: (bool) -> bool", "def", "_display", "(", "msg", ",", "paths", ")", ":", "# type: (str, Iterable[str]) -> None", "if", "not", "paths", ":", "return", "logger", ".", "info", "(", "msg", ...
[ 401, 4 ]
[ 430, 56 ]
python
en
['en', 'en', 'en']
True
UninstallPathSet.rollback
(self)
Rollback the changes previously made by remove().
Rollback the changes previously made by remove().
def rollback(self): # type: () -> None """Rollback the changes previously made by remove().""" if not self._moved_paths.can_rollback: logger.error( "Can't roll back %s; was not uninstalled", self.dist.project_name, ) return ...
[ "def", "rollback", "(", "self", ")", ":", "# type: () -> None", "if", "not", "self", ".", "_moved_paths", ".", "can_rollback", ":", "logger", ".", "error", "(", "\"Can't roll back %s; was not uninstalled\"", ",", "self", ".", "dist", ".", "project_name", ",", ")...
[ 432, 4 ]
[ 444, 26 ]
python
en
['en', 'en', 'en']
True
UninstallPathSet.commit
(self)
Remove temporary save dir: rollback will no longer be possible.
Remove temporary save dir: rollback will no longer be possible.
def commit(self): # type: () -> None """Remove temporary save dir: rollback will no longer be possible.""" self._moved_paths.commit()
[ "def", "commit", "(", "self", ")", ":", "# type: () -> None", "self", ".", "_moved_paths", ".", "commit", "(", ")" ]
[ 446, 4 ]
[ 449, 34 ]
python
en
['en', 'en', 'en']
True
Mercurial.export
(self, location, url)
Export the Hg repository at the url to the destination location
Export the Hg repository at the url to the destination location
def export(self, location, url): # type: (str, HiddenText) -> None """Export the Hg repository at the url to the destination location""" with TempDirectory(kind="export") as temp_dir: self.unpack(temp_dir.path, url=url) self.run_command( ['archive', locat...
[ "def", "export", "(", "self", ",", "location", ",", "url", ")", ":", "# type: (str, HiddenText) -> None", "with", "TempDirectory", "(", "kind", "=", "\"export\"", ")", "as", "temp_dir", ":", "self", ".", "unpack", "(", "temp_dir", ".", "path", ",", "url", ...
[ 42, 4 ]
[ 50, 13 ]
python
en
['en', 'en', 'en']
True
Mercurial.get_revision
(cls, location)
Return the repository-local changeset revision number, as an integer.
Return the repository-local changeset revision number, as an integer.
def get_revision(cls, location): """ Return the repository-local changeset revision number, as an integer. """ current_revision = cls.run_command( ['parents', '--template={rev}'], cwd=location).strip() return current_revision
[ "def", "get_revision", "(", "cls", ",", "location", ")", ":", "current_revision", "=", "cls", ".", "run_command", "(", "[", "'parents'", ",", "'--template={rev}'", "]", ",", "cwd", "=", "location", ")", ".", "strip", "(", ")", "return", "current_revision" ]
[ 100, 4 ]
[ 106, 31 ]
python
en
['en', 'error', 'th']
False
Mercurial.get_requirement_revision
(cls, location)
Return the changeset identification hash, as a 40-character hexadecimal string
Return the changeset identification hash, as a 40-character hexadecimal string
def get_requirement_revision(cls, location): """ Return the changeset identification hash, as a 40-character hexadecimal string """ current_rev_hash = cls.run_command( ['parents', '--template={node}'], cwd=location).strip() return current_rev_hash
[ "def", "get_requirement_revision", "(", "cls", ",", "location", ")", ":", "current_rev_hash", "=", "cls", ".", "run_command", "(", "[", "'parents'", ",", "'--template={node}'", "]", ",", "cwd", "=", "location", ")", ".", "strip", "(", ")", "return", "current...
[ 109, 4 ]
[ 117, 31 ]
python
en
['en', 'error', 'th']
False
Mercurial.is_commit_id_equal
(cls, dest, name)
Always assume the versions don't match
Always assume the versions don't match
def is_commit_id_equal(cls, dest, name): """Always assume the versions don't match""" return False
[ "def", "is_commit_id_equal", "(", "cls", ",", "dest", ",", "name", ")", ":", "return", "False" ]
[ 120, 4 ]
[ 122, 20 ]
python
en
['en', 'en', 'en']
True
Mercurial.get_subdirectory
(cls, location)
Return the path to setup.py, relative to the repo root. Return None if setup.py is in the repo root.
Return the path to setup.py, relative to the repo root. Return None if setup.py is in the repo root.
def get_subdirectory(cls, location): """ Return the path to setup.py, relative to the repo root. Return None if setup.py is in the repo root. """ # find the repo root repo_root = cls.run_command( ['root'], cwd=location).strip() if not os.path.isabs(rep...
[ "def", "get_subdirectory", "(", "cls", ",", "location", ")", ":", "# find the repo root", "repo_root", "=", "cls", ".", "run_command", "(", "[", "'root'", "]", ",", "cwd", "=", "location", ")", ".", "strip", "(", ")", "if", "not", "os", ".", "path", "....
[ 125, 4 ]
[ 135, 69 ]
python
en
['en', 'error', 'th']
False
_rotate_origin
(x, y, rotation_deg)
Rotate a set of 2D points counterclockwise around the origin (0, 0).
Rotate a set of 2D points counterclockwise around the origin (0, 0).
def _rotate_origin(x, y, rotation_deg): """Rotate a set of 2D points counterclockwise around the origin (0, 0). """ rotation_rad = np.deg2rad(rotation_deg) # Rotation is set negative to make counterclockwise rotation xx = x * np.cos(-rotation_rad) + y * np.sin(-rotation_rad) yy = -x * np.sin(-ro...
[ "def", "_rotate_origin", "(", "x", ",", "y", ",", "rotation_deg", ")", ":", "rotation_rad", "=", "np", ".", "deg2rad", "(", "rotation_deg", ")", "# Rotation is set negative to make counterclockwise rotation", "xx", "=", "x", "*", "np", ".", "cos", "(", "-", "r...
[ 13, 0 ]
[ 20, 17 ]
python
en
['en', 'en', 'en']
True
_plot_field_layout
(X, Y, L_min)
Plot field layout.
Plot field layout.
def _plot_field_layout(X, Y, L_min): """Plot field layout.""" fig, ax = plt.subplots(figsize=(6, 6)) # Plot a circle with a diameter equal to L_min ax.add_collection(EllipseCollection(widths=L_min, heights=L_min, angles=0, units='xy', ...
[ "def", "_plot_field_layout", "(", "X", ",", "Y", ",", "L_min", ")", ":", "fig", ",", "ax", "=", "plt", ".", "subplots", "(", "figsize", "=", "(", "6", ",", "6", ")", ")", "# Plot a circle with a diameter equal to L_min", "ax", ".", "add_collection", "(", ...
[ 23, 0 ]
[ 44, 43 ]
python
en
['en', 'fy', 'en']
True
generate_field_layout
(gcr, collector_area, L_min, neighbor_order, aspect_ratio=None, offset=None, rotation=None, layout_type=None, plot=True)
Generate a regularly-spaced collector field layout. See [1]_ for examples on how to use the function. Field layout parameters and limits are described in [2]_. Notes ----- The field layout can be specified either using selecting a standard layout using the layout_type argument or by speci...
Generate a regularly-spaced collector field layout.
def generate_field_layout(gcr, collector_area, L_min, neighbor_order, aspect_ratio=None, offset=None, rotation=None, layout_type=None, plot=True): """ Generate a regularly-spaced collector field layout. See [1]_ for examples on how to use the function. Fi...
[ "def", "generate_field_layout", "(", "gcr", ",", "collector_area", ",", "L_min", ",", "neighbor_order", ",", "aspect_ratio", "=", "None", ",", "offset", "=", "None", ",", "rotation", "=", "None", ",", "layout_type", "=", "None", ",", "plot", "=", "True", "...
[ 49, 0 ]
[ 181, 51 ]
python
en
['en', 'error', 'th']
False
two_axis_shading_fraction
(solar_azimuth, solar_elevation, collector_geometry, L_min, tracker_distance, relative_azimuth, plot=False)
Calculate the shading fraction for any layout of two-axis tracking collectors. See [1]_ for examples on how to use the function. Parameters ---------- solar_azimuth: float Solar azimuth angle in degrees. solar_elevation: float Solar elevation angle in degrees. collector_geometr...
Calculate the shading fraction for any layout of two-axis tracking collectors.
def two_axis_shading_fraction(solar_azimuth, solar_elevation, collector_geometry, L_min, tracker_distance, relative_azimuth, plot=False): """Calculate the shading fraction for any layout of two-axis tracking collectors. See [1]_ for examples on how to...
[ "def", "two_axis_shading_fraction", "(", "solar_azimuth", ",", "solar_elevation", ",", "collector_geometry", ",", "L_min", ",", "tracker_distance", ",", "relative_azimuth", ",", "plot", "=", "False", ")", ":", "# noqa: E501", "# If the sun is below the horizon, set the shad...
[ 184, 0 ]
[ 268, 27 ]
python
en
['en', 'en', 'en']
True
LogFormatter.__init__
(self, color=True, datefmt=None)
r""" :arg bool color: Enables color support. :arg string fmt: Log message format. It will be applied to the attributes dict of log records. The text between ``%(color)s`` and ``%(end_color)s`` will be colored depending on the level if color support is on. :arg dict colors...
r""" :arg bool color: Enables color support. :arg string fmt: Log message format. It will be applied to the attributes dict of log records. The text between ``%(color)s`` and ``%(end_color)s`` will be colored depending on the level if color support is on. :arg dict colors...
def __init__(self, color=True, datefmt=None): r""" :arg bool color: Enables color support. :arg string fmt: Log message format. It will be applied to the attributes dict of log records. The text between ``%(color)s`` and ``%(end_color)s`` will be colored depending on the ...
[ "def", "__init__", "(", "self", ",", "color", "=", "True", ",", "datefmt", "=", "None", ")", ":", "logging", ".", "Formatter", ".", "__init__", "(", "self", ",", "datefmt", "=", "datefmt", ")", "self", ".", "_colors", "=", "{", "}", "if", "color", ...
[ 49, 4 ]
[ 90, 31 ]
python
cy
['en', 'cy', 'hi']
False
Parser.parse
(self, file=None, string=None)
SAX parse XML text. @param file: Parse a python I{file-like} object. @type file: I{file-like} object. @param string: Parse string XML. @type string: str
SAX parse XML text.
def parse(self, file=None, string=None): """ SAX parse XML text. @param file: Parse a python I{file-like} object. @type file: I{file-like} object. @param string: Parse string XML. @type string: str """ timer = metrics.Timer() timer.start() ...
[ "def", "parse", "(", "self", ",", "file", "=", "None", ",", "string", "=", "None", ")", ":", "timer", "=", "metrics", ".", "Timer", "(", ")", "timer", ".", "start", "(", ")", "sax", ",", "handler", "=", "self", ".", "saxparser", "(", ")", "if", ...
[ 116, 4 ]
[ 138, 35 ]
python
en
['en', 'error', 'th']
False
_create_branches_on_github
(*, user, repo_id, epic, task, originating_user_id)
Expects to be called in the context of a local github checkout.
Expects to be called in the context of a local github checkout.
def _create_branches_on_github(*, user, repo_id, epic, task, originating_user_id): """ Expects to be called in the context of a local github checkout. """ repository = get_repo_info(user, repo_id=repo_id) # Make epic branch, with latest from epic: epic.refresh_from_db() epic_branch_name = e...
[ "def", "_create_branches_on_github", "(", "*", ",", "user", ",", "repo_id", ",", "epic", ",", "task", ",", "originating_user_id", ")", ":", "repository", "=", "get_repo_info", "(", "user", ",", "repo_id", "=", "repo_id", ")", "# Make epic branch, with latest from ...
[ 85, 0 ]
[ 114, 27 ]
python
en
['en', 'error', 'th']
False
refresh_commits
(*, project, branch_name, originating_user_id)
This should only run when we're notified of a force-commit. It's the nuclear option.
This should only run when we're notified of a force-commit. It's the nuclear option.
def refresh_commits(*, project, branch_name, originating_user_id): """ This should only run when we're notified of a force-commit. It's the nuclear option. """ from .models import Task repo = get_repo_info( None, repo_owner=project.repo_owner, repo_name=project.repo_name ) # We ...
[ "def", "refresh_commits", "(", "*", ",", "project", ",", "branch_name", ",", "originating_user_id", ")", ":", "from", ".", "models", "import", "Task", "repo", "=", "get_repo_info", "(", "None", ",", "repo_owner", "=", "project", ".", "repo_owner", ",", "repo...
[ 548, 0 ]
[ 573, 74 ]
python
en
['en', 'error', 'th']
False
OperationLogMiddleware._process_response
(self, request, response)
Log user operation.
Log user operation.
def _process_response(self, request, response): """Log user operation.""" log_format = self._get_log_format(request) if not log_format: return response params = self._get_parameters_from_request(request) # log a message displayed to user messages = django_mes...
[ "def", "_process_response", "(", "self", ",", "request", ",", "response", ")", ":", "log_format", "=", "self", ".", "_get_log_format", "(", "request", ")", "if", "not", "log_format", ":", "return", "response", "params", "=", "self", ".", "_get_parameters_from_...
[ 81, 4 ]
[ 101, 23 ]
python
da
['da', 'da', 'en']
True
OperationLogMiddleware.process_exception
(self, request, exception)
Log error info when exception occurred.
Log error info when exception occurred.
def process_exception(self, request, exception): """Log error info when exception occurred.""" log_format = self._get_log_format(request) if log_format is None: return params = self._get_parameters_from_request(request, True) params['message'] = exception par...
[ "def", "process_exception", "(", "self", ",", "request", ",", "exception", ")", ":", "log_format", "=", "self", ".", "_get_log_format", "(", "request", ")", "if", "log_format", "is", "None", ":", "return", "params", "=", "self", ".", "_get_parameters_from_requ...
[ 103, 4 ]
[ 113, 51 ]
python
en
['en', 'it', 'en']
True