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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
neuropoly/spinalcordtoolbox | spinalcordtoolbox/scripts/sct_dmri_separate_b0_and_dwi.py | 1 | 10782 | #!/usr/bin/env python
#########################################################################################
#
# Separate b=0 and DW images from diffusion dataset.
#
#
# ---------------------------------------------------------------------------------------
# Copyright (c) 2013 Polytechnique Montreal <www.neuro.poly... | mit | 082f7e04b83c743f76c5e49115308058 | 32.69375 | 146 | 0.572436 | 3.352612 | false | false | false | false |
neuropoly/spinalcordtoolbox | spinalcordtoolbox/scripts/sct_resample.py | 1 | 5075 | #!/usr/bin/env python
#########################################################################################
#
# Resample data using nibabel.
#
# ---------------------------------------------------------------------------------------
# Copyright (c) 2014 Polytechnique Montreal <www.neuro.polymtl.ca>
# Authors: Julie... | mit | 2fa202c86dbe05da99dfdb74ef6a4657 | 31.532051 | 145 | 0.579507 | 3.745387 | false | false | false | false |
neuropoly/spinalcordtoolbox | spinalcordtoolbox/scripts/sct_register_to_template.py | 1 | 64537 | #!/usr/bin/env python
#########################################################################################
#
# Register anatomical image to the template using the spinal cord centerline/segmentation.
#
# ---------------------------------------------------------------------------------------
# Copyright (c) 2013 Po... | mit | 20d16d03c3a85c59901e405eb29d9ed1 | 47.414854 | 197 | 0.620249 | 3.565777 | false | false | false | false |
neuropoly/spinalcordtoolbox | spinalcordtoolbox/scripts/sct_process_segmentation.py | 1 | 19795 | #!/usr/bin/env python
#########################################################################################
#
# Perform various types of processing from the spinal cord segmentation (e.g. extract centerline, compute CSA, etc.).
# (extract_centerline) extract the spinal cord centerline from the segmentation. Output ... | mit | eb5618c4ffd2b1d6b5a84f8e4dc2780d | 42.891353 | 157 | 0.588633 | 3.863947 | false | false | false | false |
neuropoly/spinalcordtoolbox | spinalcordtoolbox/testing/create_test_data.py | 1 | 13593 | # -*- coding: utf-8
# Collection of functions to create data for testing
import numpy as np
import numpy.matlib
from numpy.polynomial import Polynomial as P
from datetime import datetime
import itertools
from skimage.transform import rotate
from random import uniform
import copy
import nibabel as nib
from spinalcor... | mit | 261d5edaed945bd19dd55b3690f7d83b | 47.031802 | 120 | 0.627161 | 3.213475 | false | false | false | false |
neuropoly/spinalcordtoolbox | spinalcordtoolbox/deepseg_gm/deepseg_gm.py | 1 | 10598 | # coding: utf-8
# This is the interface API for the deepseg_gm model
# that implements the model for the Spinal Cord Gray Matter Segmentation.
#
# Reference paper:
# Perone, C. S., Calabrese, E., & Cohen-Adad, J. (2017).
# Spinal cord gray matter segmentation using deep dilated convolutions.
# URL: https://... | mit | 0555bb6784481136306cf9b184d87e47 | 30.825826 | 92 | 0.618041 | 3.810859 | false | false | false | false |
neuropoly/spinalcordtoolbox | spinalcordtoolbox/scripts/sct_compute_hausdorff_distance.py | 1 | 25171 | #!/usr/bin/env python
#
# Thinning with the Zhang-Suen algorithm (1984) --> code taken from https://github.com/linbojin/Skeletonization-by-Zhang-Suen-Thinning-Algorithm
# Computation of the distances between two skeleton
# ---------------------------------------------------------------------------------------
# Copyri... | mit | 100383ded5a95c9131f0b596e8b9550f | 43.237258 | 191 | 0.512415 | 3.620685 | false | false | false | false |
reviewboard/reviewboard | reviewboard/reviews/ui/text.py | 1 | 13698 | import logging
from django.template.loader import render_to_string
from django.utils.encoding import force_bytes
from django.utils.safestring import mark_safe
from djblets.cache.backend import cache_memoize
from pygments import highlight
from pygments.lexers import (ClassNotFound, guess_lexer_for_filename,
... | mit | cd5845a887e21c8ad7b2580fbe95a2ad | 35.528 | 79 | 0.579501 | 4.523778 | false | false | false | false |
reviewboard/reviewboard | reviewboard/diffviewer/forms.py | 1 | 16962 | """Forms for uploading diffs."""
from functools import partial
from dateutil.parser import isoparse
from django import forms
from django.core.exceptions import ValidationError
from django.utils.encoding import force_str
from django.utils.translation import gettext, gettext_lazy as _
from reviewboard.diffviewer.commi... | mit | 3191a67e96886f7b0567e6d46a966ad3 | 33.758197 | 79 | 0.584719 | 4.621798 | false | false | false | false |
reviewboard/reviewboard | reviewboard/oauth/admin.py | 1 | 5321 | """Django model administration for OAuth2 applications."""
import importlib
from django.contrib.admin.options import IS_POPUP_VAR
from django.contrib.admin.utils import flatten_fieldsets
from django.utils.translation import gettext_lazy as _
from djblets.forms.fieldsets import filter_fieldsets
from reviewboard.admin... | mit | d4850d1a9f7c8138ba251819b254be79 | 33.329032 | 79 | 0.588987 | 4.846084 | false | false | false | false |
reviewboard/reviewboard | reviewboard/webapi/resources/watched_review_request.py | 1 | 3491 | from djblets.util.decorators import augment_method_from
from reviewboard.webapi.decorators import webapi_check_local_site
from reviewboard.webapi.resources import resources
from reviewboard.webapi.resources.base_watched_object import \
BaseWatchedObjectResource
class WatchedReviewRequestResource(BaseWatchedObjec... | mit | 43b3823f975da28d9be50f5e339f9cfd | 34.989691 | 78 | 0.679175 | 4.27295 | false | false | false | false |
reviewboard/reviewboard | reviewboard/site/context_processors.py | 1 | 1972 | from django.contrib.auth.context_processors import PermLookupDict, PermWrapper
from reviewboard.site.models import LocalSite
class AllPermsLookupDict(PermLookupDict):
def __init__(self, user, app_label, perms_wrapper):
super(AllPermsLookupDict, self).__init__(user, app_label)
self.perms_wrapper ... | mit | 8305db4ffb6fcdf80e183d0f8da73c13 | 30.806452 | 78 | 0.64858 | 3.8591 | false | false | false | false |
reviewboard/reviewboard | reviewboard/reviews/views/mixins.py | 1 | 11984 | """Mixins for review request views."""
from __future__ import annotations
import logging
from datetime import datetime
from typing import List, Optional
from django.db.models import Q
from django.http import Http404, HttpRequest, HttpResponse
from django.shortcuts import get_object_or_404, render
from django.templat... | mit | 778649051dff176c4a2ee0bf3bec6fcf | 34.351032 | 79 | 0.597213 | 4.937783 | false | false | false | false |
reviewboard/reviewboard | reviewboard/webapi/resources/base_file_attachment_comment.py | 1 | 4652 | """Base class for file attachment comment resources."""
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Q
from django.template.defaultfilters import timesince
from djblets.util.decorators import augment_method_from
from djblets.webapi.fields import ResourceFieldType, StringFieldType
... | mit | e353735cd585d819220d6fa83d19fe3a | 35.629921 | 78 | 0.616509 | 4.516505 | false | false | false | false |
reviewboard/reviewboard | reviewboard/accounts/decorators.py | 1 | 3020 | from functools import wraps
from urllib.parse import quote
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect
from djblets.siteconfig.models import SiteConfiguration
from djblets.util.decorators import simple_decorator
from reviewboard.accounts.privacy import is_con... | mit | 2de6ae88a14a7c2038c7f373f7c70468 | 34.116279 | 79 | 0.634437 | 4.589666 | false | true | false | false |
reviewboard/reviewboard | reviewboard/notifications/managers.py | 1 | 2090 | from django.db.models import Manager, Q
class WebHookTargetManager(Manager):
"""Manages WebHookTarget models.
This provides a utility function for querying WebHookTargets for a
given event.
"""
def for_event(self, event, local_site_id=None, repository_id=None):
"""Returns a list of match... | mit | 8bbbfb88c02dfae680717b5a8dbb83b8 | 32.709677 | 79 | 0.58134 | 4.074074 | false | false | false | false |
reviewboard/reviewboard | reviewboard/diffviewer/models/diffcommit.py | 1 | 8673 | """DiffCommit model definition."""
from dateutil.tz import tzoffset
from django.db import models
from django.utils import timezone
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from djblets.db.fields import JSONField
from reviewboard.diffviewer.diffutils im... | mit | 316ebabe83c4daa914feb3ef6cbbe88c | 30.423913 | 79 | 0.58907 | 4.306356 | false | false | false | false |
reviewboard/reviewboard | reviewboard/scmtools/plastic.py | 1 | 12357 | import logging
import os
import re
import subprocess
from tempfile import mkstemp
from django.utils.translation import gettext_lazy as _
from djblets.util.filesystem import is_exe_in_path
from reviewboard.scmtools.core import (SCMTool, ChangeSet,
HEAD, PRE_CREATION)
from reviewb... | mit | c3daa03459f50ab0bef5000ae2b5652d | 32.947802 | 79 | 0.540908 | 4.299582 | false | false | false | false |
reviewboard/reviewboard | reviewboard/webapi/resources/oauth_token.py | 1 | 11990 | """An API for managing OAuth2 tokens."""
from django.db.models.query import Q
from django.utils.translation import gettext_lazy as _
from djblets.util.decorators import augment_method_from
from djblets.webapi.decorators import (webapi_login_required,
webapi_request_fields,
... | mit | 7b6072a25887fdae6bbd2659901814dd | 31.581522 | 78 | 0.550292 | 4.750396 | false | false | false | false |
reviewboard/reviewboard | reviewboard/diffviewer/tests/test_diff_renderer.py | 1 | 5193 | from django.http import HttpResponse
from django.test import RequestFactory
from djblets.cache.backend import cache_memoize
from kgb import SpyAgency
from reviewboard.diffviewer.errors import UserVisibleError
from reviewboard.diffviewer.models import FileDiff
from reviewboard.diffviewer.renderers import DiffRenderer
f... | mit | ce6e2d68dda83aeb8cb9a687cb2914b4 | 34.568493 | 75 | 0.580204 | 4.218522 | false | true | false | false |
reviewboard/reviewboard | reviewboard/diffviewer/parser.py | 1 | 67820 | import io
import logging
import re
import weakref
from copy import deepcopy
from django.utils.encoding import force_bytes
from django.utils.translation import gettext as _
from djblets.util.properties import AliasProperty, TypedProperty
from pydiffx import DiffType, DiffX
from pydiffx.errors import DiffXParseError
fr... | mit | 59b569c7e244fa46769f80886564a0a6 | 34.713533 | 79 | 0.55808 | 4.687262 | false | false | false | false |
reviewboard/reviewboard | reviewboard/webapi/resources/review_general_comment.py | 1 | 4426 | from django.core.exceptions import ObjectDoesNotExist
from djblets.util.decorators import augment_method_from
from djblets.webapi.decorators import (webapi_login_required,
webapi_response_errors,
webapi_request_fields)
from djblets.webapi.err... | mit | 9c829966c8987a859770355f2068233d | 38.873874 | 79 | 0.640533 | 4.301263 | false | false | false | false |
reviewboard/reviewboard | reviewboard/webapi/tests/test_diffcommit.py | 1 | 11787 | """Unit tests for the DiffCommitResource."""
from django.contrib.auth.models import User
from djblets.features.testing import override_feature_checks
from djblets.testing.decorators import add_fixtures
from djblets.webapi.errors import PERMISSION_DENIED
from djblets.webapi.testing.decorators import webapi_test_templat... | mit | 1c38851f0f3459bccd1d468f4bdbd404 | 39.927083 | 79 | 0.591414 | 4.279956 | false | true | false | false |
reviewboard/reviewboard | reviewboard/hostingsvcs/beanstalk.py | 1 | 18155 | import json
import logging
import os
from collections import defaultdict
from urllib.error import HTTPError, URLError
from urllib.parse import quote
from django import forms
from django.http import HttpResponse
from django.urls import path
from django.utils.translation import gettext_lazy as _
from django.views.decora... | mit | a44e9e29202701e9b0ffaeb550738830 | 35.31 | 79 | 0.570366 | 4.57766 | false | false | false | false |
reviewboard/reviewboard | reviewboard/webapi/resources/root_general_comment.py | 1 | 5492 | """Root general comments API resource.
Version Added:
5.0
"""
from django.db.models import Q
from djblets.util.decorators import augment_method_from
from djblets.webapi.decorators import webapi_request_fields
from djblets.webapi.fields import (BooleanFieldType,
DateTimeFieldType... | mit | f4f1f89a9466c262df32bfceb2df79e3 | 35.370861 | 79 | 0.539694 | 4.682012 | false | false | false | false |
reviewboard/reviewboard | reviewboard/accounts/pages.py | 1 | 4183 | import logging
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from djblets.configforms.mixins import DynamicConfigPageMixin
from djblets.configforms.pages import ConfigPage
from djblets.configforms.registry import ConfigPageRegistry
from djblets.registries.errors import ItemLook... | mit | 5594bbe5ce27b1164b628a62ea772ad9 | 29.532847 | 77 | 0.619651 | 4.715896 | false | true | false | false |
reviewboard/reviewboard | reviewboard/reviews/tests/test_root_view.py | 1 | 2709 | """Unit tests for reviewboard.reviews.views.RootView."""
from djblets.testing.decorators import add_fixtures
from reviewboard.site.urlresolvers import local_site_reverse
from reviewboard.testing import TestCase
class RootViewTests(TestCase):
"""Unit tests for reviewboard.reviews.views.RootView."""
fixtures... | mit | 48289702cbd4e1d0bd8b38ab819cbd64 | 37.7 | 77 | 0.628276 | 4.2 | false | true | false | false |
reviewboard/reviewboard | reviewboard/search/search_backends/whoosh.py | 1 | 2205 | """A backend for the Whoosh search engine."""
import os
from django import forms
from django.conf import settings
from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _
from reviewboard.search.search_backends.base import (SearchBackend,
... | mit | 4839e492004943f38ff84861a15b254d | 31.910448 | 77 | 0.598186 | 4.366337 | false | true | false | false |
reviewboard/reviewboard | reviewboard/reviews/views/attachments.py | 1 | 5268 | """Views for reviewing file attachments (and legacy screenshots)."""
import logging
from typing import Optional
from django.db.models import Q
from django.http import Http404, HttpRequest, HttpResponse
from django.shortcuts import get_object_or_404
from django.views.generic.base import View
from reviewboard.accounts... | mit | 807207aec92f291725fd3c06fe2c1872 | 33.207792 | 79 | 0.604214 | 4.65371 | false | false | false | false |
reviewboard/reviewboard | reviewboard/scmtools/models.py | 1 | 51341 | import logging
import uuid
from functools import wraps
from importlib import import_module
from time import time
from urllib.parse import quote
from django.contrib.auth.models import User
from django.core.cache import cache
from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.db import ... | mit | 51d8aeed5273ea1fafabecd7513248a9 | 36.069314 | 79 | 0.581485 | 4.800019 | false | false | false | false |
reviewboard/reviewboard | reviewboard/hostingsvcs/fedorahosted.py | 1 | 2006 | from django import forms
from django.utils.translation import gettext_lazy as _
from reviewboard.hostingsvcs.forms import HostingServiceForm
from reviewboard.hostingsvcs.service import HostingService
class FedoraHostedForm(HostingServiceForm):
fedorahosted_repo_name = forms.CharField(
label=_('Repository... | mit | dd6dba7a211aada7f35b8dec5230c9cc | 33.586207 | 74 | 0.58674 | 3.910331 | false | false | false | false |
reviewboard/reviewboard | reviewboard/admin/forms/diff_settings.py | 1 | 4955 | """Administration form for diff viewer settings."""
import re
from django import forms
from django.utils.translation import gettext_lazy as _
from djblets.forms.fields import ListEditDictionaryField
from djblets.forms.widgets import ListEditWidget
from djblets.siteconfig.forms import SiteSettingsForm
from reviewboar... | mit | e25df6e4f073bba858de9c30e56f1e45 | 38.325397 | 79 | 0.58668 | 4.701139 | false | false | false | false |
reviewboard/reviewboard | reviewboard/scmtools/clearcase.py | 1 | 24203 | """ClearCase SCM provider."""
import logging
import os
import re
import subprocess
import sys
import tempfile
from django.conf import settings
from django.utils.encoding import force_str
from django.utils.translation import gettext_lazy as _
from reviewboard.diffviewer.parser import DiffParser
from reviewboard.scmto... | mit | 54ec6dc2268accbda7d40767bb9234dc | 31.795393 | 79 | 0.564682 | 4.568328 | false | false | false | false |
reviewboard/reviewboard | reviewboard/integrations/tests/test_views.py | 1 | 1869 | from django.test import RequestFactory
from reviewboard.integrations.base import Integration, get_integration_manager
from reviewboard.integrations.models import IntegrationConfig
from reviewboard.integrations.views import AdminIntegrationConfigFormView
from reviewboard.site.models import LocalSite
from reviewboard.te... | mit | 677c8c46da5945143b50659ce5b75169 | 37.9375 | 78 | 0.708935 | 4.408019 | false | true | false | false |
reviewboard/reviewboard | reviewboard/admin/tests/test_lexers_mapping_widget.py | 1 | 4389 | """Unit tests for reviewboard.admin.form_widgets.LexersMappingWidget."""
from django import forms
from django.utils.html import escape, format_html
from pygments.lexers import get_all_lexers
from reviewboard.admin.form_widgets import LexersMappingWidget
from reviewboard.testing.testcase import TestCase
class TestFo... | mit | 17010beb3ff1945274a1023803375e12 | 32.761538 | 79 | 0.546822 | 4.082791 | false | true | false | false |
reviewboard/reviewboard | reviewboard/diffviewer/models/raw_file_diff_data.py | 1 | 3478 | """RawFileDiffData model definition."""
import bz2
import logging
from django.db import models
from django.utils.translation import gettext_lazy as _
from djblets.db.fields import JSONField
from reviewboard.diffviewer.errors import DiffParserError
from reviewboard.diffviewer.managers import RawFileDiffDataManager
... | mit | e636d73082d490c8c6fa6faa0149e11b | 32.12381 | 77 | 0.620759 | 4.246642 | false | false | false | false |
reviewboard/reviewboard | reviewboard/reviews/management/commands/fill-database.py | 1 | 16212 | import os
import random
import string
import sys
from django import db
from django.contrib.auth.models import User
from django.core.files import File
from django.core.management.base import BaseCommand, CommandError
from django.db import transaction
from reviewboard.accounts.models import Profile
from reviewboard.rev... | mit | 44785442dc14b0ac188f18e457071f28 | 41.439791 | 79 | 0.51098 | 3.601066 | false | false | false | false |
reviewboard/reviewboard | reviewboard/admin/templatetags/rbadmintags.py | 1 | 11584 | import re
from django import template
from django.contrib import messages
from django.contrib.admin.templatetags.admin_urls import (
add_preserved_filters,
admin_urlquote)
from django.contrib.auth.models import User
from django.template.context import RequestContext
from django.urls import reverse
from django.... | mit | d6b4bc3242cb9d8e82d6d1a8a55356b2 | 32.287356 | 79 | 0.607131 | 4.230825 | false | false | false | false |
reviewboard/reviewboard | reviewboard/webapi/resources/review_draft.py | 1 | 1253 | from django.core.exceptions import ObjectDoesNotExist
from djblets.webapi.decorators import webapi_login_required
from djblets.webapi.errors import DOES_NOT_EXIST
from reviewboard.webapi.base import WebAPIResource
from reviewboard.webapi.decorators import webapi_check_local_site
from reviewboard.webapi.resources impor... | mit | 5bdd5ada4e449122952d002ad0783095 | 32.864865 | 77 | 0.671987 | 4.135314 | false | false | false | false |
reviewboard/reviewboard | reviewboard/hostingsvcs/assembla.py | 1 | 7297 | from django import forms
from django.utils.translation import gettext_lazy as _
from reviewboard.admin.server import get_hostname
from reviewboard.hostingsvcs.forms import HostingServiceForm
from reviewboard.hostingsvcs.service import HostingService
from reviewboard.scmtools.crypto_utils import (decrypt_password,
... | mit | 84b17b0f1434ed265fe38ad9d41a1f26 | 31.431111 | 78 | 0.573797 | 4.509889 | false | false | false | false |
reviewboard/reviewboard | reviewboard/webapi/resources/repository_user.py | 1 | 11412 | """API resource for managing a repository's user ACL.
Version Added:
4.0.11
"""
from __future__ import unicode_literals
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
from djblets.util.decorators import augment_method_from
from djblets.webapi.decorators import (... | mit | d1c6c1fdee628304c708c2537b8d021c | 33.27027 | 79 | 0.59972 | 4.570284 | false | false | false | false |
reviewboard/reviewboard | reviewboard/scmtools/errors.py | 1 | 7623 | from django.utils.encoding import force_str
from django.utils.translation import gettext as _
from reviewboard.ssh.errors import SSHAuthenticationError
class SCMError(Exception):
def __init__(self, msg):
Exception.__init__(self, msg)
class ChangeSetError(SCMError):
pass
class InvalidChangeNumberE... | mit | 73623cf0cfdbce6d6c34432c3c1e6b65 | 30.241803 | 79 | 0.578906 | 4.691077 | false | false | false | false |
reviewboard/reviewboard | reviewboard/webapi/resources/repository_group.py | 1 | 10388 | """API resource for managing a repository's group ACL.
Version Added:
4.0.11
"""
from __future__ import unicode_literals
from django.core.exceptions import ObjectDoesNotExist
from djblets.webapi.decorators import (webapi_login_required,
webapi_request_fields,
... | mit | e015c06878141ed12b158353e9c84921 | 33.511628 | 82 | 0.59819 | 4.610741 | false | false | false | false |
reviewboard/reviewboard | reviewboard/webapi/resources/user.py | 1 | 23642 | import logging
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.core.validators import validate_email
from django.db import IntegrityError, transaction
from django.db.models import Q
from djblets.util.decorators import augment_method_from
fr... | mit | eb4dc84961275db0cf88823640689688 | 37.317666 | 79 | 0.520684 | 4.787768 | false | false | false | false |
reviewboard/reviewboard | reviewboard/hostingsvcs/bugzilla.py | 1 | 2250 | import logging
from django import forms
from django.utils.translation import gettext_lazy as _
from reviewboard.hostingsvcs.bugtracker import BugTracker
from reviewboard.hostingsvcs.forms import HostingServiceForm
from reviewboard.hostingsvcs.service import HostingService
from reviewboard.admin.validation import vali... | mit | f0d2c9fe3c317236e2354979d63b8b63 | 32.088235 | 78 | 0.597333 | 3.996448 | false | false | false | false |
reviewboard/reviewboard | reviewboard/webapi/resources/review_group_user.py | 1 | 9033 | from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
from djblets.util.decorators import augment_method_from
from djblets.webapi.decorators import (webapi_login_required,
webapi_response_errors,
we... | mit | 5cb48f008fc32f10daaa30bfbc09507c | 36.020492 | 79 | 0.606 | 4.260849 | false | false | false | false |
exercism/python | exercises/practice/all-your-base/all_your_base_test.py | 2 | 3983 | import unittest
from all_your_base import (
rebase,
)
# Tests adapted from `problem-specifications//canonical-data.json`
class AllYourBaseTest(unittest.TestCase):
def test_single_bit_one_to_decimal(self):
self.assertEqual(rebase(2, [1], 10), [1])
def test_binary_to_single_decimal(self):
... | mit | 897e22befe29d9096f4d65ad2c187bbf | 34.882883 | 80 | 0.609089 | 3.347059 | false | true | false | false |
exercism/python | exercises/practice/accumulate/accumulate_test.py | 8 | 1136 | import unittest
from accumulate import accumulate
class AccumulateTest(unittest.TestCase):
def test_empty_sequence(self):
self.assertEqual(accumulate([], lambda x: x / 2), [])
def test_pow(self):
self.assertEqual(
accumulate([1, 2, 3, 4, 5], lambda x: x * x), [1, 4, 9, 16, 25])
... | mit | 403e58320f82487d428b48cb1d3118bb | 28.128205 | 78 | 0.503521 | 3.452888 | false | true | false | false |
exercism/python | bin/data.py | 2 | 9982 | from enum import Enum
from dataclasses import dataclass, asdict, fields
import dataclasses
from itertools import chain
import json
from pathlib import Path
import tomli
from typing import List, Any, Dict, Type
def _custom_dataclass_init(self, *args, **kwargs):
# print(self.__class__.__name__, "__init__")
name... | mit | fc7d70026b9891116e9314e5230db917 | 25.68984 | 113 | 0.577039 | 3.840708 | false | false | false | false |
exercism/python | exercises/concept/cater-waiter/.meta/exemplar.py | 2 | 4882 | """Functions for compiling dishes and ingredients for a catering company."""
from sets_categories_data import (VEGAN,
VEGETARIAN,
KETO,
PALEO,
OMNIVORE,
... | mit | f30a4622857a7b52b23fd323deb9e666 | 35.432836 | 126 | 0.663867 | 3.445307 | false | false | false | false |
spaam/svtplay-dl | lib/svtplay_dl/service/mtvnn.py | 1 | 6186 | import json
import logging
import re
import xml.etree.ElementTree as ET
from urllib.parse import urlparse
from svtplay_dl.error import ServiceError
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.service import OpenGraphThumbMixin
from svtplay_dl.service import Service
# This is _very_ similar to mtvserv... | mit | 9ed23300b7af9862c8ac06b484029101 | 40.516779 | 150 | 0.556741 | 3.586087 | false | false | false | false |
exercism/python | exercises/practice/markdown/markdown.py | 2 | 2720 | import re
def parse(markdown):
lines = markdown.split('\n')
res = ''
in_list = False
in_list_append = False
for i in lines:
if re.match('###### (.*)', i) is not None:
i = '<h6>' + i[7:] + '</h6>'
elif re.match('##### (.*)', i) is not None:
i = '<h5>' + i[6:]... | mit | d5bcf6de602980e764b580fbfd5d6e1f | 34.324675 | 79 | 0.316912 | 3.358025 | false | false | false | false |
spaam/svtplay-dl | lib/svtplay_dl/service/sr.py | 1 | 1048 | # ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
import copy
import json
import re
from svtplay_dl.error import ServiceError
from svtplay_dl.fetcher.http import HTTP
from svtplay_dl.service import OpenGraphThumbMixin
from svtplay_dl.service import Service
class Sr(Service, Ope... | mit | 88cb43031b3d09dfb22fb4dd8c44cb5b | 32.806452 | 118 | 0.648855 | 3.18541 | false | false | false | false |
pinax/django-user-accounts | account/tests/test_models.py | 1 | 1652 | from django.test import TestCase
from account.models import SignupCode
class SignupCodeModelTestCase(TestCase):
def test_exists_no_match(self):
code = SignupCode(email="foobar@example.com", code="FOOFOO")
code.save()
self.assertFalse(SignupCode.exists(code="BARBAR"))
self.assertF... | mit | 3d5d94676044ff38db03a3a2d6fd6c53 | 35.711111 | 85 | 0.673729 | 3.545064 | false | true | false | false |
exercism/python | exercises/practice/word-search/.meta/example.py | 2 | 1676 | import copy
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def __repr__(self):
return f'Point({self.x}:{self.y})'
def __add__(self, other):
return Point(self.x + other.x, self.y + other.y)
def __sub__(self, other):
return Point(self.x - other.x,... | mit | c5c7c8845f9029be233c4730680c8c15 | 27.896552 | 80 | 0.539976 | 3.766292 | false | false | false | false |
exercism/python | exercises/practice/connect/.meta/example.py | 2 | 2077 |
class ConnectGame:
DIRECTIONS = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, -1), (-1, 1)]
WHITE = 'O'
BLACK = 'X'
def __init__(self, lines):
self.board = ConnectGame.make_board(lines)
assert len(self.board) > 0
self.width = len(self.board[0])
self.height = len(self.board)
... | mit | 992b3234dceb423602c5498d04275b5b | 30.469697 | 107 | 0.548869 | 3.933712 | false | false | false | false |
exercism/python | exercises/concept/card-games/.meta/exemplar.py | 2 | 2294 | """Functions for tracking poker hands and assorted card tasks.
Python list documentation: https://docs.python.org/3/tutorial/datastructures.html
"""
def get_rounds(number):
"""Create a list containing the current and next two round numbers.
:param number: int - current round number.
:return: list - curr... | mit | cc486c3b1bacaab601f079da3c39a61f | 25.068182 | 107 | 0.647341 | 3.748366 | false | false | false | false |
pinax/django-user-accounts | account/management/commands/user_password_expiry.py | 2 | 1267 | from django.contrib.auth import get_user_model
from django.core.management.base import LabelCommand
from account.conf import settings
from account.models import PasswordExpiry
class Command(LabelCommand):
help = "Create user-specific password expiration period."
label = "username"
def add_arguments(sel... | mit | 9a57923425c14c5e0daa2a24cd6c39af | 31.487179 | 89 | 0.633781 | 4.477032 | false | false | false | false |
codefordc/housing-insights | back_end/ETL/project.py | 1 | 6472 | '''
make_projects_table.py
----------------------
This file creates the projects table in the database, which is sent to
the front-end via /api/projects/. It depends on the following data sources:
- Projects.csv, From the Preservation Catalog Folder in the s3
- 'Affordable Housing Data... | mit | ce361b25d3fd2ac5c74cd6679907529f | 40.487179 | 192 | 0.631335 | 3.313876 | false | false | false | false |
rapptz/discord.py | discord/types/scheduled_event.py | 3 | 3294 | """
The MIT License (MIT)
Copyright (c) 2015-present Rapptz
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merg... | mit | 49b4fbc81280667d5959fa78f00e7fc5 | 28.675676 | 118 | 0.789314 | 3.852632 | false | false | false | false |
explosion/thinc | thinc/tests/test_import__all__.py | 1 | 1800 | import ast
from collections import namedtuple
from typing import Tuple, List
import pytest
import importlib
_Import = namedtuple("_Import", ["module", "name", "alias"])
def get_imports(path: str) -> Tuple[_Import, ...]:
"""Parse Python file at path, retrieve import statements.
Adapted from https://stackover... | mit | 30b44193b3650a7b73a34d87c11016db | 32.962264 | 114 | 0.613333 | 3.781513 | false | true | false | false |
explosion/thinc | thinc/layers/with_debug.py | 1 | 1333 | from typing import Optional, Callable, Any, Tuple, TypeVar
from ..model import Model
_ModelT = TypeVar("_ModelT", bound=Model)
do_nothing = lambda *args, **kwargs: None
def with_debug(
layer: _ModelT,
name: Optional[str] = None,
*,
on_init: Callable[[Model, Any, Any], None] = do_nothing,
on_for... | mit | edc4164e3518cdc75a543e95fa526435 | 29.295455 | 78 | 0.636909 | 3.535809 | false | false | false | false |
explosion/thinc | thinc/layers/with_array2d.py | 1 | 4080 | from typing import Tuple, Callable, Optional, TypeVar, cast, List, Union
from ..model import Model
from ..config import registry
from ..types import Array2d, Floats2d, List2d, Padded, Ragged
ValT = TypeVar("ValT", bound=Array2d)
SeqT = TypeVar("SeqT", bound=Union[Padded, Ragged, List2d, Array2d])
@registry.layers(... | mit | 5e77bb2a70e69e74f8442d614dee20cf | 32.442623 | 82 | 0.627206 | 2.839248 | false | false | false | false |
explosion/thinc | thinc/model.py | 1 | 34868 | from typing import Dict, List, Callable, Optional, Any, Union, Iterable, Set, cast
from typing import Generic, Sequence, Tuple, TypeVar, Iterator
import contextlib
from contextvars import ContextVar
import srsly
from pathlib import Path
import copy
import functools
import threading
from .backends import ParamServer, O... | mit | f802804091463a43c652283f17c9dc07 | 38.803653 | 109 | 0.567397 | 4.110338 | false | false | false | false |
rapptz/discord.py | discord/components.py | 1 | 16416 | """
The MIT License (MIT)
Copyright (c) 2015-present Rapptz
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merg... | mit | 516b60c1dcf58a0065d93f574e4219ec | 30.090909 | 113 | 0.605141 | 4.118414 | false | false | false | false |
rapptz/discord.py | discord/types/command.py | 2 | 6266 | """
The MIT License (MIT)
Copyright (c) 2015-present Rapptz
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merg... | mit | d2217f812cdd8a80008151d4096ff027 | 27.743119 | 93 | 0.783434 | 4.19411 | false | false | false | false |
alphagov/notifications-utils | notifications_utils/clients/redis/request_cache.py | 1 | 2989 | import json
from contextlib import suppress
from datetime import timedelta
from functools import wraps
from inspect import signature
class RequestCache:
DEFAULT_TTL = int(timedelta(days=7).total_seconds())
def __init__(self, redis_client):
self.redis_client = redis_client
@staticmethod
def ... | mit | 8e8d42a95f1c8a7b918554f55aee7535 | 33.356322 | 107 | 0.567748 | 4.487988 | false | false | false | false |
alphagov/notifications-utils | tests/clients/zendesk/test_zendesk_client.py | 1 | 7033 | from base64 import b64decode
import pytest
from notifications_utils.clients.zendesk.zendesk_client import (
NotifySupportTicket,
ZendeskClient,
ZendeskError,
)
@pytest.fixture(scope="function")
def zendesk_client(app):
client = ZendeskClient()
app.config["ZENDESK_API_KEY"] = "testkey"
clie... | mit | ac073a2507e0db0ed76ebbbdbb5ce12d | 32.650718 | 115 | 0.56633 | 3.612224 | false | true | false | false |
alphagov/notifications-utils | notifications_utils/countries/data.py | 1 | 2192 | import json
import os
def _load_data(filename):
with open(os.path.join(os.path.dirname(__file__), "_data", filename)) as contents:
if filename.endswith(".json"):
return json.load(contents)
return [line.strip() for line in contents.readlines()]
def find_canonical(item, graph, key):
... | mit | 18124577d3997b78b51d0ebff0cd8582 | 31.716418 | 86 | 0.691606 | 2.97019 | false | false | false | false |
alphagov/notifications-utils | tests/clients/antivirus/test_antivirus_client.py | 1 | 1579 | import io
import pytest
import requests
from notifications_utils.clients.antivirus.antivirus_client import (
AntivirusClient,
AntivirusError,
)
@pytest.fixture(scope="function")
def antivirus(app, mocker):
client = AntivirusClient()
app.config["ANTIVIRUS_API_HOST"] = "https://antivirus"
app.conf... | mit | f94a05d64d9a748bb3e14ae3ecdfe652 | 27.196429 | 107 | 0.678911 | 3.403017 | false | true | false | false |
alphagov/notifications-utils | notifications_utils/celery.py | 1 | 3295 | import time
from contextlib import contextmanager
from celery import Celery, Task
from flask import g, request
from flask.ctx import has_app_context, has_request_context
def make_task(app):
class NotifyTask(Task):
abstract = True
start = None
@property
def queue_name(self):
... | mit | 08b2877d50173c021f4e14f0993b0538 | 34.815217 | 118 | 0.553566 | 4.186785 | false | false | false | false |
influxdata/influxdb-python | examples/tutorial_sine_wave.py | 2 | 1991 | # -*- coding: utf-8 -*-
"""Tutorial using all elements to define a sine wave."""
import argparse
import math
import datetime
import time
from influxdb import InfluxDBClient
USER = 'root'
PASSWORD = 'root'
DBNAME = 'tutorial'
def main(host='localhost', port=8086):
"""Define function to generate the sin wave.""... | mit | 1e51b08efed9a7ed63fa9fc310c58448 | 24.525641 | 73 | 0.604721 | 3.851064 | false | false | false | false |
alphagov/notifications-utils | tests/test_countries_iso.py | 1 | 20457 | import pytest
from notifications_utils.countries import Country, CountryNotFoundError
def _country_not_found(*test_case):
return pytest.param(
*test_case,
marks=pytest.mark.xfail(raises=CountryNotFoundError),
)
@pytest.mark.parametrize(
"alpha_2, expected_name",
(
("AF", "Af... | mit | 5b76471754272f7b11027ceb4bf0c235 | 37.868821 | 82 | 0.501492 | 2.904945 | false | false | false | false |
influxdata/influxdb-python | examples/tutorial.py | 2 | 2334 | # -*- coding: utf-8 -*-
"""Tutorial on using the InfluxDB client."""
import argparse
from influxdb import InfluxDBClient
def main(host='localhost', port=8086):
"""Instantiate a connection to the InfluxDB."""
user = 'root'
password = 'root'
dbname = 'example'
dbuser = 'smly'
dbuser_password =... | mit | a6dec1121156be7dba8b394be46e2d4a | 27.814815 | 75 | 0.577978 | 3.669811 | false | false | false | false |
alphagov/notifications-utils | tests/test_letter_timings.py | 1 | 12684 | from datetime import datetime
import pytest
import pytz
from freezegun import freeze_time
from notifications_utils.letter_timings import (
get_letter_timings,
letter_can_be_cancelled,
)
@freeze_time("2017-07-14 13:59:59") # Friday, before print deadline (3PM BST)
@pytest.mark.parametrize(
(
"up... | mit | d39dc897698e47bc9d5f9644dae22109 | 33.655738 | 114 | 0.562835 | 3.187736 | false | true | false | false |
wbond/asn1crypto | tests/test_cms.py | 1 | 36612 | # coding: utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
import unittest
import os
import zlib
import sys
from datetime import datetime
from asn1crypto import cms, util
from ._unittest_compat import patch
patch()
if sys.version_info < (3,):
byte_cls = str
else:
byte... | mit | 8190e5082a4b86451c8fbc088900e1ac | 35.502493 | 119 | 0.507976 | 3.136737 | false | false | false | false |
wbond/asn1crypto | asn1crypto/ocsp.py | 2 | 19024 | # coding: utf-8
"""
ASN.1 type classes for the online certificate status protocol (OCSP). Exports
the following items:
- OCSPRequest()
- OCSPResponse()
Other type classes are defined that help compose the types listed above.
"""
from __future__ import unicode_literals, division, absolute_import, print_function
f... | mit | 9d1cfae9ba9c6ea05d153e6b5d5e3677 | 26.061166 | 111 | 0.599611 | 4.163712 | false | false | false | false |
wbond/asn1crypto | asn1crypto/algos.py | 2 | 35867 | # coding: utf-8
"""
ASN.1 type classes for various algorithms using in various aspects of public
key cryptography. Exports the following items:
- AlgorithmIdentifier()
- AnyAlgorithmIdentifier()
- DigestAlgorithm()
- DigestInfo()
- DSASignature()
- EncryptionAlgorithm()
- HmacAlgorithm()
- KdfAlgorithm()
- P... | mit | c2f73584b34c85779f473e2358d020f7 | 29.165685 | 117 | 0.518304 | 3.295993 | false | false | false | false |
wbond/asn1crypto | tests/test_crl.py | 2 | 1043 | # coding: utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
import unittest
import sys
import os
from asn1crypto import crl
from ._unittest_compat import patch
patch()
if sys.version_info < (3,):
byte_cls = str
num_cls = long # noqa
else:
byte_cls = bytes
num... | mit | 02b6ec664c695b77862e977a71e8561b | 23.833333 | 82 | 0.616491 | 3.608997 | false | true | false | false |
nschloe/meshio | src/meshio/_cli/_convert.py | 1 | 2173 | import numpy as np
from .._helpers import _writer_map, read, reader_map, write
def add_args(parser):
parser.add_argument("infile", type=str, help="mesh file to be read from")
parser.add_argument(
"--input-format",
"-i",
type=str,
choices=sorted(list(reader_map.keys())),
... | mit | 99c8fc204bc32011fab42ac3e81c3c71 | 27.973333 | 115 | 0.587207 | 3.708191 | false | false | false | false |
graphql-python/graphene | graphene/types/tests/test_base64.py | 1 | 2798 | import base64
from graphql import GraphQLError
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..base64 import Base64
class Query(ObjectType):
base64 = Base64(_in=Base64(name="input"), _match=String(name="match"))
bytes_as_base64 = Base64()
string_as_bas... | mit | 0008efb94d2291f78b84a8b5d791cb28 | 27.845361 | 84 | 0.639385 | 3.493134 | false | true | false | false |
graphql-python/graphene | graphene/types/tests/test_objecttype.py | 1 | 8250 | from pytest import raises
from ..field import Field
from ..interface import Interface
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..structures import NonNull
from ..unmountedtype import UnmountedType
class MyType(Interface):
pass
class Container(ObjectType)... | mit | c1551d1476d7ec870154f1e2fbef1b89 | 25.699029 | 86 | 0.658545 | 3.828306 | false | true | false | false |
nschloe/meshio | src/meshio/xdmf/common.py | 1 | 5436 | import numpy as np
from .._exceptions import ReadError
from .._mesh import CellBlock
numpy_to_xdmf_dtype = {
"int8": ("Int", "1"),
"int16": ("Int", "2"),
"int32": ("Int", "4"),
"int64": ("Int", "8"),
"uint8": ("UInt", "1"),
"uint16": ("UInt", "2"),
"uint32": ("UInt", "4"),
"uint64": ("... | mit | 17b3fed9e509b5db9459e4daed1cb0c1 | 30.062857 | 112 | 0.570272 | 2.667321 | false | false | false | false |
nschloe/meshio | src/meshio/h5m/_h5m.py | 1 | 8950 | """
I/O for h5m, cf.
<https://www.mcs.anl.gov/~fathom/moab-docs/html/h5mmain.html>.
"""
from datetime import datetime
import numpy as np
from .. import __about__
from .._common import warn
from .._helpers import register_format
from .._mesh import CellBlock, Mesh
# def _int_to_bool_list(num):
# # From <https://s... | mit | 89ed67456ea688904cf71346a60bd6be | 32.148148 | 88 | 0.513743 | 3.538948 | false | false | false | false |
nschloe/meshio | tests/performance.py | 1 | 11085 | import os
import pathlib
import tempfile
import time
import tracemalloc
import dufte
import matplotlib.pyplot as plt
import meshzoo
import numpy as np
import meshio
def generate_triangular_mesh():
p = pathlib.Path("sphere.xdmf")
if pathlib.Path.is_file(p):
mesh = meshio.read(p)
else:
poi... | mit | 5ce00863ad3bdc0ae99c9fe751c12119 | 31.991071 | 88 | 0.533875 | 3.04533 | false | false | false | false |
nschloe/meshio | src/meshio/off/_off.py | 1 | 2842 | """
I/O for the OFF surface format, cf.
<https://en.wikipedia.org/wiki/OFF_(file_format)>,
<http://www.geomview.org/docs/html/OFF.html>.
"""
import numpy as np
from .._common import warn
from .._exceptions import ReadError
from .._files import open_file
from .._helpers import register_format
from .._mesh import CellBl... | mit | 562fa02f9dddb19131a4eb3639bbcb3e | 29.234043 | 88 | 0.578818 | 3.296984 | false | false | false | false |
sdispater/pendulum | pendulum/helpers.py | 1 | 5288 | from __future__ import annotations
import os
import struct
from datetime import date
from datetime import datetime
from datetime import timedelta
from math import copysign
from typing import TYPE_CHECKING
from typing import TypeVar
from typing import overload
import pendulum
from pendulum.constants import DAYS_PER_... | mit | 2d717597ed19dd48c97ad59e99a155f6 | 22.713004 | 79 | 0.620651 | 3.483531 | false | false | false | false |
pyproj4/pyproj | pyproj/__main__.py | 2 | 6351 | """
This is the main entry point for pyproj CLI
e.g. python -m pyproj
"""
import argparse
import os
from pyproj import __proj_version__, __version__, _show_versions
from pyproj.aoi import BBox
from pyproj.datadir import get_data_dir, get_user_data_dir
from pyproj.sync import (
_download_resource_file,
get_p... | mit | a7c131541d26c494d3a9a1f2d9f95e64 | 29.38756 | 88 | 0.598961 | 3.952085 | false | false | false | false |
sdispater/pendulum | tests/localization/test_id.py | 1 | 2369 | from __future__ import annotations
import pendulum
locale = "id"
def test_diff_for_humans():
with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True):
diff_for_humans()
def diff_for_humans():
d = pendulum.now().subtract(seconds=1)
assert d.diff_for_humans(locale=locale) == "beberap... | mit | 43c47edb291e367225c05c245c8c7479 | 33.838235 | 88 | 0.669059 | 2.566631 | false | false | false | false |
sdispater/pendulum | pendulum/parsing/iso8601.py | 1 | 13836 | from __future__ import annotations
import datetime
import re
from typing import cast
from pendulum.constants import HOURS_PER_DAY
from pendulum.constants import MINUTES_PER_HOUR
from pendulum.constants import MONTHS_OFFSETS
from pendulum.constants import SECONDS_PER_MINUTE
from pendulum.duration import Duration
from... | mit | f9083bbb4dec6d162f5933a1f8f13f92 | 29.475771 | 129 | 0.499422 | 3.779295 | false | false | false | false |
pyproj4/pyproj | pyproj/crs/datum.py | 2 | 3722 | """
This module is for building datums to be used when
building a CRS.
"""
from typing import Any, Dict, Optional, Union
from pyproj._crs import Datum, Ellipsoid, PrimeMeridian
class CustomDatum(Datum):
"""
.. versionadded:: 2.5.0
Class to build a datum based on an ellipsoid and prime meridian.
"""
... | mit | c1bc8cc3e86eed3afd55a00d04f22124 | 31.086207 | 82 | 0.566631 | 3.963791 | false | false | false | false |
sdispater/pendulum | pendulum/time.py | 1 | 8939 | from __future__ import annotations
import datetime
from datetime import time
from datetime import timedelta
from typing import TYPE_CHECKING
from typing import Optional
from typing import cast
from typing import overload
import pendulum
from pendulum.constants import SECS_PER_HOUR
from pendulum.constants import SEC... | mit | 5835337152a470a4509343255314a1df | 28.50165 | 88 | 0.583287 | 4.104224 | false | false | false | false |
sdispater/pendulum | tests/datetime/test_behavior.py | 1 | 3578 | from __future__ import annotations
import pickle
from copy import deepcopy
from datetime import date
from datetime import datetime
from datetime import time
import pytest
import pendulum
from pendulum import timezone
from pendulum.tz.timezone import Timezone
from pendulum.utils._compat import zoneinfo
@pytest.fi... | mit | f6d12fa903b3087a710b4ff257ab6a65 | 19.802326 | 82 | 0.653158 | 2.848726 | false | true | false | false |
sdispater/pendulum | pendulum/locales/fr/locale.py | 1 | 4501 | from .custom import translations as custom_translations
"""
fr locale file.
It has been generated automatically and must not be modified directly.
"""
locale = {
"plural": lambda n: "one" if (n == n and ((n == 0) or (n == 1))) else "other",
"ordinal": lambda n: "one" if (n == n and (n == 1)) else "other",
... | mit | 41e604792f8d446d20c4aeac75322554 | 32.774436 | 86 | 0.317231 | 3.364794 | false | false | true | false |
sdispater/pendulum | pendulum/__init__.py | 1 | 8506 | from __future__ import annotations
import datetime as _datetime
from typing import Union
from typing import cast
from pendulum.__version__ import __version__
from pendulum.constants import DAYS_PER_WEEK
from pendulum.constants import FRIDAY
from pendulum.constants import HOURS_PER_DAY
from pendulum.constants import ... | mit | 8f17b64ebb9d932c920edf79ede1a527 | 22.432507 | 84 | 0.626264 | 3.445119 | false | false | false | false |
sixohsix/twitter | twitter/oauth_dance.py | 3 | 3938 | from __future__ import print_function
import webbrowser
import time
from .api import Twitter, json
from .oauth import OAuth, write_token_file
from .oauth2 import OAuth2, write_bearer_token_file
try:
_input = raw_input
except NameError:
_input = input
def oauth2_dance(consumer_key, consumer_secret, token_fi... | mit | 0f9c147d0f4e5132040717965e5b3fc3 | 32.092437 | 97 | 0.643982 | 3.89901 | false | false | false | false |
sdispater/pendulum | tests/parsing/test_parsing.py | 1 | 15572 | from __future__ import annotations
import datetime
import pytest
import pendulum
from pendulum.parsing import ParserError
from pendulum.parsing import parse
def test_y():
text = "2016"
parsed = parse(text)
assert parsed.year == 2016
assert parsed.month == 1
assert parsed.day == 1
assert ... | mit | 3731b2dd29172d5b56b0bd6499c1ea02 | 21.666667 | 54 | 0.634087 | 3.894947 | false | false | false | false |
intel/intel-iot-refkit | meta-refkit-core/scripts/lib/wic/plugins/source/dm-verity.py | 6 | 4985 | # Copyright (c) 2017, Intel Corporation.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# ... | mit | f564a8fbe7829221ab2d1900b578118f | 42.72807 | 139 | 0.601605 | 3.991193 | false | false | false | false |
intel/intel-iot-refkit | meta-refkit-extra/recipes-multimedia/btspeaker/files/btspeaker.py | 6 | 7402 | #!/usr/bin/python3
import os
import sys
import dbus
import dbus.service
import dbus.mainloop.glib
import time
import threading
import wave
import alsaaudio
import evdev
from evdev import ecodes
from select import select
try:
from gi.repository import GObject
except ImportError:
import gobject as GObject
# Class to... | mit | 6771469c9e00d417f385b3b420c61314 | 31.60793 | 108 | 0.601324 | 3.677099 | false | false | false | false |
intel/intel-iot-refkit | meta-iotqa/lib/oeqa/runtime/connectivity/services/managerdaemon.py | 6 | 1105 | import string
from oeqa.oetest import oeRuntimeTest
class CommDaemonTest(oeRuntimeTest):
"""
@class CommDaemonTest
"""
log = ""
def target_collect_info(self, cmd):
"""
@fn target_collect_info
@param self
@param cmd
@return
"""
(status, output... | mit | 3b760459576e441f05a61ce6d26074fa | 27.333333 | 75 | 0.551131 | 3.890845 | false | true | false | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.