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
mozilla/pontoon
pontoon/sync/tests/formats/test_compare_locales.py
2
9468
import os import shutil import tempfile from textwrap import dedent import pytest from pontoon.base.tests import ( create_named_tempfile, LocaleFactory, TestCase, ) from pontoon.sync.exceptions import ParseError from pontoon.sync.formats import compare_locales from pontoon.sync.tests.formats import Forma...
bsd-3-clause
9df047c488cfe756c1a1abe31fae9743
28.495327
87
0.59548
4.150811
false
true
false
false
mozilla/pontoon
pontoon/base/migrations/0029_external_accounts.py
2
1039
# Generated by Django 3.2.13 on 2022-08-03 19:14 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("base", "0028_userprofile_new_contributor_notifications"), ] operations = [ migrations.AddField( model_name="userprofile", ...
bsd-3-clause
bbc2cdf98eb535d2288fb62c27ffb4c2
27.081081
85
0.524543
4.68018
false
false
false
false
pkkid/python-plexapi
plexapi/sync.py
1
13729
# -*- coding: utf-8 -*- """ You can work with Mobile Sync on other devices straight away, but if you'd like to use your app as a `sync-target` (when you can set items to be synced to your app) you need to init some variables. .. code-block:: python def init_sync(): import plexapi plexapi.X_PLEX_PR...
bsd-3-clause
0ea226968927c3d72c94e246657fcae3
42.86262
120
0.644402
3.846736
false
false
false
false
pkkid/python-plexapi
tools/version_bump.py
2
3173
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Helper script to bump the current version.""" import argparse import re import subprocess from packaging.version import Version from plexapi import const SUPPORTED_BUMP_TYPES = ["patch", "minor", "major"] def _bump_release(release, bump_type): """Return a bumpe...
bsd-3-clause
56cd5accb262b0506aeb42cec29f63ec
28.933962
87
0.617082
3.597506
false
false
false
false
pkkid/python-plexapi
tools/plex-listdocattrs.py
1
1356
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Plex-ListDocAttrs is used during development of PlexAPI. Example usage: AttDS(dict or object).write() """ import re from collections import OrderedDict def type_finder(s): type_string = str(type(s)) x = re.search("'(.+)'", type_string) if x: retur...
bsd-3-clause
c4bc05b15b7b5172381f7803dc0f9dbb
25.588235
70
0.487463
3.503876
false
false
false
false
pkkid/python-plexapi
plexapi/server.py
1
60071
# -*- coding: utf-8 -*- from urllib.parse import urlencode from xml.etree import ElementTree import requests import os from plexapi import (BASE_HEADERS, CONFIG, TIMEOUT, X_PLEX_CONTAINER_SIZE, log, logfilter) from plexapi import utils from plexapi.alert import AlertListener from plexapi.base impo...
bsd-3-clause
24b93ef0d84092023427f98178904b2a
48.312808
124
0.616486
4.358708
false
false
false
false
pinax/symposion
symposion/schedule/models.py
2
9090
from __future__ import unicode_literals import datetime from django.core.exceptions import ObjectDoesNotExist from django.contrib.auth.models import User from django.db import models from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ from symposion.m...
bsd-3-clause
e2283d1126de40240542b318c85c3be8
30.023891
116
0.616612
4.022124
false
false
false
false
pinax/symposion
symposion/sponsorship/forms.py
5
2692
from __future__ import unicode_literals from django import forms from django.forms.models import inlineformset_factory, BaseInlineFormSet from django.contrib.admin.widgets import AdminFileWidget from django.utils.translation import ugettext_lazy as _ from symposion.sponsorship.models import Sponsor, SponsorBenefit ...
bsd-3-clause
7a3e5a4930d64be0a0476cfbc176d944
31.433735
112
0.610327
4.035982
false
false
false
false
pinax/symposion
symposion/speakers/views.py
2
4402
from __future__ import unicode_literals from django.core.exceptions import ObjectDoesNotExist from django.http import Http404 from django.shortcuts import render, redirect, get_object_or_404 from django.contrib import messages from django.contrib.auth.models import User from django.utils.translation import ugettext_la...
bsd-3-clause
a90ce88392d60bb92feefeb2d9a720a0
30.898551
81
0.629487
4.148916
false
false
false
false
pinax/symposion
symposion/reviews/views.py
2
18632
from django.core.mail import send_mass_mail from django.db.models import Q from django.http import HttpResponseBadRequest, HttpResponseNotAllowed from django.shortcuts import render, redirect, get_object_or_404 from django.template import Context, Template from django.views.decorators.http import require_POST from acc...
bsd-3-clause
669676fa08c2f5fae7b939aa009239e0
35.319688
162
0.625805
3.967632
false
false
false
false
tryolabs/luminoth
luminoth/utils/anchors.py
1
1818
import numpy as np def generate_anchors_reference(base_size, aspect_ratios, scales): """Generate base anchor to be used as reference of generating all anchors. Anchors vary only in width and height. Using the base_size and the different ratios we can calculate the wanted widths and heights. Scales a...
bsd-3-clause
12fb1fcdb1e86445d0c491200af87174
33.961538
79
0.622662
3.695122
false
false
false
false
tryolabs/luminoth
luminoth/models/base/truncated_base_network.py
1
6666
import tensorflow as tf import tensorflow.contrib.slim as slim from tensorflow.contrib.slim.nets import resnet_utils, resnet_v1 from luminoth.models.base import BaseNetwork DEFAULT_ENDPOINTS = { 'resnet_v1_50': 'block3', 'resnet_v1_101': 'block3', 'resnet_v1_152': 'block3', 'resnet_v2_50': 'block3', ...
bsd-3-clause
394ca1017b5ce0b619437d37456ec0ed
38.443787
79
0.539904
4.559508
false
true
false
false
tryolabs/luminoth
luminoth/models/fasterrcnn/rcnn_target.py
1
12823
import tensorflow as tf import sonnet as snt from luminoth.utils.bbox_transform_tf import encode from luminoth.utils.bbox_overlap import bbox_overlap_tf class RCNNTarget(snt.AbstractModule): """Generate RCNN target tensors for both probabilities and bounding boxes. Targets for RCNN are based upon the result...
bsd-3-clause
2768b13189b64bd3eecf7561ddf69662
41.886288
79
0.59908
4.019749
false
false
false
false
cclib/cclib
cclib/method/bader.py
3
9345
# -*- coding: utf-8 -*- # # Copyright (c) 2020, the cclib development team # # This file is part of cclib (http://cclib.github.io) and is distributed under # the terms of the BSD 3-Clause License. """Calculation of Bader's QTAIM charges based on data parsed by cclib.""" import copy import random import numpy import lo...
bsd-3-clause
a46efcbb9981b845ea6219abe29b36aa
41.866972
260
0.547352
4.063043
false
false
false
false
cclib/cclib
cclib/parser/nwchemparser.py
2
64319
# -*- coding: utf-8 -*- # # Copyright (c) 2020, the cclib development team # # This file is part of cclib (http://cclib.github.io) and is distributed under # the terms of the BSD 3-Clause License. """Parser for NWChem output files""" import itertools import re import numpy from cclib.parser import l...
bsd-3-clause
6f46ae2fc91aae66bcf3d2a6c37c99cf
45.92772
137
0.475505
4.16412
false
false
false
false
cclib/cclib
cclib/method/mbo.py
3
4085
# -*- coding: utf-8 -*- # # Copyright (c) 2017, the cclib development team # # This file is part of cclib (http://cclib.github.io) and is distributed under # the terms of the BSD 3-Clause License. """Calculation of Mayer's bond orders based on data parsed by cclib.""" import random import numpy from cc...
bsd-3-clause
37718e29bb38a9dac6fa2edea90f506d
31.211382
80
0.507711
4.151423
false
false
false
false
feincms/feincms
feincms/module/page/extensions/titles.py
2
2115
""" Sometimes, a single title is not enough, you'd like subtitles, and maybe differing titles in the navigation and in the <title>-tag. This extension lets you do that. """ from django.db import models from django.utils.translation import gettext_lazy as _ from feincms import extensions from feincms._internal impor...
bsd-3-clause
6dcd71e2a188c6567ddaa8cca7e3aaad
28.375
84
0.521513
4.597826
false
false
false
false
feincms/feincms
feincms/templatetags/feincms_page_tags.py
2
17283
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------ import logging import sys import traceback from django import template from django.apps import apps from django.conf import settings from django.http import HttpReques...
bsd-3-clause
fa902370a08528c27d8ce762c0c3a599
32.300578
88
0.55083
4.467046
false
false
false
false
feincms/feincms
feincms/content/section/models.py
2
3662
from django.conf import settings as django_settings from django.contrib import admin from django.core.exceptions import ImproperlyConfigured from django.db import models from django.utils.translation import gettext_lazy as _ from feincms import settings from feincms.admin.item_editor import FeinCMSInline from feincms....
bsd-3-clause
9abb9cbf59172a9b5dddd2c0bfb9d8f1
32.59633
86
0.604042
4.263097
false
false
false
false
feincms/feincms
feincms/utils/managers.py
2
1997
# ------------------------------------------------------------------------ class ActiveAwareContentManagerMixin: """ Implement what's necessary to add some kind of "active" state for content objects. The notion of active is defined by a number of filter rules that must all match (AND) for the object to ...
bsd-3-clause
cecc58b6d08d7e64f14f5b4ceafb4b36
36.679245
79
0.604907
4.732227
false
false
false
false
jupyter/nbgrader
nbgrader/exchange/default/list.py
2
10184
import os import glob import shutil import re import hashlib from nbgrader.exchange.abc import ExchangeList as ABCExchangeList from nbgrader.utils import notebook_hash, make_unique_key from .exchange import Exchange def _checksum(path): m = hashlib.md5() m.update(open(path, 'rb').read()) return m.hexdige...
bsd-3-clause
e57319dbadf88fe7646ef6df181625fd
41.610879
146
0.542714
4.404844
false
false
false
false
jupyter/nbgrader
nbgrader/converters/generate_feedback.py
2
2383
import os from traitlets.config import Config from traitlets import List, default from nbconvert.exporters import HTMLExporter from nbconvert.preprocessors import CSSHTMLHeaderPreprocessor from .base import BaseConverter from ..preprocessors import GetGrades class GenerateFeedback(BaseConverter): @property ...
bsd-3-clause
e54eb3305f66ff396362f3100ed5c7f3
34.044118
169
0.641209
4.025338
false
true
false
false
jupyter/nbgrader
nbgrader/apps/extensionapp.py
3
1166
# coding: utf-8 from traitlets.config.application import catch_config_error from .baseapp import NbGrader, format_excepthook _compat_message = """ The installation of the nbgrader extensions are now managed through the `jupyter nbextension` and `jupyter serverextension` commands. To install and enable the nbextensi...
bsd-3-clause
48567e2322aae3e4fca010c763dfb2db
30.513514
83
0.716123
3.749196
false
true
false
false
jupyter/nbgrader
nbgrader/exchange/default/collect.py
2
6185
import os import glob import shutil import sys from collections import defaultdict from textwrap import dedent import datetime from nbgrader.exchange.abc import ExchangeCollect as ABCExchangeCollect from .exchange import Exchange from nbgrader.utils import check_mode, parse_utc from ...api import Gradebook, MissingEn...
bsd-3-clause
dab6322f176e83ce7e069b0d85e629b9
41.951389
128
0.580275
4.233402
false
false
false
false
jupyter/nbgrader
demos/demo_multiple_classes/jupyterhub_config.py
2
3458
c = get_config() # Our user list c.Authenticator.allowed_users = [ 'instructor1', 'instructor2', 'student1', 'grader-course101', 'grader-course123', ] # instructor1 and instructor2 have access to different shared servers. # Note that groups providing access to the formgrader *must* start with # 'f...
bsd-3-clause
22b5843b7bcea03c8ad6bf2eccddc69d
26.887097
80
0.522846
3.974713
false
false
false
false
jupyter/nbgrader
nbgrader/apps/api.py
2
42264
import glob import re import sys import os import logging import warnings from traitlets.config import LoggingConfigurable, Config, get_config from traitlets import Instance, Enum, Unicode, observe from ..coursedir import CourseDirectory from ..converters import GenerateAssignment, Autograde, GenerateFeedback, Genera...
bsd-3-clause
ddc956921211eb654fc281a886055f1b
35.403101
114
0.554254
4.858489
false
false
false
false
jupyter/nbgrader
nbgrader/preprocessors/overwritecells.py
3
4363
from nbformat.v4.nbbase import validate from .. import utils from ..api import Gradebook, MissingEntry from . import NbGraderPreprocessor from nbconvert.exporters.exporter import ResourcesDict from nbformat.notebooknode import NotebookNode from typing import Tuple, Any class OverwriteCells(NbGraderPreprocessor): ...
bsd-3-clause
89c23fd50d135be026e1c6b0d702c92a
40.951923
107
0.599587
4.19923
false
false
false
false
jupyter/nbgrader
tasks.py
1
4400
#!/usr/bin/env python import os import sys import subprocess as sp import argparse def echo(msg): print("\033[1;37m{0}\033[0m".format(msg)) def run(cmd, **kwargs): echo(cmd) return sp.check_call(cmd, shell=True, **kwargs) try: from nbformat import read except ImportError: echo("Warning: nbfor...
bsd-3-clause
a4112b3be78d7626aa4752d771b7f222
25.190476
91
0.624091
3.32829
false
true
false
false
jupyter/nbgrader
nbgrader/plugins/export.py
3
4603
from traitlets import Unicode, List from .base import BasePlugin from ..api import MissingEntry, Gradebook class ExportPlugin(BasePlugin): """Base class for export plugins.""" to = Unicode("", help="destination to export to").tag(config=True) student = List( [], help="list of students to export...
bsd-3-clause
c1406b0ecaba360614acde17ec61e757
33.871212
80
0.528568
4.774896
false
false
false
false
jupyter/nbgrader
nbgrader/tests/apps/test_nbgrader_db.py
3
17232
import pytest import datetime import shutil import os from textwrap import dedent from os.path import join from ...api import Gradebook, MissingEntry from .. import run_nbgrader from .base import BaseTestApp class TestNbGraderDb(BaseTestApp): def test_help(self): """Does the help display without error?...
bsd-3-clause
a26dcdb6e9b65a92e527e1488e48581a
39.737589
127
0.539055
3.681265
false
true
false
false
dask/distributed
distributed/http/tests/test_routing.py
1
1192
from __future__ import annotations import pytest from tornado import web from tornado.httpclient import AsyncHTTPClient, HTTPClientError from distributed.http.routing import RoutingApplication from distributed.utils_test import gen_test class OneHandler(web.RequestHandler): def get(self): self.write("on...
bsd-3-clause
3860dd4d31e13331690b2cb7c7d2f822
28.073171
66
0.699664
4.013468
false
true
false
false
dask/distributed
distributed/shuffle/_limiter.py
1
2359
from __future__ import annotations import asyncio from distributed.metrics import time class ResourceLimiter: """Limit an abstract resource This allows us to track usage of an abstract resource. If the usage of this resources goes beyond a defined maxvalue, we can block further execution Example::...
bsd-3-clause
638883f129bd5a107b887c3a5a913059
31.763889
106
0.593048
4.235189
false
false
false
false
jschneier/django-storages
storages/backends/gcloud.py
1
12276
import mimetypes import warnings from datetime import timedelta from tempfile import SpooledTemporaryFile from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import SuspiciousOperation from django.core.files.base import File from django.utils import timezone from django.utils.deconstruc...
bsd-3-clause
4b03dba852b86f7f82c4b9ce53f84223
35.319527
98
0.59653
4.191192
false
false
false
false
cherrypy/cherrypy
cherrypy/_cpreqbody.py
8
36382
"""Request body processing for CherryPy. .. versionadded:: 3.2 Application authors have complete control over the parsing of HTTP request entities. In short, :attr:`cherrypy.request.body<cherrypy._cprequest.Request.body>` is now always set to an instance of :class:`RequestBody<cherrypy._cpreqbody.RequestBody>`, and *...
bsd-3-clause
1382b61681917e958d824b0c8ca6ac20
35.638469
79
0.586032
4.27119
false
false
false
false
cherrypy/cherrypy
cherrypy/lib/httputil.py
1
18007
"""HTTP library functions. This module contains functions for building an HTTP application framework: any one, not just one whose name starts with "Ch". ;) If you reference any modules from some popular framework inside *this* module, FuManChu will personally hang you up by your thumbs and submit you to a public canin...
bsd-3-clause
c6748796536cbfc6b65083ae4f26fca8
31.859489
79
0.603099
4.060203
false
false
false
false
cherrypy/cherrypy
cherrypy/test/test_config_server.py
12
4037
"""Tests for the CherryPy configuration system.""" import os import cherrypy from cherrypy.test import helper localDir = os.path.join(os.getcwd(), os.path.dirname(__file__)) # Client-side code # class ServerConfigTests(helper.CPWebCase): @staticmethod...
bsd-3-clause
bf0c20c773ed31ef37b498fdd0269118
31.039683
76
0.513996
4.140513
false
true
false
false
cherrypy/cherrypy
cherrypy/test/test_routes.py
12
2583
"""Test Routes dispatcher.""" import os import importlib import pytest import cherrypy from cherrypy.test import helper curdir = os.path.join(os.getcwd(), os.path.dirname(__file__)) class RoutesDispatchTest(helper.CPWebCase): """Routes dispatcher test suite.""" @staticmethod def setup_server(): ...
bsd-3-clause
300f2a778fc83115718aec9449b67e4a
31.2875
78
0.565234
4.248355
false
true
false
false
cherrypy/cherrypy
cherrypy/test/test_conn.py
3
30744
"""Tests for TCP connection handling, including proper and timely close.""" import errno import socket import sys import time import urllib.parse from http.client import BadStatusLine, HTTPConnection, NotConnected from cheroot.test import webtest import cherrypy from cherrypy._cpcompat import HTTPSConnection, ntob, ...
bsd-3-clause
eb9fecf9017805ed567e15f037908458
34.583333
79
0.561443
4.265261
false
false
false
false
mozilla/mozilla-ignite
apps/projects/migrations/0004_auto__add_field_project_blog.py
2
7459
# encoding: utf-8 import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'Project.blog' db.add_column('projects_project', 'blog', self.gf('django.db.models.fields.U...
bsd-3-clause
91d97d253d0ded5b0a2a16bc5134c275
70.721154
182
0.548063
3.685277
false
false
false
false
mozilla/mozilla-ignite
apps/resources/views.py
1
1180
import jingo from django.http import Http404 from django.core.exceptions import ObjectDoesNotExist from jinja2.exceptions import TemplateNotFound from resources.models import Resource def object_list(request, template='resources/object_list.html'): """Lists the current resources""" labs = Resource.objects.f...
bsd-3-clause
f50db18afce308a347f1841bd59050b6
26.44186
71
0.65678
4.199288
false
false
false
false
mozilla/mozilla-ignite
apps/projects/tasks.py
1
2120
import bleach from celery.task import Task from django_push.subscriber.models import Subscription, SubscriptionError from projects.utils import PushFeedParser, FeedEntryParser from feeds.models import Entry # Whitelisted tags and attributes TAGS = ('h1', 'h2', 'h3', 'h4', 'h5', 'a', 'b', 'em', 'i', 'strong'...
bsd-3-clause
d6af245dc6b60225c5cc54447efe5ff1
30.641791
79
0.587736
3.854545
false
false
false
false
mozilla/mozilla-ignite
vendor-local/lib/python/requests/sessions.py
1
10866
# -*- coding: utf-8 -*- """ requests.session ~~~~~~~~~~~~~~~~ This module provides a Session object to manage and persist settings across requests (cookies, auth, proxies). """ from .compat import cookielib from .cookies import cookiejar_from_dict, remove_cookie_by_name from .defaults import defaults from .models i...
bsd-3-clause
c67578e08987ce969bc7e1f39729cca1
32.027356
116
0.597276
4.31876
false
false
false
false
mozilla/mozilla-ignite
apps/timeslot/models.py
1
2218
from datetime import timedelta, datetime from django.conf import settings from django.db import models from django_extensions.db.fields import AutoSlugField from timeslot.managers import (TimeSlotFreeManager, ReleaseManager, TimeSlotManager) from timeslot.utils import shorten_object cl...
bsd-3-clause
65319af5e991031513cf097d8736abbc
33.65625
71
0.643372
4.145794
false
false
false
false
mozilla/mozilla-ignite
vendor-local/lib/python/rsa/_version133.py
5
11243
"""RSA module pri = k[1] //Private part of keys d,p,q Module for calculating large primes, and RSA encryption, decryption, signing and verification. Includes generating public and private keys. WARNING: this code implements the mathematics of RSA. It is not suitable for real-world secur...
bsd-3-clause
a29449d20cbd3cedb861302ab6e18a77
24.552273
97
0.597794
3.316519
false
false
false
false
mozilla/mozilla-ignite
apps/projects/migrations/0006_auto__add_field_link_subscription.py
2
9607
# encoding: utf-8 import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'Link.subscription' db.add_column('projects_link', 'subscription', self.gf('django.db.model...
bsd-3-clause
c908a9f8a33dadd925b120fdf67c0612
71.233083
182
0.547101
3.702119
false
false
false
false
mozilla/mozilla-ignite
vendor-local/lib/python/south/db/sqlite3.py
10
9009
import inspect import re from django.db.models import ForeignKey from south.db import generic from django.core.management.commands import inspectdb class DatabaseOperations(generic.DatabaseOperations): """ SQLite3 implementation of database operations. """ backend_name = "sqli...
bsd-3-clause
2d4fc18a5fd394d6a87ae72c5ee897a4
38.95
128
0.567433
4.209813
false
false
false
false
mozilla/mozilla-ignite
vendor-local/lib/python/django_extensions/tests/encrypted_fields.py
22
2792
import unittest from django.db import connection from django.conf import settings from django.core.management import call_command from django.db.models import loading # Only perform encrypted fields tests if keyczar is present # Resolves http://github.com/django-extensions/django-extensions/issues/#issue/17 try: ...
bsd-3-clause
4191ba5a41a04ffc38bdf5f73ff2fe9a
36.226667
92
0.672278
3.835165
false
true
false
false
mozilla/mozilla-ignite
apps/challenges/exporter.py
1
2709
from challenges.models import SubmissionParent def get_category_data(obj): return { 'name': obj.name, 'slug': obj.slug, } def get_author(profile): user = profile.user return { 'name': profile.name, 'title': profile.title, 'website': profile.website, 'b...
bsd-3-clause
f9db986b6bcd1ce8cca55d9bb408b0ec
27.21875
67
0.591362
3.424779
false
false
false
false
mozilla/mozilla-ignite
vendor-local/lib/python/django_extensions/management/modelviz.py
8
13604
#!/usr/bin/env python """Django model to DOT (Graphviz) converter by Antonio Cavedoni <antonio@cavedoni.org> Make sure your DJANGO_SETTINGS_MODULE is set to your project or place this script in the same directory of the project and call the script like this: $ python modelviz.py [-h] [-a] [-d] [-g] [-n] [-L <languag...
bsd-3-clause
9c3de11ce3534348d166fe1ed1b6020c
36.89415
186
0.543811
4.331105
false
false
false
false
mozilla/mozilla-ignite
apps/challenges/migrations/0040_auto__add_field_submission_collaborators.py
1
19083
# encoding: utf-8 import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'Submission.collaborators' db.add_column('challenges_submission', 'collaborators', self.gf(...
bsd-3-clause
05a4710e3ac8c4902192efd562538b35
78.182573
241
0.554944
3.721334
false
false
false
false
mozilla/mozilla-ignite
vendor-local/lib/python/south/hacks/django_1_0.py
22
1992
""" Hacks for the Django 1.0/1.0.2 releases. """ from django.conf import settings from django.db import models from django.db.models.loading import AppCache, cache from django.utils.datastructures import SortedDict class Hacks: def set_installed_apps(self, apps): """ Sets Django's INSTALLED_A...
bsd-3-clause
e4ad673c04245bc38d2ba349903ec26a
25.573333
115
0.560241
4.15
false
false
false
false
mozilla/mozilla-ignite
apps/challenges/management/commands/identicon.py
3
7520
#!/usr/bin/env python # -*- coding:utf-8 -*- """ identicon.py identicon python implementation. by Shin Adachi <shn@glucose.jp> = usage = == commandline == >>> python identicon.py [code] == python == >>> import identicon >>> identicon.render_identicon(code, size) Return a PIL Image class instance which have generate...
bsd-3-clause
832ba686ac8d94b3221222c38e1ef3be
28.147287
96
0.465824
3.275261
false
false
false
false
mozilla/mozilla-ignite
apps/events/migrations/0002_auto__add_field_event_featured__add_field_event_featured_image.py
2
6590
# encoding: utf-8 import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'Event.featured' db.add_column('events_event', 'featured', self.gf('django.db.models.fields...
bsd-3-clause
cf9f81cd72f81fdb500678225d6d98d6
66.244898
182
0.555842
3.725269
false
false
false
false
mitsuhiko/zine
zine/utils/text.py
1
4714
# -*- coding: utf-8 -*- """ zine.utils.text ~~~~~~~~~~~~~~~ This module provides various text utility functions. :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ import re import unicodedata from datetime import datetime from ite...
bsd-3-clause
0215999cfb507734cc90e1f6ca0a46b2
29.412903
86
0.595672
3.544361
false
false
false
false
mitsuhiko/zine
zine/utils/redirects.py
1
2312
# -*- coding: utf-8 -*- """ zine.utils.redirects ~~~~~~~~~~~~~~~~~~~~ This module implements the access to the redirect table. :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ from zine.application import get_application from zin...
bsd-3-clause
b940f30bb2c0b2fd0280f0151b8b7a73
27.195122
78
0.618945
3.711075
false
false
false
false
mitsuhiko/zine
zine/importers/feed.py
1
19144
# -*- coding: utf-8 -*- """ zine.importers.feed ~~~~~~~~~~~~~~~~~~~ This importer can import web feeds. Currently it is limited to ATOM plus optional Zine extensions. :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ from pic...
bsd-3-clause
a58e56b7a6fcb3d73fb0b82629cedd5d
34.649907
81
0.58504
4.42329
false
false
false
false
mitsuhiko/zine
zine/plugins/rst_parser/__init__.py
1
4263
# -*- coding: utf-8 -*- """ zine.plugins.rst_parser ~~~~~~~~~~~~~~~~~~~~~~~ Adds support for reStructuredText in posts. :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ from zine.i18n import lazy_gettext from zine.parsers import ...
bsd-3-clause
4907538e036d4d1c100adfd718642053
32.304688
78
0.623739
4.319149
false
false
false
false
mitsuhiko/zine
zine/utils/debug.py
1
2501
# -*- coding: utf-8 -*- """ zine.utils.debug ~~~~~~~~~~~~~~~~ This module provides various debugging helpers. :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ import re import sys from werkzeug import escape from zine.applicati...
bsd-3-clause
081d819c0e650e59cbaf76b81e1032c8
30.658228
78
0.557777
3.777946
false
false
false
false
globocom/database-as-a-service
dbaas/logical/tests/test_database.py
1
14479
# -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals import mock import logging from django.test import TestCase from django.db import IntegrityError from drivers import base from maintenance.tests import factory as maintenance_factory from physical.tests import factory as physical_factory f...
bsd-3-clause
8ebaa4b72a4b634c10d20ce64b541a2c
37.507979
87
0.655225
4.099377
false
true
false
false
globocom/database-as-a-service
dbaas/account/forms/role.py
1
1394
# -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals from django import forms from django.contrib import admin from django.utils.translation import ugettext_lazy as _ from django.contrib.admin.widgets import FilteredSelectMultiple from django.contrib.auth.models import User from ..models im...
bsd-3-clause
86b4b4f36e5632fb284d587b73bb5185
29.977778
118
0.635581
3.819178
false
false
false
false
globocom/database-as-a-service
dbaas/physical/migrations/0057_auto__add_field_instance_used_size_in_bytes__add_field_instance_total_.py
1
19439
# -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'Instance.used_size_in_bytes' db.add_column(u'physical_ins...
bsd-3-clause
4d27110c9a9ccf226b3c3f9b2f36c536
89
227
0.565718
3.57072
false
false
false
false
dit/dit
dit/utils/latexarray.py
1
8791
""" Functions to convert pmfs to latex arrays. """ import contextlib import os import subprocess # noqa: S404 import tempfile from debtcollector import removals import numpy as np import numpy.core.arrayprint as arrayprint from .context import cd, named_tempfile, tempdir from .misc import default_opener __all__ ...
bsd-3-clause
d0b1f66a31b5cd15c2224f4b20988fa5
29.630662
108
0.602776
3.638659
false
false
false
false
dit/dit
dit/divergences/hypercontractivity_coefficient.py
1
4583
""" Compute the hypercontractivity coefficient: s*(X||Y) = max_{U - X - Y} I[U:Y]/I[U:X] """ import numpy as np from ..algorithms import BaseAuxVarOptimizer from ..exceptions import ditException from ..helpers import normalize_rvs from ..multivariate.entropy import entropy from ..multivariate.total_correlation im...
bsd-3-clause
401bb72b3f907725e05d779ed794b4ef
31.048951
109
0.578442
3.835146
false
false
false
false
dit/dit
dit/algorithms/maxentropy.py
1
22700
""" Maximum entropy with marginal distribution constraints. Note: We are actually doing the maximum entropy optimization. So we have not built in the fact that the solution is an exponential family. Also, this doesn't seem to work that well in practice. The optimization simply fails to converge for many distributions...
bsd-3-clause
dc301621165bb26c4427ff88a108f8ed
31.898551
99
0.620617
3.995072
false
false
false
false
dit/dit
dit/convert.py
1
2470
""" Helper functions to convert between Distribution and ScalarDistribution. """ import dit __all__ = ( 'DtoSD', 'SDtoD' ) def DtoSD(dist, extract): """ Convert a Distribution to a ScalarDistribution. Parameters ---------- dist : Distribution The Distribution to convert to a Sc...
bsd-3-clause
8835ecbc4bcfc9afd3c7001a5546928e
28.759036
75
0.608907
4.356261
false
false
false
false
dit/dit
tests/inference/test_segmentaxis.py
1
2165
""" Tests for dit.inference.segmentaxis. """ import pytest import numpy as np from dit.inference.segmentaxis import segment_axis def test_sa1(): """ Test 2d. """ a = np.arange(9).reshape(3, 3) sa = segment_axis(a, 2, 1) sa_correct = np.array([[0, 1], [1, 2], ...
bsd-3-clause
ad8050c646af042364dbc2be310ec78b
21.319588
119
0.464665
3.382813
false
true
false
false
dit/dit
dit/multivariate/secret_key_agreement/reduced_intrinsic_mutual_informations.py
1
3326
""" The reduced intrinsic mutual information. Note: this code is nowhere near efficient enough to actually run. Don't try it. """ from .base_skar_optimizers import BaseReducedIntrinsicMutualInformation from .intrinsic_mutual_informations import (intrinsic_total_correlation, ...
bsd-3-clause
3e7b77f4e6e41b194f72b6a669131662
29.513761
96
0.692724
4.264103
false
false
false
false
dit/dit
dit/math/pmfops.py
1
15395
""" A catch-all module for miscellaneous pmf-based operations. Eventually, we will need to reorganize. """ import dit from ..exceptions import ditException import numpy as np __all__ = ( 'convex_combination', 'downsample', 'jittered', 'perturb_support', 'replace_zeros', ) def perturb_support(p...
bsd-3-clause
183995582ee05f50e2f84af8c49cfd73
32.023605
79
0.629736
3.668415
false
false
false
false
dit/dit
dit/multivariate/common_informations/base_markov_optimizer.py
1
10027
""" Abstract base classes. """ from abc import abstractmethod import numpy as np from ...algorithms import BaseAuxVarOptimizer from ...utils import unitful from ..dual_total_correlation import dual_total_correlation from ..entropy import entropy __all__ = ( 'MarkovVarOptimizer', 'MinimizingMarkovVarOptimiz...
bsd-3-clause
785a15e7cba6764c39719f4861966123
35.198556
116
0.566471
4.452487
false
false
false
false
dit/dit
dit/pid/measures/ict.py
1
2123
""" The redundancy measure of Sigtermans based on causal tensors. """ import numpy as np from ...exceptions import ditException from ..pid import BaseBivariatePID __all__ = ( 'PID_CT', ) def i_triangle(d, source_0, source_1, target): """ Compute the path information, and if it is direct or not. P...
bsd-3-clause
be76aa5018b8b10326097b24a87767ac
25.5125
87
0.583687
3.004249
false
false
false
false
dit/dit
tests/shannon/test_shannon.py
1
2265
""" Tests for dit.shannon.shannon. """ import pytest import numpy as np from dit import Distribution as D, ScalarDistribution as SD from dit.shannon import (entropy as H, mutual_information as I, conditional_entropy as CH, entropy_pmf) def ...
bsd-3-clause
f92517b67d43475559356725ffb87098
24.449438
60
0.53245
2.792848
false
true
false
false
dit/dit
dit/algorithms/convex_maximization.py
1
2653
""" Code for maximizing a convex function over a polytope, as defined by a set of linear equalities and inequalities. """ import numpy as np import scipy from .optutil import as_full_rank __all__ = ( 'maximize_convex_function', ) def maximize_convex_function(f, A_ineq, b_ineq, A_eq=None, b_eq=None): """ M...
bsd-3-clause
89b0626cbf20f708184dbdfec6e12dd3
28.153846
81
0.632115
3.21966
false
false
false
false
dit/dit
site/build.py
1
1719
#!/usr/bin/env python """ This script can be used to build the website. It is also run on each commit to github. Example: ./build public_html """ import os import shutil import subprocess import sys import time BUILD_DIR = 'build' def get_build_dir(): try: build_dir = sys.argv[1] except IndexEr...
bsd-3-clause
16bcb8bd5d97b820a649f85848761b2a
20.4875
66
0.585806
3.472727
false
false
false
false
dit/dit
dit/other/extropy.py
1
2159
""" The extropy. """ from ..helpers import RV_MODES from ..math.ops import get_ops import numpy as np __all__ = ( 'extropy', ) def extropy(dist, rvs=None, rv_mode=None): """ Returns the extropy J[X] over the random variables in `rvs`. If the distribution represents linear probabilities, then the ...
bsd-3-clause
e64340a5ab059ac1c655a1b7796d5caf
26.329114
78
0.599352
3.855357
false
false
false
false
dit/dit
dit/multivariate/common_informations/mss_common_information.py
1
1932
""" Compute the minimal sufficient statistic common information. """ from copy import deepcopy import numpy as np from ...algorithms.minimal_sufficient_statistic import insert_joint_mss from ...helpers import normalize_rvs from ...utils import unitful from ..dual_total_correlation import dual_total_correlation from ...
bsd-3-clause
71db0baccb5ad34dc9418a0f46f9339e
32.894737
138
0.686335
3.926829
false
false
false
false
dit/dit
tests/divergences/test_cross_entropy.py
1
1716
""" Tests for dit.divergences.cross_entropy. """ import pytest import numpy as np from dit import Distribution from dit.divergences import cross_entropy from dit.exceptions import ditException from dit.multivariate import entropy d1 = Distribution(['0', '1'], [1 / 2, 1 / 2]) d2 = Distribution(['0', '2'], [1 / 2, 1...
bsd-3-clause
d74e2f3281fd94689d4ef9eb82eb1687
25
82
0.556527
2.561194
false
true
false
false
dit/dit
tests/test_abstractdist.py
2
1053
""" Tests for dit.abstractdist. """ import numpy as np from dit.abstractdist import get_abstract_dist, distribution_constraint from dit.example_dists import Xor def test_distribution_constraint1(): """ Test the xor distribution. """ d = Xor() ad = get_abstract_dist(d) A, b = distribution_con...
bsd-3-clause
1362a54f42672e32d710d10ce9cabca3
26.710526
71
0.480532
2.742188
false
true
false
false
dit/dit
dit/profiles/entropy_triangle.py
1
5487
""" The entropy triangle, from [Valverde-Albacete, Francisco Jose, and Carmen Pelaez-Moreno. "The Multivariate Entropy Triangle and Applications." Hybrid Artificial Intelligent Systems. Springer International Publishing, 2016. 647-658]. """ from abc import ABCMeta, abstractmethod from ..distribution import BaseDistrib...
bsd-3-clause
46e737cce0bd5fe5fe94f866a02143ba
29.148352
88
0.601057
4.147392
false
false
false
false
dit/dit
dit/algorithms/prune_expand.py
1
3543
""" Functions for pruning or expanding the sample space of a distribution. This can be important when calculating meet and join random variables. It is also important for the calculations of various PID quantities. """ from dit.samplespace import ScalarSampleSpace, SampleSpace, CartesianProduct __all__ = ( 'exp...
bsd-3-clause
0877d4bab46cd813d25bd4975f616091
29.543103
77
0.651143
4.187943
false
false
false
false
dit/dit
dit/multivariate/coinformation.py
1
4885
""" The co-information aka the multivariate mutual information. """ from ..helpers import normalize_rvs from ..shannon import conditional_entropy as H from ..utils import powerset, unitful __all__ = ( 'coinformation', ) @unitful def coinformation(dist, rvs=None, crvs=None, rv_mode=None): """ Calculates...
bsd-3-clause
8c0e894ac1ccfa8cdf472abfb4ed9251
28.077381
79
0.623132
3.542422
false
false
false
false
dit/dit
dit/math/aitchison.py
1
12847
""" Functions for manipulating compositions using the Aitchison geometry. Throughout, we assume the compositions are defined such that the sum of the components is 1. http://www.springerlink.com/content/wx1166n56n685v82/ """ import math import numpy as np from dit.exceptions import ditException from dit.math import...
bsd-3-clause
c14bef48c09bb672bc77f8b286c8da98
21.941071
80
0.560286
3.332555
false
false
false
false
dit/dit
dit/distconst.py
1
35280
""" Specialized distribution constructors. """ import numpy as np from itertools import product from collections import defaultdict from random import randint from .distribution import BaseDistribution from .exceptions import ditException from .helpers import parse_rvs from .npdist import Distribution from .npscala...
bsd-3-clause
be542db41ce65503dc1855993cb1b0df
31.248629
99
0.609637
4.160377
false
false
false
false
pallets/jinja
docs/examples/inline_gettext_extension.py
3
2398
import re from jinja2.exceptions import TemplateSyntaxError from jinja2.ext import Extension from jinja2.lexer import count_newlines from jinja2.lexer import Token _outside_re = re.compile(r"\\?(gettext|_)\(") _inside_re = re.compile(r"\\?[()]") class InlineGettext(Extension): """This extension implements supp...
bsd-3-clause
b9d0d518707363a7ef9891745c1b7bb4
32.305556
68
0.477481
4.59387
false
false
false
false
pallets/jinja
src/jinja2/filters.py
4
53509
"""Built-in template filters used with the ``|`` operator.""" import math import random import re import typing import typing as t from collections import abc from itertools import chain from itertools import groupby from markupsafe import escape from markupsafe import Markup from markupsafe import soft_str from .asy...
bsd-3-clause
b0a432d36e8068d68e0e50dc112122d2
28.080978
87
0.611467
3.761088
false
false
false
false
wal-e/wal-e
wal_e/worker/wabs/wabs_deleter.py
1
1258
from wal_e import retries from wal_e import log_help from wal_e.worker.base import _Deleter try: # New class name in the Azure SDK sometime after v1.0. # # See # https://github.com/Azure/azure-sdk-for-python/blob/master/ChangeLog.txt from azure.common import AzureMissingResourceHttpError except Imp...
bsd-3-clause
51bc29a565e25c9cc31296cb56ac56f0
32.105263
78
0.636725
4.032051
false
false
false
false
ultrabug/py3status
py3status/modules/external_script.py
2
3844
""" Display output of a given script. Display output of any executable script set by `script_path`. Only the first two lines of output will be used. The first line is used as the displayed text. If the output has two or more lines, the second line is set as the text color (and should hence be a valid hex color code su...
bsd-3-clause
ccb39f933450d12db28e55bd5c927557
29.752
77
0.593132
4.115632
false
false
false
false
ultrabug/py3status
py3status/modules/usbguard.py
2
5919
r""" Allow or Reject newly plugged USB devices using USBGuard. Configuration parameters: format: display format for this module (default '{format_device}') format_button_allow: display format for allow button filter (default '\[Allow\]') format_button_reject: display format for reject butto...
bsd-3-clause
ca43987b05b706ee4e47bc7a008fb569
32.440678
85
0.546545
3.68785
false
false
false
false
ultrabug/py3status
py3status/modules/conky.py
2
13937
r""" Display Conky objects/variables on the bar. Configuration parameters: config: specify configuration settings for conky (default {}) format: display format for this module (default None) thresholds: specify color thresholds to use (default []) Format placeholders: According to man page, Conky has ...
bsd-3-clause
982409ee056b0d03014caefe2a535ab5
30.603175
80
0.567841
3.153167
false
false
false
false
ultrabug/py3status
py3status/modules/net_iplist.py
2
5194
""" Display list of network interfaces and IP addresses. This module supports both IPv4 and IPv6. There is the possibility to blacklist interfaces and IPs, as well as to show interfaces with no IP address. It will show an alternate text if no IP are available. Configuration parameters: cache_timeout: refresh inte...
bsd-3-clause
bfb50e1a4217124763b4de197dd96065
29.023121
86
0.535425
3.858841
false
false
false
false
ultrabug/py3status
py3status/modules/nvidia_smi.py
2
7208
r""" Display NVIDIA properties currently exhibiting in the NVIDIA GPUs. nvidia-smi, short for NVIDIA System Management Interface program, is a cross platform tool that supports all standard NVIDIA driver-supported Linux distros. Configuration parameters: cache_timeout: refresh interval for this module (default 10...
bsd-3-clause
eb972d59c7d106c7e9563bbbe20ba534
35.75
87
0.600861
3.592519
false
false
false
false
ultrabug/py3status
py3status/modules/spotify.py
2
7535
""" Display song currently playing in Spotify. Configuration parameters: button_next: button to switch to next song (default None) button_play_pause: button to toggle play/pause (default None) button_previous: button to switch to previous song (default None) cache_timeout: how often to update the bar (...
bsd-3-clause
4c7dfeefad3d0ebbd35313a02290b0d1
31.899563
91
0.569684
3.861609
false
false
false
false
ultrabug/py3status
py3status/modules/github.py
2
9743
""" Display Github notifications and issue/pull requests for a repo. To check notifications a Github `username` and `personal access token` are required. You can create a personal access token at https://github.com/settings/tokens/new?scopes=notifications&description=py3status The only `scope` needed is `notification...
bsd-3-clause
d0b25b6e9501d8b573e05f303c7687e2
35.354478
94
0.587601
4.2141
false
false
false
false
ultrabug/py3status
py3status/modules/glpi.py
2
2483
""" Display number of open tickets from GLPI. It features thresholds to colorize the output and forces a low timeout to limit the impact of a server connectivity problem on your i3bar freshness. Configuration parameters: cache_timeout: how often we refresh this module in seconds (default 300) critical: set ba...
bsd-3-clause
c0b47548bda75f4420a035583a712ad0
26.898876
76
0.608538
4.05719
false
false
false
false
ultrabug/py3status
py3status/modules/timewarrior.py
1
10181
r""" Track your time with Timewarrior. Timewarrior is a time tracking utility that offers simple stopwatch features as well as sophisticated calendar-base backfill, along with flexible reporting. See https://taskwarrior.org/docs/timewarrior for more information. Configuration parameters: cache_timeout: refresh in...
bsd-3-clause
7e267d8d84ddbd433ee4feebef50279f
32.60066
82
0.587565
3.836096
false
false
false
false
ultrabug/py3status
py3status/modules/moc.py
2
5719
r""" Display song currently playing in moc. MOC (music on console) is a console audio player for Linux/Unix designed to be powerful and easy to use. It consists of two parts, a server (moc) and a player/interface (mocp). It supports OGG, WAV, MP3 and other formats. Configuration parameters: button_next: mouse but...
bsd-3-clause
f9c2217d2e2693779efffd7805f30ba8
31.129213
78
0.595734
3.694444
false
false
false
false
ultrabug/py3status
py3status/modules/player_control.py
2
5602
""" Control Audacious or VLC media player. Provides an icon to control simple functions of audio/video players: - start (left click) - stop (left click) - pause (middle click) Configuration parameters: cache_timeout: how often to update in seconds (default 10) debug: enable verbose logging (bool)...
bsd-3-clause
db1fd2792a761f5b0ac8781a3e11e574
28.246073
82
0.551378
3.855072
false
false
false
false
ultrabug/py3status
py3status/udev_monitor.py
2
3726
from collections import defaultdict, Counter from time import sleep from datetime import datetime from py3status.constants import ON_TRIGGER_ACTIONS try: import pyudev except ImportError: pyudev = None class UdevMonitor: """ This class allows us to react to udev events. """ def __init__(sel...
bsd-3-clause
d8fb58e2c2c0be5dc934954c36356e09
36.26
96
0.574879
4.167785
false
false
false
false
ultrabug/py3status
py3status/modules/systemd_suspend_inhibitor.py
2
2575
r""" Turn on and off systemd suspend inhibitor. Configuration parameters: format: display format for this module (default '[\?color=state SUSPEND [\?if=state OFF|ON]]') lock_types: specify state to inhibit, comma separated list https://www.freedesktop.org/wiki/Software/systemd/inhibit/ ...
bsd-3-clause
b08d0674bf3580e13199b8e6f7dde7c8
28.261364
73
0.603495
3.616573
false
false
false
false
ultrabug/py3status
py3status/formatter.py
2
24224
import re from html import escape from math import ceil from numbers import Number from urllib.parse import parse_qsl from py3status.composite import Composite from py3status.constants import COLOR_NAMES, COLOR_NAMES_EXCLUDED def expand_color(color, default=None, passthrough=False, block=None): """ Expand va...
bsd-3-clause
e15ae8b50b1294c6914a5a59d55fedd4
33.409091
88
0.495376
4.619375
false
false
false
false
ultrabug/py3status
py3status/composite.py
2
4546
class Composite: """ Helper class to identify a composite and store its content A Composite is essentially a wrapped list containing response items. """ def __init__(self, content=None): # try and create a composite from various input types if content is None: content = ...
bsd-3-clause
dbf19dd51714d984af90923ab92c3ac5
30.136986
84
0.540255
4.629328
false
false
false
false