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 |
|---|---|---|---|---|---|---|
"""
HTTP handeler to serve specific endpoint request like
http://myserver:9004/endpoints/mymodel
For how generic endpoints requests is served look
at endpoints_handler.py
"""
import json
import logging
import shutil
from tabpy.tabpy_server.common.util import format_exception
from tabpy.tabpy_server.handlers import Ma... | tableau/TabPy | tabpy/tabpy_server/handlers/endpoint_handler.py | Python | mit | 4,926 | 0.001015 |
"""
This defines the cmdset for the red_button. Here we have defined
the commands and the cmdset in the same module, but if you
have many different commands to merge it is often better
to define the cmdset separately, picking and choosing from
among the available commands as to what should be included in the
cmdset - t... | jamesbeebop/evennia | evennia/contrib/tutorial_examples/cmdset_red_button.py | Python | bsd-3-clause | 9,705 | 0.001443 |
# Generated by h2py from /usr/include/netinet/in.h
# Included from sys/feature_tests.h
# Included from sys/isa_defs.h
_CHAR_ALIGNMENT = 1
_SHORT_ALIGNMENT = 2
_INT_ALIGNMENT = 4
_LONG_ALIGNMENT = 8
_LONG_LONG_ALIGNMENT = 8
_DOUBLE_ALIGNMENT = 8
_LONG_DOUBLE_ALIGNMENT = 16
_POINTER_ALIGNMENT = 8
_MAX_ALIGNMENT = 16
_A... | xbmc/xbmc-antiquated | xbmc/lib/libPython/Python/Lib/plat-sunos5/IN.py | Python | gpl-2.0 | 28,151 | 0.005044 |
# from test_plus.test import TestCase
#
#
# class TestUser(TestCase):
#
# def setUp(self):
# self.user = self.make_user()
#
# def test__str__(self):
# self.assertEqual(
# self.user.__str__(),
# 'testuser' # This is the default username for self.make_user()
# )
#
... | Alex-Just/gymlog | gymlog/main/tests/test_models.py | Python | mit | 476 | 0 |
#/usr/bin/env python
import codecs
import os
import sys
from setuptools import setup, find_packages
if 'publish' in sys.argv:
os.system('python setup.py sdist upload')
sys.exit()
read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read()
# Dynamically calculate the version based on galeria.VERSIO... | zokeber/django-galeria | setup.py | Python | bsd-3-clause | 1,378 | 0.002177 |
# Copyright 2012-2013 Red Hat, 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... | rackerlabs/instrumented-ceilometer | ceilometer/openstack/common/rpc/proxy.py | Python | apache-2.0 | 9,444 | 0 |
from __future__ import unicode_literals
from datetime import date
from django.contrib.auth import (
BACKEND_SESSION_KEY, SESSION_KEY, authenticate, get_user,
)
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.hashers import MD5PasswordHasher
from django.contrib.auth.models import Ano... | varunnaganathan/django | tests/auth_tests/test_auth_backends.py | Python | bsd-3-clause | 25,359 | 0.001814 |
# -*- coding: utf-8 -*-
"""Page model for Cloud Intel / Reports / Dashboards"""
from navmazing import NavigateToAttribute, NavigateToSibling
from widgetastic.widget import Text, Checkbox
from widgetastic_manageiq import SummaryFormItem, DashboardWidgetsPicker
from widgetastic_patternfly import Button, Input
from utils... | dajohnso/cfme_tests | cfme/intelligence/reports/dashboards.py | Python | gpl-2.0 | 10,188 | 0.001276 |
# The plot server must be running
# Go to http://localhost:5006/bokeh to view this plot
from collections import OrderedDict
from math import log, sqrt
import numpy as np
import pandas as pd
from six.moves import cStringIO as StringIO
from bokeh.plotting import figure, show, output_server
antibiotics = """
bacteria,... | akloster/bokeh | examples/plotting/server/burtin.py | Python | bsd-3-clause | 4,826 | 0.005387 |
#!/usr/bin/env python
#
# Copyright (c) 2009, Roboterclub Aachen e.V.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# ... | chrism333/xpcc | scons/site_tools/system_design.py | Python | bsd-3-clause | 7,787 | 0.038012 |
from sacred import Experiment
ex = Experiment('my_commands')
@ex.config
def cfg():
name = 'kyle'
@ex.command
def greet(name):
print('Hello {}! Nice to greet you!'.format(name))
@ex.command
def shout():
print('WHAZZZUUUUUUUUUUP!!!????')
@ex.automain
def main():
print('This is just the main comma... | zzsza/TIL | python/sacred/my_command.py | Python | mit | 345 | 0.002899 |
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 7 14:53:55 2016
@author: nu
"""
import numpy as np
import timeit, os, sys
from astropy.coordinates import SkyCoord
from astropy.table import Column
from astroquery.vizier import Vizier
from astropy import units as u
from TAROT_PL import TarotPIP
from Filter_data import ... | Noysena/TAROT | SFile.py | Python | gpl-3.0 | 8,161 | 0.010538 |
"""alter database for mysql compatibility
Revision ID: 9be372ec38bc
Revises: 4328f2c08f05
Create Date: 2020-02-16 15:43:35.276655
"""
from alembic import op
import sqlalchemy as sa
from docassemble.webapp.database import dbtableprefix, dbprefix, daconfig
import sys
# revision identifiers, used by Alembic.
revision =... | jhpyle/docassemble | docassemble_webapp/docassemble/webapp/alembic/versions/9be372ec38bc_alter_database_for_mysql_compatibility.py | Python | mit | 3,895 | 0.001284 |
# -*- coding: utf-8 -*-
##############################################################################
#
# This file is part of CampOS Event,
# an Odoo module.
#
# Copyright (c) 2015 Stein & Gabelgaard ApS
# http://www.steingabelgaard.dk
# Hans Henrik Gaelgaard
... | sl2017/campos | campos_event/__openerp__.py | Python | agpl-3.0 | 3,874 | 0.001807 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# IkaLog
# ======
# Copyright (C) 2015 Takeshi HASEGAWA
#
# 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/l... | hasegaw/IkaLog | ikalog/inputs/win/directshow.py | Python | apache-2.0 | 4,592 | 0.000436 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 OpenStack LLC.
# 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/LICEN... | genius1611/Keystone | keystone/contrib/extensions/admin/__init__.py | Python | apache-2.0 | 1,232 | 0.000812 |
# -*- coding: utf-8 -*-
import netaddr
from opinel.utils.aws import get_name
from opinel.utils.globals import manage_dictionary
from opinel.utils.fs import load_data, read_ip_ranges
from AWSScout2.utils import ec2_classic, get_keys
from AWSScout2.configs.regions import RegionalServiceConfig, RegionConfig
from AWSSc... | SecurityFTW/cs-suite | tools/Scout2/AWSScout2/services/vpc.py | Python | gpl-3.0 | 7,331 | 0.005866 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('organizations', '0002_migrate_locations_to_facilities'),
('notifications', '0003_auto_20150912_2049'),
]
operations = [
... | alper/volunteer_planner | notifications/migrations/0004_auto_20151003_2033.py | Python | agpl-3.0 | 847 | 0.001181 |
#__author__ = 'hello'
# -*- coding: cp936 -*-
import re
import os
import random
import json
import string
import ctypes
from myexception import *
PATH = './img/'
dm2 = ctypes.WinDLL('./CrackCaptchaAPI.dll')
if not os.path.exists('./img'):
os.mkdir('./img')
def str_tr(content):
instr = "0123456789"
outs... | dading/iphone_order | util.py | Python | apache-2.0 | 3,365 | 0.012184 |
class Solution(object):
def findPaths(self, m, n, N, i, j):
"""
:type m: int
:type n: int
:type N: int
:type i: int
:type j: int
:rtype: int
"""
MOD = 1000000007
paths = 0
cur = {(i, j): 1}
for i in xrange(N):
... | zqfan/leetcode | algorithms/576. Out of Boundary Paths/solution.py | Python | gpl-3.0 | 918 | 0 |
# -*- coding: ISO-8859-1 -*-
# Copyright 2010 Dirk Holtwick, holtwick.it
#
# 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... | rcucui/Pisa-util-fix | sx/pisa3/pisa_util.py | Python | apache-2.0 | 26,330 | 0.006077 |
#!/usr/bin/python
import sys, os, re
import json
import argparse
import pprint
arg_parser = argparse.ArgumentParser(description='Define tests')
arg_parser.add_argument('-p', '--pretty-print', action="store_true", help="select human friendly output, default is CSV")
arg_parser.add_argument('-i', '--info', action="stor... | bigfootproject/OSMEF | data_processing/aggregate_old.py | Python | apache-2.0 | 4,348 | 0.00483 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Update HTPC Manager from Github. Either through git command or tarball.
Updater and SourceUpdater written by styxit
https://github.com/styxit
Git updater written by mbw2001
https://github.com/mbw2001
Used as reference:
- https://github.com/mrkipling/maraschino
- htt... | Dahlgren/HTPC-Manager | htpc/updater.py | Python | mit | 21,554 | 0.002366 |
from django.conf import settings
from django.contrib import auth
from django.contrib.auth.forms import AuthenticationForm
from django.utils.decorators import method_decorator
from django.utils.http import is_safe_url
from django.views.decorators.debug import sensitive_post_parameters
from django.views import generic
fr... | neuroticnerd/django-demo-app | django_demo/accounts/views.py | Python | mit | 1,886 | 0 |
#!/usr/bin/python2
# -*- encoding: utf-8 -*-
#pylint: disable=W0105
import argparse
import logging
import configparser
import requests
from libpydhcpserver.dhcp import DHCPServer
class PBAADHCPServer(DHCPServer):
def __init__(
self, server_address, server_port, client_port, aaserver_addr,
... | lcy0321/pbaadhcpserver | pbaadhcpserver.py | Python | gpl-3.0 | 15,974 | 0.00144 |
def find_number(x):
str_x = str(x)
if len(str_x) == 1:
raise Exception()
left_most = str_x[0]
try:
small_from_rest = find_number(int(str_x[1:]))
return int(left_most + str(small_from_rest))
except:
# min() will throw exception if parameter is empty list, meaning no d... | danithaca/berrypicking | python/excercise/march31.py | Python | gpl-2.0 | 644 | 0.007764 |
# -*- coding: utf-8 -*-
#
# Picard, the next-generation MusicBrainz tagger
#
# Copyright (C) 2019-2020 Philipp Wolfer
#
# 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 version 2
# of the... | Sophist-UK/Sophist_picard | test/formats/test_asf.py | Python | gpl-2.0 | 6,957 | 0.00115 |
# -*- encoding: 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 G... | ttfseiko/openerp-trunk | openerp/addons/account_asset/account_asset.py | Python | agpl-3.0 | 29,177 | 0.008568 |
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from gaegraph.business_base import NodeSearch, DeleteNode
from classificacaodtm_app.commands import ListClassificacaodtmCommand, SaveClassificacaodtmCommand, UpdateClassificacaodtmCommand, \
ClassificacaodtmPublicForm, Classificacaodtm... | andersonsilvade/5semscript | Projeto/backend/apps/classificacaodtm_app/facade.py | Python | mit | 2,641 | 0.004165 |
"""!
@brief Test templates for K-Means clustering module.
@authors Andrei Novikov ([email protected])
@date 2014-2020
@copyright BSD-3-Clause
"""
from pyclustering.tests.assertion import assertion
from pyclustering.cluster.encoder import type_encoding, cluster_encoder
from pyclustering.cluster.... | annoviko/pyclustering | pyclustering/cluster/tests/kmeans_templates.py | Python | gpl-3.0 | 5,793 | 0.008113 |
import numpy as np
from shesha.util.writers.common import dm
from shesha.util.writers.common import wfs
from shesha.util.writers.common import imat
from astropy.io import fits
def wfs_to_fits_hdu(sup, wfs_id):
"""Return a fits Header Data Unit (HDU) representation of a single WFS
Args:
sup : (compasSS... | ANR-COMPASS/shesha | shesha/util/writers/common/fits.py | Python | gpl-3.0 | 5,305 | 0.00754 |
"""
Compute WordVectors using Yelp Data
"""
from gensim.models.word2vec import Word2Vec
from util.language import detect_language, tokenize_text
from data_handling import get_reviews_data
# Set to true for zero in in English reviews. Makes the process much slower
FILTER_ENGLISH = True
# Name for output w2v model file
... | lukedeo/fancy-cnn | datasets/yelp/yelp_w2v.py | Python | mit | 1,086 | 0.003683 |
# Django settings for python project.
DEBUG = True
import logging
LOG_LEVEL = logging.INFO
if DEBUG:
LOG_LEVEL = logging.DEBUG
logging.basicConfig(
level = LOG_LEVEL,
format = '[%(asctime)s %(name)s %(levelname)s] %(message)s',
)
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain... | GdZ/scriptfile | software/googleAppEngine/lib/PyAMF/doc/tutorials/examples/actionscript/bytearray/python/settings.py | Python | mit | 2,999 | 0.003334 |
"""
information needed
- path to FASTQ
- path to reference genome
- path to indexed reference genome
- read number (1/2)
- restriction enzyme used
- species name
- chromosome names (optional)
- descriptive fields (optional, e.g. --descr=flowcell:C68AEACXX,lane:4,index:24nf)
mapping strategy
- iterative/fra... | 3DGenomes/tadbit | _pytadbit/tools/tadbit_map.py | Python | gpl-3.0 | 26,222 | 0.00492 |
# Copyright 2022, 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 | compressed_communication/aggregators/comparison_methods/one_bit_sgd_test.py | Python | apache-2.0 | 8,373 | 0.00203 |
#!/usr/bin/python
import sys
import requests
try:
url = sys.argv[1]
r = requests.get('http://%s' %url ,timeout=3)
except requests.exceptions.Timeout:
print 'url timeout\n%s' %url
sys.exit(2)
except:
print 'url error \n%s' %url
sys.exit(2)
url_status = r.status_code
if ... | XiaJieCom/change | document/Service/nagios/nrpe/check_url.py | Python | lgpl-2.1 | 489 | 0.03272 |
# CTCI 1.3
# URLify
import unittest
# My Solution
#-------------------------------------------------------------------------------
# CTCI Solution
def urlify(string, length):
'''function replaces single spaces with %20 and removes trailing spaces'''
new_index = len(string)
for i in reversed(range(leng... | kyle8998/Practice-Coding-Questions | CTCI/Chapter1/1.3-URLify.py | Python | unlicense | 1,208 | 0.005795 |
# System imports
import os
from os.path import join
import pytest
from git import *
from PyGitUp.git_wrapper import RebaseError
from PyGitUp.tests import basepath, write_file, init_master, update_file, testfile_name
test_name = 'rebase_error'
repo_path = join(basepath, test_name + os.sep)
def setup():
master_pa... | msiemens/PyGitUp | PyGitUp/tests/test_rebase_error.py | Python | mit | 1,166 | 0.001715 |
#!/usr/bin/env python
#! -*- coding: utf-8 -*-
from gi.repository import Cld
from gi.repository import DcsCore as dc
from gi.repository import DcsUI as du
from gi.repository import Gtk
class DcsExample(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="DCS Example")
config = Cld.X... | open-dcs/dcs | examples/python/ui.py | Python | mit | 1,007 | 0.004965 |
#!/usr/bin/python
import io
import os
import unittest
import logging
import uuid
from mediafire import MediaFireApi, MediaFireUploader, UploadSession
from mediafire.uploader import UPLOAD_SIMPLE_LIMIT_BYTES
APP_ID = '42511'
MEDIAFIRE_EMAIL = os.environ.get('MEDIAFIRE_EMAIL')
MEDIAFIRE_PASSWORD = os.environ.get('MEDI... | MediaFire/mediafire-python-open-sdk | tests/test_smoke.py | Python | bsd-2-clause | 2,879 | 0.000347 |
from __future__ import print_function
from __future__ import absolute_import
# System modules
import argparse
import sys
import multiprocessing
import os
import textwrap
# Third-party modules
# LLDB modules
from . import configuration
class ArgParseNamespace(object):
pass
def parse_args(parser, argv):
""... | youtube/cobalt | third_party/llvm-project/lldb/packages/Python/lldbsuite/test/dotest_args.py | Python | bsd-3-clause | 13,110 | 0.002517 |
#!/usr/bin/env python
#
# Copyright 2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
#
from gnuradio import gr
from gnuradio import blocks
from gnuradio import filter
from gnuradio import analog
from gnuradio import audio
from gnuradio.filter import... | mbr0wn/gnuradio | gr-analog/examples/fm_demod.py | Python | gpl-3.0 | 2,750 | 0.003273 |
from atlas_web import app
app.run(debug=True) | RDCEP/atlas-viewer | run.py | Python | apache-2.0 | 45 | 0.022222 |
#!/usr/bin/env python
import argparse, subprocess, json, os, sys, base64, binascii, time, hashlib, re, copy, textwrap, logging
try:
from urllib.request import urlopen # Python 3
except ImportError:
from urllib2 import urlopen # Python 2
#DEFAULT_CA = "https://acme-staging.api.letsencrypt.org"
DEFAULT_CA = "htt... | FuzzyHobbit/acme-tiny | acme_tiny.py | Python | mit | 9,077 | 0.004407 |
#-------------------------------------------------------------------------------
#
# Define standard Enable 'control' components, like text/image labels,
# push buttons, radio buttons, check boxes, and so on.
#
# Written by: David C. Morrill
#
# Date: 10/10/2003
#
# (c) Copyright 2003 by Enthought, Inc.
#
# Class... | tommy-u/enable | enable/controls.py | Python | bsd-3-clause | 22,474 | 0.02207 |
import _plotly_utils.basevalidators
class BordercolorValidator(_plotly_utils.basevalidators.ColorValidator):
def __init__(
self, plotly_name="bordercolor", parent_name="sankey.hoverlabel", **kwargs
):
super(BordercolorValidator, self).__init__(
plotly_name=plotly_name,
... | plotly/plotly.py | packages/python/plotly/plotly/validators/sankey/hoverlabel/_bordercolor.py | Python | mit | 482 | 0.002075 |
"""App related signal handlers."""
import redis
from django.conf import settings
from django.db.models import signals
from django.dispatch import receiver
from modoboa.admin import models as admin_models
from . import constants
def set_message_limit(instance, key):
"""Store message limit in Redis."""
old_... | modoboa/modoboa | modoboa/policyd/handlers.py | Python | isc | 1,435 | 0 |
# Copyright 2019 Tecnativa - David
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
from odoo import SUPERUSER_ID, api
_logger = logging.getLogger(__name__)
def pre_init_hook(cr):
"""Speed up the installation of the module on an existing Odoo instance"""
cr.execute(
""... | OCA/stock-logistics-workflow | stock_return_request/hooks.py | Python | agpl-3.0 | 3,276 | 0.001526 |
# -*- coding:utf8 -*-
from scrapy import Request
from scrapy.spiders import CrawlSpider, Rule
from scrapy.linkextractors import LinkExtractor
from scrapy.loader.processors import Join
from scrapy.loader import ItemLoader
from scrapy.selector import HtmlXPathSelector, Selector
from zadolbali.items import StoryItem
cla... | alexeyqu/zadolbali_corpus | crawler/zadolbali/zadolbali/spiders/stories.py | Python | mit | 1,809 | 0.006081 |
# Copyright 2012, 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.
"""VTGateCursor, and StreamVTGateCursor."""
import itertools
import operator
import re
from vtdb import base_cursor
from vtdb import dbexceptions
write_sql_pattern... | theskyinflames/bpulse-go-client | vendor/github.com/youtube/vitess/py/vtdb/vtgate_cursor.py | Python | apache-2.0 | 9,742 | 0.005646 |
import sys,os, pickle, numpy, pylab, operator, itertools
import cv2
from shutil import copy as copyfile
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import matplotlib.pyplot as plt
from DataParseApp import dataparseDialog
from sklearn.decomposition import NMF
projectpath=os.path.split(os.path.abspath(__file__)... | johnmgregoire/JCAPRamanDataProcess | PlateAlignViaEdge_v4.py | Python | bsd-3-clause | 16,899 | 0.016214 |
"""Tests for control_flow_ops.py."""
import tensorflow.python.platform
from tensorflow.core.framework import graph_pb2
from tensorflow.python.framework import ops
from tensorflow.python.framework.test_util import TensorFlowTestCase
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import st... | liyu1990/tensorflow | tensorflow/python/ops/control_flow_ops_test.py | Python | apache-2.0 | 3,164 | 0.006953 |
#!/usr/bin/python3
'''
This is a * sort * of static method but is ugly since the
function is really global and not in the class.
'''
class Book:
num = 0
def __init__(self, price):
self.__price = price
Book.num += 1
def printit(self):
print('price is', self.__price)
def setP... | nonZero/demos-python | src/examples/short/object_oriented/static_method_1.py | Python | gpl-3.0 | 881 | 0.001135 |
# -*- coding: utf-8 -*-
import bot
import time
"""
load irc/auth/nickserv
nickserv set password hunter2
config set modules.nickserv.enabled True
config set modules.nickserv.ghost True
nickserv register [email protected]
nickserv verify register myaccount c0d3numb3r
nickserv identify
"""
class M_NickServ(bot.Module):
... | shacknetisp/vepybot | plugins/protocols/irc/auth/nickserv.py | Python | mit | 4,789 | 0.000418 |
#!/usr/bin/env python2.7
# Copyright (c) 2014-2016 Marcello Salvati
#
# 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 version 3 of the
# License, or (at your option) any later version.
#... | zhuyue1314/MITMf | plugins/BeefAutorun.py | Python | gpl-3.0 | 3,993 | 0.022039 |
import logging
from abc import abstractmethod, ABCMeta
from urllib import request
class UrlShortener(metaclass=ABCMeta):
@abstractmethod
def shorten(self, url: str) -> str:
pass
def log(self, url):
logging.info("Short URL: {}".format(url))
class Off(UrlShortener):
def shorten(self, ... | instantshare/instantshare | src/tools/shorturl.py | Python | gpl-2.0 | 726 | 0.001377 |
"""
Django settings for cadasta project.
Generated by 'django-admin startproject' using Django 1.8.6.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build path... | Cadasta/cadasta-platform | cadasta/config/settings/default.py | Python | agpl-3.0 | 17,780 | 0 |
"""
Base class for all nodes in the scene graph. It is implemented
using the composite pattern.
Responsibilities:
- Hold the relative position to its parent.
- Blit itself on the parent.
- Dirty flag itself to trigger regeneration of surface.
"""
class Component(object):
def __init__(self):
self._position... | sirmar/tetris | tetris/visibles/component.py | Python | mit | 1,102 | 0.002722 |
from Bio import Entrez
from Bio import SeqIO
from Bio import Seq
from Bio.Alphabet import IUPAC
genomes = ["Escherichia coli str. K-12 substr. MC4100 complete genome","Escherichia coli Nissle 1917, complete genome","Escherichia coli LY180, complete genome"]
genomes_short = ["K12","Nissle","LY180"]
for n,genome in enu... | gditzler/bio-course-materials | blast/get_seq.py | Python | gpl-3.0 | 1,093 | 0.014639 |
from pylons_common.lib.log import create_logger
from pylons_common.lib.utils import pluralize
logger = create_logger('pylons_common.lib.datetime')
from datetime import datetime, timedelta
DATE_FORMAT_ACCEPT = [u'%Y-%m-%d %H:%M:%S', u'%Y-%m-%d %H:%M:%SZ', u'%Y-%m-%d', u'%m-%d-%Y', u'%m/%d/%Y', u'%m.%d.%Y', u'%b %d, %... | benogle/pylons_common | pylons_common/lib/date.py | Python | mit | 3,799 | 0.010266 |
#
# This file contains functions and constants to talk
# to and from a Novation Launchpad via MIDI.
#
# Created by paul for mididings.
from mididings import *
# MEASURES - constants useful for the Pad
side = list(range(0, 8))
longside = list(range(0, 9))
step = 16 # vertical gap on pad
FirstCtrl = 104 # ctrl o... | m4773rcl0ud/launchpaddings | launchpad_utils.py | Python | gpl-3.0 | 4,442 | 0.00045 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
# Copyright (C) 2017 Francisco Acosta <[email protected]>
# 2017 Freie Universität Berlin
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# d... | mfrey/RIOT | tests/xtimer_usleep/tests/01-run.py | Python | lgpl-2.1 | 2,231 | 0.001345 |
from flask import g
import re
from sqlalchemy import and_
from sqlalchemy.orm.exc import NoResultFound
from newparp.model import (
CharacterTag,
Tag,
)
special_char_regex = re.compile("[\\ \\./]+")
underscore_strip_regex = re.compile("^_+|_+$")
def name_from_alias(alias):
# 1. Change to lowercase.
#... | MSPARP/newparp | newparp/helpers/tags.py | Python | agpl-3.0 | 1,613 | 0 |
from django.db import models
from django.test import TestCase
from .models import (
Book, Car, CustomManager, CustomQuerySet, DeconstructibleCustomManager,
FastCarAsBase, FastCarAsDefault, FunPerson, OneToOneRestrictedModel,
Person, PersonFromAbstract, PersonManager, PublishedBookManager,
RelatedModel,... | nesdis/djongo | tests/django_tests/tests/v22/tests/custom_managers/tests.py | Python | agpl-3.0 | 25,648 | 0.001716 |
def hello_world():
"Function that says hello."
print("Hello, world!")
| evanmiltenburg/python-for-text-analysis | Extra_Material/Examples/Separate_Files/main_dir_script.py | Python | apache-2.0 | 78 | 0 |
#!/usr/bin/env python
from runtest import TestBase
class TestCase(TestBase):
def __init__(self):
TestBase.__init__(self, 'abc', """
# DURATION TID FUNCTION
62.202 us [28141] | __cxa_atexit();
[28141] | main() {
[28141] | a() {
[28141] | b() {
... | namhyung/uftrace | tests/t001_basic.py | Python | gpl-2.0 | 530 | 0.001887 |
# -*- coding: utf8 -*-
"""
The ``dbs`` module
===================
Contain all functions to access to main site db or any sql-lite db, in a secure way
"""
import sqlalchemy
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.sql import join
__all__ = ['... | salas106/lahorie | lahorie/utils/sql.py | Python | mit | 886 | 0.002257 |
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible import __version__
from ansible.errors import AnsibleError
from distutils.version import LooseVersion
from operator import eq, ge, gt
from sys import version_info
try:
from __main__ ... | jeffstieler/bedrock-ansible | lib/trellis/plugins/vars/version.py | Python | mit | 2,048 | 0.007324 |
from gasistafelice.rest.views.blocks.base import BlockWithList
from django.utils.translation import ugettext as _, ugettext_lazy as _lazy
#------------------------------------------------------------------------------#
# #
#------------------... | OrlyMar/gasistafelice | gasistafelice/rest/views/blocks/account_state.py | Python | agpl-3.0 | 3,887 | 0.009262 |
import unittest
import os
from test.aiml_tests.client import TestClient
from programy.config.brain import BrainFileConfiguration
class BasicTestClient(TestClient):
def __init__(self):
TestClient.__init__(self)
def load_configuration(self, arguments):
super(BasicTestClient, self).load_configur... | dkamotsky/program-y | src/test/aiml_tests/person_tests/test_person_aiml.py | Python | mit | 904 | 0.005531 |
#!/usr/bin/python
########################################################################
# 1 August 2014
# Patrick Lombard, Centre for Stem Stem Research
# Core Bioinformatics Group
# University of Cambridge
# All right reserved.
########################################################################
import pychip... | pdl30/pychiptools | scripts/pychip_diff_bind.py | Python | gpl-2.0 | 376 | 0 |
from flask import request
from flask_restplus import Resource
from skf.api.security import security_headers, validate_privilege
from skf.api.checklist_category.business import update_checklist_category
from skf.api.checklist_category.serializers import checklist_type_update, message
from skf.api.kb.parsers import autho... | blabla1337/skf-flask | skf/api/checklist_category/endpoints/checklist_category_update.py | Python | agpl-3.0 | 1,240 | 0.003226 |
# -*- coding: utf-8 -*-
#
# Module providing the `Pool` class for managing a process pool
#
# multiprocessing/pool.py
#
# Copyright (c) 2006-2008, R Oudkerk
# Licensed to PSF under a Contributor Agreement.
#
from __future__ import absolute_import
#
# Imports
#
import errno
import itertools
import os
import platform
i... | flaviogrossi/billiard | billiard/pool.py | Python | bsd-3-clause | 64,479 | 0 |
# coding: utf-8
# numpy_utils for Intro to Data Science with Python
# Author: Kat Chuang
# Created: Nov 2014
# --------------------------------------
import numpy
## Stage 2 begin
fieldNames = ['', 'id', 'priceLabel', 'name','brandId', 'brandName', 'imageLink',
'desc', 'vendor', 'patterned', 'materi... | katychuang/python-data-sci-basics | src/numpy_utils.py | Python | mit | 3,188 | 0.016311 |
# -*- coding: utf-8 -*-
"""
Basic unit tests
"""
from __future__ import print_function
import os
import glob
import datetime
import json
import pickle
from pydal._compat import basestring, StringIO, integer_types, xrange, BytesIO, to_bytes
from pydal import DAL, Field
from pydal.helpers.classes import SQLALL, OpR... | web2py/pydal | tests/sql.py | Python | bsd-3-clause | 137,514 | 0.001136 |
"""Placeholder."""
import numpy as np
def rgb_to_hsi(im):
"""Convert to HSI the RGB pixels in im.
Adapted from
https://en.wikipedia.org/wiki/HSL_and_HSV#Hue_and_chroma.
"""
im = np.moveaxis(im, -1, 0)
if len(im) not in (3, 4):
raise ValueError("Expected 3-channel RGB or 4-channel RG... | DigitalSlideArchive/HistomicsTK | histomicstk/preprocessing/color_conversion/rgb_to_hsi.py | Python | apache-2.0 | 725 | 0 |
import LNdigitalIO
def switch_pressed(event):
event.chip.output_pins[event.pin_num].turn_on()
def switch_unpressed(event):
event.chip.output_pins[event.pin_num].turn_off()
if __name__ == "__main__":
LNdigital = LNdigitalIO.LNdigitals()
listener = LNdigitalIO.InputEventListener(chip=LNdigital)
... | LeMaker/LNdigitalIO | examples/presslights.py | Python | gpl-3.0 | 501 | 0 |
from urllib import quote
from django.test import Client
from questionnaire.forms.assign_question import AssignQuestionForm
from questionnaire.models import Questionnaire, Section, SubSection, Question, Region, QuestionGroup
from questionnaire.models.skip_rule import SkipQuestion
from questionnaire.tests.base_test imp... | eJRF/ejrf | questionnaire/tests/views/test_assign_questions_view.py | Python | bsd-3-clause | 13,049 | 0.004598 |
#! /usr/bin/env python3
import mwparserfromhell
from ws.parser_helpers.wikicode import *
class test_get_adjacent_node:
def test_basic(self):
snippet = "[[Arch Linux]] is the best!"
wikicode = mwparserfromhell.parse(snippet)
first = wikicode.get(0)
last = get_adjacent_node(wikicode... | lahwaacz/wiki-scripts | tests/parser_helpers/test_wikicode.py | Python | gpl-3.0 | 18,144 | 0.001488 |
#!/usr/bin/env python
#
# Copyright 2005-2007,2010,2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
# GNU Radio 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, or (at ... | iohannez/gnuradio | gr-filter/python/filter/qa_rational_resampler.py | Python | gpl-3.0 | 8,932 | 0.004478 |
# -*- coding: utf-8 -*-
import common
import sys, os, traceback
import time
import random
import re
import urllib
import string
from string import lower
from entities.CList import CList
from entities.CItemInfo import CItemInfo
from entities.CListItem import CListItem
from entities.CRuleItem import CRuleItem
import c... | Crach1015/plugin.video.superpack | zip/plugin.video.SportsDevil/lib/parser.py | Python | gpl-2.0 | 26,568 | 0.00478 |
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_mapcalc.py
------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
**********************************... | dwadler/QGIS | python/plugins/processing/algs/grass7/ext/r_mapcalc.py | Python | gpl-2.0 | 2,550 | 0.000786 |
# -*-coding:UTF-8 -*
import sqlite3 as sql
import json
from time import time, strftime
import settings
import logging as lgn
lgn.basicConfig(filename = '/db/db.log',level=lgn.DEBUG,\
format='%(asctime)s %(message)s')
def logit(string,*level):
if(len(level) == 0):
lgn.info(string)
else:
if(... | ForgottenBeast/spider_nest | database/utils.py | Python | gpl-3.0 | 2,171 | 0.015661 |
import re
from typing import Container, NamedTuple, Optional, overload
from ..exceptions import LocationParseError
from .util import to_str
# We only want to normalize urls with an HTTP(S) scheme.
# urllib3 infers URLs without a scheme (None) to be http.
_NORMALIZABLE_SCHEMES = ("http", "https", None)
# Almost all o... | urllib3/urllib3 | src/urllib3/util/url.py | Python | mit | 14,809 | 0.000743 |
#!/usr/bin/env python
import argparse
import datetime
import os
import re
import requests
import subprocess
import sys
import time
import xively
DEBUG = os.environ["DEBUG"] or false
def read_temperature(from_file):
if DEBUG:
print "Reading temperature from file: %s" % from_file
temperature = None
with op... | dwc/pi-monitoring | bin/push_temperature.py | Python | mit | 1,946 | 0.018499 |
# Copyright 2015 CloudFounders 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 applicable law or agreed to in writ... | tcpcloud/openvstorage | ovs/extensions/os/__init__.py | Python | apache-2.0 | 644 | 0 |
"""db migration
Revision ID: 373a21295ab
Revises: 21f5b2d3905d
Create Date: 2015-05-05 15:42:33.474470
"""
# revision identifiers, used by Alembic.
revision = '373a21295ab'
down_revision = '21f5b2d3905d'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
def upgrade():
op.dr... | Mytho/groceries-api | db/versions/20150505_154233_373a21295ab_db_migration.py | Python | mit | 1,244 | 0.003215 |
from ..library.base import number_to_list
def solve(bound: int=100):
maximal = 0
for a in range(bound):
for b in range(bound):
sum_digits = sum(number_to_list(a ** b))
if sum_digits > maximal:
maximal = sum_digits
return maximal
| cryvate/project-euler | project_euler/solutions/problem_56.py | Python | mit | 294 | 0.006803 |
# (C) Copyright 2011 Nuxeo SAS <http://nuxeo.com>
# Author: [email protected]
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it wil... | mozilla-services/FunkLoad | src/funkload/ReportRenderOrg.py | Python | gpl-2.0 | 6,127 | 0.003754 |
# -*- encoding: utf-8 -*-
# Module iainfgen
from numpy import *
def iainfgen(f, Iab):
from iaunion import iaunion
from iadil import iadil
from ianeg import ianeg
A, Bc = Iab
y = iaunion( iadil(f, A), iadil( ianeg(f), Bc))
return y
| mariecpereira/IA369Z | deliver/ia870/iainfgen.py | Python | mit | 261 | 0.019157 |
import csv
import rdflib
from rdflib.namespace import RDFS, RDF, OWL
from rdflib.term import URIRef
import threading
from apimarkdown import Markdown
from apirdflib import RDFLIBLOCK
import logging
logging.basicConfig(level=logging.INFO) # dev_appserver.py --log_level debug .
log = logging.getLogger(__name__)
class ... | unor/schemaorg | sdordf2csv.py | Python | apache-2.0 | 11,152 | 0.017755 |
from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
import pybindgen.settings
import warnings
class ErrorHandler(pybindgen.settings.ErrorHandler):
def handle_error(self, wrapper, exception, traceback_):
warnings.warn("exception %r in wrapper %s" % (exception, wrapper))
... | dtaht/ns-3-dev-old | src/network/bindings/modulegen__gcc_LP64.py | Python | gpl-2.0 | 507,731 | 0.015106 |
# Copyright 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.
"""Provides stubs for os, sys and subprocess for testing
This test allows one to test code that itself uses os, sys, and subprocess.
"""
import ntpath
impo... | Bysmyyr/chromium-crosswalk | tools/telemetry/telemetry/testing/system_stub.py | Python | bsd-3-clause | 14,620 | 0.011833 |
#!/usr/bin/env python
#
# kvmexit.py
#
# Display the exit_reason and its statistics of each vm exit
# for all vcpus of all virtual machines. For example:
# $./kvmexit.py
# PID TID KVM_EXIT_REASON COUNT
# 1273551 1273568 EXIT_REASON_MSR_WRITE 6
# 1274253 1274261 EXIT_RE... | brendangregg/bcc | tools/kvmexit.py | Python | apache-2.0 | 12,070 | 0.002237 |
from loguru import logger
import asyncio
from typing import Optional, List, Dict, ClassVar
from pydispatch import Dispatcher, Property
from pydispatch.properties import ListProperty, DictProperty
from vidhubcontrol.common import ConnectionState, ConnectionManager
class BackendBase(Dispatcher):
"""Base class for ... | nocarryr/vidhub-control | vidhubcontrol/backends/base.py | Python | gpl-3.0 | 27,623 | 0.004236 |
from __future__ import unicode_literals
import logging
from xml.dom.minidom import parseString
from django import forms
from django.utils import six
from django.utils.six.moves.urllib.error import HTTPError, URLError
from django.utils.translation import ugettext_lazy as _, ugettext
from reviewboard.hostingsvcs.error... | davidt/reviewboard | reviewboard/hostingsvcs/codebasehq.py | Python | mit | 20,408 | 0.000049 |
from __future__ import generators
from rdflib import BNode
from rdflib.Literal import Literal
from pprint import pprint
from pysqlite2 import dbapi2
import sha,sys,re,os
from rdflib.term_utils import *
from rdflib.Graph import QuotedGraph
from rdflib.store.REGEXMatching import REGEXTerm, NATIVE_REGEX, PYTHON_REGEX
from... | aaronsw/watchdog | vendor/rdflib-2.4.0/rdflib/store/SQLite.py | Python | agpl-3.0 | 18,855 | 0.016547 |
from __future__ import (absolute_import, division, print_function)
import unittest
import os
import testhelpers
from mantid.kernel import (ConfigService, ConfigServiceImpl, config,
std_vector_str, FacilityInfo, InstrumentInfo)
class ConfigServiceTest(unittest.TestCase):
__dirs_to_rm =... | dymkowsk/mantid | Framework/PythonInterface/test/python/mantid/kernel/ConfigServiceTest.py | Python | gpl-3.0 | 4,880 | 0.002459 |
# Wasp: Discrete Design with Grasshopper plug-in (GPL) initiated by Andrea Rossi
#
# This file is part of Wasp.
#
# Copyright (c) 2017, Andrea Rossi <[email protected]>
# Wasp is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the ... | ar0551/Wasp | src/ghComp/Wasp_DisCo Rule Group.py | Python | gpl-3.0 | 3,209 | 0.011218 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations
def update_site_forward(apps, schema_editor):
"""Set site domain and name."""
Site = apps.get_model("sites", "Site")
Site.objects.update_or_create(
id=settings.SITE_ID... | gijigae/django-tutorial | django_tutorial/contrib/sites/migrations/0002_set_site_domain_and_name.py | Python | bsd-3-clause | 949 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.