repo_name
stringlengths
7
65
path
stringlengths
5
186
copies
stringlengths
1
4
size
stringlengths
4
6
content
stringlengths
941
973k
license
stringclasses
14 values
hash
stringlengths
32
32
line_mean
float64
5
100
line_max
int64
26
999
alpha_frac
float64
0.25
0.93
ratio
float64
1.5
7.35
autogenerated
bool
1 class
config_or_test
bool
2 classes
has_no_keywords
bool
2 classes
has_few_assignments
bool
1 class
uccser/cs-unplugged
csunplugged/config/settings/production.py
1
2797
# -*- coding: utf-8 -*- """ Django settings for production environment. - Load secret values from files. """ from .base import * # noqa: F403 # TODO: Review # See https://docs.djangoproject.com/en/1.10/ref/settings/ ALLOWED_HOSTS = ["*"] with open(env("DEPLOYMENT_ENVIRONMENT_FILE")) as file: # noqa: F405 DEP...
mit
8e09d5b59fbda82ab4c9ca1f3687b11e
37.315068
112
0.621023
3.382104
false
true
false
false
spyder-ide/spyder-terminal
spyder_terminal/server/tests/print_size.py
2
2721
#!/usr/bin/env python """ Print console size on UNIX and Windows systems. Taken from: https://gist.github.com/jtriley/1108174 """ import os import shlex import struct import platform import subprocess def get_terminal_size(): """ Get width and height of console. Works on Linux, OS X, Windows and Cygwi...
mit
8224f39e9a6e999ab959da21b440fcf9
26.21
87
0.567438
3.529183
false
false
false
false
uccser/cs-unplugged
csunplugged/tests/resources/generators/test_sorting_network_cards.py
1
4550
from django.http import QueryDict from django.test import tag from resources.generators.SortingNetworkCardsResourceGenerator import SortingNetworkCardsResourceGenerator from tests.resources.generators.utils import BaseGeneratorTest @tag("resource") class SortingNetworkCardsResourceGeneratorTest(BaseGeneratorTest): ...
mit
8f88d5b85acc98996a37c1d1358fc0f0
34.271318
106
0.642637
4.117647
false
true
false
false
uccser/cs-unplugged
csunplugged/at_home/migrations/0003_auto_20200513_0011.py
1
3245
# Generated by Django 2.2.12 on 2020-05-13 00:11 import django.contrib.postgres.fields from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('at_home', '0002_auto_20200506_2051'), ] operations = [ migrations.Cr...
mit
0c387438a3ee474f96dca4eef01a689b
50.507937
153
0.577504
4.298013
false
false
false
false
uccser/cs-unplugged
csunplugged/tests/resources/generators/test_parity_cards.py
1
3199
from django.http import QueryDict from django.test import tag from resources.generators.ParityCardsResourceGenerator import ParityCardsResourceGenerator from tests.resources.generators.utils import BaseGeneratorTest @tag("resource") class ParityCardsResourceGeneratorTest(BaseGeneratorTest): def __init__(self, *a...
mit
466fa81756019941c79f6f5c79d1481c
31.979381
90
0.628321
4.034048
false
true
false
false
lipis/github-stats
main/model/base.py
15
1201
# coding: utf-8 from __future__ import absolute_import from google.appengine.ext import ndb from marshmallow import validate from webargs.flaskparser import parser from webargs import fields as wf from api import fields import config import util class Base(ndb.Model): created = ndb.DateTimeProperty(auto_now_add=...
mit
adca5ca343f74d48c9f1feefe3f61c30
25.688889
93
0.680266
3.511696
false
false
false
false
lipis/github-stats
run.py
1
10912
#!/usr/bin/env python # coding: utf-8 from datetime import datetime from distutils import spawn import argparse import json import os import platform import shutil import socket import sys import urllib import urllib2 __version__ = '6.2.1' ############################################################################...
mit
05afb640c1a272489de20339dbd8f738
27.416667
90
0.587702
3.40787
false
false
false
false
uccser/cs-unplugged
csunplugged/tests/at_a_distance/views/test_lesson_file_generation_view.py
1
1149
from django.conf import settings from django.test import override_settings from django.urls import reverse from tests.BaseTestWithDB import BaseTestWithDB from tests.at_a_distance.AtADistanceTestDataGenerator import AtADistanceTestDataGenerator TEST_TEMPLATES = settings.TEMPLATES TEST_TEMPLATES[0]["DIRS"].append("test...
mit
ee51c7753b2ade1e473f580671a61777
36.064516
89
0.690165
3.908163
false
true
false
false
uccser/cs-unplugged
csunplugged/topics/migrations/0091_auto_20180822_0222.py
1
5667
# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-22 02:22 from __future__ import unicode_literals import django.contrib.postgres.fields.jsonb from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('topics', '0090_auto_20180727_0031'), ] ...
mit
7f0298b60c55521773fba9c9f35bc9b4
34.198758
90
0.550909
4.483386
false
false
false
false
uccser/cs-unplugged
csunplugged/tests/resources/generators/test_binary_cards_small.py
1
9348
from django.http import QueryDict from django.test import tag from resources.generators.BinaryCardsSmallResourceGenerator import BinaryCardsSmallResourceGenerator from tests.resources.generators.utils import BaseGeneratorTest @tag("resource") class BinaryCardsSmallResourceGeneratorTest(BaseGeneratorTest): def __...
mit
6a219fbc16e7788e7b71584acbe80938
42.078341
102
0.647197
3.718377
false
true
false
false
jewettaij/moltemplate
examples/coarse_grained/DNA_models/dsDNA_only/2strands/3bp_2particles/simple_dna_example/measure_torsional_persistence_length/merge_lines_periodic.py
4
10846
#!/usr/bin/env python import sys, math g_filename = __file__.split('/')[-1] g_module_name = g_filename g_program_name = g_filename if g_filename.rfind('.py') != -1: g_module_name = g_filename[:g_filename.rfind('.py')] g_date_str = '2020-1-19' g_version_str = '0.3.0' usage_example = g_program_name + """...
mit
17984489aa310e279f151bb4937e6154
32.68323
104
0.51466
3.810963
false
false
false
false
jewettaij/moltemplate
moltemplate/renumber_DATA_first_column.py
2
2298
#!/usr/bin/env python # Author: Andrew Jewett (jewett.aij at g mail) # License: MIT License (See LICENSE.md) # Copyright (c) 2013 """ renumber the integers at the beginning of ever line in the file to make sure these numbers are contiguous. The file is read from sys.stdin. This program does not parse an ...
mit
39fea6715f7f40c587e23d56e534374e
27.725
82
0.599652
3.466063
false
false
false
false
gawel/irc3
irc3/rfc.py
1
4399
# -*- coding: utf-8 -*- from re import compile from ._rfc import * # NOQA _re_params = compile(r'P<([^>]+)>') def _extract_params(regexp): """extract parameters from regexp""" params = _re_params.findall(regexp) if params and params[0] == 'tags': params.pop(0) params.append('tags') r...
mit
58b1bd4d7fe143a7ef2898150d4b910b
26.322981
79
0.438736
2.56352
false
false
false
false
miguelgrinberg/python-engineio
src/engineio/socket.py
1
10299
import sys import time from . import exceptions from . import packet from . import payload class Socket(object): """An Engine.IO socket.""" upgrade_protocols = ['websocket'] def __init__(self, server, sid): self.server = server self.sid = sid self.queue = self.server.create_queue...
mit
e9f3803626b8d6c0775c6030a7d3323f
38.611538
79
0.533741
4.677112
false
false
false
false
iclab/centinel
centinel/experiments/baseline.py
2
12324
# # Abbas Razaghpanah (arazaghpanah@cs.stonybrook.edu) # February 2015, Stony Brook University # # baseline.py: baseline experiment that runs through # lists of URLs and does HTTP + DNS + traceroute for # every URL in the list. This is done concurrently # for each test. # # Input files can be either simple URL lists or...
mit
60b3e58f734e2b0486f6e05487d1a085
37.154799
119
0.534404
4.476571
false
false
false
false
iclab/centinel
centinel/primitives/dnslib.py
2
10650
from base64 import b64encode import dns.rdatatype import dns.message import dns.resolver import logging import select import socket import threading import time MAX_THREAD_START_RETRY = 10 THREAD_START_DELAY = 3 def get_ips(host, nameserver=None, record="A"): nameservers = [] if nameserver is not None: ...
mit
2b084518ba69497a5daf108ca935074e
38.298893
146
0.548732
4.537708
false
false
false
false
yourlabs/django-autocomplete-light
test_project/select2_nestedadmin/migrations/0001_initial.py
1
2003
# Generated by Django 2.0.6 on 2018-06-08 15:51 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='TModelOne', fields=[ ...
mit
936d8fe085fcc4e903430fc450a60e18
39.877551
178
0.587619
4.104508
false
false
false
false
iclab/centinel
centinel/utils.py
1
3560
from base64 import urlsafe_b64encode import glob import hashlib import os.path # Use this list to randomly choose a User-Agent string , updated Dec 4 2018 user_agent_pool = [ # Chrome "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36", # Ch...
mit
bfefd42fcfc13b037dbd0dceae83d104
38.555556
139
0.657022
3.293247
false
false
false
false
yourlabs/django-autocomplete-light
src/dal/widgets.py
1
6468
"""Autocomplete widgets bases.""" import copy import json from dal import forward from django import VERSION from django import forms try: from django.urls import reverse except ImportError: from django.core.urlresolvers import reverse from django.utils.safestring import mark_safe import six class WidgetM...
mit
592cd99b95138f0da0bc16e5aa38cb4e
33.222222
81
0.604205
4.291971
false
false
false
false
iclab/centinel
centinel/daemonize.py
3
2682
#!/usr/bin/python # # daemonize.py: functionality to make centinel run in the background import os import shutil import stat import tempfile def create_script_for_location(content, destination): """Create a script with the given content, mv it to the destination, and make it executable Parameters: c...
mit
852e74b323e0841d4af3530679538c04
32.525
78
0.602163
4.107198
false
false
false
false
usgo/agagd
agagd/agagd_core/tables/all_tournaments.py
1
1478
import agagd_core.defaults.styles.django_tables2 as django_tables2_styles import agagd_core.models as agagd_models import django_tables2 as tables class AllTournamentsTable(tables.Table): tournament_date = tables.Column(verbose_name="Date") description = tables.Column( verbose_name="Name", lin...
mit
1706ece2f706b27d5e38839362287505
34.190476
85
0.639378
3.799486
false
false
false
false
usgo/agagd
agagd/agagd_core/tables/top_players.py
1
1316
import agagd_core.models as agagd_models import django_tables2 as tables default_bootstrap_header_column_attrs = { "class": "table", "thead": {"class": "thead-dark"}, "th": {"scope": "col"}, } class TopDanTable(tables.Table): pin_player = tables.Column( orderable=False, linkify={ ...
mit
abb07e3e0aab3d74cd23a3603064aea1
27.608696
56
0.604103
3.635359
false
false
false
false
pytest-dev/execnet
execnet/script/shell.py
2
2487
#! /usr/bin/env python # -*- coding: utf-8 -*- """ a remote python shell for injection into startserver.py """ import os import select import socket import sys from threading import Thread from traceback import print_exc def clientside(): print("client side starting") host, port = sys.argv[1].split(":") ...
mit
c637d1f320fc622226396eb53553f5c6
26.94382
81
0.517893
4.251282
false
false
false
false
pytest-dev/execnet
execnet/script/socketserver.py
1
3833
#! /usr/bin/env python # -*- coding: utf-8 -*- """ start socket based minimal readline exec server it can exeuted in 2 modes of operation 1. as normal script, that listens for new connections 2. via existing_gateway.remote_exec (as imported module) """ # this part of the program only executes on the...
mit
3c314a353580199dddf8d0fe005c49b6
26.378571
79
0.604226
3.776355
false
false
false
false
hhatto/autopep8
test/suite/out/W19.py
1
2754
#: W191 if False: print # indented with 1 tab #: #: W191 y = x == 2 \ or x == 3 #: E101 W191 if ( x == ( 3 ) or y == 4): pass #: E101 W191 if x == 2 \ or y > 1 \ or x == 3: pass #: E101 W191 if x == 2 \ or y > 1 \ or x == 3: pass #: ...
mit
c050fc444b7e92bb8136f98394e0be28
17.238411
93
0.563181
3.036384
false
false
false
false
hhatto/autopep8
test/suite/E22.py
9
1904
#: E221 a = 12 + 3 b = 4 + 5 #: E221 E221 x = 1 y = 2 long_variable = 3 #: E221 E221 x[0] = 1 x[1] = 2 long_variable = 3 #: E221 E221 x = f(x) + 1 y = long_variable + 2 z = x[0] + 3 #: E221:3:14 text = """ bar foo %s""" % rofl #: Okay x = 1 y = 2 lon...
mit
267deae59409538a969d7d5be3f604cf
11.526316
44
0.465861
2.083151
false
false
false
false
mfenniak/heroku-buildpack-python-libffi
vendor/pip-1.3.1/pip/util.py
63
21828
import sys import shutil import os import stat import re import posixpath import pkg_resources import zipfile import tarfile import subprocess import textwrap from pip.exceptions import InstallationError, BadCommand, PipError from pip.backwardcompat import(WindowsError, string_types, raw_input, ...
mit
2428fa796f753087e799101e48aa4529
31.676647
113
0.575087
3.909726
false
false
false
false
mfenniak/heroku-buildpack-python-libffi
vendor/distribute-0.6.36/setuptools/command/bdist_wininst.py
136
1548
from distutils.command.bdist_wininst import bdist_wininst as _bdist_wininst import os, sys class bdist_wininst(_bdist_wininst): def create_exe(self, arcname, fullname, bitmap=None): _bdist_wininst.create_exe(self, arcname, fullname, bitmap) dist_files = getattr(self.distribution, 'dist_files', [])...
mit
6d13078f8162d151095a7e090f69c39f
36.756098
75
0.556848
4.095238
false
false
false
false
mfenniak/heroku-buildpack-python-libffi
vendor/pip-1.3.1/pip/commands/list.py
63
5403
from pip.basecommand import Command from pip.exceptions import DistributionNotFound, BestVersionAlreadyInstalled from pip.index import PackageFinder from pip.log import logger from pip.req import InstallRequirement from pip.util import get_installed_distributions, dist_is_editable from pip.cmdoptions import make_option...
mit
c99e205b9ac9ae9ffdfa0d75f27b8da0
39.931818
108
0.605589
4.244305
false
false
false
false
mfenniak/heroku-buildpack-python-libffi
test/distutils/envoy.py
79
4802
# -*- coding: utf-8 -*- """ envoy.core ~~~~~~~~~~ This module provides envoy awesomeness. Copyright 2012, Kenneth Reitz. MIT Licensed. """ import os import shlex import subprocess import threading __version__ = '0.0.2' __license__ = 'MIT' __author__ = 'Kenneth Reitz' class Command(object): def __init__(self...
mit
3a1c330f80a65ede58e7cbdf7a6f0376
21.866667
71
0.558517
4.062606
false
false
false
false
mfenniak/heroku-buildpack-python-libffi
vendor/pip-1.3.1/pip/commands/show.py
147
2749
import os import pkg_resources from pip.basecommand import Command from pip.log import logger class ShowCommand(Command): """Show information about one or more installed packages.""" name = 'show' usage = """ %prog [options] <package> ...""" summary = 'Show information about installed packages.'...
mit
7ac15f0af93731e7f5bdfbe9d15ed44f
33.797468
75
0.567479
4.38437
false
false
false
false
mfenniak/heroku-buildpack-python-libffi
vendor/distribute-0.6.36/setuptools/command/upload.py
65
6709
"""distutils.command.upload Implements the Distutils 'upload' subcommand (upload package to PyPI).""" from distutils.errors import * from distutils.core import Command from distutils.spawn import spawn from distutils import log try: from hashlib import md5 except ImportError: from md5 import md5 import os imp...
mit
0ecc547062349e9f5de2723a4820056d
35.264865
90
0.53704
4.331181
false
false
false
false
mfenniak/heroku-buildpack-python-libffi
test/django-1.5-skeleton/haystack/settings.py
42
5356
# Django settings for haystack project. DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@example.com'), ) MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': '', ...
mit
fb22317355cc23dbc7684ae90caa4960
33.333333
127
0.685773
3.719444
false
false
false
false
mfenniak/heroku-buildpack-python-libffi
vendor/distribute-0.6.36/setuptools/command/install.py
215
4065
import setuptools, sys, glob from distutils.command.install import install as _install from distutils.errors import DistutilsArgError class install(_install): """Use easy_install to install the package, w/dependencies""" user_options = _install.user_options + [ ('old-and-unmanageable', None, "Try not ...
mit
bd03bba0bc4a2b772b2ad3f914b620ed
31.782258
79
0.622632
4.044776
false
false
false
false
dashpay/sentinel
bin/dbtest.py
1
1826
# -*- coding: utf-8 -*- import pdb from pprint import pprint import re import sys import os sys.path.append(os.path.normpath(os.path.join(os.path.dirname(__file__), '../lib'))) import config from models import Superblock, Proposal, GovernanceObject, Setting, Signal, Vote, Outcome from models import VoteSignals, VoteOut...
mit
677792c953fc24e06773f56851a30e71
28.451613
98
0.662651
3.079258
false
false
true
false
abelfunctions/abelfunctions
abelfunctions/tests/test_riemann_surface_path_factory.py
1
19115
import unittest from abelfunctions.tests.test_abelfunctions import AbelfunctionsTestCase from abelfunctions.complex_path import ( ComplexPathPrimitive, ComplexPath, ComplexLine, ComplexArc, ComplexRay, ) from abelfunctions.riemann_surface import RiemannSurface from abelfunctions.riemann_surface_pa...
mit
8f17a2dfc5b3bf19c3bec843cb9adefb
37.930754
80
0.584567
3.089043
false
true
false
false
abelfunctions/abelfunctions
abelfunctions/tests/test_homology.py
1
21849
import unittest from sage.all import ( GF, ZZ, QQ, CDF, RDF, I, Matrix, zero_matrix, identity_matrix, real, imag ) from abelfunctions.homology import ( involution_matrix, integer_kernel_basis, N1_matrix, symmetric_block_diagonalize, diagonal_locations, symmetric_transformation_matrix, s...
mit
32ffe866ee4493089e613b2843e9b974
36.158163
269
0.555632
2.71113
false
false
false
false
gtagency/buzzmobile
buzzmobile/tools/state_viz/state_viz.py
2
1448
#!/usr/bin/env python """state_viz: node that publishes current car state image for mission_control. Subscribes: car_pose CarPose command which also stores car state (mode) Publishes: state_viz Image representing current car state """ import cv2 import os import rospy from buzzmobile.msg import CarPose from ...
mit
d35bc82fae95734e31a074ca82e18482
29.808511
78
0.674033
3.276018
false
false
false
false
abelfunctions/abelfunctions
abelfunctions/riemann_surface.py
1
13208
""" RiemannSurfaces =============== Authors ------- * Chris Swierczewski (January 2014) """ import numpy import scipy import scipy.linalg import abelfunctions from abelfunctions.differentials import differentials as generate_differentials from abelfunctions.differentials import validate_differentials from abelfunct...
mit
4968a42b786a1926233bf303df94f00e
29.155251
88
0.577756
4.185044
false
false
false
false
thefactory/marathon-python
marathon/models/events.py
1
7466
""" This module is used to translate Events from Marathon's EventBus system. See: * https://mesosphere.github.io/marathon/docs/event-bus.html * https://github.com/mesosphere/marathon/blob/master/src/main/scala/mesosphere/marathon/core/event/Events.scala """ from marathon.models.base import MarathonObject from marathon...
mit
4cfa396bbd8fc05503f6bc3fcffd0983
33.40553
111
0.707072
3.782168
false
false
false
false
vnpy/vnpy
vnpy/trader/utility.py
1
29221
""" General utility functions. """ import json import logging import sys from datetime import datetime from pathlib import Path from typing import Callable, Dict, Tuple, Union, Optional from decimal import Decimal from math import floor, ceil import numpy as np import talib from .object import BarData, TickData from...
mit
f2420b71952a1ffa429428b061746788
27.704322
116
0.537387
3.753983
false
false
false
false
vnpy/vnpy
examples/no_ui/run.py
1
3025
import multiprocessing import sys from time import sleep from datetime import datetime, time from logging import INFO from vnpy.event import EventEngine from vnpy.trader.setting import SETTINGS from vnpy.trader.engine import MainEngine from vnpy_ctp import CtpGateway from vnpy_ctastrategy import CtaStrategyApp from v...
mit
2787e90edb7b27543623ac7736133424
21.36
71
0.618247
2.92364
false
false
false
false
vnpy/vnpy
vnpy/trader/database.py
1
3523
from abc import ABC, abstractmethod from datetime import datetime from types import ModuleType from typing import List from dataclasses import dataclass from importlib import import_module from .constant import Interval, Exchange from .object import BarData, TickData from .setting import SETTINGS from .utility import ...
mit
d57931c74eec801308e6976cb055ac53
20.943396
82
0.598739
4.307407
false
false
false
false
vnpy/vnpy
vnpy/event/engine.py
1
4227
""" Event-driven framework of VeighNa framework. """ from collections import defaultdict from queue import Empty, Queue from threading import Thread from time import sleep from typing import Any, Callable, List EVENT_TIMER = "eTimer" class Event: """ Event object consists of a type string which is used ...
mit
950c0caf15871e7ff363a74f578c0915
28.559441
72
0.592619
4.487261
false
false
false
false
vnpy/vnpy
vnpy/rpc/server.py
1
3866
import threading import traceback from time import time from typing import Any, Callable, Dict import zmq from .common import HEARTBEAT_TOPIC, HEARTBEAT_INTERVAL class RpcServer: """""" def __init__(self) -> None: """ Constructor """ # Save functions dict: key is function na...
mit
84bf09764888729ee27910ecd65c1164
26.784173
104
0.549197
4.344207
false
false
false
false
jazzband/django-pipeline
tests/tests/test_template.py
4
4624
from jinja2 import Environment, PackageLoader from django.template import Template, Context from django.test import TestCase from pipeline.jinja2 import PipelineExtension from tests.utils import pipeline_settings class JinjaTest(TestCase): def setUp(self): self.env = Environment(extensions=[PipelineExt...
mit
a43e424123515edcab780c3c92f8e3b8
54.047619
153
0.661548
3.812036
false
true
false
false
jazzband/django-pipeline
tests/settings.py
2
6640
import glob import os import distutils.spawn def local_path(path): return os.path.join(os.path.dirname(__file__), path) DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'TEST_NAME': ':memory:' } } DEBUG = False SITE_ID = 1 INSTALLED_APPS = [ 'django.contrib.conten...
mit
7a8ba3f0601c632727b6d83aa411256c
28.251101
93
0.531024
3.662438
false
false
false
false
stamparm/maltrail
thirdparty/odict/ordereddict.py
1
4283
# Copyright (c) 2009 Raymond Hettinger # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, # publish,...
mit
498ffb7a6e4f32462f1f5c29808453a2
31.203008
79
0.575765
4.166342
false
false
false
false
stamparm/maltrail
trails/static/__init__.py
1
3417
#!/usr/bin/env python """ Copyright (c) 2014-2022 Maltrail developers (https://github.com/stamparm/maltrail/) See the file 'LICENSE' for copying permission """ import glob import os import re from core.settings import UNICODE_ENCODING from thirdparty import six __url__ = "(static)" def fetch(): retval = {} ...
mit
7a5990bbbb229e1b4bca206313e5f471
38.732558
133
0.431373
4.449219
false
false
false
false
stamparm/maltrail
core/datatype.py
1
1218
#!/usr/bin/env python from thirdparty.odict import OrderedDict # Reference: https://www.kunxi.org/2014/05/lru-cache-in-python class LRUDict(object): """ This class defines the LRU dictionary >>> foo = LRUDict(capacity=2) >>> foo["first"] = 1 >>> foo["second"] = 2 >>> foo["third"] = 3 >>> ...
mit
32404cfb3f6956e9db53a9411c9ef625
21.555556
62
0.536946
3.782609
false
false
false
false
stamparm/maltrail
core/trailsdict.py
1
3082
#!/usr/bin/env python """ Copyright (c) 2014-2022 Maltrail developers (https://github.com/stamparm/maltrail/) See the file 'LICENSE' for copying permission """ import re class TrailsDict(dict): def __init__(self): self._trails = {} self._regex = "" self._infos = [] self._reverse_i...
mit
9220801e7604c4e79807eac3b8825ac3
31.787234
110
0.523686
4.11482
false
false
false
false
stamparm/maltrail
trails/feeds/dataplane.py
1
1139
#!/usr/bin/env python """ See the file 'LICENSE' for copying permission """ from core.common import retrieve_content __url__ = "https://dataplane.org/*.txt" __check__ = "Dataplane.org" __info__ = "known attacker" __reference__ = "dataplane.org" def fetch(): retval = {} for url in ("https://dataplane.org/dns...
mit
66984847d95deaffc94138055467f738
42.807692
487
0.627744
3.379822
false
false
false
false
stamparm/maltrail
trails/feeds/viriback.py
1
1094
#!/usr/bin/env python """ Copyright (c) 2014-2022 Maltrail developers (https://github.com/stamparm/maltrail/) See the file 'LICENSE' for copying permission """ import re from core.common import retrieve_content __url__ = "http://tracker.viriback.com/dump.php" __check__ = "Family,URL,IP,FirstSeen" __info__ = "malwar...
mit
eae735a43567d20f5ab269fb57c2b2c5
29.388889
83
0.516453
3.598684
false
false
false
false
hips/autograd
examples/bayesian_neural_net.py
3
3924
from __future__ import absolute_import from __future__ import print_function import matplotlib.pyplot as plt import autograd.numpy as np import autograd.numpy.random as npr from black_box_svi import black_box_variational_inference from autograd.misc.optimizers import adam def make_nn_funs(layer_sizes, L2_reg, noise...
mit
a0c02b8e8360ce60cfdd2b7e46b9cc64
36.018868
79
0.610347
3.433071
false
false
false
false
hips/autograd
benchmarks/bench_core.py
2
3185
import numpy as onp import autograd.numpy as np from autograd import grad try: from autograd.core import vspace, VJPNode, backward_pass from autograd.tracer import trace, new_box MASTER_BRANCH = False except ImportError: from autograd.core import (vspace, forward_pass, backward_pass, ...
mit
324a8d21983e9623bed3a9d8764cb78e
23.689922
85
0.609733
2.803697
false
false
false
false
marcwebbie/passpie
passpie/importers/keepass_importer.py
3
1171
from passpie.importers import BaseImporter from .csv_importer import unicode_csv_reader class KeepassImporter(BaseImporter): def match(self, filepath): expected_headers = ['Group', 'Title', 'Username', 'Password', 'URL', 'Notes'] with open(filepath) as csv_file: reader = unicode_csv_r...
mit
47dfa603adfa4acb742f148d2b9beaad
33.441176
85
0.52263
4.779592
false
false
false
false
hips/autograd
tests/test_dict.py
3
3599
import autograd.numpy as np import autograd.numpy.random as npr from autograd.test_util import check_grads from autograd import dict as ag_dict, isinstance as ag_isinstance from autograd import grad import operator as op npr.seed(0) def test_getter(): def fun(input_dict): A = np.sum(input_dict['item_1']) ...
mit
b285494ce0503dcc14fb24e42d58d610
28.024194
85
0.50514
2.807332
false
true
false
false
hips/autograd
examples/print_trace.py
3
1455
"""Demonstrates how to use the tracer module, independent of autodiff, by creating a trace that prints out functions and their arguments as they're being evaluated""" from __future__ import print_function import autograd.numpy as np # autograd has already wrapped numpy for us from autograd.tracer import trace, Node c...
mit
44090e3420b2c049299307f11511b75e
32.837209
81
0.650172
3.415493
false
false
false
false
hips/autograd
examples/fluidsim/fluidsim.py
3
4712
from __future__ import absolute_import from __future__ import print_function from builtins import range import autograd.numpy as np from autograd import value_and_grad from scipy.optimize import minimize from scipy.misc import imread import matplotlib import matplotlib.pyplot as plt import os # Fluid simulation code...
mit
78381831c970e2c08470e38be4d4b161
36.396825
82
0.616935
3.057755
false
false
false
false
hips/autograd
benchmarks/bench_rnn.py
3
5801
# Write the benchmarking functions here. # See "Writing benchmarks" in the asv docs for more information. # http://asv.readthedocs.io/en/latest/writing_benchmarks.html from autograd import grad import autograd.numpy as np class RNNSuite: """ Checking speed on a vanilla RNN. """ # NOTE: this is run eac...
mit
3a9001b49f3581a3c0a929f2ed49509b
33.945783
113
0.470953
2.959694
false
false
false
false
pudo/dataset
dataset/util.py
1
4646
from hashlib import sha1 from urllib.parse import urlparse, urlencode from collections import OrderedDict from sqlalchemy.exc import ResourceClosedError QUERY_STEP = 1000 row_type = OrderedDict try: # SQLAlchemy > 1.4.0, new row model. from sqlalchemy.engine import Row # noqa def convert_row(row_type, r...
mit
77dfa430e2f6294b5325c663ef1af6b8
26.491124
74
0.600301
3.87813
false
false
false
false
hips/autograd
tests/test_list.py
3
1842
import autograd.numpy as np import autograd.numpy.random as npr from autograd.test_util import check_grads, check_vjp, check_jvp from autograd import grad from autograd import list as ag_list, isinstance as ag_isinstance npr.seed(1) def test_getter(): def fun(input_list): A = np.sum(input_list[0]) ...
mit
d5deb3b7a89c0861b332a8889ed650ca
22.615385
65
0.517372
2.825153
false
true
false
false
hips/autograd
examples/ode_net.py
3
4001
# A demo of gradients through scipy.integrate.odeint, # estimating the dynamics of a system given a trajectory. from __future__ import absolute_import from __future__ import print_function import matplotlib.pyplot as plt import numpy as npo import autograd.numpy as np from autograd import grad from autograd.scipy.in...
mit
ae9a0618120bf3b13cc40313f847c64c
31.528455
81
0.583604
3.019623
false
false
false
false
hips/autograd
autograd/wrap_util.py
3
1581
from .util import subvals def unary_to_nary(unary_operator): @wraps(unary_operator) def nary_operator(fun, argnum=0, *nary_op_args, **nary_op_kwargs): assert type(argnum) in (int, tuple, list), argnum @wrap_nary_f(fun, unary_operator, argnum) def nary_f(*args, **kwargs): @wr...
mit
662872a270567012dbf33628b02d383b
36.642857
84
0.548387
3.181087
false
false
false
false
hips/autograd
examples/rnn.py
2
4931
"""Implements the long-short term memory character model. This version vectorizes over multiple examples, but each string has a fixed length.""" from __future__ import absolute_import from __future__ import print_function from builtins import range import autograd.numpy as np import autograd.numpy.random as npr from a...
mit
97335530361df0e239e0fe2967568282
37.826772
92
0.628879
3.547482
false
false
false
false
marcwebbie/passpie
passpie/crypt.py
1
5300
from tempfile import NamedTemporaryFile import os import re from . import process from .utils import tempdir from ._compat import unicode from passpie.utils import which GPG_HOMEDIR = os.path.expanduser('~/.gnupg') DEVNULL = open(os.devnull, 'w') KEY_INPUT = u"""%echo Generating Passpie OpenPGP key Key-Type: DSA Ke...
mit
2646e88f69ffaea0c6d22b9954b5fc07
26.46114
74
0.552075
3.851744
false
false
false
false
conan-io/conan-package-tools
cpt/log.py
2
1461
import logging from logging import StreamHandler import sys import os # #### LOGGER, MOVED FROM CONF BECAUSE OF MULTIPLE PROBLEM WITH CIRCULAR INCLUDES ##### CONAN_LOGGING_LEVEL = int(os.getenv('CONAN_LOGGING_LEVEL', logging.DEBUG)) CONAN_LOGGING_FILE = os.getenv('CONAN_LOGGING_FILE', None) # None is stdout class M...
mit
ad4324b0ea89d21e35ee89cec2379ced
28.22
111
0.604381
3.6525
false
false
false
false
conan-io/conan-package-tools
cpt/ci_manager.py
1
9544
import re import os import subprocess def is_travis(): return os.getenv("TRAVIS", False) def is_appveyor(): return os.getenv("APPVEYOR", False) def is_bamboo(): return os.getenv("bamboo_buildNumber", False) def is_jenkins(): return os.getenv("JENKINS_URL", False) def is_gitlab(): return os...
mit
883e15f05c734083cbd334a78864779d
27.404762
103
0.594824
3.769352
false
false
false
false
conan-io/conan-package-tools
cpt/remotes.py
1
6307
import os from collections import namedtuple from six import string_types class Remote(namedtuple("Remote", "url use_ssl name")): def to_str(self): ret = self.url if self.use_ssl is not None: ret += "@%s" % self.use_ssl else: ret += "@True" if self.name: ...
mit
c4fc0b6f0c7471e6903a24bba8ab74b1
38.41875
106
0.527668
3.866953
false
false
false
false
conan-io/conan-package-tools
cpt/test/assets/genconanfile.py
1
13380
from conans.model.ref import ConanFileReference class GenConanfile(object): """ USAGE: x = GenConanfile().with_import("import os").\ with_setting("os").\ with_option("shared", [True, False]).\ with_default_option("shared", True).\ with_build_msg("holaaa").\ with_bu...
mit
1ac84910e6fa4d3f1aca644b55f59071
33.307692
98
0.536173
3.983328
false
false
false
false
euske/pdfminer
pdfminer/layout.py
1
21826
#!/usr/bin/env python from .utils import INF from .utils import Plane from .utils import get_bound from .utils import uniq from .utils import csort from .utils import fsplit from .utils import bbox2str from .utils import matrix2str from .utils import apply_matrix_pt ## IndexAssigner ## class IndexAssigner: def ...
mit
d0e830ab77f5258a314d802c8635154f
28.695238
97
0.507331
3.594532
false
false
false
false
euske/pdfminer
pdfminer/image.py
1
4086
#!/usr/bin/env python import struct import os import os.path from io import BytesIO from .pdftypes import LITERALS_DCT_DECODE from .pdfcolor import LITERAL_DEVICE_GRAY from .pdfcolor import LITERAL_DEVICE_RGB from .pdfcolor import LITERAL_DEVICE_CMYK def align32(x): return ((x+3)//4)*4 ## BMPWriter ## class BM...
mit
dd38caf772e83b08ad593f97f7dbab8e
32.768595
119
0.501958
3.641711
false
false
false
false
euske/pdfminer
pdfminer/arcfour.py
1
1188
#!/usr/bin/env python """ Python implementation of Arcfour encryption algorithm. This code is in the public domain. """ ## Arcfour ## class Arcfour: """ >>> Arcfour(b'Key').process(b'Plaintext').hex() 'bbf316e8d940af0ad3' >>> Arcfour(b'Wiki').process(b'pedia').hex() '1021bf0420' >>> Arcfo...
mit
bec7253c0c498ca5f95af2f84a499a02
21
59
0.473906
2.782201
false
true
false
false
euske/pdfminer
pdfminer/lzw.py
1
2936
#!/usr/bin/env python from io import BytesIO class CorruptDataError(Exception): pass ## LZWDecoder ## class LZWDecoder: def __init__(self, fp): self.fp = fp self.buff = 0 self.bpos = 8 self.nbits = 9 self.table = None self.prevbuf = None return ...
mit
f8257958a04180703c3309c7e44f4543
26.698113
78
0.42064
3.822917
false
false
false
false
plamere/spotipy
examples/artist_discography.py
1
2136
#Shows the list of all songs sung by the artist or the band import argparse import logging from spotipy.oauth2 import SpotifyClientCredentials import spotipy logger = logging.getLogger('examples.artist_discography') logging.basicConfig(level='INFO') def get_args(): parser = argparse.ArgumentParser(description='...
mit
ad7a5849ac56114bccb20e018fd4c062
28.260274
79
0.618446
3.626486
false
false
false
false
plamere/spotipy
examples/artist_albums.py
1
1417
import argparse import logging from spotipy.oauth2 import SpotifyClientCredentials import spotipy logger = logging.getLogger('examples.artist_albums') logging.basicConfig(level='INFO') sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials()) def get_args(): parser = argparse.ArgumentParser(d...
mit
91a795c90072dd6fa8bf958ed7049d67
24.763636
75
0.62597
3.578283
false
false
false
false
fuzeman/trakt.py
trakt/mapper/sync.py
2
7788
from __future__ import absolute_import, division, print_function from trakt.mapper.core.base import Mapper import logging log = logging.getLogger(__name__) class SyncMapper(Mapper): @classmethod def process(cls, client, store, items, media=None, flat=False, **kwargs): if flat: return cl...
mit
5d28a2d96bae0908579b749a99d4465a
24.618421
106
0.509502
4.262726
false
false
false
false
fuzeman/trakt.py
trakt/mapper/list_item.py
2
4027
from __future__ import absolute_import, division, print_function from trakt.mapper.core.base import Mapper class ListItemMapper(Mapper): @classmethod def process(cls, client, item, media=None, **kwargs): if media is None: # Retrieve `media` from `item` media = item.get('type')...
mit
54bad986dbe3ea84fc97c4d6e8d9411c
23.705521
111
0.538366
4.147271
false
false
false
false
fuzeman/trakt.py
tests/test_calendars.py
1
11176
# flake8: noqa: F403, F405 from __future__ import absolute_import, division, print_function from tests.core import mock from trakt import Trakt from trakt.interfaces.calendars import Base from datetime import date, datetime from dateutil.tz import tzutc from hamcrest import * from httmock import HTTMock import pytest...
mit
4a36d516f784032e4284437c17954741
25.358491
84
0.541965
3.338112
false
true
false
false
fuzeman/trakt.py
trakt/objects/list/base.py
2
5889
from __future__ import absolute_import, division, print_function from trakt.core.helpers import from_iso8601_datetime from trakt.objects.core.helpers import update_attributes class List(object): def __init__(self, client, keys, user): self._client = client self.keys = keys """ :t...
mit
75530fd39a5d198e9d727fb4d3d11ef5
20.414545
92
0.493972
4.182528
false
false
false
false
fuzeman/trakt.py
trakt/mapper/core/base.py
2
3319
from __future__ import absolute_import, division, print_function from trakt.objects import User, Movie, Show, Episode, Season, CustomList, Comment, Person, PublicList,\ WatchedProgress, CollectionProgress IDENTIFIERS = { 'movie': [ 'imdb', 'tmdb', 'slug', 'trakt' ], 's...
mit
65742bbb4d8999b6f3e6390d52eec02f
23.050725
103
0.500452
4.13325
false
false
false
false
fuzeman/trakt.py
trakt/interfaces/base/__init__.py
2
3543
from __future__ import absolute_import, division, print_function from trakt.core.errors import log_request_error from trakt.core.exceptions import RequestFailedError, ServerError, ClientError from trakt.core.pagination import PaginationIterator from trakt.helpers import setdefault import functools import logging log...
mit
c872b7cdb7deb2cc267b432af15feeba
26.679688
99
0.592154
4.680317
false
false
false
false
fuzeman/trakt.py
trakt/hooks.py
7
1441
from __future__ import absolute_import, division, print_function from six.moves import xrange import os PACKAGE_DIR = os.path.dirname(__file__) def write_version(command): if not command or not hasattr(command, 'egg_version'): print('Invalid command state') return # Retrieve current package...
mit
553af1ea696665ef05899db76747c4a0
24.732143
65
0.601666
4.059155
false
false
false
false
fuzeman/trakt.py
trakt/interfaces/sync/watchlist.py
2
1880
from __future__ import absolute_import, division, print_function from trakt.interfaces.base import authenticated from trakt.interfaces.sync.core.mixins import Get, Add, Remove class SyncWatchlistInterface(Get, Add, Remove): path = 'sync/watchlist' flags = {'in_watchlist': True} def get(self, media=None,...
mit
48b7d133464bf55cadbf4d506f37da5a
23.415584
83
0.527128
4.331797
false
false
false
false
lneuhaus/pyrpl
pyrpl/hardware_modules/iir/iir_theory.py
1
41405
############################################################################### # pyrpl - DSP servo controller for quantum optics with the RedPitaya # Copyright (C) 2014-2016 Leonhard Neuhaus (neuhaus@spectro.jussieu.fr) # # This program is free software: you can redistribute it and/or modify # it under t...
mit
1be77070c89f0ec8a706f43bef718bad
36.002681
102
0.544958
4.204407
false
false
false
false
lneuhaus/pyrpl
pyrpl/modules.py
1
30495
""" Modules are the basic building blocks of Pyrpl. The internal structure of the FPGA is made of individual modules, each performing a well defined task. Each of these FPGA modules are represented in python by a :obj:`HardwareModule`. Higher-level operations, for instance those that need a coordinated operation of s...
mit
0e6c2538dfbac31fcef3554f39353b1d
38.146341
134
0.601148
4.491163
false
false
false
false
lneuhaus/pyrpl
pyrpl/hardware_modules/asg.py
1
16805
""" There are two Arbitrary Signal Generator modules: asg1 and asg2. For these modules, any waveform composed of :math:`2^{14}` programmable points is sent to the output with arbitrary frequency and start phase upon a trigger event. .. code:: ipython3 asg = r.asg1 # make a shortcut print "Trigger sources:", a...
mit
dcd954ec9298c2d877c6e1468d5069a6
43.223684
252
0.520024
4.450477
false
false
false
false
kbr/fritzconnection
fritzconnection/core/soaper.py
1
10429
""" Module handling the SOAP based communication with the router. """ # This module is part of the FritzConnection package. # https://github.com/kbr/fritzconnection # License: MIT (https://opensource.org/licenses/MIT) # Author: Klaus Bremer import datetime import html import re import requests from requests.auth imp...
mit
f59371f39fe68e08761f12992308b0fc
30.990798
88
0.620481
4.064302
false
false
false
false
kbr/fritzconnection
setup.py
1
2350
import os import re from setuptools import setup, find_packages def get_long_description(): with open("README.rst") as file: return file.read() def get_version(): path = os.path.join("fritzconnection", "__init__.py") with open(path) as file: content = file.read() mo = re.search(r'\n\...
mit
5a0828bc1787d6daa06e03ee46cbe3ae
34.606061
74
0.609362
3.683386
false
false
false
false
pyparsing/pyparsing
examples/btpyparse.py
1
4257
""" Pyparsing parser for BibTeX files A standalone parser using pyparsing. pyparsing has a simple and expressive syntax so the grammar is easy to read and write. Submitted by Matthew Brett, 2010 Simplified BSD license """ from pyparsing import ( Regex, Suppress, ZeroOrMore, Group, ...
mit
078148488192ca26f6418dbb7c837583
29.301471
82
0.673714
3.357256
false
false
false
false
pyparsing/pyparsing
examples/protobuf_parser.py
1
4053
# protobuf_parser.py # # simple parser for parsing protobuf .proto files # # Copyright 2010, Paul McGuire # from pyparsing import ( Word, alphas, alphanums, Regex, Suppress, Forward, Group, oneOf, ZeroOrMore, Optional, delimitedList, restOfLine, quotedString, D...
mit
52b4c7f6feb8a5efd2a3c3bb2702760f
22.701754
93
0.610659
3.524348
false
false
false
false
pyparsing/pyparsing
pyparsing/results.py
1
25566
# results.py from collections.abc import MutableMapping, Mapping, MutableSequence, Iterator import pprint from typing import Tuple, Any, Dict, Set, List str_type: Tuple[type, ...] = (str, bytes) _generator_type = type((_ for _ in ())) class _ParseResultsWithOffset: tup: Tuple["ParseResults", int] __slots__ =...
mit
ead3055ea04d1ec86029f93fa99acbc2
32.419608
183
0.475006
4.302592
false
false
false
false
pyparsing/pyparsing
examples/dhcpd_leases_parser.py
1
3048
# # dhcpd_leases_parser.py # # Copyright 2008, Paul McGuire # # Sample parser to parse a dhcpd.leases file to extract leases # and lease attributes # # format ref: http://www.linuxmanpages.com/man5/dhcpd.leases.5.php # sample = r"""\ # All times in this file are in UTC (GMT), not your local timezone. Thi...
mit
4e9b55a322168115fd54fe4f49656d6e
29.42268
81
0.643045
2.814404
false
false
false
false
pyparsing/pyparsing
examples/lua_parser.py
1
7995
# # lua_parser.py # # A simple parser for the Lua language. # # Copyright 2020, Paul McGuire # """ from https://www.lua.org/manual/5.1/manual.html#8 chunk ::= {stat [';']} [laststat [';']] block ::= chunk stat ::= varlist '=' explist | functioncall | do block end | while exp ...
mit
f45d79e6f5ba281bbbdbfcef53678ae0
26.286689
110
0.546967
3.260604
false
false
false
false
codeeu/coding-events
web/forms/event_form.py
1
10889
# -*- coding: utf-8 -*- from django import forms from django_countries.fields import countries from api.models import Event from api.models.events import EventTheme, EventAudience class AddEventForm(forms.ModelForm): email_errors = { 'required': u'Please enter a valid email, so we can contact you in case...
mit
d5d54e07ff4b410881eab5cb749db051
42.210317
260
0.533841
4.501447
false
false
false
false
codeeu/coding-events
api/models/events.py
1
5857
""" Models for the event """ import datetime from hashlib import sha1 from django.utils import timezone from django.db import models from django.template.defaultfilters import slugify from taggit.managers import TaggableManager from geoposition.fields import GeopositionField from django_countries.fields import CountryF...
mit
5eb8a6b50c8e0bfdbe704d8a25490539
31.72067
127
0.644357
3.949427
false
false
false
false
codeeu/coding-events
api/migrations/0008_update_eventtheme_list.py
2
10038
# -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2 import DataMigration from django.db import models class Migration(DataMigration): def forwards(self, orm): """ Update default topics list """ update_theme_title_list = ...
mit
f8afdc3489b4c9dd108206bd90505021
59.46988
195
0.542837
3.821089
false
false
false
false
codeeu/coding-events
web/tests/__init__.py
2
1372
import factory import datetime from django.contrib.auth.models import User from api.models.events import Event class EventFactory(factory.DjangoModelFactory): class Meta: model = Event organizer = "Event Organizer" creator = factory.LazyAttribute( lambda n: User.objects.get_or_create( ...
mit
e98e751f91418e193f1d3e5563514051
23.5
61
0.612245
3.843137
false
false
false
false
codeeu/coding-events
api/processors.py
1
5039
import datetime from django.db.models import Q from models.events import Event from models.events import EventTheme from models.events import EventAudience def get_all_events(): return Event.objects.all() def get_event_by_id(event_id): event = Event.objects.get(id=event_id) return event def get_approv...
mit
8745114038dd9757a9bf1d459c465802
24.709184
101
0.632268
3.837776
false
false
false
false
codeeu/coding-events
web/tests/test_events_processors.py
2
28658
import datetime import StringIO import pytest from django.test import TestCase from django.db import IntegrityError from django.core.files.uploadedfile import InMemoryUploadedFile from django.contrib.auth.models import User from py.path import local from geoposition import Geoposition from web.processors.event import ...
mit
c463ca3daeb111f4fe4ceb9cda5af1c2
39.765292
492
0.601403
3.52627
false
true
false
false