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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cherrypy/cheroot | bin/pip_constraint_helpers.py | 1 | 2980 | """A set of functions helping generating pip constraint files."""
import functools
import os
import platform
import subprocess # noqa: S404
import sys
PYTHON_IMPLEMENTATION_MAP = { # noqa: WPS407
'cpython': 'cp',
'ironpython': 'ip',
'jython': 'jy',
'python': 'py',
'pypy': 'pp',
}
PYTHON_IMPLEMENT... | bsd-3-clause | c069125bbf4f5a3154ce2d65438a050a | 27.932039 | 79 | 0.63255 | 3.599034 | false | false | false | false |
cherrypy/cheroot | cheroot/ssl/pyopenssl.py | 1 | 13231 | """
A library for integrating :doc:`pyOpenSSL <pyopenssl:index>` with Cheroot.
The :py:mod:`OpenSSL <pyopenssl:OpenSSL>` module must be importable
for SSL/TLS/HTTPS functionality.
You can obtain it from `here <https://github.com/pyca/pyopenssl>`_.
To use this module, set :py:attr:`HTTPServer.ssl_adapter
<cheroot.serv... | bsd-3-clause | af91f6309e4d71a1ea6194640e8a57f6 | 34.18883 | 79 | 0.574862 | 4.151553 | false | false | false | false |
encode/apistar | tests/test_cli.py | 2 | 5166 | import json
import os
from click.testing import CliRunner
from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.testclient import TestClient
from apistar.cli import cli
def test_valid_document(tmpdir):
schema = os.path.join(tmpdir, "schema.json")
with open(... | bsd-3-clause | b6bafa23fc5ce4aa9c32af320e84dd82 | 31.225 | 88 | 0.534911 | 3.590529 | false | true | false | false |
encode/apistar | apistar/compat.py | 2 | 1517 | import collections
import sys
try:
import jinja2
except ImportError:
jinja2 = None
try:
import pygments
from pygments.lexers import get_lexer_by_name
from pygments.formatters import HtmlFormatter
def pygments_highlight(text, lang, style):
lexer = get_lexer_by_name(lang, stripall=Fal... | bsd-3-clause | 10824da1426830e264e0f52802ee4f80 | 24.711864 | 77 | 0.659855 | 4.334286 | false | false | false | false |
dyninc/dyn-python | dyn/tm/tools.py | 2 | 3444 | # -*- coding: utf-8 -*-
"""The tools module is designed to be able to assist users in some of the more
common or complicated tasks one will likely find themselves needing to
accomplish via the DynECT API
"""
from dyn.compat import string_types
__author__ = 'jnappi'
def change_ip(zone, from_ip, to, v6=False, publish=... | bsd-3-clause | a17bf8a224ddbe22fcc7ec4b7949bf98 | 38.136364 | 79 | 0.64547 | 4.051765 | false | false | false | false |
dyninc/dyn-python | dyn/tm/accounts.py | 2 | 66135 | # -*- coding: utf-8 -*-
"""This module contains interfaces for all Account management features of the
REST API
"""
from dyn.tm.errors import DynectInvalidArgumentError
from dyn.tm.session import DynectSession
from dyn.compat import force_unicode
import re
__author__ = 'jnappi'
__all__ = ['get_updateusers', 'get_users'... | bsd-3-clause | f8ec730028eb0f787617a4d95119324d | 35.001633 | 79 | 0.574673 | 4.027465 | false | false | false | false |
dyninc/dyn-python | dyn/tm/services/httpredirect.py | 2 | 5118 | # -*- coding: utf-8 -*-
"""This module contains API Wrapper implementations of the HTTP Redirect
service
"""
from dyn.compat import force_unicode
from dyn.tm.session import DynectSession
__author__ = 'xorg'
__all__ = ['HTTPRedirect']
class HTTPRedirect(object):
"""HTTPRedirect is a service which sets up a redire... | bsd-3-clause | 635d84b4cffcaf760be836341e60fc9d | 32.424837 | 78 | 0.55045 | 4.181521 | false | false | false | false |
dyninc/dyn-python | dyn/tm/zones.py | 1 | 54026 | # -*- coding: utf-8 -*-
"""This module contains all Zone related API objects."""
import os
from time import sleep
from datetime import datetime
from dyn.tm.utils import unix_date
from dyn.compat import force_unicode
from dyn.tm.errors import (DynectCreateError, DynectGetError,
DynectInvalidA... | bsd-3-clause | bacc668766d30481c0bdedcb293106fa | 36.754018 | 79 | 0.538426 | 4.025183 | false | false | false | false |
dyninc/dyn-python | dyn/tm/services/advanced_redirect.py | 2 | 14363 | # -*- coding: utf-8 -*-
"""This module contains API Wrapper implementations of the Advanced Redirect
service
"""
from dyn.compat import force_unicode
from dyn.tm.session import DynectSession
__author__ = 'mhowes'
__all__ = ['AdvancedRedirect',
'AdvancedRedirectRule',
'get_all_advanced_redirect_ru... | bsd-3-clause | d5d33f8872c404ffd287f7413b6e5b26 | 31.942661 | 79 | 0.516744 | 4.205857 | false | false | false | false |
qutip/qutip | qutip/qip/device/modelprocessor.py | 1 | 5755 | from collections.abc import Iterable
import numbers
import numpy as np
from qutip.qobj import Qobj
from qutip.qobjevo import QobjEvo
from qutip.qip.operations.gates import globalphase
from qutip.tensor import tensor
from qutip.mesolve import mesolve
from qutip.qip.circuit import QubitCircuit
from qutip.qip.device.pro... | bsd-3-clause | 70f4f1489bfec716e55092cd042a2289 | 31.150838 | 78 | 0.601911 | 4.10778 | false | false | false | false |
qutip/qutip | qutip/visualization.py | 1 | 57029 | """
Functions for visualizing results of quantum dynamics simulations,
visualizations of quantum states and processes.
"""
__all__ = ['hinton', 'sphereplot', 'energy_level_diagram',
'plot_energy_levels', 'fock_distribution',
'plot_fock_distribution', 'wigner_fock_distribution',
'plot_w... | bsd-3-clause | 4c824e7da833e523e56cca5e02949d98 | 30.317408 | 87 | 0.572937 | 3.509045 | false | false | false | false |
qutip/qutip | qutip/_mkl/spmv.py | 2 | 1196 | import numpy as np
from ctypes import POINTER, c_int, c_char, byref
from numpy.ctypeslib import ndpointer
import qutip.settings as qset
zcsrgemv = qset.mkl_lib.mkl_cspblas_zcsrgemv
def mkl_spmv(A, x):
"""
sparse csr_spmv using MKL
"""
m, _ = A.shape
# Pointers to data of the matrix
data = A.d... | bsd-3-clause | ebc7f225f2d11431cbd5d46e301c0977 | 30.473684 | 78 | 0.624582 | 3.07455 | false | false | false | false |
qutip/qutip | qutip/tests/test_mkl.py | 2 | 3447 | import pytest
import numpy as np
import scipy.linalg
import scipy.sparse
import qutip
if qutip.settings.has_mkl:
from qutip._mkl.spsolve import mkl_splu, mkl_spsolve
pytestmark = [
pytest.mark.skipif(not qutip.settings.has_mkl,
reason='MKL extensions not found.'),
]
class Test_spsolve... | bsd-3-clause | 061943ce7ee14dfc5880c858c8ea5610 | 29.236842 | 68 | 0.487961 | 3.085944 | false | true | false | false |
qutip/qutip | qutip/fastsparse.py | 1 | 16420 | from warnings import warn
import operator
import numpy as np
from scipy.sparse import (
csr_matrix, dia_matrix, isspmatrix, SparseEfficiencyWarning,
)
# fast_csr_matrix extends the internals of csr_matrix, and we need to
# import parts of the internals of scipy.sparse to do that:
import scipy.sparse
import scipy.... | bsd-3-clause | 46daa5718abf725593cc15dbd2569eb7 | 39.44335 | 92 | 0.538916 | 4.013689 | false | false | false | false |
qutip/qutip | qutip/orbital.py | 1 | 2571 | __all__ = ['orbital']
import numpy as np
from scipy.special import sph_harm
def orbital(theta, phi, *args):
r"""Calculates an angular wave function on a sphere.
``psi = orbital(theta,phi,ket1,ket2,...)`` calculates
the angular wave function on a sphere at the mesh of points
defined by theta and phi w... | bsd-3-clause | 05faf13a46fd4eedc3a80c8dd46a6355 | 30.740741 | 78 | 0.588876 | 3.667618 | false | false | false | false |
qutip/qutip | qutip/partial_transpose.py | 2 | 3537 | __all__ = ['partial_transpose']
import numpy as np
import scipy.sparse as sp
from qutip.qobj import Qobj
from qutip.states import (state_index_number, state_number_index,
state_number_enumerate)
def partial_transpose(rho, mask, method='dense'):
"""
Return the partial transpose of a... | bsd-3-clause | e4ce7d52b8ec95c5ae3d4b9e007850a0 | 28.722689 | 76 | 0.604467 | 3.427326 | false | false | false | false |
qutip/qutip | qutip/tests/test_fileio.py | 1 | 2229 | import pytest
import numpy as np
import uuid
import qutip
from pathlib import Path
# qsave _always_ appends a suffix to the file name at the time of writing, but
# in case this changes in the future, to ensure that we never leak a temporary
# file into the user's folders, we simply apply these tests in a temporary
# d... | bsd-3-clause | 7d2c8b27671a4a901d6dd7175c84cf25 | 36.779661 | 79 | 0.635262 | 3.526899 | false | true | false | false |
qutip/qutip | qutip/countstat.py | 2 | 9138 | """
This module contains functions for calculating current and current noise using
the counting statistics formalism.
"""
__all__ = ['countstat_current', 'countstat_current_noise']
import numpy as np
import scipy.sparse as sp
from qutip.expect import expect_rho_vec
from qutip.steadystate import pseudo_inverse, steady... | bsd-3-clause | 9ca1c18b45b229fa35a37651b77b38d6 | 37.720339 | 87 | 0.510943 | 3.885204 | false | false | false | false |
qutip/qutip | qutip/control/pulsegen.py | 2 | 41865 | # -*- coding: utf-8 -*-
# @author: Alexander Pitchford
# @email1: agp1@aber.ac.uk
# @email2: alex.pitchford@gmail.com
# @organization: Aberystwyth University
# @supervisor: Daniel Burgarth
"""
Pulse generator - Generate pulses for the timeslots
Each class defines a gen_pulse function that produces a float array of
siz... | bsd-3-clause | d36a3b1ba9120842c7de29368cf4a469 | 32.492 | 79 | 0.588941 | 3.999331 | false | false | false | false |
qutip/qutip | qutip/legacy/bloch_redfield.py | 2 | 4918 | __all__ = ['bloch_redfield_tensor']
import numpy as np
import os
import time
import types
import warnings
from functools import partial
import scipy.sparse as sp
from qutip.qobj import Qobj, isket
from qutip.states import ket2dm
from qutip.operators import qdiags
from qutip.superoperator import spre, spost, vec2mat, m... | bsd-3-clause | ab25ba446fa7c3bf6a311981b0345a88 | 31.143791 | 98 | 0.57259 | 3.203909 | false | false | false | false |
qutip/qutip | qutip/tests/test_partial_transpose.py | 2 | 2627 | """
Unit tests for QuTiP partial transpose functions.
"""
import numpy as np
from numpy.testing import assert_, run_module_suite
from qutip import Qobj, partial_transpose, tensor, rand_dm
from qutip.partial_transpose import _partial_transpose_reference
def test_partial_transpose_bipartite():
"""partial transpos... | bsd-3-clause | 09f2523b85e41bfc07f9aecb93dc96e9 | 32.679487 | 71 | 0.574039 | 3.127381 | false | true | false | false |
qutip/qutip | qutip/continuous_variables.py | 1 | 8376 | """
This module contains a collection functions for calculating continuous variable
quantities from fock-basis representation of the state of multi-mode fields.
"""
__all__ = ['correlation_matrix', 'covariance_matrix',
'correlation_matrix_field', 'correlation_matrix_quadrature',
'wigner_covarianc... | bsd-3-clause | 66bdd86728d3ed142bb91eeff2c35198 | 31.339768 | 79 | 0.575096 | 3.584082 | false | false | false | false |
qutip/qutip | qutip/krylovsolve.py | 1 | 21299 | __all__ = ["krylovsolve"]
"""
This module provides approximations of the time evolution operator
using small dimensional Krylov subspaces.
"""
from scipy.optimize import root_scalar
from math import ceil
import numpy as np
import warnings
from qutip.expect import expect
from qutip.qobj import Qobj
from qutip.solver i... | bsd-3-clause | 2d64a0984234abb40b528b56e82920a2 | 28.664345 | 88 | 0.581624 | 3.428686 | false | false | false | false |
qutip/qutip | qutip/matplotlib_utilities.py | 2 | 5460 | """
This module contains utility functions that enhance Matplotlib
in one way or another.
"""
__all__ = ['wigner_cmap', 'MidpointNorm', 'complex_phase_cmap']
import numpy as np
try:
import matplotlib as mpl
from matplotlib import cm
from matplotlib.colors import (Normalize, ColorConverter)
except:
cl... | bsd-3-clause | 735cdb8419d763ae5da8bb71e0e4a9a4 | 34.454545 | 79 | 0.574725 | 3.721881 | false | false | false | false |
mitodl/open-discussions | interactions/migrations/0001_add_content_type_interactions.py | 1 | 1276 | # Generated by Django 2.2.9 on 2020-02-05 16:56
from django.db import migrations, models
import django.db.models.deletion
import open_discussions.utils
class Migration(migrations.Migration):
initial = True
dependencies = [("contenttypes", "0002_remove_content_type_name")]
operations = [
migrat... | bsd-3-clause | 1ae64a0736adc70a5dd94cf18a966ee2 | 29.380952 | 84 | 0.454545 | 5.338912 | false | false | false | false |
mitodl/open-discussions | channels/management/commands/backpopulate_posts.py | 1 | 1955 | """Management command for populating posts and comments from reddit"""
import sys
import base36
from django.core.management import BaseCommand
from channels import tasks
class Command(BaseCommand):
"""Populate posts and comments from reddit"""
help = "Populate posts and comments from reddit"
def add_a... | bsd-3-clause | 4ff59240b5028b88b757b20b20c1baae | 33.910714 | 99 | 0.546292 | 4.089958 | false | false | false | false |
mitodl/open-discussions | open_discussions/models.py | 1 | 1660 | """
Classes related to models for open_discussions
"""
from django.db.models import DateTimeField, Model
from django.db.models.query import QuerySet
from open_discussions.utils import now_in_utc
class TimestampedModelQuerySet(QuerySet):
"""
Subclassed QuerySet for TimestampedModelManager
"""
def upd... | bsd-3-clause | 39117d2147e8986fd92ebeb6e7cd1f8b | 30.320755 | 91 | 0.695181 | 4.300518 | false | false | false | false |
mitodl/open-discussions | course_catalog/migrations/0082_enrollment_updates.py | 1 | 1547 | # Generated by Django 2.2.13 on 2021-02-28 00:55
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("course_catalog", "0081_... | bsd-3-clause | 8e7992a37afc471c5044dc16801f0a3b | 30.571429 | 85 | 0.561086 | 4.576923 | false | false | false | false |
mitodl/open-discussions | fixtures/aws.py | 1 | 2903 | """Fixtures for AWS"""
# pylint: disable=redefined-outer-name
import logging
from types import SimpleNamespace
import boto3
import pytest
from moto import mock_s3
@pytest.fixture(autouse=True)
def silence_s3_logging():
"""Only show S3 errors"""
logging.getLogger("botocore").setLevel(logging.ERROR)
@pytest.... | bsd-3-clause | 524209648624ef0264cf68b6a8b45739 | 28.03 | 88 | 0.695143 | 3.169214 | false | true | false | false |
mitodl/open-discussions | discussions/factories.py | 1 | 1919 | """Discussions factories"""
import factory
from factory.django import DjangoModelFactory
from factory.fuzzy import FuzzyChoice
from channels.factories.utils import channel_name
from discussions import api
from discussions.constants import ChannelTypes
from discussions.models import Channel
class ChannelFactory(Djang... | bsd-3-clause | a1da74135016823385da90053e566d01 | 33.890909 | 81 | 0.66962 | 4.04 | false | false | false | false |
mitodl/open-discussions | notifications/notifiers/moderator_posts.py | 1 | 1830 | """Notifier for new posts for moderators"""
from django.db import transaction
from notifications.notifiers.email import EmailNotifier
from notifications.models import NOTIFICATION_TYPE_MODERATOR, PostEvent
from notifications.utils import praw_error_to_cancelled
from channels import api
from channels.serializers.posts ... | bsd-3-clause | bd18742dbe48b863edc4a7a32b2527d2 | 36.346939 | 116 | 0.676503 | 4.42029 | false | false | false | false |
mitodl/open-discussions | open_discussions/features.py | 1 | 1870 | """Discussions feature flags"""
from functools import wraps
from django.conf import settings
EMAIL_NOTIFICATIONS = "EMAIL_NOTIFICATIONS"
FRONTPAGE_EMAIL_DIGESTS = "FRONTPAGE_EMAIL_DIGESTS"
COMMENT_NOTIFICATIONS = "COMMENT_NOTIFICATIONS"
INDEX_UPDATES = "INDEX_UPDATES"
SAML_AUTH = "SAML_AUTH"
PROFILE_UI = "PROFILE_UI"
... | bsd-3-clause | dca4eee02fed48457d9263e2a74b99fc | 29.655738 | 95 | 0.667914 | 3.555133 | false | false | false | false |
mitodl/open-discussions | channels/views/subscribers.py | 1 | 2679 | """Views for REST APIs for channels"""
from django.conf import settings
from rest_framework import status
from rest_framework.exceptions import NotFound
from rest_framework.generics import ListCreateAPIView
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_fra... | bsd-3-clause | 7d0264bfa82db6d0e035727acde6e698 | 34.72 | 82 | 0.679358 | 4.675393 | false | false | false | false |
mitodl/open-discussions | course_catalog/api.py | 1 | 24175 | """
course_catalog api functions
"""
import logging
from datetime import datetime
from urllib.parse import urljoin
import boto3
import pytz
import rapidjson
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.db import transaction
from ocw_data_parser import OCWParse... | bsd-3-clause | 91a46d0651b18f4ae6542793b465cb65 | 35.028316 | 128 | 0.602316 | 3.895424 | false | false | false | false |
mitodl/open-discussions | open_discussions/views.py | 1 | 5714 | """
open_discussions views
"""
from django.conf import settings
from django.http import (
Http404,
HttpResponse,
HttpResponsePermanentRedirect,
HttpResponseNotFound,
HttpResponseForbidden,
HttpResponseBadRequest,
)
from django.shortcuts import render, get_object_or_404
from django.urls import re... | bsd-3-clause | 261202b60da16cbf64dba0495c887908 | 33.841463 | 86 | 0.655933 | 3.693601 | false | false | false | false |
theislab/scanpy | scanpy/external/pp/_scrublet.py | 1 | 21492 | from anndata import AnnData
from typing import Optional
import numpy as np
import pandas as pd
from scipy import sparse
from ... import logging as logg
from ... import preprocessing as pp
from ...get import _get_obs_rep
def scrublet(
adata: AnnData,
adata_sim: Optional[AnnData] = None,
batch_key: str = ... | bsd-3-clause | a438944fe646a8b068603e22a5eb8003 | 37.168739 | 117 | 0.65238 | 3.871194 | false | false | false | false |
foauth/foauth.org | services/reddit.py | 2 | 1871 | from oauthlib.oauth2.draft25 import utils
import foauth.providers
class Reddit(foauth.providers.OAuth2):
# General info about the provider
provider_url = 'http://www.reddit.com/'
docs_url = 'http://www.reddit.com/dev/api'
category = 'News'
# URLs to interact with the API
authorize_url = 'http... | bsd-3-clause | 5772034fa398f1f266b5e1c254ab9b9e | 37.979167 | 79 | 0.630144 | 3.810591 | false | false | false | false |
foauth/foauth.org | services/elance.py | 1 | 1088 | import foauth.providers
from foauth import OAuthDenied
class Elance(foauth.providers.OAuth2):
# General info about the provider
provider_url = 'https://www.elance.com/'
docs_url = 'https://www.elance.com/q/api2'
category = 'Career'
# URLs to interact with the API
authorize_url = 'https://api.... | bsd-3-clause | 5490f39ea2137a5c2b81a26ac88fdcd3 | 31.969697 | 72 | 0.652574 | 3.337423 | false | false | false | false |
foauth/foauth.org | services/familysearch.py | 1 | 1342 | import requests
import foauth.providers
class FamilySearch(foauth.providers.OAuth2):
# General info about the provider
provider_url = 'http://www.familysearch.com/'
docs_url = 'https://familysearch.org/developers/docs/api/resources'
category = 'Genealogy'
favicon_url = 'https://familysearch.org/f... | bsd-3-clause | c0967ea508d80c8d2446e7f339170aff | 37.342857 | 86 | 0.643815 | 3.597855 | false | false | false | false |
foauth/foauth.org | foauth/providers.py | 1 | 9528 | import json
from os import urandom
import urllib
import urlparse
import flask
import requests
from requests_oauthlib import OAuth1 as OAuth1Manager
from oauthlib.oauth1.rfc5849 import SIGNATURE_HMAC, SIGNATURE_TYPE_AUTH_HEADER
from oauthlib.oauth2.draft25 import tokens
from werkzeug.urls import url_decode
from foauth... | bsd-3-clause | 6e6b8a86070170a2220404f13bc586e7 | 37.112 | 88 | 0.583963 | 3.968347 | false | false | false | false |
foauth/foauth.org | models.py | 2 | 3290 | import datetime
from werkzeug.security import generate_password_hash, check_password_hash
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext import login
import config
db = SQLAlchemy(config.app)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String, unique=T... | bsd-3-clause | bee96d05169a0fc314f99e3f774b909d | 30.333333 | 83 | 0.643769 | 3.755708 | false | false | false | false |
wagtail/wagtail | wagtail/migrations/0048_add_default_workflows.py | 4 | 3725 | # -*- coding: utf-8 -*-
from django.db import migrations
from django.db.models import Count, Q
from wagtail.models import Page as RealPage
def ancestor_of_q(page):
paths = [page.path[0:pos] for pos in range(0, len(page.path) + 1, page.steplen)[1:]]
q = Q(path__in=paths)
return q
def create_default_work... | bsd-3-clause | fb45335b85b8b927bb4b43564b3623a8 | 37.802083 | 133 | 0.648859 | 4.242597 | false | false | false | false |
wagtail/wagtail | wagtail/admin/api/views.py | 4 | 5160 | from collections import OrderedDict
from django.conf import settings
from django.http import Http404
from django.urls import path
from rest_framework.authentication import SessionAuthentication
from rest_framework.response import Response
from wagtail.api.v2.views import PagesAPIViewSet
from wagtail.models import Pag... | bsd-3-clause | e7eb75bd99be15de4070342354e6fc47 | 31.049689 | 79 | 0.646899 | 4.271523 | false | false | false | false |
wagtail/wagtail | wagtail/images/management/commands/wagtail_update_image_renditions.py | 4 | 2118 | from django.core.management.base import BaseCommand
from wagtail.images import get_image_model
class Command(BaseCommand):
"""Command to create missing image renditions with the option to remove (purge) any existing ones."""
help = "This command will generate all image renditions, with an option to purge ex... | bsd-3-clause | 5466b347e9b8ddf3adb3d7d9b39fbec5 | 36.821429 | 112 | 0.532578 | 4.983529 | false | false | false | false |
wagtail/wagtail | wagtail/test/modeladmintest/migrations/0009_relatedlink.py | 4 | 1073 | # Generated by Django 3.1.1 on 2020-10-01 18:16
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("wagtailcore", "0057_page_locale_fields_notnull"),
("modeladmintest", "0008_solobook"),
]
operations = [
... | bsd-3-clause | 818f71de46f24c7201f247680cf0bde7 | 27.236842 | 68 | 0.416589 | 5.234146 | false | false | false | false |
wagtail/wagtail | wagtail/contrib/simple_translation/tests/test_forms.py | 4 | 5490 | from django.forms import CheckboxInput, HiddenInput
from django.test import TestCase, override_settings
from wagtail.contrib.simple_translation.forms import SubmitTranslationForm
from wagtail.models import Locale, Page
from wagtail.test.i18n.models import TestPage
from wagtail.test.utils import WagtailTestUtils
@ove... | bsd-3-clause | 5c76fb081b90d09a86af5d043fa4fc28 | 38.214286 | 87 | 0.620765 | 3.986928 | false | true | false | false |
wagtail/wagtail | wagtail/users/views/bulk_actions/assign_role.py | 4 | 1569 | from django import forms
from django.contrib.auth.models import Group
from django.utils.translation import gettext_lazy as _
from django.utils.translation import ngettext
from wagtail.users.views.bulk_actions.user_bulk_action import UserBulkAction
from wagtail.users.views.users import change_user_perm
class RoleForm... | bsd-3-clause | a16d6717f051cfad92b0270d2d67a33e | 33.108696 | 77 | 0.664117 | 3.845588 | false | false | false | false |
wagtail/wagtail | wagtail/contrib/styleguide/views.py | 4 | 3918 | from django import forms
from django.core.paginator import Paginator
from django.template.response import TemplateResponse
from django.utils.translation import gettext as _
from wagtail.admin import messages
from wagtail.admin.forms.search import SearchForm
from wagtail.admin.rich_text import get_rich_text_editor_widg... | bsd-3-clause | 1c08400d9ee24987bd4f88dac4757a77 | 35.616822 | 99 | 0.682746 | 4.258696 | false | false | false | false |
wagtail/wagtail | wagtail/admin/tests/pages/test_page_search.py | 4 | 8003 | from django.contrib.auth.models import Permission
from django.test import TestCase
from django.urls import reverse
from wagtail.models import Page
from wagtail.search.index import SearchField
from wagtail.test.testapp.models import SimplePage, SingleEventPage
from wagtail.test.utils import WagtailTestUtils
from wagtai... | bsd-3-clause | 98bc54ef8e7157221e95eb98c7513270 | 37.109524 | 86 | 0.595652 | 3.845747 | false | true | false | false |
wagtail/wagtail | wagtail/admin/site_summary.py | 4 | 2552 | from django.forms import Media
from wagtail import hooks
from wagtail.admin.auth import user_has_any_page_permission
from wagtail.admin.navigation import get_site_for_user
from wagtail.admin.ui.components import Component
from wagtail.models import Page, Site
class SummaryItem(Component):
order = 100
def __... | bsd-3-clause | 49d5672c3ec3117947e4c385b48f64bb | 30.9 | 89 | 0.612069 | 4.116129 | false | false | false | false |
wagtail/wagtail | wagtail/search/tests/test_index_functions.py | 4 | 6914 | from datetime import date
from unittest import mock
from django.test import TestCase, override_settings
from wagtail.models import Page
from wagtail.search import index
from wagtail.test.search import models
from wagtail.test.testapp.models import SimplePage
from wagtail.test.utils import WagtailTestUtils
class Tes... | bsd-3-clause | 825a92562fa9441ecc175aaf6310d0bf | 33.059113 | 93 | 0.638849 | 3.813569 | false | true | false | false |
wagtail/wagtail | wagtail/api/v2/router.py | 4 | 2899 | import functools
from django.urls import include, re_path
from wagtail.utils.urlpatterns import decorate_urlpatterns
class WagtailAPIRouter:
"""
A class that provides routing and cross-linking for a collection
of API endpoints
"""
def __init__(self, url_namespace):
self.url_namespace = ... | bsd-3-clause | 67227bee20a5023cd0fbcdcde9a95d28 | 29.515789 | 77 | 0.595378 | 4.48068 | false | false | false | false |
wagtail/wagtail | wagtail/contrib/table_block/tests.py | 4 | 18755 | import json
import unittest
from django.test import SimpleTestCase, TestCase
from django.urls import reverse
from django.utils import translation
from wagtail.blocks.field_block import FieldBlockAdapter
from wagtail.contrib.table_block.blocks import DEFAULT_TABLE_OPTIONS, TableBlock
from wagtail.models import Page
fr... | bsd-3-clause | db3b9bf763e9a078cd3c5fac50b88427 | 34.056075 | 141 | 0.511864 | 4.087838 | false | true | false | false |
wagtail/wagtail | wagtail/admin/navigation.py | 4 | 1452 | from django.conf import settings
from wagtail.models import Page
def get_pages_with_direct_explore_permission(user):
# Get all pages that the user has direct add/edit/publish/lock permission on
if user.is_superuser:
# superuser has implicit permission on the root node
return Page.objects.filt... | bsd-3-clause | 743f46250dc9172e655df389dfc38be4 | 31.266667 | 86 | 0.652204 | 3.657431 | false | false | false | false |
wagtail/wagtail | wagtail/admin/tests/api/test_pages.py | 4 | 70767 | import collections
import datetime
import json
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group, Permission
from django.test.utils import override_settings
from django.urls import reverse
from django.utils import timezone
from wagtail import hooks
from wagtail.api.v2.tests.t... | bsd-3-clause | 781e3c1f352f0d75f2ec0d9c0377ad04 | 35.459042 | 209 | 0.585951 | 4.0307 | false | true | false | false |
wagtail/wagtail | wagtail/actions/publish_revision.py | 4 | 7722 | import logging
from django.core.exceptions import PermissionDenied
from django.utils import timezone
from wagtail.log_actions import log
from wagtail.permission_policies.base import ModelPermissionPolicy
from wagtail.signals import published
logger = logging.getLogger("wagtail")
class PublishPermissionError(Permis... | bsd-3-clause | ff9b821fa9f908e41d27d6fb1b7fd34e | 34.916279 | 118 | 0.535354 | 4.823235 | false | false | false | false |
wagtail/wagtail | wagtail/admin/search.py | 4 | 3772 | from django.forms import Media, MediaDefiningClass
from django.forms.utils import flatatt
from django.template.loader import render_to_string
from django.utils.functional import cached_property, total_ordering
from django.utils.safestring import mark_safe
from django.utils.text import slugify
from wagtail import hooks... | bsd-3-clause | 2377013de7ab8d505f950b8f0f9012ce | 31.239316 | 91 | 0.613998 | 4.06028 | false | false | false | false |
wagtail/wagtail | wagtail/admin/views/pages/revisions.py | 2 | 5408 | from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import PermissionDenied
from django.shortcuts import get_object_or_404, redirect
from django.template.loader import render_to_string
from django.template.response import TemplateResponse
from django.utils.decorators import method_dec... | bsd-3-clause | da1e73246f9c4969fbba9d801e342b79 | 32.8 | 104 | 0.663462 | 3.824611 | false | false | false | false |
wagtail/wagtail | wagtail/images/migrations/0016_deprecate_rendition_filter_relation.py | 4 | 2721 | # -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2016-11-11 17:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0015_fill_filter_spec_field"),
]
operations = [
migrations.AlterField(
model_name="rend... | bsd-3-clause | 679dcaa5de0bdf014c41ad3b81669269 | 48.472727 | 103 | 0.636531 | 4.043091 | false | false | false | false |
wagtail/wagtail | wagtail/search/views/queries.py | 4 | 1540 | from django.core.paginator import Paginator
from django.template.response import TemplateResponse
from wagtail.admin.forms.search import SearchForm
from wagtail.admin.modal_workflow import render_modal_workflow
from wagtail.search import models
from wagtail.search.utils import normalise_query_string
def chooser(requ... | bsd-3-clause | 83397aa2cf49380112fa8de262021495 | 28.615385 | 76 | 0.615584 | 4.350282 | false | false | false | false |
wagtail/wagtail | wagtail/utils/setup.py | 4 | 2739 | import io
import json
import os
import subprocess
from setuptools import Command
from setuptools.command.bdist_egg import bdist_egg
from setuptools.command.sdist import sdist as base_sdist
from wagtail import __semver__
class assets_mixin:
def compile_assets(self):
try:
subprocess.check_call... | bsd-3-clause | b79c9b9ade9984ff9a6e5ea111e92e1e | 29.433333 | 87 | 0.530486 | 4.306604 | false | false | false | false |
wagtail/wagtail | wagtail/admin/widgets/button_select.py | 4 | 1278 | from django import forms
from django.utils.translation import gettext_lazy as _
class ButtonSelect(forms.Select):
"""
A select widget for fields with choices. Displays as a list of buttons.
"""
input_type = "hidden"
template_name = "wagtailadmin/widgets/button_select.html"
option_template_nam... | bsd-3-clause | 7b8fa695d4bcd5882379c851c3336d5c | 25.625 | 89 | 0.507825 | 4.30303 | false | false | false | false |
wagtail/wagtail | wagtail/utils/deprecation.py | 4 | 2966 | import warnings
from importlib import import_module
class RemovedInWagtail50Warning(DeprecationWarning):
pass
removed_in_next_version_warning = RemovedInWagtail50Warning
class RemovedInWagtail60Warning(PendingDeprecationWarning):
pass
class MovedDefinitionHandler:
"""
A wrapper for module object... | bsd-3-clause | cfad856b77a2f01df5d1fb3ab89adc65 | 33.091954 | 118 | 0.63149 | 4.493939 | false | false | false | false |
wagtail/wagtail | wagtail/search/utils.py | 4 | 5988 | import operator
import re
from functools import partial
from django.apps import apps
from django.db import connections
from wagtail.search.index import RelatedFields, SearchField
from .query import MATCH_NONE, Phrase, PlainText
NOT_SET = object()
def balanced_reduce(operator, seq, initializer=NOT_SET):
"""
... | bsd-3-clause | 7c71d0fe81c43581d8bf1ff1732e9d66 | 28.643564 | 104 | 0.647128 | 3.978738 | false | false | false | false |
wagtail/wagtail | wagtail/images/migrations/0012_copy_image_permissions_to_collections.py | 4 | 1769 | # -*- coding: utf-8 -*-
from django.db import migrations
def get_image_permissions(apps):
# return a queryset of the 'add_image' and 'change_image' permissions
Permission = apps.get_model("auth.Permission")
ContentType = apps.get_model("contenttypes.ContentType")
image_content_type, _created = Conten... | bsd-3-clause | 151482c35b4a6cc96f12329ea8cfc733 | 33.019231 | 87 | 0.6987 | 4.221957 | false | false | false | false |
wagtail/wagtail | wagtail/admin/views/bulk_action/registry.py | 4 | 1640 | from wagtail import hooks
from wagtail.admin.views.bulk_action import BulkAction
class BulkActionRegistry:
def __init__(self):
self.actions = {} # {app_name: {model_name: {action_name: action_class]}}
self.has_scanned_for_bulk_actions = False
def _scan_for_bulk_actions(self):
if not ... | bsd-3-clause | 0f9c0578fd2662bacf0d53fa7f887f34 | 40 | 86 | 0.55 | 4.029484 | false | false | false | false |
wagtail/wagtail | wagtail/rich_text/__init__.py | 4 | 5190 | import re
from functools import lru_cache
from html import unescape
from django.core.validators import MaxLengthValidator
from django.db.models import Model
from django.template.loader import render_to_string
from django.utils.html import strip_tags
from django.utils.safestring import mark_safe
from wagtail.rich_text... | bsd-3-clause | cc1cd7e5b43e02cf7e833fda08b5210e | 31.236025 | 100 | 0.642967 | 4.247136 | false | false | false | false |
wagtail/wagtail | wagtail/migrations/0068_log_entry_empty_object.py | 4 | 1040 | # Generated by Django 4.0.2 on 2022-02-22 04:27
from django.db import migrations
def replace_empty_string_with_empty_object(apps, schema_editor):
ModelLogEntry = apps.get_model("wagtailcore.ModelLogEntry")
PageLogEntry = apps.get_model("wagtailcore.PageLogEntry")
ModelLogEntry.objects.filter(data_json='"... | bsd-3-clause | 21b324ae5e905bb3644412e57475b98d | 33.666667 | 87 | 0.697115 | 3.573883 | false | false | false | false |
python-control/python-control | examples/vehicle.py | 2 | 3257 | # vehicle.py - planar vehicle model (with flatness)
# RMM, 16 Jan 2022
import numpy as np
import matplotlib.pyplot as plt
import control as ct
import control.flatsys as fs
#
# Vehicle dynamics
#
# Function to take states, inputs and return the flat flag
def _vehicle_flat_forward(x, u, params={}):
# Get the param... | bsd-3-clause | 7461265c9078a5a55e146fe0837ca7cd | 28.342342 | 77 | 0.581517 | 2.837108 | false | false | false | false |
python-control/python-control | control/config.py | 2 | 11065 | # config.py - package defaults
# RMM, 4 Nov 2012
#
# This file contains default values and utility functions for setting
# variables that control the behavior of the control package.
# Eventually it will be possible to read and write configuration
# files. For now, you can just choose between MATLAB and FBS default
# ... | bsd-3-clause | d2ac5d7d3eb82ddf8e8d97a40da2e6ef | 35.160131 | 79 | 0.642476 | 3.920978 | false | false | false | false |
python-control/python-control | control/canonical.py | 2 | 14023 | # canonical.py - functions for converting systems to canonical forms
# RMM, 10 Nov 2012
from .exception import ControlNotImplemented, ControlSlycot
from .namedio import issiso
from .statesp import StateSpace, _convert_to_statespace
from .statefbk import ctrb, obsv
import numpy as np
from numpy import zeros, zeros_li... | bsd-3-clause | c0da72be678635f4ed6fe36bc43e50dd | 30.162222 | 113 | 0.619839 | 3.58278 | false | false | false | false |
python-control/python-control | examples/steering-optimal.py | 2 | 8749 | # steering-optimal.py - optimal control for vehicle steering
# RMM, 18 Feb 2021
#
# This file works through an optimal control example for the vehicle
# steering system. It is intended to demonstrate the functionality for
# optimal control module (control.optimal) in the python-control package.
import numpy as np
imp... | bsd-3-clause | 64b09fe1f252d168240ed6293721993d | 33.175781 | 79 | 0.688079 | 3.151657 | false | false | false | false |
python-control/python-control | control/tests/statefbk_test.py | 2 | 30709 | """statefbk_test.py - test state feedback functions
RMM, 30 Mar 2011 (based on TestStatefbk from v0.4a)
"""
import numpy as np
import pytest
import control as ct
from control import lqe, dlqe, poles, rss, ss, tf
from control.exception import ControlDimension, ControlSlycot, \
ControlArgument, slycot_check
from c... | bsd-3-clause | b533e9709656de5039cde068ce5f9bf4 | 38.421053 | 80 | 0.532417 | 3.164245 | false | true | false | false |
python-control/python-control | control/tests/descfcn_test.py | 2 | 7175 | """descfcn_test.py - test describing functions and related capabilities
RMM, 23 Jan 2021
This set of unit tests covers the various operatons of the descfcn module, as
well as some of the support functions associated with static nonlinearities.
"""
import pytest
import numpy as np
import control as ct
import math
f... | bsd-3-clause | 42657dc5fe7cd95b6a7be6c570ef68ac | 35.607143 | 78 | 0.676098 | 3.271774 | false | true | false | false |
python-control/python-control | control/tests/minreal_test.py | 2 | 4121 | """minreal_test.py - test state space class
Rvp, 13 Jun 2013
"""
import numpy as np
from scipy.linalg import eigvals
import pytest
from control import rss, ss, zeros
from control.statesp import StateSpace
from control.xferfcn import TransferFunction
from itertools import permutations
from control.tests.conftest impo... | bsd-3-clause | 65d75e3b31ee4fe3140a51b5928e930e | 34.525862 | 79 | 0.503033 | 3.179784 | false | true | false | false |
datafolklabs/cement | cement/core/handler.py | 1 | 13163 | """
Cement core handler module.
"""
import re
from abc import ABC
from ..core import exc, meta
from ..utils.misc import minimal_logger
LOG = minimal_logger(__name__)
class Handler(ABC, meta.MetaMixin):
"""Base handler class that all Cement Handlers should subclass from."""
class Meta:
"""
... | bsd-3-clause | 9225e41b5f0b1887fc336efe0558df4b | 32.239899 | 79 | 0.537719 | 4.741715 | false | false | false | false |
datafolklabs/cement | cement/ext/ext_tabulate.py | 1 | 3058 | """
Cement Tabulate extension module.
**Note** This extension has an external dependency on ``tabulate``. Cement
explicitly does **not** include external dependencies for optional
extensions.
* In Cement ``>=3.0.8`` you must include ``cement[tabulate]`` in your
applications dependencies.
* In Cement ``<3.0.8`` you ... | bsd-3-clause | e7f7e930040bd7dde3036c9524402b64 | 30.204082 | 76 | 0.595814 | 4.419075 | false | false | false | false |
datafolklabs/cement | cement/cli/contrib/jinja2/ext.py | 4 | 31502 | """Extension API for adding custom tags and behavior."""
import pprint
import re
import typing as t
from markupsafe import Markup
from . import defaults
from . import nodes
from .environment import Environment
from .exceptions import TemplateAssertionError
from .exceptions import TemplateSyntaxError
from .runtime imp... | bsd-3-clause | cfff852fd2594bd71d5c2eb730e7202b | 35.672875 | 88 | 0.592343 | 4.272616 | false | false | false | false |
datafolklabs/cement | cement/cli/main.py | 1 | 1347 |
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), 'contrib'))
from cement import App, CaughtSignal # noqa: E402
from .controllers.base import Base # noqa: E402
class CementApp(App):
class Meta:
label = 'cement'
controller = 'base'
template_module = 'cement.... | bsd-3-clause | 1efba3f1fa81cf153d92db2b7264835c | 25.94 | 73 | 0.47216 | 4.057229 | false | true | false | false |
mwaskom/seaborn | seaborn/cm.py | 1 | 66038 | from matplotlib import colors
from seaborn._compat import register_colormap
_rocket_lut = [
[ 0.01060815, 0.01808215, 0.10018654],
[ 0.01428972, 0.02048237, 0.10374486],
[ 0.01831941, 0.0229766 , 0.10738511],
[ 0.02275049, 0.02554464, 0.11108639],
[ 0.02759119, 0.02818316, 0.11483751],
[ 0.032... | bsd-3-clause | fc4b755607c549477223a1e1dea635e9 | 40.638083 | 61 | 0.626336 | 2.022294 | false | false | false | false |
mwaskom/seaborn | seaborn/miscplot.py | 2 | 1407 | import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
__all__ = ["palplot", "dogplot"]
def palplot(pal, size=1):
"""Plot the values in a color palette as a horizontal array.
Parameters
----------
pal : sequence of matplotlib colors
col... | bsd-3-clause | 383e82ec83d8a3ed13a7f49193e92962 | 28.3125 | 76 | 0.620469 | 3.366029 | false | false | false | false |
janelia-flyem/gala | gala/valprob.py | 2 | 8563 | from . import imio, option_manager, app_logger, session_manager
import libNeuroProofPriority as neuroproof
import os
import sys
import glob
import h5py
import numpy
import json
import traceback
def image_stack_verify(options_parser, options, master_logger):
if options.test_stack is not None:
if not os.path... | bsd-3-clause | b99ddd9b01ac2053a4b003d4826016ff | 35.751073 | 130 | 0.639145 | 3.335801 | false | true | false | false |
mozilla/pontoon | pontoon/checks/migrations/0001_squashed_0004_auto_20200206_0932.py | 2 | 2984 | # Generated by Django 1.11.28 on 2020-03-08 19:52
from django.db import migrations, models
import django.db.migrations.operations.special
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
("base", "__first__"),
]
operations = [
mi... | bsd-3-clause | 95a0fd59dc75fe8df6e0409c8cbc1754 | 29.762887 | 68 | 0.342493 | 6.152577 | false | false | false | false |
mozilla/pontoon | pontoon/api/schema.py | 2 | 5726 | import graphene
from graphene_django import DjangoObjectType
from graphene_django.debug import DjangoDebug
from pontoon.api.util import get_fields
from pontoon.base.models import (
Locale as LocaleModel,
Project as ProjectModel,
ProjectLocale as ProjectLocaleModel,
)
from pontoon.tags.models import Tag a... | bsd-3-clause | b63c848e8a0be3fab71802655fd5b262 | 27.346535 | 75 | 0.601292 | 4.314996 | false | false | false | false |
mozilla/pontoon | pontoon/sync/migrations/0002_change_pontoon_sync_email.py | 2 | 1040 | # Generated by Django 1.11.28 on 2020-03-08 19:30
from django.db import migrations
SYNC_USER = {
"username": "pontoon-sync",
"email": "pontoon-sync@mozilla.com",
"first_name": "Sync",
}
def add_sync_user(apps, schema_editor):
User = apps.get_model("auth", "User")
UserProfile = apps.get_model("ba... | bsd-3-clause | eb41f440ba81c892c6bfed830b0b3a0a | 21.12766 | 60 | 0.625962 | 3.45515 | false | false | false | false |
mozilla/pontoon | pontoon/translations/views.py | 2 | 15355 | from django.contrib.auth.decorators import login_required
from django.db import transaction
from django.http import JsonResponse
from django.shortcuts import get_object_or_404
from django.urls import reverse
from django.utils import timezone
from django.utils.datastructures import MultiValueDictKeyError
from django.vie... | bsd-3-clause | 922f31f08182cf4a2c8708f6ec9df82d | 29.107843 | 95 | 0.590882 | 4.557732 | false | false | false | false |
mozilla/pontoon | pontoon/batch/forms.py | 2 | 1064 | import urllib.parse
from django import forms
from pontoon.base import utils
from pontoon.batch.actions import ACTIONS_FN_MAP
class BatchActionsForm(forms.Form):
"""Handles the arguments passed to the batch actions view."""
locale = forms.CharField()
action = forms.ChoiceField(choices=[(x, x) for x in A... | bsd-3-clause | 84653502738d7208efc2f0516094ce16 | 30.294118 | 103 | 0.68515 | 3.869091 | false | false | false | false |
mozilla/pontoon | pontoon/base/tests/forms/test_permission_log.py | 2 | 3207 | import pytest
from pontoon.base.forms import LocalePermsForm, ProjectLocalePermsForm
from pontoon.base.models import PermissionChangelog
@pytest.mark.django_db
def test_locale_perms_form_log_no_changes(user_a, locale_a):
form = LocalePermsForm(
{"translators": [], "managers": []}, instance=locale_a, user... | bsd-3-clause | eb84842b8626177c2d2c8eb732aa80fb | 22.580882 | 88 | 0.628313 | 3.547566 | false | true | false | false |
mozilla/pontoon | pontoon/sync/migrations/0001_squashed_0004_add-sync-system-user.py | 2 | 3336 | # Generated by Django 1.11.28 on 2020-03-08 19:30
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
initial = True
dependencies = [
("base", "0002_auto_20200322_1821"),
]
operations = [
migra... | bsd-3-clause | 8803da64a725bfb3dd006b66bbaad37b | 31.705882 | 88 | 0.420564 | 5.42439 | false | false | false | false |
mozilla/pontoon | pontoon/sync/tests/test_tasks.py | 2 | 15685 | from unittest.mock import ANY, patch, PropertyMock
import pytest
from pontoon.base.models import ChangedEntityLocale, Locale, Project, Repository
from pontoon.base.tests import (
ChangedEntityLocaleFactory,
CONTAINS,
ProjectFactory,
RepositoryFactory,
TestCase,
TranslationFactory,
)
from ponto... | bsd-3-clause | 9de6f85f1e54da6b0829eaa92468fd89 | 34.089485 | 89 | 0.607906 | 4.042526 | false | true | false | false |
mozilla/pontoon | pontoon/sync/tests/test_models.py | 2 | 6197 | from pontoon.base.tests import ProjectFactory, RepositoryFactory, TestCase
from pontoon.base.utils import aware_datetime
from pontoon.sync.models import ProjectSyncLog
from pontoon.sync.tests import (
ProjectSyncLogFactory,
RepositorySyncLogFactory,
SyncLogFactory,
)
class SyncLogTests(TestCase):
def ... | bsd-3-clause | d311577f45f247a0dd1d4d47d006033e | 33.237569 | 88 | 0.632726 | 4.016202 | false | true | false | false |
mozilla/pontoon | pontoon/base/migrations/0013_transvision_remove.py | 2 | 1201 | # Generated by Django 3.1.3 on 2021-02-03 14:15
import django.contrib.postgres.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("base", "0012_auto_20201020_1830"),
]
operations = [
migrations.RemoveField(
model_name="lo... | bsd-3-clause | 2bf41ee295df6ecf4ee70bd19ba87237 | 30.605263 | 73 | 0.486261 | 4.983402 | false | false | false | false |
mozilla/pontoon | pontoon/db/migrations.py | 2 | 2050 | """
Django 1.10.5 doesn't support migrations/updates for fulltext fields, django-pg-fts isn't
actively maintained and current codebase is broken between various versions of Django.
Because of that I decided to implement our migrations with intent to drop it when django develops
its own solution.
"""
import copy
from ... | bsd-3-clause | bce3fd70c1248a9412ca069b7127c5f0 | 24.949367 | 97 | 0.631707 | 3.673835 | false | false | false | false |
mozilla/pontoon | pontoon/insights/migrations/0008_time_to_review_suggestions_data.py | 2 | 2852 | # Generated by Django 3.2.4 on 2021-11-30 19:56
from datetime import datetime, timedelta
from django.db import migrations
from django.db.models import F
def populate_time_to_review_suggestions(apps, schema_editor):
ActionLog = apps.get_model("actionlog", "ActionLog")
actions = (
ActionLog.objects.fi... | bsd-3-clause | fa0e78b1572775f6abc474c616666102 | 34.209877 | 87 | 0.640954 | 3.994398 | false | false | false | false |
mozilla/pontoon | pontoon/allauth_urls.py | 2 | 1663 | """
Pontoon requires a very specific subset of functionality implemented in django allauth.
Because of concerns related to the security concerns it's a better to keep only selected
views and don't allow user to tamper with the state of an account.
"""
import importlib
from django.urls import path
from django.conf impo... | bsd-3-clause | 0e421db930678ecb3f7ea280291ff98a | 33.645833 | 88 | 0.65905 | 4.319481 | false | false | false | false |
mozilla/pontoon | pontoon/checks/libraries/pontoon_db.py | 3 | 2637 | import html
import re
import bleach
from collections import defaultdict
from fluent.syntax import FluentParser, ast
from pontoon.sync.formats.ftl import localizable_entries
MAX_LENGTH_RE = re.compile(r"MAX_LENGTH:( *)(\d+)", re.MULTILINE)
parser = FluentParser()
def get_max_length(comment):
"""
Return ma... | bsd-3-clause | 2a775d343268f3a710518c2569749642 | 30.771084 | 88 | 0.64543 | 4.146226 | false | false | false | false |
mozilla/pontoon | pontoon/insights/migrations/0002_project_projectlocale.py | 2 | 3004 | # Generated by Django 3.1.3 on 2020-12-23 15:07
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
("base", "0012_auto_20201020_1830"),
("insights", "0001_initial"),
]
operations ... | bsd-3-clause | 1a06d3f2570bc1eea5016502ffd6a1f4 | 37.025316 | 86 | 0.475033 | 5.442029 | false | false | false | false |
mozilla/pontoon | pontoon/sync/vcs/models.py | 2 | 32832 | """
Models for working with remote translation data stored in a VCS.
"""
import logging
import os
import shutil
import requests
from datetime import datetime
from itertools import chain
from pathlib import Path
from urllib.parse import urljoin, urlparse
from compare_locales.paths import (
ProjectFiles,
TOMLP... | bsd-3-clause | edfe8efa217ddde458acbc5bcecf9a51 | 33.706131 | 98 | 0.573221 | 4.695652 | false | true | false | false |
mozilla/pontoon | pontoon/sync/formats/po.py | 2 | 3807 | """
Parser for to pofile translation format.
"""
from datetime import datetime
from django.utils import timezone
import polib
from pontoon.sync import KEY_SEPARATOR
from pontoon.sync.exceptions import ParseError
from pontoon.sync.formats.base import ParsedResource
from pontoon.sync.vcs.models import VCSTranslation
... | bsd-3-clause | df2e4c290aeab8be1bf13c31dd70f2bd | 30.46281 | 88 | 0.567901 | 4.041401 | false | false | false | false |
mozilla/pontoon | pontoon/tags/tests/utils/test_tags.py | 3 | 6925 | from unittest.mock import MagicMock, patch, PropertyMock
import pytest
from pontoon.tags.models import Tag
from pontoon.tags.utils import (
TagsLatestTranslationsTool,
TagsResourcesTool,
TagsStatsTool,
TagsTool,
TagTool,
)
from pontoon.tags.utils.base import Clonable
def test_util_tags_tool():
... | bsd-3-clause | 6b29e0dfbf287e53f229fdc0b624f032 | 33.1133 | 88 | 0.66296 | 3.303912 | false | true | false | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.