id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
51
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
3,300
andreikop/qutepart
qutepart/indenter/__init__.py
Indenter.onChangeSelectedBlocksIndent
def onChangeSelectedBlocksIndent(self, increase, withSpace=False): """Tab or Space pressed and few blocks are selected, or Shift+Tab pressed Insert or remove text from the beginning of blocks """ def blockIndentation(block): text = block.text() return text[:len(te...
python
def onChangeSelectedBlocksIndent(self, increase, withSpace=False): def blockIndentation(block): text = block.text() return text[:len(text) - len(text.lstrip())] def cursorAtSpaceEnd(block): cursor = QTextCursor(block) cursor.setPosition(block.position() +...
[ "def", "onChangeSelectedBlocksIndent", "(", "self", ",", "increase", ",", "withSpace", "=", "False", ")", ":", "def", "blockIndentation", "(", "block", ")", ":", "text", "=", "block", ".", "text", "(", ")", "return", "text", "[", ":", "len", "(", "text",...
Tab or Space pressed and few blocks are selected, or Shift+Tab pressed Insert or remove text from the beginning of blocks
[ "Tab", "or", "Space", "pressed", "and", "few", "blocks", "are", "selected", "or", "Shift", "+", "Tab", "pressed", "Insert", "or", "remove", "text", "from", "the", "beginning", "of", "blocks" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/indenter/__init__.py#L95-L161
3,301
andreikop/qutepart
qutepart/indenter/__init__.py
Indenter.onShortcutIndentAfterCursor
def onShortcutIndentAfterCursor(self): """Tab pressed and no selection. Insert text after cursor """ cursor = self._qpart.textCursor() def insertIndent(): if self.useTabs: cursor.insertText('\t') else: # indent to integer count of indents from li...
python
def onShortcutIndentAfterCursor(self): cursor = self._qpart.textCursor() def insertIndent(): if self.useTabs: cursor.insertText('\t') else: # indent to integer count of indents from line start charsToInsert = self.width - (len(self._qpart.textBef...
[ "def", "onShortcutIndentAfterCursor", "(", "self", ")", ":", "cursor", "=", "self", ".", "_qpart", ".", "textCursor", "(", ")", "def", "insertIndent", "(", ")", ":", "if", "self", ".", "useTabs", ":", "cursor", ".", "insertText", "(", "'\\t'", ")", "else...
Tab pressed and no selection. Insert text after cursor
[ "Tab", "pressed", "and", "no", "selection", ".", "Insert", "text", "after", "cursor" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/indenter/__init__.py#L163-L183
3,302
andreikop/qutepart
qutepart/indenter/__init__.py
Indenter.onShortcutUnindentWithBackspace
def onShortcutUnindentWithBackspace(self): """Backspace pressed, unindent """ assert self._qpart.textBeforeCursor().endswith(self.text()) charsToRemove = len(self._qpart.textBeforeCursor()) % len(self.text()) if charsToRemove == 0: charsToRemove = len(self.text()) ...
python
def onShortcutUnindentWithBackspace(self): assert self._qpart.textBeforeCursor().endswith(self.text()) charsToRemove = len(self._qpart.textBeforeCursor()) % len(self.text()) if charsToRemove == 0: charsToRemove = len(self.text()) cursor = self._qpart.textCursor() cu...
[ "def", "onShortcutUnindentWithBackspace", "(", "self", ")", ":", "assert", "self", ".", "_qpart", ".", "textBeforeCursor", "(", ")", ".", "endswith", "(", "self", ".", "text", "(", ")", ")", "charsToRemove", "=", "len", "(", "self", ".", "_qpart", ".", "...
Backspace pressed, unindent
[ "Backspace", "pressed", "unindent" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/indenter/__init__.py#L186-L197
3,303
andreikop/qutepart
qutepart/indenter/__init__.py
Indenter.onAutoIndentTriggered
def onAutoIndentTriggered(self): """Indent current line or selected lines """ cursor = self._qpart.textCursor() startBlock = self._qpart.document().findBlock(cursor.selectionStart()) endBlock = self._qpart.document().findBlock(cursor.selectionEnd()) if startBlock != end...
python
def onAutoIndentTriggered(self): cursor = self._qpart.textCursor() startBlock = self._qpart.document().findBlock(cursor.selectionStart()) endBlock = self._qpart.document().findBlock(cursor.selectionEnd()) if startBlock != endBlock: # indent multiply lines stopBlock = endBl...
[ "def", "onAutoIndentTriggered", "(", "self", ")", ":", "cursor", "=", "self", ".", "_qpart", ".", "textCursor", "(", ")", "startBlock", "=", "self", ".", "_qpart", ".", "document", "(", ")", ".", "findBlock", "(", "cursor", ".", "selectionStart", "(", ")...
Indent current line or selected lines
[ "Indent", "current", "line", "or", "selected", "lines" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/indenter/__init__.py#L199-L217
3,304
andreikop/qutepart
qutepart/indenter/__init__.py
Indenter._chooseSmartIndenter
def _chooseSmartIndenter(self, syntax): """Get indenter for syntax """ if syntax.indenter is not None: try: return _getSmartIndenter(syntax.indenter, self._qpart, self) except KeyError: logger.error("Indenter '%s' is not finished yet. But y...
python
def _chooseSmartIndenter(self, syntax): if syntax.indenter is not None: try: return _getSmartIndenter(syntax.indenter, self._qpart, self) except KeyError: logger.error("Indenter '%s' is not finished yet. But you can do it!" % syntax.indenter) try:...
[ "def", "_chooseSmartIndenter", "(", "self", ",", "syntax", ")", ":", "if", "syntax", ".", "indenter", "is", "not", "None", ":", "try", ":", "return", "_getSmartIndenter", "(", "syntax", ".", "indenter", ",", "self", ".", "_qpart", ",", "self", ")", "exce...
Get indenter for syntax
[ "Get", "indenter", "for", "syntax" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/indenter/__init__.py#L219-L233
3,305
andreikop/qutepart
qutepart/syntax/loader.py
_processEscapeSequences
def _processEscapeSequences(replaceText): """Replace symbols like \n \\, etc """ def _replaceFunc(escapeMatchObject): char = escapeMatchObject.group(0)[1] if char in _escapeSequences: return _escapeSequences[char] return escapeMatchObject.group(0) # no any replacements,...
python
def _processEscapeSequences(replaceText): def _replaceFunc(escapeMatchObject): char = escapeMatchObject.group(0)[1] if char in _escapeSequences: return _escapeSequences[char] return escapeMatchObject.group(0) # no any replacements, return original value return _seqReplacer...
[ "def", "_processEscapeSequences", "(", "replaceText", ")", ":", "def", "_replaceFunc", "(", "escapeMatchObject", ")", ":", "char", "=", "escapeMatchObject", ".", "group", "(", "0", ")", "[", "1", "]", "if", "char", "in", "_escapeSequences", ":", "return", "_...
Replace symbols like \n \\, etc
[ "Replace", "symbols", "like", "\\", "n", "\\\\", "etc" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/syntax/loader.py#L40-L50
3,306
andreikop/qutepart
qutepart/syntax/loader.py
_loadChildRules
def _loadChildRules(context, xmlElement, attributeToFormatMap): """Extract rules from Context or Rule xml element """ rules = [] for ruleElement in xmlElement.getchildren(): if not ruleElement.tag in _ruleClassDict: raise ValueError("Not supported rule '%s'" % ruleElement.tag) ...
python
def _loadChildRules(context, xmlElement, attributeToFormatMap): rules = [] for ruleElement in xmlElement.getchildren(): if not ruleElement.tag in _ruleClassDict: raise ValueError("Not supported rule '%s'" % ruleElement.tag) rule = _ruleClassDict[ruleElement.tag](context, ruleElement,...
[ "def", "_loadChildRules", "(", "context", ",", "xmlElement", ",", "attributeToFormatMap", ")", ":", "rules", "=", "[", "]", "for", "ruleElement", "in", "xmlElement", ".", "getchildren", "(", ")", ":", "if", "not", "ruleElement", ".", "tag", "in", "_ruleClass...
Extract rules from Context or Rule xml element
[ "Extract", "rules", "from", "Context", "or", "Rule", "xml", "element" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/syntax/loader.py#L196-L205
3,307
andreikop/qutepart
qutepart/syntax/loader.py
_loadContext
def _loadContext(context, xmlElement, attributeToFormatMap): """Construct context from XML element Contexts are at first constructed, and only then loaded, because when loading context, _makeContextSwitcher must have references to all defined contexts """ attribute = _safeGetRequiredAttribute(xmlEle...
python
def _loadContext(context, xmlElement, attributeToFormatMap): attribute = _safeGetRequiredAttribute(xmlElement, 'attribute', '<not set>').lower() if attribute != '<not set>': # there are no attributes for internal contexts, used by rules. See perl.xml try: format = attributeToFormatMap[attri...
[ "def", "_loadContext", "(", "context", ",", "xmlElement", ",", "attributeToFormatMap", ")", ":", "attribute", "=", "_safeGetRequiredAttribute", "(", "xmlElement", ",", "'attribute'", ",", "'<not set>'", ")", ".", "lower", "(", ")", "if", "attribute", "!=", "'<no...
Construct context from XML element Contexts are at first constructed, and only then loaded, because when loading context, _makeContextSwitcher must have references to all defined contexts
[ "Construct", "context", "from", "XML", "element", "Contexts", "are", "at", "first", "constructed", "and", "only", "then", "loaded", "because", "when", "loading", "context", "_makeContextSwitcher", "must", "have", "references", "to", "all", "defined", "contexts" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/syntax/loader.py#L419-L457
3,308
andreikop/qutepart
qutepart/syntax/loader.py
_textTypeForDefStyleName
def _textTypeForDefStyleName(attribute, defStyleName): """ ' ' for code 'c' for comments 'b' for block comments 'h' for here documents """ if 'here' in attribute.lower() and defStyleName == 'dsOthers': return 'h' # ruby elif 'block' in attribute.lower() and defStyleName ...
python
def _textTypeForDefStyleName(attribute, defStyleName): if 'here' in attribute.lower() and defStyleName == 'dsOthers': return 'h' # ruby elif 'block' in attribute.lower() and defStyleName == 'dsComment': return 'b' elif defStyleName in ('dsString', 'dsRegionMarker', 'dsChar', 'dsOthers'): ...
[ "def", "_textTypeForDefStyleName", "(", "attribute", ",", "defStyleName", ")", ":", "if", "'here'", "in", "attribute", ".", "lower", "(", ")", "and", "defStyleName", "==", "'dsOthers'", ":", "return", "'h'", "# ruby", "elif", "'block'", "in", "attribute", ".",...
' ' for code 'c' for comments 'b' for block comments 'h' for here documents
[ "for", "code", "c", "for", "comments", "b", "for", "block", "comments", "h", "for", "here", "documents" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/syntax/loader.py#L462-L477
3,309
andreikop/qutepart
qutepart/indenter/base.py
IndentAlgBase.computeIndent
def computeIndent(self, block, char): """Compute indent for the block. Basic alorightm, which knows nothing about programming languages May be used by child classes """ prevBlockText = block.previous().text() # invalid block returns empty text if char == '\n' and \ ...
python
def computeIndent(self, block, char): prevBlockText = block.previous().text() # invalid block returns empty text if char == '\n' and \ prevBlockText.strip() == '': # continue indentation, if no text return self._prevBlockIndent(block) else: # be smart return...
[ "def", "computeIndent", "(", "self", ",", "block", ",", "char", ")", ":", "prevBlockText", "=", "block", ".", "previous", "(", ")", ".", "text", "(", ")", "# invalid block returns empty text", "if", "char", "==", "'\\n'", "and", "prevBlockText", ".", "strip"...
Compute indent for the block. Basic alorightm, which knows nothing about programming languages May be used by child classes
[ "Compute", "indent", "for", "the", "block", ".", "Basic", "alorightm", "which", "knows", "nothing", "about", "programming", "languages", "May", "be", "used", "by", "child", "classes" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/indenter/base.py#L29-L39
3,310
andreikop/qutepart
qutepart/indenter/base.py
IndentAlgBase._decreaseIndent
def _decreaseIndent(self, indent): """Remove 1 indentation level """ if indent.endswith(self._qpartIndent()): return indent[:-len(self._qpartIndent())] else: # oops, strange indentation, just return previous indent return indent
python
def _decreaseIndent(self, indent): if indent.endswith(self._qpartIndent()): return indent[:-len(self._qpartIndent())] else: # oops, strange indentation, just return previous indent return indent
[ "def", "_decreaseIndent", "(", "self", ",", "indent", ")", ":", "if", "indent", ".", "endswith", "(", "self", ".", "_qpartIndent", "(", ")", ")", ":", "return", "indent", "[", ":", "-", "len", "(", "self", ".", "_qpartIndent", "(", ")", ")", "]", "...
Remove 1 indentation level
[ "Remove", "1", "indentation", "level" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/indenter/base.py#L63-L69
3,311
andreikop/qutepart
qutepart/indenter/base.py
IndentAlgBase._makeIndentFromWidth
def _makeIndentFromWidth(self, width): """Make indent text with specified with. Contains width count of spaces, or tabs and spaces """ if self._indenter.useTabs: tabCount, spaceCount = divmod(width, self._indenter.width) return ('\t' * tabCount) + (' ' * spaceCoun...
python
def _makeIndentFromWidth(self, width): if self._indenter.useTabs: tabCount, spaceCount = divmod(width, self._indenter.width) return ('\t' * tabCount) + (' ' * spaceCount) else: return ' ' * width
[ "def", "_makeIndentFromWidth", "(", "self", ",", "width", ")", ":", "if", "self", ".", "_indenter", ".", "useTabs", ":", "tabCount", ",", "spaceCount", "=", "divmod", "(", "width", ",", "self", ".", "_indenter", ".", "width", ")", "return", "(", "'\\t'",...
Make indent text with specified with. Contains width count of spaces, or tabs and spaces
[ "Make", "indent", "text", "with", "specified", "with", ".", "Contains", "width", "count", "of", "spaces", "or", "tabs", "and", "spaces" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/indenter/base.py#L71-L79
3,312
andreikop/qutepart
qutepart/indenter/base.py
IndentAlgBase._makeIndentAsColumn
def _makeIndentAsColumn(self, block, column, offset=0): """ Make indent equal to column indent. Shiftted by offset """ blockText = block.text() textBeforeColumn = blockText[:column] tabCount = textBeforeColumn.count('\t') visibleColumn = column + (tabCount * (sel...
python
def _makeIndentAsColumn(self, block, column, offset=0): blockText = block.text() textBeforeColumn = blockText[:column] tabCount = textBeforeColumn.count('\t') visibleColumn = column + (tabCount * (self._indenter.width - 1)) return self._makeIndentFromWidth(visibleColumn + offset...
[ "def", "_makeIndentAsColumn", "(", "self", ",", "block", ",", "column", ",", "offset", "=", "0", ")", ":", "blockText", "=", "block", ".", "text", "(", ")", "textBeforeColumn", "=", "blockText", "[", ":", "column", "]", "tabCount", "=", "textBeforeColumn",...
Make indent equal to column indent. Shiftted by offset
[ "Make", "indent", "equal", "to", "column", "indent", ".", "Shiftted", "by", "offset" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/indenter/base.py#L81-L90
3,313
andreikop/qutepart
qutepart/indenter/base.py
IndentAlgBase._setBlockIndent
def _setBlockIndent(self, block, indent): """Set blocks indent. Modify text in qpart """ currentIndent = self._blockIndent(block) self._qpart.replaceText((block.blockNumber(), 0), len(currentIndent), indent)
python
def _setBlockIndent(self, block, indent): currentIndent = self._blockIndent(block) self._qpart.replaceText((block.blockNumber(), 0), len(currentIndent), indent)
[ "def", "_setBlockIndent", "(", "self", ",", "block", ",", "indent", ")", ":", "currentIndent", "=", "self", ".", "_blockIndent", "(", "block", ")", "self", ".", "_qpart", ".", "replaceText", "(", "(", "block", ".", "blockNumber", "(", ")", ",", "0", ")...
Set blocks indent. Modify text in qpart
[ "Set", "blocks", "indent", ".", "Modify", "text", "in", "qpart" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/indenter/base.py#L92-L96
3,314
andreikop/qutepart
qutepart/indenter/base.py
IndentAlgBase.iterateBlocksFrom
def iterateBlocksFrom(block): """Generator, which iterates QTextBlocks from block until the End of a document But, yields not more than MAX_SEARCH_OFFSET_LINES """ count = 0 while block.isValid() and count < MAX_SEARCH_OFFSET_LINES: yield block block = blo...
python
def iterateBlocksFrom(block): count = 0 while block.isValid() and count < MAX_SEARCH_OFFSET_LINES: yield block block = block.next() count += 1
[ "def", "iterateBlocksFrom", "(", "block", ")", ":", "count", "=", "0", "while", "block", ".", "isValid", "(", ")", "and", "count", "<", "MAX_SEARCH_OFFSET_LINES", ":", "yield", "block", "block", "=", "block", ".", "next", "(", ")", "count", "+=", "1" ]
Generator, which iterates QTextBlocks from block until the End of a document But, yields not more than MAX_SEARCH_OFFSET_LINES
[ "Generator", "which", "iterates", "QTextBlocks", "from", "block", "until", "the", "End", "of", "a", "document", "But", "yields", "not", "more", "than", "MAX_SEARCH_OFFSET_LINES" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/indenter/base.py#L99-L107
3,315
andreikop/qutepart
qutepart/indenter/base.py
IndentAlgBase.iterateBlocksBackFrom
def iterateBlocksBackFrom(block): """Generator, which iterates QTextBlocks from block until the Start of a document But, yields not more than MAX_SEARCH_OFFSET_LINES """ count = 0 while block.isValid() and count < MAX_SEARCH_OFFSET_LINES: yield block block...
python
def iterateBlocksBackFrom(block): count = 0 while block.isValid() and count < MAX_SEARCH_OFFSET_LINES: yield block block = block.previous() count += 1
[ "def", "iterateBlocksBackFrom", "(", "block", ")", ":", "count", "=", "0", "while", "block", ".", "isValid", "(", ")", "and", "count", "<", "MAX_SEARCH_OFFSET_LINES", ":", "yield", "block", "block", "=", "block", ".", "previous", "(", ")", "count", "+=", ...
Generator, which iterates QTextBlocks from block until the Start of a document But, yields not more than MAX_SEARCH_OFFSET_LINES
[ "Generator", "which", "iterates", "QTextBlocks", "from", "block", "until", "the", "Start", "of", "a", "document", "But", "yields", "not", "more", "than", "MAX_SEARCH_OFFSET_LINES" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/indenter/base.py#L110-L118
3,316
andreikop/qutepart
qutepart/indenter/base.py
IndentAlgBase._lastColumn
def _lastColumn(self, block): """Returns the last non-whitespace column in the given line. If there are only whitespaces in the line, the return value is -1. """ text = block.text() index = len(block.text()) - 1 while index >= 0 and \ (text[index].isspace() ...
python
def _lastColumn(self, block): text = block.text() index = len(block.text()) - 1 while index >= 0 and \ (text[index].isspace() or \ self._qpart.isComment(block.blockNumber(), index)): index -= 1 return index
[ "def", "_lastColumn", "(", "self", ",", "block", ")", ":", "text", "=", "block", ".", "text", "(", ")", "index", "=", "len", "(", "block", ".", "text", "(", ")", ")", "-", "1", "while", "index", ">=", "0", "and", "(", "text", "[", "index", "]",...
Returns the last non-whitespace column in the given line. If there are only whitespaces in the line, the return value is -1.
[ "Returns", "the", "last", "non", "-", "whitespace", "column", "in", "the", "given", "line", ".", "If", "there", "are", "only", "whitespaces", "in", "the", "line", "the", "return", "value", "is", "-", "1", "." ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/indenter/base.py#L257-L268
3,317
andreikop/qutepart
qutepart/indenter/base.py
IndentAlgBase._nextNonSpaceColumn
def _nextNonSpaceColumn(block, column): """Returns the column with a non-whitespace characters starting at the given cursor position and searching forwards. """ textAfter = block.text()[column:] if textAfter.strip(): spaceLen = len(textAfter) - len(textAfter.lstrip())...
python
def _nextNonSpaceColumn(block, column): textAfter = block.text()[column:] if textAfter.strip(): spaceLen = len(textAfter) - len(textAfter.lstrip()) return column + spaceLen else: return -1
[ "def", "_nextNonSpaceColumn", "(", "block", ",", "column", ")", ":", "textAfter", "=", "block", ".", "text", "(", ")", "[", "column", ":", "]", "if", "textAfter", ".", "strip", "(", ")", ":", "spaceLen", "=", "len", "(", "textAfter", ")", "-", "len",...
Returns the column with a non-whitespace characters starting at the given cursor position and searching forwards.
[ "Returns", "the", "column", "with", "a", "non", "-", "whitespace", "characters", "starting", "at", "the", "given", "cursor", "position", "and", "searching", "forwards", "." ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/indenter/base.py#L271-L280
3,318
andreikop/qutepart
setup.py
_checkBuildDependencies
def _checkBuildDependencies(): compiler = distutils.ccompiler.new_compiler() """check if function without parameters from stdlib can be called There should be better way to check, if C compiler is installed """ if not compiler.has_function('rand', includes=['stdlib.h']): print("It seems like...
python
def _checkBuildDependencies(): compiler = distutils.ccompiler.new_compiler() if not compiler.has_function('rand', includes=['stdlib.h']): print("It seems like C compiler is not installed or not operable.") return False if not compiler.has_function('rand', in...
[ "def", "_checkBuildDependencies", "(", ")", ":", "compiler", "=", "distutils", ".", "ccompiler", ".", "new_compiler", "(", ")", "if", "not", "compiler", ".", "has_function", "(", "'rand'", ",", "includes", "=", "[", "'stdlib.h'", "]", ")", ":", "print", "(...
check if function without parameters from stdlib can be called There should be better way to check, if C compiler is installed
[ "check", "if", "function", "without", "parameters", "from", "stdlib", "can", "be", "called", "There", "should", "be", "better", "way", "to", "check", "if", "C", "compiler", "is", "installed" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/setup.py#L83-L117
3,319
andreikop/qutepart
qutepart/vim.py
isChar
def isChar(ev): """ Check if an event may be a typed character """ text = ev.text() if len(text) != 1: return False if ev.modifiers() not in (Qt.ShiftModifier, Qt.KeypadModifier, Qt.NoModifier): return False asciiCode = ord(text) if asciiCode <= 31 or asciiCode == 0x7f: # ...
python
def isChar(ev): text = ev.text() if len(text) != 1: return False if ev.modifiers() not in (Qt.ShiftModifier, Qt.KeypadModifier, Qt.NoModifier): return False asciiCode = ord(text) if asciiCode <= 31 or asciiCode == 0x7f: # control characters return False if text == ' '...
[ "def", "isChar", "(", "ev", ")", ":", "text", "=", "ev", ".", "text", "(", ")", "if", "len", "(", "text", ")", "!=", "1", ":", "return", "False", "if", "ev", ".", "modifiers", "(", ")", "not", "in", "(", "Qt", ".", "ShiftModifier", ",", "Qt", ...
Check if an event may be a typed character
[ "Check", "if", "an", "event", "may", "be", "a", "typed", "character" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/vim.py#L47-L64
3,320
andreikop/qutepart
qutepart/vim.py
Vim.keyPressEvent
def keyPressEvent(self, ev): """Check the event. Return True if processed and False otherwise """ if ev.key() in (Qt.Key_Shift, Qt.Key_Control, Qt.Key_Meta, Qt.Key_Alt, Qt.Key_AltGr, Qt.Key_CapsLock, Qt.Key_NumLock, Qt.Key_S...
python
def keyPressEvent(self, ev): if ev.key() in (Qt.Key_Shift, Qt.Key_Control, Qt.Key_Meta, Qt.Key_Alt, Qt.Key_AltGr, Qt.Key_CapsLock, Qt.Key_NumLock, Qt.Key_ScrollLock): return False # ignore modifier pressing. Will process key pr...
[ "def", "keyPressEvent", "(", "self", ",", "ev", ")", ":", "if", "ev", ".", "key", "(", ")", "in", "(", "Qt", ".", "Key_Shift", ",", "Qt", ".", "Key_Control", ",", "Qt", ".", "Key_Meta", ",", "Qt", ".", "Key_Alt", ",", "Qt", ".", "Key_AltGr", ",",...
Check the event. Return True if processed and False otherwise
[ "Check", "the", "event", ".", "Return", "True", "if", "processed", "and", "False", "otherwise" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/vim.py#L116-L130
3,321
andreikop/qutepart
qutepart/vim.py
Vim.extraSelections
def extraSelections(self): """ In normal mode - QTextEdit.ExtraSelection which highlightes the cursor """ if not isinstance(self._mode, Normal): return [] selection = QTextEdit.ExtraSelection() selection.format.setBackground(QColor('#ffcc22')) selection.forma...
python
def extraSelections(self): if not isinstance(self._mode, Normal): return [] selection = QTextEdit.ExtraSelection() selection.format.setBackground(QColor('#ffcc22')) selection.format.setForeground(QColor('#000000')) selection.cursor = self._qpart.textCursor() ...
[ "def", "extraSelections", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "_mode", ",", "Normal", ")", ":", "return", "[", "]", "selection", "=", "QTextEdit", ".", "ExtraSelection", "(", ")", "selection", ".", "format", ".", "setBackg...
In normal mode - QTextEdit.ExtraSelection which highlightes the cursor
[ "In", "normal", "mode", "-", "QTextEdit", ".", "ExtraSelection", "which", "highlightes", "the", "cursor" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/vim.py#L145-L157
3,322
andreikop/qutepart
qutepart/vim.py
BaseCommandMode._resetSelection
def _resetSelection(self, moveToTop=False): """ Reset selection. If moveToTop is True - move cursor to the top position """ ancor, pos = self._qpart.selectedPosition dst = min(ancor, pos) if moveToTop else pos self._qpart.cursorPosition = dst
python
def _resetSelection(self, moveToTop=False): ancor, pos = self._qpart.selectedPosition dst = min(ancor, pos) if moveToTop else pos self._qpart.cursorPosition = dst
[ "def", "_resetSelection", "(", "self", ",", "moveToTop", "=", "False", ")", ":", "ancor", ",", "pos", "=", "self", ".", "_qpart", ".", "selectedPosition", "dst", "=", "min", "(", "ancor", ",", "pos", ")", "if", "moveToTop", "else", "pos", "self", ".", ...
Reset selection. If moveToTop is True - move cursor to the top position
[ "Reset", "selection", ".", "If", "moveToTop", "is", "True", "-", "move", "cursor", "to", "the", "top", "position" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/vim.py#L458-L464
3,323
andreikop/qutepart
qutepart/vim.py
BaseVisual._selectedLinesRange
def _selectedLinesRange(self): """ Selected lines range for line manipulation methods """ (startLine, startCol), (endLine, endCol) = self._qpart.selectedPosition start = min(startLine, endLine) end = max(startLine, endLine) return start, end
python
def _selectedLinesRange(self): (startLine, startCol), (endLine, endCol) = self._qpart.selectedPosition start = min(startLine, endLine) end = max(startLine, endLine) return start, end
[ "def", "_selectedLinesRange", "(", "self", ")", ":", "(", "startLine", ",", "startCol", ")", ",", "(", "endLine", ",", "endCol", ")", "=", "self", ".", "_qpart", ".", "selectedPosition", "start", "=", "min", "(", "startLine", ",", "endLine", ")", "end", ...
Selected lines range for line manipulation methods
[ "Selected", "lines", "range", "for", "line", "manipulation", "methods" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/vim.py#L583-L589
3,324
andreikop/qutepart
qutepart/vim.py
Normal._repeat
def _repeat(self, count, func): """ Repeat action 1 or more times. If more than one - do it as 1 undoble action """ if count != 1: with self._qpart: for _ in range(count): func() else: func()
python
def _repeat(self, count, func): if count != 1: with self._qpart: for _ in range(count): func() else: func()
[ "def", "_repeat", "(", "self", ",", "count", ",", "func", ")", ":", "if", "count", "!=", "1", ":", "with", "self", ".", "_qpart", ":", "for", "_", "in", "range", "(", "count", ")", ":", "func", "(", ")", "else", ":", "func", "(", ")" ]
Repeat action 1 or more times. If more than one - do it as 1 undoble action
[ "Repeat", "action", "1", "or", "more", "times", ".", "If", "more", "than", "one", "-", "do", "it", "as", "1", "undoble", "action" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/vim.py#L912-L921
3,325
andreikop/qutepart
qutepart/vim.py
Normal.cmdDeleteUntilEndOfBlock
def cmdDeleteUntilEndOfBlock(self, cmd, count): """ C and D """ cursor = self._qpart.textCursor() for _ in range(count - 1): cursor.movePosition(QTextCursor.Down, QTextCursor.KeepAnchor) cursor.movePosition(QTextCursor.EndOfBlock, QTextCursor.KeepAnchor) _glob...
python
def cmdDeleteUntilEndOfBlock(self, cmd, count): cursor = self._qpart.textCursor() for _ in range(count - 1): cursor.movePosition(QTextCursor.Down, QTextCursor.KeepAnchor) cursor.movePosition(QTextCursor.EndOfBlock, QTextCursor.KeepAnchor) _globalClipboard.value = cursor.selec...
[ "def", "cmdDeleteUntilEndOfBlock", "(", "self", ",", "cmd", ",", "count", ")", ":", "cursor", "=", "self", ".", "_qpart", ".", "textCursor", "(", ")", "for", "_", "in", "range", "(", "count", "-", "1", ")", ":", "cursor", ".", "movePosition", "(", "Q...
C and D
[ "C", "and", "D" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/vim.py#L1103-L1115
3,326
andreikop/qutepart
qutepart/__init__.py
Qutepart.terminate
def terminate(self): """ Terminate Qutepart instance. This method MUST be called before application stop to avoid crashes and some other interesting effects Call it on close to free memory and stop background highlighting """ self.text = '' self._completer.termina...
python
def terminate(self): self.text = '' self._completer.terminate() if self._highlighter is not None: self._highlighter.terminate() if self._vim is not None: self._vim.terminate()
[ "def", "terminate", "(", "self", ")", ":", "self", ".", "text", "=", "''", "self", ".", "_completer", ".", "terminate", "(", ")", "if", "self", ".", "_highlighter", "is", "not", "None", ":", "self", ".", "_highlighter", ".", "terminate", "(", ")", "i...
Terminate Qutepart instance. This method MUST be called before application stop to avoid crashes and some other interesting effects Call it on close to free memory and stop background highlighting
[ "Terminate", "Qutepart", "instance", ".", "This", "method", "MUST", "be", "called", "before", "application", "stop", "to", "avoid", "crashes", "and", "some", "other", "interesting", "effects", "Call", "it", "on", "close", "to", "free", "memory", "and", "stop",...
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L335-L348
3,327
andreikop/qutepart
qutepart/__init__.py
Qutepart._initActions
def _initActions(self): """Init shortcuts for text editing """ def createAction(text, shortcut, slot, iconFileName=None): """Create QAction with given parameters and add to the widget """ action = QAction(text, self) if iconFileName is not None: ...
python
def _initActions(self): def createAction(text, shortcut, slot, iconFileName=None): """Create QAction with given parameters and add to the widget """ action = QAction(text, self) if iconFileName is not None: action.setIcon(getIcon(iconFileName)) ...
[ "def", "_initActions", "(", "self", ")", ":", "def", "createAction", "(", "text", ",", "shortcut", ",", "slot", ",", "iconFileName", "=", "None", ")", ":", "\"\"\"Create QAction with given parameters and add to the widget\n \"\"\"", "action", "=", "QAction", ...
Init shortcuts for text editing
[ "Init", "shortcuts", "for", "text", "editing" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L350-L416
3,328
andreikop/qutepart
qutepart/__init__.py
Qutepart._updateTabStopWidth
def _updateTabStopWidth(self): """Update tabstop width after font or indentation changed """ self.setTabStopWidth(self.fontMetrics().width(' ' * self._indenter.width))
python
def _updateTabStopWidth(self): self.setTabStopWidth(self.fontMetrics().width(' ' * self._indenter.width))
[ "def", "_updateTabStopWidth", "(", "self", ")", ":", "self", ".", "setTabStopWidth", "(", "self", ".", "fontMetrics", "(", ")", ".", "width", "(", "' '", "*", "self", ".", "_indenter", ".", "width", ")", ")" ]
Update tabstop width after font or indentation changed
[ "Update", "tabstop", "width", "after", "font", "or", "indentation", "changed" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L460-L463
3,329
andreikop/qutepart
qutepart/__init__.py
Qutepart.textForSaving
def textForSaving(self): """Get text with correct EOL symbols. Use this method for saving a file to storage """ lines = self.text.splitlines() if self.text.endswith('\n'): # splitlines ignores last \n lines.append('') return self.eol.join(lines) + self.eol
python
def textForSaving(self): lines = self.text.splitlines() if self.text.endswith('\n'): # splitlines ignores last \n lines.append('') return self.eol.join(lines) + self.eol
[ "def", "textForSaving", "(", "self", ")", ":", "lines", "=", "self", ".", "text", ".", "splitlines", "(", ")", "if", "self", ".", "text", ".", "endswith", "(", "'\\n'", ")", ":", "# splitlines ignores last \\n", "lines", ".", "append", "(", "''", ")", ...
Get text with correct EOL symbols. Use this method for saving a file to storage
[ "Get", "text", "with", "correct", "EOL", "symbols", ".", "Use", "this", "method", "for", "saving", "a", "file", "to", "storage" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L492-L498
3,330
andreikop/qutepart
qutepart/__init__.py
Qutepart.resetSelection
def resetSelection(self): """Reset selection. Nothing will be selected. """ cursor = self.textCursor() cursor.setPosition(cursor.position()) self.setTextCursor(cursor)
python
def resetSelection(self): cursor = self.textCursor() cursor.setPosition(cursor.position()) self.setTextCursor(cursor)
[ "def", "resetSelection", "(", "self", ")", ":", "cursor", "=", "self", ".", "textCursor", "(", ")", "cursor", ".", "setPosition", "(", "cursor", ".", "position", "(", ")", ")", "self", ".", "setTextCursor", "(", "cursor", ")" ]
Reset selection. Nothing will be selected.
[ "Reset", "selection", ".", "Nothing", "will", "be", "selected", "." ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L583-L588
3,331
andreikop/qutepart
qutepart/__init__.py
Qutepart.replaceText
def replaceText(self, pos, length, text): """Replace length symbols from ``pos`` with new text. If ``pos`` is an integer, it is interpreted as absolute position, if a tuple - as ``(line, column)`` """ if isinstance(pos, tuple): pos = self.mapToAbsPosition(*pos) endP...
python
def replaceText(self, pos, length, text): if isinstance(pos, tuple): pos = self.mapToAbsPosition(*pos) endPos = pos + length if not self.document().findBlock(pos).isValid(): raise IndexError('Invalid start position %d' % pos) if not self.document().findBlock(en...
[ "def", "replaceText", "(", "self", ",", "pos", ",", "length", ",", "text", ")", ":", "if", "isinstance", "(", "pos", ",", "tuple", ")", ":", "pos", "=", "self", ".", "mapToAbsPosition", "(", "*", "pos", ")", "endPos", "=", "pos", "+", "length", "if...
Replace length symbols from ``pos`` with new text. If ``pos`` is an integer, it is interpreted as absolute position, if a tuple - as ``(line, column)``
[ "Replace", "length", "symbols", "from", "pos", "with", "new", "text", "." ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L715-L735
3,332
andreikop/qutepart
qutepart/__init__.py
Qutepart.clearSyntax
def clearSyntax(self): """Clear syntax. Disables syntax highlighting This method might take long time, if document is big. Don't call it if you don't have to (i.e. in destructor) """ if self._highlighter is not None: self._highlighter.terminate() self._highlighte...
python
def clearSyntax(self): if self._highlighter is not None: self._highlighter.terminate() self._highlighter = None self.languageChanged.emit(None)
[ "def", "clearSyntax", "(", "self", ")", ":", "if", "self", ".", "_highlighter", "is", "not", "None", ":", "self", ".", "_highlighter", ".", "terminate", "(", ")", "self", ".", "_highlighter", "=", "None", "self", ".", "languageChanged", ".", "emit", "(",...
Clear syntax. Disables syntax highlighting This method might take long time, if document is big. Don't call it if you don't have to (i.e. in destructor)
[ "Clear", "syntax", ".", "Disables", "syntax", "highlighting" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L785-L793
3,333
andreikop/qutepart
qutepart/__init__.py
Qutepart.setCustomCompletions
def setCustomCompletions(self, wordSet): """Add a set of custom completions to the editors completions. This set is managed independently of the set of keywords and words from the current document, and can thus be changed at any time. """ if not isinstance(wordSet, set): ...
python
def setCustomCompletions(self, wordSet): if not isinstance(wordSet, set): raise TypeError('"wordSet" is not a set: %s' % type(wordSet)) self._completer.setCustomCompletions(wordSet)
[ "def", "setCustomCompletions", "(", "self", ",", "wordSet", ")", ":", "if", "not", "isinstance", "(", "wordSet", ",", "set", ")", ":", "raise", "TypeError", "(", "'\"wordSet\" is not a set: %s'", "%", "type", "(", "wordSet", ")", ")", "self", ".", "_complete...
Add a set of custom completions to the editors completions. This set is managed independently of the set of keywords and words from the current document, and can thus be changed at any time.
[ "Add", "a", "set", "of", "custom", "completions", "to", "the", "editors", "completions", "." ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L804-L813
3,334
andreikop/qutepart
qutepart/__init__.py
Qutepart.isCode
def isCode(self, blockOrBlockNumber, column): """Check if text at given position is a code. If language is not known, or text is not parsed yet, ``True`` is returned """ if isinstance(blockOrBlockNumber, QTextBlock): block = blockOrBlockNumber else: block...
python
def isCode(self, blockOrBlockNumber, column): if isinstance(blockOrBlockNumber, QTextBlock): block = blockOrBlockNumber else: block = self.document().findBlockByNumber(blockOrBlockNumber) return self._highlighter is None or \ self._highlighter.isCode(block...
[ "def", "isCode", "(", "self", ",", "blockOrBlockNumber", ",", "column", ")", ":", "if", "isinstance", "(", "blockOrBlockNumber", ",", "QTextBlock", ")", ":", "block", "=", "blockOrBlockNumber", "else", ":", "block", "=", "self", ".", "document", "(", ")", ...
Check if text at given position is a code. If language is not known, or text is not parsed yet, ``True`` is returned
[ "Check", "if", "text", "at", "given", "position", "is", "a", "code", "." ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L821-L832
3,335
andreikop/qutepart
qutepart/__init__.py
Qutepart.isComment
def isComment(self, line, column): """Check if text at given position is a comment. Including block comments and here documents. If language is not known, or text is not parsed yet, ``False`` is returned """ return self._highlighter is not None and \ self._highlighter.isC...
python
def isComment(self, line, column): return self._highlighter is not None and \ self._highlighter.isComment(self.document().findBlockByNumber(line), column)
[ "def", "isComment", "(", "self", ",", "line", ",", "column", ")", ":", "return", "self", ".", "_highlighter", "is", "not", "None", "and", "self", ".", "_highlighter", ".", "isComment", "(", "self", ".", "document", "(", ")", ".", "findBlockByNumber", "("...
Check if text at given position is a comment. Including block comments and here documents. If language is not known, or text is not parsed yet, ``False`` is returned
[ "Check", "if", "text", "at", "given", "position", "is", "a", "comment", ".", "Including", "block", "comments", "and", "here", "documents", "." ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L834-L840
3,336
andreikop/qutepart
qutepart/__init__.py
Qutepart.isBlockComment
def isBlockComment(self, line, column): """Check if text at given position is a block comment. If language is not known, or text is not parsed yet, ``False`` is returned """ return self._highlighter is not None and \ self._highlighter.isBlockComment(self.document().findBl...
python
def isBlockComment(self, line, column): return self._highlighter is not None and \ self._highlighter.isBlockComment(self.document().findBlockByNumber(line), column)
[ "def", "isBlockComment", "(", "self", ",", "line", ",", "column", ")", ":", "return", "self", ".", "_highlighter", "is", "not", "None", "and", "self", ".", "_highlighter", ".", "isBlockComment", "(", "self", ".", "document", "(", ")", ".", "findBlockByNumb...
Check if text at given position is a block comment. If language is not known, or text is not parsed yet, ``False`` is returned
[ "Check", "if", "text", "at", "given", "position", "is", "a", "block", "comment", "." ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L842-L848
3,337
andreikop/qutepart
qutepart/__init__.py
Qutepart.isHereDoc
def isHereDoc(self, line, column): """Check if text at given position is a here document. If language is not known, or text is not parsed yet, ``False`` is returned """ return self._highlighter is not None and \ self._highlighter.isHereDoc(self.document().findBlockByNumbe...
python
def isHereDoc(self, line, column): return self._highlighter is not None and \ self._highlighter.isHereDoc(self.document().findBlockByNumber(line), column)
[ "def", "isHereDoc", "(", "self", ",", "line", ",", "column", ")", ":", "return", "self", ".", "_highlighter", "is", "not", "None", "and", "self", ".", "_highlighter", ".", "isHereDoc", "(", "self", ".", "document", "(", ")", ".", "findBlockByNumber", "("...
Check if text at given position is a here document. If language is not known, or text is not parsed yet, ``False`` is returned
[ "Check", "if", "text", "at", "given", "position", "is", "a", "here", "document", "." ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L850-L856
3,338
andreikop/qutepart
qutepart/__init__.py
Qutepart.mapToAbsPosition
def mapToAbsPosition(self, line, column): """Convert line and column number to absolute position """ block = self.document().findBlockByNumber(line) if not block.isValid(): raise IndexError("Invalid line index %d" % line) if column >= block.length(): raise...
python
def mapToAbsPosition(self, line, column): block = self.document().findBlockByNumber(line) if not block.isValid(): raise IndexError("Invalid line index %d" % line) if column >= block.length(): raise IndexError("Invalid column index %d" % column) return block.positi...
[ "def", "mapToAbsPosition", "(", "self", ",", "line", ",", "column", ")", ":", "block", "=", "self", ".", "document", "(", ")", ".", "findBlockByNumber", "(", "line", ")", "if", "not", "block", ".", "isValid", "(", ")", ":", "raise", "IndexError", "(", ...
Convert line and column number to absolute position
[ "Convert", "line", "and", "column", "number", "to", "absolute", "position" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L881-L889
3,339
andreikop/qutepart
qutepart/__init__.py
Qutepart._setSolidEdgeGeometry
def _setSolidEdgeGeometry(self): """Sets the solid edge line geometry if needed""" if self._lineLengthEdge is not None: cr = self.contentsRect() # contents margin usually gives 1 # cursor rectangle left edge for the very first character usually # gives 4 ...
python
def _setSolidEdgeGeometry(self): if self._lineLengthEdge is not None: cr = self.contentsRect() # contents margin usually gives 1 # cursor rectangle left edge for the very first character usually # gives 4 x = self.fontMetrics().width('9' * self._lineL...
[ "def", "_setSolidEdgeGeometry", "(", "self", ")", ":", "if", "self", ".", "_lineLengthEdge", "is", "not", "None", ":", "cr", "=", "self", ".", "contentsRect", "(", ")", "# contents margin usually gives 1", "# cursor rectangle left edge for the very first character usually...
Sets the solid edge line geometry if needed
[ "Sets", "the", "solid", "edge", "line", "geometry", "if", "needed" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L940-L952
3,340
andreikop/qutepart
qutepart/__init__.py
Qutepart._insertNewBlock
def _insertNewBlock(self): """Enter pressed. Insert properly indented block """ cursor = self.textCursor() atStartOfLine = cursor.positionInBlock() == 0 with self: cursor.insertBlock() if not atStartOfLine: # if whole line is moved down - just lea...
python
def _insertNewBlock(self): cursor = self.textCursor() atStartOfLine = cursor.positionInBlock() == 0 with self: cursor.insertBlock() if not atStartOfLine: # if whole line is moved down - just leave it as is self._indenter.autoIndentBlock(cursor.block()) ...
[ "def", "_insertNewBlock", "(", "self", ")", ":", "cursor", "=", "self", ".", "textCursor", "(", ")", "atStartOfLine", "=", "cursor", ".", "positionInBlock", "(", ")", "==", "0", "with", "self", ":", "cursor", ".", "insertBlock", "(", ")", "if", "not", ...
Enter pressed. Insert properly indented block
[ "Enter", "pressed", ".", "Insert", "properly", "indented", "block" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L954-L964
3,341
andreikop/qutepart
qutepart/__init__.py
Qutepart._currentLineExtraSelections
def _currentLineExtraSelections(self): """QTextEdit.ExtraSelection, which highlightes current line """ if self._currentLineColor is None: return [] def makeSelection(cursor): selection = QTextEdit.ExtraSelection() selection.format.setBackground(self._...
python
def _currentLineExtraSelections(self): if self._currentLineColor is None: return [] def makeSelection(cursor): selection = QTextEdit.ExtraSelection() selection.format.setBackground(self._currentLineColor) selection.format.setProperty(QTextFormat.FullWidth...
[ "def", "_currentLineExtraSelections", "(", "self", ")", ":", "if", "self", ".", "_currentLineColor", "is", "None", ":", "return", "[", "]", "def", "makeSelection", "(", "cursor", ")", ":", "selection", "=", "QTextEdit", ".", "ExtraSelection", "(", ")", "sele...
QTextEdit.ExtraSelection, which highlightes current line
[ "QTextEdit", ".", "ExtraSelection", "which", "highlightes", "current", "line" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L1266-L1285
3,342
andreikop/qutepart
qutepart/__init__.py
Qutepart._selectLines
def _selectLines(self, startBlockNumber, endBlockNumber): """Select whole lines """ startBlock = self.document().findBlockByNumber(startBlockNumber) endBlock = self.document().findBlockByNumber(endBlockNumber) cursor = QTextCursor(startBlock) cursor.setPosition(endBlock.p...
python
def _selectLines(self, startBlockNumber, endBlockNumber): startBlock = self.document().findBlockByNumber(startBlockNumber) endBlock = self.document().findBlockByNumber(endBlockNumber) cursor = QTextCursor(startBlock) cursor.setPosition(endBlock.position(), QTextCursor.KeepAnchor) ...
[ "def", "_selectLines", "(", "self", ",", "startBlockNumber", ",", "endBlockNumber", ")", ":", "startBlock", "=", "self", ".", "document", "(", ")", ".", "findBlockByNumber", "(", "startBlockNumber", ")", "endBlock", "=", "self", ".", "document", "(", ")", "....
Select whole lines
[ "Select", "whole", "lines" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L1381-L1389
3,343
andreikop/qutepart
qutepart/__init__.py
Qutepart._onShortcutCopyLine
def _onShortcutCopyLine(self): """Copy selected lines to the clipboard """ lines = self.lines[self._selectedLinesSlice()] text = self._eol.join(lines) QApplication.clipboard().setText(text)
python
def _onShortcutCopyLine(self): lines = self.lines[self._selectedLinesSlice()] text = self._eol.join(lines) QApplication.clipboard().setText(text)
[ "def", "_onShortcutCopyLine", "(", "self", ")", ":", "lines", "=", "self", ".", "lines", "[", "self", ".", "_selectedLinesSlice", "(", ")", "]", "text", "=", "self", ".", "_eol", ".", "join", "(", "lines", ")", "QApplication", ".", "clipboard", "(", ")...
Copy selected lines to the clipboard
[ "Copy", "selected", "lines", "to", "the", "clipboard" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L1461-L1466
3,344
andreikop/qutepart
qutepart/__init__.py
Qutepart._onShortcutPasteLine
def _onShortcutPasteLine(self): """Paste lines from the clipboard """ lines = self.lines[self._selectedLinesSlice()] text = QApplication.clipboard().text() if text: with self: if self.textCursor().hasSelection(): startBlockNumber, e...
python
def _onShortcutPasteLine(self): lines = self.lines[self._selectedLinesSlice()] text = QApplication.clipboard().text() if text: with self: if self.textCursor().hasSelection(): startBlockNumber, endBlockNumber = self._selectedBlockNumbers() ...
[ "def", "_onShortcutPasteLine", "(", "self", ")", ":", "lines", "=", "self", ".", "lines", "[", "self", ".", "_selectedLinesSlice", "(", ")", "]", "text", "=", "QApplication", ".", "clipboard", "(", ")", ".", "text", "(", ")", "if", "text", ":", "with",...
Paste lines from the clipboard
[ "Paste", "lines", "from", "the", "clipboard" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L1468-L1483
3,345
andreikop/qutepart
qutepart/__init__.py
Qutepart._onShortcutCutLine
def _onShortcutCutLine(self): """Cut selected lines to the clipboard """ lines = self.lines[self._selectedLinesSlice()] self._onShortcutCopyLine() self._onShortcutDeleteLine()
python
def _onShortcutCutLine(self): lines = self.lines[self._selectedLinesSlice()] self._onShortcutCopyLine() self._onShortcutDeleteLine()
[ "def", "_onShortcutCutLine", "(", "self", ")", ":", "lines", "=", "self", ".", "lines", "[", "self", ".", "_selectedLinesSlice", "(", ")", "]", "self", ".", "_onShortcutCopyLine", "(", ")", "self", ".", "_onShortcutDeleteLine", "(", ")" ]
Cut selected lines to the clipboard
[ "Cut", "selected", "lines", "to", "the", "clipboard" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L1485-L1491
3,346
andreikop/qutepart
qutepart/__init__.py
Qutepart._onShortcutDuplicateLine
def _onShortcutDuplicateLine(self): """Duplicate selected text or current line """ cursor = self.textCursor() if cursor.hasSelection(): # duplicate selection text = cursor.selectedText() selectionStart, selectionEnd = cursor.selectionStart(), cursor.selectionEnd(...
python
def _onShortcutDuplicateLine(self): cursor = self.textCursor() if cursor.hasSelection(): # duplicate selection text = cursor.selectedText() selectionStart, selectionEnd = cursor.selectionStart(), cursor.selectionEnd() cursor.setPosition(selectionEnd) curs...
[ "def", "_onShortcutDuplicateLine", "(", "self", ")", ":", "cursor", "=", "self", ".", "textCursor", "(", ")", "if", "cursor", ".", "hasSelection", "(", ")", ":", "# duplicate selection", "text", "=", "cursor", ".", "selectedText", "(", ")", "selectionStart", ...
Duplicate selected text or current line
[ "Duplicate", "selected", "text", "or", "current", "line" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L1493-L1511
3,347
andreikop/qutepart
qutepart/__init__.py
Qutepart._onShortcutPrint
def _onShortcutPrint(self): """Ctrl+P handler. Show dialog, print file """ dialog = QPrintDialog(self) if dialog.exec_() == QDialog.Accepted: printer = dialog.printer() self.print_(printer)
python
def _onShortcutPrint(self): dialog = QPrintDialog(self) if dialog.exec_() == QDialog.Accepted: printer = dialog.printer() self.print_(printer)
[ "def", "_onShortcutPrint", "(", "self", ")", ":", "dialog", "=", "QPrintDialog", "(", "self", ")", "if", "dialog", ".", "exec_", "(", ")", "==", "QDialog", ".", "Accepted", ":", "printer", "=", "dialog", ".", "printer", "(", ")", "self", ".", "print_",...
Ctrl+P handler. Show dialog, print file
[ "Ctrl", "+", "P", "handler", ".", "Show", "dialog", "print", "file" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L1513-L1520
3,348
andreikop/qutepart
qutepart/__init__.py
Qutepart.getMargin
def getMargin(self, name): """Provides the requested margin. Returns a reference to the margin if found and None otherwise """ for margin in self._margins: if margin.getName() == name: return margin return None
python
def getMargin(self, name): for margin in self._margins: if margin.getName() == name: return margin return None
[ "def", "getMargin", "(", "self", ",", "name", ")", ":", "for", "margin", "in", "self", ".", "_margins", ":", "if", "margin", ".", "getName", "(", ")", "==", "name", ":", "return", "margin", "return", "None" ]
Provides the requested margin. Returns a reference to the margin if found and None otherwise
[ "Provides", "the", "requested", "margin", ".", "Returns", "a", "reference", "to", "the", "margin", "if", "found", "and", "None", "otherwise" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L1550-L1557
3,349
andreikop/qutepart
qutepart/__init__.py
Qutepart.delMargin
def delMargin(self, name): """Deletes a margin. Returns True if the margin was deleted and False otherwise. """ for index, margin in enumerate(self._margins): if margin.getName() == name: visible = margin.isVisible() margin.clear() ...
python
def delMargin(self, name): for index, margin in enumerate(self._margins): if margin.getName() == name: visible = margin.isVisible() margin.clear() margin.deleteLater() del self._margins[index] if visible: ...
[ "def", "delMargin", "(", "self", ",", "name", ")", ":", "for", "index", ",", "margin", "in", "enumerate", "(", "self", ".", "_margins", ")", ":", "if", "margin", ".", "getName", "(", ")", "==", "name", ":", "visible", "=", "margin", ".", "isVisible",...
Deletes a margin. Returns True if the margin was deleted and False otherwise.
[ "Deletes", "a", "margin", ".", "Returns", "True", "if", "the", "margin", "was", "deleted", "and", "False", "otherwise", "." ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L1559-L1572
3,350
andreikop/qutepart
qutepart/completer.py
_GlobalUpdateWordSetTimer.cancel
def cancel(self, method): """Cancel scheduled method Safe method, may be called with not-scheduled method""" if method in self._scheduledMethods: self._scheduledMethods.remove(method) if not self._scheduledMethods: self._timer.stop()
python
def cancel(self, method): if method in self._scheduledMethods: self._scheduledMethods.remove(method) if not self._scheduledMethods: self._timer.stop()
[ "def", "cancel", "(", "self", ",", "method", ")", ":", "if", "method", "in", "self", ".", "_scheduledMethods", ":", "self", ".", "_scheduledMethods", ".", "remove", "(", "method", ")", "if", "not", "self", ".", "_scheduledMethods", ":", "self", ".", "_ti...
Cancel scheduled method Safe method, may be called with not-scheduled method
[ "Cancel", "scheduled", "method", "Safe", "method", "may", "be", "called", "with", "not", "-", "scheduled", "method" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L42-L49
3,351
andreikop/qutepart
qutepart/completer.py
_CompletionModel.setData
def setData(self, wordBeforeCursor, wholeWord): """Set model information """ self._typedText = wordBeforeCursor self.words = self._makeListOfCompletions(wordBeforeCursor, wholeWord) commonStart = self._commonWordStart(self.words) self.canCompleteText = commonStart[len(wor...
python
def setData(self, wordBeforeCursor, wholeWord): self._typedText = wordBeforeCursor self.words = self._makeListOfCompletions(wordBeforeCursor, wholeWord) commonStart = self._commonWordStart(self.words) self.canCompleteText = commonStart[len(wordBeforeCursor):] self.layoutChanged....
[ "def", "setData", "(", "self", ",", "wordBeforeCursor", ",", "wholeWord", ")", ":", "self", ".", "_typedText", "=", "wordBeforeCursor", "self", ".", "words", "=", "self", ".", "_makeListOfCompletions", "(", "wordBeforeCursor", ",", "wholeWord", ")", "commonStart...
Set model information
[ "Set", "model", "information" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L69-L77
3,352
andreikop/qutepart
qutepart/completer.py
_CompletionModel.data
def data(self, index, role): """QAbstractItemModel method implementation """ if role == Qt.DisplayRole and \ index.row() < len(self.words): text = self.words[index.row()] typed = text[:len(self._typedText)] canComplete = text[len(self._typedText):le...
python
def data(self, index, role): if role == Qt.DisplayRole and \ index.row() < len(self.words): text = self.words[index.row()] typed = text[:len(self._typedText)] canComplete = text[len(self._typedText):len(self._typedText) + len(self.canCompleteText)] rest...
[ "def", "data", "(", "self", ",", "index", ",", "role", ")", ":", "if", "role", "==", "Qt", ".", "DisplayRole", "and", "index", ".", "row", "(", ")", "<", "len", "(", "self", ".", "words", ")", ":", "text", "=", "self", ".", "words", "[", "index...
QAbstractItemModel method implementation
[ "QAbstractItemModel", "method", "implementation" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L85-L105
3,353
andreikop/qutepart
qutepart/completer.py
_CompletionModel._makeListOfCompletions
def _makeListOfCompletions(self, wordBeforeCursor, wholeWord): """Make list of completions, which shall be shown """ onlySuitable = [word for word in self._wordSet \ if word.startswith(wordBeforeCursor) and \ word != wholeWord] ...
python
def _makeListOfCompletions(self, wordBeforeCursor, wholeWord): onlySuitable = [word for word in self._wordSet \ if word.startswith(wordBeforeCursor) and \ word != wholeWord] return sorted(onlySuitable)
[ "def", "_makeListOfCompletions", "(", "self", ",", "wordBeforeCursor", ",", "wholeWord", ")", ":", "onlySuitable", "=", "[", "word", "for", "word", "in", "self", ".", "_wordSet", "if", "word", ".", "startswith", "(", "wordBeforeCursor", ")", "and", "word", "...
Make list of completions, which shall be shown
[ "Make", "list", "of", "completions", "which", "shall", "be", "shown" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L134-L141
3,354
andreikop/qutepart
qutepart/completer.py
_CompletionList.close
def close(self): """Explicitly called destructor. Removes widget from the qpart """ self._closeIfNotUpdatedTimer.stop() self._qpart.removeEventFilter(self) self._qpart.cursorPositionChanged.disconnect(self._onCursorPositionChanged) QListView.close(self)
python
def close(self): self._closeIfNotUpdatedTimer.stop() self._qpart.removeEventFilter(self) self._qpart.cursorPositionChanged.disconnect(self._onCursorPositionChanged) QListView.close(self)
[ "def", "close", "(", "self", ")", ":", "self", ".", "_closeIfNotUpdatedTimer", ".", "stop", "(", ")", "self", ".", "_qpart", ".", "removeEventFilter", "(", "self", ")", "self", ".", "_qpart", ".", "cursorPositionChanged", ".", "disconnect", "(", "self", "....
Explicitly called destructor. Removes widget from the qpart
[ "Explicitly", "called", "destructor", ".", "Removes", "widget", "from", "the", "qpart" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L208-L216
3,355
andreikop/qutepart
qutepart/completer.py
_CompletionList.sizeHint
def sizeHint(self): """QWidget.sizeHint implementation Automatically resizes the widget according to rows count FIXME very bad algorithm. Remove all this margins, if you can """ width = max([self.fontMetrics().width(word) \ for word in self.model().words]...
python
def sizeHint(self): width = max([self.fontMetrics().width(word) \ for word in self.model().words]) width = width * 1.4 # FIXME bad hack. invent better formula width += 30 # margin # drawn with scrollbar without +2. I don't know why rowCount = min(self.m...
[ "def", "sizeHint", "(", "self", ")", ":", "width", "=", "max", "(", "[", "self", ".", "fontMetrics", "(", ")", ".", "width", "(", "word", ")", "for", "word", "in", "self", ".", "model", "(", ")", ".", "words", "]", ")", "width", "=", "width", "...
QWidget.sizeHint implementation Automatically resizes the widget according to rows count FIXME very bad algorithm. Remove all this margins, if you can
[ "QWidget", ".", "sizeHint", "implementation", "Automatically", "resizes", "the", "widget", "according", "to", "rows", "count" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L218-L233
3,356
andreikop/qutepart
qutepart/completer.py
_CompletionList._horizontalShift
def _horizontalShift(self): """List should be plased such way, that typed text in the list is under typed text in the editor """ strangeAdjustment = 2 # I don't know why. Probably, won't work on other systems and versions return self.fontMetrics().width(self.model().typedText())...
python
def _horizontalShift(self): strangeAdjustment = 2 # I don't know why. Probably, won't work on other systems and versions return self.fontMetrics().width(self.model().typedText()) + strangeAdjustment
[ "def", "_horizontalShift", "(", "self", ")", ":", "strangeAdjustment", "=", "2", "# I don't know why. Probably, won't work on other systems and versions", "return", "self", ".", "fontMetrics", "(", ")", ".", "width", "(", "self", ".", "model", "(", ")", ".", "typedT...
List should be plased such way, that typed text in the list is under typed text in the editor
[ "List", "should", "be", "plased", "such", "way", "that", "typed", "text", "in", "the", "list", "is", "under", "typed", "text", "in", "the", "editor" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L240-L245
3,357
andreikop/qutepart
qutepart/completer.py
_CompletionList.updateGeometry
def updateGeometry(self): """Move widget to point under cursor """ WIDGET_BORDER_MARGIN = 5 SCROLLBAR_WIDTH = 30 # just a guess sizeHint = self.sizeHint() width = sizeHint.width() height = sizeHint.height() cursorRect = self._qpart.cursorRect() ...
python
def updateGeometry(self): WIDGET_BORDER_MARGIN = 5 SCROLLBAR_WIDTH = 30 # just a guess sizeHint = self.sizeHint() width = sizeHint.width() height = sizeHint.height() cursorRect = self._qpart.cursorRect() parentSize = self.parentWidget().size() spaceBel...
[ "def", "updateGeometry", "(", "self", ")", ":", "WIDGET_BORDER_MARGIN", "=", "5", "SCROLLBAR_WIDTH", "=", "30", "# just a guess", "sizeHint", "=", "self", ".", "sizeHint", "(", ")", "width", "=", "sizeHint", ".", "width", "(", ")", "height", "=", "sizeHint",...
Move widget to point under cursor
[ "Move", "widget", "to", "point", "under", "cursor" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L247-L283
3,358
andreikop/qutepart
qutepart/completer.py
_CompletionList.eventFilter
def eventFilter(self, object, event): """Catch events from qpart Move selection, select item, or close themselves """ if event.type() == QEvent.KeyPress and event.modifiers() == Qt.NoModifier: if event.key() == Qt.Key_Escape: self.closeMe.emit() ...
python
def eventFilter(self, object, event): if event.type() == QEvent.KeyPress and event.modifiers() == Qt.NoModifier: if event.key() == Qt.Key_Escape: self.closeMe.emit() return True elif event.key() == Qt.Key_Down: if self._selectedIndex + 1 < ...
[ "def", "eventFilter", "(", "self", ",", "object", ",", "event", ")", ":", "if", "event", ".", "type", "(", ")", "==", "QEvent", ".", "KeyPress", "and", "event", ".", "modifiers", "(", ")", "==", "Qt", ".", "NoModifier", ":", "if", "event", ".", "ke...
Catch events from qpart Move selection, select item, or close themselves
[ "Catch", "events", "from", "qpart", "Move", "selection", "select", "item", "or", "close", "themselves" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L296-L322
3,359
andreikop/qutepart
qutepart/completer.py
_CompletionList._selectItem
def _selectItem(self, index): """Select item in the list """ self._selectedIndex = index self.setCurrentIndex(self.model().createIndex(index, 0))
python
def _selectItem(self, index): self._selectedIndex = index self.setCurrentIndex(self.model().createIndex(index, 0))
[ "def", "_selectItem", "(", "self", ",", "index", ")", ":", "self", ".", "_selectedIndex", "=", "index", "self", ".", "setCurrentIndex", "(", "self", ".", "model", "(", ")", ".", "createIndex", "(", "index", ",", "0", ")", ")" ]
Select item in the list
[ "Select", "item", "in", "the", "list" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L324-L328
3,360
andreikop/qutepart
qutepart/completer.py
Completer._updateWordSet
def _updateWordSet(self): """Make a set of words, which shall be completed, from text """ self._wordSet = set(self._keywords) | set(self._customCompletions) start = time.time() for line in self._qpart.lines: for match in _wordRegExp.findall(line): se...
python
def _updateWordSet(self): self._wordSet = set(self._keywords) | set(self._customCompletions) start = time.time() for line in self._qpart.lines: for match in _wordRegExp.findall(line): self._wordSet.add(match) if time.time() - start > self._WORD_SET_UPDAT...
[ "def", "_updateWordSet", "(", "self", ")", ":", "self", ".", "_wordSet", "=", "set", "(", "self", ".", "_keywords", ")", "|", "set", "(", "self", ".", "_customCompletions", ")", "start", "=", "time", ".", "time", "(", ")", "for", "line", "in", "self"...
Make a set of words, which shall be completed, from text
[ "Make", "a", "set", "of", "words", "which", "shall", "be", "completed", "from", "text" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L375-L387
3,361
andreikop/qutepart
qutepart/completer.py
Completer.invokeCompletionIfAvailable
def invokeCompletionIfAvailable(self, requestedByUser=False): """Invoke completion, if available. Called after text has been typed in qpart Returns True, if invoked """ if self._qpart.completionEnabled and self._wordSet is not None: wordBeforeCursor = self._wordBeforeCursor()...
python
def invokeCompletionIfAvailable(self, requestedByUser=False): if self._qpart.completionEnabled and self._wordSet is not None: wordBeforeCursor = self._wordBeforeCursor() wholeWord = wordBeforeCursor + self._wordAfterCursor() forceShow = requestedByUser or self._completionOpe...
[ "def", "invokeCompletionIfAvailable", "(", "self", ",", "requestedByUser", "=", "False", ")", ":", "if", "self", ".", "_qpart", ".", "completionEnabled", "and", "self", ".", "_wordSet", "is", "not", "None", ":", "wordBeforeCursor", "=", "self", ".", "_wordBefo...
Invoke completion, if available. Called after text has been typed in qpart Returns True, if invoked
[ "Invoke", "completion", "if", "available", ".", "Called", "after", "text", "has", "been", "typed", "in", "qpart", "Returns", "True", "if", "invoked" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L408-L433
3,362
andreikop/qutepart
qutepart/completer.py
Completer._closeCompletion
def _closeCompletion(self): """Close completion, if visible. Delete widget """ if self._widget is not None: self._widget.close() self._widget = None self._completionOpenedManually = False
python
def _closeCompletion(self): if self._widget is not None: self._widget.close() self._widget = None self._completionOpenedManually = False
[ "def", "_closeCompletion", "(", "self", ")", ":", "if", "self", ".", "_widget", "is", "not", "None", ":", "self", ".", "_widget", ".", "close", "(", ")", "self", ".", "_widget", "=", "None", "self", ".", "_completionOpenedManually", "=", "False" ]
Close completion, if visible. Delete widget
[ "Close", "completion", "if", "visible", ".", "Delete", "widget" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L435-L442
3,363
andreikop/qutepart
qutepart/completer.py
Completer._onCompletionListItemSelected
def _onCompletionListItemSelected(self, index): """Item selected. Insert completion to editor """ model = self._widget.model() selectedWord = model.words[index] textToInsert = selectedWord[len(model.typedText()):] self._qpart.textCursor().insertText(textToInsert) ...
python
def _onCompletionListItemSelected(self, index): model = self._widget.model() selectedWord = model.words[index] textToInsert = selectedWord[len(model.typedText()):] self._qpart.textCursor().insertText(textToInsert) self._closeCompletion()
[ "def", "_onCompletionListItemSelected", "(", "self", ",", "index", ")", ":", "model", "=", "self", ".", "_widget", ".", "model", "(", ")", "selectedWord", "=", "model", ".", "words", "[", "index", "]", "textToInsert", "=", "selectedWord", "[", "len", "(", ...
Item selected. Insert completion to editor
[ "Item", "selected", ".", "Insert", "completion", "to", "editor" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L466-L473
3,364
andreikop/qutepart
qutepart/completer.py
Completer._onCompletionListTabPressed
def _onCompletionListTabPressed(self): """Tab pressed on completion list Insert completable text, if available """ canCompleteText = self._widget.model().canCompleteText if canCompleteText: self._qpart.textCursor().insertText(canCompleteText) self.invokeCo...
python
def _onCompletionListTabPressed(self): canCompleteText = self._widget.model().canCompleteText if canCompleteText: self._qpart.textCursor().insertText(canCompleteText) self.invokeCompletionIfAvailable()
[ "def", "_onCompletionListTabPressed", "(", "self", ")", ":", "canCompleteText", "=", "self", ".", "_widget", ".", "model", "(", ")", ".", "canCompleteText", "if", "canCompleteText", ":", "self", ".", "_qpart", ".", "textCursor", "(", ")", ".", "insertText", ...
Tab pressed on completion list Insert completable text, if available
[ "Tab", "pressed", "on", "completion", "list", "Insert", "completable", "text", "if", "available" ]
109d76b239751318bcef06f39b2fbbf18687a40b
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L475-L482
3,365
twidi/django-extended-choices
extended_choices/choices.py
create_choice
def create_choice(klass, choices, subsets, kwargs): """Create an instance of a ``Choices`` object. Parameters ---------- klass : type The class to use to recreate the object. choices : list(tuple) A list of choices as expected by the ``__init__`` method of ``klass``. subsets : l...
python
def create_choice(klass, choices, subsets, kwargs): obj = klass(*choices, **kwargs) for subset in subsets: obj.add_subset(*subset) return obj
[ "def", "create_choice", "(", "klass", ",", "choices", ",", "subsets", ",", "kwargs", ")", ":", "obj", "=", "klass", "(", "*", "choices", ",", "*", "*", "kwargs", ")", "for", "subset", "in", "subsets", ":", "obj", ".", "add_subset", "(", "*", "subset"...
Create an instance of a ``Choices`` object. Parameters ---------- klass : type The class to use to recreate the object. choices : list(tuple) A list of choices as expected by the ``__init__`` method of ``klass``. subsets : list(tuple) A tuple with an entry for each subset to...
[ "Create", "an", "instance", "of", "a", "Choices", "object", "." ]
bb310c5da4d53685c69173541172e4b813a6afb2
https://github.com/twidi/django-extended-choices/blob/bb310c5da4d53685c69173541172e4b813a6afb2/extended_choices/choices.py#L1078-L1104
3,366
twidi/django-extended-choices
extended_choices/choices.py
Choices._convert_choices
def _convert_choices(self, choices): """Validate each choices Parameters ---------- choices : list of tuples The list of choices to be added Returns ------- list The list of the added constants """ # Check that each new ...
python
def _convert_choices(self, choices): # Check that each new constant is unique. constants = [c[0] for c in choices] constants_doubles = [c for c in constants if constants.count(c) > 1] if constants_doubles: raise ValueError("You cannot declare two constants with the same const...
[ "def", "_convert_choices", "(", "self", ",", "choices", ")", ":", "# Check that each new constant is unique.", "constants", "=", "[", "c", "[", "0", "]", "for", "c", "in", "choices", "]", "constants_doubles", "=", "[", "c", "for", "c", "in", "constants", "if...
Validate each choices Parameters ---------- choices : list of tuples The list of choices to be added Returns ------- list The list of the added constants
[ "Validate", "each", "choices" ]
bb310c5da4d53685c69173541172e4b813a6afb2
https://github.com/twidi/django-extended-choices/blob/bb310c5da4d53685c69173541172e4b813a6afb2/extended_choices/choices.py#L239-L312
3,367
twidi/django-extended-choices
extended_choices/choices.py
Choices.add_choices
def add_choices(self, *choices, **kwargs): """Add some choices to the current ``Choices`` instance. The given choices will be added to the existing choices. If a ``name`` attribute is passed, a new subset will be created with all the given choices. Note that it's not possible t...
python
def add_choices(self, *choices, **kwargs): # It the ``_mutable`` flag is falsy, which is the case for subsets, we refuse to add # new choices. if not self._mutable: raise RuntimeError("This ``Choices`` instance cannot be updated.") # Check for an optional subset name as the ...
[ "def", "add_choices", "(", "self", ",", "*", "choices", ",", "*", "*", "kwargs", ")", ":", "# It the ``_mutable`` flag is falsy, which is the case for subsets, we refuse to add", "# new choices.", "if", "not", "self", ".", "_mutable", ":", "raise", "RuntimeError", "(", ...
Add some choices to the current ``Choices`` instance. The given choices will be added to the existing choices. If a ``name`` attribute is passed, a new subset will be created with all the given choices. Note that it's not possible to add new choices to a subset. Parameters ...
[ "Add", "some", "choices", "to", "the", "current", "Choices", "instance", "." ]
bb310c5da4d53685c69173541172e4b813a6afb2
https://github.com/twidi/django-extended-choices/blob/bb310c5da4d53685c69173541172e4b813a6afb2/extended_choices/choices.py#L314-L392
3,368
twidi/django-extended-choices
extended_choices/choices.py
Choices.extract_subset
def extract_subset(self, *constants): """Create a subset of entries This subset is a new ``Choices`` instance, with only the wanted constants from the main ``Choices`` (each "choice entry" in the subset is shared from the main ``Choices``) Parameters ---------- *constan...
python
def extract_subset(self, *constants): # Ensure that all passed constants exists as such in the list of available constants. bad_constants = set(constants).difference(self.constants) if bad_constants: raise ValueError("All constants in subsets should be in parent choice. " ...
[ "def", "extract_subset", "(", "self", ",", "*", "constants", ")", ":", "# Ensure that all passed constants exists as such in the list of available constants.", "bad_constants", "=", "set", "(", "constants", ")", ".", "difference", "(", "self", ".", "constants", ")", "if...
Create a subset of entries This subset is a new ``Choices`` instance, with only the wanted constants from the main ``Choices`` (each "choice entry" in the subset is shared from the main ``Choices``) Parameters ---------- *constants: list The constants names of this ...
[ "Create", "a", "subset", "of", "entries" ]
bb310c5da4d53685c69173541172e4b813a6afb2
https://github.com/twidi/django-extended-choices/blob/bb310c5da4d53685c69173541172e4b813a6afb2/extended_choices/choices.py#L394-L462
3,369
twidi/django-extended-choices
extended_choices/choices.py
Choices.add_subset
def add_subset(self, name, constants): """Add a subset of entries under a defined name. This allow to defined a "sub choice" if a django field need to not have the whole choice available. The sub-choice is a new ``Choices`` instance, with only the wanted the constant from the m...
python
def add_subset(self, name, constants): # Ensure that the name is not already used as an attribute. if hasattr(self, name): raise ValueError("Cannot use '%s' as a subset name. " "It's already an attribute." % name) subset = self.extract_subset(*constants)...
[ "def", "add_subset", "(", "self", ",", "name", ",", "constants", ")", ":", "# Ensure that the name is not already used as an attribute.", "if", "hasattr", "(", "self", ",", "name", ")", ":", "raise", "ValueError", "(", "\"Cannot use '%s' as a subset name. \"", "\"It's a...
Add a subset of entries under a defined name. This allow to defined a "sub choice" if a django field need to not have the whole choice available. The sub-choice is a new ``Choices`` instance, with only the wanted the constant from the main ``Choices`` (each "choice entry" in the subset...
[ "Add", "a", "subset", "of", "entries", "under", "a", "defined", "name", "." ]
bb310c5da4d53685c69173541172e4b813a6afb2
https://github.com/twidi/django-extended-choices/blob/bb310c5da4d53685c69173541172e4b813a6afb2/extended_choices/choices.py#L464-L530
3,370
twidi/django-extended-choices
extended_choices/choices.py
AutoDisplayChoices._convert_choices
def _convert_choices(self, choices): """Auto create display values then call super method""" final_choices = [] for choice in choices: if isinstance(choice, ChoiceEntry): final_choices.append(choice) continue original_choice = choice ...
python
def _convert_choices(self, choices): final_choices = [] for choice in choices: if isinstance(choice, ChoiceEntry): final_choices.append(choice) continue original_choice = choice choice = list(choice) length = len(choice) ...
[ "def", "_convert_choices", "(", "self", ",", "choices", ")", ":", "final_choices", "=", "[", "]", "for", "choice", "in", "choices", ":", "if", "isinstance", "(", "choice", ",", "ChoiceEntry", ")", ":", "final_choices", ".", "append", "(", "choice", ")", ...
Auto create display values then call super method
[ "Auto", "create", "display", "values", "then", "call", "super", "method" ]
bb310c5da4d53685c69173541172e4b813a6afb2
https://github.com/twidi/django-extended-choices/blob/bb310c5da4d53685c69173541172e4b813a6afb2/extended_choices/choices.py#L930-L972
3,371
twidi/django-extended-choices
extended_choices/choices.py
AutoChoices.add_choices
def add_choices(self, *choices, **kwargs): """Disallow super method to thing the first argument is a subset name""" return super(AutoChoices, self).add_choices(_NO_SUBSET_NAME_, *choices, **kwargs)
python
def add_choices(self, *choices, **kwargs): return super(AutoChoices, self).add_choices(_NO_SUBSET_NAME_, *choices, **kwargs)
[ "def", "add_choices", "(", "self", ",", "*", "choices", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "AutoChoices", ",", "self", ")", ".", "add_choices", "(", "_NO_SUBSET_NAME_", ",", "*", "choices", ",", "*", "*", "kwargs", ")" ]
Disallow super method to thing the first argument is a subset name
[ "Disallow", "super", "method", "to", "thing", "the", "first", "argument", "is", "a", "subset", "name" ]
bb310c5da4d53685c69173541172e4b813a6afb2
https://github.com/twidi/django-extended-choices/blob/bb310c5da4d53685c69173541172e4b813a6afb2/extended_choices/choices.py#L1019-L1021
3,372
twidi/django-extended-choices
extended_choices/choices.py
AutoChoices._convert_choices
def _convert_choices(self, choices): """Auto create db values then call super method""" final_choices = [] for choice in choices: if isinstance(choice, ChoiceEntry): final_choices.append(choice) continue original_choice = choice ...
python
def _convert_choices(self, choices): final_choices = [] for choice in choices: if isinstance(choice, ChoiceEntry): final_choices.append(choice) continue original_choice = choice if isinstance(choice, six.string_types): ...
[ "def", "_convert_choices", "(", "self", ",", "choices", ")", ":", "final_choices", "=", "[", "]", "for", "choice", "in", "choices", ":", "if", "isinstance", "(", "choice", ",", "ChoiceEntry", ")", ":", "final_choices", ".", "append", "(", "choice", ")", ...
Auto create db values then call super method
[ "Auto", "create", "db", "values", "then", "call", "super", "method" ]
bb310c5da4d53685c69173541172e4b813a6afb2
https://github.com/twidi/django-extended-choices/blob/bb310c5da4d53685c69173541172e4b813a6afb2/extended_choices/choices.py#L1023-L1075
3,373
twidi/django-extended-choices
extended_choices/fields.py
NamedExtendedChoiceFormField.to_python
def to_python(self, value): """Convert the constant to the real choice value.""" # ``is_required`` is already checked in ``validate``. if value is None: return None # Validate the type. if not isinstance(value, six.string_types): raise forms.ValidationEr...
python
def to_python(self, value): # ``is_required`` is already checked in ``validate``. if value is None: return None # Validate the type. if not isinstance(value, six.string_types): raise forms.ValidationError( "Invalid value type (should be a string)....
[ "def", "to_python", "(", "self", ",", "value", ")", ":", "# ``is_required`` is already checked in ``validate``.", "if", "value", "is", "None", ":", "return", "None", "# Validate the type.", "if", "not", "isinstance", "(", "value", ",", "six", ".", "string_types", ...
Convert the constant to the real choice value.
[ "Convert", "the", "constant", "to", "the", "real", "choice", "value", "." ]
bb310c5da4d53685c69173541172e4b813a6afb2
https://github.com/twidi/django-extended-choices/blob/bb310c5da4d53685c69173541172e4b813a6afb2/extended_choices/fields.py#L37-L61
3,374
twidi/django-extended-choices
extended_choices/helpers.py
create_choice_attribute
def create_choice_attribute(creator_type, value, choice_entry): """Create an instance of a subclass of ChoiceAttributeMixin for the given value. Parameters ---------- creator_type : type ``ChoiceAttributeMixin`` or a subclass, from which we'll call the ``get_class_for_value`` class-meth...
python
def create_choice_attribute(creator_type, value, choice_entry): klass = creator_type.get_class_for_value(value) return klass(value, choice_entry)
[ "def", "create_choice_attribute", "(", "creator_type", ",", "value", ",", "choice_entry", ")", ":", "klass", "=", "creator_type", ".", "get_class_for_value", "(", "value", ")", "return", "klass", "(", "value", ",", "choice_entry", ")" ]
Create an instance of a subclass of ChoiceAttributeMixin for the given value. Parameters ---------- creator_type : type ``ChoiceAttributeMixin`` or a subclass, from which we'll call the ``get_class_for_value`` class-method. value : ? The value for which we want to create an inst...
[ "Create", "an", "instance", "of", "a", "subclass", "of", "ChoiceAttributeMixin", "for", "the", "given", "value", "." ]
bb310c5da4d53685c69173541172e4b813a6afb2
https://github.com/twidi/django-extended-choices/blob/bb310c5da4d53685c69173541172e4b813a6afb2/extended_choices/helpers.py#L200-L222
3,375
twidi/django-extended-choices
extended_choices/helpers.py
ChoiceAttributeMixin.get_class_for_value
def get_class_for_value(cls, value): """Class method to construct a class based on this mixin and the type of the given value. Parameters ---------- value: ? The value from which to extract the type to create the new class. Notes ----- The create cl...
python
def get_class_for_value(cls, value): type_ = value.__class__ # Check if the type is already a ``ChoiceAttribute`` if issubclass(type_, ChoiceAttributeMixin): # In this case we can return this type return type_ # Create a new class only if it wasn't already creat...
[ "def", "get_class_for_value", "(", "cls", ",", "value", ")", ":", "type_", "=", "value", ".", "__class__", "# Check if the type is already a ``ChoiceAttribute``", "if", "issubclass", "(", "type_", ",", "ChoiceAttributeMixin", ")", ":", "# In this case we can return this t...
Class method to construct a class based on this mixin and the type of the given value. Parameters ---------- value: ? The value from which to extract the type to create the new class. Notes ----- The create classes are cached (in ``cls.__classes_by_type``) ...
[ "Class", "method", "to", "construct", "a", "class", "based", "on", "this", "mixin", "and", "the", "type", "of", "the", "given", "value", "." ]
bb310c5da4d53685c69173541172e4b813a6afb2
https://github.com/twidi/django-extended-choices/blob/bb310c5da4d53685c69173541172e4b813a6afb2/extended_choices/helpers.py#L136-L166
3,376
twidi/django-extended-choices
extended_choices/helpers.py
ChoiceEntry._get_choice_attribute
def _get_choice_attribute(self, value): """Get a choice attribute for the given value. Parameters ---------- value: ? The value for which we want a choice attribute. Returns ------- An instance of a class based on ``ChoiceAttributeMixin`` for the giv...
python
def _get_choice_attribute(self, value): if value is None: raise ValueError('Using `None` in a `Choices` object is not supported. You may ' 'use an empty string.') return create_choice_attribute(self.ChoiceAttributeMixin, value, self)
[ "def", "_get_choice_attribute", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "raise", "ValueError", "(", "'Using `None` in a `Choices` object is not supported. You may '", "'use an empty string.'", ")", "return", "create_choice_attribute", "(", "...
Get a choice attribute for the given value. Parameters ---------- value: ? The value for which we want a choice attribute. Returns ------- An instance of a class based on ``ChoiceAttributeMixin`` for the given value. Raises ------ Va...
[ "Get", "a", "choice", "attribute", "for", "the", "given", "value", "." ]
bb310c5da4d53685c69173541172e4b813a6afb2
https://github.com/twidi/django-extended-choices/blob/bb310c5da4d53685c69173541172e4b813a6afb2/extended_choices/helpers.py#L306-L329
3,377
grundic/yagocd
yagocd/session.py
Session.urljoin
def urljoin(*args): """ Joins given arguments into a url. Trailing but not leading slashes are stripped for each argument. """ return "/".join(map(lambda x: str(x).rstrip('/'), args)).rstrip('/')
python
def urljoin(*args): return "/".join(map(lambda x: str(x).rstrip('/'), args)).rstrip('/')
[ "def", "urljoin", "(", "*", "args", ")", ":", "return", "\"/\"", ".", "join", "(", "map", "(", "lambda", "x", ":", "str", "(", "x", ")", ".", "rstrip", "(", "'/'", ")", ",", "args", ")", ")", ".", "rstrip", "(", "'/'", ")" ]
Joins given arguments into a url. Trailing but not leading slashes are stripped for each argument.
[ "Joins", "given", "arguments", "into", "a", "url", ".", "Trailing", "but", "not", "leading", "slashes", "are", "stripped", "for", "each", "argument", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/session.py#L52-L57
3,378
grundic/yagocd
yagocd/session.py
Session.server_version
def server_version(self): """ Special method for getting server version. Because of different behaviour on different versions of server, we have to pass different headers to the endpoints. This method requests the version from server and caches it in internal variable, s...
python
def server_version(self): if self.__server_version is None: from yagocd.resources.info import InfoManager self.__server_version = InfoManager(self).version return self.__server_version
[ "def", "server_version", "(", "self", ")", ":", "if", "self", ".", "__server_version", "is", "None", ":", "from", "yagocd", ".", "resources", ".", "info", "import", "InfoManager", "self", ".", "__server_version", "=", "InfoManager", "(", "self", ")", ".", ...
Special method for getting server version. Because of different behaviour on different versions of server, we have to pass different headers to the endpoints. This method requests the version from server and caches it in internal variable, so other resources could use it. :retu...
[ "Special", "method", "for", "getting", "server", "version", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/session.py#L69-L84
3,379
grundic/yagocd
yagocd/resources/job.py
JobInstance.pipeline_name
def pipeline_name(self): """ Get pipeline name of current job instance. Because instantiating job instance could be performed in different ways and those return different results, we have to check where from to get name of the pipeline. :return: pipeline name. """ ...
python
def pipeline_name(self): if 'pipeline_name' in self.data and self.data.pipeline_name: return self.data.get('pipeline_name') elif self.stage.pipeline is not None: return self.stage.pipeline.data.name else: return self.stage.data.pipeline_name
[ "def", "pipeline_name", "(", "self", ")", ":", "if", "'pipeline_name'", "in", "self", ".", "data", "and", "self", ".", "data", ".", "pipeline_name", ":", "return", "self", ".", "data", ".", "get", "(", "'pipeline_name'", ")", "elif", "self", ".", "stage"...
Get pipeline name of current job instance. Because instantiating job instance could be performed in different ways and those return different results, we have to check where from to get name of the pipeline. :return: pipeline name.
[ "Get", "pipeline", "name", "of", "current", "job", "instance", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/job.py#L134-L148
3,380
grundic/yagocd
yagocd/resources/job.py
JobInstance.pipeline_counter
def pipeline_counter(self): """ Get pipeline counter of current job instance. Because instantiating job instance could be performed in different ways and those return different results, we have to check where from to get counter of the pipeline. :return: pipeline counter. ...
python
def pipeline_counter(self): if 'pipeline_counter' in self.data and self.data.pipeline_counter: return self.data.get('pipeline_counter') elif self.stage.pipeline is not None: return self.stage.pipeline.data.counter else: return self.stage.data.pipeline_counter
[ "def", "pipeline_counter", "(", "self", ")", ":", "if", "'pipeline_counter'", "in", "self", ".", "data", "and", "self", ".", "data", ".", "pipeline_counter", ":", "return", "self", ".", "data", ".", "get", "(", "'pipeline_counter'", ")", "elif", "self", "....
Get pipeline counter of current job instance. Because instantiating job instance could be performed in different ways and those return different results, we have to check where from to get counter of the pipeline. :return: pipeline counter.
[ "Get", "pipeline", "counter", "of", "current", "job", "instance", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/job.py#L151-L165
3,381
grundic/yagocd
yagocd/resources/job.py
JobInstance.stage_name
def stage_name(self): """ Get stage name of current job instance. Because instantiating job instance could be performed in different ways and those return different results, we have to check where from to get name of the stage. :return: stage name. """ if 'stage...
python
def stage_name(self): if 'stage_name' in self.data and self.data.stage_name: return self.data.get('stage_name') else: return self.stage.data.name
[ "def", "stage_name", "(", "self", ")", ":", "if", "'stage_name'", "in", "self", ".", "data", "and", "self", ".", "data", ".", "stage_name", ":", "return", "self", ".", "data", ".", "get", "(", "'stage_name'", ")", "else", ":", "return", "self", ".", ...
Get stage name of current job instance. Because instantiating job instance could be performed in different ways and those return different results, we have to check where from to get name of the stage. :return: stage name.
[ "Get", "stage", "name", "of", "current", "job", "instance", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/job.py#L168-L180
3,382
grundic/yagocd
yagocd/resources/job.py
JobInstance.stage_counter
def stage_counter(self): """ Get stage counter of current job instance. Because instantiating job instance could be performed in different ways and those return different results, we have to check where from to get counter of the stage. :return: stage counter. """ ...
python
def stage_counter(self): if 'stage_counter' in self.data and self.data.stage_counter: return self.data.get('stage_counter') else: return self.stage.data.counter
[ "def", "stage_counter", "(", "self", ")", ":", "if", "'stage_counter'", "in", "self", ".", "data", "and", "self", ".", "data", ".", "stage_counter", ":", "return", "self", ".", "data", ".", "get", "(", "'stage_counter'", ")", "else", ":", "return", "self...
Get stage counter of current job instance. Because instantiating job instance could be performed in different ways and those return different results, we have to check where from to get counter of the stage. :return: stage counter.
[ "Get", "stage", "counter", "of", "current", "job", "instance", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/job.py#L183-L195
3,383
grundic/yagocd
yagocd/resources/job.py
JobInstance.artifacts
def artifacts(self): """ Property for accessing artifact manager of the current job. :return: instance of :class:`yagocd.resources.artifact.ArtifactManager` :rtype: yagocd.resources.artifact.ArtifactManager """ return ArtifactManager( session=self._session, ...
python
def artifacts(self): return ArtifactManager( session=self._session, pipeline_name=self.pipeline_name, pipeline_counter=self.pipeline_counter, stage_name=self.stage_name, stage_counter=self.stage_counter, job_name=self.data.name )
[ "def", "artifacts", "(", "self", ")", ":", "return", "ArtifactManager", "(", "session", "=", "self", ".", "_session", ",", "pipeline_name", "=", "self", ".", "pipeline_name", ",", "pipeline_counter", "=", "self", ".", "pipeline_counter", ",", "stage_name", "="...
Property for accessing artifact manager of the current job. :return: instance of :class:`yagocd.resources.artifact.ArtifactManager` :rtype: yagocd.resources.artifact.ArtifactManager
[ "Property", "for", "accessing", "artifact", "manager", "of", "the", "current", "job", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/job.py#L218-L232
3,384
grundic/yagocd
yagocd/resources/stage.py
StageInstance.url
def url(self): """ Returns url for accessing stage instance. """ return "{server_url}/go/pipelines/{pipeline_name}/{pipeline_counter}/{stage_name}/{stage_counter}".format( server_url=self._session.server_url, pipeline_name=self.pipeline_name, pipeline_...
python
def url(self): return "{server_url}/go/pipelines/{pipeline_name}/{pipeline_counter}/{stage_name}/{stage_counter}".format( server_url=self._session.server_url, pipeline_name=self.pipeline_name, pipeline_counter=self.pipeline_counter, stage_name=self.data.name, ...
[ "def", "url", "(", "self", ")", ":", "return", "\"{server_url}/go/pipelines/{pipeline_name}/{pipeline_counter}/{stage_name}/{stage_counter}\"", ".", "format", "(", "server_url", "=", "self", ".", "_session", ".", "server_url", ",", "pipeline_name", "=", "self", ".", "pi...
Returns url for accessing stage instance.
[ "Returns", "url", "for", "accessing", "stage", "instance", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/stage.py#L247-L257
3,385
grundic/yagocd
yagocd/resources/stage.py
StageInstance.pipeline_name
def pipeline_name(self): """ Get pipeline name of current stage instance. Because instantiating stage instance could be performed in different ways and those return different results, we have to check where from to get name of the pipeline. :return: pipeline name. """ ...
python
def pipeline_name(self): if 'pipeline_name' in self.data: return self.data.get('pipeline_name') elif self.pipeline is not None: return self.pipeline.data.name
[ "def", "pipeline_name", "(", "self", ")", ":", "if", "'pipeline_name'", "in", "self", ".", "data", ":", "return", "self", ".", "data", ".", "get", "(", "'pipeline_name'", ")", "elif", "self", ".", "pipeline", "is", "not", "None", ":", "return", "self", ...
Get pipeline name of current stage instance. Because instantiating stage instance could be performed in different ways and those return different results, we have to check where from to get name of the pipeline. :return: pipeline name.
[ "Get", "pipeline", "name", "of", "current", "stage", "instance", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/stage.py#L260-L272
3,386
grundic/yagocd
yagocd/resources/stage.py
StageInstance.pipeline_counter
def pipeline_counter(self): """ Get pipeline counter of current stage instance. Because instantiating stage instance could be performed in different ways and those return different results, we have to check where from to get counter of the pipeline. :return: pipeline counter. ...
python
def pipeline_counter(self): if 'pipeline_counter' in self.data: return self.data.get('pipeline_counter') elif self.pipeline is not None: return self.pipeline.data.counter
[ "def", "pipeline_counter", "(", "self", ")", ":", "if", "'pipeline_counter'", "in", "self", ".", "data", ":", "return", "self", ".", "data", ".", "get", "(", "'pipeline_counter'", ")", "elif", "self", ".", "pipeline", "is", "not", "None", ":", "return", ...
Get pipeline counter of current stage instance. Because instantiating stage instance could be performed in different ways and those return different results, we have to check where from to get counter of the pipeline. :return: pipeline counter.
[ "Get", "pipeline", "counter", "of", "current", "stage", "instance", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/stage.py#L275-L287
3,387
grundic/yagocd
yagocd/resources/stage.py
StageInstance.cancel
def cancel(self): """ Cancel an active stage of a specified stage. :return: a text confirmation. """ return self._manager.cancel(pipeline_name=self.pipeline_name, stage_name=self.stage_name)
python
def cancel(self): return self._manager.cancel(pipeline_name=self.pipeline_name, stage_name=self.stage_name)
[ "def", "cancel", "(", "self", ")", ":", "return", "self", ".", "_manager", ".", "cancel", "(", "pipeline_name", "=", "self", ".", "pipeline_name", ",", "stage_name", "=", "self", ".", "stage_name", ")" ]
Cancel an active stage of a specified stage. :return: a text confirmation.
[ "Cancel", "an", "active", "stage", "of", "a", "specified", "stage", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/stage.py#L317-L323
3,388
grundic/yagocd
yagocd/resources/stage.py
StageInstance.jobs
def jobs(self): """ Method for getting jobs from stage instance. :return: arrays of jobs. :rtype: list of yagocd.resources.job.JobInstance """ jobs = list() for data in self.data.jobs: jobs.append(JobInstance(session=self._session, data=data, stage=se...
python
def jobs(self): jobs = list() for data in self.data.jobs: jobs.append(JobInstance(session=self._session, data=data, stage=self)) return jobs
[ "def", "jobs", "(", "self", ")", ":", "jobs", "=", "list", "(", ")", "for", "data", "in", "self", ".", "data", ".", "jobs", ":", "jobs", ".", "append", "(", "JobInstance", "(", "session", "=", "self", ".", "_session", ",", "data", "=", "data", ",...
Method for getting jobs from stage instance. :return: arrays of jobs. :rtype: list of yagocd.resources.job.JobInstance
[ "Method", "for", "getting", "jobs", "from", "stage", "instance", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/stage.py#L325-L336
3,389
grundic/yagocd
yagocd/resources/stage.py
StageInstance.job
def job(self, name): """ Method for searching specific job by it's name. :param name: name of the job to search. :return: found job or None. :rtype: yagocd.resources.job.JobInstance """ for job in self.jobs(): if job.data.name == name: ...
python
def job(self, name): for job in self.jobs(): if job.data.name == name: return job
[ "def", "job", "(", "self", ",", "name", ")", ":", "for", "job", "in", "self", ".", "jobs", "(", ")", ":", "if", "job", ".", "data", ".", "name", "==", "name", ":", "return", "job" ]
Method for searching specific job by it's name. :param name: name of the job to search. :return: found job or None. :rtype: yagocd.resources.job.JobInstance
[ "Method", "for", "searching", "specific", "job", "by", "it", "s", "name", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/stage.py#L338-L348
3,390
grundic/yagocd
yagocd/resources/pipeline.py
PipelineEntity.config
def config(self): """ Property for accessing pipeline configuration. :rtype: yagocd.resources.pipeline_config.PipelineConfigManager """ return PipelineConfigManager(session=self._session, pipeline_name=self.data.name)
python
def config(self): return PipelineConfigManager(session=self._session, pipeline_name=self.data.name)
[ "def", "config", "(", "self", ")", ":", "return", "PipelineConfigManager", "(", "session", "=", "self", ".", "_session", ",", "pipeline_name", "=", "self", ".", "data", ".", "name", ")" ]
Property for accessing pipeline configuration. :rtype: yagocd.resources.pipeline_config.PipelineConfigManager
[ "Property", "for", "accessing", "pipeline", "configuration", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/pipeline.py#L466-L472
3,391
grundic/yagocd
yagocd/resources/pipeline.py
PipelineEntity.history
def history(self, offset=0): """ The pipeline history allows users to list pipeline instances. :param offset: number of pipeline instances to be skipped. :return: an array of pipeline instances :class:`yagocd.resources.pipeline.PipelineInstance`. :rtype: list of yagocd.resources...
python
def history(self, offset=0): return self._pipeline.history(name=self.data.name, offset=offset)
[ "def", "history", "(", "self", ",", "offset", "=", "0", ")", ":", "return", "self", ".", "_pipeline", ".", "history", "(", "name", "=", "self", ".", "data", ".", "name", ",", "offset", "=", "offset", ")" ]
The pipeline history allows users to list pipeline instances. :param offset: number of pipeline instances to be skipped. :return: an array of pipeline instances :class:`yagocd.resources.pipeline.PipelineInstance`. :rtype: list of yagocd.resources.pipeline.PipelineInstance
[ "The", "pipeline", "history", "allows", "users", "to", "list", "pipeline", "instances", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/pipeline.py#L474-L482
3,392
grundic/yagocd
yagocd/resources/pipeline.py
PipelineEntity.get
def get(self, counter): """ Gets pipeline instance object. :param counter pipeline counter: :return: A pipeline instance object :class:`yagocd.resources.pipeline.PipelineInstance`. :rtype: yagocd.resources.pipeline.PipelineInstance """ return self._pipeline.get(n...
python
def get(self, counter): return self._pipeline.get(name=self.data.name, counter=counter)
[ "def", "get", "(", "self", ",", "counter", ")", ":", "return", "self", ".", "_pipeline", ".", "get", "(", "name", "=", "self", ".", "data", ".", "name", ",", "counter", "=", "counter", ")" ]
Gets pipeline instance object. :param counter pipeline counter: :return: A pipeline instance object :class:`yagocd.resources.pipeline.PipelineInstance`. :rtype: yagocd.resources.pipeline.PipelineInstance
[ "Gets", "pipeline", "instance", "object", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/pipeline.py#L502-L510
3,393
grundic/yagocd
yagocd/resources/pipeline.py
PipelineEntity.pause
def pause(self, cause): """ Pause the current pipeline. :param cause: reason for pausing the pipeline. """ self._pipeline.pause(name=self.data.name, cause=cause)
python
def pause(self, cause): self._pipeline.pause(name=self.data.name, cause=cause)
[ "def", "pause", "(", "self", ",", "cause", ")", ":", "self", ".", "_pipeline", ".", "pause", "(", "name", "=", "self", ".", "data", ".", "name", ",", "cause", "=", "cause", ")" ]
Pause the current pipeline. :param cause: reason for pausing the pipeline.
[ "Pause", "the", "current", "pipeline", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/pipeline.py#L520-L526
3,394
grundic/yagocd
yagocd/resources/pipeline.py
PipelineEntity.schedule
def schedule(self, materials=None, variables=None, secure_variables=None): """ Scheduling allows user to trigger a specific pipeline. :param materials: material revisions to use. :param variables: environment variables to set. :param secure_variables: secure environment variable...
python
def schedule(self, materials=None, variables=None, secure_variables=None): return self._pipeline.schedule( name=self.data.name, materials=materials, variables=variables, secure_variables=secure_variables )
[ "def", "schedule", "(", "self", ",", "materials", "=", "None", ",", "variables", "=", "None", ",", "secure_variables", "=", "None", ")", ":", "return", "self", ".", "_pipeline", ".", "schedule", "(", "name", "=", "self", ".", "data", ".", "name", ",", ...
Scheduling allows user to trigger a specific pipeline. :param materials: material revisions to use. :param variables: environment variables to set. :param secure_variables: secure environment variables to set. :return: a text confirmation.
[ "Scheduling", "allows", "user", "to", "trigger", "a", "specific", "pipeline", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/pipeline.py#L543-L557
3,395
grundic/yagocd
yagocd/resources/pipeline.py
PipelineInstance.stages
def stages(self): """ Method for getting stages from pipeline instance. :return: arrays of stages :rtype: list of yagocd.resources.stage.StageInstance """ stages = list() for data in self.data.stages: stages.append(StageInstance(session=self._session,...
python
def stages(self): stages = list() for data in self.data.stages: stages.append(StageInstance(session=self._session, data=data, pipeline=self)) return stages
[ "def", "stages", "(", "self", ")", ":", "stages", "=", "list", "(", ")", "for", "data", "in", "self", ".", "data", ".", "stages", ":", "stages", ".", "append", "(", "StageInstance", "(", "session", "=", "self", ".", "_session", ",", "data", "=", "d...
Method for getting stages from pipeline instance. :return: arrays of stages :rtype: list of yagocd.resources.stage.StageInstance
[ "Method", "for", "getting", "stages", "from", "pipeline", "instance", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/pipeline.py#L642-L653
3,396
grundic/yagocd
yagocd/resources/pipeline.py
PipelineInstance.stage
def stage(self, name): """ Method for searching specific stage by it's name. :param name: name of the stage to search. :return: found stage or None. :rtype: yagocd.resources.stage.StageInstance """ for stage in self.stages(): if stage.data.name == nam...
python
def stage(self, name): for stage in self.stages(): if stage.data.name == name: return stage
[ "def", "stage", "(", "self", ",", "name", ")", ":", "for", "stage", "in", "self", ".", "stages", "(", ")", ":", "if", "stage", ".", "data", ".", "name", "==", "name", ":", "return", "stage" ]
Method for searching specific stage by it's name. :param name: name of the stage to search. :return: found stage or None. :rtype: yagocd.resources.stage.StageInstance
[ "Method", "for", "searching", "specific", "stage", "by", "it", "s", "name", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/pipeline.py#L655-L665
3,397
grundic/yagocd
yagocd/util.py
RequireParamMixin._require_param
def _require_param(self, name, values): """ Method for finding the value for the given parameter name. The value for the parameter could be extracted from two places: * `values` dictionary * `self._<name>` attribute The use case for this method is that some resource...
python
def _require_param(self, name, values): values = [values[name]] instance_name = '_{}'.format(name) values.append(getattr(self, instance_name, None)) try: return next(item for item in values if item is not None) except StopIteration: raise ValueError("The ...
[ "def", "_require_param", "(", "self", ",", "name", ",", "values", ")", ":", "values", "=", "[", "values", "[", "name", "]", "]", "instance_name", "=", "'_{}'", ".", "format", "(", "name", ")", "values", ".", "append", "(", "getattr", "(", "self", ","...
Method for finding the value for the given parameter name. The value for the parameter could be extracted from two places: * `values` dictionary * `self._<name>` attribute The use case for this method is that some resources are nested and managers could have dependencies on...
[ "Method", "for", "finding", "the", "value", "for", "the", "given", "parameter", "name", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/util.py#L121-L155
3,398
grundic/yagocd
yagocd/resources/__init__.py
BaseManager._accept_header
def _accept_header(self): """ Method for determining correct `Accept` header. Different resources and different GoCD version servers prefer a diverse headers. In order to manage all of them, this method tries to help: if `VERSION_TO_ACCEPT_HEADER` is not provided, if wou...
python
def _accept_header(self): if not self.VERSION_TO_ACCEPT_HEADER: return self.ACCEPT_HEADER return YagocdUtil.choose_option( version_to_options=self.VERSION_TO_ACCEPT_HEADER, default=self.ACCEPT_HEADER, server_version=self._session.server_version )
[ "def", "_accept_header", "(", "self", ")", ":", "if", "not", "self", ".", "VERSION_TO_ACCEPT_HEADER", ":", "return", "self", ".", "ACCEPT_HEADER", "return", "YagocdUtil", ".", "choose_option", "(", "version_to_options", "=", "self", ".", "VERSION_TO_ACCEPT_HEADER", ...
Method for determining correct `Accept` header. Different resources and different GoCD version servers prefer a diverse headers. In order to manage all of them, this method tries to help: if `VERSION_TO_ACCEPT_HEADER` is not provided, if would simply return default `ACCEPT_HEADER`. ...
[ "Method", "for", "determining", "correct", "Accept", "header", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/__init__.py#L57-L81
3,399
grundic/yagocd
yagocd/resources/artifact.py
Artifact.walk
def walk(self, topdown=True): """ Artifact tree generator - analogue of `os.walk`. :param topdown: if is True or not specified, directories are scanned from top-down. If topdown is set to False, directories are scanned from bottom-up. :rtype: collections.Iterator[ ...
python
def walk(self, topdown=True): return self._manager.walk(top=self._path, topdown=topdown)
[ "def", "walk", "(", "self", ",", "topdown", "=", "True", ")", ":", "return", "self", ".", "_manager", ".", "walk", "(", "top", "=", "self", ".", "_path", ",", "topdown", "=", "topdown", ")" ]
Artifact tree generator - analogue of `os.walk`. :param topdown: if is True or not specified, directories are scanned from top-down. If topdown is set to False, directories are scanned from bottom-up. :rtype: collections.Iterator[ (str, list[yagocd.resources.artifact.Artifac...
[ "Artifact", "tree", "generator", "-", "analogue", "of", "os", ".", "walk", "." ]
4c75336ae6f107c8723d37b15e52169151822127
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/resources/artifact.py#L515-L526