text stringlengths 6 947k | repo_name stringlengths 5 100 | path stringlengths 4 231 | language stringclasses 1
value | license stringclasses 15
values | size int64 6 947k | score float64 0 0.34 |
|---|---|---|---|---|---|---|
# Copyright 2012 Nebula, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agree... | ChameleonCloud/horizon | horizon/tables/__init__.py | Python | apache-2.0 | 1,788 | 0 |
#!/usr/bin/env python
try:
from setuptools import setup
except:
from distutils.core import setup
setup(name='natural',
version='0.2.0',
description='Convert data to their natural (human-readable) format',
long_description='''
Example Usage
=============
Basic usage::
>>> from natural.file im... | tehmaze/natural | setup.py | Python | mit | 1,143 | 0.011374 |
import asyncio
import discord
from discord.ext import commands
def setup(bot):
# Disabled for now
return
# Add the bot and deps
settings = bot.get_cog("Settings")
bot.add_cog(Monitor(bot, settings))
# This is the Monitor module. It keeps track of how many messages fail
class Monitor(commands.Cog)... | corpnewt/CorpBot.py | Cogs/Monitor.py | Python | mit | 2,040 | 0.036275 |
##############################################################################
# Parte do livro Introdução à Programação com Python
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2014
# Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8
# Primeira reimpressão - Outubro/2011
# Segunda reimpressão - ... | laenderoliveira/exerclivropy | exercicios_resolvidos/capitulo 05/exercicio-05-17.py | Python | mit | 695 | 0.002941 |
# -*- coding: utf-8 -*-
import scrapy
import logging
from datetime import datetime
try:
from urlparse import urljoin
except ImportError:
from urllib.parse import urljoin
from .delta_helper import DeltaHelper
class BaseSpider(scrapy.Spider):
# need overwrite in subclass
logger = logging.getLogger(__nam... | loggerhead/dianping_crawler | dianping_crawler/spiders/base_spider.py | Python | mit | 1,618 | 0 |
#!/usr/bin/env python
# encoding: utf-8
from random import choice
def random_string(length, random_range):
result = ""
for i in range(length):
result += choice(random_range)
return result
| WangYihang/Webshell-Sniper | core/utils/string_utils/random_string.py | Python | gpl-3.0 | 211 | 0.009479 |
'''
Created on 2015年1月19日
@author: Guan-yu Willie Chen
'''
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.keys import Keys
import time
#browser = webdriver.Firefox()
#browser = webdriver.Ie()
browser = ... | williechen/DailyApp | 18/py201501/sample/sample.py | Python | lgpl-3.0 | 1,423 | 0.015544 |
#!/usr/bin/env python
import os
import shutil
import sys
import ratemyflight
class ProjectException(Exception):
pass
def create_project():
"""
Copies the contents of the project_template directory to a new directory
specified as an argument to the command line.
"""
# Ensure a directory na... | stephenmcd/ratemyflight | ratemyflight/scripts/create_project.py | Python | bsd-2-clause | 1,581 | 0.003163 |
# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright (C) 2013-Today Carlos Eduardo Vercelino - CLVsol
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
#... | MostlyOpen/odoo_addons | myo_survey/__openerp__.py | Python | agpl-3.0 | 1,729 | 0 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import pytest
# pylint: disable=attribute-defined-outside-init
class TestOutput(object):
@pytest.fixture(autouse=True)
def init(self, ssh_audit):
self.Output = ssh_audit.Output
self.OutputBuffer = ssh_audit.OutputBuffer
def t... | arthepsy/ssh-audit | test/test_output.py | Python | mit | 4,631 | 0.038221 |
from __future__ import annotations
from typing import Generic, TypeVar
T = TypeVar("T")
class DisjointSetTreeNode(Generic[T]):
# Disjoint Set Node to store the parent and rank
def __init__(self, data: T) -> None:
self.data = data
self.parent = self
self.rank = 0
class DisjointSetTr... | TheAlgorithms/Python | graphs/minimum_spanning_tree_kruskal2.py | Python | mit | 4,095 | 0.000488 |
#!/usr/bin/env python3
# Copyright (c) 2014-2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the getchaintips RPC.
- introduce a network split
- work on chains of different lengths
- join th... | litecoin-project/litecoin | test/functional/rpc_getchaintips.py | Python | mit | 2,291 | 0.011349 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('webapps', '0008_remove_china_queue'),
]
operations = [
migrations.RemoveField(
model_name='webapp',
... | mozilla/zamboni | mkt/webapps/migrations/0009_remove_webapp_hosted_url.py | Python | bsd-3-clause | 356 | 0 |
import unittest
import transaction
import os
import csv
from pyramid import testing
from thesis.models import DBSession
from sqlalchemy import create_engine
from thesis.models import (
Base,
GriddedMappablePoint,
Layer
)
class TestGriddedMappableItem(unittest.TestCase):
def setUp(self):
s... | robertpyke/PyThesis | thesis/tests/gridded_mappable_point.py | Python | mit | 6,740 | 0.003709 |
#!/usr/bin/env python
"""AFF4 interface implementation.
This contains an AFF4 data model implementation.
"""
import __builtin__
import abc
import StringIO
import time
import zlib
import logging
from grr.lib import access_control
from grr.lib import config_lib
from grr.lib import data_store
from grr.lib import lexe... | MiniSEC/GRR_clone | lib/aff4.py | Python | apache-2.0 | 74,406 | 0.007701 |
# This file is part of the Simulation Manager project for VecNet.
# For copyright and licensing information about this project, see the
# NOTICE.txt and LICENSE.md files in its top-level directory; they are
# available at https://github.com/vecnet/simulation-manager
#
# This Source Code Form is subject to the terms of ... | vecnet/simulation-manager | sim_manager/tests/test_submit_group.py | Python | mpl-2.0 | 7,814 | 0.003583 |
SECRET_KEY = "foo" | flosch/simpleapi | tests/settings.py | Python | mit | 18 | 0.055556 |
from subprocess import check_call
import logging
import datetime
def setup(name):
formatter = logging.Formatter(fmt='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(name)
logger.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(fo... | OSMNames/OSMNames | osmnames/logger.py | Python | gpl-2.0 | 788 | 0.001269 |
#
# CvHelp.py -- help classes for the Cv drawing
#
# This is open-source software licensed under a BSD license.
# Please see the file LICENSE.txt for details.
import math
import numpy
import cv2
from ginga import colors
class Pen(object):
def __init__(self, color='black', linewidth=1, alpha=1.0):
self.c... | stscieisenhamer/ginga | ginga/cvw/CvHelp.py | Python | bsd-3-clause | 4,985 | 0.002207 |
__all__ = (
'Net',
)
import builtins
import collections
import itertools
from .errors import InternalError, NodeError
from .marking import Marking
from .net_element import NamedNetElement
from .node import Node
from .place import Place
from .transition import Transition
class Net(NamedNetElement):
__dict_f... | simone-campagna/petra | petra/net.py | Python | apache-2.0 | 7,080 | 0.00339 |
"""
We are playing the Guess Game. The game is as follows:
I pick a number from 1 to n. You have to guess which number I picked.
Every time you guess wrong, I'll tell you whether the number I picked is higher or lower.
However, when you guess a particular number x, and you guess wrong, you pay $x. You win the game w... | dichen001/Go4Jobs | JackChen/minimax/375. Guess Number Higher or Lower II.py | Python | gpl-3.0 | 1,292 | 0.004651 |
from __future__ import (absolute_import, division, print_function)
import mantid.simpleapi as mantid
from isis_powder.routines import common, instrument_settings
from isis_powder.abstract_inst import AbstractInst
from isis_powder.pearl_routines import pearl_advanced_config, pearl_algs, pearl_calibration_algs, pearl_o... | ScreamingUdder/mantid | scripts/Diffraction/isis_powder/pearl.py | Python | gpl-3.0 | 9,681 | 0.005991 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# compute/__init__.py
"""
See |compute.subsystem|, |compute.network|, |compute.distance|, and
|compute.parallel| for documentation.
Attributes:
all_complexes: Alias for :func:`pyphi.compute.network.all_complexes`.
ces: Alias for :func:`pyphi.compute.subsystem.ces... | wmayner/pyphi | pyphi/compute/__init__.py | Python | gpl-3.0 | 1,545 | 0 |
# GPL, (c) Reinout van Rees
#
# Script to show the diff with the last relevant tag.
import logging
import sys
import zest.releaser.choose
from zest.releaser.utils import system
from zest.releaser import utils
logger = logging.getLogger(__name__)
def main():
logging.basicConfig(level=utils.loglevel(),
... | mgedmin/zest.releaser | zest/releaser/lasttagdiff.py | Python | gpl-2.0 | 903 | 0 |
import copy
import sys
import random
import itertools
def rotate_matrix(A):
for i in range(len(A) // 2):
for j in range(i, len(A) - i - 1):
temp = A[i][j]
A[i][j] = A[-1 - j][i]
A[-1 - j][i] = A[-1 - i][-1 - j]
A[-1 - i][-1 - j] = A[j][-1 - i]
A[... | meisamhe/GPLshared | Programming/MPI — AMath 483 583, Spring 2013 1.0 documentation_files/matrix_rotation_constant.py | Python | gpl-3.0 | 1,490 | 0 |
# -*- coding: utf-8 -*-
# Copyright 2020 Green Valley Belgium NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | our-city-app/oca-backend | src/solutions/common/to/pharmacy/order.py | Python | apache-2.0 | 1,626 | 0 |
#
#
# Copyright (C) 2004 Philip J Freeman
#
# This file is part of halo_radio
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at... | ph1l/halo_radio | HaloRadio/PlaylistListMaker.py | Python | gpl-2.0 | 1,038 | 0.012524 |
from nose.tools import ok_
def fail(msg):
raise AssertionError(msg)
def assert_in(thing, seq, msg=None):
msg = msg or "'%s' not found in %s" % (thing, seq)
ok_(thing in seq, msg)
def assert_not_in(thing, seq, msg=None):
msg = msg or "unexpected '%s' found in %s" % (thing, seq)
ok_(thing not in... | rcbops/python-novaclient-buildpackage | tests/v1_1/utils.py | Python | apache-2.0 | 814 | 0 |
import pytest
# TODO: re-enable
# from app import render
# from app.models import SourceLine
class AttrDict(dict):
__getattr__ = dict.__getitem__
# http://stackoverflow.com/a/11924754/143880
def is_subset(d1, obj):
d2 = vars(obj)
return set(d1.items()).issubset(set(d2.items()))
@pytest.mark.skip("OLD... | johntellsall/shotglass | shotglass/app/tests/test_render.py | Python | mit | 881 | 0 |
#!/usr/bin/env python
#-.- encoding: utf-8 -.-
import csv,re
#medlemsfil = 'medlemmer_20032014.csv'
#medlemsfil = 'Medlemsliste 08.03.2015.csv'
medlemsfil = 'Medlemsliste 03.09.2015.csv'
def parse():
f = open(medlemsfil)
r = csv.reader(f)
index = 0
headings = None
members = None
category = None
for row in r:
... | bringsvor/bc_korps | utils/parse_members.py | Python | agpl-3.0 | 2,410 | 0.048608 |
"""
Instructions:
1) Set up testing/config.py (copy from config.py.example and fill in the fields)
2) Run this script
3) Look inside your GCP_BUCKET under test_doodad and you should see results in secret.txt
"""
import os
import doodad
from doodad.utils import TESTING_DIR
from testing.config import GCP_PROJECT, GCP_BU... | justinjfu/doodad | testing/remote/test_gcp.py | Python | gpl-3.0 | 1,085 | 0.003687 |
from django.conf.urls import include, url
from django.contrib import admin
from django.core.urlresolvers import reverse_lazy
from django.views.generic import RedirectView
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^', include('products.urls', namespace='products')),
url(r'^', include(... | vechnoe/products | src/urls.py | Python | mit | 476 | 0 |
#-*- coding: utf-8 -*-
"""
Certificates Tests.
"""
import itertools
import json
import ddt
import mock
import six
from django.conf import settings
from django.test.utils import override_settings
from opaque_keys.edx.keys import AssetKey
from six.moves import range
from cms.djangoapps.contentstore.tests.utils impor... | stvstnfrd/edx-platform | cms/djangoapps/contentstore/views/tests/test_certificates.py | Python | agpl-3.0 | 31,931 | 0.001848 |
#!/usr/bin/env python
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: t -*-
#
# NetProfile: Access module - Models
# © Copyright 2013-2015 Alex 'Unik' Unigovsky
#
# This file is part of NetProfile.
# NetProfile is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General P... | nikitos/npui | netprofile_access/netprofile_access/models.py | Python | agpl-3.0 | 23,665 | 0.046146 |
from datetime import date
class YearInfo(object):
def __init__(self, year, months_ok, months_na):
self.year = year
self.months = set(range(1, 13))
self.months_ok = set(months_ok)
self.months_na = set(months_na)
self.months_er = self.months - (self.months_ok | self.months_na)... | hackerspace/memberportal | payments/common.py | Python | gpl-2.0 | 1,647 | 0.004857 |
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "DiscreteDistributions.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
| viktorki/Discrete-Distributions | manage.py | Python | gpl-3.0 | 264 | 0.003788 |
# -*- coding: utf-8 -*-
import abc
import tensorflow as tf
from inferbeddings.models import embeddings
import sys
class BaseModel(metaclass=abc.ABCMeta):
def __init__(self, entity_embeddings=None, predicate_embeddings=None, similarity_function=None,
reuse_variables=False, *args, **kwargs):
... | uclmr/inferbeddings | inferbeddings/models/base.py | Python | mit | 7,187 | 0.005148 |
# $HeadURL$
import sys
def test_import():
""" Test to make sure the project imports OK.
"""
import pp.testing
def test_app():
""" Test the command-line app runs OK.
"""
from pp.testing.scripts import app
sys.argv = []
app.main()
if __name__ == '__main__':
# Run this tet file th... | pythonpro-dev/pp-testing | tests/unit/test_sample.py | Python | bsd-3-clause | 415 | 0 |
import math
import torch
from .optimizer import Optimizer
class SparseAdam(Optimizer):
r"""Implements lazy version of Adam algorithm suitable for sparse tensors.
In this variant, only moments that show up in the gradient get updated, and
only those portions of the gradient get applied to the parameters.
... | ryfeus/lambda-packs | pytorch/source/torch/optim/sparse_adam.py | Python | mit | 4,595 | 0.001741 |
import EoN
import networkx as nx
import matplotlib.pyplot as plt
import scipy
import random
print(r"Warning, book says \tau=2\gamma/<K>, but it's really 1.5\gamma/<K>")
print(r"Warning - for the power law graph the text says k_{max}=110, but I believe it is 118.")
N=1000
gamma = 1.
iterations = 200
rho = 0.05
tmax = ... | springer-math/Mathematics-of-Epidemics-on-Networks | docs/examples/fig4p11.py | Python | mit | 2,565 | 0.015595 |
# coding: utf8
# OeQ autogenerated lookup function for 'Window/Wall Ratio East in correlation to year of construction, based on the source data of the survey for the "German Building Typology developed by the "Institut für Wohnen und Umwelt", Darmstadt/Germany, 2011-2013'
import math
import numpy as np
import oeqLooku... | UdK-VPT/Open_eQuarter | mole/stat_corr/window_wall_ratio_east_SDH_by_building_age_lookup.py | Python | gpl-2.0 | 1,995 | 0.175527 |
# coding=utf-8
# Copyright 2022 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | google-research/google-research | f_net/models_test.py | Python | apache-2.0 | 13,843 | 0.00354 |
# import ipdb; ipdb.set_trace()
from .posts import PostAPIHandler, PostCategoriesAPIHandler
from .tweets import TweetsAPIHandler
| Laisky/laisky-blog | gargantua/apis/__init__.py | Python | apache-2.0 | 130 | 0 |
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | kubeflow/kfp-tekton-backend | sdk/python/kfp/notebook/__init__.py | Python | apache-2.0 | 598 | 0 |
#!/usr/bin/env python
#to create a file in codesnippets folder
import pyperclip
import os
import re
import subprocess
def get_extension(file_name):
if file_name.find('.')!=-1:
ext = file_name.split('.')
return (ext[1])
else:
return 'txt'
def cut(str, len1):
return str[len1 + ... | nikhilponnuru/codeCrumbs | code/create_file.py | Python | mit | 4,006 | 0.01972 |
# encoding: utf8
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = []
operations = [
migrations.CreateModel(
fields = [(u'id', models.AutoField(verbose_name=u'ID', serialize=False, auto_created=True, primary_key=True),), ('name', models.Ch... | Nimmard/james-olson.com | main/migrations/0001_initial.py | Python | gpl-2.0 | 1,003 | 0.018943 |
from django.db.backends import BaseDatabaseIntrospection
import pyodbc as Database
import types
import datetime
import decimal
class DatabaseIntrospection(BaseDatabaseIntrospection):
# Map type codes to Django Field types.
data_types_reverse = {
types.StringType: 'TextField',
type... | msabramo/django-netezza | netezza/pyodbc/introspection.py | Python | bsd-3-clause | 4,001 | 0.002999 |
# coding: utf-8
from __future__ import unicode_literals, absolute_import
from ..exception import TigrisException
import urllib.parse
class Permission(object):
""" Tigris Permission object """
BASE_ENDPOINT = 'permissions'
def __init__(self, permission_obj, session):
"""
:param permissi... | jogral/tigris-python-sdk | tigrissdk/auth/permission.py | Python | apache-2.0 | 3,756 | 0 |
import json
from json_url_rewriter import config
from json_url_rewriter.rewrite import URLRewriter
class HeaderToPathPrefixRewriter(object):
"""
A rewriter to take the value of a header and prefix any path.
"""
def __init__(self, keys, base, header_name):
self.keys = keys
self.base =... | ionrock/json_url_rewriter | json_url_rewriter/middleware.py | Python | bsd-3-clause | 2,398 | 0.000417 |
#!/usr/bin/env python
from __future__ import print_function
with open("../File_example.txt") as file_in:
for line in file_in:
print(line.strip())
print('#' * 40)
file_to_write = open("../File_example.txt", "wt")
print(file_to_write)
file_to_write.write("Line one\nLine two\nLine three\n")
file_to_write.f... | Sergiy-DBX/pynet_test- | Files/Ex_1.py | Python | unlicense | 661 | 0 |
# Copyright 2015, 2018 IBM Corp.
#
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless require... | powervm/pypowervm | pypowervm/tests/utils/test_uuid.py | Python | apache-2.0 | 2,049 | 0 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-08-28 15:17
from __future__ import unicode_literals
import DjangoUeditor.models
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('blogadmin', '0006_auto_20170827_1142'),
]
operations = ... | baike21/blog | blogadmin/migrations/0007_auto_20170828_2317.py | Python | gpl-3.0 | 3,940 | 0.005076 |
"""SCons.Tool.pdf
Common PDF Builder definition for various other Tool modules that use it.
Add an explicit action to run epstopdf to convert .eps files to .pdf
"""
#
# Copyright (c) 2001 - 2015 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software a... | stefanklug/mapnik | scons/scons-local-2.3.6/SCons/Tool/pdf.py | Python | lgpl-2.1 | 3,010 | 0.007641 |
# pylint: disable=redefined-outer-name, missing-docstring
import sys
import pytest
sys.path.append('..')
from batchflow import Config
@pytest.fixture
def config():
_config = dict(key1='val1', key2=dict())
_config['key2']['subkey1'] = 'val21'
return Config(_config)
class TestConfig:
def test_getitem... | analysiscenter/dataset | batchflow/tests/config_test.py | Python | apache-2.0 | 2,864 | 0.000349 |
# Copyright Vertex.AI
import ctypes
import json
class Context(object):
def __init__(self, lib):
self._as_parameter_ = lib.vai_alloc_ctx()
if not self._as_parameter_:
raise MemoryError('PlaidML operation context')
self._free = lib.vai_free_ctx
self._cancel = lib.vai_ca... | flaub/plaidml | plaidml/context.py | Python | agpl-3.0 | 865 | 0 |
import pytest # noqa
import python_jsonschema_objects as pjo
def test_regression_156(markdown_examples):
builder = pjo.ObjectBuilder(
markdown_examples["MultipleObjects"], resolved=markdown_examples
)
classes = builder.build_classes(named_only=True)
er = classes.ErrorResponse(message="Danger... | cwacek/python-jsonschema-objects | test/test_regression_156.py | Python | mit | 1,032 | 0 |
"""
Gnome keyring parser.
Sources:
- Gnome Keyring source code,
function generate_file() in keyrings/gkr-keyring.c,
Author: Victor Stinner
Creation date: 2008-04-09
"""
from hachoir_core.tools import paddingSize
from hachoir_parser import Parser
from hachoir_core.field import (FieldSet,
Bit, NullBits, NullBy... | kreatorkodi/repository.torrentbr | plugin.video.yatp/site-packages/hachoir_parser/misc/gnome_keyring.py | Python | gpl-2.0 | 6,255 | 0.003357 |
"""Basic contact management functions.
Contacts are linked to monitors and are used to determine where to send
alerts for monitors.
Contacts are basic name/email/phone sets.
Contacts are only stored in the database and not in memory, they are loaded
from the database each time an alert is sent.
"""
from typing impo... | beebyte/irisett | irisett/contact.py | Python | mit | 17,565 | 0.003985 |
# -*- coding: utf-8 -*-
# Mathmaker creates automatically maths exercises sheets
# with their answers
# Copyright 2006-2017 Nicolas Hainaux <nh.techn@gmail.com>
# This file is part of Mathmaker.
# Mathmaker is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License... | nicolashainaux/mathmaker | mathmaker/lib/old_style_sheet/AlgebraMiniTest0.py | Python | gpl-3.0 | 2,680 | 0 |
# ECB wrapper skeleton file for 50.020 Security
# Oka, SUTD, 2014
from present import *
import argparse
nokeybits=80
blocksize=64
def ecb(infile,outfile,keyfile,mode):
key = 0x0
with open(keyfile, 'rb') as fkey:
for i in range(nokeybits / 8):
key |= ord(fkey.read(1)) << i * 8
with ope... | LYZhelloworld/Courses | 50.020/08/ecb.py | Python | mit | 1,521 | 0.011834 |
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Tests for large portions of L{twisted.mail}.
"""
import os
import errno
import shutil
import pickle
import StringIO
import email.message
import email.parser
import tempfile
import signal
import time
from hashlib import md5
from zope.interfac... | EricMuller/mynotes-backend | requirements/twisted/Twisted-17.1.0/src/twisted/mail/test/test_mail.py | Python | mit | 84,944 | 0.00292 |
from datetime import timedelta
from django.contrib.auth.models import User
from django.core.management.base import BaseCommand
from django.db.models import Count, F
from django.utils.timezone import now
from hc.accounts.models import Profile
class Command(BaseCommand):
help = """Prune old, inactive user accounts... | healthchecks/healthchecks | hc/accounts/management/commands/pruneusers.py | Python | bsd-3-clause | 1,501 | 0 |
#!/usr/bin/python
import Proxy_Hours, proxyhours_gather_all_data
try:
from PyQt4 import QtCore, QtGui
qtplatform = "PyQt4"
except:
from PySide import QtCore, QtGui
qtplatform = "PySide"
import os
def which(pgm):
path=os.getenv('PATH')
for p in path.split(os.path.pathsep):
p=os.path.jo... | timlev/Proxy-Hours | main.py | Python | mit | 1,572 | 0.022901 |
# -*- coding: utf-8 -*-
#
# Copyright 2018 Vote inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | riga/luigi | test/config_toml_test.py | Python | apache-2.0 | 3,012 | 0 |
# coding: utf8
# qtplayer.py
# 10/1/2014 jichi
__all__ = 'HiddenPlayer',
from PySide.QtCore import QUrl
from sakurakit.skdebug import dprint
class _HiddenPlayer:
def __init__(self, parent):
self.parent = parent # QWidget
self._webView = None # QWebView
@property
def webView(self):
if not self._web... | Dangetsu/vnr | Frameworks/Sakura/py/libs/qtbrowser/qtplayer.py | Python | gpl-3.0 | 2,795 | 0.025045 |
import json
from collections import abc
# item 26: use muptiple inheritance for mixin only
# a mixin that transforms a python object to a dictionary that's ready for seralization
class ToDictMixin(object):
def to_dict(self):
"""Return a dictionary representation of this object"""
return self._traver... | totoro72/pt1 | ep/item_26_multiple_inheritance_for_mixin_only.py | Python | mit | 2,705 | 0.001479 |
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated
from edctf.api.models import challengeboard, category, challenge
from edctf.api.serializers import challengeboard_serializer, category_serializer, challenge_serializer
class cha... | IAryan/edCTF | edctf/api/views/challengeboard.py | Python | apache-2.0 | 2,095 | 0.012411 |
"""
WSGI config for Incubator project.
This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`... | gmartinvela/Incubator | Incubator/wsgi.py | Python | mit | 1,428 | 0.0007 |
#!/usr/bin/env python
#
# Copyright 2015, Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can
# be found in the LICENSE file.
import unittest
import environment
import utils
import tablet
# shards
shard_0_master = tablet.Tablet()
shard_0_rdonly = tablet.Tablet()
sh... | cgvarela/vitess | test/custom_sharding.py | Python | bsd-3-clause | 7,223 | 0.005399 |
#!/bin/python
import sys
from decimal import Decimal, getcontext,Context
from math import pi as PI
pi = Context(prec=60).create_decimal('3.1415926535897932384626433832795028841971693993751')
PI = pi
def calc(fun, n):
temp = Decimal("0.0")
for ni in xrange(n+1, 0, -1):
(a, b) = fun(ni)
temp =... | opethe1st/CompetitiveProgramming | Hackerrank/WeekOfCode/WoC29/minimalbruteforce.py | Python | gpl-3.0 | 1,231 | 0.028432 |
from django.db.backends import BaseDatabaseClient
from django.conf import settings
import os
class DatabaseClient(BaseDatabaseClient):
executable_name = 'sqlite3'
def runshell(self):
args = ['', settings.DATABASE_NAME]
os.execvp(self.executable_name, args)
| marcydoty/geraldo | site/newsite/site-geraldo/django/db/backends/sqlite3/client.py | Python | lgpl-3.0 | 283 | 0.003534 |
# Stellar Magnate - A space-themed commodity trading game
# Copyright (C) 2017 Toshio Kuratomi <toshio@fedoraproject.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version ... | abadger/stellarmagnate | magnate/ui/urwid/numbers.py | Python | agpl-3.0 | 1,371 | 0.001459 |
from baseplate.events import FieldKind
from pylons import app_globals as g
from r2.lib.eventcollector import (
EventQueue,
Event,
squelch_exceptions,
)
from r2.lib.utils import sampled
from r2.models import (
FakeSubreddit,
)
class AdEvent(Event):
@classmethod
def get_context_data(cls, reques... | madbook/reddit-plugin-adzerk | reddit_adzerk/lib/events.py | Python | bsd-3-clause | 7,482 | 0.000668 |
import inspect
import os.path
import django
import SocketServer
import sys
from django.conf import settings
from django.views.debug import linebreak_iter
# Figure out some paths
django_path = os.path.realpath(os.path.dirname(django.__file__))
socketserver_path = os.path.realpath(os.path.dirname(SocketServer.__file__)... | viswimmer1/PythonGenerator | data/python_files/30552411/__init__.py | Python | gpl-2.0 | 4,785 | 0.002508 |
import env
import numpy as np
import metaomr
import metaomr.kanungo as kan
from metaomr.page import Page
import glob
import pandas as pd
import itertools
import os.path
import sys
from datetime import datetime
from random import random, randint
IDEAL = [path for path in sorted(glob.glob('testset/modern/*.png'))
... | ringw/MetaOMR | metaomr_tests/eval_kanungo_est.py | Python | gpl-3.0 | 1,954 | 0.005629 |
#!/bin/env/python
#
# This file is part of CRISIS, an economics simulator.
#
# Copyright (C) 2015 John Kieran Phillips
#
# CRISIS is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License... | crisis-economics/CRISIS | CRISIS/test/eu/crisis_economics/abm/household/market.py | Python | gpl-3.0 | 1,926 | 0.021807 |
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | datacommonsorg/data | scripts/eurostat/regional_statistics_by_nuts/population_density/csv_template_mcf_compatibility_checker.py | Python | apache-2.0 | 976 | 0 |
"""
A script to automate installation of tool repositories from a Galaxy Tool Shed
into an instance of Galaxy.
Galaxy instance details and the installed tools can be provided in one of three
ways:
1. In the YAML format via dedicated files (see ``tool_list.yaml.sample`` for a
sample of such a file)
2. On the command... | C3BI-pasteur-fr/Galaxy-playbook | galaxy-pasteur/roles/galaxy_tools/files/install_tool_shed_tools.py | Python | gpl-2.0 | 28,649 | 0.001571 |
import numpy as np
import torch
import time
from torch.autograd import Variable
'''
fast beam search
'''
def repackage_hidden(h):
"""Wraps hidden states in new Variables, to detach them from their history."""
if type(h) == Variable:
return Variable(h.data)
else:
return tuple(repackage_hidden... | tshi04/machine-learning-codes | deliberation_network/utils.py | Python | gpl-3.0 | 9,232 | 0.005199 |
#coding:utf-8
"""
"""
class Task(object):
def __init__(self, id_, project_name, title, serial_no, timelimit, timestamp, note, status):
self.id_ = id_
self.project_name = project_name
self.title = title
self.serial_no = serial_no
self.timelimit = timelimit
self.timesta... | dev1x-org/python-example | lib/model/task.py | Python | mit | 1,058 | 0.006616 |
#-*- coding:utf-8 -*-
import wx
if evt_handler == None:
evt_handler = wx.EvtHandler() | hookehu/utility | editors/studio/core/logic_center.py | Python | gpl-2.0 | 88 | 0.056818 |
#!/usr/bin/env python
import traceback
import binascii
import sys
if __name__ == "__main__":
if len(sys.argv) < 2:
sys.stderr.write("Usage: %s <licenseForCustomerToken file>\n"
% sys.argv[0])
sys.exit(-1)
try:
data = open(sys.argv[1], "rb").read()
if ... | kidburglar/audible-activator | unused/extract-activation-bytes.py | Python | gpl-3.0 | 1,379 | 0.00145 |
import click
from bitshares.amount import Amount
from .decorators import online, unlock
from .main import main, config
from .ui import print_tx
@main.group()
def htlc():
pass
@htlc.command()
@click.argument("to")
@click.argument("amount")
@click.argument("symbol")
@click.option(
"--type", type=click.Choice(... | xeroc/uptick | uptick/htlc.py | Python | mit | 3,974 | 0.001761 |
# Copyright (c) 2014, Sven Thiele <sthiele78@gmail.com>
#
# This file is part of shogen.
#
# shogen is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option)... | bioasp/shogen | setup.py | Python | gpl-3.0 | 1,416 | 0.029661 |
team_mapping = {
"SY": "Sydney",
"WB": "Western Bulldogs",
"WC": "West Coast",
"HW": "Hawthorn",
"GE": "Geelong",
"FR": "Fremantle",
"RI": "Richmond",
"CW": "Collingwood",
"CA": "Carlton",
"GW": "Greater Western Sydney",
"AD": "Adelaide",
"GC": "Gold Coast",
"ES": "Es... | bairdj/beveridge | src/scrapy/afltables/afltables/common.py | Python | mit | 1,563 | 0.007678 |
# Copyright (c) 2011 Tencent Inc.
# All rights reserved.
#
# Author: Michaelpeng <michaelpeng@tencent.com>
# Date: January 09, 2012
"""
This is the configuration parse module which parses
the BLADE_ROOT as a configuration file.
"""
import os
import sys
import console
from blade_util import var_to_list
from cc_t... | project-zerus/blade | src/blade/configparse.py | Python | bsd-3-clause | 11,273 | 0.003193 |
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU... | gmathers/iii-addons | mrp_custom/__openerp__.py | Python | agpl-3.0 | 1,656 | 0.004227 |
"""AFOS Database Workflow."""
# 3rd Party
from twisted.internet import reactor
from txyam.client import YamClient
from pyiem.util import LOG
from pyiem.nws import product
# Local
from pywwa import common
from pywwa.ldm import bridge
from pywwa.database import get_database
DBPOOL = get_database("afos", cp_max=5)
MEMCA... | akrherz/pyWWA | parsers/pywwa/workflows/afos_dump.py | Python | mit | 2,891 | 0 |
"""
sentry.models.file
~~~~~~~~~~~~~~~~~~
:copyright: (c) 2010-2015 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""
from __future__ import absolute_import
from django.conf import settings
from django.core.files.storage import get_storage_class
from django.db import ... | camilonova/sentry | src/sentry/models/file.py | Python | bsd-3-clause | 3,050 | 0.000328 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#... | bcoca/ansible-modules-extras | database/misc/redis.py | Python | gpl-3.0 | 10,653 | 0.00169 |
"""
Django settings for central_service project.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR,... | Antikythera/hoot | Application/central_service/settings.py | Python | gpl-2.0 | 3,154 | 0 |
"""
Observe the effect in the perturbations of Laplacians
"""
import sys
import logging
import numpy
import scipy
import itertools
import copy
import matplotlib.pyplot as plt
from apgl.graph import *
from sandbox.util.PathDefaults import PathDefaults
from sandbox.misc.IterativeSpectralClustering import IterativeS... | charanpald/wallhack | wallhack/clusterexp/LaplacianExp.py | Python | gpl-3.0 | 2,822 | 0.013466 |
# encoding: utf-8
"""
Place holder for all workers
"""
from .integration_tester import IntegrationTestWorker
from .db_writer import DatabaseWriterWorker
from .deploy import BeforeDeploy, Deploy, Restart, GithubDeploy | adsabs/ADSDeploy | ADSDeploy/pipeline/workers.py | Python | gpl-3.0 | 216 | 0.00463 |
import numpy as np
import math
import sys
import os
sys.path.insert(0,os.environ['learningml']+'/GoF/')
import classifier_eval
from classifier_eval import name_to_nclf, nclf, experiment, make_keras_model
from sklearn import tree
from sklearn.ensemble import AdaBoostClassifier
from sklearn.svm import SVC
from rep.estim... | weissercn/learningml | learningml/GoF/optimisation_and_evaluation/automatisation_gaussian_same_projection/automatisation_Gaussian_same_projection_optimisation_and_evaluation_euclidean.py | Python | mit | 3,583 | 0.017304 |
# zFCP configuration dialog
#
# Copyright (C) 2013 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed... | wgwoods/anaconda | pyanaconda/ui/gui/spokes/advstorage/zfcp.py | Python | gpl-2.0 | 6,251 | 0.0016 |
from unittest import TestCase
import re
from iperflexer import oatbran
bran = oatbran
COW = 'cow'
class TestOatBran(TestCase):
def test_brackets(self):
L_BRACKET = '['
R_BRACKET = "]"
self.assertRegexpMatches(L_BRACKET, bran.L_BRACKET)
self.assertNotRegexpMatches(R_BRACKET, bran.L... | rsnakamura/iperflexer | tests/testoatbran.py | Python | mit | 4,746 | 0.001896 |
# coding: utf-8
# © simpleApps, 2014 — 2016.
__authors__ = ("Al Korgun <alkorgun@gmail.com>", "John Smith <mrdoctorwho@gmail.com>")
__version__ = "2.3"
__license__ = "MIT"
"""
Implements a single-threaded longpoll client
"""
import select
import socket
import json
import httplib
import threading
import time
import v... | mrDoctorWho/vk4xmpp | library/longpoll.py | Python | mit | 10,264 | 0.029529 |
import pytest
@pytest.mark.usefixtures('tmpdir')
@pytest.mark.filecopy('test.torrent', '__tmp__/')
class TestContentFilter:
config = """
tasks:
test_reject1:
mock:
- {title: 'test', file: '__tmp__/test.torrent'}
accept_all: yes
content_filter:
... | ianstalk/Flexget | flexget/tests/test_content_filter.py | Python | mit | 3,857 | 0.001296 |
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
import os
import unittest
from manifestparser import ManifestParser
here = os.path.dirname(os.pa... | vladikoff/fxa-mochitest | tests/mozbase/manifestparser/tests/test_default_skipif.py | Python | mpl-2.0 | 1,518 | 0.006588 |
import numpy
from chainer.backends import cuda
from chainer import function_node
from chainer.utils import type_check
def _pair(x):
if hasattr(x, '__getitem__'):
return x
return x, x
class Shift(function_node.FunctionNode):
def __init__(self, ksize=3, dilate=1):
super(Shift, self).__in... | anaruse/chainer | chainer/functions/connection/shift.py | Python | mit | 4,492 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.