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 colander
from grano.core import db
from grano.model import Permission
from grano.logic.references import ProjectRef, AccountRef
class PermissionValidator(colander.MappingSchema):
project = colander.SchemaNode(ProjectRef())
account = colander.SchemaNode(AccountRef())
reader = colander.SchemaNode(co... | CodeForAfrica/grano | grano/logic/permissions.py | Python | mit | 1,296 |
#!/usr/bin/python
## @file
## @brief Main file
import ConfigParser
import atexit
import inspect
import logging
import logging.config
import os
import sys
from time import sleep
import pydevd
from pubsub import pub
from schedule import Schedule
@atexit.register
## @fn def clean_exit():
## @brief Cleanup function
##... | Merlin71/Aria | Aria.py | Python | gpl-3.0 | 5,038 |
import random
from templates.text import TextTemplate
def process(input):
howareyou = [
'I\'m amazing, dude!',
'I\'m awesome, dude!'
]
output = {
'input': input,
'output': TextTemplate(random.choice(howareyou)).get_message(),
'success': True
}
return output
| manparvesh/BotDude | modules/src/howareyou.py | Python | mit | 320 |
import sys
import re
from collections import namedtuple
from ascii2graph import graph
from .color import get_color
from .svg import draw_box, draw_line, draw_arrow, embed_svg, get_box_dims
def get_box_center(scale, text, origin):
(x, y) = origin
width, height = get_box_dims(scale, text)
return x + 0.5 * w... | bast/gitink | gitink/main.py | Python | mpl-2.0 | 10,896 |
#-----------------------------------------------------------------------------
# Copyright (c) 2012 - 2017, Anaconda, Inc. All rights reserved.
#
# Powered by the Bokeh Development Team.
#
# The full license is in the file LICENSE.txt, distributed with this software.
#---------------------------------------------... | dennisobrien/bokeh | bokeh/themes/_dark_minimal.py | Python | bsd-3-clause | 2,468 |
"""
Some Python 2 & 3 compatibility code.
"""
import sys
PY3 = sys.version_info[0] == 3
PY26 = sys.version_info[:2] == (2,6)
if PY3:
stringtypes = (bytes, str, )
def int2byte(i):
"""Converts int (0 through 255) into b'...' character."""
return bytes((i,))
def byte2int(b):
"""Con... | gkonstantyno/construct | construct/lib/py3compat.py | Python | mit | 2,194 |
# -*- coding: utf-8 -*-
import pygame
import random
import classes.board
import classes.extras as ex
import classes.game_driver as gd
import classes.level_controller as lc
class Board(gd.BoardGame):
def __init__(self, mainloop, speaker, config, screen_w, screen_h):
self.level = lc.Level(self, mainloop, ... | imiolek-ireneusz/eduActiv8 | game_boards/game006.py | Python | gpl-3.0 | 8,486 |
#!/usr/bin/env python3
##### ##### ##### ##### #### ####
# # # # # # # # # # #### #### # # #
##### #### ##### ##### ##### # # # # ####
# # # # # # # # # # # # #
# # # # # # # # #### # #### # ####
#finds the password of a desired ... | jonDel/pyrarcr | old/pyrarcr-0.2.py | Python | mit | 2,210 |
import os
import time
from collections import deque
import pickle
from baselines.ddpg.ddpg import DDPG
from baselines.ddpg.util import mpi_mean, mpi_std, mpi_max, mpi_sum
import baselines.common.tf_util as U
from baselines import logger
import numpy as np
import tensorflow as tf
from mpi4py import MPI
def train(env... | learnercys/baselines | baselines/ddpg/training.py | Python | mit | 8,411 |
import os
# os.chdir('./ClericPy.github.io')
os.system('python main.py')
os.system(r'git add * -f')
os.system(r'git commit -m "常规更新"')
os.system(r'git push origin master')
os.system('pause')
| ClericPy/ClericPy.github.io | upload.py | Python | gpl-2.0 | 199 |
from django.contrib import admin
from manager.song.models import Song
from .models import Playlist
class SongInline(admin.StackedInline):
model = Song
extra = 5
class PlaylistAdmin(admin.ModelAdmin):
inlines = [SongInline]
list_display = ['name', 'user', 'created_at', 'updated_at']
admin.site.regis... | chaocodes/playlist-manager-django | manager/playlist/admin.py | Python | mit | 348 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | os-cloud-storage/openstack-workload-disaster-recovery | dragon/engine/parameters.py | Python | apache-2.0 | 14,040 |
# Copyright 2012, Tim Bielawa <tbielawa@redhat.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 later... | benjixx/ansible | lib/ansible/plugins/action/pause.py | Python | gpl-3.0 | 6,991 |
# $Id: vms_connect.py,v 1.3 2007/06/10 14:11:58 mggrant Exp $
#
# Xlib.support.vms_connect -- VMS-type display connection functions
#
# Copyright (C) 2000 Peter Liljenberg <petli@ctrl-c.liu.se>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Publ... | nvazquez/Turtlebots | plugins/xevents/Xlib/support/vms_connect.py | Python | mit | 2,122 |
# -*- coding: utf-8 -*-
# (c) 2015 Andreas Motl, Elmyra UG <andreas.motl@elmyra.de>
from kotori.version import __VERSION__
from pyramid.config import Configurator
def main(global_config, **settings):
"""This function returns a Pyramid WSGI application."""
settings['SOFTWARE_VERSION'] = __VERSION__
confi... | daq-tools/kotori | kotori/frontend/app.py | Python | agpl-3.0 | 843 |
import surrealism as s
import unittest
import random
import sys
class SurrealismUnittests(unittest.TestCase):
"""getsentence() unittests"""
def setUp(self):
self.variable_types = ''
if sys.version_info[0] < 3:
# noinspection PyUnresolvedReferences
self.variable_types ... | Morrolan/surrealism | test_surrealism.py | Python | gpl-3.0 | 6,547 |
# -*- coding: utf-8 -*-
# Copyright (C) 2014-present Taiga Agile LLC
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later ver... | taigaio/taiga-back | tests/integration/test_watch_tasks.py | Python | agpl-3.0 | 4,832 |
# Copyright (C) 2017 Leandro Lisboa Penz <lpenz@lpenz.org>
# This file is subject to the terms and conditions defined in
# file 'LICENSE', which is part of this source code package.
'''Collection of reporter classes'''
from collections import OrderedDict
import json
class Reporter(object):
def __init__(self):
... | lpenz/omnilint | container/omnilint/reporters.py | Python | mit | 1,800 |
# --- Day 16: Aunt Sue ---
#
# Your Aunt Sue has given you a wonderful gift, and you'd like to send her a thank you card. However, there's a small
# problem: she signed it "From, Aunt Sue".
#
# You have 500 Aunts named "Sue".
#
# So, to avoid sending the card to the wrong person, you need to figure out which Aunt Sue (... | hubbardgary/AdventOfCode | day16.py | Python | mit | 3,655 |
#!/usr/bin/env python3
__all__ = [
'get_client', 'Client', 'ThriftServer', 'Struct', 'BadEnum', 'Error',
'ApplicationError', 'TransportError', 'SSLPolicy',
]
try:
from thrift.py3.client import get_client, Client
except ImportError:
__all__.remove('Client')
__all__.remove('get_client')
try:
fro... | SergeyMakarenko/fbthrift | thrift/lib/py3/__init__.py | Python | apache-2.0 | 800 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import os
import os.path
import signal
import sys
import time
import tornado
import tornado.web
import tornado.locale
import tornado.ioloop
import tornado.options
import tornado.httpserver
from tornado.options import define, options
try:
import appstack
... | mywaiting/appstack | appstack/applications/application.py | Python | mit | 5,267 |
from typing import Optional
from ray.rllib.utils.annotations import override
from ray.rllib.utils.framework import try_import_torch
from ray.rllib.utils.schedules.schedule import Schedule
from ray.rllib.utils.typing import TensorType
torch, _ = try_import_torch()
class ExponentialSchedule(Schedule):
"""Exponent... | ray-project/ray | rllib/utils/schedules/exponential_schedule.py | Python | apache-2.0 | 1,807 |
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("cases", "0014_auto_20150312_2338")]
operations = [
migrations.AlterField(
model_name="case",
name="modified_by",
field=models.Foreign... | watchdogpolska/poradnia.siecobywatelska.pl | poradnia/cases/migrations/0015_auto_20150312_2340.py | Python | bsd-3-clause | 551 |
#!/usr/bin/python
import numpy as np
from numpy import pi, cos, sin, exp, conj
from warnings import warn
import epg
import time
import sys
import scipy.io
class PulseTrain:
def __init__(self, state_file, T, TE, TR, loss_fun, loss_fun_prime, angles_rad=None, phase_rad=None, verbose=False, step=.01, max_iter=100):... | jtamir/mri-sim-py | TODO/epg-prop_2spin.py | Python | mit | 10,519 |
from bespin.errors import BadOption, MissingPlan
from input_algorithms.spec_base import NotSpecified
class Plan(object):
@classmethod
def find_stacks(kls, configuration, stacks, plan):
if plan in (None, NotSpecified):
raise BadOption("Please specify a plan", available=list(configuration["p... | realestate-com-au/bespin | bespin/operations/plan.py | Python | mit | 829 |
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'panconvert_diag_info.ui'
#
# Created by: PyQt5 UI code generator 5.8.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Information_Dialog(object):
def setupUi(self, Informati... | apaeffgen/PanConvert | source/gui/panconvert_diag_info.py | Python | gpl-3.0 | 2,106 |
#! /usr/bin/env python
"""
Module with the MCMC (``emcee``) sampling for NEGFC parameter estimation.
"""
from __future__ import print_function
__author__ = 'O. Wertz, C. Gomez @ ULg'
__all__ = ['lnprior',
'lnlike',
'mcmc_negfc_sampling',
'chain_zero_truncated',
'show_corner... | henry-ngo/VIP | vip_hci/negfc/mcmc_sampling.py | Python | mit | 39,691 |
import json
import httpretty
import os
from similarweb import SourcesClient
TD = os.path.dirname(os.path.realpath(__file__))
def test_sources_client_has_user_key():
client = SourcesClient("test_key")
assert client.user_key == "test_key"
def test_sources_client_has_base_url():
client = SourcesClient("te... | danwagnerco/similarweb | tests/test_sources_client.py | Python | mit | 57,331 |
"""
Artificial data
===============
Collection of functions to create artificial data.
"""
| tgquintela/ElectionsTools | ElectionsTools/artificial_data/__init__.py | Python | mit | 93 |
#Joshua Pepperman
class Batters:
def __init__(self):
self.batters = []
def __iter__(self):
return iter(self.batters)
def __getitem__(self, key):
return self.batters[key]
def __len__(self):
return len(self.batters)
def indexOf(self, player):
index = 0
for p in self.batters:
if p == player:
r... | jdpepperman/baseballStats | Batters.py | Python | gpl-2.0 | 2,886 |
import time
import numpy
def getDataFromFile(filename):
"""
Return an array with data from a CSV file
"""
data_array = numpy.loadtxt(open(filename,"rb"),delimiter=",",skiprows=1)
output = numpy.ndarray(shape=(numpy.amax(data_array[:,0])+1,
numpy.amax(data_array[:,1... | grungi-ankhfire/curvefit | util.py | Python | mit | 2,780 |
# -*- coding: utf-8 -*-
# EForge project management system, Copyright © 2010, Element43
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWA... | oshepherd/eforge | eforge/vcs/models.py | Python | isc | 2,863 |
# Copyright (c) 2012 OpenStack Foundation
# 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 ... | sajeeshcs/nested_quota_final | nova/compute/resource_tracker.py | Python | apache-2.0 | 36,224 |
'''Trains a simple convnet on the MNIST dataset.
Gets to 99.25% test accuracy after 12 epochs
(there is still a lot of margin for parameter tuning).
16 seconds per epoch on a GRID K520 GPU.
'''
from __future__ import print_function
import keras
from keras.datasets import mnist
from keras.models import Sequential
from... | rsteed11/GAT | gat/scraping/ArabicTextExtractor/DeepMNISTKeras.py | Python | mit | 2,269 |
"""Support for PlayStation 4 consoles."""
import logging
import os
import voluptuous as vol
from pyps4_2ndscreen.ddp import async_create_ddp_endpoint
from pyps4_2ndscreen.media_art import COUNTRIES
from homeassistant.components.media_player.const import (
ATTR_MEDIA_CONTENT_TYPE,
ATTR_MEDIA_TITLE,
MEDIA_T... | joopert/home-assistant | homeassistant/components/ps4/__init__.py | Python | apache-2.0 | 7,078 |
import _plotly_utils.basevalidators
class LenValidator(_plotly_utils.basevalidators.NumberValidator):
def __init__(self, plotly_name="len", parent_name="heatmap.colorbar", **kwargs):
super(LenValidator, self).__init__(
plotly_name=plotly_name,
parent_name=parent_name,
e... | plotly/plotly.py | packages/python/plotly/plotly/validators/heatmap/colorbar/_len.py | Python | mit | 436 |
# The Admin4 Project
# (c) 2013-2014 Andreas Pflug
#
# Licensed under the Apache License,
# see LICENSE.TXT for conditions of usage
from _objects import SchemaObject
from _pgsql import pgQuery
import adm
from wh import xlt, shlexSplit, localTimeMillis
import logger
from _pgsql import quoteIdent, quoteValue
persiste... | andreas-p/admin4 | modPg/Table.py | Python | apache-2.0 | 19,913 |
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 21 10:53:07 2017
@author: asus
"""
import theano
from theano import tensor as T
from theano.tensor.nnet import conv2d
import numpy as np
x=T.ivector('x')
w=T.ivector('w')
w=np.array([1,0,0,1])
w=w.reshape((1,1,2,2))
input=T.tensor4(name='input')
w = theano.shared( np.... | RayleighChen/SummerVac | dou/simple_CNN.py | Python | gpl-2.0 | 493 |
from __future__ import absolute_import
#!/usr/bin/env python
import numpy as np
from nibabel import Nifti1Image
from ..affine import Affine, Rigid
from ..histogram_registration import HistogramRegistration
from .._register import _joint_histogram
from numpy.testing import (assert_array_equal,
... | alexis-roche/nireg | nireg/tests/test_histogram_registration.py | Python | bsd-3-clause | 8,361 |
import json
import re
from base64 import b64decode
from datetime import datetime
from email.utils import mktime_tz, parsedate_tz
class MandrillInbound(object):
def __init__(self, *args, **kwargs):
if not kwargs.get('json') and not kwargs.get('source'):
raise Exception('Mandrill Inbound Error:... | jpadilla/mandrill-inbound-python | mandrill_inbound/__init__.py | Python | mit | 6,411 |
from distutils.core import setup
setup(
name='pyevent',
version='0.0.1',
packages=['pyevent'],
url='https://github.com/andy9775/pyevent',
license='MIT',
author='andy',
author_email='andy9775@gmail.com',
description='A micro event library for python',
)
| andy9775/pyevent | setup.py | Python | mit | 286 |
"""
Source: https://github.com/kerguler/hoppMCMC (01/12/18)
adaptive basin-hopping Markov-chain Monte Carlo for Bayesian optimisation
This is the python (v2.7) implementation of the hoppMCMC algorithm aiming to
identify and sample from the high-probability regions of a posterior
distribution. The algorithm combines t... | asteca/ASteCA | packages/best_fit/DEPRECATED/hopp_DEPRECATED/hoppMCMC.py | Python | gpl-3.0 | 30,000 |
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU... | diogocs1/comps | web/openerp/report/render/__init__.py | Python | apache-2.0 | 1,374 |
import logging
import re
import uuid
from requests.cookies import cookiejar_from_dict
from streamlink import PluginError
from streamlink.cache import Cache
from streamlink.plugin import Plugin, PluginArgument, PluginArguments
from streamlink.plugin.api import useragents, validate
from streamlink.stream import DASHStr... | beardypig/streamlink | src/streamlink/plugins/zattoo.py | Python | bsd-2-clause | 13,444 |
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: OpenDrive Ltda
# Copyright (c) 2013 Opendrive Ltda
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# cons... | kailIII/emaresa | trunk.pe/rent/intervals.py | Python | agpl-3.0 | 2,316 |
#
# The goal for this algorithm is going to be to run a few tests on different market parameters to
# determine what kind of market we are looking at (eg. given a new market)
#
# This will help with short term and long term market analysis, and teach the program what market it is looking
# at. For the user it makes i... | mmilutinovic1313/zipline-with-algorithms | ALGORITHMS/AnalyzeMarket.py | Python | apache-2.0 | 4,190 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
os.environ.setdefault('LANG', 'en_US.UTF-8')
from litchi import settings
def main():
... | 245967906/litchi | utils/startup.py | Python | gpl-3.0 | 762 |
# Copyright (C) 2014 ABRT Team
# Copyright (C) 2014 Red Hat, Inc.
#
# This file is part of faf.
#
# faf 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) ... | abrt/faf | src/pyfaf/actions/addcompathashes.py | Python | gpl-3.0 | 5,960 |
"""
Interfaces and helpers for the virtio_serial ports.
:copyright: 2012 Red Hat Inc.
"""
from __future__ import division
from threading import Thread
from collections import deque
import logging
import os
import random
import select
import socket
import time
import struct
import aexpect
from avocado.core import exc... | ldoktor/avocado-vt | virttest/qemu_virtio_port.py | Python | gpl-2.0 | 44,379 |
#!/usr/bin/env python
'''
find max value in a file
'''
import rsf.api as rsf
import numpy as np
import sys
par = rsf.Par()
verb = par.bool('verb',False) # verbosity flag
Fin = rsf.Input() # input
n1 = Fin.int ("n1")
nn = Fin.size(1); # number of traces
din = np.zeros(n1,'f')
Fou = rsf.Output() # ou... | zxtstarry/src | user/psava/Mfindmax.py | Python | gpl-2.0 | 741 |
import numpy as np
from numpy import linalg as LA
from discreteMarkovChain import markovChain
class randomWalk(markovChain):
"""
A random walk where we move up and down with rate 1.0 in each
state between bounds m and M.
For the transition function to work well, we define some
class variables in... | gvanderheide/discreteMarkovChain | discreteMarkovChain/hitting_time.py | Python | mit | 1,491 |
__author__ = 'wenjusun'
import os
import shutil
from multiprocessing.pool import ThreadPool
from PIL import Image
import time
def get_current_time():
return int(round(time.time()*1000))
class PhotoSelector():
""" copy specified photo to destination"""
def __init__(self,src_folder,dest_folder):
se... | swenker/studio | shijing_img/tools/toolbox/photo_handler.py | Python | apache-2.0 | 3,619 |
#!/usr/bin/env python3
"""Test GAUGE main."""
# Copyright (C) 2015 Brad Cowie, Christopher Lorier and Joe Stringer.
# Copyright (C) 2015 Research and Innovation Advanced Network New Zealand Ltd.
# Copyright (C) 2015--2019 The Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may n... | anarkiwi/faucet | tests/unit/gauge/test_main.py | Python | apache-2.0 | 1,494 |
###
# Copyright (c) 2005, Jeremiah Fincher
# 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 notice,
# this list of conditi... | buildbot/supybot | src/utils/error.py | Python | bsd-3-clause | 1,941 |
from django.conf import settings
from django.core.mail import send_mail
from django.template.loader import render_to_string
from django.utils.translation import ugettext
from .base import BaseBackend
class EmailBackend(BaseBackend):
spam_sensitivity = 2
def can_send(self, user, notice_type, scoping):
... | pinax/pinax-notifications | pinax/notifications/backends/email.py | Python | mit | 1,393 |
import re
from flask import Blueprint, request, render_template
import jinja2
from .models import SystemEvent, SYSLOG_FACILITY, SYSLOG_LEVEL
from mountain.app import app
from mountain.query.parser import QueryParser, ParserError
# Define the blueprint
mod_rsyslog = Blueprint('rsyslog', __name__)
# Syslog specifics
... | tehmaze-labs/mountain | mountain/rsyslog/views.py | Python | mit | 2,967 |
"""SCons.Tool.filesystem
Tool-specific initialization for the filesystem tools.
There normally shouldn't be any need to import this module directly.
It will usually be imported through the generic SCons.Tool.Tool()
selection method.
"""
#
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009... | kerwinxu/barcodeManager | zxing/cpp/scons/scons-local-2.0.0.final.0/SCons/Tool/filesystem.py | Python | bsd-2-clause | 3,577 |
"""
.. module:: Image
:synopsis: A image database model.
.. moduleauthor:: Dan Schlosser <dan@schlosser.io>
"""
import re
import os
from datetime import datetime
from flask import url_for, current_app
from mongoengine import (Document, DateTimeField, StringField, ReferenceField,
signals)... | danrschlosser/eventum | eventum/models/Image.py | Python | mit | 3,940 |
from jsonrpc import ServiceProxy
import sys
import string
# ===== BEGIN USER SETTINGS =====
# if you do not set these you will be prompted for a password for every command
rpcuser = ""
rpcpass = ""
# ====== END USER SETTINGS ======
if rpcpass == "":
access = ServiceProxy("http://127.0.0.1:9332")
else:
access = Ser... | juanbond/doctorcoin | contrib/bitrpc/bitrpc.py | Python | mit | 7,842 |
from django.conf.urls import url
from .views import HomePageView
urlpatterns = [
url(r'^$', HomePageView.as_view(), name='homepage'),
]
| mittya/duoclub | duoclub/homepage/urls.py | Python | mit | 143 |
## This file is part of Invenio.
## Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 CERN.
##
## Invenio 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
... | egabancho/invenio | invenio/legacy/websearch/adminlib.py | Python | gpl-2.0 | 165,793 |
# -*- coding: utf-8 -*-
import os.path
import django
from django.core.management import call_command
def main(manifest_path):
basedir = os.path.dirname(manifest_path)
with open(manifest_path, 'r') as manifest:
for fixture_name in manifest:
fixture_path = os.path.join(basedir, fixture_nam... | emencia/dr-dump | drdump/load.py | Python | mit | 715 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
List Object based on SCALA List
using functional programming principles
"""
from functools import reduce
import numpy
class List():
def __init__(self, lst):
self.lst = lst
def copy(self):
return List(self.lst.copy())
def all(self):
... | caiorss/m2py | pyhof/List.py | Python | bsd-3-clause | 1,820 |
#! /usr/bin/env python
import numpy as np
from numpy.testing import assert_array_equal
import landlab.utils.structured_grid as sgrid
from landlab.grid.nodestatus import NodeStatus
def test_node_x_2d():
(x, _) = sgrid.node_coords((3, 2))
assert_array_equal(x, np.array([0.0, 1.0, 0.0, 1.0, 0.0, 1.0]))
def ... | landlab/landlab | tests/utils/test_structured_grid.py | Python | mit | 26,443 |
def add(a, b):
if b == 0: return a
sum = a ^ b
carry = (a & b) << 1
return add(sum, carry)
print add(100, 23)
| linyaoli/acm | others/intermediate/add_two_numbers_without_operator.py | Python | gpl-2.0 | 126 |
import datetime
import struct
import logging
import numpy as np
import os
import time
import re
import pytz
import scipy.spatial.distance as distance
from tzlocal import get_localzone
import warnings
def get_filename_meta_data(fn):
"""
This function retrieves the meta information from a filename given the typ... | kevroy314/msl-iposition-pipeline | cogrecon/core/data_flexing/time_travel_task/time_travel_task_binary_reader.py | Python | gpl-3.0 | 41,651 |
from cupy.random import distributions
from cupy.random import generator
def rand(*size, **kwarg):
"""Returns an array of uniform random values over the interval ``[0, 1)``.
Each element of the array is uniformly distributed on the half-open
interval ``[0, 1)``. All elements are identically and independen... | cemoody/chainer | cupy/random/sample.py | Python | mit | 4,357 |
# Copyright 2011 OpenStack Foundation
# 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 requ... | OpenAcademy-OpenStack/nova-scheduler | nova/api/openstack/compute/limits.py | Python | apache-2.0 | 16,526 |
#!/usr/bin/env python3
import logging
import math
# from binascii import unhexlify
from struct import unpack
log = logging.getLogger("protocol_helpers")
def crc8(byteData):
"""
Generate 8 bit CRC of supplied string
"""
CRC = 0
# for j in range(0, len(str),2):
for b in byteData:
# cha... | jblance/mpp-solar | mppsolar/protocols/protocol_helpers.py | Python | mit | 9,335 |
#!/usr/bin/env python
#
# NuGet packaging script.
# Assembles a NuGet package using CI artifacts in S3
# and calls nuget (in docker) to finalize the package.
#
import sys
import re
import os
import tempfile
import shutil
import subprocess
import urllib
from fnmatch import fnmatch
from string import Template
from colle... | LiberatorUSA/GUCEF | dependencies/librdkafka/packaging/nuget/packaging.py | Python | apache-2.0 | 19,011 |
#
# 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
# distributed under... | tengqm/senlin-container | senlin/tests/tempest_tests/config.py | Python | apache-2.0 | 1,284 |
## TRACK FIXER##
# @file fixTracks.py
# @brief Tries to fix gaps in tracks, both small and large (very slow with higher settings)
## For MCEdit / Python 3
## Alpha ver. 0.2.4
## by Garrett Martin (GDroidbot)
## Changelog:
#0.2: Added optional trackbed laying
#0.2.4: Fixed bugs about trackbed
# Based off of SethBl... | GMart/GMart.github.io | fixTracks0.2.4.py | Python | gpl-2.0 | 5,705 |
#!/usr/bin/python2.4
#
# Copyright 2010 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 ... | IevgenPr/gsa-admin-toolkit | connectormanager/smb_connector.py | Python | apache-2.0 | 2,948 |
from django.contrib.sites.models import Site
from django.db.utils import IntegrityError
from django.test import TestCase
from django.template import Context, Template
from simpleblocks.models import SimpleBlock
def render_to_string(template, data):
t = Template(template)
c = Context(data)
return t.render... | alfredo/django-simpleblocks | src/simpleblocks/tests.py | Python | bsd-3-clause | 1,975 |
# Copyright 2011 OpenStack Foundation
# 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 requ... | Thingee/cinder | cinder/tests/scheduler/test_scheduler_options.py | Python | apache-2.0 | 5,061 |
# (c) 2015, Andrew Gaffney <andrew@agaffney.org>
#
# 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 ve... | hfinucane/ansible | lib/ansible/plugins/callback/actionable.py | Python | gpl-3.0 | 2,532 |
from setuptools import setup, find_packages
import os
version = '1.3.0'
setup(name='collective.webservicespfgadapter',
version=version,
description="PloneFormGen adapter that sends the form submission \
to a web service",
long_description=open("README.md").read() + "\n" +
... | PSUEducationalEquity/collective.webservicespfgadapter | setup.py | Python | bsd-3-clause | 1,153 |
from givens_step import *
from ortho_basis import *
try:
from test import *
except ImportError:
pass | apatil/covariance-prior | cov_prior/__init__.py | Python | mit | 108 |
#!/usr/bin/env python
import os
import shutil
import glob
import time
import sys
import subprocess
import string
from optparse import OptionParser, make_option
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
PKG_NAME = os.path.basename(SCRIPT_DIR)
PARAMETERS = None
#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=... | yugang/crosswalk-test-suite | webapi/tct-widgetpolicy-w3c-tests/inst.wgt.py | Python | bsd-3-clause | 6,719 |
import numpy as n
import scipy.interpolate
import scipy.ndimage
def congrid(a, newdims, method='linear', centre=False, minusone=False):
'''Arbitrary resampling of source array to new dimension sizes.
Currently only supports maintaining the same number of dimensions.
To use 1-D arrays, first promote them to... | gsnyder206/synthetic-image-morph | congrid.py | Python | gpl-2.0 | 3,937 |
import boto3
DEFAULTS = {
"region_name": "ap-southeast-2" # Sydney
}
def status_code(ret):
return ret["ResponseMetadata"]["HTTPStatusCode"]
class Rekognition():
def __init__(self, profile, region=DEFAULTS["region_name"]):
self.profile = profile
self.region_name = region
self.cl... | kyhau/reko | reko/rekognition.py | Python | mit | 4,130 |
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------... | Azure/azure-sdk-for-python | sdk/eventgrid/azure-eventgrid/azure/eventgrid/_constants.py | Python | mit | 548 |
from django.contrib import admin
from .models import ServiceName, Song, BookName, ParshaName, TorahReading, HaftarahReading, AlternateBookName, AlternateParshaName
# class AuthorAdmin(admin.ModelAdmin):
# list_display = ('first_name', 'last_name', 'email')
class ServiceNameAdmin(admin.ModelAdmin):
list_displ... | brentd-smith/smolkinsite | songs/admin.py | Python | gpl-3.0 | 2,014 |
#!/usr/bin/env python
import setuptools
if __name__ == "__main__":
setuptools.setup(name="pyrcrack")
| XayOn/pyrcrack | setup.py | Python | isc | 107 |
# -*- coding: utf-8 -*-
"""
test_utils
----------
Tests for `feedsqueeze.utils` module.
"""
import sys
if sys.version_info[:2] < (2, 7):
import unittest2 as unittest
else:
import unittest
from feedsqueeze import utils
from feedsqueeze.exceptions import FeedFileDoesNotExist
class TestUtils(unittest.TestCase... | jonyamo/feedsqueeze | tests/test_utils.py | Python | bsd-3-clause | 1,263 |
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# TH... | wunderlins/learning | python/zodb/lib/osx/ZODB/POSException.py | Python | gpl-2.0 | 12,347 |
# coding=utf-8
import numpy as np
from qtpy import QtWidgets, QtCore
# OWN
from dataArtist.widgets.Tool import Tool
class ZoomTo(Tool):
'''
Zoom to a certain area that fulfils a given criterion
'''
icon = 'find.svg'
def __init__(self, imageDisplay):
Tool.__init__(self, imageDisplay)
... | radjkarl/dataArtist | dataArtist/figures/image/tools/filter/ZoomTo.py | Python | gpl-3.0 | 3,315 |
#!/usr/bin/python
from distutils.core import setup
setup(
# Basic package information.
name = 'hipchat',
version = '0.0.0',
packages = ['hipchat'],
include_package_data = True,
install_requires = ['httplib2', 'simplejson'],
url = 'https://github.com/alexcchan/hipchat/tree/master',
keywords = 'hipchat api',
d... | alexcchan/hipchat | setup.py | Python | mit | 600 |
"""
Cinder configuration - file ``/etc/cinder/cinder.conf``
=======================================================
The Cinder configuration file is a standard '.ini' file and this parser uses
the ``IniConfigFile`` class to read it.
Sample configuration::
[DEFAULT]
rpc_backend=cinder.openstack.common.rpc.imp... | PaulWay/insights-core | insights/parsers/cinder_conf.py | Python | apache-2.0 | 1,823 |
import json
from imhotep.testing_utils import fixture_path, Requester
from imhotep.shas import CommitInfo, PRInfo, get_pr_info
# via https://api.github.com/repos/justinabrahms/imhotep/pulls/10
with open(fixture_path('remote_pr.json')) as f:
remote_json_fixture = json.loads(f.read())
# via https://api.github.com... | Appdynamics/imhotep | imhotep/shas_test.py | Python | mit | 2,368 |
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Francesco Apruzzese
# Copyright 2015 Apulia Software srl
# Copyright 2015 Lorenzo Battistini - Agile Business Group
#
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
#
####... | scigghia/l10n-italy | l10n_it_ddt/tests/test_ddt.py | Python | agpl-3.0 | 8,583 |
"""Tasks related to projects, including fetching repository code, cleaning
``conf.py`` files, and rebuilding documentation.
"""
import fnmatch
import os
import shutil
import json
import logging
import socket
import requests
from celery import task
from django.conf import settings
from django.core.urlresolvers import r... | frodopwns/readthedocs.org | readthedocs/projects/tasks.py | Python | mit | 33,386 |
from app import db
from app.models import ContactGroup, Gender, Contact
import random
from datetime import datetime
def get_random_name(names_list, size=1):
name_lst = [names_list[random.randrange(0, len(names_list))].capitalize() for i in range(0, size)]
return " ".join(name_lst)
try:
db.session.add(Co... | rpiotti/Flask-AppBuilder | examples/user_registration/testdata.py | Python | bsd-3-clause | 1,431 |
import os
from django.core.files import File
from django.core.files.base import ContentFile
from django.test import TestCase
from . import models
class TestOverwriteStorage(TestCase):
def setUp(self):
self.text_file1 = "tests/data/text_file1.txt"
self.text_file2 = "tests/data/text_file2.txt"
... | ckot/django-overwrite-storage | tests/tests.py | Python | mit | 6,321 |
from __future__ import absolute_import, print_function, unicode_literals
from builtins import dict, str
from indra.statements import *
from indra.belief import BeliefEngine
from indra.belief import _get_belief_package
ev1 = Evidence(source_api='reach')
ev2 = Evidence(source_api='trips')
ev3 = Evidence(source_api='asse... | jmuhlich/indra | indra/tests/test_belief_engine.py | Python | bsd-2-clause | 5,746 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Xibo - Digitial Signage - http://www.xibo.org.uk
# Copyright (C) 2009-13 Alex Harrington
#
# This file is part of Xibo.
#
# Xibo 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... | xibosignage/xibo-pyclient | plugins/media/LocalvideoMedia.py | Python | agpl-3.0 | 1,501 |
#!/usr/bin/env python
import bohrium as np
from bohrium import visualization
a = np.ones((100,100))
visualization.plot_surface(a)
| Ektorus/bohrium | ve/cpu/tools/vizviz.py | Python | lgpl-3.0 | 131 |
# -*- coding: utf-8 -*-
#
# This file is part of CERN Analysis Preservation Framework.
# Copyright (C) 2018 CERN.
#
# CERN Analysis Preservation Framework 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... | pamfilos/data.cern.ch | cap/modules/services/views/zenodo.py | Python | gpl-2.0 | 2,719 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = 'Fabien Poussin'
__version__ = '0.3'
from xml.etree import ElementTree as etree
from jinja2 import Template
from os.path import expanduser, sep, dirname, abspath
from argparse import ArgumentParser
from traceback import print_exc
import re
import pprint
pretty_... | netik/dc26_spqr_badge | sw/firmware/ChibiOS-Contrib/tools/mx2board.py | Python | apache-2.0 | 12,105 |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2016-01-08 16:29
from __future__ import unicode_literals
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('products', '0035_auto_20160102_1442'),
]
operations... | n2o/guhema | products/migrations/0036_hacksawblade.py | Python | mit | 856 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.