code stringlengths 3 1.05M | repo_name stringlengths 5 104 | path stringlengths 4 251 | language stringclasses 1
value | license stringclasses 15
values | size int64 3 1.05M |
|---|---|---|---|---|---|
import time
import scipypy
start = time.time()
a = 0.0
for i in xrange(1, 1000000, 1):
f = i / 100.0
a += scipypy.psi(f) / float(i + 1) * i
end = time.time()
print '%s: took %s seconds' % (a, end - start)
start = time.time()
i = 0.01
while i < 10000:
scipypy.psi(i)
i += 0.01
end = time.time()
pri... | jperla/happynews | model/scipypy/speed_pypy.py | Python | agpl-3.0 | 867 |
"""Test."""
import pytest
TM_TABLE = [
([0, 1, 1, 0, 1], True),
([0], True),
([1], False),
([0, 1, 0, 0], False),
]
@pytest.mark.parametrize("n, result", TM_TABLE)
def test_is_thue_morse(n, result):
"""Test."""
from is_thue_morse import is_thue_morse
assert is_thue_morse(n) == result
| rrustia/code-katas | src/test_is_thue_morse.py | Python | mit | 318 |
#!/usr/bin/env python
# coding: utf-8
#[(1, 5), (1, 3, 4), (3, 6), (9, ), (-1, 0), (10, 1, 3)] 按每个tuple的最大值进行比较排序
list_1 = [(1, 5), (1, 3, 4), (3, 6), (9, ), (-1, 0), (10, 1, 3)]
print sorted(list_1,key = lambda x:max(x))
print sorted(list_1,key = lambda x:min(x))
| 51reboot/actual_13_homework | 04/leon/1.py | Python | mit | 294 |
# This file is part of Scapy
# See http://www.secdev.org/projects/scapy for more information
# Copyright (C) Philippe Biondi <phil@secdev.org>
# This program is published under a GPLv2 license
"""
All layers. Configurable with conf.load_layers.
"""
from __future__ import absolute_import
from scapy.config import conf
... | mtury/scapy | scapy/layers/all.py | Python | gpl-2.0 | 825 |
# This file is part of Buildbot. Buildbot 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, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without eve... | seankelly/buildbot | master/buildbot/steps/worker.py | Python | gpl-2.0 | 12,102 |
# -*- coding: utf-8 -*-
##############################################################################
#
# Adapted by Nicolas Bessi. Copyright Camptocamp SA
# Based on Florent Xicluna original code. Copyright Wingo SA
#
# This program is free software: you can redistribute it and/or modify
# it under the te... | hbrunn/server-tools | __unported__/server_environment/system_info.py | Python | agpl-3.0 | 2,161 |
# to load adapter configs
from . import actions # noqa
from . import schema # noqa
| plone/plone.server | src/plone.server/plone/server/framing/__init__.py | Python | bsd-2-clause | 85 |
# coding: utf-8
from .base import Service
| osantana/servicy | servicy/__init__.py | Python | isc | 44 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2013, Patrik Lundin <patrik@sigterm.se>
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
... | DazWorrall/ansible | lib/ansible/modules/packaging/os/openbsd_pkg.py | Python | gpl-3.0 | 26,447 |
#!/usr/bin/env python
from setuptools import setup
import os
package_name = "ROPGadget"
package_dir = "ropgadget"
package_description = """
This tool lets you search your gadgets on your binaries to facilitate your ROP exploitation.
ROPgadget supports ELF, PE and Mach-O format on x86, x64, ARM, ARM64, P... | bl4ckic3/ROPgadget | setup.py | Python | gpl-2.0 | 2,198 |
hdata = hdata.crop(*hdata.span.contract(1))
hfilt = hfilt.crop(*hfilt.span.contract(1)) | gwpy/gwpy.github.io | docs/latest/examples/signal/gw150914-6.py | Python | gpl-3.0 | 87 |
# models.card
# -*- coding: UTF-8 -*-
from operator import itemgetter, attrgetter
from wand.image import Image
from config import DEVELOP_MODE
from datetime import datetime, timedelta
from libs import doubandb, doubanfs, Employee, doubanmc, store, User
from webapp.models.consts import *
from webapp.models.notify impor... | liangsun/me | webapp/models/card.py | Python | mit | 28,108 |
# Copyright 2014 Google Inc. 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 required by applicable law or ag... | flgiordano/netcash | +/google-cloud-sdk/lib/surface/bigquery/__init__.py | Python | bsd-3-clause | 2,500 |
#!/usr/bin/python
'''
Extract _("...") strings for translation and convert to Qt4 stringdefs so that
they can be picked up by Qt linguist.
'''
from subprocess import Popen, PIPE
import glob
import operator
import os
OUT_CPP="src/qt/bitcoinstrings.cpp"
EMPTY=['""']
def parse_po(text):
"""
Parse 'po' format pro... | credits-currency/credits | share/qt/extract_strings_qt.py | Python | mit | 1,902 |
from flask_script import Command, Option
from openedoo import app
class GunicornServer(Command):
help = "Start the Server with Gunicorn"
option_list = (
Option('-h', '--host', dest='host', default='127.0.0.1'),
Option('-p', '--port', dest='port', type=int, default=5000),
Option('-w', '... | openedoo/openedoo | openedoo/template_conf/project_template/project_name/management/commands/gunicornserver.py | Python | mit | 875 |
import os
import redis
from mock import patch, MagicMock
from ...helpers import assert_raises, assert_equal, assert_not_equal
from tagalog.shipper.redis import RoundRobinConnectionPool,RedisShipper
from tagalog.shipper.shipper_error import ShipperError
class MockConnection(object):
def __init__(self, **kwargs):... | alphagov/tagalog | test/unit/shipper/test_redis.py | Python | mit | 6,620 |
import os
import shutil
import setup
from project_cron.utils import processutil
USER_ROOT = os.path.expanduser('~')
APP_NAME = setup.APP_NAME + '.app'
APP_ROOT = os.path.join('/usr/local/bin', setup.APP_NAME)
DST_PATH = os.path.join(APP_ROOT, '%s-%05X' % (setup.VERSION, setup.BUILD_NUMBER), APP_NAME)
SYMLINK_PATH = o... | ecleya/project_cron | update.py | Python | mit | 1,472 |
# Copyright 2011 OpenStack Foundation
#
# 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 l... | mmasaki/trove | trove/tests/api/root.py | Python | apache-2.0 | 7,830 |
#!/usr/bin/env python
"""
================
sMRI: FreeSurfer
================
This script, smri_freesurfer.py, demonstrates the ability to call reconall on
a set of subjects and then make an average subject.
python smri_freesurfer.py
Import necessary modules from nipype.
"""
import os
import nipype.pipeline.eng... | FredLoney/nipype | examples/smri_freesurfer.py | Python | bsd-3-clause | 1,804 |
from typing import Union
from .common import ScyllaManagerError, TaskStatus, HostStatus, HostSsl, HostRestStatus
from .cli import ScyllaManagerToolRedhatLike, ScyllaManagerToolNonRedhat, ManagerCluster
from .operator import ScyllaManagerToolOperator, OperatorManagerCluster
AnyManagerTool = Union[ScyllaManagerToolOpe... | scylladb/scylla-cluster-tests | sdcm/mgmt/__init__.py | Python | agpl-3.0 | 841 |
'''
deploy virtual router test environment, without reinstall zstack. Will redeploy
database.
@author: Youyk
'''
import os
import zstackwoodpecker.operations.deploy_operations as deploy_operations
import zstackwoodpecker.test_lib as test_lib
import zstackwoodpecker.test_util as test_util
USER_PATH = os.... | zstackio/zstack-woodpecker | integrationtest/vm/vm_password/suite_setup_no_install_zs.py | Python | apache-2.0 | 962 |
#!/usr/bin/env python
'''
Description:
This is the handler for the Social Engineering Toolkit (SET) trying to overcome the limitations of set-automate
'''
from framework.dependency_management.dependency_resolver import BaseComponent
from framework.lib.general import *
import time
SCRIPT_DELAY = 2
class SpearPhishing... | sharad1126/owtf | framework/wrappers/set/spear_phishing.py | Python | bsd-3-clause | 2,650 |
import pandas as pd
from requests import get
from StringIO import StringIO
from pandas.io.common import ZipFile
def get_movielens_data(local_file=None, get_genres=False):
'''Downloads movielens data and stores it in pandas dataframe.
'''
if not local_file:
#print 'Downloading data...'
zip_... | Evfro/fifty-shades | polara/tools/movielens.py | Python | mit | 2,538 |
""" Module that takes a configuration and input signal from a JSON file
and calculates the output signal, saving it as a JSON file.
"""
import sys
import json
from pymongo import MongoClient
from graph import Node, Edge, Graph
from resistor import Resistor
from capacitor import Capacitor
from diode import Diode
... | ThatSnail/impede | impede-app/server/py/js_play.py | Python | mit | 5,067 |
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
class Migration(DataMigration):
def forwards(self, orm):
for cs in orm.ContentSticker.objects.all():
print cs,
try:
[first_comment] = cs.content... | canvasnetworks/canvas | website/canvas/migrations/0062_copy_content_sticker_into_comment_sticker.py | Python | bsd-3-clause | 11,713 |
# P2P concurrency test cases
# Copyright (c) 2013-2015, Jouni Malinen <j@w1.fi>
#
# This software may be distributed under the terms of the BSD license.
# See README for more details.
from remotehost import remote_compatible
import logging
logger = logging.getLogger()
import subprocess
import time
import hwsim_utils
... | s0lst1c3/eaphammer | local/hostapd-eaphammer/tests/hwsim/test_p2p_concurrency.py | Python | gpl-3.0 | 11,502 |
from som.interpreter.ast.nodes.message.abstract_node import AbstractMessageNode
from som.interpreter.ast.nodes.message.generic_node import (
UnarySend,
BinarySend,
TernarySend,
NArySend,
)
from som.interpreter.ast.nodes.specialized.down_to_do_node import (
IntDownToIntDoNode,
IntDownToDoubleDoN... | SOM-st/PySOM | src/som/interpreter/ast/nodes/message/uninitialized_node.py | Python | mit | 2,458 |
#
#
#
from __future__ import absolute_import, division, print_function, unicode_literals
import sys
sys.path += (sys.path[0] + '/../lib',)
import hidapi
from logitech.unifying_receiver.base import DEVICE_UNIFYING_RECEIVER
from logitech.unifying_receiver.base import DEVICE_UNIFYING_RECEIVER_2
from logitech.unifying_re... | marcbelmont/Solaar | tools/monitor.py | Python | gpl-2.0 | 559 |
# -*- coding: utf-8 -*-
"""
tclient
~~~~~~~~
:copyright: (c) 2013 by Rhett Garber.
:license: ISC, see LICENSE for more details.
"""
__title__ = 'tclient'
__version__ = '0.0.4'
__description__ = 'HTTP client for parallel http requests'
__url__ = 'https://github.com/rhettg/tclient'
__build__ = 0
__author__ = 'Rhett G... | rhettg/tclient | tclient/__init__.py | Python | isc | 566 |
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<i@binux.me>
# http://binux.me
# Created on 2014-10-19 16:10:19
from .result_worker import ResultWorker
| ubear/Pyspider | pyspider/result/__init__.py | Python | apache-2.0 | 225 |
# Copyright 2014 Tesora, Inc.
# 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 required by ... | redhat-openstack/trove | trove/common/base_wsgi.py | Python | apache-2.0 | 27,852 |
#!/usr/bin/env python
"""Starts the Flask app in debug mode.
Do not use in production.
"""
from bot.webapp import goldstarsapp
if __name__ == "__main__":
goldstarsapp.debug = True
goldstarsapp.run(port=8042, host='0.0.0.0', processes=2)
| barentsen/AstroGoldStars | run-devserver.py | Python | mit | 247 |
"""Python challenge #7:
http://www.pythonchallenge.com/pc/def/oxygen.html"""
import urllib
from PIL import Image
def main():
png = urllib.urlopen('http://www.pythonchallenge.com/pc/def/oxygen.png')
png = Image.open(png)
output = []
png_matrix = png.load()
for x in xrange(0, int(png.size[0]), 7):
... | bm5w/pychal | 7.py | Python | mit | 565 |
"""
Tests for tools
Author: Chad Fulton
License: Simplified-BSD
"""
from __future__ import division, absolute_import, print_function
import numpy as np
import pandas as pd
from statsmodels.tsa.statespace import tools
# from .results import results_sarimax
from numpy.testing import (
assert_equal, assert_array_eq... | hlin117/statsmodels | statsmodels/tsa/statespace/tests/test_tools.py | Python | bsd-3-clause | 4,268 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""This module implements map function with various backends and
caching.
"""
from __future__ import division, print_function, absolute_import
from __future__ import unicode_literals
from sys import version
try:
import cPickle as pickle
except ImportError:
impor... | mrkrd/thorns | thorns/util/maps.py | Python | gpl-3.0 | 12,672 |
#! /usr/bin/python3
import struct
import decimal
D = decimal.Decimal
from fractions import Fraction
from counterpartylib.lib import (config, exceptions, util)
"""Burn {} to earn {} during a special period of time.""".format(config.BTC, config.XCP)
ID = 60
def initialise (db):
cursor = db.cursor()
cursor.ex... | tokenly/counterparty-lib | counterpartylib/lib/messages/burn.py | Python | mit | 5,150 |
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class RCodetools(RPackage):
"""Code analysis tools for R."""
homepage = "https://cloud.r-pr... | LLNL/spack | var/spack/repos/builtin/packages/r-codetools/package.py | Python | lgpl-2.1 | 943 |
"""
Django settings for social_network 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, ... | grepme/cmput410-project | social_network/settings.py | Python | apache-2.0 | 3,160 |
# Django settings for satchmo project.
# If you have an existing project, then ensure that you modify local_settings-customize.py
# and import it from your main settings file. (from local_settings import *)
import os
DIRNAME = os.path.dirname(__file__)
DJANGO_PROJECT = 'simple'
DJANGO_SETTINGS_MODULE = 'simple.settin... | grengojbo/satchmo | satchmo/projects/simple/settings.py | Python | bsd-3-clause | 5,650 |
(1, 2)
( 1, 2 )
(1, )
(1, )
( 1, 2, )
( 3,
4,
5 )
1 ,
1, 2,
( (1) * (2),
(3) * (4),
(5) * (6) )
((1),)
fun(2, ((1),))
fun(((1),))
(1,), (2,)
(a, b) = [
5, 6]
(x, y) = [7, 8] # prevent this last comma being used
| RyanDJLee/pyta | examples/ending_locations/Tuple.py | Python | gpl-3.0 | 256 |
# Mailanie - Cute Mailbox Explorator
# Copyright 2009 Guillaume Ayoub <guillaume.ayoub@kozea.fr>
# 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
# Mailanie is distributed in the hope ... | liZe/Mailanie | mailanie/ui/about.py | Python | gpl-3.0 | 2,202 |
#!/usr/bin/python3
# vim: set et ts=4 sw=4: #
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-
#
# main.py
# Copyright (C) 2017 Carlos Penaranda <cpenar@MR032028>
#
# example_use_glade_anjuta is free software: you can redistribute it and/or modify it
# under the terms of the... | cpenar/PolSARpro_gtk | single_data_set/src/single_data_set.py | Python | gpl-3.0 | 1,806 |
# -*- test-case-name: mamba.test.test_camelcase -*-
# Copyright (c) 2012 - Oscar Campos <oscar.campos@member.fsf.org>
# See LICENSE for more details
"""
.. module:: borg
:platform: Unix, Windows
:synopsys: Stupid class that just offers stupid CamelCase functionality
.. moduleauthor:: Oscar Campos <oscar.campo... | Kelfast/mamba-framework | mamba/utils/camelcase.py | Python | gpl-3.0 | 1,598 |
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not... | txamqp/txamqp | src/txamqp/test/test_endpoint.py | Python | apache-2.0 | 4,136 |
from setuptools import setup
setup(name='beerlistit',
version='0.1',
description='Quickly get the BeerAdvocate ratings for all the beers listed on a page.',
url='http://github.com/serhalp/beerlist.it',
author='Philippe Serhal and Curtis Heberle',
author_email='philippe.serhal@gmail.com',
... | serhalp/beerlist.it | setup.py | Python | gpl-2.0 | 499 |
# This file is part of fedmsg
# Copyright (C) 2012 Red Hat, Inc.
#
# fedmsg is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
... | fedora-infra/fedmsg_meta_fedora_infrastructure | fedmsg_meta_fedora_infrastructure/tests/mailman3.py | Python | lgpl-2.1 | 6,354 |
from __future__ import unicode_literals
import random
import re
import six
EC2_RESOURCE_TO_PREFIX = {
'customer-gateway': 'cgw',
'dhcp-options': 'dopt',
'image': 'ami',
'instance': 'i',
'internet-gateway': 'igw',
'network-acl': 'acl',
'network-acl-subnet-assoc': 'aclassoc',
'network-int... | rouge8/moto | moto/ec2/utils.py | Python | apache-2.0 | 16,489 |
# My files
from handlers import MainPage
from handlers import WelcomePage
from handlers import SignUpPage
from handlers import SignIn
from handlers import SignOut
from handlers import NewPost
from handlers import EditPost
from handlers import DeletePost
from handlers import SinglePost
from handlers import LikePost
from... | joepettigrew/multi-blog | main.py | Python | mit | 890 |
from __future__ import division, print_function, absolute_import
import numpy as np
from numpy.testing import TestCase, assert_equal, assert_almost_equal
from scipy.special import logit, expit
class TestLogit(TestCase):
def check_logit_out(self, dtype, expected):
a = np.linspace(0,1,10)
... | beiko-lab/gengis | bin/Lib/site-packages/scipy/special/tests/test_logit.py | Python | gpl-3.0 | 2,675 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2018 João Pedro Rodrigues
#
# 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
#
# Unl... | JoaoRodrigues/pdb-tools | pdbtools/pdb_tocif.py | Python | apache-2.0 | 6,175 |
import json
import os
from datetime import datetime
CONCEPT_MAP = {'people': 'Person',
'places': 'Place',
'things': 'Thing',
'activities': 'Activity',
'times': 'Time',
'mood_words': 'Mood'}
def dump_mem_to_json(mem_dict, save=None):
"""
... | CDIPS-AI-2017/pensieve | pensieve/json_dump.py | Python | apache-2.0 | 3,188 |
# Copyright 2015-present Scikit Flow Authors. 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 required by... | panmari/tensorflow | tensorflow/contrib/skflow/python/skflow/tests/test_estimators.py | Python | apache-2.0 | 2,170 |
import numpy as np
import chainer
import chainer.functions as F
import chainer.links as L
from chainer import cuda, optimizers, serializers, Variable
from chainer import training
from chainer.training import extensions
import argparse
import sys
import json
sys.path.insert(0, '../')
import common.datasets as datasets
... | Aixile/chainer-gan-experiments | tools/check_dataset.py | Python | mit | 1,320 |
import requests
from requests import exceptions
import sys
import json
class TagsConn(object):
base_url = None
info_uri = None
role_id = None
response = None
def __init__(self, access_token, api_key, base_url, info_uri, tag_id=None, tag_name=None, delete_tag=False):
self.base... | apanimesh061/hmh-client | hmh-client/API/Tags/Tags.py | Python | gpl-2.0 | 5,349 |
#!/usr/bin/env python3
import sys, base64, io
import xml.etree.ElementTree as ET
import xml.dom.minidom as md
from PIL import Image
from struct import unpack, unpack_from, iter_unpack
from pprint import pprint
from collections import defaultdict, namedtuple
def unpack_15bpp(pixel):
return (
(8 * (pixel & 0... | ariscop/battlespire-tools | bsitool/bsitool.py | Python | unlicense | 7,153 |
#!/usr/bin/env python
"""Configuration parameters for the client."""
from grr.lib import config_lib
from grr.lib.rdfvalues import crypto
# General Client options.
config_lib.DEFINE_string("Client.name", "GRR",
"The name of the client. This will be used as a base "
"n... | ksmaheshkumar/grr | config/client.py | Python | apache-2.0 | 10,670 |
import os
from pulp.common.compat import unittest
from mock import patch, Mock, PropertyMock, ANY, call
from pulp.common.plugins import importer_constants
from pulp.server.exceptions import PulpCodedException
from mongoengine import NotUniqueError
from pulp_ostree.plugins.lib import LibError, Commit
from pulp_ostr... | pcreech/pulp_ostree | plugins/test/unit/plugins/importers/test_steps.py | Python | gpl-2.0 | 25,771 |
# -*- coding: utf-8 -*-
from .context import import
import unittest
class BasicTestSuite(unittest.TestCase):
"""Basic test cases."""
def test_absolute_truth_and_meaning(self):
assert True
if __name__ == '__main__':
unittest.main()
| happykhan/igor | tests/test_basic.py | Python | gpl-3.0 | 258 |
'''
07. テンプレートによる文生成
引数x, y, zを受け取り「x時のyはz」という文字列を返す関数を実装せよ.
さらに,x=12, y="気温", z=22.4として,実行結果を確認せよ.
'''
def temp_sentence(time,temp,value):
return (str(time) + "時の" + temp + "は" + str(value))
print(temp_sentence(12,"気温",22.4))
| yasutaka/nlp_100 | kiyota/07.py | Python | mit | 373 |
# -*- coding: utf-8 -*-
import django.contrib.messages as django_messages
from django.template import loader
from django.contrib.messages.storage import default_storage
from django.http import HttpRequest
from django.utils.translation import ugettext
import pytest
from olympia.amo.messages import _make_message, info
... | tsl143/addons-server | src/olympia/amo/tests/test_messages.py | Python | bsd-3-clause | 3,072 |
def check_first_pages(first_pages):
page_links = set([page.get("url") for page in first_pages])
assert len(set(page_links)) == len(page_links)
assert len(page_links) == len(first_pages)
list_of_images = [page.get("image_urls") for page in first_pages]
image_links = [image for page in list_of_images ... | J-CPelletier/WebComicToCBZ | webcomix/util.py | Python | mit | 440 |
def extractKoongKoongTranslations(item):
"""
"""
vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title'])
if not (chp or vol or frag) or 'preview' in item['title'].lower():
return None
return False
| fake-name/ReadableWebProxy | WebMirror/management/rss_parser_funcs/feed_parse_extractKoongKoongTranslations.py | Python | bsd-3-clause | 223 |
import datetime
import os
import re
import unittest
import uuid
from decimal import ROUND_DOWN, ROUND_UP, Decimal
import pytest
from django.http import QueryDict
from django.test import TestCase, override_settings
from django.utils import six
from django.utils.timezone import activate, deactivate, utc
import rest_fra... | kgeorgy/django-rest-framework | tests/test_fields.py | Python | bsd-2-clause | 66,441 |
from openerp import api, models, fields, SUPERUSER_ID
class crm_phonecall(models.Model):
_inherit = "crm.phonecall"
repair_id = fields.Many2one('mrp.repair', 'Repair Order')
class mrp_repair(models.Model):
_inherit = 'mrp.repair'
@api.one
def _get_phonecall_count(self):
self.phonecall_... | gmathers/iii-addons | phonecall_repair_order/models.py | Python | agpl-3.0 | 1,991 |
from django.contrib.auth import authenticate
from django.contrib.auth.models import User, Permission
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.context_processors import PermWrapper, PermLookupDict
from django.db.models import Q
from django.test import TestCase, override_setting... | doismellburning/django | django/contrib/auth/tests/test_context_processors.py | Python | bsd-3-clause | 6,365 |
import re
try:
import rpython
from rpython.annotator import model
from rpython.annotator.bookkeeper import getbookkeeper
from rpython.rlib.objectmodel import instantiate, hlinvoke
from rpython.rlib.rsre import rsre_core
from rpython.rlib.rsre.rpy import get_code
from rpython.rtyper.annlowle... | rcarmo/rss2imap-gae | lib/rply/lexergenerator.py | Python | mit | 8,242 |
from corehq.apps.fixtures.models import FixtureDataItem
from corehq.util.quickcache import quickcache
DOMAIN = 'opm'
PREG_REG_XMLNS = "http://openrosa.org/formdesigner/D127C457-3E15-4F5E-88C3-98CD1722C625"
VHND_XMLNS = "http://openrosa.org/formdesigner/ff5de10d75afda15cddb3b00a0b1e21d33a50d59"
BIRTH_PREP_XMLNS = "htt... | puttarajubr/commcare-hq | custom/opm/constants.py | Python | bsd-3-clause | 1,572 |
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 ... | CWTGMBH/ERPNext2Alfresco | erpnext2alfresco/actions/cmislibalf/extension.py | Python | mit | 13,272 |
#
# SecureDrop whistleblower submission system
# Copyright (C) 2017 Loic Dachary <loic@dachary.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 3 of the License, or
#... | freedomofpress/securedrop | securedrop/tests/pageslayout/test_journalist_delete.py | Python | agpl-3.0 | 4,067 |
import uuid
import threading
import time
from datetime import datetime
import logging
from core.time import IDLE_MIN_MS
class WorldRunException(Exception):
pass
class Pixel(object):
RED_INDEX = 0
GREEN_INDEX = 1
BLUE_INDEX = 2
ALPHA_INDEX = 3
@classmethod
def from_tuple(cls, rgb_or_r... | mackay/ble_detector | display/__init__.py | Python | mit | 11,569 |
import datetime
from django.db import models
from django.db.models import Max, Count
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User
from helios.models import Election
import utils
class Institution(models.Model):
name = models.CharField(max_length=250)
... | shirlei/helios-server | heliosinstitution/models.py | Python | apache-2.0 | 7,132 |
#!/usr/bin/env python
# -*- coding: UTF8 -*-
#
# Modplug sndfile constants.
# Copyright (C) 2012 Josiah Gordon <josiahg@gmail.com>
#
# This program 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 versio... | zepto/musio | musio/modplug/sndfile.py | Python | gpl-3.0 | 1,502 |
class Solution(object):
def countNegatives(self, grid):
"""
:type grid: List[List[int]]
:rtype: int
"""
if len(grid) == 0 or len(grid[0]) == 0:
return 0
cnt = 0
rows = len(grid)
cols = len(grid[0])
for i in range(rows):
... | kingsamchen/Eureka | crack-data-structures-and-algorithms/leetcode/count_negative_numbers_in_a_sorted_matrix_q5340.py | Python | mit | 488 |
# coding=utf-8
from datetime import datetime, timedelta
import _strptime
import time
FULL_NAMES = {
u'H.Králové': u'Hradec Králové',
u'M.Boleslav': u'Mladá Boleslav',
u'K.Vary': u'Karlovy Vary',
u'SR 20': u'Slovensko 20',
u'L.Mikuláš': u'Liptovský Mikuláš',
u'N.Zámky': u'Nové Zámky',
u'HK P... | Xsichtik/plugin.video.tipsport.elh | resources/lib/match.py | Python | gpl-2.0 | 2,411 |
class WoofConsumerError(RuntimeError):
pass
class WoofNotSupported(WoofConsumerError):
pass
CURRENT_PROD_BROKER_VERSION = '0.9'
| goibibo/woof | woof/common.py | Python | apache-2.0 | 140 |
import sys
import unittest
from dynd import nd, ndt
import ctypes
class TestCTypesDTypeInterop(unittest.TestCase):
def test_type_from_ctype_typeobject(self):
self.assertEqual(ndt.int8, ndt.type(ctypes.c_int8))
self.assertEqual(ndt.int16, ndt.type(ctypes.c_int16))
self.assertEqual(ndt.int32,... | aterrel/dynd-python | dynd/tests/test_ctypes_interop.py | Python | bsd-2-clause | 2,803 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
# Xamcheck-Utils Stuff
from xamcheck_utils.collections import DefaultOrderedDict, OrderedSet
from .base import TestCase
class TestOrderedSet(TestCase):
def test_add(self):
ordered_set = OrderedSet()
ordered_set.add("something")
... | psjinx/xamcheck-utils | src/xamcheck_utils/tests/test_collections.py | Python | mit | 4,073 |
import os
from tempfile import mkdtemp
SECRET_KEY = "Please do not spew DeprecationWarnings"
# Haystack settings for running tests.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'haystack_tests.db',
}
}
INSTALLED_APPS = [
'django.contrib.admin',
'django.co... | kybi/django-haystack | test_haystack/settings.py | Python | bsd-3-clause | 1,777 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import struct
from layer1 import VarLenMessage, VarLenSocket
class TagMessage:
"""
TagMessage contains a string tag and string data.
Parameters
----------
tag: string
The type of the message. Currently supported tags are "json" and
"as... | astrilet/CARTAvis | carta/scriptedClient/layer2.py | Python | gpl-2.0 | 2,553 |
# -*- coding: utf-8 -*-
'''
Local settings
- Run in Debug mode
- Use console backend for emails
- Add Django Debug Toolbar
- Add django-extensions as app
'''
from .common import * # noqa
# DEBUG
# ------------------------------------------------------------------------------
DEBUG = env.bool('DJANGO_DEBUG', default... | giantryansaul/easy_blog_django | config/settings/local.py | Python | bsd-3-clause | 2,375 |
#!/usr/bin/env python
#
# Communicate with the ulnoiot esp dongle
# and scan for uiot-node networks
import sys
import os
import optparse
import logging
import serial
import time
def do_scan(port, cutoff):
# Create a serial connection
ser = serial.Serial(port, 115200, timeout=15);
logging.info('Starting ... | ulno/ulnoiot | bin/dongle_scan.py | Python | mit | 3,722 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from PIL import Image
def makeimageeven(image):
pixels = list(image.getdata()) # 获得 image 的像素信息列表
# 通过位运算,将 pixels 每个元素的最后一位设为0
evenpixels = [(r >> 1 << 1, g >> 1 << 1, b >> 1 << 1, t >> 1 << 1) for [r, g, b, t] in pixels]
evenimage = Image.ne... | dronly/python | shiyanlou/steganography/steganography.py | Python | apache-2.0 | 3,243 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('course', '0010_auto_20151214_1714'),
]
operations = [
migrations.AddField(
model_name='coursechapter',
... | ttsirkia/a-plus | course/migrations/0011_auto_20151215_1133.py | Python | gpl-3.0 | 624 |
# -*- coding: utf-8 -*-
import re
import json
import logging
import random
import time
import operator
import threading
from channels import Group
from channels import Channel
from channels.sessions import channel_session
from .models import Room
from .models import Player
import sys
reload(sys)
sys.setdefaultencoding... | hanchen999/werewolf-with-django-on-heroku | chat/consumers.py | Python | bsd-3-clause | 54,092 |
#!/usr/bin/env python
from setuptools import setup
setup(name='nlp_rake',
version='1.0',
description='Rapid Automatic Keyword Extraction (RAKE) algorithm',
long_description='A Python implementation of the Rapid Automatic Keyword Extraction (RAKE) algorithm as described in: Rose, S., Engel, D., Crame... | zelandiya/RAKE-tutorial | setup.py | Python | mit | 741 |
import PLConstants as CONSTS
import os
def aggregate(folder, repoName, outFile):
rule1_count =0
rule2_count =0
rule3_count =0
rule4_count =0
rule5_count =0
rule6_count =0
rule7_count =0
rule8_count =0
rule9_count =0
rule10_count =0
rule11_count =0
rule12_count =0
rul... | tushartushar/Puppeteer | Puppet-lint_aggregator/Aggregator.py | Python | apache-2.0 | 4,527 |
#-*- coding: utf-8 -*-
#+---------------------------------------------------------------------------+
#| 01001110 01100101 01110100 01111010 01101111 01100010 |
#| |
#| Netzob : Inferring communication protocols... | lootr/netzob | netzob/test/src/test_netzob/test_Tutorials/test_USBMouseProtocol.py | Python | gpl-3.0 | 9,373 |
import logging
from sqlalchemy import event
from radar.api import views
from radar.api.auth import force_password_change, require_login
from radar.api.auth import set_cors_headers
from radar.api.debug import debug_before_request, debug_teardown_request
from radar.api.logs import log_request
from radar.app import Rada... | renalreg/radar | radar/api/app.py | Python | agpl-3.0 | 1,888 |
# Copyright 2015 Internap.
#
# 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, so... | internap/netman | netman/core/objects/switch_base.py | Python | apache-2.0 | 8,954 |
#!/usr/bin/env python
#
# Copyright 2016 Google Inc. 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 requir... | googleads/googleads-python-lib | examples/adwords/v201809/basic_operations/add_campaigns.py | Python | apache-2.0 | 4,112 |
"""
Python Interchangeable Virtual Instrument Library
Copyright (c) 2016-2017 Alex Forencich
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... | python-ivi/python-ivi | ivi/tektronix/tektronixMSO4032.py | Python | mit | 1,560 |
#
# 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, software
# ... | ntt-sic/heat | heat/tests/test_sqlalchemy_types.py | Python | apache-2.0 | 1,833 |
import json
from django.conf.urls import url
from django.contrib.auth import user_logged_in, logout
from django.contrib.auth.models import User
from django.http import HttpResponse
from tastypie import fields, http
from tastypie.authentication import MultiAuthentication, SessionAuthentication, ApiKeyAuthentication, Au... | lettoosoft/lettoo-weixin-platform-back | src/api/v1/user.py | Python | mit | 16,119 |
# -*- coding: utf-8 -*-
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright (C) 2010-2022 GEM Foundation
#
# OpenQuake 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 Licen... | gem/oq-engine | openquake/hmtk/parsers/__init__.py | Python | agpl-3.0 | 830 |
# Copyright 2014-2016 Presslabs SRL
#
# 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 wri... | PressLabs/gitfs | tests/integrations/base.py | Python | apache-2.0 | 6,485 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('candidates', '0001_initial'),
]
... | mysociety/yournextrepresentative | candidates/migrations/0002_usertermsagreement.py | Python | agpl-3.0 | 827 |
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from google.appengine.ext import ndb
class FrontendJob(ndb.Model):
"""Class representing a frontend job.
A frontend job is a Clovis task sent by the u... | danakj/chromium | tools/android/loading/cloud/frontend/frontend_job.py | Python | bsd-3-clause | 2,892 |
# Copyright 2014 Amazon.com, Inc. or its affiliates. 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. A copy of
# the License is located at
#
# https://aws.amazon.com/apache2.0/
#
# or in the "license" file accomp... | boto/boto3 | boto3/resources/params.py | Python | apache-2.0 | 6,112 |
import blue_yellow_app
from blue_yellow_app.data.dbsession import DbSessionFactory
def main():
blue_yellow_app.init_db(None)
add_test_data()
def add_test_data():
pass
if __name__ == '__main__':
main() | mikeckennedy/python-for-entrepreneurs-course-demos | 17_logging_and_monitoring/start_17_blue_yellow_app_monitoring/blue_yellow_app/bin/add_test_data.py | Python | mit | 222 |
#!/usr/bin/python3
from ABE_ExpanderPi import RTC
import time
"""
================================================
ABElectronics Expander Pi | RTC clock output demo
Version 1.0 Created 21/08/2014
Version 1.1 Updated 11/06/2017 updated to include changes to Expander Pi library
run with: python3 demo-rtcout.py
=======... | abelectronicsuk/ABElectronics_Python3_Libraries | ExpanderPi/demo-rtcout.py | Python | mit | 721 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.