repo_name stringlengths 7 65 | path stringlengths 5 185 | copies stringlengths 1 4 | size stringlengths 4 6 | content stringlengths 977 990k | license stringclasses 14
values | hash stringlengths 32 32 | line_mean float64 7.18 99.4 | line_max int64 31 999 | alpha_frac float64 0.25 0.95 | ratio float64 1.5 7.84 | autogenerated bool 1
class | config_or_test bool 2
classes | has_no_keywords bool 2
classes | has_few_assignments bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
demisto/content | Packs/Tidy/Integrations/Tidy/Tidy.py | 2 | 23163 | import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
""" Developer notes
This integration based on:
1. Ansible-runner library - https://ansible-runner.readthedocs.io/en/latest/
"""
from socket import error
from typing import Any, Callable, Dict, List
from ansible_runner im... | mit | fcc122db2bac3f1bfc77cfb7f4fc98cb | 32.963343 | 117 | 0.565557 | 4.336016 | false | false | false | false |
demisto/content | Packs/ProofpointServerProtection/Integrations/ProofpointServerProtection/ProofpointServerProtection.py | 2 | 21327 | ''' IMPORTS '''
import demistomock as demisto
from CommonServerPython import *
import requests
from bs4 import BeautifulSoup
import urllib
import re
from distutils.version import StrictVersion
if not demisto.params()['proxy']:
del os.environ['HTTP_PROXY']
del os.environ['HTTPS_PROXY']
del os.environ['http... | mit | d7f0eaf222d7b8cf7b628d4becc57c8f | 31.660031 | 116 | 0.603976 | 3.50773 | false | false | false | false |
demisto/content | Packs/DeepInstinct/Integrations/DeepInstinct/DeepInstinct.py | 2 | 9169 | import requests
import json
from CommonServerPython import *
requests.packages.urllib3.disable_warnings()
def http_request(method, url_suffix, json=None):
"""
Helper function to perform http request
"""
try:
api_suffix = "/api/v1"
base_url = demisto.params().get('base_url')
if... | mit | 71c5b5e5f2d47d9e928c0cbc104f7970 | 26.954268 | 117 | 0.572691 | 3.698669 | false | false | false | false |
demisto/content | Packs/Zendesk/Integrations/Zendeskv2/Zendeskv2.py | 2 | 50033 | import demistomock as demisto
from CommonServerPython import *
from copy import copy
from functools import lru_cache
from urllib.parse import urlencode
from urllib3 import disable_warnings
from requests.exceptions import HTTPError
from requests import Response
from typing import Callable, Iterable, Optional, List, Unio... | mit | 7cc07bcb2af480fa1422f082376c3317 | 44.074775 | 262 | 0.586753 | 3.872224 | false | false | false | false |
demisto/content | Packs/MicrosoftTeams/Scripts/MicrosoftTeamsAsk/MicrosoftTeamsAsk_test.py | 2 | 2415 | from MicrosoftTeamsAsk import main
from CommonServerPython import entryTypes
import demistomock as demisto
import json
import pytest
def execute_command(name, args=None):
if name == 'addEntitlement':
return [
{
'Type': entryTypes['note'],
'Contents': '4404dae8-2... | mit | e23fdeffe356c8b7660f01395460806d | 29.56962 | 88 | 0.580538 | 3.767551 | false | true | false | false |
demisto/content | Packs/Campaign/Scripts/PerformActionOnCampaignIncidents/PerformActionOnCampaignIncidents_test.py | 2 | 3929 | import pytest
from PerformActionOnCampaignIncidents import *
NUM_OF_INCIDENTS = 5
INCIDENT_IDS = [str(i) for i in range(NUM_OF_INCIDENTS)]
CUSTOM_FIELDS = {
ACTION_ON_CAMPAIGN_FIELD_NAME: 'Close',
SELECT_CAMPAIGN_INCIDENTS_FIELD_NAME: INCIDENT_IDS
}
MOCKED_INCIDENT = {
'id': '100',
'CustomFields': CUS... | mit | fa2ee56f180f2c1b79084b5b980f109d | 29.223077 | 105 | 0.645202 | 3.781521 | false | true | false | false |
demisto/content | Packs/FireEyeCM/Integrations/FireEyeCM/FireEyeCM.py | 2 | 19406 | from typing import Tuple
from CommonServerPython import *
import urllib3
# Disable insecure warnings
urllib3.disable_warnings()
''' CONSTANTS '''
INTEGRATION_NAME = 'FireEye Central Management'
INTEGRATION_COMMAND_NAME = 'fireeye-cm'
INTEGRATION_CONTEXT_NAME = 'FireEyeCM'
DATE_FORMAT = '%Y-%m-%dT%H:%M:%SZ' # ISO860... | mit | cb4ad708165d11c8376550b070499029 | 40.465812 | 125 | 0.625271 | 3.595035 | false | false | false | false |
demisto/content | Packs/SingleConnect/Integrations/SingleConnect/test_data/http_responses.py | 2 | 2583 | SEARCH_SAPM_ACCOUNTS_RESPONSE = {
"searchResults": [{
"changePeriod": 7,
"comment": None,
"configName": "Linux",
"createdAt": 1649081886802,
"dbId": 147636,
"description": None,
"deviceId": "bdabee8c-fd74-4989-9e00-e00ab88c45a8",
"eventUserEid": "admin... | mit | 67b7ed1d2eaf9f9a81173d26547a16dc | 28.689655 | 73 | 0.518389 | 3.328608 | false | false | true | false |
demisto/content | Packs/RubrikPolaris/Scripts/RubrikSonarSensitiveHits/RubrikSonarSensitiveHits.py | 2 | 2532 | import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
def main() -> None:
try:
try:
sonar_context = demisto.context()["Rubrik"]["Sonar"]
# TODO - We can be more programmatic here.
hit_summary = [
{
... | mit | 2764c8df15deecc3d2e679d9d66536ec | 32.315789 | 94 | 0.432464 | 4.916505 | false | false | false | false |
nylas/nylas-python | nylas/client/restful_models.py | 1 | 32282 | from datetime import datetime
from collections import defaultdict
from enum import Enum
from six import StringIO
from nylas.client.restful_model_collection import RestfulModelCollection
from nylas.client.errors import FileUploadError, UnSyncedError, NylasApiError
from nylas.utils import timestamp_from_dt, AuthMethod
... | mit | d0bf01361d1bb90d780221f1a18fec46 | 28.86309 | 115 | 0.553683 | 3.891273 | false | false | false | false |
demisto/content | Packs/CommonScripts/Scripts/CheckSenderDomainDistance/CheckSenderDomainDistance.py | 2 | 2611 | import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
def levenshtein(s1, s2):
l1 = len(s1)
l2 = len(s2)
matrix = [list(range(l1 + 1))] * (l2 + 1)
for zz in range(l2 + 1):
matrix[zz] = list(range(zz, zz + l1 + 1))
for zz in range(0, l2):
for sz ... | mit | 2dbb194d531ae7bdd1478d64fb21b9a9 | 41.803279 | 116 | 0.503255 | 3.926316 | false | false | false | false |
demisto/content | Packs/CarbonBlackEnterpriseEDR/Integrations/CarbonBlackEnterpriseEDR/CarbonBlackEnterpriseEDR.py | 2 | 59258 | from typing import Union, Dict, Optional, Any, Tuple, List
import dateparser
import demistomock as demisto
import requests
import urllib3
from CommonServerPython import * # noqa: E402 lgtm [py/polluting-import]
from CommonServerUserPython import * # noqa: E402 lgtm [py/polluting-import]
# Disable insecure warnings... | mit | 6f2a4737533827a15ce05c5f5f351293 | 39.839421 | 120 | 0.60515 | 3.66197 | false | false | false | false |
demisto/content | Packs/CommonScripts/Scripts/CheckContextValue/CheckContextValue.py | 2 | 1435 | from typing import Dict
from CommonServerPython import *
def check_key(field_value, regex=None):
if regex:
if re.search(regex, field_value):
return True
else:
if field_value:
return True
return False
def poll_field(args: Dict[str, Any]) -> CommandResults:
key... | mit | ce48154f54503043daf2b74bad0c1528 | 25.090909 | 91 | 0.613937 | 3.756545 | false | false | false | false |
demisto/content | Packs/Gamma/Integrations/Gamma/Gamma.py | 2 | 12058 | import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
''' IMPORTS '''
import json
import urllib3
from typing import Any, Dict
from enum import Enum
# Disable insecure warnings
urllib3.disable_warnings()
'''CONSTANTS'''
MAX_INCIDENTS_TO_FETCH = 100
''' CLIENT CLASS '''
class ... | mit | e0e8b759f23d4784d92f99469fc6f386 | 30.565445 | 98 | 0.603583 | 4.042239 | false | false | false | false |
demisto/content | Packs/CaseManagement-Generic/Scripts/CaseMgmtIncidentTypesDisplay/CaseMgmtIncidentTypesDisplay.py | 2 | 1167 | import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
# check if this is a new Incident or not
incident = demisto.incident().get("id")
# if new Incident, the ID will be empty:
if not incident:
# get the XSOAR IncidentTypesFromList XSOAR List, and split on the comma
types... | mit | 575591b77447bade1141af12971fb031 | 35.46875 | 104 | 0.676093 | 3.801303 | false | false | false | false |
demisto/content | Packs/ShiftManagement/Scripts/OutOfOfficeListCleanup/OutOfOfficeListCleanup.py | 2 | 1813 | from CommonServerPython import *
def main():
# get current time
now = datetime.now()
# args
list_name = demisto.getArg("listname")
# update list name to start with 'OOO', so we can't overwrite other lists with this
if not list_name.startswith("OOO"):
list_name = f"OOO {list_name}"
... | mit | c88c298edc284e88974288539ede689e | 34.54902 | 120 | 0.612796 | 3.486538 | false | false | false | false |
demisto/content | Packs/Graylog/Integrations/Graylog/Graylog.py | 2 | 6515 | import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
''' IMPORTS '''
from datetime import datetime
import urllib3
import dateparser
# Disable insecure warnings
urllib3.disable_warnings()
def results_return(command, thingtoreturn):
results = CommandResults(
outputs_... | mit | a80089dc7c6828fbd0765c6bca44a263 | 41.305195 | 130 | 0.572832 | 4.004302 | false | false | false | false |
demisto/content | Packs/FireEyeHX/Integrations/FireEyeHX/FireEyeHX.py | 2 | 72640 | import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
"""
IMPORTS
"""
import base64
import json
import os
import re
import time
import requests
# disable insecure warnings
requests.packages.urllib3.disable_warnings()
"""
HANDLE PROXY
"""
def set_proxies():
if not demi... | mit | b035ce771b01ea3aeebd4b3542388b57 | 25.510949 | 131 | 0.506635 | 4.167288 | false | false | false | false |
demisto/content | Packs/SymantecDLP/Integrations/SymantecDLP/SymantecDLP.py | 2 | 34444 | import demistomock as demisto
from CommonServerPython import *
from CommonServerUserPython import *
''' IMPORTS '''
from requests import Session
from zeep import Client, Settings
from zeep.transports import Transport
from requests.auth import AuthBase, HTTPBasicAuth
from zeep import helpers
from zeep.cache import Sqlit... | mit | eada70bd25ba2814da0ad9845d8a8468 | 43.046036 | 120 | 0.647021 | 3.92569 | false | false | false | false |
demisto/content | Packs/Phishing/Scripts/PhishingDedupPreprocessingRule/PhishingDedupPreprocessingRule.py | 2 | 14388 | import dateutil # type: ignore
import demistomock as demisto
from CommonServerPython import *
from CommonServerUserPython import *
import pandas as pd
from bs4 import BeautifulSoup
from sklearn.feature_extraction.text import CountVectorizer
from numpy import dot
from numpy.linalg import norm
from email.utils import p... | mit | e00b6f7cd23060e371a8f16768219677 | 42.6 | 120 | 0.667918 | 3.448706 | false | false | false | false |
demisto/content | Packs/Vectra_AI/Integrations/VectraDetect/VectraDetect_test.py | 2 | 59842 | """Base Integration for Cortex XSOAR - Unit Tests file
Pytest Unit Tests: all funcion names must start with "test_"
More details: https://xsoar.pan.dev/docs/integrations/unit-testing
MAKE SURE YOU REVIEW/REPLACE ALL THE COMMENTS MARKED AS "TODO"
You must add at least a Unit Test function for every XSOAR command
you... | mit | 33dab9b4edda071192935a2ebef06f3a | 38.974616 | 128 | 0.584823 | 3.947361 | false | true | false | false |
demisto/content | Packs/GitHub/Integrations/GitHub/GitHub.py | 2 | 76746 | import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
''' IMPORTS '''
import copy
import json
from datetime import datetime
from typing import Any, Union
import codecs
import requests
import urllib3
# Disable insecure warnings
urllib3.disable_warnings()
''' GLOBALS/PARAMS '''
BAS... | mit | a9ad085b19af13dbf9c2db139d8f264f | 35.563125 | 120 | 0.609426 | 3.727887 | false | false | false | false |
demisto/content | Packs/Vectra_AI/Integrations/VectraDetect/VectraDetect.py | 2 | 93380 | """
Vectra Detect Integration for Cortex XSOAR
Developer Documentation: https://xsoar.pan.dev/docs/welcome
Code Conventions: https://xsoar.pan.dev/docs/integrations/code-conventions
Linting: https://xsoar.pan.dev/docs/integrations/linting
"""
# Python linting disabled example (disable linting on error code E203)
# no... | mit | a1037c1d2bdc45489b109fcc5246f82f | 35.081917 | 129 | 0.569297 | 4.15096 | false | false | false | false |
demisto/content | Packs/MailListener/Integrations/MailListenerV2/MailListenerV2.py | 1 | 24795 | import ssl
from datetime import timezone
from typing import Any, Dict, Tuple, List, Optional
from dateparser import parse
from mailparser import parse_from_bytes, parse_from_string
from imap_tools import OR
from imapclient import IMAPClient
import demistomock as demisto
from CommonServerPython import *
class Email(... | mit | 03f0ba67b3b857bf7ef7a718e7f4627a | 45.345794 | 125 | 0.596814 | 4.176352 | false | false | false | false |
demisto/content | Packs/SafeBreach/Scripts/JoinListsOfDicts/JoinListsOfDicts.py | 2 | 1477 | import demistomock as demisto
from itertools import product
def find_value_by_key(k, d):
if not isinstance(d, dict):
raise Exception("{} d is not a dictionary".format(d))
if k.startswith('CustomFields.'):
if 'CustomFields' not in d:
return
cf = d.get('CustomFields', None)
... | mit | 41c9bc733d80d4f948e22a309a424787 | 23.616667 | 83 | 0.560596 | 3.491726 | false | false | false | false |
demisto/content | Packs/Digital_Defense_FrontlineVM/Integrations/Digital_Defense_FrontlineVM/Digital_Defense_FrontlineVM.py | 2 | 33266 | import demistomock as demisto
from CommonServerPython import *
import json
import math
import re
import requests
import signal
import socket
import struct
from datetime import datetime, timedelta, timezone
from typing import List, Dict, Any
# disable insecure warnings
requests.packages.urllib3.disable_warnings()
# Pa... | mit | 9c1dd50893ab47b455eb311c34825735 | 40.069136 | 130 | 0.618439 | 3.565106 | false | false | false | false |
demisto/content | Packs/PassiveTotal/Scripts/RiskIQPassiveTotalSSLForSubjectEmailWidgetScript/RiskIQPassiveTotalSSLForSubjectEmailWidgetScript.py | 2 | 1613 | from CommonServerPython import *
import traceback
from typing import Dict, Union, Any
def set_arguments_for_widget_view(indicator_data: Dict[str, Any]) -> Union[Dict[str, str], str]:
"""
Prepare argument for commands or message to set custom layout of indicator
"""
indicator_type = indicator_data... | mit | 8cea2fd45537f8a281d6ee654a37f6ea | 35.659091 | 117 | 0.608184 | 4.073232 | false | false | false | false |
demisto/content | Packs/DemistoRESTAPI/Scripts/GetTasksWithSections/GetTasksWithSections.py | 2 | 6682 | from CommonServerPython import *
import copy
from itertools import chain
def find_start_task(tasks: Dict):
for task in tasks.values():
if task.get('type') == 'start':
return task
return DemistoException('No start task was configured')
def traverse_tasks(tasks: Dict[str, Dict],
... | mit | 8b3cece2808e3649fb537c747ae18a6c | 40.246914 | 113 | 0.571386 | 3.783692 | false | false | false | false |
nylas/nylas-python | nylas/client/neural_api_models.py | 1 | 6461 | from nylas.client.restful_models import RestfulModel, Message, File, Contact
from nylas.utils import HttpMethod
import re
def _add_options_to_body(body, options):
options_dict = options.__dict__
# Only append set options to body to prevent a 400 error
options_filtered = {k: v for k, v in options_dict.item... | mit | 4cdae9c457cd21f156e761aa18f34ba4 | 34.11413 | 87 | 0.625909 | 3.807307 | false | false | false | false |
demisto/content | Packs/CommonScripts/Scripts/GetEntries/GetEntries.py | 2 | 1755 | import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
def main():
try:
args = demisto.args()
ents = demisto.executeCommand('getEntries',
assign_params(id=args.get('id'),
f... | mit | 298025d25ac0c3c0a14b2ecce9d7f770 | 46.432432 | 120 | 0.506553 | 4.376559 | false | false | false | false |
demisto/content | Packs/AnsibleLinux/Integrations/AnsibleOpenSSL/AnsibleOpenSSL.py | 2 | 2837 | import ssh_agent_setup
import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
# Import Generated code
from AnsibleApiModule import * # noqa: E402
host_type = 'ssh'
# MAIN FUNCTION
def main() -> None:
"""main function, parses params and runs command functions
:return:
... | mit | 072fb94e486a5c78b2a4313523adc1e5 | 41.984848 | 113 | 0.64681 | 4.099711 | false | true | false | false |
demisto/content | Packs/Troubleshoot/Scripts/TroubleshootGetCommandandArgs/TroubleshootGetCommandandArgs.py | 2 | 3563 | """
Gets a command, validates it and outputting it to context
"""
from CommonServerPython import *
def is_command_available(instance_name: str, command: str) -> dict:
available_commands = demisto.getAllSupportedCommands()
if commands := available_commands.get(instance_name):
try:
return li... | mit | e5de805cb48bb1e49b472f5cdcdff856 | 36.904255 | 115 | 0.614931 | 3.847732 | false | false | false | false |
demisto/content | Packs/HelloWorld/Scripts/HelloWorldScript/HelloWorldScript.py | 2 | 2410 | """HelloWorld Script for Cortex XSOAR (aka Demisto)
This script is just a simple example on Code Conventions to write automation
scripts in Cortex XSOAR using Python 3.
Please follow the documentation links below and make sure that
your integration follows the Code Conventions and passes the Linting phase.
Developer ... | mit | f3fdde5d4e60d3c7a7ef095e4771ee96 | 24.368421 | 85 | 0.682573 | 3.905997 | false | false | false | false |
demisto/content | Packs/Confluera/Scripts/ConflueraDetectionsSummaryWarroom/ConflueraDetectionsSummaryWarroom.py | 2 | 1091 | from CommonServerPython import *
from CommonServerUserPython import *
from itertools import cycle
# Executes confluera-fetch-detections command/script
detections_data = demisto.executeCommand('confluera-fetch-detections', {'hours': '72'})
if detections_data[1] and detections_data[1]['Contents']:
detections = det... | mit | 811fc13339b3767d92425642bcd5b112 | 21.265306 | 87 | 0.580202 | 3.064607 | false | false | false | false |
demisto/content | Packs/ThreatExchange/Integrations/ThreatExchangeV2/ThreatExchangeV2.py | 2 | 38098 | """
An integration module for the ThreatExchange V2 API.
API Documentation:
https://developers.facebook.com/docs/threat-exchange/reference/apis
"""
import collections
from typing import Tuple
import urllib3
from CommonServerUserPython import * # noqa
from CommonServerPython import * # noqa # pylint: disable=unus... | mit | e2bf3999493dec32192e30e708bbfba0 | 38.074872 | 120 | 0.60284 | 4.052548 | false | false | false | false |
demisto/content | Packs/MitreCaldera/Scripts/CalderaPopulateEventLogs/CalderaPopulateEventLogs.py | 2 | 1723 | import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
incident = demisto.incident()
custom_fields = incident.get('CustomFields')
operation_id = custom_fields.get('calderaoperationid')
if operation_id:
results = demisto.executeCommand('caldera-get-operation-event-logs', {"operat... | mit | ceb1f1ad87cabab1b7f89076e55f8b94 | 43.179487 | 104 | 0.556007 | 4.12201 | false | false | false | false |
demisto/content | Packs/Palo_Alto_Networks_WildFire/Integrations/Palo_Alto_Networks_WildFire_v2/Palo_Alto_Networks_WildFire_v2.py | 2 | 63377 | import shutil
from typing import Callable, Tuple, Optional, List
import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
import tarfile
import io
import urllib3
# Disable insecure warnings
urllib3.disable_warnings()
''' GLOBALS/PARAMS '''
BRAND = 'WildFire-v2'
INTEGRATION_NAME = ... | mit | b7f85fd6a7163d74a9e6321aee87930e | 38.315757 | 121 | 0.565521 | 4.056647 | false | false | false | false |
demisto/content | Packs/Alexa/Integrations/Alexa/Alexa.py | 2 | 4645 | import demistomock as demisto
from CommonServerPython import *
from CommonServerUserPython import *
import xml.etree.ElementTree as ET # type: ignore
import requests
import re
# Disable insecure warnings
requests.packages.urllib3.disable_warnings()
"""COMMAND FUNCTIONS"""
def alexa_fallback_command(domain, use_ss... | mit | 8882fb3b92407b1c1d1060417c8834d8 | 35.289063 | 110 | 0.583208 | 3.606366 | false | false | false | false |
demisto/content | Packs/CommonWidgets/Scripts/FeedIntegrationErrorWidget/FeedIntegrationErrorWidget.py | 2 | 1878 | from dateparser import parse
import demistomock as demisto
from CommonServerPython import *
def get_feed_integration_errors() -> TableOrListWidget:
integration_search_res = demisto.internalHttpRequest(
'POST',
'/settings/integration/search',
'{}',
)
table = TableOrListWidget()
... | mit | 92e0b113632c9ce900bdebaf57d1177e | 37.326531 | 115 | 0.58147 | 4.287671 | false | false | false | false |
demisto/content | Packs/CommonScripts/Scripts/CompareIncidentsLabels/CompareIncidentsLabels.py | 2 | 1457 | import demistomock as demisto
from CommonServerPython import *
try:
inc1 = demisto.args().get('incident_id_1')
inc2 = demisto.args().get('incident_id_2')
res = demisto.executeCommand("getIncidents", {'id': inc1})
if any(is_error(entry) for entry in res):
return_error("Unable to fetch incident ... | mit | 4e11c649d5ef3a792c350293ce791085 | 34.536585 | 111 | 0.632121 | 3.195175 | false | false | false | false |
demisto/content | Packs/RubrikPolaris/Scripts/RubrikCDMClusterConnectionState/RubrikCDMClusterConnectionState.py | 2 | 1184 | import demistomock as demisto # noqa: F401
from CommonServerPython import *
def main() -> None:
ORANGE_HTML_STYLE = "color:#FF9000;font-size:250%;>"
GREEN_HTML_STYLE = "color:#00CD33;font-size:250%;>"
RED_HTML_STYLE = "color:#FF1744;font-size:250%;"
DIV_HTML_STYLE = "display:block;text-align:center;... | mit | 38a082a9cc77e105f8ac5127217dd58e | 34.878788 | 116 | 0.622466 | 3.217391 | false | false | false | false |
demisto/content | Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py | 2 | 126032 | from CommonServerPython import * # noqa: E402 lgtm [py/polluting-import]
# IMPORTS
from datetime import datetime
from typing import Dict, Callable, Any, List, Tuple, Union, Optional
from requests import Response
from requests.exceptions import MissingSchema, InvalidSchema
import urllib3
import contextlib
import trace... | mit | 223d92c4e68a8130a9d8bd85f90f6301 | 42.974878 | 120 | 0.627119 | 3.861866 | false | false | false | false |
demisto/content | Packs/HYASProtect/Integrations/HYASProtect/HYASProtect.py | 2 | 12114 | from CommonServerPython import *
# Disable insecure warnings
requests.packages.urllib3.disable_warnings()
# CORTEX XSOAR COMMAND CONSTANTS
INTEGRATION_NAME = 'HYAS PROTECT'
INTEGRATION_COMMAND_NAME = 'hyas'
INTEGRATION_CONTEXT_NAME = 'HYAS'
DOMAIN_VERDICT_SUB_CONTEXT = 'DomainVerdict'
IP_VERDICT_SUB_CONTEXT = "IPVerd... | mit | 1490ecb3eeed0cfb2ea50e1997ec8d32 | 34.524927 | 120 | 0.605333 | 3.779719 | false | false | false | false |
demisto/content | Packs/Slack/Integrations/SlackEventCollector/SlackEventCollector.py | 2 | 8308 | import demistomock as demisto
from CommonServerPython import *
from typing import Tuple
requests.packages.urllib3.disable_warnings()
VENDOR = "slack"
PRODUCT = "slack"
def arg_to_timestamp(value: Any) -> Optional[int]:
if isinstance(value, int):
return value
if datetime_obj := arg_to_datetime(value... | mit | 1829c248324e4a369a049fe915bff65a | 35.599119 | 111 | 0.586182 | 4.230143 | false | false | false | false |
demisto/content | Packs/CommonWidgets/Scripts/GetLargestInvestigations/GetLargestInvestigations.py | 2 | 4911 | import demistomock as demisto
from CommonServerPython import *
from CommonServerUserPython import *
import traceback
from typing import List, Dict
from operator import itemgetter
from dateutil.parser import parse
from dateutil.relativedelta import relativedelta
def get_investigations(raw_output, investigations):
... | mit | 3250ba5734816e6b8dffc4142ad9dff1 | 39.586777 | 120 | 0.608023 | 3.768995 | false | false | false | false |
demisto/content | Packs/QRadar/Integrations/QRadar/QRadar.py | 2 | 51879 | import demistomock as demisto
from CommonServerPython import *
from CommonServerUserPython import *
import os
import json
import requests
import traceback
import urllib
import re
from requests.exceptions import HTTPError, ConnectionError
from copy import deepcopy
# disable insecure warnings
requests.packages.urllib3.d... | mit | 1c6a5c4bfe63a6580f0336a98e3d9f10 | 40.206513 | 120 | 0.634534 | 3.553356 | false | false | false | false |
demisto/content | Packs/AWS-CloudTrail/Integrations/AWS-CloudTrail/AWS-CloudTrail.py | 2 | 17318 | import demistomock as demisto
from CommonServerPython import *
from CommonServerUserPython import *
import boto3
from botocore.config import Config
from botocore.parsers import ResponseParserError
import urllib3.util
from datetime import datetime, date
# Disable insecure warnings
urllib3.disable_warnings()
AWS_DEFAUL... | mit | 2d59baab36f2e6ea996a7d177c8f4fa2 | 38.359091 | 114 | 0.628421 | 3.898694 | false | false | false | false |
demisto/content | Packs/GoogleChronicleBackstory/Scripts/ChronicleDomainIntelligenceSourcesWidgetScript/ChronicleDomainIntelligenceSourcesWidgetScript.py | 2 | 1563 | import demistomock as demisto
from CommonServerPython import *
from typing import Any, Dict
import traceback
import json
def get_source_hr(source) -> Dict[str, Any]:
return {
'Category/Description': source.get('Category', ''),
'Confidence': source.get('IntRawConfidenceScore', 0),
'Normali... | mit | 48d303e9c5d256a2788d62f2f3b0b0ab | 32.978261 | 118 | 0.59245 | 4.224324 | false | false | false | false |
demisto/content | Packs/CommonScripts/Scripts/MatchRegexV2/MatchRegexV2.py | 2 | 2518 | import demistomock as demisto
from CommonServerPython import *
from typing import Dict
import re
LETTER_TO_REGEX_FLAGS = {
'i': re.IGNORECASE,
'm': re.MULTILINE,
's': re.DOTALL,
'u': re.UNICODE,
}
def parse_regex_flags(raw_flags: str = 'gim'):
"""
parse flags user input and convert them to ... | mit | f5a37e1904780c5c70e4e018e0da09e2 | 27.942529 | 94 | 0.599285 | 3.850153 | false | false | false | false |
demisto/content | Packs/Troubleshoot/Scripts/TroubleshootIsDockerImageExists/TroubleshootIsDockerImageExists.py | 2 | 1322 | """Validates that the docker image exists.
"""
from CommonServerPython import *
''' STANDALONE FUNCTION '''
def get_installed_docker_images():
res = demisto.executeCommand(
'demisto-api-get',
{'uri': 'settings/docker-images'}
)
if is_error(res):
raise DemistoException(get_error(r... | mit | b84f3ded652000738b930fee22abdcb3 | 30.47619 | 111 | 0.619516 | 3.777143 | false | false | false | false |
demisto/content | Utils/tests/comment_on_pr_test.py | 2 | 2783 | from Utils.comment_on_pr import get_pr_comments_url
github_comment_response_1 = [
{
"url": "https://api.github.com/repos/demisto/content/pulls/comments/477124055",
"body": "shtak"
},
{
"url": "https://api.github.com/repos/demisto/content/pulls/comments/477138466",
"body": "... | mit | c87f8bb1888d143b31e96d2653d98bf3 | 31.741176 | 110 | 0.621631 | 3.522785 | false | false | false | false |
demisto/content | Packs/PerceptionPoint/Integrations/PerceptionPoint/PerceptionPoint.py | 2 | 6023 | import demistomock as demisto
from CommonServerPython import *
''' IMPORTS'''
import requests
import json
from collections import defaultdict
''' INTEGRATION PARAMS '''
URL = 'http://api.perception-point.io/api/v1/{endpoint}' # disable-secrets-detection
INCIDENTS_ENDPOINT = 'scans/incidents/'
RELEASE_ENDPOINT = 'qua... | mit | 58e6bbf074e1f45630f8c34b2e8db572 | 32.276243 | 93 | 0.606176 | 3.520164 | false | false | false | false |
demisto/content | Packs/ThreatConnect/Integrations/ThreatConnect_v2/ThreatConnect_v2.py | 2 | 81869 | import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
''' IMPORTS '''
import copy
import urllib
from datetime import timedelta
from distutils.util import strtobool
from urllib.parse import quote, urlparse
from threatconnect import ThreatConnect
from threatconnect.Config.ResourceTy... | mit | de2c5b4b1f12d040a6f1cbef9c08f1e2 | 34.860272 | 130 | 0.594328 | 3.943403 | false | false | false | false |
demisto/content | Packs/Base/Scripts/FindSimilarIncidentsByText/FindSimilarIncidentsByText_test.py | 2 | 19458 | import json
from CommonServerPython import *
from FindSimilarIncidentsByText import main
import random
nouns = ['people', 'history', 'way', 'art', 'world', 'information', 'map', 'two', 'family', 'government', 'health',
'system', 'computer', 'meat', 'year', 'thanks', 'music', 'person', 'reading', 'method', 'd... | mit | 7f54989dec8d677100ce0571cbffa6c2 | 81.101266 | 120 | 0.56717 | 3.083188 | false | false | false | false |
demisto/content | Packs/HYASInsight/Integrations/HYASInsight/HYASInsight.py | 2 | 33184 | from typing import Tuple, Callable
from CommonServerPython import *
# Disable insecure warnings
requests.packages.urllib3.disable_warnings()
# CORTEX XSOAR COMMAND CONSTANTS
INTEGRATION_NAME = 'HYAS INSIGHT'
INTEGRATION_COMMAND_NAME = 'hyas'
INTEGRATION_CONTEXT_NAME = 'HYAS'
PASSIVE_DNS_SUB_CONTEXT = 'PassiveDNS'
DY... | mit | 876ab065974c2deb3fc3a395912b4951 | 35.748616 | 116 | 0.566779 | 3.761079 | false | false | false | false |
demisto/content | Packs/PolySwarm/Integrations/PolySwarmV2/PolySwarmV2_test.py | 2 | 33400 |
import demistomock as demisto
from PolySwarmV2 import PolyswarmConnector
TEST_SCAN_UUID = '95039375646493045'
TEST_SCAN_DOMAIN = ['domain-test.com']
TEST_SCAN_IP = ['0.0.0.0']
TEST_SCAN_URL = ['https://url-test.com']
TEST_HASH_FILE = '939adb211c3bcf76b84b2417e1d39248994e21d48a3d7eddca87bb76d6c31cc3'
TEST_ENTRY_ID = ... | mit | b0cb515159cb131a36cb0387a97a2b18 | 31.585366 | 162 | 0.46994 | 3.537386 | false | false | false | false |
demisto/content | Packs/GroupIB_ThreatIntelligenceAttribution/Integrations/GroupIB_TIA_Feed/GroupIB_TIA_Feed.py | 2 | 35835 | import demistomock as demisto
from CommonServerPython import *
from CommonServerUserPython import *
""" IMPORTS """
from typing import Dict, Generator, List, Optional, Tuple, Union
import dateparser
import urllib3
# Disable insecure warnings
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
''' CON... | mit | fdfc84d6dd0f27f3ccf9c3ff71dbf625 | 42.278986 | 120 | 0.50473 | 4.072622 | false | false | false | false |
demisto/content | Packs/Base/Scripts/GetIndicatorsByQuery/GetIndicatorsByQuery.py | 2 | 3913 | from CommonServerPython import *
import hashlib
PAGE_SIZE = 500
RANDOM_UUID = str(demisto.args().get('addRandomSalt', '').encode('utf8'))
# Memo for key matching
CACHE = {} # type: ignore
def hash_value(simple_value):
if not isinstance(simple_value, str):
simple_value = str(simple_value)
if simple... | mit | 256470978c4dd7e594954d1120391c27 | 31.338843 | 109 | 0.607718 | 3.450617 | false | false | false | false |
nylas/nylas-python | nylas/client/scheduler_restful_model_collection.py | 1 | 2374 | import copy
from nylas.client.restful_model_collection import RestfulModelCollection
from nylas.client.restful_models import Scheduler
from nylas.client.scheduler_models import (
SchedulerTimeSlot,
SchedulerBookingConfirmation,
)
class SchedulerRestfulModelCollection(RestfulModelCollection):
def __init__... | mit | fa0d608f0017a492963e932f7b424a30 | 35.523077 | 87 | 0.635215 | 3.976549 | false | false | false | false |
demisto/content | Packs/CommonScripts/Scripts/IsInCidrRanges/IsInCidrRanges.py | 2 | 1354 | import ipaddress
import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
def validate_cidr(cidr: str):
"""
Validates CIDR format.
"""
try:
ipaddress.ip_network(cidr)
except ValueError as e:
demisto.debug(f'Skipping "{cidr}": {e}')
return... | mit | 0e82fad9ff5ee4103e3d1f68d1b0052b | 23.618182 | 111 | 0.584195 | 3.740331 | false | false | false | false |
demisto/content | Packs/IntegrationsAndIncidentsHealthCheck/Scripts/RestartFailedTasks/RestartFailedTasks.py | 2 | 4844 | import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
def check_context():
"""
Check if GetFailedTasks is in the context, via checking if ${GetFailedTasks} exists, else fail with message.
Returns:
A list of the failed tasks generated by GetFailedTasks command.... | mit | 58934afbef18422abf11925205219d2f | 40.050847 | 121 | 0.63749 | 3.993405 | false | false | false | false |
demisto/content | Packs/PenfieldAI/Integrations/Penfield/Penfield_test.py | 2 | 1720 | import demistomock as demisto
from Penfield import main, get_assignee, Client
import json
import io
def util_load_json(path):
with io.open(path, mode='r', encoding='utf-8') as f:
return json.loads(f.read())
def test_main(mocker):
mock_users = "username1,username2"
mock_incident = util_load_json(... | mit | 242da0296aca8d1a4750faf0c9d91bde | 29.714286 | 112 | 0.644186 | 3.320463 | false | true | false | false |
demisto/content | Packs/Inventa/Integrations/Inventa/Inventa.py | 2 | 23178 | import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
"""IMPORTS"""
import traceback
from typing import Any, Dict
import requests
# Disable insecure warnings
requests.packages.urllib3.disable_warnings() # pylint: disable=no-member
''' CONSTANTS '''
DATE_FORMAT = '%Y-%m-%dT%... | mit | 19176f9292448f61f3d194a3f26c6b7c | 35.500787 | 115 | 0.585081 | 3.933809 | false | false | false | false |
demisto/content | Packs/Malware/Scripts/CreateHashIndicatorWrapper/CreateHashIndicatorWrapper_test.py | 2 | 5117 | """Base Script for Cortex XSOAR - Unit Tests file
Pytest Unit Tests: all funcion names must start with "test_"
More details: https://xsoar.pan.dev/docs/integrations/unit-testing
"""
import pytest
import CommonServerPython
import CreateHashIndicatorWrapper
test_data = [CommonServerPython.CommandRunner.Result(command... | mit | 8abc480146b4404cfb1c1a8ebd13c2f1 | 49.166667 | 115 | 0.500293 | 4.453438 | false | true | false | false |
demisto/content | Packs/DemistoRESTAPI/Scripts/GetTasksWithSections/GetTasksWithSections_test.py | 2 | 1699 | import json
from GetTasksWithSections import traverse_tasks, find_start_task, get_tasks_and_readable
def load_json(file):
with open(file, 'r') as f:
return json.load(f)
tasks = load_json('test_data/tasks_example.json')
def test_find_start_task():
"""
Given:
tasks from `/investigation/{... | mit | 9d75aaba31ac522a2ad23ba0a1dc18d4 | 33.673469 | 111 | 0.598587 | 3.503093 | false | true | false | false |
demisto/content | Packs/BitDam/Integrations/BitDam/BitDam.py | 1 | 7422 | import demistomock as demisto
from CommonServerPython import *
'''IMPORTS'''
import requests
import base64
import urllib3
urllib3.disable_warnings()
'''INTEGRATION PARAMS'''
API_TOKEN = demisto.params().get('apitoken')
URL_BASE = demisto.params().get('url')
USE_PROXY = demisto.params().get('proxy', False)
UNSECURE = ... | mit | 67aea7fc97a964ef2254915f71742023 | 31.41048 | 126 | 0.638911 | 3.525891 | false | false | false | false |
demisto/content | Packs/ShiftManagement/Scripts/GetShiftsPerUser/GetShiftsPerUser.py | 2 | 3409 | import demistomock as demisto
from CommonServerPython import *
from CommonServerUserPython import *
from typing import List
HOURS_DAYS_HEADER = 'Hours / Days'
SUNDAY_HEADER = 'Sunday'
MONDAY_HEADER = 'Monday'
TUESDAY_HEADER = 'Tuesday'
WEDNESDAY_HEADER = 'Wednesday'
THURSDAY_HEADER = 'Thursday'
FRIDAY_HEADER = 'Friday... | mit | 5e62a85650b05aa796126586435e8f44 | 30.859813 | 77 | 0.584042 | 3.136155 | false | false | false | false |
demisto/content | Packs/GoogleChronicleBackstory/Integrations/GoogleChronicleBackstory/GoogleChronicleBackstory.py | 2 | 153681 | """Main file for GoogleChronicleBackstory Integration."""
from CommonServerPython import *
from collections import defaultdict
from typing import Any, Dict, Tuple, List
import httplib2
import urllib.parse
from oauth2client import service_account
from copy import deepcopy
import dateparser
from hashlib import sha256
fr... | mit | 05bbcdd5bc5f8e58f118fa778bff742e | 38.537175 | 126 | 0.639832 | 3.714883 | false | false | false | false |
demisto/content | Packs/Bonusly/Scripts/IncOwnerToBonuslyUser/IncOwnerToBonuslyUser.py | 2 | 1159 | import demistomock as demisto
from CommonServerPython import *
"""
Pass in JSON key value lookup then fetches the incident owner and finds the bonusly user
"""
json_lookup = demisto.args().get('json')
if isinstance(json_lookup, str):
json_lookup = json.loads(json_lookup)
def inc_owner_bonusly_user():
owner... | mit | b5ebd3c2957965146fbef64a4a629946 | 36.387097 | 110 | 0.648835 | 3.621875 | false | false | false | false |
demisto/content | Packs/MicrosoftGraphCalendar/Integrations/MicrosoftGraphCalendar/MicrosoftGraphCalendar.py | 2 | 22665 | from CommonServerPython import *
from typing import List, Dict, Tuple, Union
import urllib3
# Disable insecure warnings
urllib3.disable_warnings()
INTEGRATION_CONTEXT_NAME = 'MSGraphCalendar'
DEFAULT_PAGE_SIZE = 100
NO_OUTPUTS: dict = {}
APP_NAME = 'ms-graph-calendar'
EVENT_HEADERS = ['Subject', 'Organizer', 'Attende... | mit | dcf05e840fef68c0dd26cb1b7a9c0b31 | 39.545617 | 120 | 0.627355 | 3.908432 | false | false | false | false |
demisto/content | Packs/Campaign/Scripts/GetCampaignDuration/GetCampaignDuration.py | 2 | 2227 | from datetime import datetime
import dateutil.parser
import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
import pytz
utc = pytz.UTC
class FieldNotFound(Exception):
pass
def get_duration_html():
try:
incident_id = demisto.incident().get('id', {})
conte... | mit | bb99954d043c2f364491dbf8c8b894a8 | 33.796875 | 102 | 0.546026 | 3.72408 | false | false | false | false |
nylas/nylas-python | nylas/client/authentication_models.py | 1 | 10378 | from copy import copy
from nylas.client.restful_model_collection import RestfulModelCollection, CHUNK_SIZE
from nylas.client.restful_models import NylasAPIObject
from nylas.utils import AuthMethod
from enum import Enum
class Integration(NylasAPIObject):
attrs = (
"name",
"provider",
"expi... | mit | 0327afa3d4e0b2a5606c02ec279ae8e1 | 28.651429 | 121 | 0.580362 | 4.276061 | false | false | false | false |
demisto/content | Packs/Cisco-umbrella/Integrations/Cisco-umbrella-investigate/Cisco-umbrella-investigate.py | 2 | 72439 | from requests import RequestException
from CommonServerPython import *
''' IMPORTS '''
import sys
import requests
import json
import time
import re
import urllib.request
import urllib.parse
import urllib.error
from urllib.parse import urlparse
from distutils.util import strtobool
from datetime import datetime, timed... | mit | d0f732aadacdba0b0a6dd9b58d3397a3 | 36.129165 | 128 | 0.568009 | 4.246131 | false | false | false | false |
demisto/content | Templates/Integrations/DataEnrichmentThreatIntelligence/DataEnrichmentThreatIntelligence.py | 2 | 12274 | from CommonServerPython import *
from CommonServerUserPython import *
import demistomock as demisto
''' IMPORTS '''
from typing import Dict, Tuple, Optional, List, Union
import urllib3
# Disable insecure warnings
urllib3.disable_warnings()
"""GLOBALS/PARAMS
Attributes:
INTEGRATION_NAME:
Name of the integ... | mit | ae7fdfe7f033e15ed36c578aceedb2d2 | 31.557029 | 104 | 0.603471 | 3.903944 | false | false | false | false |
demisto/content | Packs/StarterPack/Scripts/BaseScript/BaseScript.py | 2 | 1922 | """Base Script for Cortex XSOAR (aka Demisto)
This is an empty script with some basic structure according
to the code conventions.
MAKE SURE YOU REVIEW/REPLACE ALL THE COMMENTS MARKED AS "TODO"
Developer Documentation: https://xsoar.pan.dev/docs/welcome
Code Conventions: https://xsoar.pan.dev/docs/integrations/code-... | mit | 9ab1615cc96bf0e3ca2ed3463f2383f6 | 23.961039 | 76 | 0.692508 | 3.768627 | false | false | false | false |
demisto/content | Packs/GenericWebhook/Integrations/GenericWebhook/GenericWebhook.py | 2 | 7307 | from collections import deque
from copy import copy
from secrets import compare_digest
from tempfile import NamedTemporaryFile
from traceback import format_exc
from typing import Dict
import uvicorn
from fastapi import Depends, FastAPI, Request, Response, status
from fastapi.security import HTTPBasic, HTTPBasicCredent... | mit | 1a9fcef83c39aedab7f9e9d17af075fc | 40.517045 | 118 | 0.596962 | 4.293184 | false | false | false | false |
demisto/content | Packs/IntegrationsAndIncidentsHealthCheck/Scripts/IntegrationsCheck_Widget_IntegrationsCategory/IntegrationsCheck_Widget_IntegrationsCategory_test.py | 2 | 1151 | import pytest
import demistomock as demisto
from IntegrationsCheck_Widget_IntegrationsCategory import main, random
@pytest.mark.parametrize('list_, expected', [
([{
'Contents': 'Data Enrichment & Threat Intelligence,Vulnerability Management,Endpoint,Forensics & Malware '
'Analysis,Data... | mit | cba8c85d107db99860c90db67bb6e94d | 45.04 | 114 | 0.61338 | 3.34593 | false | true | false | false |
demisto/content | Packs/Anomali_ThreatStream/Integrations/Anomali_ThreatStream_v2/Anomali_ThreatStream_v2_test.py | 2 | 7319 | import os
import json
import demistomock as demisto
from tempfile import mkdtemp
from Anomali_ThreatStream_v2 import main, file_name_to_valid_string, get_file_reputation, Client, get_indicators
import emoji
import pytest
def util_load_json(path):
with open(path, mode='r', encoding='utf-8') as f:
return js... | mit | 53c112bbd8610b0d66d78241bb5347ce | 33.15566 | 121 | 0.595084 | 3.329195 | false | true | false | false |
demisto/content | Packs/Cryptosim/Integrations/Cryptosim/Cryptosim.py | 2 | 9557 | from datetime import datetime, timedelta
from CommonServerPython import *
from CommonServerUserPython import *
import traceback
import json
import base64
import requests
# Disable insecure warnings
requests.packages.urllib3.disable_warnings() # pylint: disable=no-member
''' CONSTANTS '''
DATE_FORMAT = '%Y-%m-%dT%H:... | mit | 5bb226723010e7b0b174dd16c377cfdd | 34.265683 | 113 | 0.607617 | 3.877079 | false | false | false | false |
demisto/content | Packs/UrlScan/Integrations/UrlScan/UrlScan_test.py | 1 | 3497 | import json
import time
from threading import Thread
import pytest
import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
RETURN_ERROR_TARGET = 'UrlScan.return_error'
SCAN_URL = 'https://urlscan.io/api/v1/scan/'
RESULT_URL = 'https://urlscan.io/api/v1/result/'
@pytest.mark.param... | mit | 76fd4f1356d874ac4942daf05b763ced | 33.623762 | 114 | 0.670861 | 3.586667 | false | true | false | false |
houtianze/bypy | bypy/chkreq.py | 1 | 2258 | #!/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
from . import gvar
from .util import (iswindows, fixenc, bannerwar... | mit | fed97ee976b3238562ff038ca6c82487 | 32.641791 | 90 | 0.700976 | 3.091907 | false | false | false | false |
ckan/ckanext-archiver | ckanext/archiver/model.py | 1 | 6686 | import itertools
from builtins import str
from builtins import object
import uuid
from datetime import datetime
from sqlalchemy import Column, MetaData
from sqlalchemy import types
from sqlalchemy.ext.declarative import declarative_base
import ckan.model as model
from ckan.lib import dictization
log = __import__('l... | mit | e658e5d4fbcc7906bb2ce46ea90c09f6 | 31.935961 | 99 | 0.618456 | 3.921408 | false | false | false | false |
ckan/ckanext-archiver | ckanext/archiver/reports.py | 1 | 11263 | import copy
try:
from collections import OrderedDict # from python 2.7
except ImportError:
from sqlalchemy.util import OrderedDict
from ckan.common import _
import ckan.model as model
import ckan.plugins as p
from ckanext.report import lib
def broken_links(organization, include_sub_organizations=False):
... | mit | 7a59b56b918bab9837a73de15e3b2822 | 41.183521 | 124 | 0.603392 | 4.029696 | false | false | false | false |
ckan/ckanext-archiver | ckanext/archiver/tests/mock_flask_server.py | 1 | 3367 | import os
from flask import Flask, request, make_response
def create_app():
app = Flask(__name__)
@app.route('/', defaults={"path": ""})
@app.route('/<path:path>')
def echo(path):
status = int(request.args.get('status', 200))
content = request.args.get('content', '')
if 'con... | mit | 41eb226af8c7fac6864f4553f5cd0937 | 28.025862 | 77 | 0.531037 | 3.770437 | false | false | false | false |
igordejanovic/parglare | tests/perf/test_mem.py | 1 | 3119 | # -*- coding: utf-8 -*-
#######################################################################
# Testing memory utilization. This is used for the purpose of testing
# of performance gains/loses for various approaches.
# Author: Igor R. Dejanovic <igor DOT dejanovic AT gmail DOT com>
# Copyright: (c) 2021 Igor R. Dej... | mit | e87f4481a5f3a3909f215bd911f20150 | 36.130952 | 78 | 0.503366 | 3.785194 | false | true | false | false |
igordejanovic/parglare | parglare/grammar.py | 1 | 71345 | # -*- coding: utf-8 -*-
from os import path
import re
import itertools
import copy
from collections import Counter
from parglare.exceptions import GrammarError, ParserInitError
from parglare.actions import pass_single, pass_none, collect, collect_sep
from parglare.common import Location, load_python_module
from parglar... | mit | efb1093e2768632a3cc25bbae7e12597 | 35.234129 | 99 | 0.554699 | 4.225348 | false | false | false | false |
igordejanovic/parglare | parglare/tables/__init__.py | 1 | 32183 | import logging
import os
from collections import OrderedDict
from itertools import chain
from parglare.grammar import ProductionRHS, AUGSYMBOL, \
ASSOC_LEFT, ASSOC_RIGHT, STOP, StringRecognizer, RegExRecognizer, \
Grammar, EMPTY, NonTerminal, DEFAULT_PRIORITY
from parglare.exceptions import GrammarError, SRConf... | mit | e9f47fc30ed43325eeb0746f6ab1372a | 37.728039 | 81 | 0.527732 | 4.551407 | false | false | false | false |
igordejanovic/parglare | tests/func/grammar/test_keywords.py | 1 | 2657 | """
Test special KEYWORD rule.
"""
# -*- coding: utf-8 -*-
import pytest
from parglare import Parser, Grammar, RegExRecognizer, StringRecognizer
from parglare.exceptions import GrammarError, ParseError
def test_keyword_must_be_regex():
grammar = r"""
S: "for" name=ID "=" from=INT "to" to=INT;
terminals
... | mit | 1f09e06192a4326e40f027702055f47b | 24.796117 | 73 | 0.621001 | 3.312968 | false | true | false | false |
igordejanovic/parglare | tests/func/parsing/test_parsing.py | 1 | 1111 | # -*- coding: utf-8 -*-
import pytest
from os.path import join, dirname
from parglare import Parser, Grammar
from ..grammar.expression_grammar import get_grammar
from parglare.exceptions import ParseError
def test_parsing():
grammar = get_grammar()
p = Parser(grammar)
assert p.parse("id+id+id")
def test... | mit | 540fd70933c3455efed8bc158b49bf35 | 23.688889 | 73 | 0.627363 | 3.450311 | false | true | false | false |
flasgger/flasgger | examples/base_model_view.py | 2 | 1773 | """
A test to ensure that MethodView inheritance works as expected
"""
from flask import Flask, jsonify
from flask.views import MethodView
from flasgger import Swagger
class BaseAPIView(MethodView):
"""BAse view"""
class ModelAPIView(BaseAPIView):
"""Model api view"""
class PostAPIView(ModelAPIView):
... | mit | 039a4a2627e3189357b60b28395ce519 | 22.328947 | 69 | 0.48731 | 4.366995 | false | false | false | false |
flasgger/flasgger | examples/restful.py | 3 | 3993 | """
Example of Flask RESTFul integration.
requires: `pip install flask-restful`
"""
from flask import Flask
from flask_restful import Api, Resource, abort, reqparse
from flasgger import Swagger, swag_from
app = Flask(__name__)
api = Api(app)
app.config['SWAGGER'] = {
'title': 'Flasgger RESTful',
'uiversion': ... | mit | 11c2464e48107a02fa27471cd8b03ff9 | 22.488235 | 67 | 0.490358 | 4.049696 | false | false | false | false |
flasgger/flasgger | examples/colors.py | 1 | 2133 | """
The simple example using declared definitions.
"""
from flask import Flask, jsonify
from flasgger import Swagger, utils
app = Flask(__name__)
app.config['SWAGGER'] = {
'title': 'Colors API'
}
Swagger(app)
@app.route('/colors/<palette>/')
def colors(palette):
"""Example endpoint return a list of colors ... | mit | 9a9d8cabd678ea13a70f1e83475af909 | 22.966292 | 77 | 0.56962 | 3.942699 | false | false | false | false |
xflr6/graphviz | graphviz/piping.py | 1 | 6976 | """Pipe DOT code objects through Graphviz ``dot``."""
import codecs
import logging
import typing
from . import _tools
from . import backend
from . import exceptions
from . import base
from . import encoding
__all__ = ['Pipe']
log = logging.getLogger(__name__)
class Pipe(encoding.Encoding, base.Base, backend.Pipe... | mit | 904bfe09f1d53a8ee50ea801d203431a | 42.329193 | 88 | 0.493693 | 4.807719 | false | false | false | false |
xflr6/graphviz | graphviz/quoting.py | 1 | 6343 | """Quote strings to be valid DOT identifiers, assemble quoted attribute lists."""
import functools
import re
import typing
import warnings
from . import _tools
from . import exceptions
__all__ = ['quote', 'quote_edge',
'a_list', 'attr_list',
'escape', 'nohtml']
# https://www.graphviz.org/doc/i... | mit | 083a01a792134a028ea896cb21f79627 | 27.701357 | 95 | 0.539177 | 3.645402 | false | false | false | false |
xflr6/graphviz | graphviz/backend/execute.py | 1 | 4382 | """Run subprocesses with ``subprocess.run()`` and ``subprocess.Popen()``."""
import errno
import logging
import os
import subprocess
import sys
import typing
from .. import _compat
__all__ = ['run_check', 'ExecutableNotFound', 'CalledProcessError']
log = logging.getLogger(__name__)
BytesOrStrIterator = typing.Un... | mit | 9f35c184403412aaae6c91e8d7f9e09a | 31.459259 | 113 | 0.610908 | 4.177312 | false | false | false | false |
xflr6/graphviz | tests/_common.py | 1 | 1501 | """Test helpers and test globals."""
import contextlib
import os
import pathlib
import platform
import subprocess
from graphviz import _compat
__all__ = ['EXPECTED_DOT_BINARY',
'EXPECTED_UNFLATTEN_BINARY',
'EXPECTED_DEFAULT_ENGINE',
'EXPECTED_DEFAULT_ENCODING',
'INVALID_CM... | mit | e563b90e9554e3d53475658e37f40e1d | 25.333333 | 82 | 0.673551 | 3.780856 | false | false | false | false |
xflr6/graphviz | graphviz/jupyter_integration.py | 1 | 4339 | """Display rendered graph as SVG in Jupyter Notebooks and QtConsole."""
import typing
from . import piping
__all__ = ['JUPYTER_FORMATS',
'SUPPORTED_JUPYTER_FORMATS', 'DEFAULT_JUPYTER_FORMAT',
'get_jupyter_format_mimetype',
'JupyterIntegration']
_IMAGE_JPEG = 'image/jpeg'
JUPYTER_FO... | mit | 3dc7f1247dd182b566f7058033b7d11d | 37.741071 | 180 | 0.587923 | 3.786213 | false | false | false | false |
xflr6/graphviz | graphviz/unflattening.py | 1 | 2435 | """Pipe source through the Graphviz *unflatten* preprocessor."""
import typing
import graphviz
from . import _tools
from . import base
from . import backend
from . import encoding
__all__ = ['Unflatten']
class Unflatten(encoding.Encoding, base.Base, backend.Unflatten):
"""Pipe source through the Graphviz *unfl... | mit | e98580fb92b8408c87bb59dbe6fa09da | 37.650794 | 81 | 0.55729 | 4.909274 | false | false | false | false |
thumbor/thumbor | thumbor/loaders/__init__.py | 1 | 1322 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# thumbor imaging service
# https://github.com/thumbor/thumbor/wiki
# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com thumbor@googlegroups.com
from typing import Dict
class LoaderResult:
ERROR_NOT_FOUND =... | mit | e2e762c2fa4ac2520fc1187a1d82aee0 | 23.036364 | 70 | 0.59531 | 4.144201 | false | false | false | false |
thumbor/thumbor | tests/handlers/test_healthcheck.py | 4 | 1698 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# thumbor imaging service
# https://github.com/thumbor/thumbor/wiki
# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com thumbor@googlegroups.com
from preggy import expect
from tornado.testing import gen_test
from... | mit | cb160e054dc30687db1709f14f72362a | 29.872727 | 74 | 0.685512 | 3.683297 | false | true | false | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.