repo_name
stringlengths
7
65
path
stringlengths
5
187
copies
stringclasses
483 values
size
stringlengths
4
7
content
stringlengths
805
1.02M
license
stringclasses
14 values
rbrito/pkg-youtube-dl
devscripts/make_supportedsites.py
36
1153
#!/usr/bin/env python from __future__ import unicode_literals import io import optparse import os import sys # Import youtube_dl ROOT_DIR = os.path.join(os.path.dirname(__file__), '..') sys.path.insert(0, ROOT_DIR) import youtube_dl def main(): parser = optparse.OptionParser(usage='%prog OUTFILE.md') optio...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/ntvcojp.py
17
1939
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( js_to_json, smuggle_url, ) class NTVCoJpCUIE(InfoExtractor): IE_NAME = 'cu.ntv.co.jp' IE_DESC = 'Nippon Television Network' _VALID_URL = r'https?://cu\.ntv\.co\.jp/(?!program)(?P<id>[^/...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/once.py
19
2167
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor class OnceIE(InfoExtractor): _VALID_URL = r'https?://.+?\.unicornmedia\.com/now/(?:ads/vmap/)?[^/]+/[^/]+/(?P<domain_id>[^/]+)/(?P<application_id>[^/]+)/(?:[^/]+/)?(?P<media_item_id>[^/]+)/content\.(?:once|m3u8|m...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/nhl.py
19
5004
from __future__ import unicode_literals import re from .common import InfoExtractor from ..compat import compat_str from ..utils import ( determine_ext, int_or_none, parse_iso8601, parse_duration, ) class NHLBaseIE(InfoExtractor): def _real_extract(self, url): site, tmp_id = re.match(sel...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/vodlocker.py
64
2796
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( ExtractorError, NO_DEFAULT, sanitized_Request, urlencode_postdata, ) class VodlockerIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?vodlocker\.(?:com|city)/(?:embed-)?(?P<id>[0-9a-...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/bravotv.py
5
3775
# coding: utf-8 from __future__ import unicode_literals import re from .adobepass import AdobePassIE from ..utils import ( smuggle_url, update_url_query, int_or_none, ) class BravoTVIE(AdobePassIE): _VALID_URL = r'https?://(?:www\.)?(?P<req_id>bravotv|oxygen)\.com/(?:[^/]+/)+(?P<id>[^/?#]+)' _TE...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/tele13.py
90
3345
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from .youtube import YoutubeIE from ..utils import ( js_to_json, qualities, determine_ext, ) class Tele13IE(InfoExtractor): _VALID_URL = r'^https?://(?:www\.)?t13\.cl/videos(?:/[^/]+)+/(?P<id>[\w-]+)' _TESTS...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/movingimage.py
64
1774
from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( unescapeHTML, parse_duration, ) class MovingImageIE(InfoExtractor): _VALID_URL = r'https?://movingimage\.nls\.uk/film/(?P<id>\d+)' _TEST = { 'url': 'http://movingimage.nls.uk/film/3561', 'm...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/bpb.py
36
2204
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( js_to_json, determine_ext, ) class BpbIE(InfoExtractor): IE_DESC = 'Bundeszentrale für politische Bildung' _VALID_URL = r'https?://(?:www\.)?bpb\.de/mediathek/(?P<id>[0-9]+)/' ...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/karaoketv.py
73
2340
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor class KaraoketvIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?karaoketv\.co\.il/[^/]+/(?P<id>\d+)' _TEST = { 'url': 'http://www.karaoketv.co.il/%D7%A9%D7%99%D7%A8%D7%99_%D7%A7%D7%A8%D7%99%D7%95%D7%A7%D7%99...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/internazionale.py
21
3328
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import unified_timestamp class InternazionaleIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?internazionale\.it/video/(?:[^/]+/)*(?P<id>[^/?#&]+)' _TESTS = [{ 'url': 'https://www.internazionale...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/gamespot.py
6
3156
from __future__ import unicode_literals from .once import OnceIE from ..compat import compat_urllib_parse_unquote class GameSpotIE(OnceIE): _VALID_URL = r'https?://(?:www\.)?gamespot\.com/(?:video|article|review)s/(?:[^/]+/\d+-|embed/)(?P<id>\d+)' _TESTS = [{ 'url': 'http://www.gamespot.com/videos/ar...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/spankbang.py
5
7229
from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( determine_ext, ExtractorError, merge_dicts, parse_duration, parse_resolution, str_to_int, url_or_none, urlencode_postdata, urljoin, ) class SpankBangIE(InfoExtractor): _V...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/youku.py
11
11404
# coding: utf-8 from __future__ import unicode_literals import random import re import string import time from .common import InfoExtractor from ..utils import ( ExtractorError, get_element_by_class, js_to_json, str_or_none, strip_jsonp, ) class YoukuIE(InfoExtractor): IE_NAME = 'youku' ...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/tv5mondeplus.py
12
4498
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( determine_ext, extract_attributes, int_or_none, parse_duration, ) class TV5MondePlusIE(InfoExtractor): IE_DESC = 'TV5MONDE+' _VALID_URL = r'https?://(?:www\.)?(?:tv5mondeplus|revoir...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/defense.py
90
1242
from __future__ import unicode_literals from .common import InfoExtractor class DefenseGouvFrIE(InfoExtractor): IE_NAME = 'defense.gouv.fr' _VALID_URL = r'https?://.*?\.defense\.gouv\.fr/layout/set/ligthboxvideo/base-de-medias/webtv/(?P<id>[^/?#]*)' _TEST = { 'url': 'http://www.defense.gouv.fr/l...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/megaphone.py
30
1770
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import js_to_json class MegaphoneIE(InfoExtractor): IE_NAME = 'megaphone.fm' IE_DESC = 'megaphone.fm embedded players' _VALID_URL = r'https://player\.megaphone\.fm/(?P<id>[A-Z0-9]+)' _TES...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/tvp.py
20
9417
# coding: utf-8 from __future__ import unicode_literals import itertools import re from .common import InfoExtractor from ..utils import ( clean_html, determine_ext, ExtractorError, get_element_by_attribute, orderedSet, ) class TVPIE(InfoExtractor): IE_NAME = 'tvp' IE_DESC = 'Telewizja P...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/vidio.py
5
3285
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( int_or_none, parse_iso8601, str_or_none, strip_or_none, try_get, ) class VidioIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?vidio\.com/watch/(?P<id>\d+)-(?P<displa...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/karrierevideos.py
15
3379
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import compat_urlparse from ..utils import ( fix_xml_ampersands, float_or_none, xpath_with_ns, xpath_text, ) class KarriereVideosIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?karrierevid...
unlicense
rbrito/pkg-youtube-dl
test/test_unicode_literals.py
168
1894
from __future__ import unicode_literals # Allow direct execution import os import sys import unittest sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import io import re rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) IGNORED_FILES = [ 'setup.py', # http://...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/vvvvid.py
1
9782
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from .youtube import YoutubeIE from ..utils import ( ExtractorError, int_or_none, str_or_none, ) class VVVVIDIE(InfoExtractor): _VALID_URL_BASE = r'https?://(?:www\.)?vvvvid\.it/(?:#!)?(?:show|anime|f...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/fivemin.py
79
1917
from __future__ import unicode_literals from .common import InfoExtractor class FiveMinIE(InfoExtractor): IE_NAME = '5min' _VALID_URL = r'(?:5min:|https?://(?:[^/]*?5min\.com/|delivery\.vidible\.tv/aol)(?:(?:Scripts/PlayerSeed\.js|playerseed/?)?\?.*?playList=)?)(?P<id>\d+)' _TESTS = [ { ...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/eagleplatform.py
23
7736
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..compat import compat_HTTPError from ..utils import ( ExtractorError, int_or_none, unsmuggle_url, url_or_none, ) class EaglePlatformIE(InfoExtractor): _VALID_URL = r'''(?x) ...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/jeuxvideo.py
30
2041
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor class JeuxVideoIE(InfoExtractor): _VALID_URL = r'https?://.*?\.jeuxvideo\.com/.*/(.*?)\.htm' _TESTS = [{ 'url': 'http://www.jeuxvideo.com/reportages-videos-jeux/0004/00046170/tearaway-playstation-vi...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/carambatv.py
20
3524
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import compat_str from ..utils import ( float_or_none, int_or_none, try_get, ) from .videomore import VideomoreIE class CarambaTVIE(InfoExtractor): _VALID_URL = r'(?:carambatv:|https?://video1\.ca...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/slideshare.py
39
2132
from __future__ import unicode_literals import re import json from .common import InfoExtractor from ..compat import ( compat_urlparse, ) from ..utils import ( ExtractorError, get_element_by_id, ) class SlideshareIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?slideshare\.net/[^/]+?/(?P<title>....
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/safari.py
12
9746
# coding: utf-8 from __future__ import unicode_literals import json import re from .common import InfoExtractor from ..compat import ( compat_parse_qs, compat_urlparse, ) from ..utils import ( ExtractorError, update_url_query, ) class SafariBaseIE(InfoExtractor): _LOGIN_URL = 'https://learning....
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/cjsw.py
45
2412
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( determine_ext, unescapeHTML, ) class CJSWIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?cjsw\.com/program/(?P<program>[^/]+)/episode/(?P<id>\d+)' _TESTS = [{ 'url':...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/ellentube.py
29
4909
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( clean_html, extract_attributes, float_or_none, int_or_none, try_get, ) class EllenTubeBaseIE(InfoExtractor): def _extract_data_config(self, webpage, video_id): details = sel...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/people.py
64
1140
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor class PeopleIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?people\.com/people/videos/0,,(?P<id>\d+),00\.html' _TEST = { 'url': 'http://www.people.com/people/videos/0,,20995451,00.html', 'info_dict...
unlicense
rbrito/pkg-youtube-dl
youtube_dl/extractor/abc.py
12
7495
from __future__ import unicode_literals import hashlib import hmac import re import time from .common import InfoExtractor from ..compat import compat_str from ..utils import ( ExtractorError, js_to_json, int_or_none, parse_iso8601, try_get, unescapeHTML, update_url_query, ) class ABCIE(...
unlicense
unitedstates/congress-legislators
scripts/election_results.py
1
10137
# Update the data files according to the results of # a general election using a spreadsheet of election # results and prepares for a new Congress. This script # does the following: # # * Adds end dates to all current leadership roles since # leadership resets in both chambers each Congress. # * Brings senators not u...
cc0-1.0
unitedstates/congress-legislators
scripts/social_media.py
1
18271
#!/usr/bin/env python # run with --sweep (or by default): # given a service, looks through current members for those missing an account on that service, # and checks that member's official website's source code for mentions of that service. # A CSV of "leads" is produced for manual review. # # run with --update:...
cc0-1.0
eliben/code-for-blog
2011/socket_client_thread_sample/sampleguiclient.py
1
3818
""" Sample GUI using SocketClientThread for socket communication, while doing other stuff in parallel. Eli Bendersky (eliben@gmail.com) This code is in the public domain """ import os, sys, time import Queue from PyQt4.QtCore import * from PyQt4.QtGui import * from socketclientthread import SocketClientThread, Client...
unlicense
eliben/code-for-blog
2013/twisted_irc_testbot.py
13
3414
#------------------------------------------------------------------------------- # twisted_irc_testbot.py # # A sample IRC bot based on the example in Twisted's docs. # # Eli Bendersky (eliben@gmail.com) # Last updated: 2013.01.27 # This code is in the public domain #----------------------------------------------------...
unlicense
eliben/code-for-blog
2018/type-inference/parser.py
1
7046
# EBNF specification for micro-ML. { x } means zero or more repetitions of x. # # The top-level is decl. # # decl: ID { ID } '=' expr # # expr: INT # | bool # | ID # | ID '(' { expr ',' } ')' # | ...
unlicense
eliben/code-for-blog
2011/asio_protobuf_sample/tester_client.py
13
2232
#!/usr/bin/python # # tester_client.py: simple testing client for the server. Suitable for # usage from the python interactive prompt. # # Eli Bendersky (eliben@gmail.com) # This code is in the public domain # from __future__ import print_function import sys from socket import * import struct from stringdb_pb2 import...
unlicense
eliben/code-for-blog
2009/pygame_creeps_game/pathfinder.py
1
4974
from priorityqueueset import PriorityQueueSet class PathFinder(object): """ Computes a path in a graph using the A* algorithm. Initialize the object and then repeatedly compute_path to get the path between a start point and an end point. The points on a graph are required to be hashable ...
unlicense
eliben/code-for-blog
2009/csp_for_euler68/csp_sample_problems.py
13
12407
""" A collection of "worlds" suitable by solution by a CSP. Each world has a make_XXX_SCP function that creates a new CSP object, and some auxiliary utilities. """ import re, math from collections import defaultdict from types import StringTypes from csplib import CSP #-------------------------------...
unlicense
eliben/code-for-blog
2012/plugins_python/htmlize/iplugin.py
1
2327
#------------------------------------------------------------------------------- # htmlize: htmlize/iplugin.py # # The plugin interface. Plugins that want to register with htmlize must inherit # IPlugin. # # Eli Bendersky (eliben@gmail.com) # This code is in the public domain #------------------------------------------...
unlicense
cfpb/owning-a-home-api
ratechecker/tests/test_views.py
1
14027
import json from datetime import datetime, timedelta from django.test import override_settings from django.utils import timezone from model_mommy import mommy from rest_framework import status from rest_framework.test import APITestCase from ratechecker.models import Adjustment, Product, Rate, Region from ratechecke...
cc0-1.0
mozilla-services/tokenserver
tokenserver/tests/test_remote_browserid_verifier.py
1
7579
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/. import json import contextlib import unittest from pyramid.config import Configurator from tokenserver.verifiers impor...
mpl-2.0
mozilla-services/tokenserver
tokenserver/tests/assignment/test_sqlnode.py
1
24094
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/. import math import os import time import unittest import uuid from collections import defaultdict from sqlalchemy.sql im...
mpl-2.0
mozilla-services/tokenserver
tokenserver/scripts/count_users.py
1
3191
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/. """ Script to emit total-user-count metrics for exec dashboard. This script takes a tokenserver config file, uses it to...
mpl-2.0
mozilla-services/tokenserver
tokenserver/assignment/sqlnode/migrations/versions/6569dd9a060_populate_nodeid_column_and_index.py
1
1476
# flake8: noqa """populate nodeid column and index Revision ID: 6569dd9a060 Revises: 846f28d1b6f Create Date: 2014-04-14 05:26:44.146236 This updates the values in the "nodeid" column to ensure that they match the value in the string-based "node" column, then indexes the column for fast node-based lookup. It should...
mpl-2.0
pycket/pycket
pycket/test/test_ast.py
4
10721
#! /usr/bin/env python # -*- coding: utf-8 -*- import pytest from pycket.expand import expand, expand_string from pycket.values import W_Symbol, W_Fixnum, w_false, w_true from pycket.expand import parse_module from pycket.interpreter import (LexicalVar, ModuleVar, Done, CaseLambda, vari...
mit
onecodex/onecodex
onecodex/exceptions.py
1
3218
class OneCodexException(Exception): pass class MethodNotSupported(OneCodexException): """The object does not support this operation.""" pass class PermissionDenied(OneCodexException): pass class ServerError(OneCodexException): pass class UnboundObject(OneCodexException): """To use again...
mit
pycket/pycket
pycket/hidden_classes.py
4
7665
from rpython.rlib import jit, unroll, rweakref from rpython.rlib.objectmodel import specialize def make_map_type(getter, keyclass): class Map(object): """ A basic implementation of a map which assigns Racket values to an index based on the identity of the Racket value. A Map consists ...
mit
onecodex/onecodex
onecodex/models/analysis.py
1
2826
from onecodex.models import OneCodexBase class Analyses(OneCodexBase): _resource_path = "/api/v1/analyses" _cached_result = None def results(self, json=True): """Fetch the results of an Analyses resource. Parameters ---------- json : bool, optional Return a JS...
mit
pycket/pycket
pycket/prims/continuation_marks.py
1
6193
#! /usr/bin/env python # -*- coding: utf-8 -*- from pycket import impersonators as imp from pycket import values from pycket import vector from pycket.cont import call_cont, Cont from pycket.error import SchemeException from pycket.prims.expose import default, expo...
mit
onecodex/onecodex
onecodex/vendored/potion_client/links.py
2
4737
# flake8: noqa try: import simplejson as json except ImportError: import json import re from requests import Request from requests.exceptions import HTTPError from .collection import PaginatedList from .converter import PotionJSONEncoder, PotionJSONDecoder from .schema import Schema class Link(object): ...
mit
onecodex/onecodex
tests/test_api_models.py
1
14224
from __future__ import print_function import datetime import io import pytest import mock import responses import sys try: from urllib.parse import unquote_plus # Py3 except ImportError: from urllib import unquote_plus import onecodex from onecodex import Api from onecodex.exceptions import MethodNotSupporte...
mit
pycket/pycket
pycket/test/test_impersonators.py
4
23872
#! /usr/bin/env python # -*- coding: utf-8 -*- from pycket.test.testhelper import * from pycket.values import * from pycket.impersonators import * from pycket.values_struct import * import pytest import sys sys.setrecursionlimit(10000) def test_impersonator_properties(): m = run_mod( """ #lang pycket ...
mit
pycket/pycket
pycket/values_parameter.py
1
7530
from pycket import values from pycket.arity import Arity from pycket.base import W_Object from pycket.cont import call_cont, continuation, BaseCont from pycket.error import SchemeException from pycket.hash.persistent...
mit
pycket/pycket
pycket/hash/equal.py
2
19602
from pycket import config from pycket import values, values_string from pycket.base import SingletonMeta, UnhashableType from pycket.hash.base import W_HashTable, get_dict_item, next_valid_index, w_missing from pycket.error import SchemeException fro...
mit
onecodex/onecodex
tests/test_dataframes.py
2
3650
import pytest pytest.importorskip("pandas") # noqa import pandas as pd from onecodex.analyses import AnalysisMixin from onecodex.dataframes import ClassificationsDataFrame, ClassificationsSeries, OneCodexAccessor def test_pandas_subclass(): inner_df = pd.DataFrame({"datum1": [7, 4, 21], "datum2": [8, 16, 24]})...
mit
pycket/pycket
pycket/values_struct.py
1
55181
import itertools, sys from pycket import config from pycket import values from pycket import vector as values_vector from pycket.arity import Arity from pycket.base import SingleResultMixin, UnhashableType from pycket.cont import continuation, label from pycket.error import SchemeException from pycket.prims.expose imp...
mit
pycket/pycket
pycket/prims/logging.py
2
4642
from pycket import values, values_parameter, values_string from pycket.arity import Arity from pycket.argument_parser import ArgParser, EndOfInput from pycket.prims.expose import default, expose, expose_val from rpython.rlib import jit DEBUG = values.W_Symbol.make("debug") LOG_...
mit
pycket/pycket
pycket/values.py
1
67304
#! /usr/bin/env python # -*- coding: utf-8 -*- from pycket import config from pycket.base import W_Object, W_ProtoObject, UnhashableType from pycket.cont import continuation, label, NilCont from pycket.env import ConsEnv from pycket.error import Sch...
mit
houtianze/bypy
bypy/const.py
1
8705
#!/usr/bin/env python # encoding: utf-8 # PYTHON_ARGCOMPLETE_OK # from __future__ imports must occur at the beginning of the file from __future__ import unicode_literals from __future__ import print_function from __future__ import division import sys import os # https://packaging.python.org/single_source_version/ __...
mit
kibitzr/kibitzr
kibitzr/app.py
1
5995
import logging import signal import time import code import psutil import os import entrypoints from .conf import settings, SettingsParser from .fetcher import cleanup_fetchers, persistent_firefox from .checker import Checker from .bootstrap import create_boilerplate from . import timeline logger = logging.getLogge...
mit
demisto/content
Packs/CommonScripts/Scripts/CalculateEntropy/CalculateEntropy.py
2
1737
import demistomock as demisto from CommonServerPython import * # noqa: E402 lgtm [py/polluting-import] from CommonServerUserPython import * # noqa: E402 lgtm [py/polluting-import] import math import string def calculate_shannon_entropy(data, minimum_entropy): """Algorithm to determine the randomness of a given ...
mit
demisto/content
Packs/PANWComprehensiveInvestigation/Scripts/PanwIndicatorCreateQueries/PanwIndicatorCreateQueries_test.py
2
3263
from PanwIndicatorCreateQueries import generate_ip_queries, generate_hash_queries, generate_domain_queries def test_generate_ip_queries(): """Unit test Given - generate_ip_queries command - command args(single and multiple ips) When - executing generate_ip_queries command Then - Valida...
mit
demisto/content
Packs/ShiftManagement/Scripts/CreateChannelWrapper/CreateChannelWrapper.py
2
2075
from CommonServerPython import * def main(): args = demisto.args() channel_type = args.get('type') channel_name = args.get('name') channel_desc = args.get('description') channel_team = args.get('team') errors = [] integrations_to_create = [] channels_created = [] modules = demist...
mit
demisto/content
Packs/Workday/Integrations/Workday_IAM/test_data/fetch_incidents_source_priority_mock_data.py
2
1396
full_report = { "Report_Entry": [{ "Employment_Status": "Active", "Last_Day_Of_Work": "10/05/2035", "Last_Hire_Date": "10/05/2020", "Emp_ID": "100122", "Email_Address": "rrahardjo@paloaltonetworks.com" }] } employee_id_to_user_profile = { "100122": { "employm...
mit
demisto/content
Packs/LogRhythmRest/Integrations/LogRhythmRest/LogRhythmRest.py
2
83553
# -*- coding: utf-8 -*- import demistomock as demisto from CommonServerPython import * from CommonServerUserPython import * ''' IMPORTS ''' import json import requests import random import string from datetime import datetime, timedelta # Disable insecure warnings requests.packages.urllib3.disable_warnings() ''' ...
mit
demisto/content
Packs/CIRCL/Integrations/CIRCL/CIRCL.py
2
7040
import demistomock as demisto from CommonServerPython import * from CommonServerUserPython import * import requests import json # disable insecure warnings requests.packages.urllib3.disable_warnings() ''' GLOBAL VARS ''' BASE_URL = demisto.getParam('url') USERNAME = demisto.getParam('credentials')['identifier'] PASSW...
mit
demisto/content
Packs/NCSCCyberAsssessmentFramework/Scripts/NCSCReportDetailsC/NCSCReportDetailsC.py
2
3754
import json import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 def calculate_overall(data: dict = None) -> str: if not data: return "" results = [x['Result'] for x in data] if "Not Achieved" in results: return "Not Achieved" elif "Partially Achi...
mit
demisto/content
Packs/CrowdStrikeFalcon/Integrations/CrowdStrikeFalcon/CrowdStrikeFalcon_test.py
2
161566
import pytest import os import json from _pytest.python_api import raises import demistomock as demisto from CommonServerPython import outputPaths, entryTypes, DemistoException, IncidentStatus from test_data import input_data RETURN_ERROR_TARGET = 'CrowdStrikeFalcon.return_error' SERVER_URL = 'https://4.4.4.4' def...
mit
demisto/content
Packs/CortexXDR/Scripts/CortexXDRIdentityInformationWidget/CortexXDRIdentityInformationWidget_test.py
2
1049
import io import pytest from CommonServerPython import * import CortexXDRIdentityInformationWidget def util_load_json(path): with io.open(path, mode='r', encoding='utf-8') as f: return json.loads(f.read()) @pytest.mark.parametrize('context_data, expected_result', [ (util_load_json('test_data/context...
mit
demisto/content
Packs/MalwareInvestigationAndResponse/Scripts/InvestigationSummaryToTable/InvestigationSummaryToTable_test.py
2
1584
import json from pathlib import Path from InvestigationSummaryToTable import Result, get_findings, findings_to_command_results TEST_DATA_DIR = Path(__file__).parent / 'test_data' def _load_test_file(file_name: str): return json.loads((TEST_DATA_DIR / file_name).read_text()) def _dump_test_file(file_name: str,...
mit
demisto/content
Packs/Stealthwatch_Cloud/Integrations/Stealthwatch_Cloud/Stealthwatch_Cloud.py
2
17438
import demistomock as demisto from CommonServerPython import * ''' IMPORTS ''' import requests import json import os from datetime import datetime, timedelta import collections # disable insecure warnings requests.packages.urllib3.disable_warnings() ''' GLOBAL VARS ''' SERVER = demisto.params().get('serverURL', '').s...
mit
demisto/content
Packs/ServiceNow/Integrations/ServiceNow_CMDB/test_data/result_constants.py
2
4486
EXPECTED_RECORDS_LIST_WITH_RECORDS = { 'ServiceNowCMDB(val.ID===obj.ID)': { 'Class': 'test_class', 'Records': [{ 'sys_id': '0ad329e3db27901026fca015ca9619fb', 'name': 'Test record 1' }, { 'sys_id': '2a41eb4e1b739810042611b4bd4bcb9d', 'name': 'T...
mit
demisto/content
Packs/ARIAPacketIntelligence/Integrations/ARIAPacketIntelligence/ARIAPacketIntelligence.py
2
97247
import demistomock as demisto from CommonServerPython import * import json import requests import time import re class ParameterError(Exception): """ Raised when the function parameters do not meet requirements """ pass """ Remediation Configuration String (RCS) that use to select SIA. """ class RCS: ...
mit
demisto/content
Packs/CommonScripts/Scripts/ParseCSV/ParseCSV_test.py
2
4480
import json import pytest import demistomock as demisto class TestParseCSV: @staticmethod def mock_results(mocker): mocker.patch.object(demisto, "results") @staticmethod def mock_context(mocker, args_value=None): if not args_value: args_value = { "entryID":...
mit
demisto/content
Packs/CommonScripts/Scripts/ProvidesCommand/ProvidesCommand_test.py
2
1741
import demistomock as demisto import json def executeCommand(name, args=None): if name == 'demisto-api-get' and args and 'uri' in args and args['uri'] == "/settings/integration-commands": file_name = 'TestData/integration_commands.json' elif name == 'demisto-api-post' and args and 'uri' in args and ar...
mit
demisto/content
Packs/Cryptocurrency/Scripts/CryptoCurrenciesFormat/CryptoCurrenciesFormat.py
2
1206
import demistomock as demisto from hashlib import sha256 from CommonServerPython import * # noqa: E402 lgtm [py/polluting-import] from typing import Union DIGITS58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' def decode_base58(address, length) -> bytes: n = 0 for char in address: ...
mit
demisto/content
Packs/SolarWinds/Integrations/SolarWinds/SolarWinds_test.py
2
16943
import json import io import os import pytest import unittest.mock as mock from CommonServerPython import DemistoException BASE_URL = "https://{}:17778/SolarWinds/InformationService/v3/Json" SERVER_DOMAIN = "dummy.server" def util_load_json(path): with io.open(path, mode='r', encoding='utf-8') as f: ret...
mit
demisto/content
Packs/Base/Scripts/WordTokenizerV2/word_tokenizer_test.py
2
3412
# coding=utf-8 from collections import defaultdict import demistomock from CommonServerPython import * def get_args(): args = defaultdict(lambda: "yes") args['encoding'] = 'utf8' args['removeNonEnglishWords'] = 'no' args['hashWordWithSeed'] = "5381" args['language'] = 'English' return args ...
mit
demisto/content
Packs/CommonScripts/Scripts/CheckContextValue/CheckContextValue_test.py
2
2863
from CommonServerPython import * from CheckContextValue import poll_field context = { 'id': 1, 'name': 'This is incident1', 'type': 'Phishing', 'severity': 0, 'status': 1, 'created': '2019-01-02', 'closed': '0001-01-01T00:00:00Z', 'foo': 'bar', } missing_context = { 'id': 2, 'n...
mit
demisto/content
Packs/ProofpointServerProtection/Integrations/ProofpointProtectionServerV2/ProofpointProtectionServerV2.py
2
19087
from typing import Any, Dict, Union import demistomock as demisto # noqa: F401 import urllib3 from CommonServerPython import * # noqa: F401 from dateparser import parse from requests import Response urllib3.disable_warnings() class Client(BaseClient): def health_check(self) -> Dict[str, str]: return s...
mit
demisto/content
Packs/Attlasian/Integrations/Attlasian_IAM/Attlasian_IAM.py
2
8380
import demistomock as demisto from CommonServerPython import * import traceback # Disable insecure warnings requests.packages.urllib3.disable_warnings() '''CLIENT CLASS''' class Client(BaseClient): """ Atlassian IAM Client class that implements logic to authenticate with Atlassian. """ def __init__(...
mit
demisto/content
Packs/GoogleKeyManagementService/Integrations/GoogleKeyManagementService/GoogleKeyManagementService_test.py
2
2402
from google.cloud import kms class Client: def __init__(self, params): self.project = params.get('project') self.location = params.get('location') self.key_ring = params.get('key_ring') self.service_account = params.get('service_account') self.role = params.get('role') MO...
mit
demisto/content
Packs/ApiModules/Scripts/JSONFeedApiModule/JSONFeedApiModule.py
1
18721
from CommonServerPython import * ''' IMPORTS ''' import urllib3 import jmespath from typing import List, Dict, Union, Optional, Callable, Tuple # disable insecure warnings urllib3.disable_warnings() class Client: def __init__(self, url: str = '', credentials: dict = None, feed_name_to_config: D...
mit
demisto/content
Packs/FeedCyjax/Integrations/FeedCyjax/test_data/indicators.py
2
2165
mocked_indicators = [ { "type": "URL", "industry_type": [ "IT", "online gaming", "Military" ], "value": "https://test.domainos.com?test=true&id=32423", "handling_condition": "GREEN", "discovered_at": "2020-12-31T14:18:26+0000", ...
mit
demisto/content
Packs/UnisysStealth/Integrations/UnisysStealth/UnisysStealth.py
2
6075
import json import os import demistomock as demisto # noqa: F401 import requests from CommonServerPython import * # noqa: F401 from requests.auth import HTTPBasicAuth # disable insecure warnings requests.packages.urllib3.disable_warnings() USERNAME = demisto.params().get('credentials')['identifier'] PASSWORD = dem...
mit
demisto/content
Packs/CortexAttackSurfaceManagement/Scripts/GenerateASMReport/GenerateASMReport_test.py
2
3260
import json import demistomock as demisto # noqa: F401 from CommonServerPython import EntryType def util_load_json(path): with open(path, mode="r") as f: return json.loads(f.read()) def test_get_asm_args(mocker): """Tests get_asm_args helper function. Given: - Mock JSON that mi...
mit
demisto/content
Packs/CortexXDR/Integrations/CortexXDRIR/CortexXDRIR.py
2
63140
import hashlib import secrets import string import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 from CoreIRApiModule import * from itertools import zip_longest # Disable insecure warnings urllib3.disable_warnings() TIME_FORMAT = "%Y-%m-%dT%H:%M:%S" NONCE_LENGTH = 64 API_KEY_LENG...
mit
demisto/content
Packs/Netskope/Integrations/NetskopeAPIv1/NetskopeAPIv1.py
2
38749
# type: ignore from copy import deepcopy from typing import Any, Dict, List, Optional, Tuple from urllib.parse import urljoin import urllib3 import demistomock as demisto from CommonServerPython import * from CommonServerUserPython import * # disable insecure warnings urllib3.disable_warnings() DEFAULT_PAGE = 1 DEF...
mit
demisto/content
Packs/FortiSandbox/Integrations/FortiSandbox/FortiSandbox.py
2
17497
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 """IMPORTS""" import base64 import hashlib import json import os import requests # Disable insecure warnings requests.packages.urllib3.disable_warnings() """HELPER FUNCTIONS""" def _handle_post(post_url, data): try: ...
mit
demisto/content
Packs/IronPort/Integrations/CiscoEmailSecurityApplianceIronPortV2/CiscoEmailSecurityApplianceIronPortV2.py
1
64731
from typing import Callable, Tuple import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 import uuid JWT_TOKEN_EXPIRATION_PERIOD = 30 DEFAULT_FETCH = 50 TIMESTAMP_FORMAT = "%d %b %Y %H:%M:%S (%Z +00:00)" QUARANTINE_TIMESTAMP_FORMAT = "%d %b %Y %H:%M (%Z +00:00)" DATETIME_FORMAT ...
mit
demisto/content
Packs/ShiftManagement/Scripts/GetOnCallHoursPerUser/GetOnCallHoursPerUser_test.py
2
2316
import json import demistomock as demisto from GetOnCallHoursPerUser import main ROLES = [ { 'name': 'Shift1', 'shifts': [ {'fromDay': 0, 'fromHour': 8, 'fromMinute': 0, 'toDay': 3, 'toHour': 12, 'toMinute': 0}, {'fromDay': 4, 'fromHour': 16, 'fromMinute': 0, 'toDay': 6, 't...
mit
demisto/content
Packs/CommonScripts/Scripts/MarkAsNoteByTag/MarkAsNoteByTag.py
2
1144
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 def mark_as_note(entries): if isError(entries[0]): demisto.results( {'Type': entryTypes['error'], 'ContentsFormat': formats['text'], 'Contents': 'Unable to retrieve entries'}) else: ids = '' ...
mit
demisto/content
Packs/CommonScripts/Scripts/RemoveKeyFromList/RemoveKeyFromList.py
2
2173
"""RemoveKeyFromList Removes a Key from a JSON-backed List """ import demistomock as demisto from CommonServerPython import * # noqa # pylint: disable=unused-wildcard-import from CommonServerUserPython import * # noqa from typing import Dict, Any import traceback ''' STANDALONE FUNCTION ''' def remove_key_from_...
mit
demisto/content
Tests/scripts/create_artifacts_graph/create_artifacts.py
2
2802
from argparse import ArgumentParser from pathlib import Path from demisto_sdk.commands.content_graph.interface.neo4j.neo4j_graph import Neo4jContentGraphInterface from demisto_sdk.commands.common.constants import MarketplaceVersions from demisto_sdk.commands.content_graph.objects.repository import ContentDTO from Tests...
mit
demisto/content
Packs/QRadar/Scripts/QRadarPrintAssets/QRadarPrintAssets.py
2
1126
import json import demistomock as demisto # noqa: F401 import yaml from CommonServerPython import * # noqa: F401 def main(): try: incident = demisto.incident() assets = incident.get('CustomFields', {}).get('assettable', {}) if not assets: return '' if not isinstanc...
mit
demisto/content
Packs/fireeye/Scripts/FireEyeDetonateFile/FireEyeDetonateFile_test.py
2
4205
from FireEyeDetonateFile import get_results, detonate_file, poll_stage import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 import pytest @pytest.mark.parametrize('feDone, profiles, status, feSubmissionKeys, file, mock_value, expected_results', [ (False, [], None, None, None,...
mit
demisto/content
Packs/ThreatGrid/Integrations/FeedCiscoSecureMalwareAnalytics/FeedCiscoSecureMalwareAnalytics_test.py
2
3414
from FeedCiscoSecureMalwareAnalytics import Client, fetch_indicators, fetch_indicators_command, \ create_entity_relationships from CommonServerPython import * from test_data.feed_data import banking_dns_response, sinkholed_ip_dns_response def test_fetch_indicators(requests_mock): """Unit test Given - ...
mit
demisto/content
Packs/RiskSense/Integrations/RiskSense/RiskSense_test.py
2
15758
import unittest import pytest import json from unittest.mock import patch from RiskSense import Client CLIENT_DETAILS = { 'ClientName': 'test client', 'Id': 747 } class MyTestCase(unittest.TestCase): client = Client('url', 60, False, False, ()) @patch("RiskSense.get_client_detail_from_context") ...
mit