_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q267600
WebsiteManagementService.delete_site
test
def delete_site(self, webspace_name, website_name, delete_empty_server_farm=False, delete_metrics=False): ''' Delete a website. webspace_name: The name of the webspace. website_name: The name of the website. delete_empty_server_farm: ...
python
{ "resource": "" }
q267601
WebsiteManagementService.update_site
test
def update_site(self, webspace_name, website_name, state=None): ''' Update a web site. webspace_name: The name of the webspace. website_name: The name of the website. state: The wanted state ('Running' or 'Stopped' accepted) ''' ...
python
{ "resource": "" }
q267602
WebsiteManagementService.restart_site
test
def restart_site(self, webspace_name, website_name): ''' Restart a web site. webspace_name: The name of the webspace. website_name: The name of the website. ''' return self._perform_post( self._get_restart_path(webspace_name, website_n...
python
{ "resource": "" }
q267603
WebsiteManagementService.get_historical_usage_metrics
test
def get_historical_usage_metrics(self, webspace_name, website_name, metrics = None, start_time=None, end_time=None, time_grain=None): ''' Get historical usage metrics. webspace_name: The name of the webspace. website_name: The...
python
{ "resource": "" }
q267604
WebsiteManagementService.get_metric_definitions
test
def get_metric_definitions(self, webspace_name, website_name): ''' Get metric definitions of metrics available of this web site. webspace_name: The name of the webspace. website_name: The name of the website. ''' return self._perform_get(self._get...
python
{ "resource": "" }
q267605
WebsiteManagementService.get_publish_profile_xml
test
def get_publish_profile_xml(self, webspace_name, website_name): ''' Get a site's publish profile as a string webspace_name: The name of the webspace. website_name: The name of the website. ''' return self._perform_get(self._get_publishxml_path(web...
python
{ "resource": "" }
q267606
WebsiteManagementService.get_publish_profile
test
def get_publish_profile(self, webspace_name, website_name): ''' Get a site's publish profile as an object webspace_name: The name of the webspace. website_name: The name of the website. ''' return self._perform_get(self._get_publishxml_path(webspa...
python
{ "resource": "" }
q267607
RegistriesOperations.update_policies
test
def update_policies( self, resource_group_name, registry_name, quarantine_policy=None, trust_policy=None, custom_headers=None, raw=False, polling=True, **operation_config): """Updates the policies for the specified container registry. :param resource_group_name: The name of the resource gro...
python
{ "resource": "" }
q267608
SchedulerManagementService.create_cloud_service
test
def create_cloud_service(self, cloud_service_id, label, description, geo_region): ''' The Create Cloud Service request creates a new cloud service. When job collections are created, they are hosted within a cloud service. A cloud service groups job collections together in a given region....
python
{ "resource": "" }
q267609
SchedulerManagementService.check_job_collection_name
test
def check_job_collection_name(self, cloud_service_id, job_collection_id): ''' The Check Name Availability operation checks if a new job collection with the given name may be created, or if it is unavailable. The result of the operation is a Boolean true or false. cloud_service_i...
python
{ "resource": "" }
q267610
SchedulerManagementService.get_job_collection
test
def get_job_collection(self, cloud_service_id, job_collection_id): ''' The Get Job Collection operation gets the details of a job collection cloud_service_id: The cloud service id job_collection_id: Name of the hosted service. ''' _validate_not_no...
python
{ "resource": "" }
q267611
ManagedDatabasesOperations.complete_restore
test
def complete_restore( self, location_name, operation_id, last_backup_name, custom_headers=None, raw=False, polling=True, **operation_config): """Completes the restore operation on a managed database. :param location_name: The name of the region where the resource is located. ...
python
{ "resource": "" }
q267612
Sender.cancel_scheduled_messages
test
async def cancel_scheduled_messages(self, *sequence_numbers): """Cancel one or more messages that have previsouly been scheduled and are still pending. :param sequence_numbers: The seqeuence numbers of the scheduled messages. :type sequence_numbers: int Example: .. literali...
python
{ "resource": "" }
q267613
Sender.send_pending_messages
test
async def send_pending_messages(self): """Wait until all pending messages have been sent. :returns: A list of the send results of all the pending messages. Each send result is a tuple with two values. The first is a boolean, indicating `True` if the message sent, or `False` if it fail...
python
{ "resource": "" }
q267614
Sender.reconnect
test
async def reconnect(self): """Reconnect the handler. If the handler was disconnected from the service with a retryable error - attempt to reconnect. This method will be called automatically for most retryable errors. Also attempts to re-queue any messages that were pending befor...
python
{ "resource": "" }
q267615
get_certificate_from_publish_settings
test
def get_certificate_from_publish_settings(publish_settings_path, path_to_write_certificate, subscription_id=None): ''' Writes a certificate file to the specified location. This can then be used to instantiate ServiceManagementService. Returns the subscription ID. publish_settings_path: Path...
python
{ "resource": "" }
q267616
Plugin.load_cookies
test
def load_cookies(self): """ Load any stored cookies for the plugin that have not expired. :return: list of the restored cookie names """ if not self.session or not self.cache: raise RuntimeError("Cannot loaded cached cookies in unbound plugin") restored = []...
python
{ "resource": "" }
q267617
terminal_width
test
def terminal_width(value): """Returns the width of the string it would be when displayed.""" if isinstance(value, bytes): value = value.decode("utf8", "ignore") return sum(map(get_width, map(ord, value)))
python
{ "resource": "" }
q267618
get_cut_prefix
test
def get_cut_prefix(value, max_len): """Drops Characters by unicode not by bytes.""" should_convert = isinstance(value, bytes) if should_convert: value = value.decode("utf8", "ignore") for i in range(len(value)): if terminal_width(value[i:]) <= max_len: break return value[...
python
{ "resource": "" }
q267619
print_inplace
test
def print_inplace(msg): """Clears out the previous line and prints a new one.""" term_width = get_terminal_size().columns spacing = term_width - terminal_width(msg) # On windows we need one less space or we overflow the line for some reason. if is_win32: spacing -= 1 sys.stderr.write("...
python
{ "resource": "" }
q267620
format_filesize
test
def format_filesize(size): """Formats the file size into a human readable format.""" for suffix in ("bytes", "KB", "MB", "GB", "TB"): if size < 1024.0: if suffix in ("GB", "TB"): return "{0:3.2f} {1}".format(size, suffix) else: return "{0:3.1f} {1}...
python
{ "resource": "" }
q267621
format_time
test
def format_time(elapsed): """Formats elapsed seconds into a human readable format.""" hours = int(elapsed / (60 * 60)) minutes = int((elapsed % (60 * 60)) / 60) seconds = int(elapsed % 60) rval = "" if hours: rval += "{0}h".format(hours) if elapsed > 60: rval += "{0}m".form...
python
{ "resource": "" }
q267622
create_status_line
test
def create_status_line(**params): """Creates a status line with appropriate size.""" max_size = get_terminal_size().columns - 1 for fmt in PROGRESS_FORMATS: status = fmt.format(**params) if len(status) <= max_size: break return status
python
{ "resource": "" }
q267623
progress
test
def progress(iterator, prefix): """Progress an iterator and updates a pretty status line to the terminal. The status line contains: - Amount of data read from the iterator - Time elapsed - Average speed, based on the last few seconds. """ if terminal_width(prefix) > 25: prefix = ...
python
{ "resource": "" }
q267624
SegmentTemplate.segment_numbers
test
def segment_numbers(self): """ yield the segment number and when it will be available There are two cases for segment number generation, static and dynamic. In the case of static stream, the segment number starts at the startNumber and counts up to the number of segments that ar...
python
{ "resource": "" }
q267625
Representation.segments
test
def segments(self, **kwargs): """ Segments are yielded when they are available Segments appear on a time line, for dynamic content they are only available at a certain time and sometimes for a limited time. For static content they are all available at the same time. :param kwar...
python
{ "resource": "" }
q267626
SegmentedStreamWorker.wait
test
def wait(self, time): """Pauses the thread for a specified time. Returns False if interrupted by another thread and True if the time runs out normally. """ self._wait = Event() return not self._wait.wait(time)
python
{ "resource": "" }
q267627
SegmentedStreamWriter.put
test
def put(self, segment): """Adds a segment to the download pool and write queue.""" if self.closed: return if segment is not None: future = self.executor.submit(self.fetch, segment, retries=self.retries) else: ...
python
{ "resource": "" }
q267628
SegmentedStreamWriter.queue
test
def queue(self, queue_, value): """Puts a value into a queue but aborts if this thread is closed.""" while not self.closed: try: queue_.put(value, block=True, timeout=1) return except queue.Full: continue
python
{ "resource": "" }
q267629
HDSStream._pv_params
test
def _pv_params(cls, session, pvswf, pv, **request_params): """Returns any parameters needed for Akamai HD player verification. Algorithm originally documented by KSV, source: http://stream-recorder.com/forum/showpost.php?p=43761&postcount=13 """ try: data, hdntl = p...
python
{ "resource": "" }
q267630
BBCiPlayer._extract_nonce
test
def _extract_nonce(cls, http_result): """ Given an HTTP response from the sessino endpoint, extract the nonce, so we can "sign" requests with it. We don't really sign the requests in the traditional sense of a nonce, we just incude them in the auth requests. :param http_result: HTTP res...
python
{ "resource": "" }
q267631
BBCiPlayer.find_vpid
test
def find_vpid(self, url, res=None): """ Find the Video Packet ID in the HTML for the provided URL :param url: URL to download, if res is not provided. :param res: Provide a cached version of the HTTP response to search :type url: string :type res: requests.Response ...
python
{ "resource": "" }
q267632
parse_json
test
def parse_json(data, name="JSON", exception=PluginError, schema=None): """Wrapper around json.loads. Wraps errors in custom exception with a snippet of the data in the message. """ try: json_data = json.loads(data) except ValueError as err: snippet = repr(data) if len(snippe...
python
{ "resource": "" }
q267633
parse_xml
test
def parse_xml(data, name="XML", ignore_ns=False, exception=PluginError, schema=None, invalid_char_entities=False): """Wrapper around ElementTree.fromstring with some extras. Provides these extra features: - Handles incorrectly encoded XML - Allows stripping namespace information - Wraps errors i...
python
{ "resource": "" }
q267634
parse_qsd
test
def parse_qsd(data, name="query string", exception=PluginError, schema=None, **params): """Parses a query string into a dict. Unlike parse_qs and parse_qsl, duplicate keys are not preserved in favor of a simpler return value. """ value = dict(parse_qsl(data, **params)) if schema: value...
python
{ "resource": "" }
q267635
search_dict
test
def search_dict(data, key): """ Search for a key in a nested dict, or list of nested dicts, and return the values. :param data: dict/list to search :param key: key to find :return: matches for key """ if isinstance(data, dict): for dkey, value in data.items(): if dkey ==...
python
{ "resource": "" }
q267636
StreamProcess.spawn
test
def spawn(self, parameters=None, arguments=None, stderr=None, timeout=None, short_option_prefix="-", long_option_prefix="--"): """ Spawn the process defined in `cmd` parameters is converted to options the short and long option prefixes if a list is given as the value, the parameter is r...
python
{ "resource": "" }
q267637
itertags
test
def itertags(html, tag): """ Brute force regex based HTML tag parser. This is a rough-and-ready searcher to find HTML tags when standards compliance is not required. Will find tags that are commented out, or inside script tag etc. :param html: HTML page :param tag: tag name to find :return: gen...
python
{ "resource": "" }
q267638
DASHStream.parse_manifest
test
def parse_manifest(cls, session, url_or_manifest, **args): """ Attempt to parse a DASH manifest file and return its streams :param session: Streamlink session instance :param url_or_manifest: URL of the manifest file or an XML manifest string :return: a dict of name -> DASHStrea...
python
{ "resource": "" }
q267639
HTTPSession.determine_json_encoding
test
def determine_json_encoding(cls, sample): """ Determine which Unicode encoding the JSON text sample is encoded with RFC4627 (http://www.ietf.org/rfc/rfc4627.txt) suggests that the encoding of JSON text can be determined by checking the pattern of NULL bytes in first 4 octets of the text...
python
{ "resource": "" }
q267640
HTTPSession.json
test
def json(cls, res, *args, **kwargs): """Parses JSON from a response.""" # if an encoding is already set then use the provided encoding if res.encoding is None: res.encoding = cls.determine_json_encoding(res.content[:4]) return parse_json(res.text, *args, **kwargs)
python
{ "resource": "" }
q267641
HTTPSession.xml
test
def xml(cls, res, *args, **kwargs): """Parses XML from a response.""" return parse_xml(res.text, *args, **kwargs)
python
{ "resource": "" }
q267642
HTTPSession.parse_cookies
test
def parse_cookies(self, cookies, **kwargs): """Parses a semi-colon delimited list of cookies. Example: foo=bar;baz=qux """ for name, value in _parse_keyvalue_list(cookies): self.cookies.set(name, value, **kwargs)
python
{ "resource": "" }
q267643
HTTPSession.parse_headers
test
def parse_headers(self, headers): """Parses a semi-colon delimited list of headers. Example: foo=bar;baz=qux """ for name, value in _parse_keyvalue_list(headers): self.headers[name] = value
python
{ "resource": "" }
q267644
HTTPSession.parse_query_params
test
def parse_query_params(self, cookies, **kwargs): """Parses a semi-colon delimited list of query parameters. Example: foo=bar;baz=qux """ for name, value in _parse_keyvalue_list(cookies): self.params[name] = value
python
{ "resource": "" }
q267645
_LogRecord.getMessage
test
def getMessage(self): """ Return the message for this LogRecord. Return the message for this LogRecord after merging any user-supplied arguments with the message. """ msg = self.msg if self.args: msg = msg.format(*self.args) return maybe_encod...
python
{ "resource": "" }
q267646
StreamlinkLogger.makeRecord
test
def makeRecord(self, name, level, fn, lno, msg, args, exc_info, func=None, extra=None, sinfo=None): """ A factory method which can be overridden in subclasses to create specialized LogRecords. """ if name.startswith("streamlink"): rv = _LogRecord(na...
python
{ "resource": "" }
q267647
LiveEdu.login
test
def login(self): """ Attempt a login to LiveEdu.tv """ email = self.get_option("email") password = self.get_option("password") if email and password: res = self.session.http.get(self.login_url) csrf_match = self.csrf_re.search(res.text) ...
python
{ "resource": "" }
q267648
load_support_plugin
test
def load_support_plugin(name): """Loads a plugin from the same directory as the calling plugin. The path used is extracted from the last call in module scope, therefore this must be called only from module level in the originating plugin or the correct plugin path will not be found. """ # Get...
python
{ "resource": "" }
q267649
update_qsd
test
def update_qsd(url, qsd=None, remove=None): """ Update or remove keys from a query string in a URL :param url: URL to update :param qsd: dict of keys to update, a None value leaves it unchanged :param remove: list of keys to remove, or "*" to remove all note: updated keys are nev...
python
{ "resource": "" }
q267650
FLVTagConcat.iter_chunks
test
def iter_chunks(self, fd=None, buf=None, skip_header=None): """Reads FLV tags from fd or buf and returns them with adjusted timestamps.""" timestamps = dict(self.timestamps_add) tag_iterator = self.iter_tags(fd=fd, buf=buf, skip_header=skip_header) if not self.flv_header_writ...
python
{ "resource": "" }
q267651
Arguments.requires
test
def requires(self, name): """ Find all the arguments required by name :param name: name of the argument the find the dependencies :return: list of dependant arguments """ results = set([name]) argument = self.get(name) for reqname in argument.requires: ...
python
{ "resource": "" }
q267652
check_file_output
test
def check_file_output(filename, force): """Checks if file already exists and ask the user if it should be overwritten if it does.""" log.debug("Checking file output") if os.path.isfile(filename) and not force: if sys.stdin.isatty(): answer = console.ask("File {0} already exists! Ov...
python
{ "resource": "" }
q267653
create_output
test
def create_output(plugin): """Decides where to write the stream. Depending on arguments it can be one of these: - The stdout pipe - A subprocess' stdin pipe - A named pipe that the subprocess reads from - A regular file """ if (args.output or args.stdout) and (args.record or args....
python
{ "resource": "" }
q267654
create_http_server
test
def create_http_server(host=None, port=0): """Creates a HTTP server listening on a given host and port. If host is empty, listen on all available interfaces, and if port is 0, listen on a random high port. """ try: http = HTTPServer() http.bind(host=host, port=port) except OSEr...
python
{ "resource": "" }
q267655
iter_http_requests
test
def iter_http_requests(server, player): """Repeatedly accept HTTP connections on a server. Forever if the serving externally, or while a player is running if it is not empty. """ while not player or player.running: try: yield server.open(timeout=2.5) except OSError: ...
python
{ "resource": "" }
q267656
output_stream_http
test
def output_stream_http(plugin, initial_streams, external=False, port=0): """Continuously output the stream over HTTP.""" global output if not external: if not args.player: console.exit("The default player (VLC) does not seem to be " "installed. You must specify ...
python
{ "resource": "" }
q267657
output_stream_passthrough
test
def output_stream_passthrough(plugin, stream): """Prepares a filename to be passed to the player.""" global output title = create_title(plugin) filename = '"{0}"'.format(stream_to_url(stream)) output = PlayerOutput(args.player, args=args.player_args, filename=filename, cal...
python
{ "resource": "" }
q267658
open_stream
test
def open_stream(stream): """Opens a stream and reads 8192 bytes from it. This is useful to check if a stream actually has data before opening the output. """ global stream_fd # Attempts to open the stream try: stream_fd = stream.open() except StreamError as err: raise ...
python
{ "resource": "" }
q267659
output_stream
test
def output_stream(plugin, stream): """Open stream, create output and finally write the stream to output.""" global output success_open = False for i in range(args.retry_open): try: stream_fd, prebuffer = open_stream(stream) success_open = True break e...
python
{ "resource": "" }
q267660
read_stream
test
def read_stream(stream, output, prebuffer, chunk_size=8192): """Reads data from stream and then writes it to the output.""" is_player = isinstance(output, PlayerOutput) is_http = isinstance(output, HTTPServer) is_fifo = is_player and output.namedpipe show_progress = isinstance(output, FileOutput) an...
python
{ "resource": "" }
q267661
handle_stream
test
def handle_stream(plugin, streams, stream_name): """Decides what to do with the selected stream. Depending on arguments it can be one of these: - Output internal command-line - Output JSON represenation - Continuously output the stream over HTTP - Output stream data to selected output ...
python
{ "resource": "" }
q267662
fetch_streams
test
def fetch_streams(plugin): """Fetches streams using correct parameters.""" return plugin.streams(stream_types=args.stream_types, sorting_excludes=args.stream_sorting_excludes)
python
{ "resource": "" }
q267663
fetch_streams_with_retry
test
def fetch_streams_with_retry(plugin, interval, count): """Attempts to fetch streams repeatedly until some are returned or limit hit.""" try: streams = fetch_streams(plugin) except PluginError as err: log.error(u"{0}", err) streams = None if not streams: log.info(...
python
{ "resource": "" }
q267664
resolve_stream_name
test
def resolve_stream_name(streams, stream_name): """Returns the real stream name of a synonym.""" if stream_name in STREAM_SYNONYMS and stream_name in streams: for name, stream in streams.items(): if stream is streams[stream_name] and name not in STREAM_SYNONYMS: return name ...
python
{ "resource": "" }
q267665
format_valid_streams
test
def format_valid_streams(plugin, streams): """Formats a dict of streams. Filters out synonyms and displays them next to the stream they point to. Streams are sorted according to their quality (based on plugin.stream_weight). """ delimiter = ", " validstreams = [] for name, strea...
python
{ "resource": "" }
q267666
handle_url
test
def handle_url(): """The URL handler. Attempts to resolve the URL to a plugin and then attempts to fetch a list of available streams. Proceeds to handle stream if user specified a valid one, otherwise output list of valid streams. """ try: plugin = streamlink.resolve_url(args.url...
python
{ "resource": "" }
q267667
print_plugins
test
def print_plugins(): """Outputs a list of all plugins Streamlink has loaded.""" pluginlist = list(streamlink.get_plugins().keys()) pluginlist_formatted = ", ".join(sorted(pluginlist)) if console.json: console.msg_json(pluginlist) else: console.msg("Loaded plugins: {0}", pluginlist_...
python
{ "resource": "" }
q267668
authenticate_twitch_oauth
test
def authenticate_twitch_oauth(): """Opens a web browser to allow the user to grant Streamlink access to their Twitch account.""" client_id = TWITCH_CLIENT_ID redirect_uri = "https://streamlink.github.io/twitch_oauth.html" url = ("https://api.twitch.tv/kraken/oauth2/authorize" "?respon...
python
{ "resource": "" }
q267669
load_plugins
test
def load_plugins(dirs): """Attempts to load plugins from a list of directories.""" dirs = [os.path.expanduser(d) for d in dirs] for directory in dirs: if os.path.isdir(directory): streamlink.load_plugins(directory) else: log.warning("Plugin path {0} does not exist o...
python
{ "resource": "" }
q267670
setup_args
test
def setup_args(parser, config_files=[], ignore_unknown=False): """Parses arguments.""" global args arglist = sys.argv[1:] # Load arguments from config files for config_file in filter(os.path.isfile, config_files): arglist.insert(0, "@" + config_file) args, unknown = parser.parse_known_...
python
{ "resource": "" }
q267671
setup_console
test
def setup_console(output): """Console setup.""" global console # All console related operations is handled via the ConsoleOutput class console = ConsoleOutput(output, streamlink) console.json = args.json # Handle SIGTERM just like SIGINT signal.signal(signal.SIGTERM, signal.default_int_han...
python
{ "resource": "" }
q267672
setup_http_session
test
def setup_http_session(): """Sets the global HTTP settings, such as proxy and headers.""" if args.http_proxy: streamlink.set_option("http-proxy", args.http_proxy) if args.https_proxy: streamlink.set_option("https-proxy", args.https_proxy) if args.http_cookie: streamlink.set_opt...
python
{ "resource": "" }
q267673
setup_plugins
test
def setup_plugins(extra_plugin_dir=None): """Loads any additional plugins.""" if os.path.isdir(PLUGINS_DIR): load_plugins([PLUGINS_DIR]) if extra_plugin_dir: load_plugins(extra_plugin_dir)
python
{ "resource": "" }
q267674
setup_options
test
def setup_options(): """Sets Streamlink options.""" if args.hls_live_edge: streamlink.set_option("hls-live-edge", args.hls_live_edge) if args.hls_segment_attempts: streamlink.set_option("hls-segment-attempts", args.hls_segment_attempts) if args.hls_playlist_reload_attempts: str...
python
{ "resource": "" }
q267675
log_current_versions
test
def log_current_versions(): """Show current installed versions""" if logger.root.isEnabledFor(logging.DEBUG): # MAC OS X if sys.platform == "darwin": os_version = "macOS {0}".format(platform.mac_ver()[0]) # Windows elif sys.platform.startswith("win"): os_v...
python
{ "resource": "" }
q267676
Viasat._get_stream_id
test
def _get_stream_id(self, text): """Try to find a stream_id""" m = self._image_re.search(text) if m: return m.group("stream_id")
python
{ "resource": "" }
q267677
Viasat._get_iframe
test
def _get_iframe(self, text): """Fallback if no stream_id was found before""" m = self._iframe_re.search(text) if m: return self.session.streams(m.group("url"))
python
{ "resource": "" }
q267678
Streamlink.set_option
test
def set_option(self, key, value): """Sets general options used by plugins and streams originating from this session object. :param key: key of the option :param value: value to set the option to **Available options**: ======================== =========================...
python
{ "resource": "" }
q267679
Streamlink.get_option
test
def get_option(self, key): """Returns current value of specified option. :param key: key of the option """ # Backwards compatibility if key == "rtmpdump": key = "rtmp-rtmpdump" elif key == "rtmpdump-proxy": key = "rtmp-proxy" elif key == ...
python
{ "resource": "" }
q267680
Streamlink.set_plugin_option
test
def set_plugin_option(self, plugin, key, value): """Sets plugin specific options used by plugins originating from this session object. :param plugin: name of the plugin :param key: key of the option :param value: value to set the option to """ if plugin in self...
python
{ "resource": "" }
q267681
Streamlink.get_plugin_option
test
def get_plugin_option(self, plugin, key): """Returns current value of plugin specific option. :param plugin: name of the plugin :param key: key of the option """ if plugin in self.plugins: plugin = self.plugins[plugin] return plugin.get_option(key)
python
{ "resource": "" }
q267682
Streamlink.resolve_url
test
def resolve_url(self, url, follow_redirect=True): """Attempts to find a plugin that can use this URL. The default protocol (http) will be prefixed to the URL if not specified. Raises :exc:`NoPluginError` on failure. :param url: a URL to match against loaded plugins :pa...
python
{ "resource": "" }
q267683
Streamlink.load_plugins
test
def load_plugins(self, path): """Attempt to load plugins from the path specified. :param path: full path to a directory where to look for plugins """ for loader, name, ispkg in pkgutil.iter_modules([path]): file, pathname, desc = imp.find_module(name, [path]) # ...
python
{ "resource": "" }
q267684
hours_minutes_seconds
test
def hours_minutes_seconds(value): """converts a timestamp to seconds - hours:minutes:seconds to seconds - minutes:seconds to seconds - 11h22m33s to seconds - 11h to seconds - 20h15m to seconds - seconds to seconds :param value: hh:mm:ss ; 00h00m00s ; seconds :return: se...
python
{ "resource": "" }
q267685
startswith
test
def startswith(string): """Checks if the string value starts with another string.""" def starts_with(value): validate(text, value) if not value.startswith(string): raise ValueError("'{0}' does not start with '{1}'".format(value, string)) return True return starts_with
python
{ "resource": "" }
q267686
endswith
test
def endswith(string): """Checks if the string value ends with another string.""" def ends_with(value): validate(text, value) if not value.endswith(string): raise ValueError("'{0}' does not end with '{1}'".format(value, string)) return True return ends_with
python
{ "resource": "" }
q267687
contains
test
def contains(string): """Checks if the string value contains another string.""" def contains_str(value): validate(text, value) if string not in value: raise ValueError("'{0}' does not contain '{1}'".format(value, string)) return True return contains_str
python
{ "resource": "" }
q267688
getattr
test
def getattr(attr, default=None): """Get a named attribute from an object. When a default argument is given, it is returned when the attribute doesn't exist. """ def getter(value): return _getattr(value, attr, default) return transform(getter)
python
{ "resource": "" }
q267689
filter
test
def filter(func): """Filters out unwanted items using the specified function. Supports both dicts and sequences, key/value pairs are expanded when applied to a dict. """ def expand_kv(kv): return func(*kv) def filter_values(value): cls = type(value) if isinstance(value,...
python
{ "resource": "" }
q267690
map
test
def map(func): """Apply function to each value inside the sequence or dict. Supports both dicts and sequences, key/value pairs are expanded when applied to a dict. """ # text is an alias for basestring on Python 2, which cannot be # instantiated and therefore can't be used to transform the valu...
python
{ "resource": "" }
q267691
url
test
def url(**attributes): """Parses an URL and validates its attributes.""" def check_url(value): validate(text, value) parsed = urlparse(value) if not parsed.netloc: raise ValueError("'{0}' is not a valid URL".format(value)) for name, schema in attributes.items(): ...
python
{ "resource": "" }
q267692
xml_find
test
def xml_find(xpath): """Find a XML element via xpath.""" def xpath_find(value): validate(ET.iselement, value) value = value.find(xpath) if value is None: raise ValueError("XPath '{0}' did not return an element".format(xpath)) return validate(ET.iselement, value) ...
python
{ "resource": "" }
q267693
xml_findall
test
def xml_findall(xpath): """Find a list of XML elements via xpath.""" def xpath_findall(value): validate(ET.iselement, value) return value.findall(xpath) return transform(xpath_findall)
python
{ "resource": "" }
q267694
_find_player_url
test
def _find_player_url(response): """ Finds embedded player url in HTTP response. :param response: Response object. :returns: Player url (str). """ url = '' matches = _player_re.search(response.text) if matches: tmp_url = matches.group(0).replace('&amp;', '&') if 'hash' no...
python
{ "resource": "" }
q267695
load
test
def load(data, base_uri=None, parser=M3U8Parser, **kwargs): """Attempts to parse a M3U8 playlist from a string of data. If specified, *base_uri* is the base URI that relative URIs will be joined together with, otherwise relative URIs will be as is. If specified, *parser* can be a M3U8Parser subclass t...
python
{ "resource": "" }
q267696
PlayerOutput.supported_player
test
def supported_player(cls, cmd): """ Check if the current player supports adding a title :param cmd: command to test :return: name of the player|None """ if not is_win32: # under a POSIX system use shlex to find the actual command # under windows t...
python
{ "resource": "" }
q267697
SteamBroadcastPlugin.dologin
test
def dologin(self, email, password, emailauth="", emailsteamid="", captchagid="-1", captcha_text="", twofactorcode=""): """ Logs in to Steam """ epassword, rsatimestamp = self.encrypt_password(email, password) login_data = { 'username': email, "password":...
python
{ "resource": "" }
q267698
Huomao.get_stream_id
test
def get_stream_id(self, html): """Returns the stream_id contained in the HTML.""" stream_id = stream_id_pattern.search(html) if not stream_id: self.logger.error("Failed to extract stream_id.") return stream_id.group("stream_id")
python
{ "resource": "" }
q267699
Huomao.get_stream_info
test
def get_stream_info(self, html): """ Returns a nested list of different stream options. Each entry in the list will contain a stream_url and stream_quality_name for each stream occurrence that was found in the JS. """ stream_info = stream_info_pattern.findall(html) ...
python
{ "resource": "" }