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 |
|---|---|---|---|---|---|---|
# -*- coding: utf8 -*-
import MapModel as Mm
from MapObjects.MovingObject import MovingObject
import Statistic
class Enemy(MovingObject):
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
def __init__(self, health, width, height):
super().__init__()
self.gold = 2
self.able_to_go = {Mm.Player,... | v-samodelkin/TowerDefence | MapObjects/Enemy.py | Python | mit | 2,746 | 0 |
import os, requests, time
import mydropbox
edmunds = mydropbox.get_keys('edmunds')
api_key = edmunds['api_key']
api_secret = edmunds['api_secret']
vin = mydropbox.read_dropbox_file(os.path.join('Records', 'Financials', 'Car', 'VIN')).strip()
r = requests.get("https://api.edmunds.com/api/vehicle/v2/vins/%s?&fmt=json&a... | smiley325/accounter | ref/edmunds.py | Python | epl-1.0 | 1,537 | 0.001952 |
from django.template.loader import get_template
from . import BaseNotification
class EmailNotification(BaseNotification):
def get_message(self):
template = get_template('user_profile/notification/email/issue.txt')
return template.render({
'issue': self.issue,
'notification... | mcallistersean/b2-issue-tracker | toucan/user_profile/notifications/email.py | Python | mit | 561 | 0.005348 |
#!/usr/bin/env python3
import sys
import dbus
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
'-t',
'--trunclen',
type=int,
metavar='trunclen'
)
parser.add_argument(
'-f',
'--format',
type=str,
metavar='custom format',
dest='custom_format'
)
parser.add_argum... | naegi/dotfiles | home/spotify_status.py | Python | unlicense | 3,414 | 0.003515 |
# -*- coding: utf-8 -*-
# Copyright (c) 2010-2017 Tuukka Turto
#
# 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,... | tuturto/pyherc | src/pyherc/test/unit/test_itemadder.py | Python | mit | 5,532 | 0.009219 |
from threading import Thread
import sys
import imaplib
import time
class Can(Thread):
def __init__(self, id, config, opener, key):
Thread.__init__(self)
self.key = key
self.config = config
self.id = id
self.opener = opener
self.running = True
pass
def run(self):
try:
user = ... | scommab/can-opener | cans/gmail.py | Python | apache-2.0 | 1,364 | 0.026393 |
"""
Students grade peer submissions.
"""
from __future__ import absolute_import
from bok_choy.page_object import PageObject
from bok_choy.promise import Promise
class PeerGradePage(PageObject):
"""
Students grade peer submissions.
"""
url = None
def is_browser_on_page(self):
def _is_co... | ESOedX/edx-platform | common/test/acceptance/pages/lms/peer_grade.py | Python | agpl-3.0 | 1,101 | 0.000908 |
import os, re, sys
import read_dicts
from collections import Counter
import pandas as pd
import numpy as np
import operator
import random
sys.path.append('.')
ENABLE_WRITE = 1
INDEX_NAMES_FILES = '../../data/aaindex/list_of_indices.txt'
def getscores(d, aalist, seq):
score_list = list()
char_freq = dict()... | seokjunbing/cs75 | src/data_processing/read_data.py | Python | gpl-3.0 | 22,577 | 0.00186 |
# Copyright 2019, 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... | google-research/federated | utils/keras_metrics.py | Python | apache-2.0 | 2,516 | 0.004769 |
from math import sqrt
def euclidean_distance(p1, p2):
"""
Compute euclidean distance for two points
:param p1:
:param p2:
:return:
"""
dx, dy = p2[0] - p1[0], p2[1] - p1[1]
# Magnitude. Coulomb law.
return sqrt(dx ** 2 + dy ** 2) | dsaldana/roomba_sensor_network | roomba_sensor/src/roomba_sensor/util/geo.py | Python | gpl-3.0 | 268 | 0.003731 |
from __future__ import print_function, division, absolute_import
import warnings
import sys
# unittest only added in 3.4 self.subTest()
if sys.version_info[0] < 3 or sys.version_info[1] < 4:
import unittest2 as unittest
else:
import unittest
# unittest.mock is not available in 2.7 (though unittest2 might conta... | aleju/ImageAugmenter | test/augmentables/test_bbs.py | Python | mit | 85,736 | 0.000105 |
# coding: utf-8
# Copyright (C) 1994-2016 Altair Engineering, Inc.
# For more information, contact Altair at www.altair.com.
#
# This file is part of the PBS Professional ("PBS Pro") software.
#
# Open Source License Information:
#
# PBS Pro is free software. You can redistribute it and/or modify it under the
# terms ... | vinodchitrali/pbspro | test/fw/ptl/lib/pbs_testlib.py | Python | agpl-3.0 | 502,834 | 0.00042 |
import re
import requests
import threading
from ..common import clean_title,clean_search
import xbmc
from ..scraper import Scraper
sources = []
class scrape_thread(threading.Thread):
def __init__(self,m,match,qual):
self.m = m
self.match = match
self.qual = qual
threading.Thread.__i... | mrquim/mrquimrepo | script.module.nanscrapers/lib/nanscrapers/scraperplugins/yesmovies.py | Python | gpl-2.0 | 5,703 | 0.01543 |
import contextlib
import sqlalchemy as sa
from sqlalchemy import and_
from sqlalchemy import between
from sqlalchemy import bindparam
from sqlalchemy import Boolean
from sqlalchemy import cast
from sqlalchemy import collate
from sqlalchemy import column
from sqlalchemy import desc
from sqlalchemy import distinct
from ... | wujuguang/sqlalchemy | test/orm/test_query.py | Python | mit | 183,302 | 0.000005 |
# -*- coding: utf-8 -*-
"""
MiniTwit
~~~~~~~~
A microblogging application written with Flask and sqlite3.
:copyright: (c) 2010 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import time
from sqlite3 import dbapi2 as sqlite3
from hashlib im... | HackingHabits/PersonalPasswordManager | packages/Flask/examples/minitwit/minitwit.py | Python | mit | 8,424 | 0.00095 |
import string
import random
import json
from collections import defaultdict
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.template.context import RequestContext
from catmaid.fields import Double3D
from catmaid.models import Log, NeuronSearch, CELL_BODY_CHOICES, \
... | htem/CATMAID | django/applications/catmaid/control/common.py | Python | agpl-3.0 | 8,243 | 0.002669 |
""" Buildbot inplace config
(C) Copyright 2015 HicknHack Software GmbH
The original code can be found at:
https://github.com/hicknhack-software/buildbot-inplace-config
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... | hicknhack-software/buildbot-inplace-config | buildbot_inplace/config.py | Python | apache-2.0 | 5,400 | 0.002222 |
class constant():
folder_name = 'results'
MAX_HELP_POSITION = 27
CURRENT_VERSION = '0.9.1'
output = None
file_logger = None
# jitsi options
jitsi_masterpass = None
# mozilla options
manually = None
path = None
bruteforce = None
specific_path = None
mozilla_software = ''
# ie optio... | theoneandonly-vector/LaZagne | Windows/src/LaZagne/config/constant.py | Python | lgpl-3.0 | 416 | 0.057692 |
from sklearn2sql_heroku.tests.regression import generic as reg_gen
reg_gen.test_model("SVR_rbf" , "freidman1" , "db2")
| antoinecarme/sklearn2sql_heroku | tests/regression/freidman1/ws_freidman1_SVR_rbf_db2_code_gen.py | Python | bsd-3-clause | 121 | 0.016529 |
# -*- coding: utf-8 -*-
from helper.resource import YuzukiResource | Perlmint/Yuzuki | resource/util.py | Python | mit | 66 | 0.015152 |
from __future__ import absolute_import
import os
import re
import numpy as np
import tensorflow as tf
stop_words=set(["a","an","the"])
def load_candidates(data_dir, task_id):
assert task_id > 0 and task_id < 6
candidates=[]
candidates_f=None
candid_dic={}
#candidates_f='candidates.txt'
candid... | DineshRaghu/dstc6-track1 | src/data_utils.py | Python | gpl-3.0 | 14,089 | 0.013273 |
from pathlib import Path
def source_dir():
src = Path("@CMAKE_CURRENT_SOURCE_DIR@/../..")
if src.is_dir():
return src.relative_to(Path.cwd())
# If the file was not correctly configured by cmake, look for the source
# folder, assuming the build folder is inside the source folder.
current_p... | joakim-hove/ert | tests/utils.py | Python | gpl-3.0 | 582 | 0 |
"""Triton Daemon - Communication server for Oxford Triton system
The Triton fridge already has communication capacity to directly control and read both the temperatures and other elements
of the fridge (pressure sensors, valves, compressor, ...). However, the Triton logging uses binary format files that can
only be o... | yausern/stlab | devices/TritonDaemon/TritonDaemon.py | Python | gpl-3.0 | 4,577 | 0.007428 |
#!/usr/bin/env python
# ESP32 efuse get/set utility
# https://github.com/themadinventor/esptool
#
# Copyright (C) 2016 Espressif Systems (Shanghai) PTE LTD
#
# 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
# ... | themadinventor/esptool | espefuse.py | Python | gpl-2.0 | 42,922 | 0.004497 |
import abc
class PluginTypeBase(object):
""" Baseclass for plugin types.
This needs to be derived from in order for plugin types to
be accepted by plugz.
"""
__metaclass__ = abc.ABCMeta
plugintype = None
@staticmethod
def is_valid_file(file):
""" Accept or reject files as va... | mistermatti/plugz | plugz/plugz.py | Python | bsd-3-clause | 373 | 0.002681 |
import pycrs
import mpl_toolkits.basemap.pyproj as pyproj # Import the pyproj module
import shapefile as shp
import matplotlib.pyplot as plt
shpFilePath = r"taxi_zones\taxi_zones"
sf = shp.Reader(shpFilePath)
records = sf.records()
plt.figure()
for shape in sf.shapeRecords():
x = [i[0] for i in shape... | arg-hya/taxiCab | Plots/TrajectoryPlot/TrajectoryPlot.py | Python | gpl-3.0 | 1,224 | 0.013072 |
"""
This module contains all the Data Access Objects for models which are persisted to Elasticsearch
at some point in their lifecycle.
Each DAO is an extension of the octopus ESDAO utility class which provides all of the ES-level heavy lifting,
so these DAOs mostly just provide information on where to persist the data... | JiscPER/jper | service/dao.py | Python | apache-2.0 | 3,957 | 0.006318 |
import math
import fpformat
import os
from pydrone.utils.data_structures import Graph
def world_generator(size, x_end, y_end, knowledge):
# Controllo se si richiede un mondo con il knowledge degli stati o meno
if knowledge:
world = Graph(x_end, y_end)
for i in range(size):
for j i... | DMIAlumni/pydrone-game | pydrone/utils/matrix_generator.py | Python | bsd-2-clause | 1,291 | 0.001549 |
from setuptools import setup
setup(name='decision_tree',
version='0.04',
description='Practice implementation of a classification decision tree',
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2.7',
... | metjush/decision_tree | setup.py | Python | mit | 734 | 0.042234 |
# -*- coding: utf-8 -*-
import pytest
import re
import requests
try:
# Faster, C-ext
from cStringIO import StringIO
except ImportError:
# Slower, pure python
from StringIO import StringIO
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFP... | lehinevych/cfme_tests | cfme/tests/configure/test_docs.py | Python | gpl-2.0 | 5,548 | 0.001802 |
import pyak
import yikbot
import time
# Latitude and Longitude of location where bot should be localized
yLocation = pyak.Location("42.270340", "-83.742224")
yb = yikbot.YikBot("yikBot", yLocation)
print "DEBUG: Registered yikBot with handle %s and id %s" % (yb.handle, yb.id)
print "DEBUG: Going to sleep, new yakker... | congrieb/yikBot | start.py | Python | mit | 469 | 0.004264 |
import unittest
import warnings
import datetime
from django.core.urlresolvers import reverse
from django.test import TestCase
from incuna.utils import find
from articles.models import Article
class ArticleAccessTests(TestCase):
fixtures = ['articles_data.json',]
def test_article_index(self):
response ... | viswimmer1/PythonGenerator | data/python_files/29179833/tests.py | Python | gpl-2.0 | 3,436 | 0.009604 |
#
# ----------------------------------------------------------------------------------------------------
#
# Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify ... | graalvm/mx | mx.py | Python | gpl-2.0 | 772,837 | 0.003661 |
"""Tail any mongodb collection"""
from time import sleep
from bson import ObjectId
__version__ = "1.1.0"
def fetch(collection, filter, last_oid_generation_time=None):
if last_oid_generation_time is not None:
last_oid = ObjectId.from_datetime(last_oid_generation_time)
filter.update({"_id": {"$gt... | Shir0kamii/mongofollow | mongofollow.py | Python | mit | 1,092 | 0 |
"""
This file is part of ALTcointip.
ALTcointip 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.
ALTcointip is distr... | Healdb/altcointip | src/ctb/ctb_coin.py | Python | gpl-2.0 | 8,785 | 0.006602 |
#
# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), its
# affiliates and/or its licensors.
#
from ..helpers.translators import verify_translate
from grenade.translators.sequence import SequenceTranslator
from probe.fixtures.mock_shotgun import MockShotgun
class TestSequenceTranslator(objec... | xxxIsaacPeralxxx/anim-studio-tools | grenade/tests/unit/test_translators/test_sequence.py | Python | gpl-3.0 | 3,110 | 0.018328 |
"""
Defines forms for providing validation of embargo admin details.
"""
from django import forms
from django.utils.translation import ugettext as _
import ipaddr
from xmodule.modulestore.django import modulestore
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from embargo.models... | zadgroup/edx-platform | common/djangoapps/embargo/forms.py | Python | agpl-3.0 | 3,061 | 0.000327 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('cardsgame', '0002_card_mana_cost'),
]
operations = [
migrations.AddField(
model_name='card',
name='m... | mrjmad/gnu_linux_mag_drf | hall_of_cards/cardsgame/migrations/0003_card_modified.py | Python | mit | 465 | 0.002151 |
# coding: utf-8
from __future__ import unicode_literals
import itertools
import json
import re
from .common import InfoExtractor, SearchInfoExtractor
from ..compat import (
compat_urllib_parse,
compat_urlparse,
)
from ..utils import (
clean_html,
unescapeHTML,
ExtractorError,
int_or_none,
... | Buggaarde/youtube-dl | youtube_dl/extractor/yahoo.py | Python | unlicense | 13,867 | 0.002323 |
""" Simple datasets to be used for unit tests. """
__authors__ = "Ian Goodfellow"
__copyright__ = "Copyright 2010-2012, Universite de Montreal"
__credits__ = ["Ian Goodfellow"]
__license__ = "3-clause BSD"
__maintainer__ = "LISA Lab"
__email__ = "pylearn-dev@googlegroups"
import numpy as np
from theano.compat.six.move... | junbochen/pylearn2 | pylearn2/testing/datasets.py | Python | bsd-3-clause | 2,822 | 0 |
# Copyright (c) 2005 Maxim Sobolev. All rights reserved.
# Copyright (c) 2006-2007 Sippy Software, Inc. All rights reserved.
#
# This file is part of SIPPY, a free RFC3261 SIP stack and B2BUA.
#
# SIPPY is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pub... | lemenkov/sippy | sippy/SipReplaces.py | Python | gpl-2.0 | 2,867 | 0.011161 |
#
# 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... | nathanielvarona/airflow | airflow/contrib/sensors/sagemaker_tuning_sensor.py | Python | apache-2.0 | 1,201 | 0.001665 |
import os
import sympy
from example_helper import save_example_fit
from scipy_data_fitting import Data, Model, Fit
#
# Example of a fit to a sine wave with error bars.
#
name = 'wave'
# Load data from a csv file.
data = Data(name)
data.path = os.path.join('examples','data', 'wave.csv')
data.genfromtxt_args['skip_he... | razor-x/scipy-data_fitting | examples/wave.py | Python | mit | 1,252 | 0.002417 |
from gtable import Table
import numpy as np
def test_records():
t = Table({'a': [1, 2, 3], 'b': np.array([4, 5, 6])})
t1 = Table({'a': [1, 2, 3], 'd': np.array([4, 5, 6])})
t.stack(t1)
records = [r for r in t.records()]
assert records == [
{'a': 1, 'b': 4},
{'a': 2, 'b': 5},
... | guillemborrell/gtable | tests/test_records.py | Python | bsd-3-clause | 1,282 | 0.00078 |
# Copyright 2016 The TensorFlow 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 applica... | unnikrishnankgs/va | venv/lib/python3.5/site-packages/tensorflow/contrib/distributions/python/ops/bijectors/affine_linear_operator.py | Python | bsd-2-clause | 1,182 | 0.000846 |
# Imported via `make aws_managed_policies`
aws_managed_policies_data = """
{
"AWSAccountActivityAccess": {
"Arn": "arn:aws:iam::aws:policy/AWSAccountActivityAccess",
"AttachmentCount": 0,
"CreateDate": "2015-02-06T18:41:18+00:00",
"DefaultVersionId": "v1",
"Document": {
... | botify-labs/moto | moto/iam/aws_managed_policies.py | Python | apache-2.0 | 495,649 | 0.000176 |
# (c) 2014 James Cammarata, <jcammarata@ansible.com>
#
# 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 late... | dr0pz0ne/sibble | lib/ansible/parsing/splitter.py | Python | gpl-3.0 | 10,657 | 0.002721 |
#!/usr/bin/python
import sys, copy, tarfile
""" - Splits Percolator output into decoy and target files.
- Extracts unique PSM/peptides/proteins out of a Percolator output file.
- Merges Percolator output files
Usage: python percolator_output_modifier.py command psm/peptides/proteins [score] infile outfile... | wohllab/milkyway_proteomics | galaxy_milkyway_files/tools/wohl-proteomics/MSGFcrux/percolator_output_modifier_fractionated.py | Python | mit | 10,590 | 0.011143 |
# Copyright 2011 Cisco Systems, 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... | onecloud/neutron | neutron/plugins/cisco/common/cisco_constants.py | Python | apache-2.0 | 2,838 | 0.000352 |
"""Main label index.
Revision ID: e679554261b2
Revises: e2be4ab896d3
Create Date: 2019-05-09 18:55:24.472216
"""
# revision identifiers, used by Alembic.
revision = 'e679554261b2'
down_revision = 'e2be4ab896d3'
from alembic import op
def upgrade():
op.create_index(
op.f('ix_label_main_label_id'), 'lab... | hasgeek/funnel | migrations/versions/e679554261b2_main_label_index.py | Python | agpl-3.0 | 452 | 0.004425 |
from flask.ext.assets import Bundle
from . import wa
js_libs = Bundle('js/libs/jquery.min.js',
'js/libs/bootstrap.min.js',
'js/libs/lodash.min.js',
#filters='jsmin',
output='js/libs.js')
js_board = Bundle('js/libs/drawingboard.min.js',
... | luizdepra/sketch_n_hit | app/assets.py | Python | mit | 984 | 0.003049 |
#!/usr/bin/env python3
import csv
import sqlite3
# requires python3
# requires sqlite3
#
sqldb = sqlite3.connect(':memory:')
def main:
while True:
input_location = input("Please provide the pathname of the file you wish to extract data from. Enter a blank line when you are done.")
if input_location = False:
... | fedallah/dsperf | pytest_2.py | Python | mit | 1,084 | 0.057196 |
__problem_title__ = "Eleven-free integers"
__problem_url___ = "https://projecteuler.net/problem=442"
__problem_description__ = "An integer is called if its decimal expansion does not contain any " \
"substring representing a power of 11 except 1. For example, 2404 and " \
... | jrichte43/ProjectEuler | Problem-0442/solutions.py | Python | gpl-3.0 | 936 | 0.00641 |
import sublime
import sublime_plugin
OPTIONS_LAST_REGEX = "jump_caret_last_regex"
class CaretJumpCommand(sublime_plugin.TextCommand):
def run(self, edit, jump=True, jump_to=None, repeat_previous_jump=False):
view = self.view
def get_next_sels(user_input):
new_sels = []
fo... | r-stein/sublime-text-caret-jump | caret_jump.py | Python | mit | 2,134 | 0 |
import wx
import svd
import my
class View(wx.Panel):
def __init__(self, parent, data=None):
wx.Panel.__init__(self, parent)
self.data = {}
self.tree = wx.TreeCtrl(self)
self.tree.AddRoot('FROM_RUSSIA_WITH_LOVE')
self.Bind(wx.EVT_SIZE, self.onResize)
self.Bind(wx.EV... | dmitrystu/svd_editor | modules/tview.py | Python | apache-2.0 | 7,250 | 0.001517 |
#!/usr/bin/python
#
# 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.
#
# Ansible is distribut... | t0mk/ansible | lib/ansible/modules/network/nxos/nxos_vlan.py | Python | gpl-3.0 | 13,902 | 0.001511 |
# -*- coding: utf-8 -*-
from os import path
from gluon import current
from gluon.html import *
from s3 import s3_represent_facilities, s3_register_validation
# =============================================================================
class index():
""" Custom Home Page """
def __call__(self):
... | flavour/rgims_as_diff | private/templates/RGIMS/controllers.py | Python | mit | 9,573 | 0.011804 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import warnings
import pytest
from translate.convert import dtd2po, po2dtd, test_convert
from translate.misc import wStringIO
from translate.storage import dtd, po
class TestPO2DTD:
def setup_method(self, method):
warnings.resetwarnings()
def teardown... | utkbansal/kuma | vendor/packages/translate/convert/test_po2dtd.py | Python | mpl-2.0 | 22,788 | 0.001668 |
#!/usr/bin/python
#
# This file is part of django-ship project.
#
# Copyright (C) 2011-2020 William Oliveira de Lagos <william.lagos@icloud.com>
#
# Shipping is free software: you can redistribute it and/or modify
# it under the terms of the Lesser GNU General Public License as published by
# the Free Software ... | efforia/django-shipping | shipping/providers/default.py | Python | lgpl-3.0 | 5,966 | 0.008213 |
# Solution to exercise MaxCounters
# http://www.codility.com/train/
def solution(N, A):
counters = [0 for _ in range(N)]
last_max_counter = 0
current_max_counter = 0
# Iterate through A. At each step, the value of counter i is
# last_max_counter or counters[i], whichever is greater
... | jmaidens/Codility | MaxCounters.py | Python | mit | 951 | 0.005258 |
#__*__coding:utf-8__*__
import urllib
import urllib2
URL_IP = 'http://127.0.0.1:8000/ip'
URL_GET = 'http://127.0.0.1:8000/get'
def use_simple_urllib2():
response = urllib2.urlopen(URL_IP)
print '>>>>Response Headers:'
print response.info()
print '>>>>Response Body:'
print ''.join([line for line i... | ctenix/pytheway | imooc_requests_urllib.py | Python | gpl-3.0 | 978 | 0.011579 |
from sklearn2sql_heroku.tests.classification import generic as class_gen
class_gen.test_model("GaussianNB" , "FourClass_500" , "sqlite")
| antoinecarme/sklearn2sql_heroku | tests/classification/FourClass_500/ws_FourClass_500_GaussianNB_sqlite_code_gen.py | Python | bsd-3-clause | 139 | 0.014388 |
__author__ = 'Lenusik'
from model.contact import Contact
import re
class ContactHelper:
def __init__(self, app):
self.app = app
contact_cache = None
def get_contact_list(self):
if self.contact_cache is None:
driver = self.app.driver
self.app.open_home_page()
... | Lenusik/python | fixture/contact.py | Python | gpl-2.0 | 2,909 | 0.003438 |
from yandextank.plugins.Aggregator import SecondAggregateData
from yandextank.plugins.Autostop import AutostopPlugin
from Tank_Test import TankTestCase
import tempfile
import unittest
class AutostopTestCase(TankTestCase):
def setUp(self):
core = self.get_core()
core.load_configs(['config/autostop.... | asekretenko/yandex-tank | tests/Autostop_Test.py | Python | lgpl-2.1 | 3,041 | 0.007892 |
# -*- encoding: utf-8 -*-
__author__ = 'ray'
__date__ = '2/27/15'
from flask import jsonify, abort
from flask.views import MethodView
from ..models import ThemeModel
class ThemeView(MethodView):
""" Theme View
Retrieve description of a list of available themes.
:param theme_model: A theme model that ... | Kotaimen/stonemason | stonemason/service/tileserver/themes/views.py | Python | mit | 1,132 | 0.000883 |
import warnings
warnings.simplefilter(action="ignore", category=RuntimeWarning)
warnings.simplefilter(action="ignore", category=PendingDeprecationWarning)
from hicexplorer import hicBuildMatrix, hicInfo
from hicmatrix import HiCMatrix as hm
from tempfile import NamedTemporaryFile, mkdtemp
import shutil
import os
import... | maxplanck-ie/HiCExplorer | hicexplorer/test/long_run/test_hicBuildMatrix.py | Python | gpl-2.0 | 9,095 | 0.002969 |
#!/usr/bin/python
#coding=utf-8
'''
@author: sheng
@license:
'''
import unittest
from meridian.acupoints import zuwuli233
class TestZuwuli233Functions(unittest.TestCase):
def setUp(self):
pass
def test_xxx(self):
pass
if __name__ == '__main__':
unittest.main()
| sinotradition/meridian | meridian/tst/acupoints/test_zuwuli233.py | Python | apache-2.0 | 299 | 0.006689 |
import sys
import os
from subprocess import Popen, PIPE
import unittest
class CmdlineTest(unittest.TestCase):
def setUp(self):
self.env = os.environ.copy()
if 'PYTHONPATH' in os.environ:
self.env['PYTHONPATH'] = os.environ['PYTHONPATH']
self.env['SCRAPY_SETTINGS_MODULE'] = 'scr... | willingc/oh-mainline | vendor/packages/scrapy/scrapy/tests/test_cmdline/__init__.py | Python | agpl-3.0 | 1,166 | 0.008576 |
# Copyright 2015 Hewlett-Packard Development Company, L.P.
#
# 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... | openstack/octavia | octavia/tests/unit/common/test_base_taskflow.py | Python | apache-2.0 | 5,974 | 0 |
from unicodeconverter import convertToUnicode
def evaluateBoolean(b):
if isinstance(b, bool):
return b
if isinstance(b, str):
b = convertToUnicode(b)
if isinstance(b, unicode):
if b.lower() == u"false":
return False
elif b.lower() == u"true":
return T... | hiidef/hiispider | legacy/evaluateboolean.py | Python | mit | 650 | 0.004615 |
import os
class ImageStore:
def __init__(self, root):
self.root = root
def exists(self, image):
image.root = self.root
return os.path.isfile(image.path)
def create(self, image):
image.root = self.root
image.generate()
| CptSpaceToaster/memegen | memegen/stores/image.py | Python | mit | 275 | 0 |
# -*- coding: utf-8 -*-
#
# Copyright 2004-2020 University of Oslo, Norway
#
# This file is part of Cerebrum.
#
# Cerebrum 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 2 of the License, or
# ... | unioslo/cerebrum | Cerebrum/modules/no/hia/OrgLDIF.py | Python | gpl-2.0 | 4,715 | 0 |
""" Back-ported, durable, and portable selectors """
# MIT License
#
# Copyright (c) 2017 Seth Michael Larson
#
# 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... | smmribeiro/intellij-community | plugins/hg4idea/testData/bin/mercurial/thirdparty/selectors2.py | Python | apache-2.0 | 27,478 | 0.000619 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from datetime import timedelta
from decimal import Decimal
from django.db import models
from django.db import transaction
from django.utils.timezone import now
from django.db.models import Sum, Max, F
from audit_log.models.managers import AuditLog
cla... | tombs/Water-Billing-System | waterbilling/core/models.py | Python | agpl-3.0 | 53,833 | 0.009529 |
from pbxproj import PBXGenericObject
class XCConfigurationList(PBXGenericObject):
def _get_comment(self):
info = self._get_section()
return f'Build configuration list for {info[0]} "{info[1]}"'
def _get_section(self):
objects = self.get_parent()
target_id = self.get_id()
... | kronenthaler/mod-pbxproj | pbxproj/pbxsections/XCConfigurationList.py | Python | mit | 821 | 0.002436 |
"""The ClimaCell integration."""
from __future__ import annotations
from datetime import timedelta
import logging
from math import ceil
from typing import Any
from pyclimacell import ClimaCellV3, ClimaCellV4
from pyclimacell.const import CURRENT, DAILY, FORECASTS, HOURLY, NOWCAST
from pyclimacell.exceptions import (
... | sander76/home-assistant | homeassistant/components/climacell/__init__.py | Python | apache-2.0 | 11,985 | 0.000834 |
"""
Course Advanced Settings page
"""
from bok_choy.promise import EmptyPromise
from .course_page import CoursePage
from .utils import press_the_notification_button, type_in_codemirror, get_codemirror_value
KEY_CSS = '.key h3.title'
UNDO_BUTTON_SELECTOR = ".action-item .action-undo"
MANUAL_BUTTON_SELECTOR = ".action... | xingyepei/edx-platform | common/test/acceptance/pages/studio/settings_advanced.py | Python | agpl-3.0 | 7,464 | 0.001742 |
from RaspiBot import Methods, sleep
# represents btn color and action on press in a state
class Btn:
def __init__(self, red, green, nextid = None):
self.red = red
self.green = green
self.next = nextid
# represents one menu state with message, button and own action
class State:
de... | alex-Symbroson/BotScript | BotScript/res/calibrate.py | Python | mit | 4,128 | 0.004845 |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-09-21 15:18
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('article', '0001_initial'),
]
operations = [
migrations.AlterField(
... | wenxiaomao1023/wenxiaomao | article/migrations/0002_auto_20160921_1518.py | Python | mit | 587 | 0 |
"""
@author: Nikhith !!
"""
from pycricbuzz import Cricbuzz
import json
import sys
""" Writing a CLI for Live score """
try:
cric_obj = Cricbuzz() # cric_obj contains object instance of Cricbuzz Class
matches = cric_obj.matches()
except:
print "Connection dobhindhi bey!"
sys.exit(0)
... | nikkitricky/nikbuzz | score.py | Python | mit | 5,706 | 0.006484 |
# Create your views here.
from rest_framework import viewsets
from offers.models import Offer, OfferHistory, OfferReview
from offers.serializers import (
OfferSerializer,
OfferHistorySerializer,
OfferReviewSerializer
)
from shops.serializers import ShopSerializer
from rest_framework import status
from rest_... | cliffton/localsecrets | offers/views.py | Python | mit | 3,993 | 0.001002 |
def represents_int(value):
try:
int(value)
return True
except ValueError:
return False
def bytes_to_gib(byte_value, round_digits=2):
return round(byte_value / 1024 / 1024 / float(1024), round_digits)
def count_to_millions(count_value, round_digits=3):
return round(count... | skomendera/PyMyTools | providers/value.py | Python | mit | 359 | 0 |
from .image import Image
from .product_category import ProductCategory
from .supplier import Supplier, PaymentMethod
from .product import Product
from .product import ProductImage
from .enum_values import EnumValues
from .related_values import RelatedValues
from .customer import Customer
from .expense import Expense
fr... | betterlife/psi | psi/app/models/__init__.py | Python | mit | 875 | 0.001143 |
# Copyright 2020 The dm_control 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 applicable law or agreed to i... | deepmind/dm_control | dm_control/locomotion/arenas/bowl.py | Python | apache-2.0 | 4,927 | 0.008119 |
"""The tests for the Template Binary sensor platform."""
from datetime import timedelta
import logging
from unittest.mock import patch
import pytest
from homeassistant import setup
from homeassistant.components import binary_sensor
from homeassistant.const import (
ATTR_DEVICE_CLASS,
EVENT_HOMEASSISTANT_START... | Danielhiversen/home-assistant | tests/components/template/test_binary_sensor.py | Python | apache-2.0 | 27,103 | 0.001107 |
import unittest
import datetime
import pykmlib
class PyKmlibAdsTest(unittest.TestCase):
def test_smoke(self):
classificator_file_str = ''
with open('./data/classificator.txt', 'r') as classificator_file:
classificator_file_str = classificator_file.read()
types_file_str = ''
... | rokuz/omim | kml/pykmlib/bindings_test.py | Python | apache-2.0 | 4,094 | 0.004272 |
m = [2]
for i in range(int(input())-1):
m.append(int(3*m[i]/2))
print(sum(m)) | vipmunot/HackerRank | Algorithms/Viral Advertising.py | Python | mit | 81 | 0.012346 |
# (c) Nelen & Schuurmans. GPL licensed, see LICENSE.rst.
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from __future__ import print_function
import logging
import requests
logger = logging.getLogger(__name__)
def collect_filters(url):
"""Return filters from FEWS, cleaned and ready for storing... | lizardsystem/lizard-fewsapi | lizard_fewsapi/collect.py | Python | gpl-3.0 | 1,482 | 0 |
if dest.lower()=='footballbot': dest=origin
par=' '.join(params).lower()
if len(par) < 10 and par.count('is') == 0 and par.count('?') == 0 and par.count('will') == 0 and par.count('should') == 0 and par.count('could') == 0 and par.count('do') == 0 and par.count('has') == 0 and par.count('does') == 0 and par.count('when... | epmatsw/FootballBot | fxns/8ball.py | Python | cc0-1.0 | 986 | 0.037525 |
# Copyright (c) 2012 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.
import logging
import os
import time
import traceback
import urlparse
import random
import csv
from chrome_remote_control import page_test
from chrome_re... | junmin-zhu/chromium-rivertrail | tools/chrome_remote_control/chrome_remote_control/page_runner.py | Python | bsd-3-clause | 6,385 | 0.01112 |
import cv2
import skimage.data
import instance_occlsegm_lib
def test_resize():
for interpolation in [cv2.INTER_NEAREST, cv2.INTER_LINEAR]:
_test_resize(interpolation)
def _test_resize(interpolation):
img = skimage.data.astronaut()
H_dst, W_dst = 480, 640
ret = instance_occlsegm_lib.image.r... | start-jsk/jsk_apc | demos/instance_occlsegm/tests/image_tests/test_resize.py | Python | bsd-3-clause | 1,334 | 0 |
BREADABILITY_AVAILABLE = True
try:
from breadability.readable import Article, prep_article, check_siblings
except ImportError:
BREADABILITY_AVAILABLE = False
Article = object
from operator import attrgetter
from werkzeug.utils import cached_property
import re
from lxml.etree import tounicode, tostring
... | denz/swarm-crawler | swarm_crawler/text.py | Python | bsd-3-clause | 2,172 | 0.005525 |
# -*- coding: utf-8 -*-
import pytest
import mock
from apispec import APISpec, Path
from apispec.exceptions import PluginError, APISpecError
description = 'This is a sample Petstore server. You can find out more '
'about Swagger at <a href=\"http://swagger.wordnik.com\">http://swagger.wordnik.com</a> '
'or on irc.f... | gorgias/apispec | tests/test_core.py | Python | mit | 13,849 | 0.000939 |
#!usr/bin/env python
# -*- coding: utf-8 -*-
"""
@author magic
"""
import urllib2
def download(url, user_agent='wswp', num_retries=2):
print 'Downloading:', url
headers = {'User-Agent': user_agent}
request = urllib2.Request(url, headers=headers)
try:
html = urllib2.urlopen(request).read()
... | csunny/blog_project | source/libs/spider/common.py | Python | mit | 694 | 0.001441 |
from django.conf.urls import patterns, include, url
from settings import STATIC_ROOT, GRAPHITE_API_PREFIX, CONTENT_DIR
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns(
'',
# These views are needed for the django-rest-framew... | ceph/calamari-clients | utils/urls.py | Python | mit | 3,135 | 0.00319 |
from __future__ import unicode_literals
from copy import copy
import difflib
import errno
from functools import wraps
import json
import os
import re
import sys
import select
import socket
import threading
import unittest
from unittest import skipIf # Imported here for backward compatibility
from unittest.util... | makinacorpus/django | django/test/testcases.py | Python | bsd-3-clause | 49,061 | 0.002242 |
""" Helper for the CS Resources section
"""
import re
from distutils.version import LooseVersion #pylint: disable=no-name-in-module,import-error
from DIRAC import S_OK, S_ERROR, gConfig
from DIRAC.ConfigurationSystem.Client.Helpers.Path import cfgPath
from DIRAC.Core... | hgiemza/DIRAC | ConfigurationSystem/Client/Helpers/Resources.py | Python | gpl-3.0 | 10,846 | 0.043426 |
# Define here the models for your scraped items
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/items.html
from scrapy.item import Item, Field
class WorkabroadItem(Item):
# define the fields for your item here like:
# name = Field()
pass
class PostItem(Item):
href = Field()
id ... | staceytay/workabroad-scraper | workabroad/items.py | Python | mit | 490 | 0.004082 |
#!/bin/env python3.4
# -*- coding: UTF-8 -*-
import simocracy.wiki as wiki
import re
## config ##
#Möglichkeit zur Simulation des Vorgangs
simulation = False
#Loglevel: schreibe nur geänderte Zeilen ("line") oder
# ganze geänderte Artikel ("article") auf stdin oder
# gar nicht ("none")
loglevel = "... | Simocracy/simocraPy | simocracy/ldhost.py | Python | gpl-2.0 | 2,714 | 0.006275 |
# -*- coding: utf-8 -*-
import os
import unittest
import inotify.constants
import inotify.calls
import inotify.adapters
import inotify.test_support
try:
unicode
except NameError:
_HAS_PYTHON2_UNICODE_SUPPORT = False
else:
_HAS_PYTHON2_UNICODE_SUPPORT = True
class TestInotify(unittest.TestCase):
def... | dsoprea/PyInotify | tests/test_inotify.py | Python | gpl-2.0 | 17,960 | 0.003905 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.