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
honeynet/droidbot
start.py
2
9318
# helper file of droidbot # it parses command arguments and send the options to droidbot import argparse from droidbot import input_manager from droidbot import input_policy from droidbot import env_manager from droidbot import DroidBot from droidbot.droidmaster import DroidMaster def parse_args(): """ parse ...
mit
2db5eb9be0c1272e14bc704479ccae7d
52.551724
167
0.580704
4.202977
false
false
false
false
humancompatibleai/imitation
src/imitation/util/video_wrapper.py
1
2617
"""Wrapper to record rendered video frames from an environment.""" import os import gym from gym.wrappers.monitoring import video_recorder from imitation.data import types class VideoWrapper(gym.Wrapper): """Creates videos from wrapped environment by calling render after each timestep.""" def __init__( ...
mit
5801ee530b70668c64ff9ecd34eac6f2
33.434211
88
0.591517
4.458262
false
false
false
false
humancompatibleai/imitation
src/imitation/algorithms/bc.py
1
15636
"""Behavioural Cloning (BC). Trains policy by applying supervised learning to a fixed dataset of (observation, action) pairs generated by some expert demonstrator. """ import contextlib from typing import Any, Callable, Dict, Iterable, Mapping, Optional, Tuple, Type, Union import gym import numpy as np import torch ...
mit
ca1fd1671cae20fb706222bf7304b7b5
37.895522
104
0.57406
4.191957
false
false
false
false
humancompatibleai/imitation
src/imitation/envs/examples/airl_envs/__init__.py
1
1244
from typing import Optional from gym.envs import register as gym_register _ENTRY_POINT_PREFIX = "imitation.envs.examples.airl_envs" def _register(env_name: str, entry_point: str, kwargs: Optional[dict] = None): entry_point = f"{_ENTRY_POINT_PREFIX}.{entry_point}" gym_register(id=env_name, entry_point=entry_...
mit
bdcd8554d52566700e029695a60b379f
28.619048
78
0.645498
3.079208
false
false
false
false
humancompatibleai/imitation
src/imitation/util/networks.py
1
2430
"""Helper methods to build and run neural networks.""" import collections from typing import Iterable, Optional, Type from torch import nn class SqueezeLayer(nn.Module): """Torch module that squeezes a B*1 tensor down into a size-B vector.""" def forward(self, x): assert x.ndim == 2 and x.shape[1] ...
mit
82c99bdaf15004ee39f00f4dce85923d
30.532468
86
0.621911
3.712538
false
false
false
false
humancompatibleai/imitation
src/imitation/scripts/config/expert_demos.py
1
4739
import os import sacred from imitation.scripts.config.common import DEFAULT_INIT_RL_KWARGS from imitation.util import util expert_demos_ex = sacred.Experiment("expert_demos") @expert_demos_ex.config def expert_demos_defaults(): env_name = "CartPole-v1" # The gym.Env name total_timesteps = int(1e6) # Numb...
mit
69284d1c3b3c4d4a11ab24a7a058d6c2
25.327778
82
0.69023
2.954489
false
true
false
false
humancompatibleai/imitation
src/imitation/rewards/discrim_nets.py
1
12334
import abc import logging from typing import Optional import gym import numpy as np import torch as th import torch.nn.functional as F from stable_baselines3.common import preprocessing from torch import nn from imitation.rewards import common as rewards_common from imitation.rewards import reward_nets from imitation...
mit
27a670e100a7901b8dc3db6341f2ac34
32.884615
97
0.58359
3.900696
false
false
false
false
valohai/valohai-cli
valohai_cli/utils/matching.py
1
2213
import re from typing import Any, Iterable, List, Optional, Union import click from valohai_cli.utils import force_text from valohai_cli.utils.cli_utils import join_with_style def match_prefix(choices: Iterable[Any], value: str, return_unique: bool = True) -> Union[List[Any], Any, None]: """ Match `value` i...
mit
40d064dc56cced971ac4e9e33f0c3c73
39.236364
112
0.659738
3.639803
false
false
false
false
jazzband/website
jazzband/projects/views.py
1
23433
import hashlib import hmac import logging import os import shutil import tempfile from datetime import datetime import delegator import requests from flask import ( Blueprint, abort, current_app, flash, jsonify, make_response, redirect, request, send_from_directory, url_for, ) f...
mit
c60047afc6fe06ec4f332cadb4e4af40
35.217929
88
0.570008
4.334628
false
false
false
false
jazzband/website
jazzband/projects/models.py
1
7862
import os import time from datetime import datetime from uuid import uuid4 from flask import current_app, render_template from flask_login import current_user from sqlalchemy import func, orm from sqlalchemy.dialects.postgresql import JSONB, UUID from sqlalchemy_utils import aggregated, generic_repr from werkzeug.secu...
mit
f323ed307ec8dbf97732c587ab65598a
34.414414
88
0.641567
3.527142
false
false
false
false
valohai/valohai-cli
tests/commands/deployment/test_create_version.py
1
1948
import uuid import pytest from tests.commands.run_test_utils import RunAPIMock from valohai_cli.commands.deployment.create_version import create_version from valohai_cli.ctx import get_project from valohai_cli.models.project import Project @pytest.mark.parametrize('name', (None, '666')) def test_create_version(runn...
mit
2fa42a15ce44e40a1c7e2f290b135281
37.196078
125
0.661191
3.746154
false
true
false
false
valohai/valohai-cli
tests/stub_git.py
1
2737
import os import tempfile from pathlib import Path from subprocess import check_call, check_output from typing import Any, List, Optional, Tuple, Union from valohai_cli.utils import get_random_string class StubGit: def __init__(self, path: Any): if type(path) not in {Path, str}: # support fo...
mit
b18d43e1777b57c1e8d05a700eef6e7a
34.089744
99
0.625868
3.688679
false
false
false
false
valohai/valohai-cli
valohai_cli/utils/file_size_format.py
1
1054
# Adapted from Jinja2. Jinja2 is (c) 2017 by the Jinja Team, licensed under the BSD license. from typing import Union binary_prefixes = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] decimal_prefixes = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] def filesizeformat(value: Union[int, float], binary: boo...
mit
26fad729270a2190d17667cf6275356d
39.538462
92
0.594877
3.346032
false
false
false
false
jazzband/website
jazzband/admin.py
3
2880
from flask import redirect, request, session, url_for from flask_admin import Admin, AdminIndexView, expose from flask_admin.contrib import sqla from flask_login import current_user from .account.models import OAuth from .auth import current_user_is_roadie from .db import postgres from .members.models import EmailAddr...
mit
b2e798f0519007ab045b2e49d721038f
27.514851
75
0.658333
3.68758
false
false
false
false
jazzband/website
jazzband/account/blueprint.py
1
11651
import logging from flask import current_app, flash from flask_dance.consumer import OAuth2ConsumerBlueprint, oauth_error from flask_dance.consumer.requests import BaseOAuth2Session, OAuth2Session from flask_dance.consumer.storage.sqla import SQLAlchemyStorage from flask_login import current_user, login_user from sent...
mit
a6223da1699a77d8fbb2f2c7c18cf6d7
35.638365
96
0.59291
4.072352
false
false
false
false
jazzband/website
jazzband/db.py
3
7581
from collections import deque from contextlib import contextmanager from flask_redis import FlaskRedis from flask_sqlalchemy import Model, SQLAlchemy from walrus import Walrus from .exceptions import Rollback class JazzbandModel(Model): @classmethod def update_or_create(cls, defaults=None, commit=True, **kw...
mit
3b7cc4b2abf71892a2f2c66b99a538f3
39.978378
154
0.634085
4.594545
false
false
false
false
jazzband/website
jazzband/account/forms.py
3
1593
from flask_login import current_user from flask_wtf import FlaskForm from wtforms import ValidationError, validators from wtforms.fields import BooleanField, StringField CONSENT_ERROR_MESSAGE = "Your consent is required to continue." class ConsentForm(FlaskForm): profile = BooleanField( "I consent to fet...
mit
e2d361ce3ec1034fbffbfd32a47596a7
37.756098
84
0.685337
4.553009
false
false
false
false
valohai/valohai-cli
valohai_cli/commands/update_check.py
1
2113
import sys from typing import Optional import click import requests import valohai_cli from valohai_cli.messages import warn @click.command() def update_check() -> None: data = get_pypi_info() current_version = valohai_cli.__version__ latest_version = data['info']['version'] click.echo(f'Your versio...
mit
f9995fd181afc1cd8200a33325858e3c
35.431034
113
0.648841
3.920223
false
true
false
false
jazzband/website
jazzband/projects/forms.py
3
4216
import re from flask_login import current_user from flask_wtf import FlaskForm from flask_wtf.file import FileAllowed, FileField, FileRequired from packaging import version from wtforms import StringField, SubmitField, ValidationError, validators _project_name_re = re.compile( r"^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-...
mit
c6cceb25999ed9f723b7e8ee2a804e7b
27.486486
87
0.571632
4.328542
false
false
false
false
jazzband/website
jazzband/members/tasks.py
1
1612
import logging from datetime import timedelta from spinach import Tasks from ..account import github from ..config import ONE_MINUTE from ..db import postgres, redis from .models import EmailAddress, User logger = logging.getLogger(__name__) tasks = Tasks() @tasks.task(name="sync_members", periodicity=timedelta(m...
mit
e827ee75bbe276c5ae9498de57743452
27.280702
82
0.646402
3.638826
false
false
false
false
heyman/locust
locust/clients.py
1
11870
import re import time import requests import six from requests import Request, Response from requests.auth import HTTPBasicAuth from requests.exceptions import (InvalidSchema, InvalidURL, MissingSchema, RequestException) from six.moves.urllib.parse import urlparse, urlunparse from . ...
mit
fa8324be771fc1c52811123c3ea146ad
45.367188
147
0.619208
4.597211
false
false
false
false
heyman/locust
locust/contrib/fasthttp.py
1
15632
from __future__ import absolute_import import chardet import re import six import socket from base64 import b64encode from six.moves.urllib.parse import urlparse, urlunparse from ssl import SSLError from timeit import default_timer if six.PY2: from cookielib import CookieJar class ConnectionRefusedError(Excep...
mit
ab852c1a8d712f54c38d481db8d68c2b
39.708333
162
0.623721
4.494537
false
false
false
false
harrystech/arthur-redshift-etl
python/etl/util/timer.py
1
1460
"""Timer class for when you need to measure the elapsed time in seconds.""" import datetime def utc_now() -> datetime.datetime: """ Return the current time for timezone UTC. Unlike datetime.utcnow(), this timestamp is timezone-aware. """ return datetime.datetime.now(datetime.timezone.utc) def ...
mit
9363ae818bf94b253ae589700c1e08fd
27.076923
97
0.613014
4.147727
false
false
false
false
tobi-wan-kenobi/bumblebee-status
bumblebee_status/modules/contrib/cmus.py
1
5688
# pylint: disable=C0111,R0903 """Displays information about the current song in cmus. Requires the following executable: * cmus-remote Parameters: * cmus.format: Format string for the song information. Tag values can be put in curly brackets (i.e. {artist}) Additional tags: * {file} - full son...
mit
6229378fb636b4dce1afe42fb102addb
35.461538
208
0.534986
3.966527
false
false
false
false
tobi-wan-kenobi/bumblebee-status
bumblebee_status/modules/contrib/pihole.py
1
2850
# pylint: disable=C0111,R0903 """Displays the pi-hole status (up/down) together with the number of ads that were blocked today Parameters: * pihole.address : pi-hole address (e.q: http://192.168.1.3) * pihole.pwhash : pi-hole webinterface password hash (can be obtained from the /etc/pihole/SetupVars....
mit
4449333349ae6bca57d16a080a239236
32.529412
120
0.543158
4.014085
false
false
false
false
tobi-wan-kenobi/bumblebee-status
tests/modules/contrib/test_network_traffic.py
1
2991
import pytest from unittest import TestCase, mock import core.config import core.widget import modules.contrib.network_traffic from types import SimpleNamespace pytest.importorskip("psutil") pytest.importorskip("netifaces") def io_counters_mock(recv, sent): return { 'lo': SimpleNamespace( by...
mit
e1485a0e78eeaa471258e46be3fdaa3c
28.038835
76
0.629555
3.422197
false
true
false
false
tobi-wan-kenobi/bumblebee-status
bumblebee_status/modules/contrib/github.py
1
3373
# pylint: disable=C0111,R0903 """ Displays the unread GitHub notifications count for a GitHub user using the following reasons: * https://developer.github.com/v3/activity/notifications/#notification-reasons Uses `xdg-open` or `x-www-browser` to open web-pages. Requires the following library: * requests Par...
mit
c1cecdb80b794bd1c3412c6b8b43853b
27.82906
119
0.569226
4.313299
false
false
false
false
tobi-wan-kenobi/bumblebee-status
bumblebee_status/modules/core/scroll.py
1
1626
# pylint: disable=C0111,R0903 """Displays two widgets that can be used to scroll the whole status bar Parameters: * scroll.width: Width (in number of widgets) to display """ import core.module import core.widget import core.input import core.event import util.format class Module(core.module.Module): def __...
mit
9f0cf815e08d44dd81a2716e928c0dda
29.679245
83
0.613161
3.772622
false
true
false
false
tobi-wan-kenobi/bumblebee-status
bumblebee_status/modules/contrib/mocp.py
1
1800
# pylint: disable=C0111,R0903 # -*- coding: utf-8 -*- """Displays information about the current song in mocp. Left click toggles play/pause. Right click toggles shuffle. Requires the following executable: * mocp Parameters: * mocp.format: Format string for the song information. Replace string sequences with ...
mit
5944fe8fd7a4611237c82bfa60cee728
29.508475
115
0.601111
3.837953
false
false
false
false
tobi-wan-kenobi/bumblebee-status
bumblebee_status/modules/contrib/solaar.py
1
1592
"""Shows status and load percentage of logitech's unifying device Requires the following executable: * solaar (from community) contributed by `cambid <https://github.com/cambid>`_ - many thanks! """ import logging import core.module import core.widget import core.decorators import util.cli class Module(core....
mit
96cd108a3a67ca711fd9c63cab624b95
26.448276
77
0.584171
3.930864
false
false
false
false
tobi-wan-kenobi/bumblebee-status
bumblebee_status/modules/contrib/cpu2.py
1
5735
"""Multiwidget CPU module Can display any combination of: * max CPU frequency * total CPU load in percents (integer value) * per-core CPU load as graph - either mono or colored * CPU temperature (in Celsius degrees) * CPU fan speed Requirements: * the psutil Python module for the first three...
mit
baf2f8e117a210c7de0c68c98993860f
36.12987
88
0.573977
3.628173
false
false
false
false
tobi-wan-kenobi/bumblebee-status
bumblebee_status/core/output.py
1
10278
import sys import json import time import threading import core.theme import core.event import util.format def dump_json(obj): return obj.dict() def assign(src, dst, key, src_key=None, default=None): if not src_key: if key.startswith("_"): src_key = key else: src_ke...
mit
a1a0da5078676f3fa10b3d61ee581c40
32.588235
119
0.532205
4.15945
false
false
false
false
tobi-wan-kenobi/bumblebee-status
bumblebee_status/modules/contrib/docker_ps.py
1
1263
# -*- coding: utf-8 -*- """Displays the number of docker containers running Requires the following python packages: * docker contributed by `jlopezzarza <https://github.com/jlopezzarza>`_ - many thanks! """ import docker from requests.exceptions import ConnectionError import core.module import core.widget imp...
mit
e1bf75bef70b22862125718d9c9b0cd3
25.3125
77
0.590657
3.934579
false
false
false
false
tobi-wan-kenobi/bumblebee-status
bumblebee_status/modules/core/git.py
1
2138
# pylint: disable=C0111,R0903 """Print the branch and git status for the currently focused window. Requires: * xcwd * Python module 'pygit2' """ import os import pygit2 import core.module import util.cli class Module(core.module.Module): def __init__(self, config, theme): super().__init__(con...
mit
32a9510f0282e9b7a51856d69de6a4f0
27.131579
75
0.511693
4.159533
false
false
false
false
tobi-wan-kenobi/bumblebee-status
bumblebee_status/util/location.py
1
3512
"""Retrieves location information from an external service and caches it for 12h (retries are done every 30m in case of problems) Right now, it uses (in order of preference): - http://free.ipwhois.io/ - 10k free requests/month - http://ipapi.co/ - 30k free requests/month - http://ip-api.com/ - ~2m free req...
mit
5232c865b8fcf10824753e6025899968
21.08805
80
0.531606
3.855104
false
false
false
false
tobi-wan-kenobi/bumblebee-status
bumblebee_status/modules/contrib/messagereceiver.py
1
2803
# pylint: disable=C0111,R0903 """ Displays the message that's received via unix socket. Parameters: * messagereceiver : Unix socket address (e.g: /tmp/bumblebee_messagereceiver.sock) Example: The following examples assume that /tmp/bumblebee_messagereceiver.sock is used as unix socket address. In ...
mit
dc02882ed128ea2696f51f4bbbcbd7d1
31.905882
135
0.585627
4.131462
false
false
false
false
pythonindia/junction
junction/urls.py
1
5345
# -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals import django.views.defaults from django.conf import settings from django.conf.urls import include, url from django.conf.urls.static import static from django.contrib import admin from django.views.generic.base import RedirectView, Templa...
mit
9488f04d446947bb376d1700d3481293
32.40625
88
0.64565
3.560959
false
false
true
false
spectralpython/spectral
spectral/algorithms/continuum.py
1
14678
''' Continuum and continuum removal. Continuum is defined as convex hull of spectrum. Continuum is removed from spectra by dividing spectra by its continuum. That results in values between 0 and 1, where absorption bands are expressed as drops below 1. It is usefull for comparing and classification based on absorption...
mit
6842151931a3d6fe07b427b1ec545ca2
40
112
0.649135
3.904762
false
false
false
false
pythonindia/junction
junction/base/constants.py
1
2834
# -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals import inspect def _user_attributes(cls): defaults = dir(type(str("defaults"), (object,), {})) # gives all inbuilt attrs return [item[0] for item in inspect.getmembers(cls) if item[0] not in defaults] def choices(cls): ""...
mit
d7734abab5e35aa2f33d586cd42acf8b
23.643478
83
0.618913
3.070423
false
false
false
false
pythonindia/junction
junction/feedback/admin.py
1
3402
# -*- coding: utf-8 -*- from django.contrib import admin from junction.base.admin import TimeAuditAdmin from junction.conferences import service from .models import ( ChoiceFeedbackQuestion, ChoiceFeedbackQuestionValue, ScheduleItemChoiceFeedback, ScheduleItemTextFeedback, TextFeedbackQuestion, )...
mit
e60c1a1fcb39a1772eedd7b877b5dddb
33.714286
87
0.702528
4.059666
false
false
false
false
pythonindia/junction
junction/feedback/serializers.py
1
1459
# -*- coding: utf-8 -*- from rest_framework import serializers from .models import ( ChoiceFeedbackQuestion, ChoiceFeedbackQuestionValue, TextFeedbackQuestion, ) def object_exists(model, pk): if not model.objects.filter(pk=pk): raise serializers.ValidationError("The question doesn't exist") ...
mit
e71e5ec60ef16b3aee15d17a6b425f65
28.77551
74
0.694311
4.646497
false
false
false
false
saxix/django-concurrency
src/concurrency/fields.py
1
13785
import copy import functools import hashlib import logging import time from collections import OrderedDict from functools import update_wrapper from django.db import models from django.db.models import signals from django.db.models.fields import Field from django.db.models.signals import class_prepared, post_migrate f...
mit
076eb479702ce82439555cb6ec028c33
37.940678
116
0.61741
4.269124
false
false
false
false
saxix/django-concurrency
tests/demoapp/demo/migrations/0001_initial.py
1
11522
# Generated by Django 1.9.6 on 2016-09-09 15:41 import django.db.models.deletion from django.conf import settings from django.db import migrations, models import concurrency.fields class Migration(migrations.Migration): initial = True dependencies = [ ('auth', '0002_concurrency_add_version_to_group...
mit
a4ce8b273e1d116ba543d63b0ef9ab33
50.900901
218
0.585662
4.416251
false
false
false
false
whitesmith/hawkpost
humans/migrations/0001_initial.py
1
3019
# -*- coding: utf-8 -*- # Generated by Django 1.9.2 on 2016-02-27 23:21 from __future__ import unicode_literals import django.contrib.auth.models import django.core.validators from django.db import migrations, models import django.utils.timezone class Migration(migrations.Migration): initial = True depende...
mit
60a3518d1e25d8e98de0b1fef037c461
64.630435
421
0.641934
4.294452
false
false
false
false
pythonindia/junction
junction/conferences/management/commands/conference_moderator.py
1
4433
# -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals from django.contrib.auth import get_user_model from django.contrib.auth.models import Permission from django.core.management.base import BaseCommand, CommandError from junction.conferences.models import Conference APP_PE...
mit
872392cf5a6555ee8dc78c573364b5b1
34.464
77
0.61561
4.371795
false
false
false
false
spectralpython/spectral
spectral/database/usgs.py
1
23468
''' Code for reading and managing USGS spectral library data. References: Kokaly, R.F., Clark, R.N., Swayze, G.A., Livo, K.E., Hoefen, T.M., Pearson, N.C., Wise, R.A., Benzel, W.M., Lowers, H.A., Driscoll, R.L., and Klein, A.J., 2017, USGS Spectral Library Version 7: U.S. Geological Survey Data Series 1035...
mit
5d0a4915eaf7bd1857ee2749ebeed8b8
37.854305
140
0.579981
4.106387
false
false
false
false
pythonindia/junction
junction/base/emailer.py
1
1234
# -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals from os import path from django.conf import settings from django.core.mail import send_mail from django.template.loader import render_to_string def send_email(to, context, template_dir): """Render given templates and send email to ...
mit
7d5eee4c238564111ebf37e054bde373
28.380952
88
0.672609
3.661721
false
false
false
false
spectralpython/spectral
spectral/tests/database.py
1
6646
''' Runs unit tests of functions associated with spectral databases. To run the unit tests, type the following from the system command line: # python -m spectral.tests.database Note that the ECOSTRESS database must be requested so if the data files are not located on the local file system, these tests will be sk...
mit
034fa493e040b8c680feb1060ccffe3b
36.337079
112
0.616611
3.409954
false
true
false
false
spectralpython/spectral
spectral/algorithms/classifiers.py
1
16400
''' Supervised classifiers and base class for all classifiers. ''' from __future__ import absolute_import, division, print_function, unicode_literals import logging import math import numpy import numpy as np from warnings import warn import spectral as spy from .algorithms import GaussianStats, ImageIterator from ...
mit
8b6569df9b0a087b0393d8cb947f3c5b
35.853933
82
0.599024
4.331749
false
false
false
false
pythonindia/junction
junction/schedule/migrations/0003_scheduleitemtype.py
1
2711
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models SCHEDULE_ITEM_TYPES = ["Talk", "Lunch", "Break", "Workshop", "Poster", "Open Space"] def load_fixture(apps, schema_editor): Model = apps.get_model("schedule", "ScheduleItemTy...
mit
b7545ec2ac2e1095c3abe6670c59889f
32.469136
87
0.459609
4.94708
false
false
false
false
spectralpython/spectral
spectral/algorithms/resampling.py
1
7807
''' Functions for resampling a spectrum from one band discretization to another. ''' from __future__ import absolute_import, division, print_function, unicode_literals import logging import math import numpy as np from ..spectral import BandInfo def erf_local(x): # save the sign of x sign = 1 if x >= 0 else...
mit
707d4dc1527553aa9165c0878e0f00b0
31.802521
90
0.596644
3.524605
false
false
false
false
oss/shrunk
backend/shrunk/api/security.py
1
5372
from crypt import methods from os import link from pydoc import cli from typing import Any from flask import Blueprint, abort, current_app, jsonify from shrunk.client import ShrunkClient from ..client.exceptions import NoSuchObjectException, InvalidStateChange from shrunk.util.decorators import require_login from bson...
mit
b2c8e1f64cb3446816ff73fd1780ee51
30.6
97
0.664185
3.684499
false
false
false
false
spectralpython/spectral
spectral/io/bsqfile.py
1
13367
''' Code for handling files that are band sequential (BSQ). ''' from __future__ import absolute_import, division, print_function, unicode_literals import array import logging import numpy as np import os import sys import spectral as spy from ..utilities.python23 import typecode, tobytes, frombytes from .spyfile imp...
mit
006c9537c51e4fa6c1424d1e485268e4
32.168734
82
0.524875
4.045702
false
false
false
false
markstory/lint-review
tests/tools/test_pytype.py
1
4014
from lintreview.review import Problems, Comment from lintreview.tools.pytype import Pytype from unittest import TestCase from tests import root_dir, requires_image, read_file, read_and_restore_file class TestPytype(TestCase): fixtures = [ 'tests/fixtures/pytype/no_errors.py', 'tests/fixtures/pyty...
mit
7cc128a65ee8bd8f9280c2dbc1788d84
34.839286
76
0.616094
3.702952
false
true
false
false
markstory/lint-review
lintreview/tools/yamllint.py
1
1718
import os import lintreview.docker as docker from lintreview.review import IssueComment from lintreview.tools import Tool, process_quickfix, extract_version class Yamllint(Tool): name = 'yamllint' def version(self): output = docker.run('python2', ['yamllint', '--version'], self.base_path) r...
mit
51edd417a307b3fc2fa073a6d34d3afe
29.140351
81
0.566356
4.139759
false
true
false
false
markstory/lint-review
tests/test_processor.py
1
6893
from unittest import TestCase from mock import patch, sentinel, ANY import json import responses from lintreview.config import build_review_config from lintreview.diff import DiffCollection from lintreview.processor import Processor from lintreview.fixers.error import ConfigurationError, WorkflowError from . import l...
mit
88d28546799061a2e7aa458bcb117be1
31.060465
88
0.622806
3.916477
false
true
false
false
markstory/lint-review
tests/test_diff.py
1
14939
import re from unittest import TestCase from mock import patch from . import load_fixture, create_pull_files from lintreview.diff import DiffCollection, Diff, parse_diff, ParseError class TestDiffCollection(TestCase): # Single file, single commit one_file = load_fixture('diff/one_file_pull_request.txt') ...
mit
8c7fa142a5ff8e37077a5e68ab0ca9d0
36.916244
85
0.633108
3.694115
false
true
false
false
markstory/lint-review
lintreview/cli.py
1
3417
import argparse import lintreview.github as github import sys from flask import url_for from lintreview.web import app def main(): parser = create_parser() args = parser.parse_args() args.func(args) def register_hook(args): try: process_hook(github.register_hook, args) sys.stdout.wr...
mit
085ee6f0a7ef1baa6a9877c17b74d3a1
28.205128
77
0.585601
4.287327
false
false
false
false
markstory/lint-review
lintreview/tools/goodcheck.py
1
2306
import logging import json import lintreview.docker as docker from lintreview.tools import Tool log = logging.getLogger(__name__) class Goodcheck(Tool): name = 'goodcheck' def check_dependencies(self): """ See if ruby image exists """ return docker.image_exists('ruby2') ...
mit
9058bdaea3bf4c0ec7f06c3afc473e2f
31.942857
77
0.533391
4.460348
false
false
false
false
markstory/lint-review
tests/tools/test_foodcritic.py
1
1733
import os from lintreview.review import Comment, Problems from lintreview.tools.foodcritic import Foodcritic from unittest import TestCase from tests import root_dir, requires_image class TestFoodcritic(TestCase): fixtures = [ 'tests/fixtures/foodcritic/noerrors', 'tests/fixtures/foodcritic/error...
mit
e238517ea3e1d37d0fd0af65c7200540
32.980392
74
0.583381
4.020882
false
true
false
false
kivy/plyer
plyer/platforms/win/audio.py
1
9787
''' Documentation: http://docs.microsoft.com/en-us/windows/desktop/Multimedia .. versionadded:: 1.4.0 ''' from os.path import join from ctypes import windll from ctypes import ( sizeof, c_void_p, c_ulonglong, c_ulong, c_wchar_p, byref, Structure, create_string_buffer ) from ctypes.wintypes import DWORD, UINT...
mit
f894d3712e81fc6770e87657f1ddd6e1
23.590452
79
0.580157
3.994694
false
false
false
false
kivy/plyer
examples/temperature/main.py
2
1794
from kivy.app import App from kivy.clock import Clock from kivy.lang import Builder from kivy.properties import NumericProperty from kivy.properties import ObjectProperty from kivy.uix.boxlayout import BoxLayout Builder.load_string(''' #:import temperature plyer.temperature <TemperatureInterface>: temperature: te...
mit
3d61017b5a96b2d000e030b2a377f3ce
25.382353
74
0.622631
4.440594
false
false
false
false
kivy/plyer
plyer/utils.py
1
9554
''' Utils ===== ''' __all__ = ('platform', 'reify', 'deprecated') from os import environ from os import path from sys import platform as _sys_platform import sys class Platform: ''' Refactored to class to allow module function to be replaced with module variable. ''' def __init__(self): ...
mit
244d5bef37c877a331f723c150e1b4af
31.944828
79
0.559661
4.386593
false
false
false
false
kivy/plyer
plyer/facades/email.py
1
1460
''' Email ===== The :class:`Email` provides access to public methods to use email of your device. .. note:: On Android `INTERNET` permission is needed. Simple Examples --------------- To send an e-mail:: >>> from plyer import email >>> recipient = 'abc@gmail.com' >>> subject = 'Hi' >>> text = '...
mit
721933c910cc15a9b3833f616184af9e
24.172414
73
0.59726
4.294118
false
false
false
false
kivy/plyer
plyer/facades/irblaster.py
1
2551
''' IrBlaster ============ The :class:`IrBlaster` provides access to public methods by which your device can act as a remote and could be used to control your TV, AC, Music Player, Projectors, Set top box or anything that can be controlled by a remote. .. note:: - On Android your app needs the TRANSMIT_IR permiss...
mit
d1f3266ac9a41ec65b236c132fb79add
23.528846
77
0.594277
4.483304
false
false
false
false
kivy/plyer
plyer/platforms/macosx/libs/osx_motion_sensor.py
1
3173
import ctypes from ctypes import ( Structure, cdll, sizeof, c_int8, c_int16, c_size_t ) from ctypes.util import find_library import platform ERROR_DICT = { "0": "IOKit Framework not found, is this OSX?", "-1": "No SMCMotionSensor service", "-2": "No sms device", "-3": "Could not open motion sen...
mit
f3a5dce473139a435ce3931ab53390cf
23.789063
73
0.636621
3.379127
false
false
false
false
uploadcare/pyuploadcare
pyuploadcare/transformations/image.py
1
10674
from typing import List, Optional, Union from pyuploadcare.transformations.base import BaseTransformation, StrEnum class StretchMode(StrEnum): on = "on" off = "off" fill = "fill" class CropAlignment(StrEnum): center = "center" # type: ignore top = "top" right = "right" bottom = "bottom...
mit
ccba670124c5253f1c37cafb72c68476
26.510309
77
0.581132
3.634321
false
false
false
false
kivy/plyer
plyer/facades/gyroscope.py
1
3203
''' Gyroscope ============ The gyroscope measures the rate of rotation around a device's x, y, and z axis. The :class:`Gyroscope` provides access to public methods to use gyroscope of your device. Simple Examples --------------- To enable gyroscope:: >>> from plyer import gyroscope >>> gyroscope.enable() ...
mit
147d4c24296f1abceb539fa96f5cfd9a
24.420635
78
0.632844
4.013784
false
false
false
false
kivy/plyer
examples/storagepath/main.py
1
1737
''' Storage Path Example. ''' from kivy.lang import Builder from kivy.app import App from kivy.uix.boxlayout import BoxLayout Builder.load_string(''' #: import storagepath plyer.storagepath <StoragePathInterface>: BoxLayout: orientation: 'vertical' BoxLayout: Button: te...
mit
a5b4150ee9a7b468bd6af3a61fa180a2
27.016129
76
0.533103
4.205811
false
false
false
false
kivy/plyer
plyer/platforms/macosx/uniqueid.py
2
1071
''' Module of MacOS API for plyer.uniqueid. ''' from os import environ from subprocess import Popen, PIPE from plyer.facades import UniqueID from plyer.utils import whereis_exe class OSXUniqueID(UniqueID): ''' Implementation of MacOS uniqueid API. ''' def _get_uid(self): old_lang = environ.g...
mit
3284db57ef718b109fe048619c25bdb2
21.787234
59
0.578898
3.705882
false
false
false
false
uploadcare/pyuploadcare
pyuploadcare/api/entities.py
1
3405
from datetime import datetime from decimal import Decimal from enum import Enum from typing import Dict, List, Optional, Tuple from uuid import UUID from pydantic import BaseModel, EmailStr, PrivateAttr class Entity(BaseModel): ... class IDEntity(Entity): id: UUID class UUIDEntity(Entity): uuid: UUID...
mit
129f9feeb38414be958e0f409c65cc37
19.389222
57
0.681057
3.62234
false
false
false
false
kivy/plyer
plyer/platforms/android/gravity.py
1
2078
''' Android gravity --------------------- ''' from jnius import autoclass from jnius import cast from jnius import java_method from jnius import PythonJavaClass from plyer.facades import Gravity from plyer.platforms.android import activity Context = autoclass('android.content.Context') Sensor = autoclass('android.ha...
mit
2541447dfdf3c4ef59f8a2b76227a5fe
23.738095
76
0.62127
4.106719
false
false
false
false
uploadcare/pyuploadcare
pyuploadcare/api/api.py
1
11929
import hashlib import hmac from time import time from typing import Any, Dict, Iterable, List, Optional, Union, cast from uuid import UUID from httpx._types import RequestFiles from pyuploadcare.api import entities, responses from pyuploadcare.api.base import ( API, CreateMixin, DeleteMixin, DeleteWit...
mit
d4622c4ddbcb8fdc5a560716f9af8050
31.504087
91
0.592003
4.093686
false
false
false
false
kivy/plyer
plyer/platforms/win/libs/balloontip.py
1
6418
# -- coding: utf-8 -- ''' Module of Windows API for creating taskbar balloon tip notification in the taskbar's tray notification area. ''' __all__ = ('WindowsBalloonTip', 'balloon_tip') import time import ctypes import atexit from threading import RLock from plyer.platforms.win.libs import win_api_defs WS_OVERLAP...
mit
da267babf0528320e71260bcd25c2d25
30.15534
79
0.603303
3.722738
false
false
false
false
uploadcare/pyuploadcare
pyuploadcare/transformations/base.py
1
1305
from enum import Enum from typing import List, Optional, Union class StrEnum(str, Enum): def __str__(self): return self.value class BaseTransformation: def __init__( self, transformation: Optional[Union[str, "BaseTransformation"]] = None ): if isinstance(transformation, BaseTrans...
mit
25b54d82253640b39cad54b5033d6a13
24.588235
79
0.571648
4.453925
false
false
false
false
kivy/plyer
plyer/platforms/macosx/wifi.py
2
5218
from pyobjus import autoclass from pyobjus.dylib_manager import load_framework, INCLUDE from plyer.facades import Wifi load_framework(INCLUDE.Foundation) load_framework(INCLUDE.CoreWLAN) CWInterface = autoclass('CWInterface') CWNetwork = autoclass('CWNetwork') CWWiFiClient = autoclass('CWWiFiClient') NSArray = autoc...
mit
93dfc32a1631d0c09ba950240395ba56
34.496599
77
0.613645
4.21827
false
false
false
false
kivy/plyer
plyer/platforms/android/vibrator.py
1
1844
"""Implementation Vibrator for Android.""" from jnius import autoclass, cast from plyer.facades import Vibrator from plyer.platforms.android import activity from plyer.platforms.android import SDK_INT Context = autoclass("android.content.Context") vibrator_service = activity.getSystemService(Context.VIBRATOR_SERVICE)...
mit
e88b6705540601d886a53e2f13afd96a
28.269841
75
0.605206
3.882105
false
false
false
false
kivy/plyer
plyer/__init__.py
1
4074
''' Plyer ===== ''' __all__ = ( 'accelerometer', 'audio', 'barometer', 'battery', 'bluetooth', 'brightness', 'call', 'camera', 'compass', 'cpu', 'email', 'filechooser', 'flash', 'gps', 'gravity', 'gyroscope', 'humidity', 'irblaster', 'keystore', 'light', 'notification', 'orientation', 'processors', ...
mit
e54881dac1c216bfeaa7f4d39663431e
31.854839
77
0.731959
2.850945
false
false
false
false
caktus/django-timepiece
timepiece/tests/test_management.py
3
8043
from dateutil.relativedelta import relativedelta from django.utils import timezone from django.test import TestCase from timepiece import utils from timepiece.management.commands import check_entries from timepiece.entries.models import Entry from . import factories class CheckEntries(TestCase): def setUp(sel...
mit
14d3382d2444f9a670c6de0c09f603c9
39.621212
86
0.595549
4.049849
false
true
false
false
caktus/django-timepiece
timepiece/crm/migrations/0003_auto_20151119_0906.py
1
1361
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('crm', '0002_auto_20150115_1654'), ] operations = [ migrations.AlterField( model_name='attribute', na...
mit
67499592b46832c28249e1951c30ffaa
33.897436
157
0.590742
4.536667
false
false
false
false
caktus/django-timepiece
timepiece/entries/forms.py
1
7826
import datetime from dateutil.relativedelta import relativedelta from django import forms from django.db.models import Q from selectable import forms as selectable from timepiece import utils from timepiece.crm.models import Project, ProjectRelationship from timepiece.entries.models import Entry, Location, ProjectHo...
mit
c0ff9ab692d35f8202968bf07bd28322
36.990291
98
0.600946
4.221143
false
false
false
false
caktus/django-timepiece
timepiece/contracts/migrations/0003_auto_20151119_0906.py
1
1396
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('contracts', '0002_auto_20150115_1654'), ] operations = [ migrations.AlterField( model_name='contracthour', ...
mit
de703e7b71beffa828342d5b94dca63a
34.794872
156
0.567335
4.217523
false
false
false
false
openelections/openelections-core
openelex/us/sc/datasource.py
1
5065
from future import standard_library standard_library.install_aliases() from os.path import join import json import datetime import urllib.parse import clarify from openelex import PROJECT_ROOT from openelex.base.datasource import BaseDatasource from openelex.lib import build_raw_github_url class Datasource(BaseDataso...
mit
eed722aedd382d9bbe3d4d7d7f4f1951
37.371212
120
0.517473
4.355116
false
false
false
false
openelections/openelections-core
openelex/us/pa/datasource.py
1
3643
""" Standardize names of data files from the Pennsylvania Secretary of State. The state offers CSV files containing precinct-level results for regularly scheduled primary and general elections; these were split from a single zip file into election-specific files and thus have no `raw_url` attribute. Special elections ...
mit
9de31558306c8140b51a3932b26e0e97
37.347368
148
0.595388
4.135074
false
false
false
false
openelections/openelections-core
openelex/us/la/datasource.py
1
3897
""" Louisiana has pre-processed county-level CSV files available on Github at https://github.com/openelections/openelections-data-la. """ from future import standard_library standard_library.install_aliases() from builtins import str from os.path import join import json import datetime import urllib.parse from openele...
mit
70cf568dfc5ae2475b790404f0e35020
33.184211
101
0.57788
4.07636
false
false
false
false
openelections/openelections-core
openelex/us/vt/datasource.py
1
8965
""" In VT, we have to search for elections on the vermont secretary of state website. We will be given some election id, we can then query election results with: http://vtelectionarchive.sec.state.vt.us/elections/download/%election-id%/precincts_include:0/ or http://vtelectionarchive.sec.state.vt.us/electi...
mit
d9a98bacffb2bb333de812e906f3b396
40.313364
142
0.631456
3.351402
false
false
false
false
viblo/pymunk
pymunk/shapes.py
1
25479
__docformat__ = "reStructuredText" import logging from typing import TYPE_CHECKING, List, Optional, Sequence, Tuple if TYPE_CHECKING: from .body import Body from .space import Space from ._chipmunk_cffi import ffi from ._chipmunk_cffi import lib as cp from ._pickle import PickleMixin, _State from ._typing_at...
mit
6bd401bb44366eb8a289133c421d4230
32.881649
88
0.583186
3.880445
false
false
false
false
viblo/pymunk
pymunk/matplotlib_util.py
1
3667
"""This submodule contains helper functions to help with quick prototyping using pymunk together with pyglet. Intended to help with debugging and prototyping, not for actual production use in a full application. The methods contained in this module is opinionated about your coordinate system and not very optimized (...
mit
13ff98338596412faa4d71f818dc786a
29.305785
86
0.589583
3.627102
false
false
false
false
viblo/pymunk
pymunk/bb.py
1
3510
__docformat__ = "reStructuredText" from typing import NamedTuple, Tuple from . import _chipmunk_cffi lib = _chipmunk_cffi.lib ffi = _chipmunk_cffi.ffi from .vec2d import Vec2d class BB(NamedTuple): """Simple axis-aligned 2D bounding box. Stored as left, bottom, right, top values. An instance can be c...
mit
c6de0e771b52daa87023e4714b1d05cc
30.061947
85
0.5849
3.346044
false
false
false
false
viblo/pymunk
dump/pyramid_bench.py
1
2877
"""Basic benchmark of a pyramid of boxes Results with 10000 iterations (lower is better) python 2.6: 186.8 sec pypy-1.9: 428.9 sec """ import timeit import pymunk from pymunk import Vec2d class PyramidDemo: def flipyv(self, v): return v[0], -v[1]+self.h def __init__(self):...
mit
1f749ee06054716c778f415a61fc23cf
27.080808
105
0.466111
3.651015
false
false
false
false
openelections/openelections-core
openelex/tasks/datasource.py
1
3581
from __future__ import print_function import csv from pprint import pprint import inspect import sys import click from openelex.base.datasource import MAPPING_FIELDNAMES from .utils import default_state_options, load_module def handle_task(task, state, datefilter): "Call Datasoure methods dynamically based on ...
mit
62dbb92b3f6414554eb29510464caa28
32.783019
122
0.687797
3.741902
false
false
false
false
viblo/pymunk
pymunk/examples/arrows.py
1
7410
"""Showcase of flying arrows that can stick to objects in a somewhat realistic looking way. """ import sys from typing import List import pygame import pymunk import pymunk.pygame_util from pymunk.vec2d import Vec2d def create_arrow(): vs = [(-30, 0), (0, 3), (10, 0), (0, -3)] # mass = 1 # moment = pym...
mit
f3fa63b2823f8a56536c85fb6e1c4ea1
31.933333
87
0.57193
3.408464
false
false
false
false
viblo/pymunk
dump/many_crash.py
1
1387
import gc import multiprocessing import random import pymunk random.seed(0) loops = 20 num_objects = 200 d = {} def f(x): print(f"loop {x}/{loops}") s = pymunk.Space() for x in range(num_objects): b = pymunk.Body(10, 20) c = lambda: pymunk.Circle(b, 10) e = lambda: pymunk.S...
mit
a49d28b59c2f2a91107675e57d0e79ae
20.015152
79
0.524153
3.075388
false
false
false
false
viblo/pymunk
pymunk/tests/test_shape_filter.py
1
1109
import pickle import unittest import pymunk as p class UnitTestShapeFilter(unittest.TestCase): def testInit(self) -> None: f = p.ShapeFilter() self.assertEqual(f.group, 0) self.assertEqual(f.categories, 0xFFFFFFFF) self.assertEqual(f.mask, 0xFFFFFFFF) f = p.ShapeFilter(1,...
mit
0d39d8c6ff2176294b6b9d3c5dd77da2
25.404762
68
0.625789
3.340361
false
true
false
false
openelections/openelections-core
openelex/us/ar/datasource.py
1
9828
from future import standard_library standard_library.install_aliases() import os.path import re import urllib.parse from bs4 import BeautifulSoup import requests import unicodecsv from openelex.base.datasource import BaseDatasource from openelex.lib import build_github_url from openelex.lib.text import ocd_type_id ...
mit
b5b6c5dd36c6041a0abb8251b74e46ff
40.294118
104
0.588523
3.9
false
false
false
false
openelections/openelections-core
openelex/us/sd/datasource.py
1
5593
""" Standardize names of data files on South Dakota Secretary of State website. The state offers PDF files containing precinct-level results for statewide candidates (includes U.S. House) and state legislative candidates. The CSV versions of those are contained in the https://github.com/openelections/openelections-da...
mit
283434198921a04ed901a1acd34d0795
39.23741
158
0.571607
4.076531
false
false
false
false
openelections/openelections-core
openelex/us/ga/datasource.py
1
5614
""" Stake in the ground for GA results """ from future import standard_library standard_library.install_aliases() from os.path import join import json import datetime import urllib.parse from openelex import PROJECT_ROOT from openelex.lib import build_github_url from openelex.base.datasource import BaseDatasource cla...
mit
dc7e3f0aef375023ffc6022bfb475cad
38.535211
122
0.508906
4.338485
false
false
false
false
viblo/pymunk
benchmarks/vec2d_baseclass.py
1
3960
"""Test different ways to implement Vec2d. Compares: - Object and NamedTuple as base classes - Ways to create a Vec2d. """ from typing import NamedTuple import pymunk print("pymunk.version", pymunk.version) s = None g = None vec_obj = None vec_ntuple = None def setup(): global s global g glob...
mit
df290c5bcdb8928846caca36e3ed4131
22.431953
73
0.570707
3.209076
false
false
false
false
viblo/pymunk
pymunk/examples/platformer.py
1
10982
"""Showcase of a very basic 2d platformer The red girl sprite is taken from Sithjester's RMXP Resources: http://untamed.wild-refuge.net/rmxpresources.php?characters .. note:: The code of this example is a bit messy. If you adapt this to your own code you might want to structure it a bit differently. """ __docfo...
mit
5f2447a202f1d3911777364cc80f9668
31.39528
88
0.562739
3.361494
false
false
false
false
openelections/openelections-core
openelex/us/md/validate/election.py
1
21387
from __future__ import print_function from builtins import object import os import unicodecsv from openelex.models import Contest, Candidate, Result from openelex.us.md import jurisdiction from functools import reduce # Classes that describe election attributes class MDElection(object): """ Base class for d...
mit
cb1399c9dfa06a111b4371b6e304b793
33.329053
93
0.63908
3.396379
false
true
false
false