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
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
44,500
AmesCornish/buttersink
buttersink/BestDiffs.py
BestDiffs._prune
def _prune(self): """ Get rid of all intermediate nodes that aren't needed. """ done = False while not done: done = True for node in [node for node in self.nodes.values() if node.intermediate]: if not [dep for dep in self.nodes.values() if dep.previous == ...
python
def _prune(self): """ Get rid of all intermediate nodes that aren't needed. """ done = False while not done: done = True for node in [node for node in self.nodes.values() if node.intermediate]: if not [dep for dep in self.nodes.values() if dep.previous == ...
[ "def", "_prune", "(", "self", ")", ":", "done", "=", "False", "while", "not", "done", ":", "done", "=", "True", "for", "node", "in", "[", "node", "for", "node", "in", "self", ".", "nodes", ".", "values", "(", ")", "if", "node", ".", "intermediate",...
Get rid of all intermediate nodes that aren't needed.
[ "Get", "rid", "of", "all", "intermediate", "nodes", "that", "aren", "t", "needed", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/BestDiffs.py#L313-L322
44,501
pycontribs/activedirectory
activedirectory/activedirectory.py
ActiveDirectory.__compress_attributes
def __compress_attributes(self, dic): """ This will convert all attributes that are list with only one item string into simple string. It seems that LDAP always return lists, even when it doesn t make sense. :param dic: :return: """ result = {} for k, v i...
python
def __compress_attributes(self, dic): """ This will convert all attributes that are list with only one item string into simple string. It seems that LDAP always return lists, even when it doesn t make sense. :param dic: :return: """ result = {} for k, v i...
[ "def", "__compress_attributes", "(", "self", ",", "dic", ")", ":", "result", "=", "{", "}", "for", "k", ",", "v", "in", "dic", ".", "iteritems", "(", ")", ":", "if", "isinstance", "(", "v", ",", "types", ".", "ListType", ")", "and", "len", "(", "...
This will convert all attributes that are list with only one item string into simple string. It seems that LDAP always return lists, even when it doesn t make sense. :param dic: :return:
[ "This", "will", "convert", "all", "attributes", "that", "are", "list", "with", "only", "one", "item", "string", "into", "simple", "string", ".", "It", "seems", "that", "LDAP", "always", "return", "lists", "even", "when", "it", "doesn", "t", "make", "sense"...
cd491511e2ed667c3b4634a682ea012c6cbedb38
https://github.com/pycontribs/activedirectory/blob/cd491511e2ed667c3b4634a682ea012c6cbedb38/activedirectory/activedirectory.py#L253-L276
44,502
AmesCornish/buttersink
buttersink/ButterStore.py
ButterStore._keepVol
def _keepVol(self, vol): """ Mark this volume to be kept in path. """ if vol is None: return if vol in self.extraVolumes: del self.extraVolumes[vol] return if vol not in self.paths: raise Exception("%s not in %s" % (vol, self)) p...
python
def _keepVol(self, vol): """ Mark this volume to be kept in path. """ if vol is None: return if vol in self.extraVolumes: del self.extraVolumes[vol] return if vol not in self.paths: raise Exception("%s not in %s" % (vol, self)) p...
[ "def", "_keepVol", "(", "self", ",", "vol", ")", ":", "if", "vol", "is", "None", ":", "return", "if", "vol", "in", "self", ".", "extraVolumes", ":", "del", "self", ".", "extraVolumes", "[", "vol", "]", "return", "if", "vol", "not", "in", "self", "....
Mark this volume to be kept in path.
[ "Mark", "this", "volume", "to", "be", "kept", "in", "path", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/ButterStore.py#L308-L326
44,503
AmesCornish/buttersink
buttersink/ioctl.py
Structure.write
def write(self, keyArgs): """ Write specified key arguments into data structure. """ # bytearray doesn't work with fcntl args = array.array('B', (0,) * self.size) self._struct.pack_into(args, 0, *list(self.yieldArgs(keyArgs))) return args
python
def write(self, keyArgs): """ Write specified key arguments into data structure. """ # bytearray doesn't work with fcntl args = array.array('B', (0,) * self.size) self._struct.pack_into(args, 0, *list(self.yieldArgs(keyArgs))) return args
[ "def", "write", "(", "self", ",", "keyArgs", ")", ":", "# bytearray doesn't work with fcntl", "args", "=", "array", ".", "array", "(", "'B'", ",", "(", "0", ",", ")", "*", "self", ".", "size", ")", "self", ".", "_struct", ".", "pack_into", "(", "args",...
Write specified key arguments into data structure.
[ "Write", "specified", "key", "arguments", "into", "data", "structure", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/ioctl.py#L222-L227
44,504
AmesCornish/buttersink
buttersink/ioctl.py
Structure.popValue
def popValue(self, argList): """ Take a flat arglist, and pop relevent values and return as a value or tuple. """ # return self._Tuple(*[name for (name, typeObj) in self._types.items()]) return self._Tuple(*[typeObj.popValue(argList) for (name, typeObj) in self._types.items()])
python
def popValue(self, argList): """ Take a flat arglist, and pop relevent values and return as a value or tuple. """ # return self._Tuple(*[name for (name, typeObj) in self._types.items()]) return self._Tuple(*[typeObj.popValue(argList) for (name, typeObj) in self._types.items()])
[ "def", "popValue", "(", "self", ",", "argList", ")", ":", "# return self._Tuple(*[name for (name, typeObj) in self._types.items()])", "return", "self", ".", "_Tuple", "(", "*", "[", "typeObj", ".", "popValue", "(", "argList", ")", "for", "(", "name", ",", "typeObj...
Take a flat arglist, and pop relevent values and return as a value or tuple.
[ "Take", "a", "flat", "arglist", "and", "pop", "relevent", "values", "and", "return", "as", "a", "value", "or", "tuple", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/ioctl.py#L229-L232
44,505
AmesCornish/buttersink
buttersink/ioctl.py
Buffer.read
def read(self, structure): """ Read and advance. """ start = self.offset self.skip(structure.size) return structure.read(self.buf, start)
python
def read(self, structure): """ Read and advance. """ start = self.offset self.skip(structure.size) return structure.read(self.buf, start)
[ "def", "read", "(", "self", ",", "structure", ")", ":", "start", "=", "self", ".", "offset", "self", ".", "skip", "(", "structure", ".", "size", ")", "return", "structure", ".", "read", "(", "self", ".", "buf", ",", "start", ")" ]
Read and advance.
[ "Read", "and", "advance", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/ioctl.py#L259-L263
44,506
AmesCornish/buttersink
buttersink/ioctl.py
Buffer.readView
def readView(self, newLength=None): """ Return a view of the next newLength bytes, and skip it. """ if newLength is None: newLength = self.len result = self.peekView(newLength) self.skip(newLength) return result
python
def readView(self, newLength=None): """ Return a view of the next newLength bytes, and skip it. """ if newLength is None: newLength = self.len result = self.peekView(newLength) self.skip(newLength) return result
[ "def", "readView", "(", "self", ",", "newLength", "=", "None", ")", ":", "if", "newLength", "is", "None", ":", "newLength", "=", "self", ".", "len", "result", "=", "self", ".", "peekView", "(", "newLength", ")", "self", ".", "skip", "(", "newLength", ...
Return a view of the next newLength bytes, and skip it.
[ "Return", "a", "view", "of", "the", "next", "newLength", "bytes", "and", "skip", "it", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/ioctl.py#L269-L275
44,507
AmesCornish/buttersink
buttersink/ioctl.py
Buffer.peekView
def peekView(self, newLength): """ Return a view of the next newLength bytes. """ # Note: In Python 2.7, memoryviews can't be written to # by the struct module. (BUG) return memoryview(self.buf)[self.offset:self.offset + newLength]
python
def peekView(self, newLength): """ Return a view of the next newLength bytes. """ # Note: In Python 2.7, memoryviews can't be written to # by the struct module. (BUG) return memoryview(self.buf)[self.offset:self.offset + newLength]
[ "def", "peekView", "(", "self", ",", "newLength", ")", ":", "# Note: In Python 2.7, memoryviews can't be written to", "# by the struct module. (BUG)", "return", "memoryview", "(", "self", ".", "buf", ")", "[", "self", ".", "offset", ":", "self", ".", "offset", "+", ...
Return a view of the next newLength bytes.
[ "Return", "a", "view", "of", "the", "next", "newLength", "bytes", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/ioctl.py#L277-L281
44,508
AmesCornish/buttersink
buttersink/ioctl.py
Buffer.readBuffer
def readBuffer(self, newLength): """ Read next chunk as another buffer. """ result = Buffer(self.buf, self.offset, newLength) self.skip(newLength) return result
python
def readBuffer(self, newLength): """ Read next chunk as another buffer. """ result = Buffer(self.buf, self.offset, newLength) self.skip(newLength) return result
[ "def", "readBuffer", "(", "self", ",", "newLength", ")", ":", "result", "=", "Buffer", "(", "self", ".", "buf", ",", "self", ".", "offset", ",", "newLength", ")", "self", ".", "skip", "(", "newLength", ")", "return", "result" ]
Read next chunk as another buffer.
[ "Read", "next", "chunk", "as", "another", "buffer", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/ioctl.py#L283-L287
44,509
AmesCornish/buttersink
buttersink/ioctl.py
Control._IOC
def _IOC(cls, dir, op, structure=None): """ Encode an ioctl id. """ control = cls(dir, op, structure) def do(dev, **args): return control(dev, **args) return do
python
def _IOC(cls, dir, op, structure=None): """ Encode an ioctl id. """ control = cls(dir, op, structure) def do(dev, **args): return control(dev, **args) return do
[ "def", "_IOC", "(", "cls", ",", "dir", ",", "op", ",", "structure", "=", "None", ")", ":", "control", "=", "cls", "(", "dir", ",", "op", ",", "structure", ")", "def", "do", "(", "dev", ",", "*", "*", "args", ")", ":", "return", "control", "(", ...
Encode an ioctl id.
[ "Encode", "an", "ioctl", "id", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/ioctl.py#L337-L343
44,510
AmesCornish/buttersink
buttersink/ioctl.py
Control.IOWR
def IOWR(cls, op, structure): """ Returns an ioctl Device method with READ and WRITE arguments. """ return cls._IOC(READ | WRITE, op, structure)
python
def IOWR(cls, op, structure): """ Returns an ioctl Device method with READ and WRITE arguments. """ return cls._IOC(READ | WRITE, op, structure)
[ "def", "IOWR", "(", "cls", ",", "op", ",", "structure", ")", ":", "return", "cls", ".", "_IOC", "(", "READ", "|", "WRITE", ",", "op", ",", "structure", ")" ]
Returns an ioctl Device method with READ and WRITE arguments.
[ "Returns", "an", "ioctl", "Device", "method", "with", "READ", "and", "WRITE", "arguments", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/ioctl.py#L356-L358
44,511
AmesCornish/buttersink
buttersink/btrfs.py
bytes2uuid
def bytes2uuid(b): """ Return standard human-friendly UUID. """ if b.strip(chr(0)) == '': return None s = b.encode('hex') return "%s-%s-%s-%s-%s" % (s[0:8], s[8:12], s[12:16], s[16:20], s[20:])
python
def bytes2uuid(b): """ Return standard human-friendly UUID. """ if b.strip(chr(0)) == '': return None s = b.encode('hex') return "%s-%s-%s-%s-%s" % (s[0:8], s[8:12], s[12:16], s[16:20], s[20:])
[ "def", "bytes2uuid", "(", "b", ")", ":", "if", "b", ".", "strip", "(", "chr", "(", "0", ")", ")", "==", "''", ":", "return", "None", "s", "=", "b", ".", "encode", "(", "'hex'", ")", "return", "\"%s-%s-%s-%s-%s\"", "%", "(", "s", "[", "0", ":", ...
Return standard human-friendly UUID.
[ "Return", "standard", "human", "-", "friendly", "UUID", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/btrfs.py#L24-L30
44,512
AmesCornish/buttersink
buttersink/btrfs.py
_Volume.fullPath
def fullPath(self): """ Return full butter path from butter root. """ for ((dirTree, dirID, dirSeq), (dirPath, name)) in self.links.items(): try: path = self.fileSystem.volumes[dirTree].fullPath if path is not None: return path + ("/" if pa...
python
def fullPath(self): """ Return full butter path from butter root. """ for ((dirTree, dirID, dirSeq), (dirPath, name)) in self.links.items(): try: path = self.fileSystem.volumes[dirTree].fullPath if path is not None: return path + ("/" if pa...
[ "def", "fullPath", "(", "self", ")", ":", "for", "(", "(", "dirTree", ",", "dirID", ",", "dirSeq", ")", ",", "(", "dirPath", ",", "name", ")", ")", "in", "self", ".", "links", ".", "items", "(", ")", ":", "try", ":", "path", "=", "self", ".", ...
Return full butter path from butter root.
[ "Return", "full", "butter", "path", "from", "butter", "root", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/btrfs.py#L394-L407
44,513
AmesCornish/buttersink
buttersink/btrfs.py
_Volume.linuxPaths
def linuxPaths(self): """ Return full paths from linux root. The first path returned will be the path through the top-most mount. (Usually the root). """ for ((dirTree, dirID, dirSeq), (dirPath, name)) in self.links.items(): for path in self.fileSystem.volumes[dirTre...
python
def linuxPaths(self): """ Return full paths from linux root. The first path returned will be the path through the top-most mount. (Usually the root). """ for ((dirTree, dirID, dirSeq), (dirPath, name)) in self.links.items(): for path in self.fileSystem.volumes[dirTre...
[ "def", "linuxPaths", "(", "self", ")", ":", "for", "(", "(", "dirTree", ",", "dirID", ",", "dirSeq", ")", ",", "(", "dirPath", ",", "name", ")", ")", "in", "self", ".", "links", ".", "items", "(", ")", ":", "for", "path", "in", "self", ".", "fi...
Return full paths from linux root. The first path returned will be the path through the top-most mount. (Usually the root).
[ "Return", "full", "paths", "from", "linux", "root", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/btrfs.py#L410-L420
44,514
AmesCornish/buttersink
buttersink/btrfs.py
_Volume.destroy
def destroy(self): """ Delete this subvolume from the filesystem. """ path = next(iter(self.linuxPaths)) directory = _Directory(os.path.dirname(path)) with directory as device: device.SNAP_DESTROY(name=str(os.path.basename(path)), )
python
def destroy(self): """ Delete this subvolume from the filesystem. """ path = next(iter(self.linuxPaths)) directory = _Directory(os.path.dirname(path)) with directory as device: device.SNAP_DESTROY(name=str(os.path.basename(path)), )
[ "def", "destroy", "(", "self", ")", ":", "path", "=", "next", "(", "iter", "(", "self", ".", "linuxPaths", ")", ")", "directory", "=", "_Directory", "(", "os", ".", "path", ".", "dirname", "(", "path", ")", ")", "with", "directory", "as", "device", ...
Delete this subvolume from the filesystem.
[ "Delete", "this", "subvolume", "from", "the", "filesystem", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/btrfs.py#L446-L451
44,515
AmesCornish/buttersink
buttersink/btrfs.py
_Volume.copy
def copy(self, path): """ Make another snapshot of this into dirName. """ directoryPath = os.path.dirname(path) if not os.path.exists(directoryPath): os.makedirs(directoryPath) logger.debug('Create copy of %s in %s', os.path.basename(path), directoryPath) with self....
python
def copy(self, path): """ Make another snapshot of this into dirName. """ directoryPath = os.path.dirname(path) if not os.path.exists(directoryPath): os.makedirs(directoryPath) logger.debug('Create copy of %s in %s', os.path.basename(path), directoryPath) with self....
[ "def", "copy", "(", "self", ",", "path", ")", ":", "directoryPath", "=", "os", ".", "path", ".", "dirname", "(", "path", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "directoryPath", ")", ":", "os", ".", "makedirs", "(", "directoryPath", ...
Make another snapshot of this into dirName.
[ "Make", "another", "snapshot", "of", "this", "into", "dirName", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/btrfs.py#L453-L479
44,516
AmesCornish/buttersink
buttersink/btrfs.py
FileSystem.subvolumes
def subvolumes(self): """ Subvolumes contained in this mount. """ self.SYNC() self._getDevices() self._getRoots() self._getMounts() self._getUsage() volumes = self.volumes.values() volumes.sort(key=(lambda v: v.fullPath)) return volumes
python
def subvolumes(self): """ Subvolumes contained in this mount. """ self.SYNC() self._getDevices() self._getRoots() self._getMounts() self._getUsage() volumes = self.volumes.values() volumes.sort(key=(lambda v: v.fullPath)) return volumes
[ "def", "subvolumes", "(", "self", ")", ":", "self", ".", "SYNC", "(", ")", "self", ".", "_getDevices", "(", ")", "self", ".", "_getRoots", "(", ")", "self", ".", "_getMounts", "(", ")", "self", ".", "_getUsage", "(", ")", "volumes", "=", "self", "....
Subvolumes contained in this mount.
[ "Subvolumes", "contained", "in", "this", "mount", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/btrfs.py#L515-L525
44,517
AmesCornish/buttersink
buttersink/btrfs.py
FileSystem._rescanSizes
def _rescanSizes(self, force=True): """ Zero and recalculate quota sizes to subvolume sizes will be correct. """ status = self.QUOTA_CTL(cmd=BTRFS_QUOTA_CTL_ENABLE).status logger.debug("CTL Status: %s", hex(status)) status = self.QUOTA_RESCAN_STATUS() logger.debug("RESCAN Status...
python
def _rescanSizes(self, force=True): """ Zero and recalculate quota sizes to subvolume sizes will be correct. """ status = self.QUOTA_CTL(cmd=BTRFS_QUOTA_CTL_ENABLE).status logger.debug("CTL Status: %s", hex(status)) status = self.QUOTA_RESCAN_STATUS() logger.debug("RESCAN Status...
[ "def", "_rescanSizes", "(", "self", ",", "force", "=", "True", ")", ":", "status", "=", "self", ".", "QUOTA_CTL", "(", "cmd", "=", "BTRFS_QUOTA_CTL_ENABLE", ")", ".", "status", "logger", ".", "debug", "(", "\"CTL Status: %s\"", ",", "hex", "(", "status", ...
Zero and recalculate quota sizes to subvolume sizes will be correct.
[ "Zero", "and", "recalculate", "quota", "sizes", "to", "subvolume", "sizes", "will", "be", "correct", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/btrfs.py#L527-L541
44,518
AmesCornish/buttersink
buttersink/send.py
TLV_GET
def TLV_GET(attrs, attrNum, format): """ Get a tag-length-value encoded attribute. """ attrView = attrs[attrNum] if format == 's': format = str(attrView.len) + format try: (result,) = struct.unpack_from(format, attrView.buf, attrView.offset) except TypeError: # Working around...
python
def TLV_GET(attrs, attrNum, format): """ Get a tag-length-value encoded attribute. """ attrView = attrs[attrNum] if format == 's': format = str(attrView.len) + format try: (result,) = struct.unpack_from(format, attrView.buf, attrView.offset) except TypeError: # Working around...
[ "def", "TLV_GET", "(", "attrs", ",", "attrNum", ",", "format", ")", ":", "attrView", "=", "attrs", "[", "attrNum", "]", "if", "format", "==", "'s'", ":", "format", "=", "str", "(", "attrView", ".", "len", ")", "+", "format", "try", ":", "(", "resul...
Get a tag-length-value encoded attribute.
[ "Get", "a", "tag", "-", "length", "-", "value", "encoded", "attribute", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/send.py#L127-L137
44,519
AmesCornish/buttersink
buttersink/send.py
TLV_PUT
def TLV_PUT(attrs, attrNum, format, value): """ Put a tag-length-value encoded attribute. """ attrView = attrs[attrNum] if format == 's': format = str(attrView.len) + format struct.pack_into(format, attrView.buf, attrView.offset, value)
python
def TLV_PUT(attrs, attrNum, format, value): """ Put a tag-length-value encoded attribute. """ attrView = attrs[attrNum] if format == 's': format = str(attrView.len) + format struct.pack_into(format, attrView.buf, attrView.offset, value)
[ "def", "TLV_PUT", "(", "attrs", ",", "attrNum", ",", "format", ",", "value", ")", ":", "attrView", "=", "attrs", "[", "attrNum", "]", "if", "format", "==", "'s'", ":", "format", "=", "str", "(", "attrView", ".", "len", ")", "+", "format", "struct", ...
Put a tag-length-value encoded attribute.
[ "Put", "a", "tag", "-", "length", "-", "value", "encoded", "attribute", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/send.py#L140-L145
44,520
AmesCornish/buttersink
buttersink/SSHStore.py
command
def command(name, mode): """ Label a method as a command with name. """ def decorator(fn): commands[name] = fn.__name__ _Client._addMethod(fn.__name__, name, mode) return fn return decorator
python
def command(name, mode): """ Label a method as a command with name. """ def decorator(fn): commands[name] = fn.__name__ _Client._addMethod(fn.__name__, name, mode) return fn return decorator
[ "def", "command", "(", "name", ",", "mode", ")", ":", "def", "decorator", "(", "fn", ")", ":", "commands", "[", "name", "]", "=", "fn", ".", "__name__", "_Client", ".", "_addMethod", "(", "fn", ".", "__name__", ",", "name", ",", "mode", ")", "retur...
Label a method as a command with name.
[ "Label", "a", "method", "as", "a", "command", "with", "name", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/SSHStore.py#L431-L437
44,521
AmesCornish/buttersink
buttersink/SSHStore.py
_Obj2Dict.diff
def diff(self, diff): """ Serialize to a dictionary. """ if diff is None: return None return dict( toVol=diff.toUUID, fromVol=diff.fromUUID, size=diff.size, sizeIsEstimated=diff.sizeIsEstimated, )
python
def diff(self, diff): """ Serialize to a dictionary. """ if diff is None: return None return dict( toVol=diff.toUUID, fromVol=diff.fromUUID, size=diff.size, sizeIsEstimated=diff.sizeIsEstimated, )
[ "def", "diff", "(", "self", ",", "diff", ")", ":", "if", "diff", "is", "None", ":", "return", "None", "return", "dict", "(", "toVol", "=", "diff", ".", "toUUID", ",", "fromVol", "=", "diff", ".", "fromUUID", ",", "size", "=", "diff", ".", "size", ...
Serialize to a dictionary.
[ "Serialize", "to", "a", "dictionary", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/SSHStore.py#L74-L83
44,522
AmesCornish/buttersink
buttersink/SSHStore.py
_Client._open
def _open(self): """ Open connection to remote host. """ if self._process is not None: return cmd = [ 'ssh', self._host, 'sudo', 'buttersink', '--server', '--mode', self._mode, self._dire...
python
def _open(self): """ Open connection to remote host. """ if self._process is not None: return cmd = [ 'ssh', self._host, 'sudo', 'buttersink', '--server', '--mode', self._mode, self._dire...
[ "def", "_open", "(", "self", ")", ":", "if", "self", ".", "_process", "is", "not", "None", ":", "return", "cmd", "=", "[", "'ssh'", ",", "self", ".", "_host", ",", "'sudo'", ",", "'buttersink'", ",", "'--server'", ",", "'--mode'", ",", "self", ".", ...
Open connection to remote host.
[ "Open", "connection", "to", "remote", "host", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/SSHStore.py#L325-L350
44,523
AmesCornish/buttersink
buttersink/SSHStore.py
_Client._close
def _close(self): """ Close connection to remote host. """ if self._process is None: return self.quit() self._process.stdin.close() logger.debug("Waiting for ssh process to finish...") self._process.wait() # Wait for ssh session to finish. # self....
python
def _close(self): """ Close connection to remote host. """ if self._process is None: return self.quit() self._process.stdin.close() logger.debug("Waiting for ssh process to finish...") self._process.wait() # Wait for ssh session to finish. # self....
[ "def", "_close", "(", "self", ")", ":", "if", "self", ".", "_process", "is", "None", ":", "return", "self", ".", "quit", "(", ")", "self", ".", "_process", ".", "stdin", ".", "close", "(", ")", "logger", ".", "debug", "(", "\"Waiting for ssh process to...
Close connection to remote host.
[ "Close", "connection", "to", "remote", "host", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/SSHStore.py#L352-L367
44,524
AmesCornish/buttersink
buttersink/SSHStore.py
StoreProxyServer.run
def run(self): """ Run the server. Returns with system error code. """ normalized = os.path.normpath(self.path) + ("/" if self.path.endswith("/") else "") if self.path != normalized: sys.stderr.write("Please use full path '%s'" % (normalized,)) return -1 self.bu...
python
def run(self): """ Run the server. Returns with system error code. """ normalized = os.path.normpath(self.path) + ("/" if self.path.endswith("/") else "") if self.path != normalized: sys.stderr.write("Please use full path '%s'" % (normalized,)) return -1 self.bu...
[ "def", "run", "(", "self", ")", ":", "normalized", "=", "os", ".", "path", ".", "normpath", "(", "self", ".", "path", ")", "+", "(", "\"/\"", "if", "self", ".", "path", ".", "endswith", "(", "\"/\"", ")", "else", "\"\"", ")", "if", "self", ".", ...
Run the server. Returns with system error code.
[ "Run", "the", "server", ".", "Returns", "with", "system", "error", "code", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/SSHStore.py#L488-L508
44,525
AmesCornish/buttersink
buttersink/SSHStore.py
StoreProxyServer._sendResult
def _sendResult(self, result): """ Send parseable json result of command. """ # logger.debug("Result: %s", result) try: result = json.dumps(result) except Exception as error: result = json.dumps(self._errorInfo(command, error)) sys.stdout.write(result) ...
python
def _sendResult(self, result): """ Send parseable json result of command. """ # logger.debug("Result: %s", result) try: result = json.dumps(result) except Exception as error: result = json.dumps(self._errorInfo(command, error)) sys.stdout.write(result) ...
[ "def", "_sendResult", "(", "self", ",", "result", ")", ":", "# logger.debug(\"Result: %s\", result)", "try", ":", "result", "=", "json", ".", "dumps", "(", "result", ")", "except", "Exception", "as", "error", ":", "result", "=", "json", ".", "dumps", "(", ...
Send parseable json result of command.
[ "Send", "parseable", "json", "result", "of", "command", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/SSHStore.py#L525-L536
44,526
AmesCornish/buttersink
buttersink/SSHStore.py
StoreProxyServer.version
def version(self): """ Return kernel and btrfs version. """ return dict( buttersink=theVersion, btrfs=self.butterStore.butter.btrfsVersion, linux=platform.platform(), )
python
def version(self): """ Return kernel and btrfs version. """ return dict( buttersink=theVersion, btrfs=self.butterStore.butter.btrfsVersion, linux=platform.platform(), )
[ "def", "version", "(", "self", ")", ":", "return", "dict", "(", "buttersink", "=", "theVersion", ",", "btrfs", "=", "self", ".", "butterStore", ".", "butter", ".", "btrfsVersion", ",", "linux", "=", "platform", ".", "platform", "(", ")", ",", ")" ]
Return kernel and btrfs version.
[ "Return", "kernel", "and", "btrfs", "version", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/SSHStore.py#L577-L583
44,527
AmesCornish/buttersink
buttersink/SSHStore.py
StoreProxyServer.send
def send(self, diffTo, diffFrom): """ Do a btrfs send. """ diff = self.toObj.diff(diffTo, diffFrom) self._open(self.butterStore.send(diff))
python
def send(self, diffTo, diffFrom): """ Do a btrfs send. """ diff = self.toObj.diff(diffTo, diffFrom) self._open(self.butterStore.send(diff))
[ "def", "send", "(", "self", ",", "diffTo", ",", "diffFrom", ")", ":", "diff", "=", "self", ".", "toObj", ".", "diff", "(", "diffTo", ",", "diffFrom", ")", "self", ".", "_open", "(", "self", ".", "butterStore", ".", "send", "(", "diff", ")", ")" ]
Do a btrfs send.
[ "Do", "a", "btrfs", "send", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/SSHStore.py#L586-L589
44,528
AmesCornish/buttersink
buttersink/SSHStore.py
StoreProxyServer.receive
def receive(self, path, diffTo, diffFrom): """ Receive a btrfs diff. """ diff = self.toObj.diff(diffTo, diffFrom) self._open(self.butterStore.receive(diff, [path, ]))
python
def receive(self, path, diffTo, diffFrom): """ Receive a btrfs diff. """ diff = self.toObj.diff(diffTo, diffFrom) self._open(self.butterStore.receive(diff, [path, ]))
[ "def", "receive", "(", "self", ",", "path", ",", "diffTo", ",", "diffFrom", ")", ":", "diff", "=", "self", ".", "toObj", ".", "diff", "(", "diffTo", ",", "diffFrom", ")", "self", ".", "_open", "(", "self", ".", "butterStore", ".", "receive", "(", "...
Receive a btrfs diff.
[ "Receive", "a", "btrfs", "diff", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/SSHStore.py#L592-L595
44,529
AmesCornish/buttersink
buttersink/SSHStore.py
StoreProxyServer.fillVolumesAndPaths
def fillVolumesAndPaths(self): """ Get all volumes for initialization. """ return [ (self.toDict.vol(vol), paths) for vol, paths in self.butterStore.paths.items() ]
python
def fillVolumesAndPaths(self): """ Get all volumes for initialization. """ return [ (self.toDict.vol(vol), paths) for vol, paths in self.butterStore.paths.items() ]
[ "def", "fillVolumesAndPaths", "(", "self", ")", ":", "return", "[", "(", "self", ".", "toDict", ".", "vol", "(", "vol", ")", ",", "paths", ")", "for", "vol", ",", "paths", "in", "self", ".", "butterStore", ".", "paths", ".", "items", "(", ")", "]" ...
Get all volumes for initialization.
[ "Get", "all", "volumes", "for", "initialization", "." ]
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/SSHStore.py#L629-L634
44,530
brennv/namedtupled
namedtupled/integrations.py
load_lists
def load_lists(keys=[], values=[], name='NT'): """ Map namedtuples given a pair of key, value lists. """ mapping = dict(zip(keys, values)) return mapper(mapping, _nt_name=name)
python
def load_lists(keys=[], values=[], name='NT'): """ Map namedtuples given a pair of key, value lists. """ mapping = dict(zip(keys, values)) return mapper(mapping, _nt_name=name)
[ "def", "load_lists", "(", "keys", "=", "[", "]", ",", "values", "=", "[", "]", ",", "name", "=", "'NT'", ")", ":", "mapping", "=", "dict", "(", "zip", "(", "keys", ",", "values", ")", ")", "return", "mapper", "(", "mapping", ",", "_nt_name", "=",...
Map namedtuples given a pair of key, value lists.
[ "Map", "namedtuples", "given", "a", "pair", "of", "key", "value", "lists", "." ]
2b8e3bafd82835ef01549d7a266c34454637ff70
https://github.com/brennv/namedtupled/blob/2b8e3bafd82835ef01549d7a266c34454637ff70/namedtupled/integrations.py#L8-L11
44,531
brennv/namedtupled
namedtupled/integrations.py
load_json
def load_json(data=None, path=None, name='NT'): """ Map namedtuples with json data. """ if data and not path: return mapper(json.loads(data), _nt_name=name) if path and not data: return mapper(json.load(path), _nt_name=name) if data and path: raise ValueError('expected one source...
python
def load_json(data=None, path=None, name='NT'): """ Map namedtuples with json data. """ if data and not path: return mapper(json.loads(data), _nt_name=name) if path and not data: return mapper(json.load(path), _nt_name=name) if data and path: raise ValueError('expected one source...
[ "def", "load_json", "(", "data", "=", "None", ",", "path", "=", "None", ",", "name", "=", "'NT'", ")", ":", "if", "data", "and", "not", "path", ":", "return", "mapper", "(", "json", ".", "loads", "(", "data", ")", ",", "_nt_name", "=", "name", ")...
Map namedtuples with json data.
[ "Map", "namedtuples", "with", "json", "data", "." ]
2b8e3bafd82835ef01549d7a266c34454637ff70
https://github.com/brennv/namedtupled/blob/2b8e3bafd82835ef01549d7a266c34454637ff70/namedtupled/integrations.py#L14-L21
44,532
brennv/namedtupled
namedtupled/integrations.py
load_yaml
def load_yaml(data=None, path=None, name='NT'): """ Map namedtuples with yaml data. """ if data and not path: return mapper(yaml.load(data), _nt_name=name) if path and not data: with open(path, 'r') as f: data = yaml.load(f) return mapper(data, _nt_name=name) if data ...
python
def load_yaml(data=None, path=None, name='NT'): """ Map namedtuples with yaml data. """ if data and not path: return mapper(yaml.load(data), _nt_name=name) if path and not data: with open(path, 'r') as f: data = yaml.load(f) return mapper(data, _nt_name=name) if data ...
[ "def", "load_yaml", "(", "data", "=", "None", ",", "path", "=", "None", ",", "name", "=", "'NT'", ")", ":", "if", "data", "and", "not", "path", ":", "return", "mapper", "(", "yaml", ".", "load", "(", "data", ")", ",", "_nt_name", "=", "name", ")"...
Map namedtuples with yaml data.
[ "Map", "namedtuples", "with", "yaml", "data", "." ]
2b8e3bafd82835ef01549d7a266c34454637ff70
https://github.com/brennv/namedtupled/blob/2b8e3bafd82835ef01549d7a266c34454637ff70/namedtupled/integrations.py#L24-L33
44,533
brennv/namedtupled
namedtupled/namedtupled.py
mapper
def mapper(mapping, _nt_name='NT'): """ Convert mappings to namedtuples recursively. """ if isinstance(mapping, Mapping) and not isinstance(mapping, AsDict): for key, value in list(mapping.items()): mapping[key] = mapper(value) return namedtuple_wrapper(_nt_name, **mapping) elif ...
python
def mapper(mapping, _nt_name='NT'): """ Convert mappings to namedtuples recursively. """ if isinstance(mapping, Mapping) and not isinstance(mapping, AsDict): for key, value in list(mapping.items()): mapping[key] = mapper(value) return namedtuple_wrapper(_nt_name, **mapping) elif ...
[ "def", "mapper", "(", "mapping", ",", "_nt_name", "=", "'NT'", ")", ":", "if", "isinstance", "(", "mapping", ",", "Mapping", ")", "and", "not", "isinstance", "(", "mapping", ",", "AsDict", ")", ":", "for", "key", ",", "value", "in", "list", "(", "map...
Convert mappings to namedtuples recursively.
[ "Convert", "mappings", "to", "namedtuples", "recursively", "." ]
2b8e3bafd82835ef01549d7a266c34454637ff70
https://github.com/brennv/namedtupled/blob/2b8e3bafd82835ef01549d7a266c34454637ff70/namedtupled/namedtupled.py#L6-L14
44,534
brennv/namedtupled
namedtupled/namedtupled.py
ignore
def ignore(mapping): """ Use ignore to prevent a mapping from being mapped to a namedtuple. """ if isinstance(mapping, Mapping): return AsDict(mapping) elif isinstance(mapping, list): return [ignore(item) for item in mapping] return mapping
python
def ignore(mapping): """ Use ignore to prevent a mapping from being mapped to a namedtuple. """ if isinstance(mapping, Mapping): return AsDict(mapping) elif isinstance(mapping, list): return [ignore(item) for item in mapping] return mapping
[ "def", "ignore", "(", "mapping", ")", ":", "if", "isinstance", "(", "mapping", ",", "Mapping", ")", ":", "return", "AsDict", "(", "mapping", ")", "elif", "isinstance", "(", "mapping", ",", "list", ")", ":", "return", "[", "ignore", "(", "item", ")", ...
Use ignore to prevent a mapping from being mapped to a namedtuple.
[ "Use", "ignore", "to", "prevent", "a", "mapping", "from", "being", "mapped", "to", "a", "namedtuple", "." ]
2b8e3bafd82835ef01549d7a266c34454637ff70
https://github.com/brennv/namedtupled/blob/2b8e3bafd82835ef01549d7a266c34454637ff70/namedtupled/namedtupled.py#L26-L32
44,535
mongolab/mongoctl
mongoctl/utils.py
ensure_dir
def ensure_dir(dir_path): """ If DIR_PATH does not exist, makes it. Failing that, raises Exception. Returns True if dir already existed; False if it had to be made. """ exists = dir_exists(dir_path) if not exists: try: os.makedirs(dir_path) except(Exception,RuntimeErr...
python
def ensure_dir(dir_path): """ If DIR_PATH does not exist, makes it. Failing that, raises Exception. Returns True if dir already existed; False if it had to be made. """ exists = dir_exists(dir_path) if not exists: try: os.makedirs(dir_path) except(Exception,RuntimeErr...
[ "def", "ensure_dir", "(", "dir_path", ")", ":", "exists", "=", "dir_exists", "(", "dir_path", ")", "if", "not", "exists", ":", "try", ":", "os", ".", "makedirs", "(", "dir_path", ")", "except", "(", "Exception", ",", "RuntimeError", ")", ",", "e", ":",...
If DIR_PATH does not exist, makes it. Failing that, raises Exception. Returns True if dir already existed; False if it had to be made.
[ "If", "DIR_PATH", "does", "not", "exist", "makes", "it", ".", "Failing", "that", "raises", "Exception", ".", "Returns", "True", "if", "dir", "already", "existed", ";", "False", "if", "it", "had", "to", "be", "made", "." ]
fab15216127ad4bf8ea9aa8a95d75504c0ef01a2
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/utils.py#L97-L109
44,536
mongolab/mongoctl
mongoctl/utils.py
validate_openssl
def validate_openssl(): """ Validates OpenSSL to ensure it has TLS_FALLBACK_SCSV supported """ try: open_ssl_exe = which("openssl") if not open_ssl_exe: raise Exception("No openssl exe found in path") try: # execute a an invalid command to get output ...
python
def validate_openssl(): """ Validates OpenSSL to ensure it has TLS_FALLBACK_SCSV supported """ try: open_ssl_exe = which("openssl") if not open_ssl_exe: raise Exception("No openssl exe found in path") try: # execute a an invalid command to get output ...
[ "def", "validate_openssl", "(", ")", ":", "try", ":", "open_ssl_exe", "=", "which", "(", "\"openssl\"", ")", "if", "not", "open_ssl_exe", ":", "raise", "Exception", "(", "\"No openssl exe found in path\"", ")", "try", ":", "# execute a an invalid command to get output...
Validates OpenSSL to ensure it has TLS_FALLBACK_SCSV supported
[ "Validates", "OpenSSL", "to", "ensure", "it", "has", "TLS_FALLBACK_SCSV", "supported" ]
fab15216127ad4bf8ea9aa8a95d75504c0ef01a2
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/utils.py#L366-L383
44,537
mongolab/mongoctl
mongoctl/objects/replicaset_cluster.py
ReplicaSetClusterMember.validate_against_current_config
def validate_against_current_config(self, current_rs_conf): """ Validates the member document against current rs conf 1- If there is a member in current config with _id equals to my id then ensure hosts addresses resolve to the same host 2- If there is a member i...
python
def validate_against_current_config(self, current_rs_conf): """ Validates the member document against current rs conf 1- If there is a member in current config with _id equals to my id then ensure hosts addresses resolve to the same host 2- If there is a member i...
[ "def", "validate_against_current_config", "(", "self", ",", "current_rs_conf", ")", ":", "# if rs is not configured yet then there is nothing to validate", "if", "not", "current_rs_conf", ":", "return", "my_host", "=", "self", ".", "get_host", "(", ")", "current_member_conf...
Validates the member document against current rs conf 1- If there is a member in current config with _id equals to my id then ensure hosts addresses resolve to the same host 2- If there is a member in current config with host resolving to my host then ensure that ...
[ "Validates", "the", "member", "document", "against", "current", "rs", "conf", "1", "-", "If", "there", "is", "a", "member", "in", "current", "config", "with", "_id", "equals", "to", "my", "id", "then", "ensure", "hosts", "addresses", "resolve", "to", "the"...
fab15216127ad4bf8ea9aa8a95d75504c0ef01a2
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/objects/replicaset_cluster.py#L179-L221
44,538
mongolab/mongoctl
mongoctl/objects/replicaset_cluster.py
ReplicaSetCluster.get_dump_best_secondary
def get_dump_best_secondary(self, max_repl_lag=None): """ Returns the best secondary member to be used for dumping best = passives with least lags, if no passives then least lag """ secondary_lag_tuples = [] primary_member = self.get_primary_member() if not prima...
python
def get_dump_best_secondary(self, max_repl_lag=None): """ Returns the best secondary member to be used for dumping best = passives with least lags, if no passives then least lag """ secondary_lag_tuples = [] primary_member = self.get_primary_member() if not prima...
[ "def", "get_dump_best_secondary", "(", "self", ",", "max_repl_lag", "=", "None", ")", ":", "secondary_lag_tuples", "=", "[", "]", "primary_member", "=", "self", ".", "get_primary_member", "(", ")", "if", "not", "primary_member", ":", "raise", "MongoctlException", ...
Returns the best secondary member to be used for dumping best = passives with least lags, if no passives then least lag
[ "Returns", "the", "best", "secondary", "member", "to", "be", "used", "for", "dumping", "best", "=", "passives", "with", "least", "lags", "if", "no", "passives", "then", "least", "lag" ]
fab15216127ad4bf8ea9aa8a95d75504c0ef01a2
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/objects/replicaset_cluster.py#L377-L422
44,539
mongolab/mongoctl
mongoctl/objects/replicaset_cluster.py
ReplicaSetCluster.is_replicaset_initialized
def is_replicaset_initialized(self): """ iterate on all members and check if any has joined the replica """ # it's possible isMaster returns an "incomplete" result if we # query a replica set member while it's loading the replica set config # https://jira.mongodb.org/bro...
python
def is_replicaset_initialized(self): """ iterate on all members and check if any has joined the replica """ # it's possible isMaster returns an "incomplete" result if we # query a replica set member while it's loading the replica set config # https://jira.mongodb.org/bro...
[ "def", "is_replicaset_initialized", "(", "self", ")", ":", "# it's possible isMaster returns an \"incomplete\" result if we", "# query a replica set member while it's loading the replica set config", "# https://jira.mongodb.org/browse/SERVER-13458", "# let's try to detect this state before proceed...
iterate on all members and check if any has joined the replica
[ "iterate", "on", "all", "members", "and", "check", "if", "any", "has", "joined", "the", "replica" ]
fab15216127ad4bf8ea9aa8a95d75504c0ef01a2
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/objects/replicaset_cluster.py#L425-L444
44,540
mongolab/mongoctl
mongoctl/objects/replicaset_cluster.py
ReplicaSetCluster.match_member_id
def match_member_id(self, member_conf, current_member_confs): """ Attempts to find an id for member_conf where fom current members confs there exists a element. Returns the id of an element of current confs WHERE member_conf.host and element.host are EQUAL or map to same host ...
python
def match_member_id(self, member_conf, current_member_confs): """ Attempts to find an id for member_conf where fom current members confs there exists a element. Returns the id of an element of current confs WHERE member_conf.host and element.host are EQUAL or map to same host ...
[ "def", "match_member_id", "(", "self", ",", "member_conf", ",", "current_member_confs", ")", ":", "if", "current_member_confs", "is", "None", ":", "return", "None", "for", "curr_mem_conf", "in", "current_member_confs", ":", "if", "is_same_address", "(", "member_conf...
Attempts to find an id for member_conf where fom current members confs there exists a element. Returns the id of an element of current confs WHERE member_conf.host and element.host are EQUAL or map to same host
[ "Attempts", "to", "find", "an", "id", "for", "member_conf", "where", "fom", "current", "members", "confs", "there", "exists", "a", "element", ".", "Returns", "the", "id", "of", "an", "element", "of", "current", "confs", "WHERE", "member_conf", ".", "host", ...
fab15216127ad4bf8ea9aa8a95d75504c0ef01a2
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/objects/replicaset_cluster.py#L763-L777
44,541
mongolab/mongoctl
mongoctl/binary_repo.py
get_os_dist_info
def get_os_dist_info(): """ Returns the distribution info """ distribution = platform.dist() dist_name = distribution[0].lower() dist_version_str = distribution[1] if dist_name and dist_version_str: return dist_name, dist_version_str else: return None, None
python
def get_os_dist_info(): """ Returns the distribution info """ distribution = platform.dist() dist_name = distribution[0].lower() dist_version_str = distribution[1] if dist_name and dist_version_str: return dist_name, dist_version_str else: return None, None
[ "def", "get_os_dist_info", "(", ")", ":", "distribution", "=", "platform", ".", "dist", "(", ")", "dist_name", "=", "distribution", "[", "0", "]", ".", "lower", "(", ")", "dist_version_str", "=", "distribution", "[", "1", "]", "if", "dist_name", "and", "...
Returns the distribution info
[ "Returns", "the", "distribution", "info" ]
fab15216127ad4bf8ea9aa8a95d75504c0ef01a2
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/binary_repo.py#L442-L453
44,542
mongolab/mongoctl
mongoctl/objects/server.py
Server.get_mongo_version
def get_mongo_version(self): """ Gets mongo version of the server if it is running. Otherwise return version configured in mongoVersion property """ if self._mongo_version: return self._mongo_version mongo_version = self.read_current_mongo_version() ...
python
def get_mongo_version(self): """ Gets mongo version of the server if it is running. Otherwise return version configured in mongoVersion property """ if self._mongo_version: return self._mongo_version mongo_version = self.read_current_mongo_version() ...
[ "def", "get_mongo_version", "(", "self", ")", ":", "if", "self", ".", "_mongo_version", ":", "return", "self", ".", "_mongo_version", "mongo_version", "=", "self", ".", "read_current_mongo_version", "(", ")", "if", "not", "mongo_version", ":", "mongo_version", "...
Gets mongo version of the server if it is running. Otherwise return version configured in mongoVersion property
[ "Gets", "mongo", "version", "of", "the", "server", "if", "it", "is", "running", ".", "Otherwise", "return", "version", "configured", "in", "mongoVersion", "property" ]
fab15216127ad4bf8ea9aa8a95d75504c0ef01a2
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/objects/server.py#L258-L273
44,543
mongolab/mongoctl
mongoctl/objects/server.py
Server.get_server_build_info
def get_server_build_info(self): """ issues a buildinfo command """ if self.is_online(): try: return self.get_mongo_client().server_info() except OperationFailure, ofe: log_exception(ofe) if "there are no users authe...
python
def get_server_build_info(self): """ issues a buildinfo command """ if self.is_online(): try: return self.get_mongo_client().server_info() except OperationFailure, ofe: log_exception(ofe) if "there are no users authe...
[ "def", "get_server_build_info", "(", "self", ")", ":", "if", "self", ".", "is_online", "(", ")", ":", "try", ":", "return", "self", ".", "get_mongo_client", "(", ")", ".", "server_info", "(", ")", "except", "OperationFailure", ",", "ofe", ":", "log_excepti...
issues a buildinfo command
[ "issues", "a", "buildinfo", "command" ]
fab15216127ad4bf8ea9aa8a95d75504c0ef01a2
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/objects/server.py#L290-L307
44,544
mongolab/mongoctl
mongoctl/objects/server.py
Server.authenticate_db
def authenticate_db(self, db, dbname, retry=True): """ Returns True if we manage to auth to the given db, else False. """ log_verbose("Server '%s' attempting to authenticate to db '%s'" % (self.id, dbname)) login_user = self.get_login_user(dbname) username = None ...
python
def authenticate_db(self, db, dbname, retry=True): """ Returns True if we manage to auth to the given db, else False. """ log_verbose("Server '%s' attempting to authenticate to db '%s'" % (self.id, dbname)) login_user = self.get_login_user(dbname) username = None ...
[ "def", "authenticate_db", "(", "self", ",", "db", ",", "dbname", ",", "retry", "=", "True", ")", ":", "log_verbose", "(", "\"Server '%s' attempting to authenticate to db '%s'\"", "%", "(", "self", ".", "id", ",", "dbname", ")", ")", "login_user", "=", "self", ...
Returns True if we manage to auth to the given db, else False.
[ "Returns", "True", "if", "we", "manage", "to", "auth", "to", "the", "given", "db", "else", "False", "." ]
fab15216127ad4bf8ea9aa8a95d75504c0ef01a2
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/objects/server.py#L619-L671
44,545
mongolab/mongoctl
mongoctl/objects/server.py
Server.needs_repl_key
def needs_repl_key(self): """ We need a repl key if you are auth + a cluster member + version is None or >= 2.0.0 """ cluster = self.get_cluster() return (self.supports_repl_key() and cluster is not None and cluster.get_repl_key() is not None)
python
def needs_repl_key(self): """ We need a repl key if you are auth + a cluster member + version is None or >= 2.0.0 """ cluster = self.get_cluster() return (self.supports_repl_key() and cluster is not None and cluster.get_repl_key() is not None)
[ "def", "needs_repl_key", "(", "self", ")", ":", "cluster", "=", "self", ".", "get_cluster", "(", ")", "return", "(", "self", ".", "supports_repl_key", "(", ")", "and", "cluster", "is", "not", "None", "and", "cluster", ".", "get_repl_key", "(", ")", "is",...
We need a repl key if you are auth + a cluster member + version is None or >= 2.0.0
[ "We", "need", "a", "repl", "key", "if", "you", "are", "auth", "+", "a", "cluster", "member", "+", "version", "is", "None", "or", ">", "=", "2", ".", "0", ".", "0" ]
fab15216127ad4bf8ea9aa8a95d75504c0ef01a2
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/objects/server.py#L1003-L1010
44,546
mongolab/mongoctl
mongoctl/commands/command_utils.py
exact_or_minor_exe_version_match
def exact_or_minor_exe_version_match(executable_name, exe_version_tuples, version): """ IF there is an exact match then use it OTHERWISE try to find a minor version match """ exe = exact_exe_version_match(executable_name, ...
python
def exact_or_minor_exe_version_match(executable_name, exe_version_tuples, version): """ IF there is an exact match then use it OTHERWISE try to find a minor version match """ exe = exact_exe_version_match(executable_name, ...
[ "def", "exact_or_minor_exe_version_match", "(", "executable_name", ",", "exe_version_tuples", ",", "version", ")", ":", "exe", "=", "exact_exe_version_match", "(", "executable_name", ",", "exe_version_tuples", ",", "version", ")", "if", "not", "exe", ":", "exe", "="...
IF there is an exact match then use it OTHERWISE try to find a minor version match
[ "IF", "there", "is", "an", "exact", "match", "then", "use", "it", "OTHERWISE", "try", "to", "find", "a", "minor", "version", "match" ]
fab15216127ad4bf8ea9aa8a95d75504c0ef01a2
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/commands/command_utils.py#L231-L246
44,547
jgillick/python-pause
pause/__init__.py
seconds
def seconds(num): """ Pause for this many seconds """ now = pytime.time() end = now + num until(end)
python
def seconds(num): """ Pause for this many seconds """ now = pytime.time() end = now + num until(end)
[ "def", "seconds", "(", "num", ")", ":", "now", "=", "pytime", ".", "time", "(", ")", "end", "=", "now", "+", "num", "until", "(", "end", ")" ]
Pause for this many seconds
[ "Pause", "for", "this", "many", "seconds" ]
ac53175b19693ac8e89b874443a29662eb0c15d5
https://github.com/jgillick/python-pause/blob/ac53175b19693ac8e89b874443a29662eb0c15d5/pause/__init__.py#L75-L81
44,548
mongolab/mongoctl
mongoctl/commands/server/start.py
_pre_mongod_server_start
def _pre_mongod_server_start(server, options_override=None): """ Does necessary work before starting a server 1- An efficiency step for arbiters running with --no-journal * there is a lock file ==> * server must not have exited cleanly from last run, and does not know how to auto-...
python
def _pre_mongod_server_start(server, options_override=None): """ Does necessary work before starting a server 1- An efficiency step for arbiters running with --no-journal * there is a lock file ==> * server must not have exited cleanly from last run, and does not know how to auto-...
[ "def", "_pre_mongod_server_start", "(", "server", ",", "options_override", "=", "None", ")", ":", "lock_file_path", "=", "server", ".", "get_lock_file_path", "(", ")", "no_journal", "=", "(", "server", ".", "get_cmd_option", "(", "\"nojournal\"", ")", "or", "(",...
Does necessary work before starting a server 1- An efficiency step for arbiters running with --no-journal * there is a lock file ==> * server must not have exited cleanly from last run, and does not know how to auto-recover (as a journalled server would) * however: this is an arb...
[ "Does", "necessary", "work", "before", "starting", "a", "server" ]
fab15216127ad4bf8ea9aa8a95d75504c0ef01a2
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/commands/server/start.py#L191-L221
44,549
mongolab/mongoctl
mongoctl/commands/server/start.py
prepare_mongod_server
def prepare_mongod_server(server): """ Contains post start server operations """ log_info("Preparing server '%s' for use as configured..." % server.id) cluster = server.get_cluster() # setup the local users if server supports that if server.supports_local_users(): user...
python
def prepare_mongod_server(server): """ Contains post start server operations """ log_info("Preparing server '%s' for use as configured..." % server.id) cluster = server.get_cluster() # setup the local users if server supports that if server.supports_local_users(): user...
[ "def", "prepare_mongod_server", "(", "server", ")", ":", "log_info", "(", "\"Preparing server '%s' for use as configured...\"", "%", "server", ".", "id", ")", "cluster", "=", "server", ".", "get_cluster", "(", ")", "# setup the local users if server supports that", "if", ...
Contains post start server operations
[ "Contains", "post", "start", "server", "operations" ]
fab15216127ad4bf8ea9aa8a95d75504c0ef01a2
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/commands/server/start.py#L254-L270
44,550
mongolab/mongoctl
mongoctl/commands/server/start.py
_rlimit_min
def _rlimit_min(one_val, nother_val): """Returns the more stringent rlimit value. -1 means no limit.""" if one_val < 0 or nother_val < 0 : return max(one_val, nother_val) else: return min(one_val, nother_val)
python
def _rlimit_min(one_val, nother_val): """Returns the more stringent rlimit value. -1 means no limit.""" if one_val < 0 or nother_val < 0 : return max(one_val, nother_val) else: return min(one_val, nother_val)
[ "def", "_rlimit_min", "(", "one_val", ",", "nother_val", ")", ":", "if", "one_val", "<", "0", "or", "nother_val", "<", "0", ":", "return", "max", "(", "one_val", ",", "nother_val", ")", "else", ":", "return", "min", "(", "one_val", ",", "nother_val", "...
Returns the more stringent rlimit value. -1 means no limit.
[ "Returns", "the", "more", "stringent", "rlimit", "value", ".", "-", "1", "means", "no", "limit", "." ]
fab15216127ad4bf8ea9aa8a95d75504c0ef01a2
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/commands/server/start.py#L492-L497
44,551
openwisp/netdiff
netdiff/parsers/netjson.py
NetJsonParser.parse
def parse(self, data): """ Converts a NetJSON 'NetworkGraph' object to a NetworkX Graph object,which is then returned. Additionally checks for protocol version, revision and metric. """ graph = self._init_graph() # ensure is NetJSON NetworkGraph object if ...
python
def parse(self, data): """ Converts a NetJSON 'NetworkGraph' object to a NetworkX Graph object,which is then returned. Additionally checks for protocol version, revision and metric. """ graph = self._init_graph() # ensure is NetJSON NetworkGraph object if ...
[ "def", "parse", "(", "self", ",", "data", ")", ":", "graph", "=", "self", ".", "_init_graph", "(", ")", "# ensure is NetJSON NetworkGraph object", "if", "'type'", "not", "in", "data", "or", "data", "[", "'type'", "]", "!=", "'NetworkGraph'", ":", "raise", ...
Converts a NetJSON 'NetworkGraph' object to a NetworkX Graph object,which is then returned. Additionally checks for protocol version, revision and metric.
[ "Converts", "a", "NetJSON", "NetworkGraph", "object", "to", "a", "NetworkX", "Graph", "object", "which", "is", "then", "returned", ".", "Additionally", "checks", "for", "protocol", "version", "revision", "and", "metric", "." ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/parsers/netjson.py#L8-L45
44,552
openwisp/netdiff
netdiff/parsers/openvpn.py
OpenvpnParser.parse
def parse(self, data): """ Converts a OpenVPN JSON to a NetworkX Graph object which is then returned. """ # initialize graph and list of aggregated nodes graph = self._init_graph() server = self._server_common_name # add server (central node) to graph ...
python
def parse(self, data): """ Converts a OpenVPN JSON to a NetworkX Graph object which is then returned. """ # initialize graph and list of aggregated nodes graph = self._init_graph() server = self._server_common_name # add server (central node) to graph ...
[ "def", "parse", "(", "self", ",", "data", ")", ":", "# initialize graph and list of aggregated nodes", "graph", "=", "self", ".", "_init_graph", "(", ")", "server", "=", "self", ".", "_server_common_name", "# add server (central node) to graph", "graph", ".", "add_nod...
Converts a OpenVPN JSON to a NetworkX Graph object which is then returned.
[ "Converts", "a", "OpenVPN", "JSON", "to", "a", "NetworkX", "Graph", "object", "which", "is", "then", "returned", "." ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/parsers/openvpn.py#L25-L67
44,553
openwisp/netdiff
netdiff/parsers/batman.py
BatmanParser._txtinfo_to_python
def _txtinfo_to_python(self, data): """ Converts txtinfo format to python """ self._format = 'txtinfo' # find interesting section lines = data.split('\n') try: start = lines.index('Table: Topology') + 2 except ValueError: raise Pars...
python
def _txtinfo_to_python(self, data): """ Converts txtinfo format to python """ self._format = 'txtinfo' # find interesting section lines = data.split('\n') try: start = lines.index('Table: Topology') + 2 except ValueError: raise Pars...
[ "def", "_txtinfo_to_python", "(", "self", ",", "data", ")", ":", "self", ".", "_format", "=", "'txtinfo'", "# find interesting section", "lines", "=", "data", ".", "split", "(", "'\\n'", ")", "try", ":", "start", "=", "lines", ".", "index", "(", "'Table: T...
Converts txtinfo format to python
[ "Converts", "txtinfo", "format", "to", "python" ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/parsers/batman.py#L23-L44
44,554
openwisp/netdiff
netdiff/parsers/batman.py
BatmanParser._get_primary_address
def _get_primary_address(self, mac_address, node_list): """ Uses the _get_aggregated_node_list structure to find the primary mac address associated to a secondary one, if none is found returns itself. """ for local_addresses in node_list: if mac_address in loc...
python
def _get_primary_address(self, mac_address, node_list): """ Uses the _get_aggregated_node_list structure to find the primary mac address associated to a secondary one, if none is found returns itself. """ for local_addresses in node_list: if mac_address in loc...
[ "def", "_get_primary_address", "(", "self", ",", "mac_address", ",", "node_list", ")", ":", "for", "local_addresses", "in", "node_list", ":", "if", "mac_address", "in", "local_addresses", ":", "return", "local_addresses", "[", "0", "]", "return", "mac_address" ]
Uses the _get_aggregated_node_list structure to find the primary mac address associated to a secondary one, if none is found returns itself.
[ "Uses", "the", "_get_aggregated_node_list", "structure", "to", "find", "the", "primary", "mac", "address", "associated", "to", "a", "secondary", "one", "if", "none", "is", "found", "returns", "itself", "." ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/parsers/batman.py#L46-L55
44,555
openwisp/netdiff
netdiff/parsers/batman.py
BatmanParser._get_aggregated_node_list
def _get_aggregated_node_list(self, data): """ Returns list of main and secondary mac addresses. """ node_list = [] for node in data: local_addresses = [node['primary']] if 'secondary' in node: local_addresses += node['secondary'] ...
python
def _get_aggregated_node_list(self, data): """ Returns list of main and secondary mac addresses. """ node_list = [] for node in data: local_addresses = [node['primary']] if 'secondary' in node: local_addresses += node['secondary'] ...
[ "def", "_get_aggregated_node_list", "(", "self", ",", "data", ")", ":", "node_list", "=", "[", "]", "for", "node", "in", "data", ":", "local_addresses", "=", "[", "node", "[", "'primary'", "]", "]", "if", "'secondary'", "in", "node", ":", "local_addresses"...
Returns list of main and secondary mac addresses.
[ "Returns", "list", "of", "main", "and", "secondary", "mac", "addresses", "." ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/parsers/batman.py#L57-L67
44,556
openwisp/netdiff
netdiff/parsers/batman.py
BatmanParser._parse_alfred_vis
def _parse_alfred_vis(self, data): """ Converts a alfred-vis JSON object to a NetworkX Graph object which is then returned. Additionally checks for "source_vesion" to determine the batman-adv version. """ # initialize graph and list of aggregated nodes graph = sel...
python
def _parse_alfred_vis(self, data): """ Converts a alfred-vis JSON object to a NetworkX Graph object which is then returned. Additionally checks for "source_vesion" to determine the batman-adv version. """ # initialize graph and list of aggregated nodes graph = sel...
[ "def", "_parse_alfred_vis", "(", "self", ",", "data", ")", ":", "# initialize graph and list of aggregated nodes", "graph", "=", "self", ".", "_init_graph", "(", ")", "if", "'source_version'", "in", "data", ":", "self", ".", "version", "=", "data", "[", "'source...
Converts a alfred-vis JSON object to a NetworkX Graph object which is then returned. Additionally checks for "source_vesion" to determine the batman-adv version.
[ "Converts", "a", "alfred", "-", "vis", "JSON", "object", "to", "a", "NetworkX", "Graph", "object", "which", "is", "then", "returned", ".", "Additionally", "checks", "for", "source_vesion", "to", "determine", "the", "batman", "-", "adv", "version", "." ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/parsers/batman.py#L79-L106
44,557
openwisp/netdiff
netdiff/parsers/base.py
BaseParser.json
def json(self, dict=False, **kwargs): """ Outputs NetJSON format """ try: graph = self.graph except AttributeError: raise NotImplementedError() return _netjson_networkgraph(self.protocol, self.version, ...
python
def json(self, dict=False, **kwargs): """ Outputs NetJSON format """ try: graph = self.graph except AttributeError: raise NotImplementedError() return _netjson_networkgraph(self.protocol, self.version, ...
[ "def", "json", "(", "self", ",", "dict", "=", "False", ",", "*", "*", "kwargs", ")", ":", "try", ":", "graph", "=", "self", ".", "graph", "except", "AttributeError", ":", "raise", "NotImplementedError", "(", ")", "return", "_netjson_networkgraph", "(", "...
Outputs NetJSON format
[ "Outputs", "NetJSON", "format" ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/parsers/base.py#L135-L150
44,558
openwisp/netdiff
netdiff/utils.py
diff
def diff(old, new): """ Returns differences of two network topologies old and new in NetJSON NetworkGraph compatible format """ protocol = new.protocol version = new.version revision = new.revision metric = new.metric # calculate differences in_both = _find_unchanged(old.graph, n...
python
def diff(old, new): """ Returns differences of two network topologies old and new in NetJSON NetworkGraph compatible format """ protocol = new.protocol version = new.version revision = new.revision metric = new.metric # calculate differences in_both = _find_unchanged(old.graph, n...
[ "def", "diff", "(", "old", ",", "new", ")", ":", "protocol", "=", "new", ".", "protocol", "version", "=", "new", ".", "version", "revision", "=", "new", ".", "revision", "metric", "=", "new", ".", "metric", "# calculate differences", "in_both", "=", "_fi...
Returns differences of two network topologies old and new in NetJSON NetworkGraph compatible format
[ "Returns", "differences", "of", "two", "network", "topologies", "old", "and", "new", "in", "NetJSON", "NetworkGraph", "compatible", "format" ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/utils.py#L7-L48
44,559
openwisp/netdiff
netdiff/utils.py
_make_diff
def _make_diff(old, new, both): """ calculates differences between topologies 'old' and 'new' returns a tuple with two network graph objects the first graph contains the added nodes, the secnod contains the added links """ # make a copy of old topology to avoid tampering with it diff_edges =...
python
def _make_diff(old, new, both): """ calculates differences between topologies 'old' and 'new' returns a tuple with two network graph objects the first graph contains the added nodes, the secnod contains the added links """ # make a copy of old topology to avoid tampering with it diff_edges =...
[ "def", "_make_diff", "(", "old", ",", "new", ",", "both", ")", ":", "# make a copy of old topology to avoid tampering with it", "diff_edges", "=", "new", ".", "copy", "(", ")", "not_different", "=", "[", "tuple", "(", "edge", ")", "for", "edge", "in", "both", ...
calculates differences between topologies 'old' and 'new' returns a tuple with two network graph objects the first graph contains the added nodes, the secnod contains the added links
[ "calculates", "differences", "between", "topologies", "old", "and", "new", "returns", "a", "tuple", "with", "two", "network", "graph", "objects", "the", "first", "graph", "contains", "the", "added", "nodes", "the", "secnod", "contains", "the", "added", "links" ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/utils.py#L51-L70
44,560
openwisp/netdiff
netdiff/utils.py
_find_unchanged
def _find_unchanged(old, new): """ returns edges that are in both old and new """ edges = [] old_edges = [set(edge) for edge in old.edges()] new_edges = [set(edge) for edge in new.edges()] for old_edge in old_edges: if old_edge in new_edges: edges.append(set(old_edge)) ...
python
def _find_unchanged(old, new): """ returns edges that are in both old and new """ edges = [] old_edges = [set(edge) for edge in old.edges()] new_edges = [set(edge) for edge in new.edges()] for old_edge in old_edges: if old_edge in new_edges: edges.append(set(old_edge)) ...
[ "def", "_find_unchanged", "(", "old", ",", "new", ")", ":", "edges", "=", "[", "]", "old_edges", "=", "[", "set", "(", "edge", ")", "for", "edge", "in", "old", ".", "edges", "(", ")", "]", "new_edges", "=", "[", "set", "(", "edge", ")", "for", ...
returns edges that are in both old and new
[ "returns", "edges", "that", "are", "in", "both", "old", "and", "new" ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/utils.py#L73-L83
44,561
openwisp/netdiff
netdiff/utils.py
_find_changed
def _find_changed(old, new, both): """ returns links that have changed cost """ # create two list of sets of old and new edges including cost old_edges = [] for edge in old.edges(data=True): # skip links that are not in both if set((edge[0], edge[1])) not in both: con...
python
def _find_changed(old, new, both): """ returns links that have changed cost """ # create two list of sets of old and new edges including cost old_edges = [] for edge in old.edges(data=True): # skip links that are not in both if set((edge[0], edge[1])) not in both: con...
[ "def", "_find_changed", "(", "old", ",", "new", ",", "both", ")", ":", "# create two list of sets of old and new edges including cost", "old_edges", "=", "[", "]", "for", "edge", "in", "old", ".", "edges", "(", "data", "=", "True", ")", ":", "# skip links that a...
returns links that have changed cost
[ "returns", "links", "that", "have", "changed", "cost" ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/utils.py#L86-L119
44,562
openwisp/netdiff
netdiff/parsers/bmx6.py
Bmx6Parser.parse
def parse(self, data): """ Converts a BMX6 b6m JSON to a NetworkX Graph object which is then returned. """ # initialize graph and list of aggregated nodes graph = self._init_graph() if len(data) != 0: if "links" not in data[0]: raise Pa...
python
def parse(self, data): """ Converts a BMX6 b6m JSON to a NetworkX Graph object which is then returned. """ # initialize graph and list of aggregated nodes graph = self._init_graph() if len(data) != 0: if "links" not in data[0]: raise Pa...
[ "def", "parse", "(", "self", ",", "data", ")", ":", "# initialize graph and list of aggregated nodes", "graph", "=", "self", ".", "_init_graph", "(", ")", "if", "len", "(", "data", ")", "!=", "0", ":", "if", "\"links\"", "not", "in", "data", "[", "0", "]...
Converts a BMX6 b6m JSON to a NetworkX Graph object which is then returned.
[ "Converts", "a", "BMX6", "b6m", "JSON", "to", "a", "NetworkX", "Graph", "object", "which", "is", "then", "returned", "." ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/parsers/bmx6.py#L11-L31
44,563
openwisp/netdiff
netdiff/parsers/cnml.py
CnmlParser.parse
def parse(self, data): """ Converts a CNML structure to a NetworkX Graph object which is then returned. """ graph = self._init_graph() # loop over links and create networkx graph # Add only working nodes with working links for link in data.get_inner_links(...
python
def parse(self, data): """ Converts a CNML structure to a NetworkX Graph object which is then returned. """ graph = self._init_graph() # loop over links and create networkx graph # Add only working nodes with working links for link in data.get_inner_links(...
[ "def", "parse", "(", "self", ",", "data", ")", ":", "graph", "=", "self", ".", "_init_graph", "(", ")", "# loop over links and create networkx graph", "# Add only working nodes with working links", "for", "link", "in", "data", ".", "get_inner_links", "(", ")", ":", ...
Converts a CNML structure to a NetworkX Graph object which is then returned.
[ "Converts", "a", "CNML", "structure", "to", "a", "NetworkX", "Graph", "object", "which", "is", "then", "returned", "." ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/parsers/cnml.py#L34-L50
44,564
openwisp/netdiff
netdiff/parsers/olsr.py
OlsrParser.parse
def parse(self, data): """ Converts a dict representing an OLSR 0.6.x topology to a NetworkX Graph object, which is then returned. Additionally checks for "config" data in order to determine version and revision. """ graph = self._init_graph() if 'topology' not in...
python
def parse(self, data): """ Converts a dict representing an OLSR 0.6.x topology to a NetworkX Graph object, which is then returned. Additionally checks for "config" data in order to determine version and revision. """ graph = self._init_graph() if 'topology' not in...
[ "def", "parse", "(", "self", ",", "data", ")", ":", "graph", "=", "self", ".", "_init_graph", "(", ")", "if", "'topology'", "not", "in", "data", ":", "raise", "ParserError", "(", "'Parse error, \"topology\" key not found'", ")", "elif", "'mid'", "not", "in",...
Converts a dict representing an OLSR 0.6.x topology to a NetworkX Graph object, which is then returned. Additionally checks for "config" data in order to determine version and revision.
[ "Converts", "a", "dict", "representing", "an", "OLSR", "0", ".", "6", ".", "x", "topology", "to", "a", "NetworkX", "Graph", "object", "which", "is", "then", "returned", ".", "Additionally", "checks", "for", "config", "data", "in", "order", "to", "determine...
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/parsers/olsr.py#L20-L71
44,565
openwisp/netdiff
netdiff/parsers/olsr.py
OlsrParser._txtinfo_to_jsoninfo
def _txtinfo_to_jsoninfo(self, data): """ converts olsr 1 txtinfo format to jsoninfo """ # replace INFINITE with inf, which is convertible to float data = data.replace('INFINITE', 'inf') # find interesting section lines = data.split('\n') # process links ...
python
def _txtinfo_to_jsoninfo(self, data): """ converts olsr 1 txtinfo format to jsoninfo """ # replace INFINITE with inf, which is convertible to float data = data.replace('INFINITE', 'inf') # find interesting section lines = data.split('\n') # process links ...
[ "def", "_txtinfo_to_jsoninfo", "(", "self", ",", "data", ")", ":", "# replace INFINITE with inf, which is convertible to float", "data", "=", "data", ".", "replace", "(", "'INFINITE'", ",", "'inf'", ")", "# find interesting section", "lines", "=", "data", ".", "split"...
converts olsr 1 txtinfo format to jsoninfo
[ "converts", "olsr", "1", "txtinfo", "format", "to", "jsoninfo" ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/parsers/olsr.py#L73-L122
44,566
pyupio/changelogs
changelogs/changelogs.py
check_for_launchpad
def check_for_launchpad(old_vendor, name, urls): """Check if the project is hosted on launchpad. :param name: str, name of the project :param urls: set, urls to check. :return: the name of the project on launchpad, or an empty string. """ if old_vendor != "pypi": # XXX This might work f...
python
def check_for_launchpad(old_vendor, name, urls): """Check if the project is hosted on launchpad. :param name: str, name of the project :param urls: set, urls to check. :return: the name of the project on launchpad, or an empty string. """ if old_vendor != "pypi": # XXX This might work f...
[ "def", "check_for_launchpad", "(", "old_vendor", ",", "name", ",", "urls", ")", ":", "if", "old_vendor", "!=", "\"pypi\"", ":", "# XXX This might work for other starting vendors", "# XXX but I didn't check. For now only allow", "# XXX pypi -> launchpad.", "return", "''", "for...
Check if the project is hosted on launchpad. :param name: str, name of the project :param urls: set, urls to check. :return: the name of the project on launchpad, or an empty string.
[ "Check", "if", "the", "project", "is", "hosted", "on", "launchpad", "." ]
0cdb929ac4546c766cd7eef9ae4eb4baaa08f452
https://github.com/pyupio/changelogs/blob/0cdb929ac4546c766cd7eef9ae4eb4baaa08f452/changelogs/changelogs.py#L110-L129
44,567
pyupio/changelogs
changelogs/changelogs.py
check_switch_vendor
def check_switch_vendor(old_vendor, name, urls, _depth=0): """Check if the project should switch vendors. E.g project pushed on pypi, but changelog on launchpad. :param name: str, name of the project :param urls: set, urls to check. :return: tuple, (str(new vendor name), str(new project name)) ...
python
def check_switch_vendor(old_vendor, name, urls, _depth=0): """Check if the project should switch vendors. E.g project pushed on pypi, but changelog on launchpad. :param name: str, name of the project :param urls: set, urls to check. :return: tuple, (str(new vendor name), str(new project name)) ...
[ "def", "check_switch_vendor", "(", "old_vendor", ",", "name", ",", "urls", ",", "_depth", "=", "0", ")", ":", "if", "_depth", ">", "3", ":", "# Protect against recursive things vendors here.", "return", "\"\"", "new_name", "=", "check_for_launchpad", "(", "old_ven...
Check if the project should switch vendors. E.g project pushed on pypi, but changelog on launchpad. :param name: str, name of the project :param urls: set, urls to check. :return: tuple, (str(new vendor name), str(new project name))
[ "Check", "if", "the", "project", "should", "switch", "vendors", ".", "E", ".", "g", "project", "pushed", "on", "pypi", "but", "changelog", "on", "launchpad", "." ]
0cdb929ac4546c766cd7eef9ae4eb4baaa08f452
https://github.com/pyupio/changelogs/blob/0cdb929ac4546c766cd7eef9ae4eb4baaa08f452/changelogs/changelogs.py#L132-L146
44,568
klen/python-scss
scss/function.py
check_pil
def check_pil(func): """ PIL module checking decorator. """ def __wrapper(*args, **kwargs): root = kwargs.get('root') if not Image: if root and root.get_opt('warn'): warn("Images manipulation require PIL") return 'none' return func(*args, **kwa...
python
def check_pil(func): """ PIL module checking decorator. """ def __wrapper(*args, **kwargs): root = kwargs.get('root') if not Image: if root and root.get_opt('warn'): warn("Images manipulation require PIL") return 'none' return func(*args, **kwa...
[ "def", "check_pil", "(", "func", ")", ":", "def", "__wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "root", "=", "kwargs", ".", "get", "(", "'root'", ")", "if", "not", "Image", ":", "if", "root", "and", "root", ".", "get_opt", "("...
PIL module checking decorator.
[ "PIL", "module", "checking", "decorator", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/function.py#L54-L64
44,569
klen/python-scss
scss/function.py
_mix
def _mix(color1, color2, weight=0.5, **kwargs): """ Mixes two colors together. """ weight = float(weight) c1 = color1.value c2 = color2.value p = 0.0 if weight < 0 else 1.0 if weight > 1 else weight w = p * 2 - 1 a = c1[3] - c2[3] w1 = ((w if (w * a == -1) else (w + a) / (1 + w * a)...
python
def _mix(color1, color2, weight=0.5, **kwargs): """ Mixes two colors together. """ weight = float(weight) c1 = color1.value c2 = color2.value p = 0.0 if weight < 0 else 1.0 if weight > 1 else weight w = p * 2 - 1 a = c1[3] - c2[3] w1 = ((w if (w * a == -1) else (w + a) / (1 + w * a)...
[ "def", "_mix", "(", "color1", ",", "color2", ",", "weight", "=", "0.5", ",", "*", "*", "kwargs", ")", ":", "weight", "=", "float", "(", "weight", ")", "c1", "=", "color1", ".", "value", "c2", "=", "color2", ".", "value", "p", "=", "0.0", "if", ...
Mixes two colors together.
[ "Mixes", "two", "colors", "together", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/function.py#L100-L114
44,570
klen/python-scss
scss/function.py
_hsla
def _hsla(h, s, l, a, **kwargs): """ HSL with alpha channel color value. """ res = colorsys.hls_to_rgb(float(h), float(l), float(s)) return ColorValue([x * 255.0 for x in res] + [float(a)])
python
def _hsla(h, s, l, a, **kwargs): """ HSL with alpha channel color value. """ res = colorsys.hls_to_rgb(float(h), float(l), float(s)) return ColorValue([x * 255.0 for x in res] + [float(a)])
[ "def", "_hsla", "(", "h", ",", "s", ",", "l", ",", "a", ",", "*", "*", "kwargs", ")", ":", "res", "=", "colorsys", ".", "hls_to_rgb", "(", "float", "(", "h", ")", ",", "float", "(", "l", ")", ",", "float", "(", "s", ")", ")", "return", "Col...
HSL with alpha channel color value.
[ "HSL", "with", "alpha", "channel", "color", "value", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/function.py#L126-L130
44,571
klen/python-scss
scss/function.py
_hue
def _hue(color, **kwargs): """ Get hue value of HSL color. """ h = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[0] return NumberValue(h * 360.0)
python
def _hue(color, **kwargs): """ Get hue value of HSL color. """ h = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[0] return NumberValue(h * 360.0)
[ "def", "_hue", "(", "color", ",", "*", "*", "kwargs", ")", ":", "h", "=", "colorsys", ".", "rgb_to_hls", "(", "*", "[", "x", "/", "255.0", "for", "x", "in", "color", ".", "value", "[", ":", "3", "]", "]", ")", "[", "0", "]", "return", "Number...
Get hue value of HSL color.
[ "Get", "hue", "value", "of", "HSL", "color", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/function.py#L133-L137
44,572
klen/python-scss
scss/function.py
_lightness
def _lightness(color, **kwargs): """ Get lightness value of HSL color. """ l = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[1] return NumberValue((l * 100, '%'))
python
def _lightness(color, **kwargs): """ Get lightness value of HSL color. """ l = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[1] return NumberValue((l * 100, '%'))
[ "def", "_lightness", "(", "color", ",", "*", "*", "kwargs", ")", ":", "l", "=", "colorsys", ".", "rgb_to_hls", "(", "*", "[", "x", "/", "255.0", "for", "x", "in", "color", ".", "value", "[", ":", "3", "]", "]", ")", "[", "1", "]", "return", "...
Get lightness value of HSL color.
[ "Get", "lightness", "value", "of", "HSL", "color", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/function.py#L140-L144
44,573
klen/python-scss
scss/function.py
_saturation
def _saturation(color, **kwargs): """ Get saturation value of HSL color. """ s = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[2] return NumberValue((s * 100, '%'))
python
def _saturation(color, **kwargs): """ Get saturation value of HSL color. """ s = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[2] return NumberValue((s * 100, '%'))
[ "def", "_saturation", "(", "color", ",", "*", "*", "kwargs", ")", ":", "s", "=", "colorsys", ".", "rgb_to_hls", "(", "*", "[", "x", "/", "255.0", "for", "x", "in", "color", ".", "value", "[", ":", "3", "]", "]", ")", "[", "2", "]", "return", ...
Get saturation value of HSL color.
[ "Get", "saturation", "value", "of", "HSL", "color", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/function.py#L147-L151
44,574
klen/python-scss
scss/parser.py
load
def load(path, cache=None, precache=False): """ Parse from file. """ parser = Stylesheet(cache) return parser.load(path, precache=precache)
python
def load(path, cache=None, precache=False): """ Parse from file. """ parser = Stylesheet(cache) return parser.load(path, precache=precache)
[ "def", "load", "(", "path", ",", "cache", "=", "None", ",", "precache", "=", "False", ")", ":", "parser", "=", "Stylesheet", "(", "cache", ")", "return", "parser", ".", "load", "(", "path", ",", "precache", "=", "precache", ")" ]
Parse from file.
[ "Parse", "from", "file", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L392-L396
44,575
klen/python-scss
scss/parser.py
Ruleset.parse
def parse(self, target): """ Parse nested rulesets and save it in cache. """ if isinstance(target, ContentNode): if target.name: self.parent = target self.name.parse(self) self.name += target.name target.ruleset....
python
def parse(self, target): """ Parse nested rulesets and save it in cache. """ if isinstance(target, ContentNode): if target.name: self.parent = target self.name.parse(self) self.name += target.name target.ruleset....
[ "def", "parse", "(", "self", ",", "target", ")", ":", "if", "isinstance", "(", "target", ",", "ContentNode", ")", ":", "if", "target", ".", "name", ":", "self", ".", "parent", "=", "target", "self", ".", "name", ".", "parse", "(", "self", ")", "sel...
Parse nested rulesets and save it in cache.
[ "Parse", "nested", "rulesets", "and", "save", "it", "in", "cache", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L63-L74
44,576
klen/python-scss
scss/parser.py
Declaration.parse
def parse(self, target): """ Parse nested declaration. """ if not isinstance(target, Node): parent = ContentNode(None, None, []) parent.parse(target) target = parent super(Declaration, self).parse(target) self.name = str(self.data[0]) ...
python
def parse(self, target): """ Parse nested declaration. """ if not isinstance(target, Node): parent = ContentNode(None, None, []) parent.parse(target) target = parent super(Declaration, self).parse(target) self.name = str(self.data[0]) ...
[ "def", "parse", "(", "self", ",", "target", ")", ":", "if", "not", "isinstance", "(", "target", ",", "Node", ")", ":", "parent", "=", "ContentNode", "(", "None", ",", "None", ",", "[", "]", ")", "parent", ".", "parse", "(", "target", ")", "target",...
Parse nested declaration.
[ "Parse", "nested", "declaration", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L88-L107
44,577
klen/python-scss
scss/parser.py
VarDefinition.parse
def parse(self, target): """ Update root and parent context. """ super(VarDefinition, self).parse(target) if isinstance(self.parent, ParseNode): self.parent.ctx.update({self.name: self.expression.value}) self.root.set_var(self)
python
def parse(self, target): """ Update root and parent context. """ super(VarDefinition, self).parse(target) if isinstance(self.parent, ParseNode): self.parent.ctx.update({self.name: self.expression.value}) self.root.set_var(self)
[ "def", "parse", "(", "self", ",", "target", ")", ":", "super", "(", "VarDefinition", ",", "self", ")", ".", "parse", "(", "target", ")", "if", "isinstance", "(", "self", ".", "parent", ",", "ParseNode", ")", ":", "self", ".", "parent", ".", "ctx", ...
Update root and parent context.
[ "Update", "root", "and", "parent", "context", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L188-L194
44,578
klen/python-scss
scss/parser.py
Stylesheet.set_var
def set_var(self, vardef): """ Set variable to global stylesheet context. """ if not(vardef.default and self.cache['ctx'].get(vardef.name)): self.cache['ctx'][vardef.name] = vardef.expression.value
python
def set_var(self, vardef): """ Set variable to global stylesheet context. """ if not(vardef.default and self.cache['ctx'].get(vardef.name)): self.cache['ctx'][vardef.name] = vardef.expression.value
[ "def", "set_var", "(", "self", ",", "vardef", ")", ":", "if", "not", "(", "vardef", ".", "default", "and", "self", ".", "cache", "[", "'ctx'", "]", ".", "get", "(", "vardef", ".", "name", ")", ")", ":", "self", ".", "cache", "[", "'ctx'", "]", ...
Set variable to global stylesheet context.
[ "Set", "variable", "to", "global", "stylesheet", "context", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L292-L296
44,579
klen/python-scss
scss/parser.py
Stylesheet.set_opt
def set_opt(self, name, value): """ Set option. """ self.cache['opts'][name] = value if name == 'compress': self.cache['delims'] = self.def_delims if not value else ( '', '', '')
python
def set_opt(self, name, value): """ Set option. """ self.cache['opts'][name] = value if name == 'compress': self.cache['delims'] = self.def_delims if not value else ( '', '', '')
[ "def", "set_opt", "(", "self", ",", "name", ",", "value", ")", ":", "self", ".", "cache", "[", "'opts'", "]", "[", "name", "]", "=", "value", "if", "name", "==", "'compress'", ":", "self", ".", "cache", "[", "'delims'", "]", "=", "self", ".", "de...
Set option.
[ "Set", "option", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L298-L307
44,580
klen/python-scss
scss/parser.py
Stylesheet.update
def update(self, cache): """ Update self cache from other. """ self.cache['delims'] = cache.get('delims') self.cache['opts'].update(cache.get('opts')) self.cache['rset'].update(cache.get('rset')) self.cache['mix'].update(cache.get('mix')) map(self.set_var, cache['...
python
def update(self, cache): """ Update self cache from other. """ self.cache['delims'] = cache.get('delims') self.cache['opts'].update(cache.get('opts')) self.cache['rset'].update(cache.get('rset')) self.cache['mix'].update(cache.get('mix')) map(self.set_var, cache['...
[ "def", "update", "(", "self", ",", "cache", ")", ":", "self", ".", "cache", "[", "'delims'", "]", "=", "cache", ".", "get", "(", "'delims'", ")", "self", ".", "cache", "[", "'opts'", "]", ".", "update", "(", "cache", ".", "get", "(", "'opts'", ")...
Update self cache from other.
[ "Update", "self", "cache", "from", "other", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L314-L321
44,581
klen/python-scss
scss/parser.py
Stylesheet.scan
def scan(src): """ Scan scss from string and return nodes. """ assert isinstance(src, (unicode_, bytes_)) try: nodes = STYLESHEET.parseString(src, parseAll=True) return nodes except ParseBaseException: err = sys.exc_info()[1] print(...
python
def scan(src): """ Scan scss from string and return nodes. """ assert isinstance(src, (unicode_, bytes_)) try: nodes = STYLESHEET.parseString(src, parseAll=True) return nodes except ParseBaseException: err = sys.exc_info()[1] print(...
[ "def", "scan", "(", "src", ")", ":", "assert", "isinstance", "(", "src", ",", "(", "unicode_", ",", "bytes_", ")", ")", "try", ":", "nodes", "=", "STYLESHEET", ".", "parseString", "(", "src", ",", "parseAll", "=", "True", ")", "return", "nodes", "exc...
Scan scss from string and return nodes.
[ "Scan", "scss", "from", "string", "and", "return", "nodes", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L324-L336
44,582
klen/python-scss
scss/parser.py
Stylesheet.loads
def loads(self, src): """ Compile css from scss string. """ assert isinstance(src, (unicode_, bytes_)) nodes = self.scan(src.strip()) self.parse(nodes) return ''.join(map(str, nodes))
python
def loads(self, src): """ Compile css from scss string. """ assert isinstance(src, (unicode_, bytes_)) nodes = self.scan(src.strip()) self.parse(nodes) return ''.join(map(str, nodes))
[ "def", "loads", "(", "self", ",", "src", ")", ":", "assert", "isinstance", "(", "src", ",", "(", "unicode_", ",", "bytes_", ")", ")", "nodes", "=", "self", ".", "scan", "(", "src", ".", "strip", "(", ")", ")", "self", ".", "parse", "(", "nodes", ...
Compile css from scss string.
[ "Compile", "css", "from", "scss", "string", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L343-L349
44,583
klen/python-scss
scss/parser.py
Stylesheet.load
def load(self, f, precache=None): """ Compile scss from file. File is string path of file object. """ precache = precache or self.get_opt('cache') or False nodes = None if isinstance(f, file_): path = os.path.abspath(f.name) else: path...
python
def load(self, f, precache=None): """ Compile scss from file. File is string path of file object. """ precache = precache or self.get_opt('cache') or False nodes = None if isinstance(f, file_): path = os.path.abspath(f.name) else: path...
[ "def", "load", "(", "self", ",", "f", ",", "precache", "=", "None", ")", ":", "precache", "=", "precache", "or", "self", ".", "get_opt", "(", "'cache'", ")", "or", "False", "nodes", "=", "None", "if", "isinstance", "(", "f", ",", "file_", ")", ":",...
Compile scss from file. File is string path of file object.
[ "Compile", "scss", "from", "file", ".", "File", "is", "string", "path", "of", "file", "object", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L351-L382
44,584
openego/ego.io
egoio/tools/config.py
load_config
def load_config(filename, filepath=''): """ Loads config file Parameters ---------- filename: str Filename of config file (incl. file extension filepath: str Absolute path to directory of desired config file """ FILE = path.join(filepath, filename) try: cfg...
python
def load_config(filename, filepath=''): """ Loads config file Parameters ---------- filename: str Filename of config file (incl. file extension filepath: str Absolute path to directory of desired config file """ FILE = path.join(filepath, filename) try: cfg...
[ "def", "load_config", "(", "filename", ",", "filepath", "=", "''", ")", ":", "FILE", "=", "path", ".", "join", "(", "filepath", ",", "filename", ")", "try", ":", "cfg", ".", "read", "(", "FILE", ")", "global", "_loaded", "_loaded", "=", "True", "exce...
Loads config file Parameters ---------- filename: str Filename of config file (incl. file extension filepath: str Absolute path to directory of desired config file
[ "Loads", "config", "file" ]
35c472914ee62eff37ddb8e69be3d83276cf2d42
https://github.com/openego/ego.io/blob/35c472914ee62eff37ddb8e69be3d83276cf2d42/egoio/tools/config.py#L37-L56
44,585
NeelShah18/emot
emot/core.py
emoji
def emoji(string): '''emot.emoji is use to detect emoji from text >>> text = "I love python 👨 :-)" >>> emot.emoji(text) >>> {'value': ['👨'], 'mean': [':man:'], 'location': [[14, 14]], 'flag': True} ''' __entities = {} __value = [] __mean = [] __location = [] flag =...
python
def emoji(string): '''emot.emoji is use to detect emoji from text >>> text = "I love python 👨 :-)" >>> emot.emoji(text) >>> {'value': ['👨'], 'mean': [':man:'], 'location': [[14, 14]], 'flag': True} ''' __entities = {} __value = [] __mean = [] __location = [] flag =...
[ "def", "emoji", "(", "string", ")", ":", "__entities", "=", "{", "}", "__value", "=", "[", "]", "__mean", "=", "[", "]", "__location", "=", "[", "]", "flag", "=", "True", "try", ":", "pro_string", "=", "str", "(", "string", ")", "for", "pos", ","...
emot.emoji is use to detect emoji from text >>> text = "I love python 👨 :-)" >>> emot.emoji(text) >>> {'value': ['👨'], 'mean': [':man:'], 'location': [[14, 14]], 'flag': True}
[ "emot", ".", "emoji", "is", "use", "to", "detect", "emoji", "from", "text" ]
e0db2c7ebc033f232652f20c5466d27bfebe02bd
https://github.com/NeelShah18/emot/blob/e0db2c7ebc033f232652f20c5466d27bfebe02bd/emot/core.py#L17-L55
44,586
NeelShah18/emot
emot/core.py
emoticons
def emoticons(string): '''emot.emoticons is use to detect emoticons from text >>> text = "I love python 👨 :-)" >>> emot.emoticons(text) >>> {'value': [':-)'], 'location': [[16, 19]], 'mean': ['Happy face smiley'], 'flag': True} ''' __entities = [] flag = True try: p...
python
def emoticons(string): '''emot.emoticons is use to detect emoticons from text >>> text = "I love python 👨 :-)" >>> emot.emoticons(text) >>> {'value': [':-)'], 'location': [[16, 19]], 'mean': ['Happy face smiley'], 'flag': True} ''' __entities = [] flag = True try: p...
[ "def", "emoticons", "(", "string", ")", ":", "__entities", "=", "[", "]", "flag", "=", "True", "try", ":", "pattern", "=", "u'('", "+", "u'|'", ".", "join", "(", "k", "for", "k", "in", "emo_unicode", ".", "EMOTICONS", ")", "+", "u')'", "__entities", ...
emot.emoticons is use to detect emoticons from text >>> text = "I love python 👨 :-)" >>> emot.emoticons(text) >>> {'value': [':-)'], 'location': [[16, 19]], 'mean': ['Happy face smiley'], 'flag': True}
[ "emot", ".", "emoticons", "is", "use", "to", "detect", "emoticons", "from", "text" ]
e0db2c7ebc033f232652f20c5466d27bfebe02bd
https://github.com/NeelShah18/emot/blob/e0db2c7ebc033f232652f20c5466d27bfebe02bd/emot/core.py#L57-L93
44,587
insynchq/flask-googlelogin
flask_googlelogin.py
GoogleLogin.init_app
def init_app(self, app, add_context_processor=True): """ Initialize with app configuration """ # Check if login manager has been initialized if not hasattr(app, 'login_manager'): self.login_manager.init_app( app, add_context_processor=...
python
def init_app(self, app, add_context_processor=True): """ Initialize with app configuration """ # Check if login manager has been initialized if not hasattr(app, 'login_manager'): self.login_manager.init_app( app, add_context_processor=...
[ "def", "init_app", "(", "self", ",", "app", ",", "add_context_processor", "=", "True", ")", ":", "# Check if login manager has been initialized", "if", "not", "hasattr", "(", "app", ",", "'login_manager'", ")", ":", "self", ".", "login_manager", ".", "init_app", ...
Initialize with app configuration
[ "Initialize", "with", "app", "configuration" ]
67346d232414fdba7283f516cb7540d41134d175
https://github.com/insynchq/flask-googlelogin/blob/67346d232414fdba7283f516cb7540d41134d175/flask_googlelogin.py#L39-L55
44,588
insynchq/flask-googlelogin
flask_googlelogin.py
GoogleLogin.login_url
def login_url(self, params=None, **kwargs): """ Return login url with params encoded in state Available Google auth server params: response_type: code, token prompt: none, select_account, consent approval_prompt: force, auto access_type: online, offline s...
python
def login_url(self, params=None, **kwargs): """ Return login url with params encoded in state Available Google auth server params: response_type: code, token prompt: none, select_account, consent approval_prompt: force, auto access_type: online, offline s...
[ "def", "login_url", "(", "self", ",", "params", "=", "None", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'response_type'", ",", "'code'", ")", "kwargs", ".", "setdefault", "(", "'access_type'", ",", "'online'", ")", "if", "'prom...
Return login url with params encoded in state Available Google auth server params: response_type: code, token prompt: none, select_account, consent approval_prompt: force, auto access_type: online, offline scopes: string (separated with commas) or list redirect_u...
[ "Return", "login", "url", "with", "params", "encoded", "in", "state" ]
67346d232414fdba7283f516cb7540d41134d175
https://github.com/insynchq/flask-googlelogin/blob/67346d232414fdba7283f516cb7540d41134d175/flask_googlelogin.py#L88-L119
44,589
insynchq/flask-googlelogin
flask_googlelogin.py
GoogleLogin.unauthorized_callback
def unauthorized_callback(self): """ Redirect to login url with next param set as request.url """ return redirect(self.login_url(params=dict(next=request.url)))
python
def unauthorized_callback(self): """ Redirect to login url with next param set as request.url """ return redirect(self.login_url(params=dict(next=request.url)))
[ "def", "unauthorized_callback", "(", "self", ")", ":", "return", "redirect", "(", "self", ".", "login_url", "(", "params", "=", "dict", "(", "next", "=", "request", ".", "url", ")", ")", ")" ]
Redirect to login url with next param set as request.url
[ "Redirect", "to", "login", "url", "with", "next", "param", "set", "as", "request", ".", "url" ]
67346d232414fdba7283f516cb7540d41134d175
https://github.com/insynchq/flask-googlelogin/blob/67346d232414fdba7283f516cb7540d41134d175/flask_googlelogin.py#L121-L125
44,590
insynchq/flask-googlelogin
flask_googlelogin.py
GoogleLogin.get_access_token
def get_access_token(self, refresh_token): """ Use a refresh token to obtain a new access token """ token = requests.post(GOOGLE_OAUTH2_TOKEN_URL, data=dict( refresh_token=refresh_token, grant_type='refresh_token', client_id=self.client_id, ...
python
def get_access_token(self, refresh_token): """ Use a refresh token to obtain a new access token """ token = requests.post(GOOGLE_OAUTH2_TOKEN_URL, data=dict( refresh_token=refresh_token, grant_type='refresh_token', client_id=self.client_id, ...
[ "def", "get_access_token", "(", "self", ",", "refresh_token", ")", ":", "token", "=", "requests", ".", "post", "(", "GOOGLE_OAUTH2_TOKEN_URL", ",", "data", "=", "dict", "(", "refresh_token", "=", "refresh_token", ",", "grant_type", "=", "'refresh_token'", ",", ...
Use a refresh token to obtain a new access token
[ "Use", "a", "refresh", "token", "to", "obtain", "a", "new", "access", "token" ]
67346d232414fdba7283f516cb7540d41134d175
https://github.com/insynchq/flask-googlelogin/blob/67346d232414fdba7283f516cb7540d41134d175/flask_googlelogin.py#L151-L166
44,591
insynchq/flask-googlelogin
flask_googlelogin.py
GoogleLogin.oauth2callback
def oauth2callback(self, view_func): """ Decorator for OAuth2 callback. Calls `GoogleLogin.login` then passes results to `view_func`. """ @wraps(view_func) def decorated(*args, **kwargs): params = {} # Check sig if 'state' in request....
python
def oauth2callback(self, view_func): """ Decorator for OAuth2 callback. Calls `GoogleLogin.login` then passes results to `view_func`. """ @wraps(view_func) def decorated(*args, **kwargs): params = {} # Check sig if 'state' in request....
[ "def", "oauth2callback", "(", "self", ",", "view_func", ")", ":", "@", "wraps", "(", "view_func", ")", "def", "decorated", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "}", "# Check sig", "if", "'state'", "in", "request", ...
Decorator for OAuth2 callback. Calls `GoogleLogin.login` then passes results to `view_func`.
[ "Decorator", "for", "OAuth2", "callback", ".", "Calls", "GoogleLogin", ".", "login", "then", "passes", "results", "to", "view_func", "." ]
67346d232414fdba7283f516cb7540d41134d175
https://github.com/insynchq/flask-googlelogin/blob/67346d232414fdba7283f516cb7540d41134d175/flask_googlelogin.py#L168-L214
44,592
klen/python-scss
scss/tool.py
complete
def complete(text, state): """ Auto complete scss constructions in interactive mode. """ for cmd in COMMANDS: if cmd.startswith(text): if not state: return cmd else: state -= 1
python
def complete(text, state): """ Auto complete scss constructions in interactive mode. """ for cmd in COMMANDS: if cmd.startswith(text): if not state: return cmd else: state -= 1
[ "def", "complete", "(", "text", ",", "state", ")", ":", "for", "cmd", "in", "COMMANDS", ":", "if", "cmd", ".", "startswith", "(", "text", ")", ":", "if", "not", "state", ":", "return", "cmd", "else", ":", "state", "-=", "1" ]
Auto complete scss constructions in interactive mode.
[ "Auto", "complete", "scss", "constructions", "in", "interactive", "mode", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/tool.py#L16-L23
44,593
ulule/django-linguist
linguist/fields/__init__.py
Linguist.validate_args
def validate_args(self): """ Validates arguments. """ from ..mixins import ModelMixin for arg in ("instance", "decider", "identifier", "fields", "default_language"): if getattr(self, arg) is None: raise AttributeError("%s must not be None" % arg) ...
python
def validate_args(self): """ Validates arguments. """ from ..mixins import ModelMixin for arg in ("instance", "decider", "identifier", "fields", "default_language"): if getattr(self, arg) is None: raise AttributeError("%s must not be None" % arg) ...
[ "def", "validate_args", "(", "self", ")", ":", "from", ".", ".", "mixins", "import", "ModelMixin", "for", "arg", "in", "(", "\"instance\"", ",", "\"decider\"", ",", "\"identifier\"", ",", "\"fields\"", ",", "\"default_language\"", ")", ":", "if", "getattr", ...
Validates arguments.
[ "Validates", "arguments", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/fields/__init__.py#L40-L56
44,594
ulule/django-linguist
linguist/fields/__init__.py
Linguist.active_language
def active_language(self): """ Returns active language. """ # Current instance language (if user uses activate_language() method) if self._language is not None: return self._language # Current site language (translation.get_language()) current = utils...
python
def active_language(self): """ Returns active language. """ # Current instance language (if user uses activate_language() method) if self._language is not None: return self._language # Current site language (translation.get_language()) current = utils...
[ "def", "active_language", "(", "self", ")", ":", "# Current instance language (if user uses activate_language() method)", "if", "self", ".", "_language", "is", "not", "None", ":", "return", "self", ".", "_language", "# Current site language (translation.get_language())", "cur...
Returns active language.
[ "Returns", "active", "language", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/fields/__init__.py#L59-L73
44,595
ulule/django-linguist
linguist/fields/__init__.py
Linguist.translation_instances
def translation_instances(self): """ Returns translation instances. """ return [ instance for k, v in six.iteritems(self.instance._linguist_translations) for instance in v.values() ]
python
def translation_instances(self): """ Returns translation instances. """ return [ instance for k, v in six.iteritems(self.instance._linguist_translations) for instance in v.values() ]
[ "def", "translation_instances", "(", "self", ")", ":", "return", "[", "instance", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "self", ".", "instance", ".", "_linguist_translations", ")", "for", "instance", "in", "v", ".", "values", "(", ")"...
Returns translation instances.
[ "Returns", "translation", "instances", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/fields/__init__.py#L128-L136
44,596
ulule/django-linguist
linguist/fields/__init__.py
Linguist.get_cache
def get_cache( self, instance, translation=None, language=None, field_name=None, field_value=None, ): """ Returns translation from cache. """ is_new = bool(instance.pk is None) try: cached_obj = instance._linguist_t...
python
def get_cache( self, instance, translation=None, language=None, field_name=None, field_value=None, ): """ Returns translation from cache. """ is_new = bool(instance.pk is None) try: cached_obj = instance._linguist_t...
[ "def", "get_cache", "(", "self", ",", "instance", ",", "translation", "=", "None", ",", "language", "=", "None", ",", "field_name", "=", "None", ",", "field_value", "=", "None", ",", ")", ":", "is_new", "=", "bool", "(", "instance", ".", "pk", "is", ...
Returns translation from cache.
[ "Returns", "translation", "from", "cache", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/fields/__init__.py#L145-L196
44,597
ulule/django-linguist
linguist/fields/__init__.py
Linguist.set_cache
def set_cache( self, instance=None, translation=None, language=None, field_name=None, field_value=None, ): """ Add a new translation into the cache. """ if instance is not None and translation is not None: cached_obj = Cache...
python
def set_cache( self, instance=None, translation=None, language=None, field_name=None, field_value=None, ): """ Add a new translation into the cache. """ if instance is not None and translation is not None: cached_obj = Cache...
[ "def", "set_cache", "(", "self", ",", "instance", "=", "None", ",", "translation", "=", "None", ",", "language", "=", "None", ",", "field_name", "=", "None", ",", "field_value", "=", "None", ",", ")", ":", "if", "instance", "is", "not", "None", "and", ...
Add a new translation into the cache.
[ "Add", "a", "new", "translation", "into", "the", "cache", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/fields/__init__.py#L198-L234
44,598
ulule/django-linguist
linguist/mixins.py
QuerySetMixin._filter_or_exclude
def _filter_or_exclude(self, negate, *args, **kwargs): """ Overrides default behavior to handle linguist fields. """ from .models import Translation new_args = self.get_cleaned_args(args) new_kwargs = self.get_cleaned_kwargs(kwargs) translation_args = self.get_t...
python
def _filter_or_exclude(self, negate, *args, **kwargs): """ Overrides default behavior to handle linguist fields. """ from .models import Translation new_args = self.get_cleaned_args(args) new_kwargs = self.get_cleaned_kwargs(kwargs) translation_args = self.get_t...
[ "def", "_filter_or_exclude", "(", "self", ",", "negate", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", ".", "models", "import", "Translation", "new_args", "=", "self", ".", "get_cleaned_args", "(", "args", ")", "new_kwargs", "=", "self", "...
Overrides default behavior to handle linguist fields.
[ "Overrides", "default", "behavior", "to", "handle", "linguist", "fields", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/mixins.py#L55-L91
44,599
ulule/django-linguist
linguist/mixins.py
QuerySetMixin.has_linguist_kwargs
def has_linguist_kwargs(self, kwargs): """ Parses the given kwargs and returns True if they contain linguist lookups. """ for k in kwargs: if self.is_linguist_lookup(k): return True return False
python
def has_linguist_kwargs(self, kwargs): """ Parses the given kwargs and returns True if they contain linguist lookups. """ for k in kwargs: if self.is_linguist_lookup(k): return True return False
[ "def", "has_linguist_kwargs", "(", "self", ",", "kwargs", ")", ":", "for", "k", "in", "kwargs", ":", "if", "self", ".", "is_linguist_lookup", "(", "k", ")", ":", "return", "True", "return", "False" ]
Parses the given kwargs and returns True if they contain linguist lookups.
[ "Parses", "the", "given", "kwargs", "and", "returns", "True", "if", "they", "contain", "linguist", "lookups", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/mixins.py#L144-L152