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
7,400
pyroscope/pyrocore
src/pyrocore/torrent/engine.py
TorrentView._fetch_items
def _fetch_items(self): """ Fetch to attribute. """ if self._items is None: self._items = list(self.engine.items(self)) return self._items
python
def _fetch_items(self): """ Fetch to attribute. """ if self._items is None: self._items = list(self.engine.items(self)) return self._items
[ "def", "_fetch_items", "(", "self", ")", ":", "if", "self", ".", "_items", "is", "None", ":", "self", ".", "_items", "=", "list", "(", "self", ".", "engine", ".", "items", "(", "self", ")", ")", "return", "self", ".", "_items" ]
Fetch to attribute.
[ "Fetch", "to", "attribute", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/engine.py#L605-L611
7,401
pyroscope/pyrocore
src/pyrocore/torrent/engine.py
TorrentView._check_hash_view
def _check_hash_view(self): """ Return infohash if view name refers to a single item, else None. """ infohash = None if self.viewname.startswith('#'): infohash = self.viewname[1:] elif len(self.viewname) == 40: try: int(self.viewname, 16) ...
python
def _check_hash_view(self): """ Return infohash if view name refers to a single item, else None. """ infohash = None if self.viewname.startswith('#'): infohash = self.viewname[1:] elif len(self.viewname) == 40: try: int(self.viewname, 16) ...
[ "def", "_check_hash_view", "(", "self", ")", ":", "infohash", "=", "None", "if", "self", ".", "viewname", ".", "startswith", "(", "'#'", ")", ":", "infohash", "=", "self", ".", "viewname", "[", "1", ":", "]", "elif", "len", "(", "self", ".", "viewnam...
Return infohash if view name refers to a single item, else None.
[ "Return", "infohash", "if", "view", "name", "refers", "to", "a", "single", "item", "else", "None", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/engine.py#L614-L627
7,402
pyroscope/pyrocore
src/pyrocore/torrent/engine.py
TorrentView.size
def size(self): """ Total unfiltered size of view. """ #return len(self._fetch_items()) if self._check_hash_view(): return 1 else: return self.engine.open().view.size(xmlrpc.NOHASH, self.viewname)
python
def size(self): """ Total unfiltered size of view. """ #return len(self._fetch_items()) if self._check_hash_view(): return 1 else: return self.engine.open().view.size(xmlrpc.NOHASH, self.viewname)
[ "def", "size", "(", "self", ")", ":", "#return len(self._fetch_items())", "if", "self", ".", "_check_hash_view", "(", ")", ":", "return", "1", "else", ":", "return", "self", ".", "engine", ".", "open", "(", ")", ".", "view", ".", "size", "(", "xmlrpc", ...
Total unfiltered size of view.
[ "Total", "unfiltered", "size", "of", "view", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/engine.py#L630-L637
7,403
pyroscope/pyrocore
src/pyrocore/torrent/engine.py
TorrentEngine.group_by
def group_by(self, fields, items=None): """ Returns a dict of lists of items, grouped by the given fields. ``fields`` can be a string (one field) or an iterable of field names. """ result = defaultdict(list) if items is None: items = self.items() try: ...
python
def group_by(self, fields, items=None): """ Returns a dict of lists of items, grouped by the given fields. ``fields`` can be a string (one field) or an iterable of field names. """ result = defaultdict(list) if items is None: items = self.items() try: ...
[ "def", "group_by", "(", "self", ",", "fields", ",", "items", "=", "None", ")", ":", "result", "=", "defaultdict", "(", "list", ")", "if", "items", "is", "None", ":", "items", "=", "self", ".", "items", "(", ")", "try", ":", "key", "=", "operator", ...
Returns a dict of lists of items, grouped by the given fields. ``fields`` can be a string (one field) or an iterable of field names.
[ "Returns", "a", "dict", "of", "lists", "of", "items", "grouped", "by", "the", "given", "fields", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/engine.py#L700-L719
7,404
pyroscope/pyrocore
src/pyrocore/util/xmlrpc.py
RTorrentProxy._set_mappings
def _set_mappings(self): """ Set command mappings according to rTorrent version. """ try: self._versions = (self.system.client_version(), self.system.library_version(),) self._version_info = tuple(int(i) for i in self._versions[0].split('.')) self._use_depreca...
python
def _set_mappings(self): """ Set command mappings according to rTorrent version. """ try: self._versions = (self.system.client_version(), self.system.library_version(),) self._version_info = tuple(int(i) for i in self._versions[0].split('.')) self._use_depreca...
[ "def", "_set_mappings", "(", "self", ")", ":", "try", ":", "self", ".", "_versions", "=", "(", "self", ".", "system", ".", "client_version", "(", ")", ",", "self", ".", "system", ".", "library_version", "(", ")", ",", ")", "self", ".", "_version_info",...
Set command mappings according to rTorrent version.
[ "Set", "command", "mappings", "according", "to", "rTorrent", "version", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/xmlrpc.py#L241-L261
7,405
pyroscope/pyrocore
src/pyrocore/util/xmlrpc.py
RTorrentProxy._fix_mappings
def _fix_mappings(self): """ Add computed stuff to mappings. """ self._mapping.update((key+'=', val+'=') for key, val in self._mapping.items() if not key.endswith('=')) if config.debug: self.LOG.debug("CMD MAPPINGS ARE: %r" % (self._mapping,))
python
def _fix_mappings(self): """ Add computed stuff to mappings. """ self._mapping.update((key+'=', val+'=') for key, val in self._mapping.items() if not key.endswith('=')) if config.debug: self.LOG.debug("CMD MAPPINGS ARE: %r" % (self._mapping,))
[ "def", "_fix_mappings", "(", "self", ")", ":", "self", ".", "_mapping", ".", "update", "(", "(", "key", "+", "'='", ",", "val", "+", "'='", ")", "for", "key", ",", "val", "in", "self", ".", "_mapping", ".", "items", "(", ")", "if", "not", "key", ...
Add computed stuff to mappings.
[ "Add", "computed", "stuff", "to", "mappings", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/xmlrpc.py#L264-L270
7,406
pyroscope/pyrocore
src/pyrocore/util/xmlrpc.py
RTorrentProxy._map_call
def _map_call(self, cmd): """ Map old to new command names. """ if config.debug and cmd != self._mapping.get(cmd, cmd): self.LOG.debug("MAP %s ==> %s" % (cmd, self._mapping[cmd])) cmd = self._mapping.get(cmd, cmd) # These we do by code, to avoid lengthy lists in the ...
python
def _map_call(self, cmd): """ Map old to new command names. """ if config.debug and cmd != self._mapping.get(cmd, cmd): self.LOG.debug("MAP %s ==> %s" % (cmd, self._mapping[cmd])) cmd = self._mapping.get(cmd, cmd) # These we do by code, to avoid lengthy lists in the ...
[ "def", "_map_call", "(", "self", ",", "cmd", ")", ":", "if", "config", ".", "debug", "and", "cmd", "!=", "self", ".", "_mapping", ".", "get", "(", "cmd", ",", "cmd", ")", ":", "self", ".", "LOG", ".", "debug", "(", "\"MAP %s ==> %s\"", "%", "(", ...
Map old to new command names.
[ "Map", "old", "to", "new", "command", "names", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/xmlrpc.py#L273-L284
7,407
pyroscope/pyrocore
src/pyrocore/torrent/watch.py
MetafileHandler.parse
def parse(self): """ Parse metafile and check pre-conditions. """ try: if not os.path.getsize(self.ns.pathname): # Ignore 0-byte dummy files (Firefox creates these while downloading) self.job.LOG.warn("Ignoring 0-byte metafile '%s'" % (self.ns.pathname...
python
def parse(self): """ Parse metafile and check pre-conditions. """ try: if not os.path.getsize(self.ns.pathname): # Ignore 0-byte dummy files (Firefox creates these while downloading) self.job.LOG.warn("Ignoring 0-byte metafile '%s'" % (self.ns.pathname...
[ "def", "parse", "(", "self", ")", ":", "try", ":", "if", "not", "os", ".", "path", ".", "getsize", "(", "self", ".", "ns", ".", "pathname", ")", ":", "# Ignore 0-byte dummy files (Firefox creates these while downloading)", "self", ".", "job", ".", "LOG", "."...
Parse metafile and check pre-conditions.
[ "Parse", "metafile", "and", "check", "pre", "-", "conditions", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/watch.py#L59-L94
7,408
pyroscope/pyrocore
src/pyrocore/torrent/watch.py
MetafileHandler.addinfo
def addinfo(self): """ Add known facts to templating namespace. """ # Basic values self.ns.watch_path = self.job.config.path self.ns.relpath = None for watch in self.job.config.path: if self.ns.pathname.startswith(watch.rstrip('/') + '/'): self...
python
def addinfo(self): """ Add known facts to templating namespace. """ # Basic values self.ns.watch_path = self.job.config.path self.ns.relpath = None for watch in self.job.config.path: if self.ns.pathname.startswith(watch.rstrip('/') + '/'): self...
[ "def", "addinfo", "(", "self", ")", ":", "# Basic values", "self", ".", "ns", ".", "watch_path", "=", "self", ".", "job", ".", "config", ".", "path", "self", ".", "ns", ".", "relpath", "=", "None", "for", "watch", "in", "self", ".", "job", ".", "co...
Add known facts to templating namespace.
[ "Add", "known", "facts", "to", "templating", "namespace", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/watch.py#L97-L137
7,409
pyroscope/pyrocore
src/pyrocore/torrent/watch.py
MetafileHandler.load
def load(self): """ Load metafile into client. """ if not self.ns.info_hash and not self.parse(): return self.addinfo() # TODO: dry_run try: # TODO: Scrub metafile if requested # Determine target state start_it = self.job...
python
def load(self): """ Load metafile into client. """ if not self.ns.info_hash and not self.parse(): return self.addinfo() # TODO: dry_run try: # TODO: Scrub metafile if requested # Determine target state start_it = self.job...
[ "def", "load", "(", "self", ")", ":", "if", "not", "self", ".", "ns", ".", "info_hash", "and", "not", "self", ".", "parse", "(", ")", ":", "return", "self", ".", "addinfo", "(", ")", "# TODO: dry_run", "try", ":", "# TODO: Scrub metafile if requested", "...
Load metafile into client.
[ "Load", "metafile", "into", "client", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/watch.py#L140-L199
7,410
pyroscope/pyrocore
src/pyrocore/torrent/watch.py
TreeWatchHandler.handle_path
def handle_path(self, event): """ Handle a path-related event. """ self.job.LOG.debug("Notification %r" % event) if event.dir: return if any(event.pathname.endswith(i) for i in self.METAFILE_EXT): MetafileHandler(self.job, event.pathname).handle() ...
python
def handle_path(self, event): """ Handle a path-related event. """ self.job.LOG.debug("Notification %r" % event) if event.dir: return if any(event.pathname.endswith(i) for i in self.METAFILE_EXT): MetafileHandler(self.job, event.pathname).handle() ...
[ "def", "handle_path", "(", "self", ",", "event", ")", ":", "self", ".", "job", ".", "LOG", ".", "debug", "(", "\"Notification %r\"", "%", "event", ")", "if", "event", ".", "dir", ":", "return", "if", "any", "(", "event", ".", "pathname", ".", "endswi...
Handle a path-related event.
[ "Handle", "a", "path", "-", "related", "event", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/watch.py#L243-L253
7,411
pyroscope/pyrocore
src/pyrocore/torrent/watch.py
TreeWatch.setup
def setup(self): """ Set up inotify manager. See https://github.com/seb-m/pyinotify/. """ if not pyinotify.WatchManager: raise error.UserError("You need to install 'pyinotify' to use %s (%s)!" % ( self.__class__.__name__, pyinotify._import_error)) # pylin...
python
def setup(self): """ Set up inotify manager. See https://github.com/seb-m/pyinotify/. """ if not pyinotify.WatchManager: raise error.UserError("You need to install 'pyinotify' to use %s (%s)!" % ( self.__class__.__name__, pyinotify._import_error)) # pylin...
[ "def", "setup", "(", "self", ")", ":", "if", "not", "pyinotify", ".", "WatchManager", ":", "raise", "error", ".", "UserError", "(", "\"You need to install 'pyinotify' to use %s (%s)!\"", "%", "(", "self", ".", "__class__", ".", "__name__", ",", "pyinotify", ".",...
Set up inotify manager. See https://github.com/seb-m/pyinotify/.
[ "Set", "up", "inotify", "manager", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/watch.py#L332-L352
7,412
pyroscope/pyrocore
src/pyrocore/util/traits.py
get_filetypes
def get_filetypes(filelist, path=None, size=os.path.getsize): """ Get a sorted list of file types and their weight in percent from an iterable of file names. @return: List of weighted file extensions (no '.'), sorted in descending order @rtype: list of (weight, filetype) """ path = ...
python
def get_filetypes(filelist, path=None, size=os.path.getsize): """ Get a sorted list of file types and their weight in percent from an iterable of file names. @return: List of weighted file extensions (no '.'), sorted in descending order @rtype: list of (weight, filetype) """ path = ...
[ "def", "get_filetypes", "(", "filelist", ",", "path", "=", "None", ",", "size", "=", "os", ".", "path", ".", "getsize", ")", ":", "path", "=", "path", "or", "(", "lambda", "_", ":", "_", ")", "# Get total size for each file extension", "histo", "=", "def...
Get a sorted list of file types and their weight in percent from an iterable of file names. @return: List of weighted file extensions (no '.'), sorted in descending order @rtype: list of (weight, filetype)
[ "Get", "a", "sorted", "list", "of", "file", "types", "and", "their", "weight", "in", "percent", "from", "an", "iterable", "of", "file", "names", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/traits.py#L127-L154
7,413
pyroscope/pyrocore
src/pyrocore/util/traits.py
name_trait
def name_trait(name, add_info=False): """ Determine content type from name. """ kind, info = None, {} # Anything to check against? if name and not name.startswith("VTS_"): lower_name = name.lower() trait_patterns = (("tv", TV_PATTERNS, "show"), ("movie", MOVIE_PATTERNS, "title")) ...
python
def name_trait(name, add_info=False): """ Determine content type from name. """ kind, info = None, {} # Anything to check against? if name and not name.startswith("VTS_"): lower_name = name.lower() trait_patterns = (("tv", TV_PATTERNS, "show"), ("movie", MOVIE_PATTERNS, "title")) ...
[ "def", "name_trait", "(", "name", ",", "add_info", "=", "False", ")", ":", "kind", ",", "info", "=", "None", ",", "{", "}", "# Anything to check against?", "if", "name", "and", "not", "name", ".", "startswith", "(", "\"VTS_\"", ")", ":", "lower_name", "=...
Determine content type from name.
[ "Determine", "content", "type", "from", "name", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/traits.py#L157-L201
7,414
pyroscope/pyrocore
src/pyrocore/util/traits.py
detect_traits
def detect_traits(name=None, alias=None, filetype=None): """ Build traits list from passed attributes. The result is a list of hierarchical classifiers, the top-level consisting of "audio", "movie", "tv", "video", "document", etc. It can be used as a part of completion paths to build direct...
python
def detect_traits(name=None, alias=None, filetype=None): """ Build traits list from passed attributes. The result is a list of hierarchical classifiers, the top-level consisting of "audio", "movie", "tv", "video", "document", etc. It can be used as a part of completion paths to build direct...
[ "def", "detect_traits", "(", "name", "=", "None", ",", "alias", "=", "None", ",", "filetype", "=", "None", ")", ":", "result", "=", "[", "]", "if", "filetype", ":", "filetype", "=", "filetype", ".", "lstrip", "(", "'.'", ")", "# Check for \"themed\" trac...
Build traits list from passed attributes. The result is a list of hierarchical classifiers, the top-level consisting of "audio", "movie", "tv", "video", "document", etc. It can be used as a part of completion paths to build directory structures.
[ "Build", "traits", "list", "from", "passed", "attributes", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/traits.py#L204-L241
7,415
pyroscope/pyrocore
src/pyrocore/util/metafile.py
console_progress
def console_progress(): """ Return a progress indicator for consoles if stdout is a tty. """ def progress(totalhashed, totalsize): "Helper" msg = " " * 30 if totalhashed < totalsize: msg = "%5.1f%% complete" % (totalhashed * 100.0 / totalsize) sys.stdout.w...
python
def console_progress(): """ Return a progress indicator for consoles if stdout is a tty. """ def progress(totalhashed, totalsize): "Helper" msg = " " * 30 if totalhashed < totalsize: msg = "%5.1f%% complete" % (totalhashed * 100.0 / totalsize) sys.stdout.w...
[ "def", "console_progress", "(", ")", ":", "def", "progress", "(", "totalhashed", ",", "totalsize", ")", ":", "\"Helper\"", "msg", "=", "\" \"", "*", "30", "if", "totalhashed", "<", "totalsize", ":", "msg", "=", "\"%5.1f%% complete\"", "%", "(", "totalhashed"...
Return a progress indicator for consoles if stdout is a tty.
[ "Return", "a", "progress", "indicator", "for", "consoles", "if", "stdout", "is", "a", "tty", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L74-L89
7,416
pyroscope/pyrocore
src/pyrocore/util/metafile.py
check_info
def check_info(info): """ Validate info dict. Raise ValueError if validation fails. """ if not isinstance(info, dict): raise ValueError("bad metainfo - not a dictionary") pieces = info.get("pieces") if not isinstance(pieces, basestring) or len(pieces) % 20 != 0: raise Value...
python
def check_info(info): """ Validate info dict. Raise ValueError if validation fails. """ if not isinstance(info, dict): raise ValueError("bad metainfo - not a dictionary") pieces = info.get("pieces") if not isinstance(pieces, basestring) or len(pieces) % 20 != 0: raise Value...
[ "def", "check_info", "(", "info", ")", ":", "if", "not", "isinstance", "(", "info", ",", "dict", ")", ":", "raise", "ValueError", "(", "\"bad metainfo - not a dictionary\"", ")", "pieces", "=", "info", ".", "get", "(", "\"pieces\"", ")", "if", "not", "isin...
Validate info dict. Raise ValueError if validation fails.
[ "Validate", "info", "dict", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L112-L171
7,417
pyroscope/pyrocore
src/pyrocore/util/metafile.py
check_meta
def check_meta(meta): """ Validate meta dict. Raise ValueError if validation fails. """ if not isinstance(meta, dict): raise ValueError("bad metadata - not a dictionary") if not isinstance(meta.get("announce"), basestring): raise ValueError("bad announce URL - not a string") ...
python
def check_meta(meta): """ Validate meta dict. Raise ValueError if validation fails. """ if not isinstance(meta, dict): raise ValueError("bad metadata - not a dictionary") if not isinstance(meta.get("announce"), basestring): raise ValueError("bad announce URL - not a string") ...
[ "def", "check_meta", "(", "meta", ")", ":", "if", "not", "isinstance", "(", "meta", ",", "dict", ")", ":", "raise", "ValueError", "(", "\"bad metadata - not a dictionary\"", ")", "if", "not", "isinstance", "(", "meta", ".", "get", "(", "\"announce\"", ")", ...
Validate meta dict. Raise ValueError if validation fails.
[ "Validate", "meta", "dict", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L174-L185
7,418
pyroscope/pyrocore
src/pyrocore/util/metafile.py
clean_meta
def clean_meta(meta, including_info=False, logger=None): """ Clean meta dict. Optionally log changes using the given logger. @param logger: If given, a callable accepting a string message. @return: Set of keys removed from C{meta}. """ modified = set() for key in meta.keys(): i...
python
def clean_meta(meta, including_info=False, logger=None): """ Clean meta dict. Optionally log changes using the given logger. @param logger: If given, a callable accepting a string message. @return: Set of keys removed from C{meta}. """ modified = set() for key in meta.keys(): i...
[ "def", "clean_meta", "(", "meta", ",", "including_info", "=", "False", ",", "logger", "=", "None", ")", ":", "modified", "=", "set", "(", ")", "for", "key", "in", "meta", ".", "keys", "(", ")", ":", "if", "[", "key", "]", "not", "in", "METAFILE_STD...
Clean meta dict. Optionally log changes using the given logger. @param logger: If given, a callable accepting a string message. @return: Set of keys removed from C{meta}.
[ "Clean", "meta", "dict", ".", "Optionally", "log", "changes", "using", "the", "given", "logger", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L188-L222
7,419
pyroscope/pyrocore
src/pyrocore/util/metafile.py
sanitize
def sanitize(meta, diagnostics=False): """ Try to fix common problems, especially transcode non-standard string encodings. """ bad_encodings, bad_fields = set(), set() def sane_encoding(field, text): "Transcoding helper." for encoding in ('utf-8', meta.get('encoding', None), 'cp1252'): ...
python
def sanitize(meta, diagnostics=False): """ Try to fix common problems, especially transcode non-standard string encodings. """ bad_encodings, bad_fields = set(), set() def sane_encoding(field, text): "Transcoding helper." for encoding in ('utf-8', meta.get('encoding', None), 'cp1252'): ...
[ "def", "sanitize", "(", "meta", ",", "diagnostics", "=", "False", ")", ":", "bad_encodings", ",", "bad_fields", "=", "set", "(", ")", ",", "set", "(", ")", "def", "sane_encoding", "(", "field", ",", "text", ")", ":", "\"Transcoding helper.\"", "for", "en...
Try to fix common problems, especially transcode non-standard string encodings.
[ "Try", "to", "fix", "common", "problems", "especially", "transcode", "non", "-", "standard", "string", "encodings", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L225-L258
7,420
pyroscope/pyrocore
src/pyrocore/util/metafile.py
add_fast_resume
def add_fast_resume(meta, datapath): """ Add fast resume data to a metafile dict. """ # Get list of files files = meta["info"].get("files", None) single = files is None if single: if os.path.isdir(datapath): datapath = os.path.join(datapath, meta["info"]["name"]) file...
python
def add_fast_resume(meta, datapath): """ Add fast resume data to a metafile dict. """ # Get list of files files = meta["info"].get("files", None) single = files is None if single: if os.path.isdir(datapath): datapath = os.path.join(datapath, meta["info"]["name"]) file...
[ "def", "add_fast_resume", "(", "meta", ",", "datapath", ")", ":", "# Get list of files", "files", "=", "meta", "[", "\"info\"", "]", ".", "get", "(", "\"files\"", ",", "None", ")", "single", "=", "files", "is", "None", "if", "single", ":", "if", "os", ...
Add fast resume data to a metafile dict.
[ "Add", "fast", "resume", "data", "to", "a", "metafile", "dict", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L301-L343
7,421
pyroscope/pyrocore
src/pyrocore/util/metafile.py
data_size
def data_size(metadata): """ Calculate the size of a torrent based on parsed metadata. """ info = metadata['info'] if 'length' in info: # Single file total_size = info['length'] else: # Directory structure total_size = sum([f['length'] for f in info['files']]) r...
python
def data_size(metadata): """ Calculate the size of a torrent based on parsed metadata. """ info = metadata['info'] if 'length' in info: # Single file total_size = info['length'] else: # Directory structure total_size = sum([f['length'] for f in info['files']]) r...
[ "def", "data_size", "(", "metadata", ")", ":", "info", "=", "metadata", "[", "'info'", "]", "if", "'length'", "in", "info", ":", "# Single file", "total_size", "=", "info", "[", "'length'", "]", "else", ":", "# Directory structure", "total_size", "=", "sum",...
Calculate the size of a torrent based on parsed metadata.
[ "Calculate", "the", "size", "of", "a", "torrent", "based", "on", "parsed", "metadata", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L352-L364
7,422
pyroscope/pyrocore
src/pyrocore/util/metafile.py
checked_open
def checked_open(filename, log=None, quiet=False): """ Open and validate the given metafile. Optionally provide diagnostics on the passed logger, for invalid metafiles, which then just cause a warning but no exception. "quiet" can supress that warning. """ with open(filename, "rb") a...
python
def checked_open(filename, log=None, quiet=False): """ Open and validate the given metafile. Optionally provide diagnostics on the passed logger, for invalid metafiles, which then just cause a warning but no exception. "quiet" can supress that warning. """ with open(filename, "rb") a...
[ "def", "checked_open", "(", "filename", ",", "log", "=", "None", ",", "quiet", "=", "False", ")", ":", "with", "open", "(", "filename", ",", "\"rb\"", ")", "as", "handle", ":", "raw_data", "=", "handle", ".", "read", "(", ")", "data", "=", "bencode",...
Open and validate the given metafile. Optionally provide diagnostics on the passed logger, for invalid metafiles, which then just cause a warning but no exception. "quiet" can supress that warning.
[ "Open", "and", "validate", "the", "given", "metafile", ".", "Optionally", "provide", "diagnostics", "on", "the", "passed", "logger", "for", "invalid", "metafiles", "which", "then", "just", "cause", "a", "warning", "but", "no", "exception", ".", "quiet", "can",...
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L367-L389
7,423
pyroscope/pyrocore
src/pyrocore/util/metafile.py
MaskingPrettyPrinter.format
def format(self, obj, context, maxlevels, level): # pylint: disable=arguments-differ """ Mask obj if it looks like an URL, then pass it to the super class. """ if isinstance(obj, basestring) and "://" in fmt.to_unicode(obj): obj = mask_keys(obj) return pprint.PrettyPrinter.f...
python
def format(self, obj, context, maxlevels, level): # pylint: disable=arguments-differ """ Mask obj if it looks like an URL, then pass it to the super class. """ if isinstance(obj, basestring) and "://" in fmt.to_unicode(obj): obj = mask_keys(obj) return pprint.PrettyPrinter.f...
[ "def", "format", "(", "self", ",", "obj", ",", "context", ",", "maxlevels", ",", "level", ")", ":", "# pylint: disable=arguments-differ", "if", "isinstance", "(", "obj", ",", "basestring", ")", "and", "\"://\"", "in", "fmt", ".", "to_unicode", "(", "obj", ...
Mask obj if it looks like an URL, then pass it to the super class.
[ "Mask", "obj", "if", "it", "looks", "like", "an", "URL", "then", "pass", "it", "to", "the", "super", "class", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L104-L109
7,424
pyroscope/pyrocore
src/pyrocore/util/metafile.py
Metafile._get_datapath
def _get_datapath(self): """ Get a valid datapath, else raise an exception. """ if self._datapath is None: raise OSError(errno.ENOENT, "You didn't provide any datapath for %r" % self.filename) return self._datapath
python
def _get_datapath(self): """ Get a valid datapath, else raise an exception. """ if self._datapath is None: raise OSError(errno.ENOENT, "You didn't provide any datapath for %r" % self.filename) return self._datapath
[ "def", "_get_datapath", "(", "self", ")", ":", "if", "self", ".", "_datapath", "is", "None", ":", "raise", "OSError", "(", "errno", ".", "ENOENT", ",", "\"You didn't provide any datapath for %r\"", "%", "self", ".", "filename", ")", "return", "self", ".", "_...
Get a valid datapath, else raise an exception.
[ "Get", "a", "valid", "datapath", "else", "raise", "an", "exception", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L413-L419
7,425
pyroscope/pyrocore
src/pyrocore/util/metafile.py
Metafile._set_datapath
def _set_datapath(self, datapath): """ Set a datapath. """ if datapath: self._datapath = datapath.rstrip(os.sep) self._fifo = int(stat.S_ISFIFO(os.stat(self.datapath).st_mode)) else: self._datapath = None self._fifo = False
python
def _set_datapath(self, datapath): """ Set a datapath. """ if datapath: self._datapath = datapath.rstrip(os.sep) self._fifo = int(stat.S_ISFIFO(os.stat(self.datapath).st_mode)) else: self._datapath = None self._fifo = False
[ "def", "_set_datapath", "(", "self", ",", "datapath", ")", ":", "if", "datapath", ":", "self", ".", "_datapath", "=", "datapath", ".", "rstrip", "(", "os", ".", "sep", ")", "self", ".", "_fifo", "=", "int", "(", "stat", ".", "S_ISFIFO", "(", "os", ...
Set a datapath.
[ "Set", "a", "datapath", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L421-L429
7,426
pyroscope/pyrocore
src/pyrocore/util/metafile.py
Metafile.walk
def walk(self): """ Generate paths in "self.datapath". """ # FIFO? if self._fifo: if self._fifo > 1: raise RuntimeError("INTERNAL ERROR: FIFO read twice!") self._fifo += 1 # Read paths relative to directory containing the FIFO ...
python
def walk(self): """ Generate paths in "self.datapath". """ # FIFO? if self._fifo: if self._fifo > 1: raise RuntimeError("INTERNAL ERROR: FIFO read twice!") self._fifo += 1 # Read paths relative to directory containing the FIFO ...
[ "def", "walk", "(", "self", ")", ":", "# FIFO?", "if", "self", ".", "_fifo", ":", "if", "self", ".", "_fifo", ">", "1", ":", "raise", "RuntimeError", "(", "\"INTERNAL ERROR: FIFO read twice!\"", ")", "self", ".", "_fifo", "+=", "1", "# Read paths relative to...
Generate paths in "self.datapath".
[ "Generate", "paths", "in", "self", ".", "datapath", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L434-L472
7,427
pyroscope/pyrocore
src/pyrocore/util/metafile.py
Metafile._calc_size
def _calc_size(self): """ Get total size of "self.datapath". """ return sum(os.path.getsize(filename) for filename in self.walk() )
python
def _calc_size(self): """ Get total size of "self.datapath". """ return sum(os.path.getsize(filename) for filename in self.walk() )
[ "def", "_calc_size", "(", "self", ")", ":", "return", "sum", "(", "os", ".", "path", ".", "getsize", "(", "filename", ")", "for", "filename", "in", "self", ".", "walk", "(", ")", ")" ]
Get total size of "self.datapath".
[ "Get", "total", "size", "of", "self", ".", "datapath", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L475-L480
7,428
pyroscope/pyrocore
src/pyrocore/util/metafile.py
Metafile._make_info
def _make_info(self, piece_size, progress, walker, piece_callback=None): """ Create info dict. """ # These collect the file descriptions and piece hashes file_list = [] pieces = [] # Initialize progress state hashing_secs = time.time() totalsize = -1 if s...
python
def _make_info(self, piece_size, progress, walker, piece_callback=None): """ Create info dict. """ # These collect the file descriptions and piece hashes file_list = [] pieces = [] # Initialize progress state hashing_secs = time.time() totalsize = -1 if s...
[ "def", "_make_info", "(", "self", ",", "piece_size", ",", "progress", ",", "walker", ",", "piece_callback", "=", "None", ")", ":", "# These collect the file descriptions and piece hashes", "file_list", "=", "[", "]", "pieces", "=", "[", "]", "# Initialize progress s...
Create info dict.
[ "Create", "info", "dict", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L483-L564
7,429
pyroscope/pyrocore
src/pyrocore/util/metafile.py
Metafile._make_meta
def _make_meta(self, tracker_url, root_name, private, progress): """ Create torrent dict. """ # Calculate piece size if self._fifo: # TODO we need to add a (command line) param, probably for total data size # for now, always 1MB piece_size_exp = 20 ...
python
def _make_meta(self, tracker_url, root_name, private, progress): """ Create torrent dict. """ # Calculate piece size if self._fifo: # TODO we need to add a (command line) param, probably for total data size # for now, always 1MB piece_size_exp = 20 ...
[ "def", "_make_meta", "(", "self", ",", "tracker_url", ",", "root_name", ",", "private", ",", "progress", ")", ":", "# Calculate piece size", "if", "self", ".", "_fifo", ":", "# TODO we need to add a (command line) param, probably for total data size", "# for now, always 1MB...
Create torrent dict.
[ "Create", "torrent", "dict", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L567-L608
7,430
pyroscope/pyrocore
src/pyrocore/util/metafile.py
Metafile.check
def check(self, metainfo, datapath, progress=None): """ Check piece hashes of a metafile against the given datapath. """ if datapath: self.datapath = datapath def check_piece(filename, piece): "Callback for new piece" if piece != metainfo["info"]["pie...
python
def check(self, metainfo, datapath, progress=None): """ Check piece hashes of a metafile against the given datapath. """ if datapath: self.datapath = datapath def check_piece(filename, piece): "Callback for new piece" if piece != metainfo["info"]["pie...
[ "def", "check", "(", "self", ",", "metainfo", ",", "datapath", ",", "progress", "=", "None", ")", ":", "if", "datapath", ":", "self", ".", "datapath", "=", "datapath", "def", "check_piece", "(", "filename", ",", "piece", ")", ":", "\"Callback for new piece...
Check piece hashes of a metafile against the given datapath.
[ "Check", "piece", "hashes", "of", "a", "metafile", "against", "the", "given", "datapath", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/metafile.py#L674-L692
7,431
pyroscope/pyrocore
src/pyrocore/torrent/queue.py
QueueManager._start
def _start(self, items): """ Start some items if conditions are met. """ # TODO: Filter by a custom date field, for scheduled downloads starting at a certain time, or after a given delay # TODO: Don't start anything more if download BW is used >= config threshold in % # Check i...
python
def _start(self, items): """ Start some items if conditions are met. """ # TODO: Filter by a custom date field, for scheduled downloads starting at a certain time, or after a given delay # TODO: Don't start anything more if download BW is used >= config threshold in % # Check i...
[ "def", "_start", "(", "self", ",", "items", ")", ":", "# TODO: Filter by a custom date field, for scheduled downloads starting at a certain time, or after a given delay", "# TODO: Don't start anything more if download BW is used >= config threshold in %", "# Check if anything more is ready to st...
Start some items if conditions are met.
[ "Start", "some", "items", "if", "conditions", "are", "met", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/queue.py#L63-L132
7,432
pyroscope/pyrocore
src/pyrocore/torrent/queue.py
QueueManager.run
def run(self): """ Queue manager job callback. """ try: self.proxy = config_ini.engine.open() # Get items from 'pyrotorque' view items = list(config_ini.engine.items(self.VIEWNAME, cache=False)) if self.sort_key: items.sort(key=se...
python
def run(self): """ Queue manager job callback. """ try: self.proxy = config_ini.engine.open() # Get items from 'pyrotorque' view items = list(config_ini.engine.items(self.VIEWNAME, cache=False)) if self.sort_key: items.sort(key=se...
[ "def", "run", "(", "self", ")", ":", "try", ":", "self", ".", "proxy", "=", "config_ini", ".", "engine", ".", "open", "(", ")", "# Get items from 'pyrotorque' view", "items", "=", "list", "(", "config_ini", ".", "engine", ".", "items", "(", "self", ".", ...
Queue manager job callback.
[ "Queue", "manager", "job", "callback", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/queue.py#L135-L153
7,433
pyroscope/pyrocore
src/pyrocore/scripts/rtcontrol.py
print_help_fields
def print_help_fields(): """ Print help about fields and field formatters. """ # Mock entries, so they fulfill the expectations towards a field definition def custom_manifold(): "named rTorrent custom attribute, e.g. 'custom_completion_target'" return ("custom_KEY", custom_manifold) ...
python
def print_help_fields(): """ Print help about fields and field formatters. """ # Mock entries, so they fulfill the expectations towards a field definition def custom_manifold(): "named rTorrent custom attribute, e.g. 'custom_completion_target'" return ("custom_KEY", custom_manifold) ...
[ "def", "print_help_fields", "(", ")", ":", "# Mock entries, so they fulfill the expectations towards a field definition", "def", "custom_manifold", "(", ")", ":", "\"named rTorrent custom attribute, e.g. 'custom_completion_target'\"", "return", "(", "\"custom_KEY\"", ",", "custom_man...
Print help about fields and field formatters.
[ "Print", "help", "about", "fields", "and", "field", "formatters", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/scripts/rtcontrol.py#L35-L61
7,434
pyroscope/pyrocore
src/pyrocore/scripts/rtcontrol.py
FieldStatistics.add
def add(self, field, val): "Add a sample" if engine.FieldDefinition.FIELDS[field]._matcher is matching.TimeFilter: val = self._basetime - val try: self.total[field] += val self.min[field] = min(self.min[field], val) if field in self.min else val s...
python
def add(self, field, val): "Add a sample" if engine.FieldDefinition.FIELDS[field]._matcher is matching.TimeFilter: val = self._basetime - val try: self.total[field] += val self.min[field] = min(self.min[field], val) if field in self.min else val s...
[ "def", "add", "(", "self", ",", "field", ",", "val", ")", ":", "if", "engine", ".", "FieldDefinition", ".", "FIELDS", "[", "field", "]", ".", "_matcher", "is", "matching", ".", "TimeFilter", ":", "val", "=", "self", ".", "_basetime", "-", "val", "try...
Add a sample
[ "Add", "a", "sample" ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/scripts/rtcontrol.py#L83-L93
7,435
pyroscope/pyrocore
src/pyrocore/scripts/rtcontrol.py
RtorrentControl.help_completion_fields
def help_completion_fields(self): """ Return valid field names. """ for name, field in sorted(engine.FieldDefinition.FIELDS.items()): if issubclass(field._matcher, matching.BoolFilter): yield "%s=no" % (name,) yield "%s=yes" % (name,) c...
python
def help_completion_fields(self): """ Return valid field names. """ for name, field in sorted(engine.FieldDefinition.FIELDS.items()): if issubclass(field._matcher, matching.BoolFilter): yield "%s=no" % (name,) yield "%s=yes" % (name,) c...
[ "def", "help_completion_fields", "(", "self", ")", ":", "for", "name", ",", "field", "in", "sorted", "(", "engine", ".", "FieldDefinition", ".", "FIELDS", ".", "items", "(", ")", ")", ":", "if", "issubclass", "(", "field", ".", "_matcher", ",", "matching...
Return valid field names.
[ "Return", "valid", "field", "names", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/scripts/rtcontrol.py#L309-L333
7,436
pyroscope/pyrocore
src/pyrocore/scripts/rtcontrol.py
RtorrentControl.format_item
def format_item(self, item, defaults=None, stencil=None): """ Format an item. """ from pyrobase.osutil import shell_escape try: item_text = fmt.to_console(formatting.format_item(self.options.output_format, item, defaults)) except (NameError, ValueError, TypeError), e...
python
def format_item(self, item, defaults=None, stencil=None): """ Format an item. """ from pyrobase.osutil import shell_escape try: item_text = fmt.to_console(formatting.format_item(self.options.output_format, item, defaults)) except (NameError, ValueError, TypeError), e...
[ "def", "format_item", "(", "self", ",", "item", ",", "defaults", "=", "None", ",", "stencil", "=", "None", ")", ":", "from", "pyrobase", ".", "osutil", "import", "shell_escape", "try", ":", "item_text", "=", "fmt", ".", "to_console", "(", "formatting", "...
Format an item.
[ "Format", "an", "item", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/scripts/rtcontrol.py#L337-L355
7,437
pyroscope/pyrocore
src/pyrocore/scripts/rtcontrol.py
RtorrentControl.emit
def emit(self, item, defaults=None, stencil=None, to_log=False, item_formatter=None): """ Print an item to stdout, or the log on INFO level. """ item_text = self.format_item(item, defaults, stencil) # Post-process line? if item_formatter: item_text = item_formatter(i...
python
def emit(self, item, defaults=None, stencil=None, to_log=False, item_formatter=None): """ Print an item to stdout, or the log on INFO level. """ item_text = self.format_item(item, defaults, stencil) # Post-process line? if item_formatter: item_text = item_formatter(i...
[ "def", "emit", "(", "self", ",", "item", ",", "defaults", "=", "None", ",", "stencil", "=", "None", ",", "to_log", "=", "False", ",", "item_formatter", "=", "None", ")", ":", "item_text", "=", "self", ".", "format_item", "(", "item", ",", "defaults", ...
Print an item to stdout, or the log on INFO level.
[ "Print", "an", "item", "to", "stdout", "or", "the", "log", "on", "INFO", "level", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/scripts/rtcontrol.py#L358-L383
7,438
pyroscope/pyrocore
src/pyrocore/scripts/rtcontrol.py
RtorrentControl.validate_output_format
def validate_output_format(self, default_format): """ Prepare output format for later use. """ output_format = self.options.output_format # Use default format if none is given if output_format is None: output_format = default_format # Check if it's a custom ...
python
def validate_output_format(self, default_format): """ Prepare output format for later use. """ output_format = self.options.output_format # Use default format if none is given if output_format is None: output_format = default_format # Check if it's a custom ...
[ "def", "validate_output_format", "(", "self", ",", "default_format", ")", ":", "output_format", "=", "self", ".", "options", ".", "output_format", "# Use default format if none is given", "if", "output_format", "is", "None", ":", "output_format", "=", "default_format", ...
Prepare output format for later use.
[ "Prepare", "output", "format", "for", "later", "use", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/scripts/rtcontrol.py#L387-L417
7,439
pyroscope/pyrocore
src/pyrocore/scripts/rtcontrol.py
RtorrentControl.get_output_fields
def get_output_fields(self): """ Get field names from output template. """ # Re-engineer list from output format # XXX TODO: Would be better to use a FieldRecorder class to catch the full field names emit_fields = list(i.lower() for i in re.sub(r"[^_A-Z]+", ' ', self.format_item(...
python
def get_output_fields(self): """ Get field names from output template. """ # Re-engineer list from output format # XXX TODO: Would be better to use a FieldRecorder class to catch the full field names emit_fields = list(i.lower() for i in re.sub(r"[^_A-Z]+", ' ', self.format_item(...
[ "def", "get_output_fields", "(", "self", ")", ":", "# Re-engineer list from output format", "# XXX TODO: Would be better to use a FieldRecorder class to catch the full field names", "emit_fields", "=", "list", "(", "i", ".", "lower", "(", ")", "for", "i", "in", "re", ".", ...
Get field names from output template.
[ "Get", "field", "names", "from", "output", "template", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/scripts/rtcontrol.py#L421-L436
7,440
pyroscope/pyrocore
src/pyrocore/scripts/rtcontrol.py
RtorrentControl.validate_sort_fields
def validate_sort_fields(self): """ Take care of sorting. """ sort_fields = ','.join(self.options.sort_fields) if sort_fields == '*': sort_fields = self.get_output_fields() return formatting.validate_sort_fields(sort_fields or config.sort_fields)
python
def validate_sort_fields(self): """ Take care of sorting. """ sort_fields = ','.join(self.options.sort_fields) if sort_fields == '*': sort_fields = self.get_output_fields() return formatting.validate_sort_fields(sort_fields or config.sort_fields)
[ "def", "validate_sort_fields", "(", "self", ")", ":", "sort_fields", "=", "','", ".", "join", "(", "self", ".", "options", ".", "sort_fields", ")", "if", "sort_fields", "==", "'*'", ":", "sort_fields", "=", "self", ".", "get_output_fields", "(", ")", "retu...
Take care of sorting.
[ "Take", "care", "of", "sorting", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/scripts/rtcontrol.py#L439-L446
7,441
pyroscope/pyrocore
src/pyrocore/scripts/rtcontrol.py
RtorrentControl.show_in_view
def show_in_view(self, sourceview, matches, targetname=None): """ Show search result in ncurses view. """ append = self.options.append_view or self.options.alter_view == 'append' remove = self.options.alter_view == 'remove' action_name = ', appending to' if append else ', removin...
python
def show_in_view(self, sourceview, matches, targetname=None): """ Show search result in ncurses view. """ append = self.options.append_view or self.options.alter_view == 'append' remove = self.options.alter_view == 'remove' action_name = ', appending to' if append else ', removin...
[ "def", "show_in_view", "(", "self", ",", "sourceview", ",", "matches", ",", "targetname", "=", "None", ")", ":", "append", "=", "self", ".", "options", ".", "append_view", "or", "self", ".", "options", ".", "alter_view", "==", "'append'", "remove", "=", ...
Show search result in ncurses view.
[ "Show", "search", "result", "in", "ncurses", "view", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/scripts/rtcontrol.py#L449-L461
7,442
pyroscope/pyrocore
docs/examples/rt-heatmap.py
HeatMap.heatmap
def heatmap(self, df, imagefile): """ Create the heat map. """ import seaborn as sns import matplotlib.ticker as tkr import matplotlib.pyplot as plt from matplotlib.colors import LinearSegmentedColormap sns.set() with sns.axes_style('whitegrid'): ...
python
def heatmap(self, df, imagefile): """ Create the heat map. """ import seaborn as sns import matplotlib.ticker as tkr import matplotlib.pyplot as plt from matplotlib.colors import LinearSegmentedColormap sns.set() with sns.axes_style('whitegrid'): ...
[ "def", "heatmap", "(", "self", ",", "df", ",", "imagefile", ")", ":", "import", "seaborn", "as", "sns", "import", "matplotlib", ".", "ticker", "as", "tkr", "import", "matplotlib", ".", "pyplot", "as", "plt", "from", "matplotlib", ".", "colors", "import", ...
Create the heat map.
[ "Create", "the", "heat", "map", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/docs/examples/rt-heatmap.py#L55-L81
7,443
pyroscope/pyrocore
src/pyrocore/ui/categories.py
CategoryManager.mainloop
def mainloop(self): """ Manage category views. """ # Get client state proxy = config.engine.open() views = [x for x in sorted(proxy.view.list()) if x.startswith(self.PREFIX)] current_view = real_current_view = proxy.ui.current_view() if current_view not in views:...
python
def mainloop(self): """ Manage category views. """ # Get client state proxy = config.engine.open() views = [x for x in sorted(proxy.view.list()) if x.startswith(self.PREFIX)] current_view = real_current_view = proxy.ui.current_view() if current_view not in views:...
[ "def", "mainloop", "(", "self", ")", ":", "# Get client state", "proxy", "=", "config", ".", "engine", ".", "open", "(", ")", "views", "=", "[", "x", "for", "x", "in", "sorted", "(", "proxy", ".", "view", ".", "list", "(", ")", ")", "if", "x", "....
Manage category views.
[ "Manage", "category", "views", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/ui/categories.py#L53-L91
7,444
pyroscope/pyrocore
src/pyrocore/data/config/config.py
_custom_fields
def _custom_fields(): """ Yield custom field definitions. """ # Import some commonly needed modules import os from pyrocore.torrent import engine, matching from pyrocore.util import fmt # PUT CUSTOM FIELD CODE HERE # Disk space check (as an example) # see https://pyrocore.readthedo...
python
def _custom_fields(): """ Yield custom field definitions. """ # Import some commonly needed modules import os from pyrocore.torrent import engine, matching from pyrocore.util import fmt # PUT CUSTOM FIELD CODE HERE # Disk space check (as an example) # see https://pyrocore.readthedo...
[ "def", "_custom_fields", "(", ")", ":", "# Import some commonly needed modules", "import", "os", "from", "pyrocore", ".", "torrent", "import", "engine", ",", "matching", "from", "pyrocore", ".", "util", "import", "fmt", "# PUT CUSTOM FIELD CODE HERE", "# Disk space chec...
Yield custom field definitions.
[ "Yield", "custom", "field", "definitions", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/data/config/config.py#L7-L35
7,445
pyroscope/pyrocore
src/pyrocore/util/stats.py
engine_data
def engine_data(engine): """ Get important performance data and metadata from rTorrent. """ views = ("default", "main", "started", "stopped", "complete", "incomplete", "seeding", "leeching", "active", "messages") methods = [ "throttle.global_up.rate", "throttle.global_up.max_rate", ...
python
def engine_data(engine): """ Get important performance data and metadata from rTorrent. """ views = ("default", "main", "started", "stopped", "complete", "incomplete", "seeding", "leeching", "active", "messages") methods = [ "throttle.global_up.rate", "throttle.global_up.max_rate", ...
[ "def", "engine_data", "(", "engine", ")", ":", "views", "=", "(", "\"default\"", ",", "\"main\"", ",", "\"started\"", ",", "\"stopped\"", ",", "\"complete\"", ",", "\"incomplete\"", ",", "\"seeding\"", ",", "\"leeching\"", ",", "\"active\"", ",", "\"messages\"",...
Get important performance data and metadata from rTorrent.
[ "Get", "important", "performance", "data", "and", "metadata", "from", "rTorrent", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/stats.py#L25-L54
7,446
pyroscope/pyrocore
src/pyrocore/util/osmagic.py
_write_pidfile
def _write_pidfile(pidfile): """ Write file with current process ID. """ pid = str(os.getpid()) handle = open(pidfile, 'w') try: handle.write("%s\n" % pid) finally: handle.close()
python
def _write_pidfile(pidfile): """ Write file with current process ID. """ pid = str(os.getpid()) handle = open(pidfile, 'w') try: handle.write("%s\n" % pid) finally: handle.close()
[ "def", "_write_pidfile", "(", "pidfile", ")", ":", "pid", "=", "str", "(", "os", ".", "getpid", "(", ")", ")", "handle", "=", "open", "(", "pidfile", ",", "'w'", ")", "try", ":", "handle", ".", "write", "(", "\"%s\\n\"", "%", "pid", ")", "finally",...
Write file with current process ID.
[ "Write", "file", "with", "current", "process", "ID", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/osmagic.py#L30-L38
7,447
pyroscope/pyrocore
src/pyrocore/util/osmagic.py
guard
def guard(pidfile, guardfile=None): """ Raise an EnvironmentError when the "guardfile" doesn't exist, or the process with the ID found in "pidfile" is still active. """ # Check guard if guardfile and not os.path.exists(guardfile): raise EnvironmentError("Guard file '%s' not found, won't ...
python
def guard(pidfile, guardfile=None): """ Raise an EnvironmentError when the "guardfile" doesn't exist, or the process with the ID found in "pidfile" is still active. """ # Check guard if guardfile and not os.path.exists(guardfile): raise EnvironmentError("Guard file '%s' not found, won't ...
[ "def", "guard", "(", "pidfile", ",", "guardfile", "=", "None", ")", ":", "# Check guard", "if", "guardfile", "and", "not", "os", ".", "path", ".", "exists", "(", "guardfile", ")", ":", "raise", "EnvironmentError", "(", "\"Guard file '%s' not found, won't start!\...
Raise an EnvironmentError when the "guardfile" doesn't exist, or the process with the ID found in "pidfile" is still active.
[ "Raise", "an", "EnvironmentError", "when", "the", "guardfile", "doesn", "t", "exist", "or", "the", "process", "with", "the", "ID", "found", "in", "pidfile", "is", "still", "active", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/osmagic.py#L70-L86
7,448
pyroscope/pyrocore
src/pyrocore/util/osmagic.py
daemonize
def daemonize(pidfile=None, logfile=None, sync=True): """ Fork the process into the background. @param pidfile: Optional PID file path. @param sync: Wait for parent process to disappear? @param logfile: Optional name of stdin/stderr log file or stream. """ log = logging.getLogger("d...
python
def daemonize(pidfile=None, logfile=None, sync=True): """ Fork the process into the background. @param pidfile: Optional PID file path. @param sync: Wait for parent process to disappear? @param logfile: Optional name of stdin/stderr log file or stream. """ log = logging.getLogger("d...
[ "def", "daemonize", "(", "pidfile", "=", "None", ",", "logfile", "=", "None", ",", "sync", "=", "True", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "\"daemonize\"", ")", "ppid", "=", "os", ".", "getpid", "(", ")", "try", ":", "pid", "="...
Fork the process into the background. @param pidfile: Optional PID file path. @param sync: Wait for parent process to disappear? @param logfile: Optional name of stdin/stderr log file or stream.
[ "Fork", "the", "process", "into", "the", "background", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/osmagic.py#L89-L158
7,449
pyroscope/pyrocore
src/pyrocore/util/algo.py
flatten
def flatten(nested, containers=(list, tuple)): """ Flatten a nested list in-place and return it. """ flat = list(nested) # handle iterators / generators i = 0 while i < len(flat): while isinstance(flat[i], containers): if not flat[i]: # kill empty list ...
python
def flatten(nested, containers=(list, tuple)): """ Flatten a nested list in-place and return it. """ flat = list(nested) # handle iterators / generators i = 0 while i < len(flat): while isinstance(flat[i], containers): if not flat[i]: # kill empty list ...
[ "def", "flatten", "(", "nested", ",", "containers", "=", "(", "list", ",", "tuple", ")", ")", ":", "flat", "=", "list", "(", "nested", ")", "# handle iterators / generators", "i", "=", "0", "while", "i", "<", "len", "(", "flat", ")", ":", "while", "i...
Flatten a nested list in-place and return it.
[ "Flatten", "a", "nested", "list", "in", "-", "place", "and", "return", "it", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/algo.py#L42-L62
7,450
pyroscope/pyrocore
pavement.py
gendocs
def gendocs(): "create some doc pages automatically" helppage = path("docs/references-cli-usage.rst") content = [ ".. automatically generated using 'paver gendocs'.", "", ".. contents::", " :local:", "", ".. note::", "", " The help output...
python
def gendocs(): "create some doc pages automatically" helppage = path("docs/references-cli-usage.rst") content = [ ".. automatically generated using 'paver gendocs'.", "", ".. contents::", " :local:", "", ".. note::", "", " The help output...
[ "def", "gendocs", "(", ")", ":", "helppage", "=", "path", "(", "\"docs/references-cli-usage.rst\"", ")", "content", "=", "[", "\".. automatically generated using 'paver gendocs'.\"", ",", "\"\"", ",", "\".. contents::\"", ",", "\" :local:\"", ",", "\"\"", ",", "\"....
create some doc pages automatically
[ "create", "some", "doc", "pages", "automatically" ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/pavement.py#L196-L237
7,451
pyroscope/pyrocore
pavement.py
watchdog_pid
def watchdog_pid(): """Get watchdog PID via ``netstat``.""" result = sh('netstat -tulpn 2>/dev/null | grep 127.0.0.1:{:d}' .format(SPHINX_AUTOBUILD_PORT), capture=True, ignore_error=True) pid = result.strip() pid = pid.split()[-1] if pid else None pid = pid.split('/', 1)[0] if pid an...
python
def watchdog_pid(): """Get watchdog PID via ``netstat``.""" result = sh('netstat -tulpn 2>/dev/null | grep 127.0.0.1:{:d}' .format(SPHINX_AUTOBUILD_PORT), capture=True, ignore_error=True) pid = result.strip() pid = pid.split()[-1] if pid else None pid = pid.split('/', 1)[0] if pid an...
[ "def", "watchdog_pid", "(", ")", ":", "result", "=", "sh", "(", "'netstat -tulpn 2>/dev/null | grep 127.0.0.1:{:d}'", ".", "format", "(", "SPHINX_AUTOBUILD_PORT", ")", ",", "capture", "=", "True", ",", "ignore_error", "=", "True", ")", "pid", "=", "result", ".",...
Get watchdog PID via ``netstat``.
[ "Get", "watchdog", "PID", "via", "netstat", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/pavement.py#L262-L270
7,452
pyroscope/pyrocore
pavement.py
autodocs
def autodocs(): "create Sphinx docs locally, and start a watchdog" build_dir = path('docs/_build') index_html = build_dir / 'html/index.html' if build_dir.exists(): build_dir.rmtree() with pushd("docs"): print "\n*** Generating API doc ***\n" sh("sphinx-apidoc -o apidoc -f -...
python
def autodocs(): "create Sphinx docs locally, and start a watchdog" build_dir = path('docs/_build') index_html = build_dir / 'html/index.html' if build_dir.exists(): build_dir.rmtree() with pushd("docs"): print "\n*** Generating API doc ***\n" sh("sphinx-apidoc -o apidoc -f -...
[ "def", "autodocs", "(", ")", ":", "build_dir", "=", "path", "(", "'docs/_build'", ")", "index_html", "=", "build_dir", "/", "'html/index.html'", "if", "build_dir", ".", "exists", "(", ")", ":", "build_dir", ".", "rmtree", "(", ")", "with", "pushd", "(", ...
create Sphinx docs locally, and start a watchdog
[ "create", "Sphinx", "docs", "locally", "and", "start", "a", "watchdog" ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/pavement.py#L275-L299
7,453
pyroscope/pyrocore
pavement.py
stopdocs
def stopdocs(): "stop Sphinx watchdog" for i in range(4): pid = watchdog_pid() if pid: if not i: sh('ps {}'.format(pid)) sh('kill {}'.format(pid)) time.sleep(.5) else: break
python
def stopdocs(): "stop Sphinx watchdog" for i in range(4): pid = watchdog_pid() if pid: if not i: sh('ps {}'.format(pid)) sh('kill {}'.format(pid)) time.sleep(.5) else: break
[ "def", "stopdocs", "(", ")", ":", "for", "i", "in", "range", "(", "4", ")", ":", "pid", "=", "watchdog_pid", "(", ")", "if", "pid", ":", "if", "not", "i", ":", "sh", "(", "'ps {}'", ".", "format", "(", "pid", ")", ")", "sh", "(", "'kill {}'", ...
stop Sphinx watchdog
[ "stop", "Sphinx", "watchdog" ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/pavement.py#L303-L313
7,454
pyroscope/pyrocore
pavement.py
coverage
def coverage(): "generate coverage report and show in browser" coverage_index = path("build/coverage/index.html") coverage_index.remove() sh("paver test") coverage_index.exists() and webbrowser.open(coverage_index)
python
def coverage(): "generate coverage report and show in browser" coverage_index = path("build/coverage/index.html") coverage_index.remove() sh("paver test") coverage_index.exists() and webbrowser.open(coverage_index)
[ "def", "coverage", "(", ")", ":", "coverage_index", "=", "path", "(", "\"build/coverage/index.html\"", ")", "coverage_index", ".", "remove", "(", ")", "sh", "(", "\"paver test\"", ")", "coverage_index", ".", "exists", "(", ")", "and", "webbrowser", ".", "open"...
generate coverage report and show in browser
[ "generate", "coverage", "report", "and", "show", "in", "browser" ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/pavement.py#L327-L332
7,455
pyroscope/pyrocore
src/pyrocore/config.py
lookup_announce_alias
def lookup_announce_alias(name): """ Get canonical alias name and announce URL list for the given alias. """ for alias, urls in announce.items(): if alias.lower() == name.lower(): return alias, urls raise KeyError("Unknown alias %s" % (name,))
python
def lookup_announce_alias(name): """ Get canonical alias name and announce URL list for the given alias. """ for alias, urls in announce.items(): if alias.lower() == name.lower(): return alias, urls raise KeyError("Unknown alias %s" % (name,))
[ "def", "lookup_announce_alias", "(", "name", ")", ":", "for", "alias", ",", "urls", "in", "announce", ".", "items", "(", ")", ":", "if", "alias", ".", "lower", "(", ")", "==", "name", ".", "lower", "(", ")", ":", "return", "alias", ",", "urls", "ra...
Get canonical alias name and announce URL list for the given alias.
[ "Get", "canonical", "alias", "name", "and", "announce", "URL", "list", "for", "the", "given", "alias", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/config.py#L27-L34
7,456
pyroscope/pyrocore
src/pyrocore/config.py
map_announce2alias
def map_announce2alias(url): """ Get tracker alias for announce URL, and if none is defined, the 2nd level domain. """ import urlparse # Try to find an exact alias URL match and return its label for alias, urls in announce.items(): if any(i == url for i in urls): return alias ...
python
def map_announce2alias(url): """ Get tracker alias for announce URL, and if none is defined, the 2nd level domain. """ import urlparse # Try to find an exact alias URL match and return its label for alias, urls in announce.items(): if any(i == url for i in urls): return alias ...
[ "def", "map_announce2alias", "(", "url", ")", ":", "import", "urlparse", "# Try to find an exact alias URL match and return its label", "for", "alias", ",", "urls", "in", "announce", ".", "items", "(", ")", ":", "if", "any", "(", "i", "==", "url", "for", "i", ...
Get tracker alias for announce URL, and if none is defined, the 2nd level domain.
[ "Get", "tracker", "alias", "for", "announce", "URL", "and", "if", "none", "is", "defined", "the", "2nd", "level", "domain", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/config.py#L37-L59
7,457
pyroscope/pyrocore
src/pyrocore/util/load_config.py
validate
def validate(key, val): """ Validate a configuration value. """ if val and val.startswith("~/"): return os.path.expanduser(val) if key == "output_header_frequency": return int(val, 10) if key.endswith("_ecma48"): return eval("'%s'" % val.replace("'", r"\'")) # pylint: disabl...
python
def validate(key, val): """ Validate a configuration value. """ if val and val.startswith("~/"): return os.path.expanduser(val) if key == "output_header_frequency": return int(val, 10) if key.endswith("_ecma48"): return eval("'%s'" % val.replace("'", r"\'")) # pylint: disabl...
[ "def", "validate", "(", "key", ",", "val", ")", ":", "if", "val", "and", "val", ".", "startswith", "(", "\"~/\"", ")", ":", "return", "os", ".", "path", ".", "expanduser", "(", "val", ")", "if", "key", "==", "\"output_header_frequency\"", ":", "return"...
Validate a configuration value.
[ "Validate", "a", "configuration", "value", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/load_config.py#L35-L45
7,458
pyroscope/pyrocore
src/pyrocore/util/load_config.py
ConfigLoader._update_config
def _update_config(self, namespace): # pylint: disable=no-self-use """ Inject the items from the given dict into the configuration. """ for key, val in namespace.items(): setattr(config, key, val)
python
def _update_config(self, namespace): # pylint: disable=no-self-use """ Inject the items from the given dict into the configuration. """ for key, val in namespace.items(): setattr(config, key, val)
[ "def", "_update_config", "(", "self", ",", "namespace", ")", ":", "# pylint: disable=no-self-use", "for", "key", ",", "val", "in", "namespace", ".", "items", "(", ")", ":", "setattr", "(", "config", ",", "key", ",", "val", ")" ]
Inject the items from the given dict into the configuration.
[ "Inject", "the", "items", "from", "the", "given", "dict", "into", "the", "configuration", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/load_config.py#L85-L89
7,459
pyroscope/pyrocore
src/pyrocore/util/load_config.py
ConfigLoader._interpolation_escape
def _interpolation_escape(self, namespace): """ Re-escape interpolation strings. """ for key, val in namespace.items(): if '%' in val: namespace[key] = self.INTERPOLATION_ESCAPE.sub(lambda match: '%' + match.group(0), val)
python
def _interpolation_escape(self, namespace): """ Re-escape interpolation strings. """ for key, val in namespace.items(): if '%' in val: namespace[key] = self.INTERPOLATION_ESCAPE.sub(lambda match: '%' + match.group(0), val)
[ "def", "_interpolation_escape", "(", "self", ",", "namespace", ")", ":", "for", "key", ",", "val", "in", "namespace", ".", "items", "(", ")", ":", "if", "'%'", "in", "val", ":", "namespace", "[", "key", "]", "=", "self", ".", "INTERPOLATION_ESCAPE", "....
Re-escape interpolation strings.
[ "Re", "-", "escape", "interpolation", "strings", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/load_config.py#L92-L97
7,460
pyroscope/pyrocore
src/pyrocore/util/load_config.py
ConfigLoader._validate_namespace
def _validate_namespace(self, namespace): """ Validate the given namespace. This method is idempotent! """ # Update config values (so other code can access them in the bootstrap phase) self._update_config(namespace) # Validate announce URLs for key, val in namespace["ann...
python
def _validate_namespace(self, namespace): """ Validate the given namespace. This method is idempotent! """ # Update config values (so other code can access them in the bootstrap phase) self._update_config(namespace) # Validate announce URLs for key, val in namespace["ann...
[ "def", "_validate_namespace", "(", "self", ",", "namespace", ")", ":", "# Update config values (so other code can access them in the bootstrap phase)", "self", ".", "_update_config", "(", "namespace", ")", "# Validate announce URLs", "for", "key", ",", "val", "in", "namespa...
Validate the given namespace. This method is idempotent!
[ "Validate", "the", "given", "namespace", ".", "This", "method", "is", "idempotent!" ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/load_config.py#L100-L130
7,461
pyroscope/pyrocore
src/pyrocore/util/load_config.py
ConfigLoader._set_from_ini
def _set_from_ini(self, namespace, ini_file): """ Copy values from loaded INI file to namespace. """ # Isolate global values global_vars = dict((key, val) for key, val in namespace.items() if isinstance(val, basestring) ) # Copy all sections ...
python
def _set_from_ini(self, namespace, ini_file): """ Copy values from loaded INI file to namespace. """ # Isolate global values global_vars = dict((key, val) for key, val in namespace.items() if isinstance(val, basestring) ) # Copy all sections ...
[ "def", "_set_from_ini", "(", "self", ",", "namespace", ",", "ini_file", ")", ":", "# Isolate global values", "global_vars", "=", "dict", "(", "(", "key", ",", "val", ")", "for", "key", ",", "val", "in", "namespace", ".", "items", "(", ")", "if", "isinsta...
Copy values from loaded INI file to namespace.
[ "Copy", "values", "from", "loaded", "INI", "file", "to", "namespace", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/load_config.py#L133-L162
7,462
pyroscope/pyrocore
src/pyrocore/util/load_config.py
ConfigLoader._set_defaults
def _set_defaults(self, namespace, optional_cfg_files): """ Set default values in the given dict. """ # Add current configuration directory namespace["config_dir"] = self.config_dir # Load defaults for idx, cfg_file in enumerate([self.CONFIG_INI] + optional_cfg_files): ...
python
def _set_defaults(self, namespace, optional_cfg_files): """ Set default values in the given dict. """ # Add current configuration directory namespace["config_dir"] = self.config_dir # Load defaults for idx, cfg_file in enumerate([self.CONFIG_INI] + optional_cfg_files): ...
[ "def", "_set_defaults", "(", "self", ",", "namespace", ",", "optional_cfg_files", ")", ":", "# Add current configuration directory", "namespace", "[", "\"config_dir\"", "]", "=", "self", ".", "config_dir", "# Load defaults", "for", "idx", ",", "cfg_file", "in", "enu...
Set default values in the given dict.
[ "Set", "default", "values", "in", "the", "given", "dict", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/load_config.py#L165-L186
7,463
pyroscope/pyrocore
src/pyrocore/util/load_config.py
ConfigLoader._load_ini
def _load_ini(self, namespace, config_file): """ Load INI style configuration. """ self.LOG.debug("Loading %r..." % (config_file,)) ini_file = ConfigParser.SafeConfigParser() ini_file.optionxform = str # case-sensitive option names if ini_file.read(config_file): ...
python
def _load_ini(self, namespace, config_file): """ Load INI style configuration. """ self.LOG.debug("Loading %r..." % (config_file,)) ini_file = ConfigParser.SafeConfigParser() ini_file.optionxform = str # case-sensitive option names if ini_file.read(config_file): ...
[ "def", "_load_ini", "(", "self", ",", "namespace", ",", "config_file", ")", ":", "self", ".", "LOG", ".", "debug", "(", "\"Loading %r...\"", "%", "(", "config_file", ",", ")", ")", "ini_file", "=", "ConfigParser", ".", "SafeConfigParser", "(", ")", "ini_fi...
Load INI style configuration.
[ "Load", "INI", "style", "configuration", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/load_config.py#L189-L199
7,464
pyroscope/pyrocore
src/pyrocore/util/load_config.py
ConfigLoader._load_py
def _load_py(self, namespace, config_file): """ Load scripted configuration. """ if config_file and os.path.isfile(config_file): self.LOG.debug("Loading %r..." % (config_file,)) exec(compile(open(config_file).read(), config_file, 'exec'), # pylint: disable=exec-used ...
python
def _load_py(self, namespace, config_file): """ Load scripted configuration. """ if config_file and os.path.isfile(config_file): self.LOG.debug("Loading %r..." % (config_file,)) exec(compile(open(config_file).read(), config_file, 'exec'), # pylint: disable=exec-used ...
[ "def", "_load_py", "(", "self", ",", "namespace", ",", "config_file", ")", ":", "if", "config_file", "and", "os", ".", "path", ".", "isfile", "(", "config_file", ")", ":", "self", ".", "LOG", ".", "debug", "(", "\"Loading %r...\"", "%", "(", "config_file...
Load scripted configuration.
[ "Load", "scripted", "configuration", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/load_config.py#L202-L210
7,465
pyroscope/pyrocore
src/pyrocore/util/load_config.py
ConfigLoader.load
def load(self, optional_cfg_files=None): """ Actually load the configuation from either the default location or the given directory. """ optional_cfg_files = optional_cfg_files or [] # Guard against coding errors if self._loaded: raise RuntimeError("INTERNAL ERROR: A...
python
def load(self, optional_cfg_files=None): """ Actually load the configuation from either the default location or the given directory. """ optional_cfg_files = optional_cfg_files or [] # Guard against coding errors if self._loaded: raise RuntimeError("INTERNAL ERROR: A...
[ "def", "load", "(", "self", ",", "optional_cfg_files", "=", "None", ")", ":", "optional_cfg_files", "=", "optional_cfg_files", "or", "[", "]", "# Guard against coding errors", "if", "self", ".", "_loaded", ":", "raise", "RuntimeError", "(", "\"INTERNAL ERROR: Attemp...
Actually load the configuation from either the default location or the given directory.
[ "Actually", "load", "the", "configuation", "from", "either", "the", "default", "location", "or", "the", "given", "directory", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/load_config.py#L213-L246
7,466
pyroscope/pyrocore
src/pyrocore/util/load_config.py
ConfigLoader.create
def create(self, remove_all_rc_files=False): """ Create default configuration files at either the default location or the given directory. """ # Check and create configuration directory if os.path.exists(self.config_dir): self.LOG.debug("Configuration directory %r already exi...
python
def create(self, remove_all_rc_files=False): """ Create default configuration files at either the default location or the given directory. """ # Check and create configuration directory if os.path.exists(self.config_dir): self.LOG.debug("Configuration directory %r already exi...
[ "def", "create", "(", "self", ",", "remove_all_rc_files", "=", "False", ")", ":", "# Check and create configuration directory", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "config_dir", ")", ":", "self", ".", "LOG", ".", "debug", "(", "\"Config...
Create default configuration files at either the default location or the given directory.
[ "Create", "default", "configuration", "files", "at", "either", "the", "default", "location", "or", "the", "given", "directory", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/load_config.py#L249-L285
7,467
pyroscope/pyrocore
src/pyrocore/scripts/mktor.py
MetafileCreator.make_magnet_meta
def make_magnet_meta(self, magnet_uri): """ Create a magnet-uri torrent. """ import cgi import hashlib if magnet_uri.startswith("magnet:"): magnet_uri = magnet_uri[7:] meta = {"magnet-uri": "magnet:" + magnet_uri} magnet_params = cgi.parse_qs(magnet_u...
python
def make_magnet_meta(self, magnet_uri): """ Create a magnet-uri torrent. """ import cgi import hashlib if magnet_uri.startswith("magnet:"): magnet_uri = magnet_uri[7:] meta = {"magnet-uri": "magnet:" + magnet_uri} magnet_params = cgi.parse_qs(magnet_u...
[ "def", "make_magnet_meta", "(", "self", ",", "magnet_uri", ")", ":", "import", "cgi", "import", "hashlib", "if", "magnet_uri", ".", "startswith", "(", "\"magnet:\"", ")", ":", "magnet_uri", "=", "magnet_uri", "[", "7", ":", "]", "meta", "=", "{", "\"magnet...
Create a magnet-uri torrent.
[ "Create", "a", "magnet", "-", "uri", "torrent", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/scripts/mktor.py#L84-L109
7,468
pyroscope/pyrocore
src/pyrocore/util/pymagic.py
get_class_logger
def get_class_logger(obj): """ Get a logger specific for the given object's class. """ return logging.getLogger(obj.__class__.__module__ + '.' + obj.__class__.__name__)
python
def get_class_logger(obj): """ Get a logger specific for the given object's class. """ return logging.getLogger(obj.__class__.__module__ + '.' + obj.__class__.__name__)
[ "def", "get_class_logger", "(", "obj", ")", ":", "return", "logging", ".", "getLogger", "(", "obj", ".", "__class__", ".", "__module__", "+", "'.'", "+", "obj", ".", "__class__", ".", "__name__", ")" ]
Get a logger specific for the given object's class.
[ "Get", "a", "logger", "specific", "for", "the", "given", "object", "s", "class", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/pymagic.py#L67-L70
7,469
pyroscope/pyrocore
src/pyrocore/util/pymagic.py
JSONEncoder.default
def default(self, o): # pylint: disable=method-hidden """Support more object types.""" if isinstance(o, set): return list(sorted(o)) elif hasattr(o, 'as_dict'): return o.as_dict() else: return super(JSONEncoder, self).default(o)
python
def default(self, o): # pylint: disable=method-hidden """Support more object types.""" if isinstance(o, set): return list(sorted(o)) elif hasattr(o, 'as_dict'): return o.as_dict() else: return super(JSONEncoder, self).default(o)
[ "def", "default", "(", "self", ",", "o", ")", ":", "# pylint: disable=method-hidden", "if", "isinstance", "(", "o", ",", "set", ")", ":", "return", "list", "(", "sorted", "(", "o", ")", ")", "elif", "hasattr", "(", "o", ",", "'as_dict'", ")", ":", "r...
Support more object types.
[ "Support", "more", "object", "types", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/pymagic.py#L85-L92
7,470
pyroscope/pyrocore
src/pyrocore/torrent/formatting.py
fmt_sz
def fmt_sz(intval): """ Format a byte sized value. """ try: return fmt.human_size(intval) except (ValueError, TypeError): return "N/A".rjust(len(fmt.human_size(0)))
python
def fmt_sz(intval): """ Format a byte sized value. """ try: return fmt.human_size(intval) except (ValueError, TypeError): return "N/A".rjust(len(fmt.human_size(0)))
[ "def", "fmt_sz", "(", "intval", ")", ":", "try", ":", "return", "fmt", ".", "human_size", "(", "intval", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "return", "\"N/A\"", ".", "rjust", "(", "len", "(", "fmt", ".", "human_size", "(", ...
Format a byte sized value.
[ "Format", "a", "byte", "sized", "value", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/formatting.py#L41-L47
7,471
pyroscope/pyrocore
src/pyrocore/torrent/formatting.py
fmt_iso
def fmt_iso(timestamp): """ Format a UNIX timestamp to an ISO datetime string. """ try: return fmt.iso_datetime(timestamp) except (ValueError, TypeError): return "N/A".rjust(len(fmt.iso_datetime(0)))
python
def fmt_iso(timestamp): """ Format a UNIX timestamp to an ISO datetime string. """ try: return fmt.iso_datetime(timestamp) except (ValueError, TypeError): return "N/A".rjust(len(fmt.iso_datetime(0)))
[ "def", "fmt_iso", "(", "timestamp", ")", ":", "try", ":", "return", "fmt", ".", "iso_datetime", "(", "timestamp", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "return", "\"N/A\"", ".", "rjust", "(", "len", "(", "fmt", ".", "iso_datetime"...
Format a UNIX timestamp to an ISO datetime string.
[ "Format", "a", "UNIX", "timestamp", "to", "an", "ISO", "datetime", "string", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/formatting.py#L50-L56
7,472
pyroscope/pyrocore
src/pyrocore/torrent/formatting.py
fmt_duration
def fmt_duration(duration): """ Format a duration value in seconds to a readable form. """ try: return fmt.human_duration(float(duration), 0, 2, True) except (ValueError, TypeError): return "N/A".rjust(len(fmt.human_duration(0, 0, 2, True)))
python
def fmt_duration(duration): """ Format a duration value in seconds to a readable form. """ try: return fmt.human_duration(float(duration), 0, 2, True) except (ValueError, TypeError): return "N/A".rjust(len(fmt.human_duration(0, 0, 2, True)))
[ "def", "fmt_duration", "(", "duration", ")", ":", "try", ":", "return", "fmt", ".", "human_duration", "(", "float", "(", "duration", ")", ",", "0", ",", "2", ",", "True", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "return", "\"N/A\""...
Format a duration value in seconds to a readable form.
[ "Format", "a", "duration", "value", "in", "seconds", "to", "a", "readable", "form", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/formatting.py#L59-L65
7,473
pyroscope/pyrocore
src/pyrocore/torrent/formatting.py
fmt_subst
def fmt_subst(regex, subst): """Replace regex with string.""" return lambda text: re.sub(regex, subst, text) if text else text
python
def fmt_subst(regex, subst): """Replace regex with string.""" return lambda text: re.sub(regex, subst, text) if text else text
[ "def", "fmt_subst", "(", "regex", ",", "subst", ")", ":", "return", "lambda", "text", ":", "re", ".", "sub", "(", "regex", ",", "subst", ",", "text", ")", "if", "text", "else", "text" ]
Replace regex with string.
[ "Replace", "regex", "with", "string", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/formatting.py#L89-L91
7,474
pyroscope/pyrocore
src/pyrocore/torrent/formatting.py
preparse
def preparse(output_format): """ Do any special processing of a template, and return the result. """ try: return templating.preparse(output_format, lambda path: os.path.join(config.config_dir, "templates", path)) except ImportError as exc: if "tempita" in str(exc): raise erro...
python
def preparse(output_format): """ Do any special processing of a template, and return the result. """ try: return templating.preparse(output_format, lambda path: os.path.join(config.config_dir, "templates", path)) except ImportError as exc: if "tempita" in str(exc): raise erro...
[ "def", "preparse", "(", "output_format", ")", ":", "try", ":", "return", "templating", ".", "preparse", "(", "output_format", ",", "lambda", "path", ":", "os", ".", "path", ".", "join", "(", "config", ".", "config_dir", ",", "\"templates\"", ",", "path", ...
Do any special processing of a template, and return the result.
[ "Do", "any", "special", "processing", "of", "a", "template", "and", "return", "the", "result", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/formatting.py#L214-L226
7,475
pyroscope/pyrocore
src/pyrocore/torrent/formatting.py
validate_field_list
def validate_field_list(fields, allow_fmt_specs=False, name_filter=None): """ Make sure the fields in the given list exist. @param fields: List of fields (comma-/space-separated if a string). @type fields: list or str @return: validated field names. @rtype: list """ formats ...
python
def validate_field_list(fields, allow_fmt_specs=False, name_filter=None): """ Make sure the fields in the given list exist. @param fields: List of fields (comma-/space-separated if a string). @type fields: list or str @return: validated field names. @rtype: list """ formats ...
[ "def", "validate_field_list", "(", "fields", ",", "allow_fmt_specs", "=", "False", ",", "name_filter", "=", "None", ")", ":", "formats", "=", "[", "i", "[", "4", ":", "]", "for", "i", "in", "globals", "(", ")", "if", "i", ".", "startswith", "(", "\"f...
Make sure the fields in the given list exist. @param fields: List of fields (comma-/space-separated if a string). @type fields: list or str @return: validated field names. @rtype: list
[ "Make", "sure", "the", "fields", "in", "the", "given", "list", "exist", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/formatting.py#L319-L349
7,476
pyroscope/pyrocore
src/pyrocore/torrent/formatting.py
validate_sort_fields
def validate_sort_fields(sort_fields): """ Make sure the fields in the given list exist, and return sorting key. If field names are prefixed with '-', sort order is reversed for that field (descending). """ # Allow descending order per field by prefixing with '-' descending = set() def sort...
python
def validate_sort_fields(sort_fields): """ Make sure the fields in the given list exist, and return sorting key. If field names are prefixed with '-', sort order is reversed for that field (descending). """ # Allow descending order per field by prefixing with '-' descending = set() def sort...
[ "def", "validate_sort_fields", "(", "sort_fields", ")", ":", "# Allow descending order per field by prefixing with '-'", "descending", "=", "set", "(", ")", "def", "sort_order_filter", "(", "name", ")", ":", "\"Helper to remove flag and memoize sort order\"", "if", "name", ...
Make sure the fields in the given list exist, and return sorting key. If field names are prefixed with '-', sort order is reversed for that field (descending).
[ "Make", "sure", "the", "fields", "in", "the", "given", "list", "exist", "and", "return", "sorting", "key", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/formatting.py#L352-L390
7,477
pyroscope/pyrocore
src/pyrocore/torrent/formatting.py
OutputMapping.formatter_help
def formatter_help(cls): """ Return a list of format specifiers and their documentation. """ result = [("raw", "Switch off the default field formatter.")] for name, method in globals().items(): if name.startswith("fmt_"): result.append((name[4:], method.__doc...
python
def formatter_help(cls): """ Return a list of format specifiers and their documentation. """ result = [("raw", "Switch off the default field formatter.")] for name, method in globals().items(): if name.startswith("fmt_"): result.append((name[4:], method.__doc...
[ "def", "formatter_help", "(", "cls", ")", ":", "result", "=", "[", "(", "\"raw\"", ",", "\"Switch off the default field formatter.\"", ")", "]", "for", "name", ",", "method", "in", "globals", "(", ")", ".", "items", "(", ")", ":", "if", "name", ".", "sta...
Return a list of format specifiers and their documentation.
[ "Return", "a", "list", "of", "format", "specifiers", "and", "their", "documentation", "." ]
89ad01346a570943d20311a0b488440975876612
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/formatting.py#L138-L147
7,478
wroberts/pytimeparse
pytimeparse/timeparse.py
timeparse
def timeparse(sval, granularity='seconds'): ''' Parse a time expression, returning it as a number of seconds. If possible, the return value will be an `int`; if this is not possible, the return will be a `float`. Returns `None` if a time expression cannot be parsed from the given string. Argu...
python
def timeparse(sval, granularity='seconds'): ''' Parse a time expression, returning it as a number of seconds. If possible, the return value will be an `int`; if this is not possible, the return will be a `float`. Returns `None` if a time expression cannot be parsed from the given string. Argu...
[ "def", "timeparse", "(", "sval", ",", "granularity", "=", "'seconds'", ")", ":", "match", "=", "COMPILED_SIGN", ".", "match", "(", "sval", ")", "sign", "=", "-", "1", "if", "match", ".", "groupdict", "(", ")", "[", "'sign'", "]", "==", "'-'", "else",...
Parse a time expression, returning it as a number of seconds. If possible, the return value will be an `int`; if this is not possible, the return will be a `float`. Returns `None` if a time expression cannot be parsed from the given string. Arguments: - `sval`: the string value to parse >>> ...
[ "Parse", "a", "time", "expression", "returning", "it", "as", "a", "number", "of", "seconds", ".", "If", "possible", "the", "return", "value", "will", "be", "an", "int", ";", "if", "this", "is", "not", "possible", "the", "return", "will", "be", "a", "fl...
dc7e783216b98a04d3f749bd82c863d6d7c41f6e
https://github.com/wroberts/pytimeparse/blob/dc7e783216b98a04d3f749bd82c863d6d7c41f6e/pytimeparse/timeparse.py#L118-L181
7,479
tylertreat/BigQuery-Python
bigquery/client.py
get_client
def get_client(project_id=None, credentials=None, service_url=None, service_account=None, private_key=None, private_key_file=None, json_key=None, json_key_file=None, readonly=True, swallow_results=True, num_retries=0): """Return a singleton ...
python
def get_client(project_id=None, credentials=None, service_url=None, service_account=None, private_key=None, private_key_file=None, json_key=None, json_key_file=None, readonly=True, swallow_results=True, num_retries=0): """Return a singleton ...
[ "def", "get_client", "(", "project_id", "=", "None", ",", "credentials", "=", "None", ",", "service_url", "=", "None", ",", "service_account", "=", "None", ",", "private_key", "=", "None", ",", "private_key_file", "=", "None", ",", "json_key", "=", "None", ...
Return a singleton instance of BigQueryClient. Either AssertionCredentials or a service account and private key combination need to be provided in order to authenticate requests to BigQuery. Parameters ---------- project_id : str, optional The BigQuery project id, required unless json_key o...
[ "Return", "a", "singleton", "instance", "of", "BigQueryClient", ".", "Either", "AssertionCredentials", "or", "a", "service", "account", "and", "private", "key", "combination", "need", "to", "be", "provided", "in", "order", "to", "authenticate", "requests", "to", ...
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L54-L155
7,480
tylertreat/BigQuery-Python
bigquery/client.py
get_projects
def get_projects(bq_service): """Given the BigQuery service, return data about all projects.""" projects_request = bq_service.projects().list().execute() projects = [] for project in projects_request.get('projects', []): project_data = { 'id': project['id'], 'name': proj...
python
def get_projects(bq_service): """Given the BigQuery service, return data about all projects.""" projects_request = bq_service.projects().list().execute() projects = [] for project in projects_request.get('projects', []): project_data = { 'id': project['id'], 'name': proj...
[ "def", "get_projects", "(", "bq_service", ")", ":", "projects_request", "=", "bq_service", ".", "projects", "(", ")", ".", "list", "(", ")", ".", "execute", "(", ")", "projects", "=", "[", "]", "for", "project", "in", "projects_request", ".", "get", "(",...
Given the BigQuery service, return data about all projects.
[ "Given", "the", "BigQuery", "service", "return", "data", "about", "all", "projects", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L158-L169
7,481
tylertreat/BigQuery-Python
bigquery/client.py
_get_bq_service
def _get_bq_service(credentials=None, service_url=None): """Construct an authorized BigQuery service object.""" assert credentials, 'Must provide ServiceAccountCredentials' http = credentials.authorize(Http()) service = build( 'bigquery', 'v2', http=http, discoveryServi...
python
def _get_bq_service(credentials=None, service_url=None): """Construct an authorized BigQuery service object.""" assert credentials, 'Must provide ServiceAccountCredentials' http = credentials.authorize(Http()) service = build( 'bigquery', 'v2', http=http, discoveryServi...
[ "def", "_get_bq_service", "(", "credentials", "=", "None", ",", "service_url", "=", "None", ")", ":", "assert", "credentials", ",", "'Must provide ServiceAccountCredentials'", "http", "=", "credentials", ".", "authorize", "(", "Http", "(", ")", ")", "service", "...
Construct an authorized BigQuery service object.
[ "Construct", "an", "authorized", "BigQuery", "service", "object", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L172-L186
7,482
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient._submit_query_job
def _submit_query_job(self, query_data): """ Submit a query job to BigQuery. This is similar to BigQueryClient.query, but gives the user direct access to the query method on the offical BigQuery python client. For fine-grained control over a query job, see: ...
python
def _submit_query_job(self, query_data): """ Submit a query job to BigQuery. This is similar to BigQueryClient.query, but gives the user direct access to the query method on the offical BigQuery python client. For fine-grained control over a query job, see: ...
[ "def", "_submit_query_job", "(", "self", ",", "query_data", ")", ":", "logger", ".", "debug", "(", "'Submitting query job: %s'", "%", "query_data", ")", "job_collection", "=", "self", ".", "bigquery", ".", "jobs", "(", ")", "try", ":", "query_reply", "=", "j...
Submit a query job to BigQuery. This is similar to BigQueryClient.query, but gives the user direct access to the query method on the offical BigQuery python client. For fine-grained control over a query job, see: https://google-api-client-libraries.appspot.c...
[ "Submit", "a", "query", "job", "to", "BigQuery", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L226-L279
7,483
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient._insert_job
def _insert_job(self, body_object): """ Submit a job to BigQuery Direct proxy to the insert() method of the offical BigQuery python client. Able to submit load, link, query, copy, or extract jobs. For more details, see: https://google-api-client-lib...
python
def _insert_job(self, body_object): """ Submit a job to BigQuery Direct proxy to the insert() method of the offical BigQuery python client. Able to submit load, link, query, copy, or extract jobs. For more details, see: https://google-api-client-lib...
[ "def", "_insert_job", "(", "self", ",", "body_object", ")", ":", "logger", ".", "debug", "(", "'Submitting job: %s'", "%", "body_object", ")", "job_collection", "=", "self", ".", "bigquery", ".", "jobs", "(", ")", "return", "job_collection", ".", "insert", "...
Submit a job to BigQuery Direct proxy to the insert() method of the offical BigQuery python client. Able to submit load, link, query, copy, or extract jobs. For more details, see: https://google-api-client-libraries.appspot.com/documentation/bigquery/v2/pyt...
[ "Submit", "a", "job", "to", "BigQuery" ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L302-L333
7,484
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.query
def query(self, query, max_results=None, timeout=0, dry_run=False, use_legacy_sql=None, external_udf_uris=None): """Submit a query to BigQuery. Parameters ---------- query : str BigQuery query string max_results : int, optional The maximum number of rows ...
python
def query(self, query, max_results=None, timeout=0, dry_run=False, use_legacy_sql=None, external_udf_uris=None): """Submit a query to BigQuery. Parameters ---------- query : str BigQuery query string max_results : int, optional The maximum number of rows ...
[ "def", "query", "(", "self", ",", "query", ",", "max_results", "=", "None", ",", "timeout", "=", "0", ",", "dry_run", "=", "False", ",", "use_legacy_sql", "=", "None", ",", "external_udf_uris", "=", "None", ")", ":", "logger", ".", "debug", "(", "'Exec...
Submit a query to BigQuery. Parameters ---------- query : str BigQuery query string max_results : int, optional The maximum number of rows to return per page of results. timeout : float, optional How long to wait for the query to complete, in ...
[ "Submit", "a", "query", "to", "BigQuery", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L335-L387
7,485
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.get_query_schema
def get_query_schema(self, job_id): """Retrieve the schema of a query by job id. Parameters ---------- job_id : str The job_id that references a BigQuery query Returns ------- list A ``list`` of ``dict`` objects that represent the schema....
python
def get_query_schema(self, job_id): """Retrieve the schema of a query by job id. Parameters ---------- job_id : str The job_id that references a BigQuery query Returns ------- list A ``list`` of ``dict`` objects that represent the schema....
[ "def", "get_query_schema", "(", "self", ",", "job_id", ")", ":", "query_reply", "=", "self", ".", "get_query_results", "(", "job_id", ",", "offset", "=", "0", ",", "limit", "=", "0", ")", "if", "not", "query_reply", "[", "'jobComplete'", "]", ":", "logge...
Retrieve the schema of a query by job id. Parameters ---------- job_id : str The job_id that references a BigQuery query Returns ------- list A ``list`` of ``dict`` objects that represent the schema.
[ "Retrieve", "the", "schema", "of", "a", "query", "by", "job", "id", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L389-L409
7,486
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.get_table_schema
def get_table_schema(self, dataset, table, project_id=None): """Return the table schema. Parameters ---------- dataset : str The dataset containing the `table`. table : str The table to get the schema for project_id: str, optional The ...
python
def get_table_schema(self, dataset, table, project_id=None): """Return the table schema. Parameters ---------- dataset : str The dataset containing the `table`. table : str The table to get the schema for project_id: str, optional The ...
[ "def", "get_table_schema", "(", "self", ",", "dataset", ",", "table", ",", "project_id", "=", "None", ")", ":", "project_id", "=", "self", ".", "_get_project_id", "(", "project_id", ")", "try", ":", "result", "=", "self", ".", "bigquery", ".", "tables", ...
Return the table schema. Parameters ---------- dataset : str The dataset containing the `table`. table : str The table to get the schema for project_id: str, optional The project of the dataset. Returns ------- list ...
[ "Return", "the", "table", "schema", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L411-L442
7,487
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.check_job
def check_job(self, job_id): """Return the state and number of results of a query by job id. Parameters ---------- job_id : str The job id of the query to check. Returns ------- tuple (``bool``, ``int``) Whether or not the query has compl...
python
def check_job(self, job_id): """Return the state and number of results of a query by job id. Parameters ---------- job_id : str The job id of the query to check. Returns ------- tuple (``bool``, ``int``) Whether or not the query has compl...
[ "def", "check_job", "(", "self", ",", "job_id", ")", ":", "query_reply", "=", "self", ".", "get_query_results", "(", "job_id", ",", "offset", "=", "0", ",", "limit", "=", "0", ")", "return", "(", "query_reply", ".", "get", "(", "'jobComplete'", ",", "F...
Return the state and number of results of a query by job id. Parameters ---------- job_id : str The job id of the query to check. Returns ------- tuple (``bool``, ``int``) Whether or not the query has completed and the total number of...
[ "Return", "the", "state", "and", "number", "of", "results", "of", "a", "query", "by", "job", "id", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L444-L463
7,488
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.get_query_rows
def get_query_rows(self, job_id, offset=None, limit=None, timeout=0): """Retrieve a list of rows from a query table by job id. This method will append results from multiple pages together. If you want to manually page through results, you can use `get_query_results` method directly. ...
python
def get_query_rows(self, job_id, offset=None, limit=None, timeout=0): """Retrieve a list of rows from a query table by job id. This method will append results from multiple pages together. If you want to manually page through results, you can use `get_query_results` method directly. ...
[ "def", "get_query_rows", "(", "self", ",", "job_id", ",", "offset", "=", "None", ",", "limit", "=", "None", ",", "timeout", "=", "0", ")", ":", "# Get query results", "query_reply", "=", "self", ".", "get_query_results", "(", "job_id", ",", "offset", "=", ...
Retrieve a list of rows from a query table by job id. This method will append results from multiple pages together. If you want to manually page through results, you can use `get_query_results` method directly. Parameters ---------- job_id : str The job id th...
[ "Retrieve", "a", "list", "of", "rows", "from", "a", "query", "table", "by", "job", "id", ".", "This", "method", "will", "append", "results", "from", "multiple", "pages", "together", ".", "If", "you", "want", "to", "manually", "page", "through", "results", ...
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L465-L508
7,489
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.check_dataset
def check_dataset(self, dataset_id, project_id=None): """Check to see if a dataset exists. Parameters ---------- dataset_id : str Dataset unique id project_id: str, optional The project the dataset is in Returns ------- bool ...
python
def check_dataset(self, dataset_id, project_id=None): """Check to see if a dataset exists. Parameters ---------- dataset_id : str Dataset unique id project_id: str, optional The project the dataset is in Returns ------- bool ...
[ "def", "check_dataset", "(", "self", ",", "dataset_id", ",", "project_id", "=", "None", ")", ":", "dataset", "=", "self", ".", "get_dataset", "(", "dataset_id", ",", "project_id", ")", "return", "bool", "(", "dataset", ")" ]
Check to see if a dataset exists. Parameters ---------- dataset_id : str Dataset unique id project_id: str, optional The project the dataset is in Returns ------- bool True if dataset at `dataset_id` exists, else Fasle
[ "Check", "to", "see", "if", "a", "dataset", "exists", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L510-L526
7,490
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.get_dataset
def get_dataset(self, dataset_id, project_id=None): """Retrieve a dataset if it exists, otherwise return an empty dict. Parameters ---------- dataset_id : str Dataset unique id project_id: str, optional The project the dataset is in Returns ...
python
def get_dataset(self, dataset_id, project_id=None): """Retrieve a dataset if it exists, otherwise return an empty dict. Parameters ---------- dataset_id : str Dataset unique id project_id: str, optional The project the dataset is in Returns ...
[ "def", "get_dataset", "(", "self", ",", "dataset_id", ",", "project_id", "=", "None", ")", ":", "project_id", "=", "self", ".", "_get_project_id", "(", "project_id", ")", "try", ":", "dataset", "=", "self", ".", "bigquery", ".", "datasets", "(", ")", "."...
Retrieve a dataset if it exists, otherwise return an empty dict. Parameters ---------- dataset_id : str Dataset unique id project_id: str, optional The project the dataset is in Returns ------- dict Contains dataset object if ...
[ "Retrieve", "a", "dataset", "if", "it", "exists", "otherwise", "return", "an", "empty", "dict", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L528-L552
7,491
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.get_table
def get_table(self, dataset, table, project_id=None): """ Retrieve a table if it exists, otherwise return an empty dict. Parameters ---------- dataset : str The dataset that the table is in table : str The name of the table project_id: str, option...
python
def get_table(self, dataset, table, project_id=None): """ Retrieve a table if it exists, otherwise return an empty dict. Parameters ---------- dataset : str The dataset that the table is in table : str The name of the table project_id: str, option...
[ "def", "get_table", "(", "self", ",", "dataset", ",", "table", ",", "project_id", "=", "None", ")", ":", "project_id", "=", "self", ".", "_get_project_id", "(", "project_id", ")", "try", ":", "table", "=", "self", ".", "bigquery", ".", "tables", "(", "...
Retrieve a table if it exists, otherwise return an empty dict. Parameters ---------- dataset : str The dataset that the table is in table : str The name of the table project_id: str, optional The project that the table is in Returns ...
[ "Retrieve", "a", "table", "if", "it", "exists", "otherwise", "return", "an", "empty", "dict", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L574-L599
7,492
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.create_table
def create_table(self, dataset, table, schema, expiration_time=None, time_partitioning=False, project_id=None): """Create a new table in the dataset. Parameters ---------- dataset : str The dataset to create the table in tabl...
python
def create_table(self, dataset, table, schema, expiration_time=None, time_partitioning=False, project_id=None): """Create a new table in the dataset. Parameters ---------- dataset : str The dataset to create the table in tabl...
[ "def", "create_table", "(", "self", ",", "dataset", ",", "table", ",", "schema", ",", "expiration_time", "=", "None", ",", "time_partitioning", "=", "False", ",", "project_id", "=", "None", ")", ":", "project_id", "=", "self", ".", "_get_project_id", "(", ...
Create a new table in the dataset. Parameters ---------- dataset : str The dataset to create the table in table : str The name of the table to create schema : dict The table schema expiration_time : int or double, optional ...
[ "Create", "a", "new", "table", "in", "the", "dataset", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L601-L661
7,493
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.patch_table
def patch_table(self, dataset, table, schema, project_id=None): """Patch an existing table in the dataset. Parameters ---------- dataset : str The dataset to patch the table in table : str The name of the table to patch schema : dict T...
python
def patch_table(self, dataset, table, schema, project_id=None): """Patch an existing table in the dataset. Parameters ---------- dataset : str The dataset to patch the table in table : str The name of the table to patch schema : dict T...
[ "def", "patch_table", "(", "self", ",", "dataset", ",", "table", ",", "schema", ",", "project_id", "=", "None", ")", ":", "project_id", "=", "self", ".", "_get_project_id", "(", "project_id", ")", "body", "=", "{", "'schema'", ":", "{", "'fields'", ":", ...
Patch an existing table in the dataset. Parameters ---------- dataset : str The dataset to patch the table in table : str The name of the table to patch schema : dict The table schema project_id: str, optional The project t...
[ "Patch", "an", "existing", "table", "in", "the", "dataset", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L714-L762
7,494
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.create_view
def create_view(self, dataset, view, query, use_legacy_sql=None, project_id=None): """Create a new view in the dataset. Parameters ---------- dataset : str The dataset to create the view in view : str The name of the view to create query : dict ...
python
def create_view(self, dataset, view, query, use_legacy_sql=None, project_id=None): """Create a new view in the dataset. Parameters ---------- dataset : str The dataset to create the view in view : str The name of the view to create query : dict ...
[ "def", "create_view", "(", "self", ",", "dataset", ",", "view", ",", "query", ",", "use_legacy_sql", "=", "None", ",", "project_id", "=", "None", ")", ":", "project_id", "=", "self", ".", "_get_project_id", "(", "project_id", ")", "body", "=", "{", "'tab...
Create a new view in the dataset. Parameters ---------- dataset : str The dataset to create the view in view : str The name of the view to create query : dict A query that BigQuery executes when the view is referenced. use_lega...
[ "Create", "a", "new", "view", "in", "the", "dataset", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L764-L820
7,495
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.delete_table
def delete_table(self, dataset, table, project_id=None): """Delete a table from the dataset. Parameters ---------- dataset : str The dataset to delete the table from. table : str The name of the table to delete project_id: str, optional ...
python
def delete_table(self, dataset, table, project_id=None): """Delete a table from the dataset. Parameters ---------- dataset : str The dataset to delete the table from. table : str The name of the table to delete project_id: str, optional ...
[ "def", "delete_table", "(", "self", ",", "dataset", ",", "table", ",", "project_id", "=", "None", ")", ":", "project_id", "=", "self", ".", "_get_project_id", "(", "project_id", ")", "try", ":", "response", "=", "self", ".", "bigquery", ".", "tables", "(...
Delete a table from the dataset. Parameters ---------- dataset : str The dataset to delete the table from. table : str The name of the table to delete project_id: str, optional String id of the project Returns ------- ...
[ "Delete", "a", "table", "from", "the", "dataset", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L822-L859
7,496
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.get_tables
def get_tables(self, dataset_id, app_id, start_time, end_time, project_id=None): """Retrieve a list of tables that are related to the given app id and are inside the range of start and end times. Parameters ---------- dataset_id : str The BigQuery dataset id to consi...
python
def get_tables(self, dataset_id, app_id, start_time, end_time, project_id=None): """Retrieve a list of tables that are related to the given app id and are inside the range of start and end times. Parameters ---------- dataset_id : str The BigQuery dataset id to consi...
[ "def", "get_tables", "(", "self", ",", "dataset_id", ",", "app_id", ",", "start_time", ",", "end_time", ",", "project_id", "=", "None", ")", ":", "if", "isinstance", "(", "start_time", ",", "datetime", ")", ":", "start_time", "=", "calendar", ".", "timegm"...
Retrieve a list of tables that are related to the given app id and are inside the range of start and end times. Parameters ---------- dataset_id : str The BigQuery dataset id to consider. app_id : str The appspot name start_time : Union[datetime, ...
[ "Retrieve", "a", "list", "of", "tables", "that", "are", "related", "to", "the", "given", "app", "id", "and", "are", "inside", "the", "range", "of", "start", "and", "end", "times", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L861-L893
7,497
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.wait_for_job
def wait_for_job(self, job, interval=5, timeout=60): """ Waits until the job indicated by job_resource is done or has failed Parameters ---------- job : Union[dict, str] ``dict`` representing a BigQuery job resource, or a ``str`` representing the BigQuery...
python
def wait_for_job(self, job, interval=5, timeout=60): """ Waits until the job indicated by job_resource is done or has failed Parameters ---------- job : Union[dict, str] ``dict`` representing a BigQuery job resource, or a ``str`` representing the BigQuery...
[ "def", "wait_for_job", "(", "self", ",", "job", ",", "interval", "=", "5", ",", "timeout", "=", "60", ")", ":", "complete", "=", "False", "job_id", "=", "str", "(", "job", "if", "isinstance", "(", "job", ",", "(", "six", ".", "binary_type", ",", "s...
Waits until the job indicated by job_resource is done or has failed Parameters ---------- job : Union[dict, str] ``dict`` representing a BigQuery job resource, or a ``str`` representing the BigQuery job id interval : float, optional Polling interval i...
[ "Waits", "until", "the", "job", "indicated", "by", "job_resource", "is", "done", "or", "has", "failed" ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L1274-L1321
7,498
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.push_rows
def push_rows(self, dataset, table, rows, insert_id_key=None, skip_invalid_rows=None, ignore_unknown_values=None, template_suffix=None, project_id=None): """Upload rows to BigQuery table. Parameters ---------- dataset : str The dataset to ...
python
def push_rows(self, dataset, table, rows, insert_id_key=None, skip_invalid_rows=None, ignore_unknown_values=None, template_suffix=None, project_id=None): """Upload rows to BigQuery table. Parameters ---------- dataset : str The dataset to ...
[ "def", "push_rows", "(", "self", ",", "dataset", ",", "table", ",", "rows", ",", "insert_id_key", "=", "None", ",", "skip_invalid_rows", "=", "None", ",", "ignore_unknown_values", "=", "None", ",", "template_suffix", "=", "None", ",", "project_id", "=", "Non...
Upload rows to BigQuery table. Parameters ---------- dataset : str The dataset to upload to table : str The name of the table to insert rows into rows : list A ``list`` of rows (``dict`` objects) to add to the table insert_id_k...
[ "Upload", "rows", "to", "BigQuery", "table", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L1323-L1415
7,499
tylertreat/BigQuery-Python
bigquery/client.py
BigQueryClient.get_all_tables
def get_all_tables(self, dataset_id, project_id=None): """Retrieve a list of tables for the dataset. Parameters ---------- dataset_id : str The dataset to retrieve table data for. project_id: str Unique ``str`` identifying the BigQuery project contains th...
python
def get_all_tables(self, dataset_id, project_id=None): """Retrieve a list of tables for the dataset. Parameters ---------- dataset_id : str The dataset to retrieve table data for. project_id: str Unique ``str`` identifying the BigQuery project contains th...
[ "def", "get_all_tables", "(", "self", ",", "dataset_id", ",", "project_id", "=", "None", ")", ":", "tables_data", "=", "self", ".", "_get_all_tables_for_dataset", "(", "dataset_id", ",", "project_id", ")", "tables", "=", "[", "]", "for", "table", "in", "tabl...
Retrieve a list of tables for the dataset. Parameters ---------- dataset_id : str The dataset to retrieve table data for. project_id: str Unique ``str`` identifying the BigQuery project contains the dataset Returns ------- A ``list`` with...
[ "Retrieve", "a", "list", "of", "tables", "for", "the", "dataset", "." ]
88d99de42d954d49fc281460068f0e95003da098
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L1417-L1438