repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
pyQode/pyqode.core | pyqode/core/backend/workers.py | DocumentWordsProvider.complete | def complete(self, code, *args):
"""
Provides completions based on the document words.
:param code: code to complete
:param args: additional (unused) arguments.
"""
completions = []
for word in self.split(code, self.separators):
completions.append({'n... | python | def complete(self, code, *args):
"""
Provides completions based on the document words.
:param code: code to complete
:param args: additional (unused) arguments.
"""
completions = []
for word in self.split(code, self.separators):
completions.append({'n... | [
"def",
"complete",
"(",
"self",
",",
"code",
",",
"*",
"args",
")",
":",
"completions",
"=",
"[",
"]",
"for",
"word",
"in",
"self",
".",
"split",
"(",
"code",
",",
"self",
".",
"separators",
")",
":",
"completions",
".",
"append",
"(",
"{",
"'name'... | Provides completions based on the document words.
:param code: code to complete
:param args: additional (unused) arguments. | [
"Provides",
"completions",
"based",
"on",
"the",
"document",
"words",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/backend/workers.py#L158-L168 |
pyQode/pyqode.core | pyqode/core/modes/checker.py | CheckerMessage.status_to_string | def status_to_string(cls, status):
"""
Converts a message status to a string.
:param status: Status to convert (p yqode.core.modes.CheckerMessages)
:return: The status string.
:rtype: str
"""
strings = {CheckerMessages.INFO: "Info",
CheckerMess... | python | def status_to_string(cls, status):
"""
Converts a message status to a string.
:param status: Status to convert (p yqode.core.modes.CheckerMessages)
:return: The status string.
:rtype: str
"""
strings = {CheckerMessages.INFO: "Info",
CheckerMess... | [
"def",
"status_to_string",
"(",
"cls",
",",
"status",
")",
":",
"strings",
"=",
"{",
"CheckerMessages",
".",
"INFO",
":",
"\"Info\"",
",",
"CheckerMessages",
".",
"WARNING",
":",
"\"Warning\"",
",",
"CheckerMessages",
".",
"ERROR",
":",
"\"Error\"",
"}",
"re... | Converts a message status to a string.
:param status: Status to convert (p yqode.core.modes.CheckerMessages)
:return: The status string.
:rtype: str | [
"Converts",
"a",
"message",
"status",
"to",
"a",
"string",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/checker.py#L37-L48 |
pyQode/pyqode.core | pyqode/core/modes/checker.py | CheckerMode.add_messages | def add_messages(self, messages):
"""
Adds a message or a list of message.
:param messages: A list of messages or a single message
"""
# remove old messages
if len(messages) > self.limit:
messages = messages[:self.limit]
_logger(self.__class__).log(5,... | python | def add_messages(self, messages):
"""
Adds a message or a list of message.
:param messages: A list of messages or a single message
"""
# remove old messages
if len(messages) > self.limit:
messages = messages[:self.limit]
_logger(self.__class__).log(5,... | [
"def",
"add_messages",
"(",
"self",
",",
"messages",
")",
":",
"# remove old messages",
"if",
"len",
"(",
"messages",
")",
">",
"self",
".",
"limit",
":",
"messages",
"=",
"messages",
"[",
":",
"self",
".",
"limit",
"]",
"_logger",
"(",
"self",
".",
"_... | Adds a message or a list of message.
:param messages: A list of messages or a single message | [
"Adds",
"a",
"message",
"or",
"a",
"list",
"of",
"message",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/checker.py#L181-L197 |
pyQode/pyqode.core | pyqode/core/modes/checker.py | CheckerMode.remove_message | def remove_message(self, message):
"""
Removes a message.
:param message: Message to remove
"""
import time
_logger(self.__class__).log(5, 'removing message %s' % message)
t = time.time()
usd = message.block.userData()
if usd:
try:
... | python | def remove_message(self, message):
"""
Removes a message.
:param message: Message to remove
"""
import time
_logger(self.__class__).log(5, 'removing message %s' % message)
t = time.time()
usd = message.block.userData()
if usd:
try:
... | [
"def",
"remove_message",
"(",
"self",
",",
"message",
")",
":",
"import",
"time",
"_logger",
"(",
"self",
".",
"__class__",
")",
".",
"log",
"(",
"5",
",",
"'removing message %s'",
"%",
"message",
")",
"t",
"=",
"time",
".",
"time",
"(",
")",
"usd",
... | Removes a message.
:param message: Message to remove | [
"Removes",
"a",
"message",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/checker.py#L255-L272 |
pyQode/pyqode.core | pyqode/core/modes/checker.py | CheckerMode.clear_messages | def clear_messages(self):
"""
Clears all messages.
"""
while len(self._messages):
msg = self._messages.pop(0)
usd = msg.block.userData()
if usd and hasattr(usd, 'messages'):
usd.messages[:] = []
if msg.decoration:
... | python | def clear_messages(self):
"""
Clears all messages.
"""
while len(self._messages):
msg = self._messages.pop(0)
usd = msg.block.userData()
if usd and hasattr(usd, 'messages'):
usd.messages[:] = []
if msg.decoration:
... | [
"def",
"clear_messages",
"(",
"self",
")",
":",
"while",
"len",
"(",
"self",
".",
"_messages",
")",
":",
"msg",
"=",
"self",
".",
"_messages",
".",
"pop",
"(",
"0",
")",
"usd",
"=",
"msg",
".",
"block",
".",
"userData",
"(",
")",
"if",
"usd",
"an... | Clears all messages. | [
"Clears",
"all",
"messages",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/checker.py#L274-L284 |
pyQode/pyqode.core | pyqode/core/modes/checker.py | CheckerMode._on_work_finished | def _on_work_finished(self, results):
"""
Display results.
:param status: Response status
:param results: Response data, messages.
"""
messages = []
for msg in results:
msg = CheckerMessage(*msg)
if msg.line >= self.editor.blockCount():
... | python | def _on_work_finished(self, results):
"""
Display results.
:param status: Response status
:param results: Response data, messages.
"""
messages = []
for msg in results:
msg = CheckerMessage(*msg)
if msg.line >= self.editor.blockCount():
... | [
"def",
"_on_work_finished",
"(",
"self",
",",
"results",
")",
":",
"messages",
"=",
"[",
"]",
"for",
"msg",
"in",
"results",
":",
"msg",
"=",
"CheckerMessage",
"(",
"*",
"msg",
")",
"if",
"msg",
".",
"line",
">=",
"self",
".",
"editor",
".",
"blockCo... | Display results.
:param status: Response status
:param results: Response data, messages. | [
"Display",
"results",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/checker.py#L297-L312 |
pyQode/pyqode.core | pyqode/core/modes/checker.py | CheckerMode.request_analysis | def request_analysis(self):
"""
Requests an analysis.
"""
if self._finished:
_logger(self.__class__).log(5, 'running analysis')
self._job_runner.request_job(self._request)
elif self.editor:
# retry later
_logger(self.__class__).log(... | python | def request_analysis(self):
"""
Requests an analysis.
"""
if self._finished:
_logger(self.__class__).log(5, 'running analysis')
self._job_runner.request_job(self._request)
elif self.editor:
# retry later
_logger(self.__class__).log(... | [
"def",
"request_analysis",
"(",
"self",
")",
":",
"if",
"self",
".",
"_finished",
":",
"_logger",
"(",
"self",
".",
"__class__",
")",
".",
"log",
"(",
"5",
",",
"'running analysis'",
")",
"self",
".",
"_job_runner",
".",
"request_job",
"(",
"self",
".",
... | Requests an analysis. | [
"Requests",
"an",
"analysis",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/checker.py#L314-L325 |
pyQode/pyqode.core | pyqode/core/modes/checker.py | CheckerMode._request | def _request(self):
""" Requests a checking of the editor content. """
try:
self.editor.toPlainText()
except (TypeError, RuntimeError):
return
try:
max_line_length = self.editor.modes.get(
'RightMarginMode').position
except KeyE... | python | def _request(self):
""" Requests a checking of the editor content. """
try:
self.editor.toPlainText()
except (TypeError, RuntimeError):
return
try:
max_line_length = self.editor.modes.get(
'RightMarginMode').position
except KeyE... | [
"def",
"_request",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"editor",
".",
"toPlainText",
"(",
")",
"except",
"(",
"TypeError",
",",
"RuntimeError",
")",
":",
"return",
"try",
":",
"max_line_length",
"=",
"self",
".",
"editor",
".",
"modes",
"."... | Requests a checking of the editor content. | [
"Requests",
"a",
"checking",
"of",
"the",
"editor",
"content",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/checker.py#L327-L351 |
pyQode/pyqode.core | pyqode/core/widgets/_pty.py | openpty | def openpty():
"""openpty() -> (master_fd, slave_fd)
Open a pty master/slave pair, using os.openpty() if possible."""
try:
return os.openpty()
except (AttributeError, OSError):
pass
master_fd, slave_name = _open_terminal()
slave_fd = slave_open(slave_name)
return master_fd, ... | python | def openpty():
"""openpty() -> (master_fd, slave_fd)
Open a pty master/slave pair, using os.openpty() if possible."""
try:
return os.openpty()
except (AttributeError, OSError):
pass
master_fd, slave_name = _open_terminal()
slave_fd = slave_open(slave_name)
return master_fd, ... | [
"def",
"openpty",
"(",
")",
":",
"try",
":",
"return",
"os",
".",
"openpty",
"(",
")",
"except",
"(",
"AttributeError",
",",
"OSError",
")",
":",
"pass",
"master_fd",
",",
"slave_name",
"=",
"_open_terminal",
"(",
")",
"slave_fd",
"=",
"slave_open",
"(",... | openpty() -> (master_fd, slave_fd)
Open a pty master/slave pair, using os.openpty() if possible. | [
"openpty",
"()",
"-",
">",
"(",
"master_fd",
"slave_fd",
")",
"Open",
"a",
"pty",
"master",
"/",
"slave",
"pair",
"using",
"os",
".",
"openpty",
"()",
"if",
"possible",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/_pty.py#L21-L31 |
pyQode/pyqode.core | pyqode/core/widgets/_pty.py | master_open | def master_open():
"""master_open() -> (master_fd, slave_name)
Open a pty master and return the fd, and the filename of the slave end.
Deprecated, use openpty() instead."""
try:
master_fd, slave_fd = os.openpty()
except (AttributeError, OSError):
pass
else:
slave_name = ... | python | def master_open():
"""master_open() -> (master_fd, slave_name)
Open a pty master and return the fd, and the filename of the slave end.
Deprecated, use openpty() instead."""
try:
master_fd, slave_fd = os.openpty()
except (AttributeError, OSError):
pass
else:
slave_name = ... | [
"def",
"master_open",
"(",
")",
":",
"try",
":",
"master_fd",
",",
"slave_fd",
"=",
"os",
".",
"openpty",
"(",
")",
"except",
"(",
"AttributeError",
",",
"OSError",
")",
":",
"pass",
"else",
":",
"slave_name",
"=",
"os",
".",
"ttyname",
"(",
"slave_fd"... | master_open() -> (master_fd, slave_name)
Open a pty master and return the fd, and the filename of the slave end.
Deprecated, use openpty() instead. | [
"master_open",
"()",
"-",
">",
"(",
"master_fd",
"slave_name",
")",
"Open",
"a",
"pty",
"master",
"and",
"return",
"the",
"fd",
"and",
"the",
"filename",
"of",
"the",
"slave",
"end",
".",
"Deprecated",
"use",
"openpty",
"()",
"instead",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/_pty.py#L33-L47 |
pyQode/pyqode.core | pyqode/core/widgets/_pty.py | _open_terminal | def _open_terminal():
"""Open pty master and return (master_fd, tty_name)."""
for x in 'pqrstuvwxyzPQRST':
for y in '0123456789abcdef':
pty_name = '/dev/pty' + x + y
try:
fd = os.open(pty_name, os.O_RDWR)
except OSError:
continue
... | python | def _open_terminal():
"""Open pty master and return (master_fd, tty_name)."""
for x in 'pqrstuvwxyzPQRST':
for y in '0123456789abcdef':
pty_name = '/dev/pty' + x + y
try:
fd = os.open(pty_name, os.O_RDWR)
except OSError:
continue
... | [
"def",
"_open_terminal",
"(",
")",
":",
"for",
"x",
"in",
"'pqrstuvwxyzPQRST'",
":",
"for",
"y",
"in",
"'0123456789abcdef'",
":",
"pty_name",
"=",
"'/dev/pty'",
"+",
"x",
"+",
"y",
"try",
":",
"fd",
"=",
"os",
".",
"open",
"(",
"pty_name",
",",
"os",
... | Open pty master and return (master_fd, tty_name). | [
"Open",
"pty",
"master",
"and",
"return",
"(",
"master_fd",
"tty_name",
")",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/_pty.py#L49-L59 |
pyQode/pyqode.core | pyqode/core/widgets/_pty.py | slave_open | def slave_open(tty_name):
"""slave_open(tty_name) -> slave_fd
Open the pty slave and acquire the controlling terminal, returning
opened filedescriptor.
Deprecated, use openpty() instead."""
result = os.open(tty_name, os.O_RDWR)
try:
from fcntl import ioctl, I_PUSH
except ImportError... | python | def slave_open(tty_name):
"""slave_open(tty_name) -> slave_fd
Open the pty slave and acquire the controlling terminal, returning
opened filedescriptor.
Deprecated, use openpty() instead."""
result = os.open(tty_name, os.O_RDWR)
try:
from fcntl import ioctl, I_PUSH
except ImportError... | [
"def",
"slave_open",
"(",
"tty_name",
")",
":",
"result",
"=",
"os",
".",
"open",
"(",
"tty_name",
",",
"os",
".",
"O_RDWR",
")",
"try",
":",
"from",
"fcntl",
"import",
"ioctl",
",",
"I_PUSH",
"except",
"ImportError",
":",
"return",
"result",
"try",
":... | slave_open(tty_name) -> slave_fd
Open the pty slave and acquire the controlling terminal, returning
opened filedescriptor.
Deprecated, use openpty() instead. | [
"slave_open",
"(",
"tty_name",
")",
"-",
">",
"slave_fd",
"Open",
"the",
"pty",
"slave",
"and",
"acquire",
"the",
"controlling",
"terminal",
"returning",
"opened",
"filedescriptor",
".",
"Deprecated",
"use",
"openpty",
"()",
"instead",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/_pty.py#L61-L77 |
pyQode/pyqode.core | pyqode/core/widgets/_pty.py | fork | def fork():
"""fork() -> (pid, master_fd)
Fork and make the child a session leader with a controlling terminal."""
try:
pid, fd = os.forkpty()
except (AttributeError, OSError):
pass
else:
if pid == CHILD:
try:
os.setsid()
except OSErro... | python | def fork():
"""fork() -> (pid, master_fd)
Fork and make the child a session leader with a controlling terminal."""
try:
pid, fd = os.forkpty()
except (AttributeError, OSError):
pass
else:
if pid == CHILD:
try:
os.setsid()
except OSErro... | [
"def",
"fork",
"(",
")",
":",
"try",
":",
"pid",
",",
"fd",
"=",
"os",
".",
"forkpty",
"(",
")",
"except",
"(",
"AttributeError",
",",
"OSError",
")",
":",
"pass",
"else",
":",
"if",
"pid",
"==",
"CHILD",
":",
"try",
":",
"os",
".",
"setsid",
"... | fork() -> (pid, master_fd)
Fork and make the child a session leader with a controlling terminal. | [
"fork",
"()",
"-",
">",
"(",
"pid",
"master_fd",
")",
"Fork",
"and",
"make",
"the",
"child",
"a",
"session",
"leader",
"with",
"a",
"controlling",
"terminal",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/_pty.py#L79-L117 |
pyQode/pyqode.core | pyqode/core/widgets/_pty.py | _writen | def _writen(fd, data):
"""Write all the data to a descriptor."""
while data:
n = os.write(fd, data)
data = data[n:] | python | def _writen(fd, data):
"""Write all the data to a descriptor."""
while data:
n = os.write(fd, data)
data = data[n:] | [
"def",
"_writen",
"(",
"fd",
",",
"data",
")",
":",
"while",
"data",
":",
"n",
"=",
"os",
".",
"write",
"(",
"fd",
",",
"data",
")",
"data",
"=",
"data",
"[",
"n",
":",
"]"
] | Write all the data to a descriptor. | [
"Write",
"all",
"the",
"data",
"to",
"a",
"descriptor",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/_pty.py#L119-L123 |
pyQode/pyqode.core | pyqode/core/widgets/_pty.py | _copy | def _copy(master_fd, master_read=_read, stdin_read=_read):
"""Parent copy loop.
Copies
pty master -> standard output (master_read)
standard input -> pty master (stdin_read)"""
fds = [master_fd, STDIN_FILENO]
while True:
rfds, wfds, xfds = select(fds, [], [])
... | python | def _copy(master_fd, master_read=_read, stdin_read=_read):
"""Parent copy loop.
Copies
pty master -> standard output (master_read)
standard input -> pty master (stdin_read)"""
fds = [master_fd, STDIN_FILENO]
while True:
rfds, wfds, xfds = select(fds, [], [])
... | [
"def",
"_copy",
"(",
"master_fd",
",",
"master_read",
"=",
"_read",
",",
"stdin_read",
"=",
"_read",
")",
":",
"fds",
"=",
"[",
"master_fd",
",",
"STDIN_FILENO",
"]",
"while",
"True",
":",
"rfds",
",",
"wfds",
",",
"xfds",
"=",
"select",
"(",
"fds",
... | Parent copy loop.
Copies
pty master -> standard output (master_read)
standard input -> pty master (stdin_read) | [
"Parent",
"copy",
"loop",
".",
"Copies",
"pty",
"master",
"-",
">",
"standard",
"output",
"(",
"master_read",
")",
"standard",
"input",
"-",
">",
"pty",
"master",
"(",
"stdin_read",
")"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/_pty.py#L129-L148 |
pyQode/pyqode.core | pyqode/core/widgets/_pty.py | spawn | def spawn(argv, master_read=_read, stdin_read=_read):
"""Create a spawned process."""
if type(argv) == type(''):
argv = (argv,)
pid, master_fd = fork()
if pid == CHILD:
try:
os.execlp(argv[0], *argv)
except:
# If we wanted to be really clever, we would use... | python | def spawn(argv, master_read=_read, stdin_read=_read):
"""Create a spawned process."""
if type(argv) == type(''):
argv = (argv,)
pid, master_fd = fork()
if pid == CHILD:
try:
os.execlp(argv[0], *argv)
except:
# If we wanted to be really clever, we would use... | [
"def",
"spawn",
"(",
"argv",
",",
"master_read",
"=",
"_read",
",",
"stdin_read",
"=",
"_read",
")",
":",
"if",
"type",
"(",
"argv",
")",
"==",
"type",
"(",
"''",
")",
":",
"argv",
"=",
"(",
"argv",
",",
")",
"pid",
",",
"master_fd",
"=",
"fork",... | Create a spawned process. | [
"Create",
"a",
"spawned",
"process",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/_pty.py#L150-L182 |
psphere-project/psphere | psphere/__init__.py | ManagedObject._get_dataobject | def _get_dataobject(self, name, multivalued):
"""This function only gets called if the decorated property
doesn't have a value in the cache."""
logger.debug("Querying server for uncached data object %s", name)
# This will retrieve the value and inject it into the cache
self.updat... | python | def _get_dataobject(self, name, multivalued):
"""This function only gets called if the decorated property
doesn't have a value in the cache."""
logger.debug("Querying server for uncached data object %s", name)
# This will retrieve the value and inject it into the cache
self.updat... | [
"def",
"_get_dataobject",
"(",
"self",
",",
"name",
",",
"multivalued",
")",
":",
"logger",
".",
"debug",
"(",
"\"Querying server for uncached data object %s\"",
",",
"name",
")",
"# This will retrieve the value and inject it into the cache",
"self",
".",
"update_view_data"... | This function only gets called if the decorated property
doesn't have a value in the cache. | [
"This",
"function",
"only",
"gets",
"called",
"if",
"the",
"decorated",
"property",
"doesn",
"t",
"have",
"a",
"value",
"in",
"the",
"cache",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/__init__.py#L110-L116 |
psphere-project/psphere | psphere/__init__.py | ManagedObject._get_mor | def _get_mor(self, name, multivalued):
"""This function only gets called if the decorated property
doesn't have a value in the cache."""
logger.debug("Querying server for uncached MOR %s", name)
# This will retrieve the value and inject it into the cache
logger.debug("Getting vie... | python | def _get_mor(self, name, multivalued):
"""This function only gets called if the decorated property
doesn't have a value in the cache."""
logger.debug("Querying server for uncached MOR %s", name)
# This will retrieve the value and inject it into the cache
logger.debug("Getting vie... | [
"def",
"_get_mor",
"(",
"self",
",",
"name",
",",
"multivalued",
")",
":",
"logger",
".",
"debug",
"(",
"\"Querying server for uncached MOR %s\"",
",",
"name",
")",
"# This will retrieve the value and inject it into the cache",
"logger",
".",
"debug",
"(",
"\"Getting vi... | This function only gets called if the decorated property
doesn't have a value in the cache. | [
"This",
"function",
"only",
"gets",
"called",
"if",
"the",
"decorated",
"property",
"doesn",
"t",
"have",
"a",
"value",
"in",
"the",
"cache",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/__init__.py#L118-L125 |
psphere-project/psphere | psphere/__init__.py | ManagedObject.flush_cache | def flush_cache(self, properties=None):
"""Flushes the cache being held for this instance.
:param properties: The list of properties to flush from the cache.
:type properties: list or None (default). If None, flush entire cache.
"""
if hasattr(self, '_cache'):
if pr... | python | def flush_cache(self, properties=None):
"""Flushes the cache being held for this instance.
:param properties: The list of properties to flush from the cache.
:type properties: list or None (default). If None, flush entire cache.
"""
if hasattr(self, '_cache'):
if pr... | [
"def",
"flush_cache",
"(",
"self",
",",
"properties",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_cache'",
")",
":",
"if",
"properties",
"is",
"None",
":",
"del",
"(",
"self",
".",
"_cache",
")",
"else",
":",
"for",
"prop",
"in",
"... | Flushes the cache being held for this instance.
:param properties: The list of properties to flush from the cache.
:type properties: list or None (default). If None, flush entire cache. | [
"Flushes",
"the",
"cache",
"being",
"held",
"for",
"this",
"instance",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/__init__.py#L138-L151 |
psphere-project/psphere | psphere/__init__.py | ManagedObject.update | def update(self, properties=None):
"""Updates the properties being held for this instance.
:param properties: The list of properties to update.
:type properties: list or None (default). If None, update all
currently cached properties.
"""
if properties is None:
... | python | def update(self, properties=None):
"""Updates the properties being held for this instance.
:param properties: The list of properties to update.
:type properties: list or None (default). If None, update all
currently cached properties.
"""
if properties is None:
... | [
"def",
"update",
"(",
"self",
",",
"properties",
"=",
"None",
")",
":",
"if",
"properties",
"is",
"None",
":",
"try",
":",
"self",
".",
"update_view_data",
"(",
"properties",
"=",
"list",
"(",
"self",
".",
"_cache",
".",
"keys",
"(",
")",
")",
")",
... | Updates the properties being held for this instance.
:param properties: The list of properties to update.
:type properties: list or None (default). If None, update all
currently cached properties. | [
"Updates",
"the",
"properties",
"being",
"held",
"for",
"this",
"instance",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/__init__.py#L153-L168 |
psphere-project/psphere | psphere/__init__.py | ManagedObject.update_view_data | def update_view_data(self, properties=None):
"""Update the local object from the server-side object.
>>> vm = VirtualMachine.find_one(client, filter={"name": "genesis"})
>>> # Update all properties
>>> vm.update_view_data()
>>> # Update the config and summary properties
... | python | def update_view_data(self, properties=None):
"""Update the local object from the server-side object.
>>> vm = VirtualMachine.find_one(client, filter={"name": "genesis"})
>>> # Update all properties
>>> vm.update_view_data()
>>> # Update the config and summary properties
... | [
"def",
"update_view_data",
"(",
"self",
",",
"properties",
"=",
"None",
")",
":",
"if",
"properties",
"is",
"None",
":",
"properties",
"=",
"[",
"]",
"logger",
".",
"info",
"(",
"\"Updating view data for object of type %s\"",
",",
"self",
".",
"_mo_ref",
".",
... | Update the local object from the server-side object.
>>> vm = VirtualMachine.find_one(client, filter={"name": "genesis"})
>>> # Update all properties
>>> vm.update_view_data()
>>> # Update the config and summary properties
>>> vm.update_view_data(properties=["config", "s... | [
"Update",
"the",
"local",
"object",
"from",
"the",
"server",
"-",
"side",
"object",
".",
">>>",
"vm",
"=",
"VirtualMachine",
".",
"find_one",
"(",
"client",
"filter",
"=",
"{",
"name",
":",
"genesis",
"}",
")",
">>>",
"#",
"Update",
"all",
"properties",
... | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/__init__.py#L179-L224 |
psphere-project/psphere | psphere/__init__.py | ManagedObject.preload | def preload(self, name, properties=None):
"""Pre-loads the requested properties for each object in the "name"
attribute.
:param name: The name of the attribute containing the list to
preload.
:type name: str
:param properties: The properties to preload on the objects or ... | python | def preload(self, name, properties=None):
"""Pre-loads the requested properties for each object in the "name"
attribute.
:param name: The name of the attribute containing the list to
preload.
:type name: str
:param properties: The properties to preload on the objects or ... | [
"def",
"preload",
"(",
"self",
",",
"name",
",",
"properties",
"=",
"None",
")",
":",
"if",
"properties",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"You must specify some properties to preload. To\"",
"\" preload all properties use the string \\\"all\\\".\"",
")",
... | Pre-loads the requested properties for each object in the "name"
attribute.
:param name: The name of the attribute containing the list to
preload.
:type name: str
:param properties: The properties to preload on the objects or the
string all to preload all properties.
... | [
"Pre",
"-",
"loads",
"the",
"requested",
"properties",
"for",
"each",
"object",
"in",
"the",
"name",
"attribute",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/__init__.py#L226-L258 |
psphere-project/psphere | psphere/__init__.py | ManagedObject._set_view_data | def _set_view_data(self, object_content):
"""Update the local object from the passed in object_content."""
# A debugging convenience, allows inspection of the object_content
# that was used to create the object
logger.info("Setting view data for a %s", self.__class__)
self._objec... | python | def _set_view_data(self, object_content):
"""Update the local object from the passed in object_content."""
# A debugging convenience, allows inspection of the object_content
# that was used to create the object
logger.info("Setting view data for a %s", self.__class__)
self._objec... | [
"def",
"_set_view_data",
"(",
"self",
",",
"object_content",
")",
":",
"# A debugging convenience, allows inspection of the object_content",
"# that was used to create the object",
"logger",
".",
"info",
"(",
"\"Setting view data for a %s\"",
",",
"self",
".",
"__class__",
")",... | Update the local object from the passed in object_content. | [
"Update",
"the",
"local",
"object",
"from",
"the",
"passed",
"in",
"object_content",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/__init__.py#L260-L310 |
bmwcarit/zubbi | zubbi/scraper/main.py | _initialize_repo_cache | def _initialize_repo_cache():
"""Initialize the repository cache used for scraping.
Retrieves a list of repositories with their provider and last scraping time
from Elasticsearch.
This list can be used to check which repos need to be scraped (e.g. after
a specific amount of time).
"""
LOGGE... | python | def _initialize_repo_cache():
"""Initialize the repository cache used for scraping.
Retrieves a list of repositories with their provider and last scraping time
from Elasticsearch.
This list can be used to check which repos need to be scraped (e.g. after
a specific amount of time).
"""
LOGGE... | [
"def",
"_initialize_repo_cache",
"(",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"Initializing repository cache\"",
")",
"# Initialize Repo Cache",
"repo_cache",
"=",
"{",
"}",
"# Get all repos from Elasticsearch",
"for",
"hit",
"in",
"GitRepo",
".",
"search",
"(",
")",
... | Initialize the repository cache used for scraping.
Retrieves a list of repositories with their provider and last scraping time
from Elasticsearch.
This list can be used to check which repos need to be scraped (e.g. after
a specific amount of time). | [
"Initialize",
"the",
"repository",
"cache",
"used",
"for",
"scraping",
"."
] | train | https://github.com/bmwcarit/zubbi/blob/b99dfd6113c0351f13876f4172648c2eb63468ba/zubbi/scraper/main.py#L105-L125 |
psphere-project/psphere | examples/query_supported_features.py | main | def main(options):
"""Obtains supported features from the license manager"""
client = Client(server=options.server, username=options.username,
password=options.password)
print('Successfully connected to %s' % client.server)
lm_info = client.sc.licenseManager.QuerySupportedFeatures()
... | python | def main(options):
"""Obtains supported features from the license manager"""
client = Client(server=options.server, username=options.username,
password=options.password)
print('Successfully connected to %s' % client.server)
lm_info = client.sc.licenseManager.QuerySupportedFeatures()
... | [
"def",
"main",
"(",
"options",
")",
":",
"client",
"=",
"Client",
"(",
"server",
"=",
"options",
".",
"server",
",",
"username",
"=",
"options",
".",
"username",
",",
"password",
"=",
"options",
".",
"password",
")",
"print",
"(",
"'Successfully connected ... | Obtains supported features from the license manager | [
"Obtains",
"supported",
"features",
"from",
"the",
"license",
"manager"
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/examples/query_supported_features.py#L21-L30 |
pyQode/pyqode.core | pyqode/core/managers/modes.py | ModesManager.append | def append(self, mode):
"""
Adds a mode to the editor.
:param mode: The mode instance to append.
"""
_logger().log(5, 'adding mode %r', mode.name)
self._modes[mode.name] = mode
mode.on_install(self.editor)
return mode | python | def append(self, mode):
"""
Adds a mode to the editor.
:param mode: The mode instance to append.
"""
_logger().log(5, 'adding mode %r', mode.name)
self._modes[mode.name] = mode
mode.on_install(self.editor)
return mode | [
"def",
"append",
"(",
"self",
",",
"mode",
")",
":",
"_logger",
"(",
")",
".",
"log",
"(",
"5",
",",
"'adding mode %r'",
",",
"mode",
".",
"name",
")",
"self",
".",
"_modes",
"[",
"mode",
".",
"name",
"]",
"=",
"mode",
"mode",
".",
"on_install",
... | Adds a mode to the editor.
:param mode: The mode instance to append. | [
"Adds",
"a",
"mode",
"to",
"the",
"editor",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/managers/modes.py#L22-L32 |
pyQode/pyqode.core | pyqode/core/managers/modes.py | ModesManager.remove | def remove(self, name_or_klass):
"""
Removes a mode from the editor.
:param name_or_klass: The name (or class) of the mode to remove.
:returns: The removed mode.
"""
_logger().log(5, 'removing mode %r', name_or_klass)
mode = self.get(name_or_klass)
mode.o... | python | def remove(self, name_or_klass):
"""
Removes a mode from the editor.
:param name_or_klass: The name (or class) of the mode to remove.
:returns: The removed mode.
"""
_logger().log(5, 'removing mode %r', name_or_klass)
mode = self.get(name_or_klass)
mode.o... | [
"def",
"remove",
"(",
"self",
",",
"name_or_klass",
")",
":",
"_logger",
"(",
")",
".",
"log",
"(",
"5",
",",
"'removing mode %r'",
",",
"name_or_klass",
")",
"mode",
"=",
"self",
".",
"get",
"(",
"name_or_klass",
")",
"mode",
".",
"on_uninstall",
"(",
... | Removes a mode from the editor.
:param name_or_klass: The name (or class) of the mode to remove.
:returns: The removed mode. | [
"Removes",
"a",
"mode",
"from",
"the",
"editor",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/managers/modes.py#L34-L45 |
pyQode/pyqode.core | pyqode/core/managers/modes.py | ModesManager.get | def get(self, name_or_klass):
"""
Gets a mode by name (or class)
:param name_or_klass: The name or the class of the mode to get
:type name_or_klass: str or type
:rtype: pyqode.core.api.Mode
"""
if not isinstance(name_or_klass, str):
name_or_klass = na... | python | def get(self, name_or_klass):
"""
Gets a mode by name (or class)
:param name_or_klass: The name or the class of the mode to get
:type name_or_klass: str or type
:rtype: pyqode.core.api.Mode
"""
if not isinstance(name_or_klass, str):
name_or_klass = na... | [
"def",
"get",
"(",
"self",
",",
"name_or_klass",
")",
":",
"if",
"not",
"isinstance",
"(",
"name_or_klass",
",",
"str",
")",
":",
"name_or_klass",
"=",
"name_or_klass",
".",
"__name__",
"return",
"self",
".",
"_modes",
"[",
"name_or_klass",
"]"
] | Gets a mode by name (or class)
:param name_or_klass: The name or the class of the mode to get
:type name_or_klass: str or type
:rtype: pyqode.core.api.Mode | [
"Gets",
"a",
"mode",
"by",
"name",
"(",
"or",
"class",
")"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/managers/modes.py#L57-L67 |
pyQode/pyqode.core | pyqode/core/api/panel.py | Panel.on_install | def on_install(self, editor):
"""
Extends :meth:`pyqode.core.api.Mode.on_install` method to set the
editor instance as the parent widget.
.. warning:: Don't forget to call **super** if you override this
method!
:param editor: editor instance
:type editor: py... | python | def on_install(self, editor):
"""
Extends :meth:`pyqode.core.api.Mode.on_install` method to set the
editor instance as the parent widget.
.. warning:: Don't forget to call **super** if you override this
method!
:param editor: editor instance
:type editor: py... | [
"def",
"on_install",
"(",
"self",
",",
"editor",
")",
":",
"Mode",
".",
"on_install",
"(",
"self",
",",
"editor",
")",
"self",
".",
"setParent",
"(",
"editor",
")",
"self",
".",
"setPalette",
"(",
"QtWidgets",
".",
"QApplication",
".",
"instance",
"(",
... | Extends :meth:`pyqode.core.api.Mode.on_install` method to set the
editor instance as the parent widget.
.. warning:: Don't forget to call **super** if you override this
method!
:param editor: editor instance
:type editor: pyqode.core.api.CodeEdit | [
"Extends",
":",
"meth",
":",
"pyqode",
".",
"core",
".",
"api",
".",
"Mode",
".",
"on_install",
"method",
"to",
"set",
"the",
"editor",
"instance",
"as",
"the",
"parent",
"widget",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/api/panel.py#L74-L93 |
pyQode/pyqode.core | pyqode/core/api/panel.py | Panel.setVisible | def setVisible(self, visible):
"""
Shows/Hides the panel
Automatically call CodeEdit.refresh_panels.
:param visible: Visible state
"""
_logger().log(5, '%s visibility changed', self.name)
super(Panel, self).setVisible(visible)
if self.editor:
... | python | def setVisible(self, visible):
"""
Shows/Hides the panel
Automatically call CodeEdit.refresh_panels.
:param visible: Visible state
"""
_logger().log(5, '%s visibility changed', self.name)
super(Panel, self).setVisible(visible)
if self.editor:
... | [
"def",
"setVisible",
"(",
"self",
",",
"visible",
")",
":",
"_logger",
"(",
")",
".",
"log",
"(",
"5",
",",
"'%s visibility changed'",
",",
"self",
".",
"name",
")",
"super",
"(",
"Panel",
",",
"self",
")",
".",
"setVisible",
"(",
"visible",
")",
"if... | Shows/Hides the panel
Automatically call CodeEdit.refresh_panels.
:param visible: Visible state | [
"Shows",
"/",
"Hides",
"the",
"panel"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/api/panel.py#L106-L117 |
pyQode/pyqode.core | pyqode/core/managers/decorations.py | TextDecorationsManager.append | def append(self, decoration):
"""
Adds a text decoration on a CodeEdit instance
:param decoration: Text decoration to add
:type decoration: pyqode.core.api.TextDecoration
"""
if decoration not in self._decorations:
self._decorations.append(decoration)
... | python | def append(self, decoration):
"""
Adds a text decoration on a CodeEdit instance
:param decoration: Text decoration to add
:type decoration: pyqode.core.api.TextDecoration
"""
if decoration not in self._decorations:
self._decorations.append(decoration)
... | [
"def",
"append",
"(",
"self",
",",
"decoration",
")",
":",
"if",
"decoration",
"not",
"in",
"self",
".",
"_decorations",
":",
"self",
".",
"_decorations",
".",
"append",
"(",
"decoration",
")",
"self",
".",
"_decorations",
"=",
"sorted",
"(",
"self",
"."... | Adds a text decoration on a CodeEdit instance
:param decoration: Text decoration to add
:type decoration: pyqode.core.api.TextDecoration | [
"Adds",
"a",
"text",
"decoration",
"on",
"a",
"CodeEdit",
"instance"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/managers/decorations.py#L21-L34 |
pyQode/pyqode.core | pyqode/core/managers/decorations.py | TextDecorationsManager.remove | def remove(self, decoration):
"""
Removes a text decoration from the editor.
:param decoration: Text decoration to remove
:type decoration: pyqode.core.api.TextDecoration
"""
try:
self._decorations.remove(decoration)
self.editor.setExtraSelections... | python | def remove(self, decoration):
"""
Removes a text decoration from the editor.
:param decoration: Text decoration to remove
:type decoration: pyqode.core.api.TextDecoration
"""
try:
self._decorations.remove(decoration)
self.editor.setExtraSelections... | [
"def",
"remove",
"(",
"self",
",",
"decoration",
")",
":",
"try",
":",
"self",
".",
"_decorations",
".",
"remove",
"(",
"decoration",
")",
"self",
".",
"editor",
".",
"setExtraSelections",
"(",
"self",
".",
"_decorations",
")",
"return",
"True",
"except",
... | Removes a text decoration from the editor.
:param decoration: Text decoration to remove
:type decoration: pyqode.core.api.TextDecoration | [
"Removes",
"a",
"text",
"decoration",
"from",
"the",
"editor",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/managers/decorations.py#L36-L48 |
pyQode/pyqode.core | pyqode/core/managers/decorations.py | TextDecorationsManager.clear | def clear(self):
"""
Removes all text decoration from the editor.
"""
self._decorations[:] = []
try:
self.editor.setExtraSelections(self._decorations)
except RuntimeError:
pass | python | def clear(self):
"""
Removes all text decoration from the editor.
"""
self._decorations[:] = []
try:
self.editor.setExtraSelections(self._decorations)
except RuntimeError:
pass | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"_decorations",
"[",
":",
"]",
"=",
"[",
"]",
"try",
":",
"self",
".",
"editor",
".",
"setExtraSelections",
"(",
"self",
".",
"_decorations",
")",
"except",
"RuntimeError",
":",
"pass"
] | Removes all text decoration from the editor. | [
"Removes",
"all",
"text",
"decoration",
"from",
"the",
"editor",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/managers/decorations.py#L50-L59 |
pyQode/pyqode.core | pyqode/core/modes/zoom.py | ZoomMode._on_key_pressed | def _on_key_pressed(self, event):
"""
Resets editor font size to the default font size
:param event: wheelEvent
:type event: QKeyEvent
"""
if (int(event.modifiers()) & QtCore.Qt.ControlModifier > 0 and
not int(event.modifiers()) & QtCore.Qt.ShiftModifier)... | python | def _on_key_pressed(self, event):
"""
Resets editor font size to the default font size
:param event: wheelEvent
:type event: QKeyEvent
"""
if (int(event.modifiers()) & QtCore.Qt.ControlModifier > 0 and
not int(event.modifiers()) & QtCore.Qt.ShiftModifier)... | [
"def",
"_on_key_pressed",
"(",
"self",
",",
"event",
")",
":",
"if",
"(",
"int",
"(",
"event",
".",
"modifiers",
"(",
")",
")",
"&",
"QtCore",
".",
"Qt",
".",
"ControlModifier",
">",
"0",
"and",
"not",
"int",
"(",
"event",
".",
"modifiers",
"(",
")... | Resets editor font size to the default font size
:param event: wheelEvent
:type event: QKeyEvent | [
"Resets",
"editor",
"font",
"size",
"to",
"the",
"default",
"font",
"size"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/zoom.py#L55-L72 |
pyQode/pyqode.core | pyqode/core/modes/zoom.py | ZoomMode._on_wheel_event | def _on_wheel_event(self, event):
"""
Increments or decrements editor fonts settings on mouse wheel event
if ctrl modifier is on.
:param event: wheel event
:type event: QWheelEvent
"""
try:
delta = event.angleDelta().y()
except AttributeError:... | python | def _on_wheel_event(self, event):
"""
Increments or decrements editor fonts settings on mouse wheel event
if ctrl modifier is on.
:param event: wheel event
:type event: QWheelEvent
"""
try:
delta = event.angleDelta().y()
except AttributeError:... | [
"def",
"_on_wheel_event",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"delta",
"=",
"event",
".",
"angleDelta",
"(",
")",
".",
"y",
"(",
")",
"except",
"AttributeError",
":",
"# PyQt4/PySide",
"delta",
"=",
"event",
".",
"delta",
"(",
")",
"if",
... | Increments or decrements editor fonts settings on mouse wheel event
if ctrl modifier is on.
:param event: wheel event
:type event: QWheelEvent | [
"Increments",
"or",
"decrements",
"editor",
"fonts",
"settings",
"on",
"mouse",
"wheel",
"event",
"if",
"ctrl",
"modifier",
"is",
"on",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/zoom.py#L74-L93 |
pyQode/pyqode.core | pyqode/core/widgets/interactive.py | InteractiveConsole.set_writer | def set_writer(self, writer):
"""
Changes the writer function to handle writing to the text edit.
A writer function must have the following prototype:
.. code-block:: python
def write(text_edit, text, color)
:param writer: write function as described above.
... | python | def set_writer(self, writer):
"""
Changes the writer function to handle writing to the text edit.
A writer function must have the following prototype:
.. code-block:: python
def write(text_edit, text, color)
:param writer: write function as described above.
... | [
"def",
"set_writer",
"(",
"self",
",",
"writer",
")",
":",
"if",
"self",
".",
"_writer",
"!=",
"writer",
"and",
"self",
".",
"_writer",
":",
"self",
".",
"_writer",
"=",
"None",
"if",
"writer",
":",
"self",
".",
"_writer",
"=",
"writer"
] | Changes the writer function to handle writing to the text edit.
A writer function must have the following prototype:
.. code-block:: python
def write(text_edit, text, color)
:param writer: write function as described above. | [
"Changes",
"the",
"writer",
"function",
"to",
"handle",
"writing",
"to",
"the",
"text",
"edit",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/interactive.py#L98-L113 |
pyQode/pyqode.core | pyqode/core/widgets/interactive.py | InteractiveConsole.start_process | def start_process(self, process, args=None, cwd=None, env=None):
"""
Starts a process interactively.
:param process: Process to run
:type process: str
:param args: List of arguments (list of str)
:type args: list
:param cwd: Working directory
:type cwd:... | python | def start_process(self, process, args=None, cwd=None, env=None):
"""
Starts a process interactively.
:param process: Process to run
:type process: str
:param args: List of arguments (list of str)
:type args: list
:param cwd: Working directory
:type cwd:... | [
"def",
"start_process",
"(",
"self",
",",
"process",
",",
"args",
"=",
"None",
",",
"cwd",
"=",
"None",
",",
"env",
"=",
"None",
")",
":",
"self",
".",
"setReadOnly",
"(",
"False",
")",
"if",
"env",
"is",
"None",
":",
"env",
"=",
"{",
"}",
"if",
... | Starts a process interactively.
:param process: Process to run
:type process: str
:param args: List of arguments (list of str)
:type args: list
:param cwd: Working directory
:type cwd: str
:param env: environment variables (dict). | [
"Starts",
"a",
"process",
"interactively",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/interactive.py#L271-L318 |
pyQode/pyqode.core | pyqode/core/widgets/interactive.py | InteractiveConsole.stop_process | def stop_process(self):
"""
Stop the process (by killing it).
"""
if self.process is not None:
self._user_stop = True
self.process.kill()
self.setReadOnly(True)
self._running = False | python | def stop_process(self):
"""
Stop the process (by killing it).
"""
if self.process is not None:
self._user_stop = True
self.process.kill()
self.setReadOnly(True)
self._running = False | [
"def",
"stop_process",
"(",
"self",
")",
":",
"if",
"self",
".",
"process",
"is",
"not",
"None",
":",
"self",
".",
"_user_stop",
"=",
"True",
"self",
".",
"process",
".",
"kill",
"(",
")",
"self",
".",
"setReadOnly",
"(",
"True",
")",
"self",
".",
... | Stop the process (by killing it). | [
"Stop",
"the",
"process",
"(",
"by",
"killing",
"it",
")",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/interactive.py#L320-L328 |
pyQode/pyqode.core | pyqode/core/widgets/interactive.py | InteractiveConsole.write | def write(text_edit, text, color):
"""
Default write function. Move the cursor to the end and insert text with
the specified color.
:param text_edit: QInteractiveConsole instance
:type text_edit: pyqode.widgets.QInteractiveConsole
:param text: Text to write
:typ... | python | def write(text_edit, text, color):
"""
Default write function. Move the cursor to the end and insert text with
the specified color.
:param text_edit: QInteractiveConsole instance
:type text_edit: pyqode.widgets.QInteractiveConsole
:param text: Text to write
:typ... | [
"def",
"write",
"(",
"text_edit",
",",
"text",
",",
"color",
")",
":",
"try",
":",
"text_edit",
".",
"moveCursor",
"(",
"QTextCursor",
".",
"End",
")",
"text_edit",
".",
"setTextColor",
"(",
"color",
")",
"text_edit",
".",
"insertPlainText",
"(",
"text",
... | Default write function. Move the cursor to the end and insert text with
the specified color.
:param text_edit: QInteractiveConsole instance
:type text_edit: pyqode.widgets.QInteractiveConsole
:param text: Text to write
:type text: str
:param color: Desired text color
... | [
"Default",
"write",
"function",
".",
"Move",
"the",
"cursor",
"to",
"the",
"end",
"and",
"insert",
"text",
"with",
"the",
"specified",
"color",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/interactive.py#L418-L438 |
pyQode/pyqode.core | pyqode/core/widgets/interactive.py | InteractiveConsole.apply_color_scheme | def apply_color_scheme(self, color_scheme):
"""
Apply a pygments color scheme to the console.
As there is not a 1 to 1 mapping between color scheme formats and
console formats, we decided to make the following mapping (it usually
looks good for most of the available pygments sty... | python | def apply_color_scheme(self, color_scheme):
"""
Apply a pygments color scheme to the console.
As there is not a 1 to 1 mapping between color scheme formats and
console formats, we decided to make the following mapping (it usually
looks good for most of the available pygments sty... | [
"def",
"apply_color_scheme",
"(",
"self",
",",
"color_scheme",
")",
":",
"self",
".",
"stdout_color",
"=",
"color_scheme",
".",
"formats",
"[",
"'normal'",
"]",
".",
"foreground",
"(",
")",
".",
"color",
"(",
")",
"self",
".",
"stdin_color",
"=",
"color_sc... | Apply a pygments color scheme to the console.
As there is not a 1 to 1 mapping between color scheme formats and
console formats, we decided to make the following mapping (it usually
looks good for most of the available pygments styles):
- stdout_color = normal color
- s... | [
"Apply",
"a",
"pygments",
"color",
"scheme",
"to",
"the",
"console",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/interactive.py#L440-L465 |
pyQode/pyqode.core | pyqode/core/api/encodings.py | convert_to_codec_key | def convert_to_codec_key(value):
"""
Normalize code key value (encoding codecs must be lower case and must
not contain any dashes).
:param value: value to convert.
"""
if not value:
# fallback to utf-8
value = 'UTF-8'
# UTF-8 -> utf_8
converted = value.replace('-', '_').... | python | def convert_to_codec_key(value):
"""
Normalize code key value (encoding codecs must be lower case and must
not contain any dashes).
:param value: value to convert.
"""
if not value:
# fallback to utf-8
value = 'UTF-8'
# UTF-8 -> utf_8
converted = value.replace('-', '_').... | [
"def",
"convert_to_codec_key",
"(",
"value",
")",
":",
"if",
"not",
"value",
":",
"# fallback to utf-8",
"value",
"=",
"'UTF-8'",
"# UTF-8 -> utf_8",
"converted",
"=",
"value",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
".",
"lower",
"(",
")",
"# fix some ... | Normalize code key value (encoding codecs must be lower case and must
not contain any dashes).
:param value: value to convert. | [
"Normalize",
"code",
"key",
"value",
"(",
"encoding",
"codecs",
"must",
"be",
"lower",
"case",
"and",
"must",
"not",
"contain",
"any",
"dashes",
")",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/api/encodings.py#L98-L148 |
pyQode/pyqode.core | pyqode/core/api/folding.py | FoldDetector.process_block | def process_block(self, current_block, previous_block, text):
"""
Processes a block and setup its folding info.
This method call ``detect_fold_level`` and handles most of the tricky
corner cases so that all you have to do is focus on getting the proper
fold level foreach meaning... | python | def process_block(self, current_block, previous_block, text):
"""
Processes a block and setup its folding info.
This method call ``detect_fold_level`` and handles most of the tricky
corner cases so that all you have to do is focus on getting the proper
fold level foreach meaning... | [
"def",
"process_block",
"(",
"self",
",",
"current_block",
",",
"previous_block",
",",
"text",
")",
":",
"prev_fold_level",
"=",
"TextBlockHelper",
".",
"get_fold_lvl",
"(",
"previous_block",
")",
"if",
"text",
".",
"strip",
"(",
")",
"==",
"''",
":",
"# bla... | Processes a block and setup its folding info.
This method call ``detect_fold_level`` and handles most of the tricky
corner cases so that all you have to do is focus on getting the proper
fold level foreach meaningful block, skipping the blank ones.
:param current_block: current block t... | [
"Processes",
"a",
"block",
"and",
"setup",
"its",
"folding",
"info",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/api/folding.py#L66-L118 |
pyQode/pyqode.core | pyqode/core/api/folding.py | IndentFoldDetector.detect_fold_level | def detect_fold_level(self, prev_block, block):
"""
Detects fold level by looking at the block indentation.
:param prev_block: previous text block
:param block: current block to highlight
"""
text = block.text()
# round down to previous indentation guide to ensur... | python | def detect_fold_level(self, prev_block, block):
"""
Detects fold level by looking at the block indentation.
:param prev_block: previous text block
:param block: current block to highlight
"""
text = block.text()
# round down to previous indentation guide to ensur... | [
"def",
"detect_fold_level",
"(",
"self",
",",
"prev_block",
",",
"block",
")",
":",
"text",
"=",
"block",
".",
"text",
"(",
")",
"# round down to previous indentation guide to ensure contiguous block",
"# fold level evolution.",
"return",
"(",
"len",
"(",
"text",
")",... | Detects fold level by looking at the block indentation.
:param prev_block: previous text block
:param block: current block to highlight | [
"Detects",
"fold",
"level",
"by",
"looking",
"at",
"the",
"block",
"indentation",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/api/folding.py#L143-L153 |
GoogleCloudPlatform/python-repo-tools | gcp_devrel/tools/pylint.py | read_config | def read_config(contents):
"""Reads pylintrc config into native ConfigParser object.
Args:
contents (str): The contents of the file containing the INI config.
Returns:
ConfigParser.ConfigParser: The parsed configuration.
"""
file_obj = io.StringIO(contents)
config = six.moves.c... | python | def read_config(contents):
"""Reads pylintrc config into native ConfigParser object.
Args:
contents (str): The contents of the file containing the INI config.
Returns:
ConfigParser.ConfigParser: The parsed configuration.
"""
file_obj = io.StringIO(contents)
config = six.moves.c... | [
"def",
"read_config",
"(",
"contents",
")",
":",
"file_obj",
"=",
"io",
".",
"StringIO",
"(",
"contents",
")",
"config",
"=",
"six",
".",
"moves",
".",
"configparser",
".",
"ConfigParser",
"(",
")",
"config",
".",
"readfp",
"(",
"file_obj",
")",
"return"... | Reads pylintrc config into native ConfigParser object.
Args:
contents (str): The contents of the file containing the INI config.
Returns:
ConfigParser.ConfigParser: The parsed configuration. | [
"Reads",
"pylintrc",
"config",
"into",
"native",
"ConfigParser",
"object",
"."
] | train | https://github.com/GoogleCloudPlatform/python-repo-tools/blob/87422ba91814529848a2b8bf8be4294283a3e041/gcp_devrel/tools/pylint.py#L113-L125 |
GoogleCloudPlatform/python-repo-tools | gcp_devrel/tools/pylint.py | load_local_config | def load_local_config(filename):
"""Loads the pylint.config.py file.
Args:
filename (str): The python file containing the local configuration.
Returns:
module: The loaded Python module.
"""
if not filename:
return imp.new_module('local_pylint_config')
module = imp.load_... | python | def load_local_config(filename):
"""Loads the pylint.config.py file.
Args:
filename (str): The python file containing the local configuration.
Returns:
module: The loaded Python module.
"""
if not filename:
return imp.new_module('local_pylint_config')
module = imp.load_... | [
"def",
"load_local_config",
"(",
"filename",
")",
":",
"if",
"not",
"filename",
":",
"return",
"imp",
".",
"new_module",
"(",
"'local_pylint_config'",
")",
"module",
"=",
"imp",
".",
"load_source",
"(",
"'local_pylint_config'",
",",
"filename",
")",
"return",
... | Loads the pylint.config.py file.
Args:
filename (str): The python file containing the local configuration.
Returns:
module: The loaded Python module. | [
"Loads",
"the",
"pylint",
".",
"config",
".",
"py",
"file",
"."
] | train | https://github.com/GoogleCloudPlatform/python-repo-tools/blob/87422ba91814529848a2b8bf8be4294283a3e041/gcp_devrel/tools/pylint.py#L128-L140 |
GoogleCloudPlatform/python-repo-tools | gcp_devrel/tools/pylint.py | determine_final_config | def determine_final_config(config_module):
"""Determines the final additions and replacements.
Combines the config module with the defaults.
Args:
config_module: The loaded local configuration module.
Returns:
Config: the final configuration.
"""
config = Config(
DEFAU... | python | def determine_final_config(config_module):
"""Determines the final additions and replacements.
Combines the config module with the defaults.
Args:
config_module: The loaded local configuration module.
Returns:
Config: the final configuration.
"""
config = Config(
DEFAU... | [
"def",
"determine_final_config",
"(",
"config_module",
")",
":",
"config",
"=",
"Config",
"(",
"DEFAULT_LIBRARY_RC_ADDITIONS",
",",
"DEFAULT_LIBRARY_RC_REPLACEMENTS",
",",
"DEFAULT_TEST_RC_ADDITIONS",
",",
"DEFAULT_TEST_RC_REPLACEMENTS",
")",
"for",
"field",
"in",
"config",... | Determines the final additions and replacements.
Combines the config module with the defaults.
Args:
config_module: The loaded local configuration module.
Returns:
Config: the final configuration. | [
"Determines",
"the",
"final",
"additions",
"and",
"replacements",
"."
] | train | https://github.com/GoogleCloudPlatform/python-repo-tools/blob/87422ba91814529848a2b8bf8be4294283a3e041/gcp_devrel/tools/pylint.py#L148-L167 |
GoogleCloudPlatform/python-repo-tools | gcp_devrel/tools/pylint.py | lint_fileset | def lint_fileset(*dirnames, **kwargs):
"""Lints a group of files using a given rcfile.
Keyword arguments are
* ``rc_filename`` (``str``): The name of the Pylint config RC file.
* ``description`` (``str``): A description of the files and configuration
currently being ru... | python | def lint_fileset(*dirnames, **kwargs):
"""Lints a group of files using a given rcfile.
Keyword arguments are
* ``rc_filename`` (``str``): The name of the Pylint config RC file.
* ``description`` (``str``): A description of the files and configuration
currently being ru... | [
"def",
"lint_fileset",
"(",
"*",
"dirnames",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"rc_filename",
"=",
"kwargs",
"[",
"'rc_filename'",
"]",
"description",
"=",
"kwargs",
"[",
"'description'",
"]",
"if",
"len",
"(",
"kwargs",
")",
"!=",
"2",
":... | Lints a group of files using a given rcfile.
Keyword arguments are
* ``rc_filename`` (``str``): The name of the Pylint config RC file.
* ``description`` (``str``): A description of the files and configuration
currently being run.
Args:
dirnames (tuple): Direct... | [
"Lints",
"a",
"group",
"of",
"files",
"using",
"a",
"given",
"rcfile",
"."
] | train | https://github.com/GoogleCloudPlatform/python-repo-tools/blob/87422ba91814529848a2b8bf8be4294283a3e041/gcp_devrel/tools/pylint.py#L188-L220 |
GoogleCloudPlatform/python-repo-tools | gcp_devrel/tools/pylint.py | make_rc | def make_rc(base_cfg, target_filename,
additions=None, replacements=None):
"""Combines a base rc and additions into single file.
Args:
base_cfg (ConfigParser.ConfigParser): The configuration we are
merging into.
target_filename (str): The filename where the new configura... | python | def make_rc(base_cfg, target_filename,
additions=None, replacements=None):
"""Combines a base rc and additions into single file.
Args:
base_cfg (ConfigParser.ConfigParser): The configuration we are
merging into.
target_filename (str): The filename where the new configura... | [
"def",
"make_rc",
"(",
"base_cfg",
",",
"target_filename",
",",
"additions",
"=",
"None",
",",
"replacements",
"=",
"None",
")",
":",
"# Set-up the mutable default values.",
"if",
"additions",
"is",
"None",
":",
"additions",
"=",
"{",
"}",
"if",
"replacements",
... | Combines a base rc and additions into single file.
Args:
base_cfg (ConfigParser.ConfigParser): The configuration we are
merging into.
target_filename (str): The filename where the new configuration
will be saved.
additions (dict): (Optional) The values added to the c... | [
"Combines",
"a",
"base",
"rc",
"and",
"additions",
"into",
"single",
"file",
"."
] | train | https://github.com/GoogleCloudPlatform/python-repo-tools/blob/87422ba91814529848a2b8bf8be4294283a3e041/gcp_devrel/tools/pylint.py#L223-L284 |
GoogleCloudPlatform/python-repo-tools | gcp_devrel/tools/pylint.py | run_command | def run_command(args):
"""Script entry point. Lints both sets of files."""
library_rc = 'pylintrc'
test_rc = 'pylintrc.test'
if os.path.exists(library_rc):
os.remove(library_rc)
if os.path.exists(test_rc):
os.remove(test_rc)
default_config = read_config(get_default_config())
... | python | def run_command(args):
"""Script entry point. Lints both sets of files."""
library_rc = 'pylintrc'
test_rc = 'pylintrc.test'
if os.path.exists(library_rc):
os.remove(library_rc)
if os.path.exists(test_rc):
os.remove(test_rc)
default_config = read_config(get_default_config())
... | [
"def",
"run_command",
"(",
"args",
")",
":",
"library_rc",
"=",
"'pylintrc'",
"test_rc",
"=",
"'pylintrc.test'",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"library_rc",
")",
":",
"os",
".",
"remove",
"(",
"library_rc",
")",
"if",
"os",
".",
"path",
... | Script entry point. Lints both sets of files. | [
"Script",
"entry",
"point",
".",
"Lints",
"both",
"sets",
"of",
"files",
"."
] | train | https://github.com/GoogleCloudPlatform/python-repo-tools/blob/87422ba91814529848a2b8bf8be4294283a3e041/gcp_devrel/tools/pylint.py#L287-L312 |
psphere-project/psphere | psphere/client.py | HTTPSClientContextTransport.u2open | def u2open(self, u2request):
"""
Open a connection.
@param u2request: A urllib2 request.
@type u2request: urllib2.Requet.
@return: The opened file-like urllib2 object.
@rtype: fp
"""
tm = self.options.timeout
url = build_opener(HTTPSClientAuthHandl... | python | def u2open(self, u2request):
"""
Open a connection.
@param u2request: A urllib2 request.
@type u2request: urllib2.Requet.
@return: The opened file-like urllib2 object.
@rtype: fp
"""
tm = self.options.timeout
url = build_opener(HTTPSClientAuthHandl... | [
"def",
"u2open",
"(",
"self",
",",
"u2request",
")",
":",
"tm",
"=",
"self",
".",
"options",
".",
"timeout",
"url",
"=",
"build_opener",
"(",
"HTTPSClientAuthHandler",
"(",
"self",
".",
"context",
")",
")",
"if",
"self",
".",
"u2ver",
"(",
")",
"<",
... | Open a connection.
@param u2request: A urllib2 request.
@type u2request: urllib2.Requet.
@return: The opened file-like urllib2 object.
@rtype: fp | [
"Open",
"a",
"connection",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L69-L83 |
psphere-project/psphere | psphere/client.py | Client.login | def login(self, username=None, password=None):
"""Login to a vSphere server.
>>> client.login(username='Administrator', password='strongpass')
:param username: The username to authenticate as.
:type username: str
:param password: The password to authenticate with.
:type... | python | def login(self, username=None, password=None):
"""Login to a vSphere server.
>>> client.login(username='Administrator', password='strongpass')
:param username: The username to authenticate as.
:type username: str
:param password: The password to authenticate with.
:type... | [
"def",
"login",
"(",
"self",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"if",
"username",
"is",
"None",
":",
"username",
"=",
"self",
".",
"username",
"if",
"password",
"is",
"None",
":",
"password",
"=",
"self",
".",
"pass... | Login to a vSphere server.
>>> client.login(username='Administrator', password='strongpass')
:param username: The username to authenticate as.
:type username: str
:param password: The password to authenticate with.
:type password: str | [
"Login",
"to",
"a",
"vSphere",
"server",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L170-L186 |
psphere-project/psphere | psphere/client.py | Client.logout | def logout(self):
"""Logout of a vSphere server."""
if self._logged_in is True:
self.si.flush_cache()
self.sc.sessionManager.Logout()
self._logged_in = False | python | def logout(self):
"""Logout of a vSphere server."""
if self._logged_in is True:
self.si.flush_cache()
self.sc.sessionManager.Logout()
self._logged_in = False | [
"def",
"logout",
"(",
"self",
")",
":",
"if",
"self",
".",
"_logged_in",
"is",
"True",
":",
"self",
".",
"si",
".",
"flush_cache",
"(",
")",
"self",
".",
"sc",
".",
"sessionManager",
".",
"Logout",
"(",
")",
"self",
".",
"_logged_in",
"=",
"False"
] | Logout of a vSphere server. | [
"Logout",
"of",
"a",
"vSphere",
"server",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L188-L193 |
psphere-project/psphere | psphere/client.py | Client.invoke | def invoke(self, method, _this, **kwargs):
"""Invoke a method on the server.
>>> client.invoke('CurrentTime', client.si)
:param method: The method to invoke, as found in the SDK.
:type method: str
:param _this: The managed object reference against which to invoke \
the ... | python | def invoke(self, method, _this, **kwargs):
"""Invoke a method on the server.
>>> client.invoke('CurrentTime', client.si)
:param method: The method to invoke, as found in the SDK.
:type method: str
:param _this: The managed object reference against which to invoke \
the ... | [
"def",
"invoke",
"(",
"self",
",",
"method",
",",
"_this",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"(",
"self",
".",
"_logged_in",
"is",
"False",
"and",
"method",
"not",
"in",
"[",
"\"Login\"",
",",
"\"RetrieveServiceContent\"",
"]",
")",
":",
"logger... | Invoke a method on the server.
>>> client.invoke('CurrentTime', client.si)
:param method: The method to invoke, as found in the SDK.
:type method: str
:param _this: The managed object reference against which to invoke \
the method.
:type _this: ManagedObject
:pa... | [
"Invoke",
"a",
"method",
"on",
"the",
"server",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L195-L239 |
psphere-project/psphere | psphere/client.py | Client._mor_to_pobject | def _mor_to_pobject(self, mo_ref):
"""Converts a MOR to a psphere object."""
kls = classmapper(mo_ref._type)
new_object = kls(mo_ref, self)
return new_object | python | def _mor_to_pobject(self, mo_ref):
"""Converts a MOR to a psphere object."""
kls = classmapper(mo_ref._type)
new_object = kls(mo_ref, self)
return new_object | [
"def",
"_mor_to_pobject",
"(",
"self",
",",
"mo_ref",
")",
":",
"kls",
"=",
"classmapper",
"(",
"mo_ref",
".",
"_type",
")",
"new_object",
"=",
"kls",
"(",
"mo_ref",
",",
"self",
")",
"return",
"new_object"
] | Converts a MOR to a psphere object. | [
"Converts",
"a",
"MOR",
"to",
"a",
"psphere",
"object",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L241-L245 |
psphere-project/psphere | psphere/client.py | Client._marshal | def _marshal(self, obj):
"""Walks an object and marshals any psphere object into MORs."""
logger.debug("Checking if %s needs to be marshalled", obj)
if isinstance(obj, ManagedObject):
logger.debug("obj is a psphere object, converting to MOR")
return obj._mo_ref
i... | python | def _marshal(self, obj):
"""Walks an object and marshals any psphere object into MORs."""
logger.debug("Checking if %s needs to be marshalled", obj)
if isinstance(obj, ManagedObject):
logger.debug("obj is a psphere object, converting to MOR")
return obj._mo_ref
i... | [
"def",
"_marshal",
"(",
"self",
",",
"obj",
")",
":",
"logger",
".",
"debug",
"(",
"\"Checking if %s needs to be marshalled\"",
",",
"obj",
")",
"if",
"isinstance",
"(",
"obj",
",",
"ManagedObject",
")",
":",
"logger",
".",
"debug",
"(",
"\"obj is a psphere ob... | Walks an object and marshals any psphere object into MORs. | [
"Walks",
"an",
"object",
"and",
"marshals",
"any",
"psphere",
"object",
"into",
"MORs",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L247-L273 |
psphere-project/psphere | psphere/client.py | Client._unmarshal | def _unmarshal(self, obj):
"""Walks an object and unmarshals any MORs into psphere objects."""
if isinstance(obj, suds.sudsobject.Object) is False:
logger.debug("%s is not a suds instance, skipping", obj)
return obj
logger.debug("Processing:")
logger.debug(obj)
... | python | def _unmarshal(self, obj):
"""Walks an object and unmarshals any MORs into psphere objects."""
if isinstance(obj, suds.sudsobject.Object) is False:
logger.debug("%s is not a suds instance, skipping", obj)
return obj
logger.debug("Processing:")
logger.debug(obj)
... | [
"def",
"_unmarshal",
"(",
"self",
",",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"suds",
".",
"sudsobject",
".",
"Object",
")",
"is",
"False",
":",
"logger",
".",
"debug",
"(",
"\"%s is not a suds instance, skipping\"",
",",
"obj",
")",
"return... | Walks an object and unmarshals any MORs into psphere objects. | [
"Walks",
"an",
"object",
"and",
"unmarshals",
"any",
"MORs",
"into",
"psphere",
"objects",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L275-L324 |
psphere-project/psphere | psphere/client.py | Client.create | def create(self, type_, **kwargs):
"""Create a SOAP object of the requested type.
>>> client.create('VirtualE1000')
:param type_: The type of SOAP object to create.
:type type_: str
:param kwargs: TODO
:type kwargs: TODO
"""
obj = self.factory.create("n... | python | def create(self, type_, **kwargs):
"""Create a SOAP object of the requested type.
>>> client.create('VirtualE1000')
:param type_: The type of SOAP object to create.
:type type_: str
:param kwargs: TODO
:type kwargs: TODO
"""
obj = self.factory.create("n... | [
"def",
"create",
"(",
"self",
",",
"type_",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"self",
".",
"factory",
".",
"create",
"(",
"\"ns0:%s\"",
"%",
"type_",
")",
"for",
"key",
",",
"value",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"seta... | Create a SOAP object of the requested type.
>>> client.create('VirtualE1000')
:param type_: The type of SOAP object to create.
:type type_: str
:param kwargs: TODO
:type kwargs: TODO | [
"Create",
"a",
"SOAP",
"object",
"of",
"the",
"requested",
"type",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L326-L340 |
psphere-project/psphere | psphere/client.py | Client.get_view | def get_view(self, mo_ref, properties=None):
"""Get a view of a vSphere managed object.
:param mo_ref: The MOR to get a view of
:type mo_ref: ManagedObjectReference
:param properties: A list of properties to retrieve from the \
server
:type properties: list
... | python | def get_view(self, mo_ref, properties=None):
"""Get a view of a vSphere managed object.
:param mo_ref: The MOR to get a view of
:type mo_ref: ManagedObjectReference
:param properties: A list of properties to retrieve from the \
server
:type properties: list
... | [
"def",
"get_view",
"(",
"self",
",",
"mo_ref",
",",
"properties",
"=",
"None",
")",
":",
"# This maps the mo_ref into a psphere class and then instantiates it",
"kls",
"=",
"classmapper",
"(",
"mo_ref",
".",
"_type",
")",
"view",
"=",
"kls",
"(",
"mo_ref",
",",
... | Get a view of a vSphere managed object.
:param mo_ref: The MOR to get a view of
:type mo_ref: ManagedObjectReference
:param properties: A list of properties to retrieve from the \
server
:type properties: list
:returns: A view representing the ManagedObjectRefere... | [
"Get",
"a",
"view",
"of",
"a",
"vSphere",
"managed",
"object",
".",
":",
"param",
"mo_ref",
":",
"The",
"MOR",
"to",
"get",
"a",
"view",
"of",
":",
"type",
"mo_ref",
":",
"ManagedObjectReference",
":",
"param",
"properties",
":",
"A",
"list",
"of",
"pr... | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L354-L372 |
psphere-project/psphere | psphere/client.py | Client.get_views | def get_views(self, mo_refs, properties=None):
"""Get a list of local view's for multiple managed objects.
:param mo_refs: The list of ManagedObjectReference's that views are \
to be created for.
:type mo_refs: ManagedObjectReference
:param properties: The properties to retrieve... | python | def get_views(self, mo_refs, properties=None):
"""Get a list of local view's for multiple managed objects.
:param mo_refs: The list of ManagedObjectReference's that views are \
to be created for.
:type mo_refs: ManagedObjectReference
:param properties: The properties to retrieve... | [
"def",
"get_views",
"(",
"self",
",",
"mo_refs",
",",
"properties",
"=",
"None",
")",
":",
"property_specs",
"=",
"[",
"]",
"for",
"mo_ref",
"in",
"mo_refs",
":",
"property_spec",
"=",
"self",
".",
"create",
"(",
"'PropertySpec'",
")",
"property_spec",
"."... | Get a list of local view's for multiple managed objects.
:param mo_refs: The list of ManagedObjectReference's that views are \
to be created for.
:type mo_refs: ManagedObjectReference
:param properties: The properties to retrieve in the views.
:type properties: list
:ret... | [
"Get",
"a",
"list",
"of",
"local",
"view",
"s",
"for",
"multiple",
"managed",
"objects",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L374-L420 |
psphere-project/psphere | psphere/client.py | Client.get_search_filter_spec | def get_search_filter_spec(self, begin_entity, property_spec):
"""Build a PropertyFilterSpec capable of full inventory traversal.
By specifying all valid traversal specs we are creating a PFS that
can recursively select any object under the given entity.
:param begin_entity: Th... | python | def get_search_filter_spec(self, begin_entity, property_spec):
"""Build a PropertyFilterSpec capable of full inventory traversal.
By specifying all valid traversal specs we are creating a PFS that
can recursively select any object under the given entity.
:param begin_entity: Th... | [
"def",
"get_search_filter_spec",
"(",
"self",
",",
"begin_entity",
",",
"property_spec",
")",
":",
"# The selection spec for additional objects we want to filter",
"ss_strings",
"=",
"[",
"'resource_pool_traversal_spec'",
",",
"'resource_pool_vm_traversal_spec'",
",",
"'folder_tr... | Build a PropertyFilterSpec capable of full inventory traversal.
By specifying all valid traversal specs we are creating a PFS that
can recursively select any object under the given entity.
:param begin_entity: The place in the MOB to start the search.
:type begin_entity: Manage... | [
"Build",
"a",
"PropertyFilterSpec",
"capable",
"of",
"full",
"inventory",
"traversal",
".",
"By",
"specifying",
"all",
"valid",
"traversal",
"specs",
"we",
"are",
"creating",
"a",
"PFS",
"that",
"can",
"recursively",
"select",
"any",
"object",
"under",
"the",
... | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L422-L519 |
psphere-project/psphere | psphere/client.py | Client.invoke_task | def invoke_task(self, method, **kwargs):
"""Execute a \*_Task method and wait for it to complete.
:param method: The \*_Task method to invoke.
:type method: str
:param kwargs: The arguments to pass to the method.
:type kwargs: TODO
"""
# Don't execute me... | python | def invoke_task(self, method, **kwargs):
"""Execute a \*_Task method and wait for it to complete.
:param method: The \*_Task method to invoke.
:type method: str
:param kwargs: The arguments to pass to the method.
:type kwargs: TODO
"""
# Don't execute me... | [
"def",
"invoke_task",
"(",
"self",
",",
"method",
",",
"*",
"*",
"kwargs",
")",
":",
"# Don't execute methods which don't return a Task object",
"if",
"not",
"method",
".",
"endswith",
"(",
"'_Task'",
")",
":",
"logger",
".",
"error",
"(",
"'invoke_task can only b... | Execute a \*_Task method and wait for it to complete.
:param method: The \*_Task method to invoke.
:type method: str
:param kwargs: The arguments to pass to the method.
:type kwargs: TODO | [
"Execute",
"a",
"\\",
"*",
"_Task",
"method",
"and",
"wait",
"for",
"it",
"to",
"complete",
".",
":",
"param",
"method",
":",
"The",
"\\",
"*",
"_Task",
"method",
"to",
"invoke",
".",
":",
"type",
"method",
":",
"str",
":",
"param",
"kwargs",
":",
... | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L521-L550 |
psphere-project/psphere | psphere/client.py | Client.find_entity_views | def find_entity_views(self, view_type, begin_entity=None, properties=None):
"""Find all ManagedEntity's of the requested type.
:param view_type: The type of ManagedEntity's to find.
:type view_type: str
:param begin_entity: The MOR to start searching for the entity. \
The defaul... | python | def find_entity_views(self, view_type, begin_entity=None, properties=None):
"""Find all ManagedEntity's of the requested type.
:param view_type: The type of ManagedEntity's to find.
:type view_type: str
:param begin_entity: The MOR to start searching for the entity. \
The defaul... | [
"def",
"find_entity_views",
"(",
"self",
",",
"view_type",
",",
"begin_entity",
"=",
"None",
",",
"properties",
"=",
"None",
")",
":",
"if",
"properties",
"is",
"None",
":",
"properties",
"=",
"[",
"]",
"# Start the search at the root folder if no begin_entity was g... | Find all ManagedEntity's of the requested type.
:param view_type: The type of ManagedEntity's to find.
:type view_type: str
:param begin_entity: The MOR to start searching for the entity. \
The default is to start the search at the root folder.
:type begin_entity: ManagedObjectR... | [
"Find",
"all",
"ManagedEntity",
"s",
"of",
"the",
"requested",
"type",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L552-L588 |
psphere-project/psphere | psphere/client.py | Client.find_entity_view | def find_entity_view(self, view_type, begin_entity=None, filter={},
properties=None):
"""Find a ManagedEntity of the requested type.
Traverses the MOB looking for an entity matching the filter.
:param view_type: The type of ManagedEntity to find.
:type view_typ... | python | def find_entity_view(self, view_type, begin_entity=None, filter={},
properties=None):
"""Find a ManagedEntity of the requested type.
Traverses the MOB looking for an entity matching the filter.
:param view_type: The type of ManagedEntity to find.
:type view_typ... | [
"def",
"find_entity_view",
"(",
"self",
",",
"view_type",
",",
"begin_entity",
"=",
"None",
",",
"filter",
"=",
"{",
"}",
",",
"properties",
"=",
"None",
")",
":",
"if",
"properties",
"is",
"None",
":",
"properties",
"=",
"[",
"]",
"kls",
"=",
"classma... | Find a ManagedEntity of the requested type.
Traverses the MOB looking for an entity matching the filter.
:param view_type: The type of ManagedEntity to find.
:type view_type: str
:param begin_entity: The MOR to start searching for the entity. \
The default is to start the searc... | [
"Find",
"a",
"ManagedEntity",
"of",
"the",
"requested",
"type",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L590-L677 |
psphere-project/psphere | psphere/template.py | load_template | def load_template(name=None):
"""Loads a template of the specified name.
Templates are placed in the <template_dir> directory in YAML format with
a .yaml extension.
If no name is specified then the function will return the default
template (<template_dir>/default.yaml) if it exists.
:para... | python | def load_template(name=None):
"""Loads a template of the specified name.
Templates are placed in the <template_dir> directory in YAML format with
a .yaml extension.
If no name is specified then the function will return the default
template (<template_dir>/default.yaml) if it exists.
:para... | [
"def",
"load_template",
"(",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"\"default\"",
"logger",
".",
"info",
"(",
"\"Loading template with name %s\"",
",",
"name",
")",
"try",
":",
"template_file",
"=",
"open",
"(",
"\"%s... | Loads a template of the specified name.
Templates are placed in the <template_dir> directory in YAML format with
a .yaml extension.
If no name is specified then the function will return the default
template (<template_dir>/default.yaml) if it exists.
:param name: The name of the template to l... | [
"Loads",
"a",
"template",
"of",
"the",
"specified",
"name",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/template.py#L38-L66 |
psphere-project/psphere | psphere/template.py | list_templates | def list_templates():
"""Returns a list of all templates."""
templates = [f for f in glob.glob(os.path.join(template_path, '*.yaml'))]
return templates | python | def list_templates():
"""Returns a list of all templates."""
templates = [f for f in glob.glob(os.path.join(template_path, '*.yaml'))]
return templates | [
"def",
"list_templates",
"(",
")",
":",
"templates",
"=",
"[",
"f",
"for",
"f",
"in",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"template_path",
",",
"'*.yaml'",
")",
")",
"]",
"return",
"templates"
] | Returns a list of all templates. | [
"Returns",
"a",
"list",
"of",
"all",
"templates",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/template.py#L69-L72 |
psphere-project/psphere | examples/vmcreate.py | create_vm | def create_vm(client, name, compute_resource, datastore, disksize, nics,
memory, num_cpus, guest_id, host=None):
"""Create a virtual machine using the specified values.
:param name: The name of the VM to create.
:type name: str
:param compute_resource: The name of a ComputeResource in whi... | python | def create_vm(client, name, compute_resource, datastore, disksize, nics,
memory, num_cpus, guest_id, host=None):
"""Create a virtual machine using the specified values.
:param name: The name of the VM to create.
:type name: str
:param compute_resource: The name of a ComputeResource in whi... | [
"def",
"create_vm",
"(",
"client",
",",
"name",
",",
"compute_resource",
",",
"datastore",
",",
"disksize",
",",
"nics",
",",
"memory",
",",
"num_cpus",
",",
"guest_id",
",",
"host",
"=",
"None",
")",
":",
"print",
"(",
"\"Creating VM %s\"",
"%",
"name",
... | Create a virtual machine using the specified values.
:param name: The name of the VM to create.
:type name: str
:param compute_resource: The name of a ComputeResource in which to \
create the VM.
:type compute_resource: str
:param datastore: The name of the datastore on which to create ... | [
"Create",
"a",
"virtual",
"machine",
"using",
"the",
"specified",
"values",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/examples/vmcreate.py#L28-L180 |
psphere-project/psphere | examples/vmcreate.py | create_nic | def create_nic(client, target, nic):
"""Return a NIC spec"""
# Iterate through the networks and look for one matching
# the requested name
for network in target.network:
if network.name == nic["network_name"]:
net = network
break
else:
return None
# Succe... | python | def create_nic(client, target, nic):
"""Return a NIC spec"""
# Iterate through the networks and look for one matching
# the requested name
for network in target.network:
if network.name == nic["network_name"]:
net = network
break
else:
return None
# Succe... | [
"def",
"create_nic",
"(",
"client",
",",
"target",
",",
"nic",
")",
":",
"# Iterate through the networks and look for one matching",
"# the requested name",
"for",
"network",
"in",
"target",
".",
"network",
":",
"if",
"network",
".",
"name",
"==",
"nic",
"[",
"\"n... | Return a NIC spec | [
"Return",
"a",
"NIC",
"spec"
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/examples/vmcreate.py#L182-L217 |
psphere-project/psphere | examples/vmcreate.py | main | def main(name, options):
"""The main method for this script.
:param name: The name of the VM to create.
:type name: str
:param template_name: The name of the template to use for creating \
the VM.
:type template_name: str
"""
server = config._config_value("general", "server", o... | python | def main(name, options):
"""The main method for this script.
:param name: The name of the VM to create.
:type name: str
:param template_name: The name of the template to use for creating \
the VM.
:type template_name: str
"""
server = config._config_value("general", "server", o... | [
"def",
"main",
"(",
"name",
",",
"options",
")",
":",
"server",
"=",
"config",
".",
"_config_value",
"(",
"\"general\"",
",",
"\"server\"",
",",
"options",
".",
"server",
")",
"if",
"server",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"server must be... | The main method for this script.
:param name: The name of the VM to create.
:type name: str
:param template_name: The name of the template to use for creating \
the VM.
:type template_name: str | [
"The",
"main",
"method",
"for",
"this",
"script",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/examples/vmcreate.py#L254-L307 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemTreeView.add_ignore_patterns | def add_ignore_patterns(self, *patterns):
"""
Adds an ignore pattern to the list for ignore patterns.
Ignore patterns are used to filter out unwanted files or directories
from the file system model.
A pattern is a Unix shell-style wildcards. See :mod:`fnmatch` for a
dee... | python | def add_ignore_patterns(self, *patterns):
"""
Adds an ignore pattern to the list for ignore patterns.
Ignore patterns are used to filter out unwanted files or directories
from the file system model.
A pattern is a Unix shell-style wildcards. See :mod:`fnmatch` for a
dee... | [
"def",
"add_ignore_patterns",
"(",
"self",
",",
"*",
"patterns",
")",
":",
"for",
"ptrn",
"in",
"patterns",
":",
"if",
"isinstance",
"(",
"ptrn",
",",
"list",
")",
":",
"for",
"p",
"in",
"ptrn",
":",
"self",
".",
"_ignored_patterns",
".",
"append",
"("... | Adds an ignore pattern to the list for ignore patterns.
Ignore patterns are used to filter out unwanted files or directories
from the file system model.
A pattern is a Unix shell-style wildcards. See :mod:`fnmatch` for a
deeper explanation about the shell-style wildcards. | [
"Adds",
"an",
"ignore",
"pattern",
"to",
"the",
"list",
"for",
"ignore",
"patterns",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L176-L191 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemTreeView.set_context_menu | def set_context_menu(self, context_menu):
"""
Sets the context menu of the tree view.
:param context_menu: QMenu
"""
self.context_menu = context_menu
self.context_menu.tree_view = self
self.context_menu.init_actions()
for action in self.context_menu.actio... | python | def set_context_menu(self, context_menu):
"""
Sets the context menu of the tree view.
:param context_menu: QMenu
"""
self.context_menu = context_menu
self.context_menu.tree_view = self
self.context_menu.init_actions()
for action in self.context_menu.actio... | [
"def",
"set_context_menu",
"(",
"self",
",",
"context_menu",
")",
":",
"self",
".",
"context_menu",
"=",
"context_menu",
"self",
".",
"context_menu",
".",
"tree_view",
"=",
"self",
"self",
".",
"context_menu",
".",
"init_actions",
"(",
")",
"for",
"action",
... | Sets the context menu of the tree view.
:param context_menu: QMenu | [
"Sets",
"the",
"context",
"menu",
"of",
"the",
"tree",
"view",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L193-L203 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemTreeView.set_root_path | def set_root_path(self, path, hide_extra_columns=True):
"""
Sets the root path to watch
:param path: root path - str
:param hide_extra_columns: Hide extra column (size, paths,...)
"""
if not self.isVisible():
self._path_to_set = path
self._hide_ext... | python | def set_root_path(self, path, hide_extra_columns=True):
"""
Sets the root path to watch
:param path: root path - str
:param hide_extra_columns: Hide extra column (size, paths,...)
"""
if not self.isVisible():
self._path_to_set = path
self._hide_ext... | [
"def",
"set_root_path",
"(",
"self",
",",
"path",
",",
"hide_extra_columns",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"isVisible",
"(",
")",
":",
"self",
".",
"_path_to_set",
"=",
"path",
"self",
".",
"_hide_extra_colums",
"=",
"hide_extra_columns",
... | Sets the root path to watch
:param path: root path - str
:param hide_extra_columns: Hide extra column (size, paths,...) | [
"Sets",
"the",
"root",
"path",
"to",
"watch",
":",
"param",
"path",
":",
"root",
"path",
"-",
"str",
":",
"param",
"hide_extra_columns",
":",
"Hide",
"extra",
"column",
"(",
"size",
"paths",
"...",
")"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L205-L245 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemTreeView.filePath | def filePath(self, index):
"""
Gets the file path of the item at the specified ``index``.
:param index: item index - QModelIndex
:return: str
"""
return self._fs_model_source.filePath(
self._fs_model_proxy.mapToSource(index)) | python | def filePath(self, index):
"""
Gets the file path of the item at the specified ``index``.
:param index: item index - QModelIndex
:return: str
"""
return self._fs_model_source.filePath(
self._fs_model_proxy.mapToSource(index)) | [
"def",
"filePath",
"(",
"self",
",",
"index",
")",
":",
"return",
"self",
".",
"_fs_model_source",
".",
"filePath",
"(",
"self",
".",
"_fs_model_proxy",
".",
"mapToSource",
"(",
"index",
")",
")"
] | Gets the file path of the item at the specified ``index``.
:param index: item index - QModelIndex
:return: str | [
"Gets",
"the",
"file",
"path",
"of",
"the",
"item",
"at",
"the",
"specified",
"index",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L269-L277 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemTreeView.fileInfo | def fileInfo(self, index):
"""
Gets the file info of the item at the specified ``index``.
:param index: item index - QModelIndex
:return: QFileInfo
"""
return self._fs_model_source.fileInfo(
self._fs_model_proxy.mapToSource(index)) | python | def fileInfo(self, index):
"""
Gets the file info of the item at the specified ``index``.
:param index: item index - QModelIndex
:return: QFileInfo
"""
return self._fs_model_source.fileInfo(
self._fs_model_proxy.mapToSource(index)) | [
"def",
"fileInfo",
"(",
"self",
",",
"index",
")",
":",
"return",
"self",
".",
"_fs_model_source",
".",
"fileInfo",
"(",
"self",
".",
"_fs_model_proxy",
".",
"mapToSource",
"(",
"index",
")",
")"
] | Gets the file info of the item at the specified ``index``.
:param index: item index - QModelIndex
:return: QFileInfo | [
"Gets",
"the",
"file",
"info",
"of",
"the",
"item",
"at",
"the",
"specified",
"index",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L279-L287 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemHelper.copy_to_clipboard | def copy_to_clipboard(self, copy=True):
"""
Copies the selected items to the clipboard
:param copy: True to copy, False to cut.
"""
urls = self.selected_urls()
if not urls:
return
mime = self._UrlListMimeData(copy)
mime.set_list(urls)
c... | python | def copy_to_clipboard(self, copy=True):
"""
Copies the selected items to the clipboard
:param copy: True to copy, False to cut.
"""
urls = self.selected_urls()
if not urls:
return
mime = self._UrlListMimeData(copy)
mime.set_list(urls)
c... | [
"def",
"copy_to_clipboard",
"(",
"self",
",",
"copy",
"=",
"True",
")",
":",
"urls",
"=",
"self",
".",
"selected_urls",
"(",
")",
"if",
"not",
"urls",
":",
"return",
"mime",
"=",
"self",
".",
"_UrlListMimeData",
"(",
"copy",
")",
"mime",
".",
"set_list... | Copies the selected items to the clipboard
:param copy: True to copy, False to cut. | [
"Copies",
"the",
"selected",
"items",
"to",
"the",
"clipboard",
":",
"param",
"copy",
":",
"True",
"to",
"copy",
"False",
"to",
"cut",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L347-L358 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemHelper.selected_urls | def selected_urls(self):
"""
Gets the list of selected items file path (url)
"""
urls = []
debug('gettings urls')
for proxy_index in self.tree_view.selectedIndexes():
finfo = self.tree_view.fileInfo(proxy_index)
urls.append(finfo.canonicalFilePath(... | python | def selected_urls(self):
"""
Gets the list of selected items file path (url)
"""
urls = []
debug('gettings urls')
for proxy_index in self.tree_view.selectedIndexes():
finfo = self.tree_view.fileInfo(proxy_index)
urls.append(finfo.canonicalFilePath(... | [
"def",
"selected_urls",
"(",
"self",
")",
":",
"urls",
"=",
"[",
"]",
"debug",
"(",
"'gettings urls'",
")",
"for",
"proxy_index",
"in",
"self",
".",
"tree_view",
".",
"selectedIndexes",
"(",
")",
":",
"finfo",
"=",
"self",
".",
"tree_view",
".",
"fileInf... | Gets the list of selected items file path (url) | [
"Gets",
"the",
"list",
"of",
"selected",
"items",
"file",
"path",
"(",
"url",
")"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L360-L370 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemHelper.paste_from_clipboard | def paste_from_clipboard(self):
"""
Pastes files from clipboard.
"""
to = self.get_current_path()
if os.path.isfile(to):
to = os.path.abspath(os.path.join(to, os.pardir))
mime = QtWidgets.QApplication.clipboard().mimeData()
paste_operation = None
... | python | def paste_from_clipboard(self):
"""
Pastes files from clipboard.
"""
to = self.get_current_path()
if os.path.isfile(to):
to = os.path.abspath(os.path.join(to, os.pardir))
mime = QtWidgets.QApplication.clipboard().mimeData()
paste_operation = None
... | [
"def",
"paste_from_clipboard",
"(",
"self",
")",
":",
"to",
"=",
"self",
".",
"get_current_path",
"(",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"to",
")",
":",
"to",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"j... | Pastes files from clipboard. | [
"Pastes",
"files",
"from",
"clipboard",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L372-L389 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemHelper._paste | def _paste(self, sources, destination, copy):
"""
Copies the files listed in ``sources`` to destination. Source are
removed if copy is set to False.
"""
for src in sources:
debug('%s <%s> to <%s>' % (
'copying' if copy else 'cutting', src, destination)... | python | def _paste(self, sources, destination, copy):
"""
Copies the files listed in ``sources`` to destination. Source are
removed if copy is set to False.
"""
for src in sources:
debug('%s <%s> to <%s>' % (
'copying' if copy else 'cutting', src, destination)... | [
"def",
"_paste",
"(",
"self",
",",
"sources",
",",
"destination",
",",
"copy",
")",
":",
"for",
"src",
"in",
"sources",
":",
"debug",
"(",
"'%s <%s> to <%s>'",
"%",
"(",
"'copying'",
"if",
"copy",
"else",
"'cutting'",
",",
"src",
",",
"destination",
")",... | Copies the files listed in ``sources`` to destination. Source are
removed if copy is set to False. | [
"Copies",
"the",
"files",
"listed",
"in",
"sources",
"to",
"destination",
".",
"Source",
"are",
"removed",
"if",
"copy",
"is",
"set",
"to",
"False",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L391-L439 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemHelper._get_files | def _get_files(path):
"""
Returns the list of files contained in path (recursively).
"""
ret_val = []
for root, _, files in os.walk(path):
for f in files:
ret_val.append(os.path.join(root, f))
return ret_val | python | def _get_files(path):
"""
Returns the list of files contained in path (recursively).
"""
ret_val = []
for root, _, files in os.walk(path):
for f in files:
ret_val.append(os.path.join(root, f))
return ret_val | [
"def",
"_get_files",
"(",
"path",
")",
":",
"ret_val",
"=",
"[",
"]",
"for",
"root",
",",
"_",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"for",
"f",
"in",
"files",
":",
"ret_val",
".",
"append",
"(",
"os",
".",
"path",
".",
... | Returns the list of files contained in path (recursively). | [
"Returns",
"the",
"list",
"of",
"files",
"contained",
"in",
"path",
"(",
"recursively",
")",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L442-L450 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemHelper.delete | def delete(self):
"""
Deletes the selected items.
"""
urls = self.selected_urls()
rep = QtWidgets.QMessageBox.question(
self.tree_view, _('Confirm delete'),
_('Are you sure about deleting the selected files/directories?'),
QtWidgets.QMessageBox... | python | def delete(self):
"""
Deletes the selected items.
"""
urls = self.selected_urls()
rep = QtWidgets.QMessageBox.question(
self.tree_view, _('Confirm delete'),
_('Are you sure about deleting the selected files/directories?'),
QtWidgets.QMessageBox... | [
"def",
"delete",
"(",
"self",
")",
":",
"urls",
"=",
"self",
".",
"selected_urls",
"(",
")",
"rep",
"=",
"QtWidgets",
".",
"QMessageBox",
".",
"question",
"(",
"self",
".",
"tree_view",
",",
"_",
"(",
"'Confirm delete'",
")",
",",
"_",
"(",
"'Are you s... | Deletes the selected items. | [
"Deletes",
"the",
"selected",
"items",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L452-L481 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemHelper.get_current_path | def get_current_path(self):
"""
Gets the path of the currently selected item.
"""
path = self.tree_view.fileInfo(
self.tree_view.currentIndex()).filePath()
# https://github.com/pyQode/pyQode/issues/6
if not path:
path = self.tree_view.root_path
... | python | def get_current_path(self):
"""
Gets the path of the currently selected item.
"""
path = self.tree_view.fileInfo(
self.tree_view.currentIndex()).filePath()
# https://github.com/pyQode/pyQode/issues/6
if not path:
path = self.tree_view.root_path
... | [
"def",
"get_current_path",
"(",
"self",
")",
":",
"path",
"=",
"self",
".",
"tree_view",
".",
"fileInfo",
"(",
"self",
".",
"tree_view",
".",
"currentIndex",
"(",
")",
")",
".",
"filePath",
"(",
")",
"# https://github.com/pyQode/pyQode/issues/6",
"if",
"not",
... | Gets the path of the currently selected item. | [
"Gets",
"the",
"path",
"of",
"the",
"currently",
"selected",
"item",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L483-L492 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemHelper.copy_path_to_clipboard | def copy_path_to_clipboard(self):
"""
Copies the file path to the clipboard
"""
path = self.get_current_path()
QtWidgets.QApplication.clipboard().setText(path)
debug('path copied: %s' % path) | python | def copy_path_to_clipboard(self):
"""
Copies the file path to the clipboard
"""
path = self.get_current_path()
QtWidgets.QApplication.clipboard().setText(path)
debug('path copied: %s' % path) | [
"def",
"copy_path_to_clipboard",
"(",
"self",
")",
":",
"path",
"=",
"self",
".",
"get_current_path",
"(",
")",
"QtWidgets",
".",
"QApplication",
".",
"clipboard",
"(",
")",
".",
"setText",
"(",
"path",
")",
"debug",
"(",
"'path copied: %s'",
"%",
"path",
... | Copies the file path to the clipboard | [
"Copies",
"the",
"file",
"path",
"to",
"the",
"clipboard"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L494-L500 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemHelper.rename | def rename(self):
"""
Renames the selected item in the tree view
"""
src = self.get_current_path()
pardir, name = os.path.split(src)
new_name, status = QtWidgets.QInputDialog.getText(
self.tree_view, _('Rename '), _('New name:'),
QtWidgets.QLineEdi... | python | def rename(self):
"""
Renames the selected item in the tree view
"""
src = self.get_current_path()
pardir, name = os.path.split(src)
new_name, status = QtWidgets.QInputDialog.getText(
self.tree_view, _('Rename '), _('New name:'),
QtWidgets.QLineEdi... | [
"def",
"rename",
"(",
"self",
")",
":",
"src",
"=",
"self",
".",
"get_current_path",
"(",
")",
"pardir",
",",
"name",
"=",
"os",
".",
"path",
".",
"split",
"(",
"src",
")",
"new_name",
",",
"status",
"=",
"QtWidgets",
".",
"QInputDialog",
".",
"getTe... | Renames the selected item in the tree view | [
"Renames",
"the",
"selected",
"item",
"in",
"the",
"tree",
"view"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L502-L536 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemHelper.create_directory | def create_directory(self):
"""
Creates a directory under the selected directory (if the selected item
is a file, the parent directory is used).
"""
src = self.get_current_path()
name, status = QtWidgets.QInputDialog.getText(
self.tree_view, _('Create director... | python | def create_directory(self):
"""
Creates a directory under the selected directory (if the selected item
is a file, the parent directory is used).
"""
src = self.get_current_path()
name, status = QtWidgets.QInputDialog.getText(
self.tree_view, _('Create director... | [
"def",
"create_directory",
"(",
"self",
")",
":",
"src",
"=",
"self",
".",
"get_current_path",
"(",
")",
"name",
",",
"status",
"=",
"QtWidgets",
".",
"QInputDialog",
".",
"getText",
"(",
"self",
".",
"tree_view",
",",
"_",
"(",
"'Create directory'",
")",
... | Creates a directory under the selected directory (if the selected item
is a file, the parent directory is used). | [
"Creates",
"a",
"directory",
"under",
"the",
"selected",
"directory",
"(",
"if",
"the",
"selected",
"item",
"is",
"a",
"file",
"the",
"parent",
"directory",
"is",
"used",
")",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L538-L563 |
pyQode/pyqode.core | pyqode/core/widgets/filesystem_treeview.py | FileSystemHelper.create_file | def create_file(self):
"""
Creates a file under the current directory.
"""
src = self.get_current_path()
name, status = QtWidgets.QInputDialog.getText(
self.tree_view, _('Create new file'), _('File name:'),
QtWidgets.QLineEdit.Normal, '')
if status... | python | def create_file(self):
"""
Creates a file under the current directory.
"""
src = self.get_current_path()
name, status = QtWidgets.QInputDialog.getText(
self.tree_view, _('Create new file'), _('File name:'),
QtWidgets.QLineEdit.Normal, '')
if status... | [
"def",
"create_file",
"(",
"self",
")",
":",
"src",
"=",
"self",
".",
"get_current_path",
"(",
")",
"name",
",",
"status",
"=",
"QtWidgets",
".",
"QInputDialog",
".",
"getText",
"(",
"self",
".",
"tree_view",
",",
"_",
"(",
"'Create new file'",
")",
",",... | Creates a file under the current directory. | [
"Creates",
"a",
"file",
"under",
"the",
"current",
"directory",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/filesystem_treeview.py#L565-L592 |
pyQode/pyqode.core | pyqode/core/managers/file.py | FileManager.get_mimetype | def get_mimetype(path):
"""
Guesses the mime type of a file. If mime type cannot be detected, plain
text is assumed.
:param path: path of the file
:return: the corresponding mime type.
"""
filename = os.path.split(path)[1]
mimetype = mimetypes.guess_type(... | python | def get_mimetype(path):
"""
Guesses the mime type of a file. If mime type cannot be detected, plain
text is assumed.
:param path: path of the file
:return: the corresponding mime type.
"""
filename = os.path.split(path)[1]
mimetype = mimetypes.guess_type(... | [
"def",
"get_mimetype",
"(",
"path",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"[",
"1",
"]",
"mimetype",
"=",
"mimetypes",
".",
"guess_type",
"(",
"filename",
")",
"[",
"0",
"]",
"if",
"mimetype",
"is",
"None",
"... | Guesses the mime type of a file. If mime type cannot be detected, plain
text is assumed.
:param path: path of the file
:return: the corresponding mime type. | [
"Guesses",
"the",
"mime",
"type",
"of",
"a",
"file",
".",
"If",
"mime",
"type",
"cannot",
"be",
"detected",
"plain",
"text",
"is",
"assumed",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/managers/file.py#L186-L199 |
pyQode/pyqode.core | pyqode/core/managers/file.py | FileManager.open | def open(self, path, encoding=None, use_cached_encoding=True):
"""
Open a file and set its content on the editor widget.
pyqode does not try to guess encoding. It's up to the client code to
handle encodings. You can either use a charset detector to detect
encoding or rely on a s... | python | def open(self, path, encoding=None, use_cached_encoding=True):
"""
Open a file and set its content on the editor widget.
pyqode does not try to guess encoding. It's up to the client code to
handle encodings. You can either use a charset detector to detect
encoding or rely on a s... | [
"def",
"open",
"(",
"self",
",",
"path",
",",
"encoding",
"=",
"None",
",",
"use_cached_encoding",
"=",
"True",
")",
":",
"ret_val",
"=",
"False",
"if",
"encoding",
"is",
"None",
":",
"encoding",
"=",
"locale",
".",
"getpreferredencoding",
"(",
")",
"sel... | Open a file and set its content on the editor widget.
pyqode does not try to guess encoding. It's up to the client code to
handle encodings. You can either use a charset detector to detect
encoding or rely on a settings in your application. It is also up to
you to handle UnicodeDecodeEr... | [
"Open",
"a",
"file",
"and",
"set",
"its",
"content",
"on",
"the",
"editor",
"widget",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/managers/file.py#L201-L281 |
pyQode/pyqode.core | pyqode/core/managers/file.py | FileManager.reload | def reload(self, encoding):
"""
Reload the file with another encoding.
:param encoding: the new encoding to use to reload the file.
"""
assert os.path.exists(self.path)
self.open(self.path, encoding=encoding,
use_cached_encoding=False) | python | def reload(self, encoding):
"""
Reload the file with another encoding.
:param encoding: the new encoding to use to reload the file.
"""
assert os.path.exists(self.path)
self.open(self.path, encoding=encoding,
use_cached_encoding=False) | [
"def",
"reload",
"(",
"self",
",",
"encoding",
")",
":",
"assert",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
"self",
".",
"open",
"(",
"self",
".",
"path",
",",
"encoding",
"=",
"encoding",
",",
"use_cached_encoding",
"=",
"Fal... | Reload the file with another encoding.
:param encoding: the new encoding to use to reload the file. | [
"Reload",
"the",
"file",
"with",
"another",
"encoding",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/managers/file.py#L297-L305 |
pyQode/pyqode.core | pyqode/core/managers/file.py | FileManager.save | def save(self, path=None, encoding=None, fallback_encoding=None):
"""
Save the editor content to a file.
:param path: optional file path. Set it to None to save using the
current path (save), set a new path to save as.
:param encoding: optional encoding, will use th... | python | def save(self, path=None, encoding=None, fallback_encoding=None):
"""
Save the editor content to a file.
:param path: optional file path. Set it to None to save using the
current path (save), set a new path to save as.
:param encoding: optional encoding, will use th... | [
"def",
"save",
"(",
"self",
",",
"path",
"=",
"None",
",",
"encoding",
"=",
"None",
",",
"fallback_encoding",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"editor",
".",
"dirty",
"and",
"(",
"encoding",
"is",
"None",
"and",
"encoding",
"==",
"sel... | Save the editor content to a file.
:param path: optional file path. Set it to None to save using the
current path (save), set a new path to save as.
:param encoding: optional encoding, will use the current
file encoding if None.
:param fallback_enco... | [
"Save",
"the",
"editor",
"content",
"to",
"a",
"file",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/managers/file.py#L342-L425 |
pyQode/pyqode.core | pyqode/core/managers/file.py | FileManager.close | def close(self, clear=True):
"""
Close the file open in the editor:
- clear editor content
- reset file attributes to their default values
:param clear: True to clear the editor content. Default is True.
"""
Cache().set_cursor_position(
self.p... | python | def close(self, clear=True):
"""
Close the file open in the editor:
- clear editor content
- reset file attributes to their default values
:param clear: True to clear the editor content. Default is True.
"""
Cache().set_cursor_position(
self.p... | [
"def",
"close",
"(",
"self",
",",
"clear",
"=",
"True",
")",
":",
"Cache",
"(",
")",
".",
"set_cursor_position",
"(",
"self",
".",
"path",
",",
"self",
".",
"editor",
".",
"textCursor",
"(",
")",
".",
"position",
"(",
")",
")",
"self",
".",
"editor... | Close the file open in the editor:
- clear editor content
- reset file attributes to their default values
:param clear: True to clear the editor content. Default is True. | [
"Close",
"the",
"file",
"open",
"in",
"the",
"editor",
":",
"-",
"clear",
"editor",
"content",
"-",
"reset",
"file",
"attributes",
"to",
"their",
"default",
"values"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/managers/file.py#L427-L442 |
pyQode/pyqode.core | pyqode/core/modes/right_margin.py | RightMarginMode.on_state_changed | def on_state_changed(self, state):
"""
Connects/Disconnects to the painted event of the editor
:param state: Enable state
"""
if state:
self.editor.painted.connect(self._paint_margin)
self.editor.repaint()
else:
self.editor.painted.dis... | python | def on_state_changed(self, state):
"""
Connects/Disconnects to the painted event of the editor
:param state: Enable state
"""
if state:
self.editor.painted.connect(self._paint_margin)
self.editor.repaint()
else:
self.editor.painted.dis... | [
"def",
"on_state_changed",
"(",
"self",
",",
"state",
")",
":",
"if",
"state",
":",
"self",
".",
"editor",
".",
"painted",
".",
"connect",
"(",
"self",
".",
"_paint_margin",
")",
"self",
".",
"editor",
".",
"repaint",
"(",
")",
"else",
":",
"self",
"... | Connects/Disconnects to the painted event of the editor
:param state: Enable state | [
"Connects",
"/",
"Disconnects",
"to",
"the",
"painted",
"event",
"of",
"the",
"editor"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/right_margin.py#L59-L70 |
pyQode/pyqode.core | pyqode/core/modes/right_margin.py | RightMarginMode._paint_margin | def _paint_margin(self, event):
""" Paints the right margin after editor paint event. """
font = QtGui.QFont(self.editor.font_name, self.editor.font_size +
self.editor.zoom_level)
metrics = QtGui.QFontMetricsF(font)
pos = self._margin_pos
offset = self.... | python | def _paint_margin(self, event):
""" Paints the right margin after editor paint event. """
font = QtGui.QFont(self.editor.font_name, self.editor.font_size +
self.editor.zoom_level)
metrics = QtGui.QFontMetricsF(font)
pos = self._margin_pos
offset = self.... | [
"def",
"_paint_margin",
"(",
"self",
",",
"event",
")",
":",
"font",
"=",
"QtGui",
".",
"QFont",
"(",
"self",
".",
"editor",
".",
"font_name",
",",
"self",
".",
"editor",
".",
"font_size",
"+",
"self",
".",
"editor",
".",
"zoom_level",
")",
"metrics",
... | Paints the right margin after editor paint event. | [
"Paints",
"the",
"right",
"margin",
"after",
"editor",
"paint",
"event",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/right_margin.py#L72-L83 |
pyQode/pyqode.core | pyqode/core/modes/filewatcher.py | FileWatcherMode._update_mtime | def _update_mtime(self):
""" Updates modif time """
try:
self._mtime = os.path.getmtime(self.editor.file.path)
except OSError:
# file_path does not exists.
self._mtime = 0
self._timer.stop()
except (TypeError, AttributeError):
#... | python | def _update_mtime(self):
""" Updates modif time """
try:
self._mtime = os.path.getmtime(self.editor.file.path)
except OSError:
# file_path does not exists.
self._mtime = 0
self._timer.stop()
except (TypeError, AttributeError):
#... | [
"def",
"_update_mtime",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_mtime",
"=",
"os",
".",
"path",
".",
"getmtime",
"(",
"self",
".",
"editor",
".",
"file",
".",
"path",
")",
"except",
"OSError",
":",
"# file_path does not exists.",
"self",
".",
... | Updates modif time | [
"Updates",
"modif",
"time"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/filewatcher.py#L96-L111 |
pyQode/pyqode.core | pyqode/core/modes/filewatcher.py | FileWatcherMode._check_file | def _check_file(self):
"""
Checks watched file moficiation time and permission changes.
"""
try:
self.editor.toPlainText()
except RuntimeError:
self._timer.stop()
return
if self.editor and self.editor.file.path:
if not os.pa... | python | def _check_file(self):
"""
Checks watched file moficiation time and permission changes.
"""
try:
self.editor.toPlainText()
except RuntimeError:
self._timer.stop()
return
if self.editor and self.editor.file.path:
if not os.pa... | [
"def",
"_check_file",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"editor",
".",
"toPlainText",
"(",
")",
"except",
"RuntimeError",
":",
"self",
".",
"_timer",
".",
"stop",
"(",
")",
"return",
"if",
"self",
".",
"editor",
"and",
"self",
".",
"edi... | Checks watched file moficiation time and permission changes. | [
"Checks",
"watched",
"file",
"moficiation",
"time",
"and",
"permission",
"changes",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/filewatcher.py#L113-L132 |
pyQode/pyqode.core | pyqode/core/modes/filewatcher.py | FileWatcherMode._notify | def _notify(self, title, message, expected_action=None):
"""
Notify user from external event
"""
if self.editor is None:
return
inital_value = self.editor.save_on_focus_out
self.editor.save_on_focus_out = False
self._flg_notify = True
dlg_type ... | python | def _notify(self, title, message, expected_action=None):
"""
Notify user from external event
"""
if self.editor is None:
return
inital_value = self.editor.save_on_focus_out
self.editor.save_on_focus_out = False
self._flg_notify = True
dlg_type ... | [
"def",
"_notify",
"(",
"self",
",",
"title",
",",
"message",
",",
"expected_action",
"=",
"None",
")",
":",
"if",
"self",
".",
"editor",
"is",
"None",
":",
"return",
"inital_value",
"=",
"self",
".",
"editor",
".",
"save_on_focus_out",
"self",
".",
"edit... | Notify user from external event | [
"Notify",
"user",
"from",
"external",
"event"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/filewatcher.py#L134-L151 |
pyQode/pyqode.core | pyqode/core/modes/filewatcher.py | FileWatcherMode._notify_change | def _notify_change(self):
"""
Notify user from external change if autoReloadChangedFiles is False
then reload the changed file in the editor
"""
def inner_action(*args):
""" Inner action: open file """
# cache cursor position before reloading so that the c... | python | def _notify_change(self):
"""
Notify user from external change if autoReloadChangedFiles is False
then reload the changed file in the editor
"""
def inner_action(*args):
""" Inner action: open file """
# cache cursor position before reloading so that the c... | [
"def",
"_notify_change",
"(",
"self",
")",
":",
"def",
"inner_action",
"(",
"*",
"args",
")",
":",
"\"\"\" Inner action: open file \"\"\"",
"# cache cursor position before reloading so that the cursor",
"# position is restored automatically after reload has finished.",
"# See OpenCob... | Notify user from external change if autoReloadChangedFiles is False
then reload the changed file in the editor | [
"Notify",
"user",
"from",
"external",
"change",
"if",
"autoReloadChangedFiles",
"is",
"False",
"then",
"reload",
"the",
"changed",
"file",
"in",
"the",
"editor"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/filewatcher.py#L153-L182 |
pyQode/pyqode.core | pyqode/core/modes/filewatcher.py | FileWatcherMode._check_for_pending | def _check_for_pending(self, *args, **kwargs):
"""
Checks if a notification is pending.
"""
if self._notification_pending and not self._processing:
self._processing = True
args, kwargs = self._data
self._notify(*args, **kwargs)
self._notifi... | python | def _check_for_pending(self, *args, **kwargs):
"""
Checks if a notification is pending.
"""
if self._notification_pending and not self._processing:
self._processing = True
args, kwargs = self._data
self._notify(*args, **kwargs)
self._notifi... | [
"def",
"_check_for_pending",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_notification_pending",
"and",
"not",
"self",
".",
"_processing",
":",
"self",
".",
"_processing",
"=",
"True",
"args",
",",
"kwargs",
"=",... | Checks if a notification is pending. | [
"Checks",
"if",
"a",
"notification",
"is",
"pending",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/filewatcher.py#L184-L193 |
pyQode/pyqode.core | pyqode/core/modes/filewatcher.py | FileWatcherMode._notify_deleted_file | def _notify_deleted_file(self):
"""
Notify user from external file deletion.
"""
self.file_deleted.emit(self.editor)
# file deleted, disable file watcher
self.enabled = False | python | def _notify_deleted_file(self):
"""
Notify user from external file deletion.
"""
self.file_deleted.emit(self.editor)
# file deleted, disable file watcher
self.enabled = False | [
"def",
"_notify_deleted_file",
"(",
"self",
")",
":",
"self",
".",
"file_deleted",
".",
"emit",
"(",
"self",
".",
"editor",
")",
"# file deleted, disable file watcher",
"self",
".",
"enabled",
"=",
"False"
] | Notify user from external file deletion. | [
"Notify",
"user",
"from",
"external",
"file",
"deletion",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/filewatcher.py#L195-L201 |
GoogleCloudPlatform/python-repo-tools | gcp_devrel/tools/appengine.py | get_gae_versions | def get_gae_versions():
"""Gets a list of all of the available Python SDK versions, sorted with
the newest last."""
r = requests.get(SDK_RELEASES_URL)
r.raise_for_status()
releases = r.json().get('items', {})
# We only care about the Python releases, which all are in the format
# "featured... | python | def get_gae_versions():
"""Gets a list of all of the available Python SDK versions, sorted with
the newest last."""
r = requests.get(SDK_RELEASES_URL)
r.raise_for_status()
releases = r.json().get('items', {})
# We only care about the Python releases, which all are in the format
# "featured... | [
"def",
"get_gae_versions",
"(",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"SDK_RELEASES_URL",
")",
"r",
".",
"raise_for_status",
"(",
")",
"releases",
"=",
"r",
".",
"json",
"(",
")",
".",
"get",
"(",
"'items'",
",",
"{",
"}",
")",
"# We only ... | Gets a list of all of the available Python SDK versions, sorted with
the newest last. | [
"Gets",
"a",
"list",
"of",
"all",
"of",
"the",
"available",
"Python",
"SDK",
"versions",
"sorted",
"with",
"the",
"newest",
"last",
"."
] | train | https://github.com/GoogleCloudPlatform/python-repo-tools/blob/87422ba91814529848a2b8bf8be4294283a3e041/gcp_devrel/tools/appengine.py#L41-L63 |
GoogleCloudPlatform/python-repo-tools | gcp_devrel/tools/appengine.py | is_existing_up_to_date | def is_existing_up_to_date(destination, latest_version):
"""Returns False if there is no existing install or if the existing install
is out of date. Otherwise, returns True."""
version_path = os.path.join(
destination, 'google_appengine', 'VERSION')
if not os.path.exists(version_path):
... | python | def is_existing_up_to_date(destination, latest_version):
"""Returns False if there is no existing install or if the existing install
is out of date. Otherwise, returns True."""
version_path = os.path.join(
destination, 'google_appengine', 'VERSION')
if not os.path.exists(version_path):
... | [
"def",
"is_existing_up_to_date",
"(",
"destination",
",",
"latest_version",
")",
":",
"version_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"destination",
",",
"'google_appengine'",
",",
"'VERSION'",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(... | Returns False if there is no existing install or if the existing install
is out of date. Otherwise, returns True. | [
"Returns",
"False",
"if",
"there",
"is",
"no",
"existing",
"install",
"or",
"if",
"the",
"existing",
"install",
"is",
"out",
"of",
"date",
".",
"Otherwise",
"returns",
"True",
"."
] | train | https://github.com/GoogleCloudPlatform/python-repo-tools/blob/87422ba91814529848a2b8bf8be4294283a3e041/gcp_devrel/tools/appengine.py#L66-L86 |
GoogleCloudPlatform/python-repo-tools | gcp_devrel/tools/appengine.py | download_sdk | def download_sdk(url):
"""Downloads the SDK and returns a file-like object for the zip content."""
r = requests.get(url)
r.raise_for_status()
return StringIO(r.content) | python | def download_sdk(url):
"""Downloads the SDK and returns a file-like object for the zip content."""
r = requests.get(url)
r.raise_for_status()
return StringIO(r.content) | [
"def",
"download_sdk",
"(",
"url",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
")",
"r",
".",
"raise_for_status",
"(",
")",
"return",
"StringIO",
"(",
"r",
".",
"content",
")"
] | Downloads the SDK and returns a file-like object for the zip content. | [
"Downloads",
"the",
"SDK",
"and",
"returns",
"a",
"file",
"-",
"like",
"object",
"for",
"the",
"zip",
"content",
"."
] | train | https://github.com/GoogleCloudPlatform/python-repo-tools/blob/87422ba91814529848a2b8bf8be4294283a3e041/gcp_devrel/tools/appengine.py#L89-L93 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.